BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
TofID.cxx
Go to the documentation of this file.
1#include "Identifier/TofID.h"
2#include <assert.h>
3#include <iostream>
4
5
7}
8
10}
11
12//----------------------------------------------------------------------------
13bool TofID::values_ok ( const unsigned int barrel_ec,
14 const unsigned int layer,
15 const unsigned int phi_module,
16 const unsigned int end
17 ) {
18 if ( barrel_ec > BARREL_EC_MAX ) return false;
19 if ( BARREL_EC_MIN == barrel_ec || BARREL_EC_MIN == barrel_ec) {
20 if ( layer > LAYER_ENDCAP_MAX ) return false;
21 }
22 else {
23 if ( layer > LAYER_BARREL_MAX ) return false;
24 }
25 if( end > 1 ) return false;
26
27 return true;
28}
29
30
31//-----------------------------------------------------------------------------
32bool TofID::values_ok ( const unsigned int barrel_ec,
33 const unsigned int endcap,
34 const unsigned int module,
35 const unsigned int strip,
36 const unsigned int end
37 ) {
38 if( barrel_ec != BARREL_EC_MRPC ) return false;
39 if( endcap > ENDCAP_MRPC_MAX ) return false;
40 if( module > MODULE_MRPC_MAX ) return false;
41 if( strip > STRIP_MRPC_MAX ) return false;
42 if( end > 1 ) return false;
43
44 return true;
45}
46
47
48//----------------------------------------------------------------------------
49bool TofID::is_barrel (const Identifier& id) {
50 unsigned int pos = (id.get_value() & TofID::BARREL_EC_MASK) >> TofID::BARREL_EC_INDEX;
51 return (pos == BARREL_EC_MAX || pos == BARREL_EC_MIN || pos == BARREL_EC_MRPC) ? false : true;
52}
53
54
55bool TofID::is_barrel (const unsigned int barrel_ec) {
56 return (barrel_ec == BARREL_EC_MAX || barrel_ec == BARREL_EC_MIN || barrel_ec == BARREL_EC_MRPC) ? false : true;
57}
58
59
60//----------------------------------------------------------------------------
61int TofID::barrel_ec (const Identifier& id ) {
62 return ((id.get_value() & TofID::BARREL_EC_MASK) >> TofID::BARREL_EC_INDEX);
63}
64
65//----------------------------------------------------------------------------
66int TofID::layer (const Identifier& id) {
67 if( ( TofID::is_mrpc( id ) ) ) { return -999; }
68 return ((id.get_value() & TofID::LAYER_MASK) >> TofID::LAYER_INDEX);
69}
70
71
72//----------------------------------------------------------------------------
74 if( ( TofID::is_mrpc( id ) ) ) { return -999; }
75 return ((id.get_value() & TofID::PHI_MASK) >> TofID::PHI_INDEX);
76}
77
78//----------------------------------------------------------------------------
79int TofID::end(const Identifier& id) {
80 return ((id.get_value() & TofID::END_MASK) >> TofID::END_INDEX);
81}
82
83//----------------------------------------------------------------------------
85 if (is_barrel(id)) {
86 return LAYER_BARREL_MAX;
87 } else {
88 return LAYER_ENDCAP_MAX;
89 }
90}
91
92//----------------------------------------------------------------------------
94 if (is_barrel(id)) {
95 return PHI_BARREL_MAX;
96 } else {
97 return PHI_ENDCAP_MAX;
98 }
99}
100
101//----------------------------------------------------------------------------
102bool TofID::is_scin( const Identifier& id ) {
103 unsigned int pos = (id.get_value() & TofID::BARREL_EC_MASK) >> TofID::BARREL_EC_INDEX;
104 return (pos == BARREL_EC_MRPC) ? false : true;
105}
106
107
108bool TofID::is_scin(const unsigned int barrel_ec ) {
109 return (barrel_ec < BARREL_EC_MRPC) ? true : false;
110}
111
112//----------------------------------------------------------------------------
113bool TofID::is_mrpc( const Identifier& id ) {
114 unsigned int pos = (id.get_value() & TofID::BARREL_EC_MASK) >> TofID::BARREL_EC_INDEX;
115 return (pos == BARREL_EC_MRPC) ? true : false;
116}
117
118
119bool TofID::is_mrpc(const unsigned int barrel_ec ) {
120 return (barrel_ec == BARREL_EC_MRPC) ? true : false;
121}
122
123//----------------------------------------------------------------------------
124int TofID::endcap( const Identifier& id ) {
125 if( ( TofID::is_scin( id ) ) ) { return -999; }
126 return ((id.get_value() & TofID::ENDCAP_MASK) >> TofID::ENDCAP_INDEX);
127}
128
129//----------------------------------------------------------------------------
130int TofID::module( const Identifier& id ) {
131 if( ( TofID::is_scin( id ) ) ) { return -999; }
132 return ((id.get_value() & TofID::MODULE_MASK) >> TofID::MODULE_INDEX);
133}
134
135//----------------------------------------------------------------------------
136int TofID::strip( const Identifier& id ) {
137 if( ( TofID::is_scin( id ) ) ) { return -999; }
138 return ((id.get_value() & TofID::STRIP_MASK) >> TofID::STRIP_INDEX);
139}
140
141
142//----------------------------------------------------------------------------
144 int layer,
145 int phi_module,
146 int end
147 ) {
148 assert ( values_ok(barrel_ec, layer, phi_module, end) );
149 unsigned int value = (BesDetectorID::TOF_ID << TOF_INDEX) |
150 (barrel_ec << BARREL_EC_INDEX)|
151 (layer << LAYER_INDEX) | (phi_module << PHI_INDEX) |
152 (end << END_INDEX);
153 return Identifier(value);
154}
155
156
158 return Identifier(value);
159}
160
161
162//----------------------------------------------------------------------------
164 int endcap,
165 int module,
166 int strip,
167 int end
168 ) {
169 assert ( values_ok(barrel_ec, endcap, module, strip, end) );
170 unsigned int value = (BesDetectorID::TOF_ID << TOF_INDEX) |
171 (barrel_ec << BARREL_EC_INDEX)|
172 (endcap << ENDCAP_INDEX) | (module << MODULE_INDEX) |
173 (strip << STRIP_INDEX) | (end << END_INDEX);
174 return Identifier(value);
175}
176
177//----------------------------------------------------------------------------
178unsigned int TofID::getIntID ( int barrel_ec,
179 int layer,
180 int phi_module,
181 int end
182 )
183{
184 unsigned int value = (BesDetectorID::TOF_ID << TOF_INDEX) |
185 (barrel_ec << BARREL_EC_INDEX)|
186 (layer << LAYER_INDEX) | (phi_module << PHI_INDEX) |
187 (end << END_INDEX);
188 return value;
189}
190
191
192//----------------------------------------------------------------------------
193unsigned int TofID::getIntID ( int barrel_ec,
194 int endcap,
195 int module,
196 int strip,
197 int end
198 ) {
199 unsigned int value = (BesDetectorID::TOF_ID << TOF_INDEX) |
200 (barrel_ec << BARREL_EC_INDEX)|
201 (endcap << ENDCAP_INDEX) | (module << MODULE_INDEX) |
202 (strip << STRIP_INDEX) | (end << END_INDEX);
203 return value;
204}
205
206
208{
209 return LAYER_BARREL_MAX;
210}
211
213{
214 return LAYER_ENDCAP_MAX;
215}
216
218{
219 return PHI_BARREL_MAX;
220}
221
223{
224 return PHI_ENDCAP_MAX;
225}
227{
228 return BARREL_EC_MAX;
229}
230
232{
233 return BARREL_EC_MIN;
234}
235
237{
238 return BARREL_EC_MRPC;
239}
240
242{
243 return ENDCAP_MRPC_MAX;
244}
245
247{
248 return MODULE_MRPC_MAX;
249}
250
252{
253 return STRIP_MRPC_MAX;
254}
static int endcap(const Identifier &id)
Definition: TofID.cxx:124
static int strip(const Identifier &id)
Definition: TofID.cxx:136
static Identifier cell_id(int barrel_ec, int layer, int phi_module, int end)
For a single crystal.
Definition: TofID.cxx:143
static value_type getENDCAP_MRPC_MAX()
Definition: TofID.cxx:241
static bool is_scin(const Identifier &id)
Definition: TofID.cxx:102
~TofID()
destructor
Definition: TofID.cxx:9
static value_type getMODULE_MRPC_MAX()
Definition: TofID.cxx:246
static bool values_ok(const unsigned int barrel_ec, const unsigned int layer, const unsigned int phi_module, const unsigned int end)
Definition: TofID.cxx:13
static int end(const Identifier &id)
Definition: TofID.cxx:79
static value_type getPHI_BARREL_MAX()
Definition: TofID.cxx:217
static value_type getPHI_ENDCAP_MAX()
Definition: TofID.cxx:222
static value_type getSTRIP_MRPC_MAX()
Definition: TofID.cxx:251
static value_type getBARREL_EC_MIN()
Definition: TofID.cxx:231
static value_type getBARREL_EC_MAX()
Definition: TofID.cxx:226
static bool is_barrel(const Identifier &id)
Test for barrel.
Definition: TofID.cxx:49
TofID()
constructor
Definition: TofID.cxx:6
static bool is_mrpc(const Identifier &id)
Definition: TofID.cxx:113
static int phi_module(const Identifier &id)
Definition: TofID.cxx:73
static int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
Definition: TofID.cxx:61
int phi_module_max(const Identifier &id)
Max/Min values for each field (error returns -999)
Definition: TofID.cxx:93
static value_type getLAYER_ENDCAP_MAX()
Definition: TofID.cxx:212
static value_type getBARREL_EC_MRPC()
Definition: TofID.cxx:236
static value_type getIntID(int barrel_ec, int layer, int phi_module, int end)
Definition: TofID.cxx:178
static int layer(const Identifier &id)
Definition: TofID.cxx:66
int layer_max(const Identifier &id)
Definition: TofID.cxx:84
static int module(const Identifier &id)
Definition: TofID.cxx:130
static value_type getLAYER_BARREL_MAX()
Definition: TofID.cxx:207