BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
MucID.cxx
Go to the documentation of this file.
1#include "Identifier/MucID.h"
2#include <assert.h>
3
4const unsigned int MucID::CHANNEL_BARREL_LAYER_NUM[MucID::LAYER_BARREL_NUM] =
5 {64,112,64,112,64,112,64,112,64}; // change 96 to 112. 2006.10.20
6
8}
9
11}
12
13//----------------------------------------------------------------------------
14bool MucID::values_ok ( const unsigned int barrel_ec,
15 const unsigned int segment,
16 const unsigned int layer,
17 const unsigned int channel
18 ) {
19 // Check values
20 if ( barrel_ec >= BARREL_EC_NUM ) return false;
21 if ( barrel_ec == 0 || barrel_ec == BARREL_EC_NUM - 1 ) {
22 if ( segment >= SEGMENT_ENDCAP_NUM ) return false;
23 if ( layer >= LAYER_ENDCAP_NUM ) return false;
24 if ( channel >= CHANNEL_ENDCAP_NUM_MAX ) return false;
25 }
26 else {
27 if ( segment >= SEGMENT_BARREL_NUM ) return false;
28 if ( layer >= LAYER_BARREL_NUM ) return false;
29 if ( channel >= CHANNEL_BARREL_LAYER_NUM[layer] ) return false;
30 }
31 return true;
32}
33
34//----------------------------------------------------------------------------
35bool MucID::is_barrel (const Identifier& id) {
36 unsigned int pos = (id.get_value() & MucID::BARREL_EC_MASK) >> MucID::BARREL_EC_INDEX;
37 return (pos == 0 || pos == BARREL_EC_NUM - 1) ? false : true;
38}
39
40//----------------------------------------------------------------------------
42 return ((id.get_value() & MucID::BARREL_EC_MASK) >> MucID::BARREL_EC_INDEX);
43}
44
45//----------------------------------------------------------------------------
46int MucID::part (const Identifier& id) {
47 return ((id.get_value() & MucID::BARREL_EC_MASK) >> MucID::BARREL_EC_INDEX);
48}
49
50//----------------------------------------------------------------------------
51int MucID::segment (const Identifier& id) {
52 return (id.get_value() & MucID::SEGMENT_MASK) >> MucID::SEGMENT_INDEX;
53}
54
55//----------------------------------------------------------------------------
56int MucID::seg (const Identifier& id) {
57 return (id.get_value() & MucID::SEGMENT_MASK) >> MucID::SEGMENT_INDEX;
58}
59
60//----------------------------------------------------------------------------
61int MucID::layer (const Identifier& id) {
62 return (id.get_value() & MucID::LAYER_MASK) >> MucID::LAYER_INDEX;
63}
64
65//----------------------------------------------------------------------------
66int MucID::gap (const Identifier& id) {
67 return (id.get_value() & MucID::LAYER_MASK) >> MucID::LAYER_INDEX;
68}
69
70//----------------------------------------------------------------------------
71int MucID::channel (const Identifier& id) {
72 return (id.get_value() & MucID::CHANNEL_MASK) >> MucID::CHANNEL_INDEX;
73}
74
75//----------------------------------------------------------------------------
76int MucID::strip (const Identifier& id) {
77 return (id.get_value() & MucID::CHANNEL_MASK) >> MucID::CHANNEL_INDEX;
78}
79
80//----------------------------------------------------------------------------
82 if (is_barrel(id)) {
83 return SEGMENT_BARREL_NUM - 1;
84 } else {
85 return SEGMENT_ENDCAP_NUM - 1;
86 }
87}
88
89//----------------------------------------------------------------------------
91 if (is_barrel(id)) {
92 return SEGMENT_BARREL_NUM;
93 } else {
94 return SEGMENT_ENDCAP_NUM;
95 }
96}
97
98//----------------------------------------------------------------------------
100 if (this->is_barrel(id)) {
101 return LAYER_BARREL_NUM - 1;
102 } else {
103 return LAYER_ENDCAP_NUM - 1;
104 }
105}
106
107//----------------------------------------------------------------------------
109 if (this->is_barrel(id)) {
110 return LAYER_BARREL_NUM;
111 } else {
112 return LAYER_ENDCAP_NUM;
113 }
114}
115
116//----------------------------------------------------------------------------
118 if (this->is_barrel(id)) {
119 return CHANNEL_BARREL_NUM_MAX - 1;
120 } else {
121 return CHANNEL_ENDCAP_NUM_MAX - 1;
122 }
123}
124
125//----------------------------------------------------------------------------
127 if (this->is_barrel(id)) {
128 return CHANNEL_BARREL_LAYER_NUM[this->gap(id)];
129 } else {
130 return CHANNEL_ENDCAP_NUM_MAX;
131 }
132}
133
134//----------------------------------------------------------------------------
136 int segment,
137 int layer,
138 int channel
139 ) {
140 assert ( values_ok(barrel_ec, segment, layer, channel) );
141 value_type value = (MUC_ID << MUC_INDEX) | (barrel_ec << BARREL_EC_INDEX)|
142 (segment << SEGMENT_INDEX) | (layer << LAYER_INDEX) | (channel << CHANNEL_INDEX);
143 return Identifier(value);
144}
145
146//----------------------------------------------------------------------------
147unsigned int MucID::getIntID ( int barrel_ec,
148 int segment,
149 int layer,
150 int channel
151 ) {
152 value_type value = (MUC_ID << MUC_INDEX) | (barrel_ec << BARREL_EC_INDEX)|
153 (segment << SEGMENT_INDEX) | (layer << LAYER_INDEX) | (channel << CHANNEL_INDEX);
154 return value;
155
156}
157
158//---------------------------------------------------------------------------
159unsigned int MucID::getPartNum(){
160 return BARREL_EC_NUM;
161}
162
163///---------------------------------------------------------------------------
164unsigned int MucID::getSegNum( int part ) {
165 if (part == 1) return SEGMENT_BARREL_NUM;
166 else if (part == 0 || part == 2) return SEGMENT_ENDCAP_NUM;
167 else return 0;
168}
169
170//----------------------------------------------------------------------------
171unsigned int MucID::getGapNum( int part ) {
172 if (part == 1) return LAYER_BARREL_NUM;
173 if (part == 0 || part == 2) return LAYER_ENDCAP_NUM;
174 else return 0;
175}
176
177//----------------------------------------------------------------------------
178unsigned int MucID::getStripNum (int part, int seg, int gap) {
179 if (part == 1) {
180 if (seg == 2) return CHANNEL_BARREL_LAYER_NUM[gap];
181 else return CHANNEL_BARREL_LAYER_NUM[gap];
182 } else {
183 return CHANNEL_ENDCAP_NUM_MAX;
184 }
185}
186
187///---------------------------------------------------------------------------
188unsigned int MucID::getSegMax() {
189 if (SEGMENT_BARREL_NUM > SEGMENT_ENDCAP_NUM) return SEGMENT_BARREL_NUM;
190 else return SEGMENT_ENDCAP_NUM;
191}
192
193///---------------------------------------------------------------------------
194
195unsigned int MucID::getGapMax() {
196 if (LAYER_BARREL_NUM > LAYER_ENDCAP_NUM) return LAYER_BARREL_NUM;
197 else return LAYER_ENDCAP_NUM;
198}
199
200unsigned int MucID::getStripMax() {
201 if (CHANNEL_BARREL_NUM_MAX > CHANNEL_ENDCAP_NUM_MAX) return CHANNEL_BARREL_NUM_MAX;
202 else return CHANNEL_ENDCAP_NUM_MAX;
203}
204
205//---------------------------------------------------------------------------
207 return SEGMENT_BARREL_NUM - 1;
208}
209
210//---------------------------------------------------------------------------
212 return SEGMENT_ENDCAP_NUM - 1;
213}
214
215//---------------------------------------------------------------------------
217 return LAYER_BARREL_NUM - 1;
218}
219
220//---------------------------------------------------------------------------
222 return LAYER_ENDCAP_NUM - 1;
223}
224
225//---------------------------------------------------------------------------
227 return CHANNEL_BARREL_NUM_MAX;
228}
229
230//---------------------------------------------------------------------------
232 return CHANNEL_ENDCAP_NUM_MAX;
233}
234
235//---------------------------------------------------------------------------
237 return BARREL_EC_NUM - 1;
238}
239
240//---------------------------------------------------------------------------
242 return 0;
243}
static const unsigned int MUC_ID
Definition: BesDetectorID.h:78
static const unsigned int MUC_INDEX
Definition: BesDetectorID.h:79
static int barrel_ec(const Identifier &id)
Values of different levels.
Definition: MucID.cxx:41
static value_type getStripMax()
Definition: MucID.cxx:200
static value_type getIntID(int barrel_ec, int segment, int layer, int channel)
Definition: MucID.cxx:147
static int layer(const Identifier &id)
Definition: MucID.cxx:61
static bool values_ok(const unsigned int barrel_ec, const unsigned int segment, const unsigned int layer, const unsigned int channel)
Definition: MucID.cxx:14
static int channel(const Identifier &id)
Definition: MucID.cxx:71
static value_type getSEGMENT_BARREL_MAX()
Definition: MucID.cxx:206
int segment_max(const Identifier &id)
Max/Min values for each field.
Definition: MucID.cxx:81
static int part(const Identifier &id)
Definition: MucID.cxx:46
static value_type getGapMax()
Definition: MucID.cxx:195
static int segment(const Identifier &id)
Definition: MucID.cxx:51
static value_type getBARREL_EC_MAX()
Definition: MucID.cxx:236
static value_type getPartNum()
Definition: MucID.cxx:159
static Identifier channel_id(int barrel_ec, int segment, int layer, int channel)
For a single crystal.
Definition: MucID.cxx:135
Identifier::value_type value_type
Definition: MucID.h:12
int layer_max(const Identifier &id)
Definition: MucID.cxx:99
~MucID()
destructor
Definition: MucID.cxx:10
static value_type getSegMax()
Definition: MucID.cxx:188
static value_type getSEGMENT_ENDCAP_MAX()
Definition: MucID.cxx:211
static value_type getLAYER_BARREL_MAX()
Definition: MucID.cxx:216
static bool is_barrel(const Identifier &id)
Test for barrel.
Definition: MucID.cxx:35
static int gap(const Identifier &id)
Definition: MucID.cxx:66
static int seg(const Identifier &id)
Definition: MucID.cxx:56
static value_type getLAYER_ENDCAP_MAX()
Definition: MucID.cxx:221
static value_type getBARREL_EC_MIN()
Definition: MucID.cxx:241
MucID()
constructor
Definition: MucID.cxx:7
static value_type getSegNum(int part)
Definition: MucID.cxx:164
static value_type getStripNum(int part, int seg, int gap)
Definition: MucID.cxx:178
static value_type getCHANNEL_BARREL_MAX()
Definition: MucID.cxx:226
static int strip(const Identifier &id)
Definition: MucID.cxx:76
static value_type getGapNum(int part)
Definition: MucID.cxx:171
int channel_max(const Identifier &id)
Definition: MucID.cxx:117
static value_type getCHANNEL_ENDCAP_MAX()
Definition: MucID.cxx:231