BOSS 8.0.0
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
7MucID::MucID( void ) {}
8
9MucID::~MucID( void ) {}
10
11//----------------------------------------------------------------------------
12bool MucID::values_ok( const unsigned int barrel_ec, const unsigned int segment,
13 const unsigned int layer, const unsigned int channel ) {
14 // Check values
15 if ( barrel_ec >= BARREL_EC_NUM ) return false;
16 if ( barrel_ec == 0 || barrel_ec == BARREL_EC_NUM - 1 )
17 {
18 if ( segment >= SEGMENT_ENDCAP_NUM ) return false;
19 if ( layer >= LAYER_ENDCAP_NUM ) return false;
20 if ( channel >= CHANNEL_ENDCAP_NUM_MAX ) return false;
21 }
22 else
23 {
24 if ( segment >= SEGMENT_BARREL_NUM ) return false;
25 if ( layer >= LAYER_BARREL_NUM ) return false;
26 if ( channel >= CHANNEL_BARREL_LAYER_NUM[layer] ) return false;
27 }
28 return true;
29}
30
31//----------------------------------------------------------------------------
32bool MucID::is_barrel( const Identifier& id ) {
33 unsigned int pos = ( id.get_value() & MucID::BARREL_EC_MASK ) >> MucID::BARREL_EC_INDEX;
34 return ( pos == 0 || pos == BARREL_EC_NUM - 1 ) ? false : true;
35}
36
37//----------------------------------------------------------------------------
38int MucID::barrel_ec( const Identifier& id ) {
39 return ( ( id.get_value() & MucID::BARREL_EC_MASK ) >> MucID::BARREL_EC_INDEX );
40}
41
42//----------------------------------------------------------------------------
43int MucID::part( const Identifier& id ) {
44 return ( ( id.get_value() & MucID::BARREL_EC_MASK ) >> MucID::BARREL_EC_INDEX );
45}
46
47//----------------------------------------------------------------------------
48int MucID::segment( const Identifier& id ) {
49 return ( id.get_value() & MucID::SEGMENT_MASK ) >> MucID::SEGMENT_INDEX;
50}
51
52//----------------------------------------------------------------------------
53int MucID::seg( const Identifier& id ) {
54 return ( id.get_value() & MucID::SEGMENT_MASK ) >> MucID::SEGMENT_INDEX;
55}
56
57//----------------------------------------------------------------------------
58int MucID::layer( const Identifier& id ) {
59 return ( id.get_value() & MucID::LAYER_MASK ) >> MucID::LAYER_INDEX;
60}
61
62//----------------------------------------------------------------------------
63int MucID::gap( const Identifier& id ) {
64 return ( id.get_value() & MucID::LAYER_MASK ) >> MucID::LAYER_INDEX;
65}
66
67//----------------------------------------------------------------------------
68int MucID::channel( const Identifier& id ) {
69 return ( id.get_value() & MucID::CHANNEL_MASK ) >> MucID::CHANNEL_INDEX;
70}
71
72//----------------------------------------------------------------------------
73int MucID::strip( const Identifier& id ) {
74 return ( id.get_value() & MucID::CHANNEL_MASK ) >> MucID::CHANNEL_INDEX;
75}
76
77//----------------------------------------------------------------------------
79 if ( is_barrel( id ) ) { return SEGMENT_BARREL_NUM - 1; }
80 else { return SEGMENT_ENDCAP_NUM - 1; }
81}
82
83//----------------------------------------------------------------------------
84int MucID::getSegNum( const Identifier& id ) {
85 if ( is_barrel( id ) ) { return SEGMENT_BARREL_NUM; }
86 else { return SEGMENT_ENDCAP_NUM; }
87}
88
89//----------------------------------------------------------------------------
90int MucID::layer_max( const Identifier& id ) {
91 if ( this->is_barrel( id ) ) { return LAYER_BARREL_NUM - 1; }
92 else { return LAYER_ENDCAP_NUM - 1; }
93}
94
95//----------------------------------------------------------------------------
96int MucID::getGapNum( const Identifier& id ) {
97 if ( this->is_barrel( id ) ) { return LAYER_BARREL_NUM; }
98 else { return LAYER_ENDCAP_NUM; }
99}
100
101//----------------------------------------------------------------------------
103 if ( this->is_barrel( id ) ) { return CHANNEL_BARREL_NUM_MAX - 1; }
104 else { return CHANNEL_ENDCAP_NUM_MAX - 1; }
105}
106
107//----------------------------------------------------------------------------
109 if ( this->is_barrel( id ) ) { return CHANNEL_BARREL_LAYER_NUM[this->gap( id )]; }
110 else { return CHANNEL_ENDCAP_NUM_MAX; }
111}
112
113//----------------------------------------------------------------------------
115 assert( values_ok( barrel_ec, segment, layer, channel ) );
116 value_type value = ( MUC_ID << MUC_INDEX ) | ( barrel_ec << BARREL_EC_INDEX ) |
117 ( segment << SEGMENT_INDEX ) | ( layer << LAYER_INDEX ) |
118 ( channel << CHANNEL_INDEX );
119 return Identifier( value );
120}
121
122//----------------------------------------------------------------------------
123unsigned int MucID::getIntID( int barrel_ec, int segment, int layer, int channel ) {
124 value_type value = ( MUC_ID << MUC_INDEX ) | ( barrel_ec << BARREL_EC_INDEX ) |
125 ( segment << SEGMENT_INDEX ) | ( layer << LAYER_INDEX ) |
126 ( channel << CHANNEL_INDEX );
127 return value;
128}
129
130//---------------------------------------------------------------------------
131unsigned int MucID::getPartNum() { return BARREL_EC_NUM; }
132
133///---------------------------------------------------------------------------
134unsigned int MucID::getSegNum( int part ) {
135 if ( part == 1 ) return SEGMENT_BARREL_NUM;
136 else if ( part == 0 || part == 2 ) return SEGMENT_ENDCAP_NUM;
137 else return 0;
138}
139
140//----------------------------------------------------------------------------
141unsigned int MucID::getGapNum( int part ) {
142 if ( part == 1 ) return LAYER_BARREL_NUM;
143 if ( part == 0 || part == 2 ) return LAYER_ENDCAP_NUM;
144 else return 0;
145}
146
147//----------------------------------------------------------------------------
148unsigned int MucID::getStripNum( int part, int seg, int gap ) {
149 if ( part == 1 )
150 {
151 if ( seg == 2 ) return CHANNEL_BARREL_LAYER_NUM[gap];
152 else return CHANNEL_BARREL_LAYER_NUM[gap];
153 }
154 else { return CHANNEL_ENDCAP_NUM_MAX; }
155}
156
157///---------------------------------------------------------------------------
158unsigned int MucID::getSegMax() {
159 if ( SEGMENT_BARREL_NUM > SEGMENT_ENDCAP_NUM ) return SEGMENT_BARREL_NUM;
160 else return SEGMENT_ENDCAP_NUM;
161}
162
163///---------------------------------------------------------------------------
164
165unsigned int MucID::getGapMax() {
166 if ( LAYER_BARREL_NUM > LAYER_ENDCAP_NUM ) return LAYER_BARREL_NUM;
167 else return LAYER_ENDCAP_NUM;
168}
169
170unsigned int MucID::getStripMax() {
171 if ( CHANNEL_BARREL_NUM_MAX > CHANNEL_ENDCAP_NUM_MAX ) return CHANNEL_BARREL_NUM_MAX;
172 else return CHANNEL_ENDCAP_NUM_MAX;
173}
174
175//---------------------------------------------------------------------------
176unsigned int MucID::getSEGMENT_BARREL_MAX() { return SEGMENT_BARREL_NUM - 1; }
177
178//---------------------------------------------------------------------------
179unsigned int MucID::getSEGMENT_ENDCAP_MAX() { return SEGMENT_ENDCAP_NUM - 1; }
180
181//---------------------------------------------------------------------------
182unsigned int MucID::getLAYER_BARREL_MAX() { return LAYER_BARREL_NUM - 1; }
183
184//---------------------------------------------------------------------------
185unsigned int MucID::getLAYER_ENDCAP_MAX() { return LAYER_ENDCAP_NUM - 1; }
186
187//---------------------------------------------------------------------------
188unsigned int MucID::getCHANNEL_BARREL_MAX() { return CHANNEL_BARREL_NUM_MAX; }
189
190//---------------------------------------------------------------------------
191unsigned int MucID::getCHANNEL_ENDCAP_MAX() { return CHANNEL_ENDCAP_NUM_MAX; }
192
193//---------------------------------------------------------------------------
194unsigned int MucID::getBARREL_EC_MAX() { return BARREL_EC_NUM - 1; }
195
196//---------------------------------------------------------------------------
197unsigned int MucID::getBARREL_EC_MIN() { return 0; }
static int barrel_ec(const Identifier &id)
Values of different levels.
Definition MucID.cxx:38
static value_type getStripMax()
Definition MucID.cxx:170
static value_type getIntID(int barrel_ec, int segment, int layer, int channel)
Definition MucID.cxx:123
static int layer(const Identifier &id)
Definition MucID.cxx:58
static bool values_ok(const unsigned int barrel_ec, const unsigned int segment, const unsigned int layer, const unsigned int channel)
Definition MucID.cxx:12
static int channel(const Identifier &id)
Definition MucID.cxx:68
static value_type getSEGMENT_BARREL_MAX()
Definition MucID.cxx:176
int segment_max(const Identifier &id)
Max/Min values for each field.
Definition MucID.cxx:78
static int part(const Identifier &id)
Definition MucID.cxx:43
static value_type getGapMax()
Definition MucID.cxx:165
static int segment(const Identifier &id)
Definition MucID.cxx:48
static value_type getBARREL_EC_MAX()
Definition MucID.cxx:194
static value_type getPartNum()
Definition MucID.cxx:131
static Identifier channel_id(int barrel_ec, int segment, int layer, int channel)
For a single crystal.
Definition MucID.cxx:114
int layer_max(const Identifier &id)
Definition MucID.cxx:90
~MucID()
destructor
Definition MucID.cxx:9
static value_type getSegMax()
Definition MucID.cxx:158
static value_type getSEGMENT_ENDCAP_MAX()
Definition MucID.cxx:179
static value_type getLAYER_BARREL_MAX()
Definition MucID.cxx:182
static bool is_barrel(const Identifier &id)
Test for barrel.
Definition MucID.cxx:32
static int gap(const Identifier &id)
Definition MucID.cxx:63
static int seg(const Identifier &id)
Definition MucID.cxx:53
static value_type getLAYER_ENDCAP_MAX()
Definition MucID.cxx:185
static value_type getBARREL_EC_MIN()
Definition MucID.cxx:197
MucID()
constructor
Definition MucID.cxx:7
static value_type getSegNum(int part)
Definition MucID.cxx:134
static value_type getStripNum(int part, int seg, int gap)
Definition MucID.cxx:148
static value_type getCHANNEL_BARREL_MAX()
Definition MucID.cxx:188
static int strip(const Identifier &id)
Definition MucID.cxx:73
static value_type getGapNum(int part)
Definition MucID.cxx:141
int channel_max(const Identifier &id)
Definition MucID.cxx:102
static value_type getCHANNEL_ENDCAP_MAX()
Definition MucID.cxx:191