CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
bak_Identifier-01-02-14/src/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
17 ) {
18 // Check values
19
20 // std::cout << " barrel_ec = "<< barrel_ec
21 // << " layer = "<< layer
22 // << " phi_module = "<< phi_module <<std::endl;
23
24 if ( barrel_ec > BARREL_EC_MAX) return false;
25 if ( BARREL_EC_MIN == barrel_ec || BARREL_EC_MIN == barrel_ec) {
26 // if ( phi_module > PHI_ENDCAP_MAX ) return false;
27 if ( layer > LAYER_ENDCAP_MAX ) return false;
28 }
29 else {
30 //if ( phi_module > PHI_BARREL_MAX ) return false; //#Matthias : Switched of as the simulation will not run if switched on!
31 if ( layer > LAYER_BARREL_MAX ) return false;
32 }
33
34 return true;
35}
36
37
38
39bool TofID::values_ok_mrpc(const unsigned int partID, const unsigned int scinNum)
40{
41 if(partID<3 || partID>6) return false;
42 if(scinNum<26 || scinNum>474) return false;
43 if(scinNum%25==0) return false;
44
45 return true;
46}
47
48
49bool TofID::values_ok_mrpc_mc(const unsigned int partID, const unsigned int scinNum)
50{
51 if(partID<3 || partID>6) return false;
52 if(scinNum<25 || scinNum>474) return false;
53
54 return true;
55}
56
57
59{
60 //if( (id & TofID::MRPC_MASK)== MRPC_MASK){ return true;}
62 {
63 //std::cout << "MATTHIAS my mrpc is true " <<std::endl;
64 //std::cout << " (id & (BesDetectorID::MRPC_ID << MRPC_INDEX)) "<< (id & (BesDetectorID::MRPC_ID << MRPC_INDEX) ) <<std::endl;
65 //std::cout << " (BesDetectorID::MRPC_ID << MRPC_INDEX) " << (BesDetectorID::MRPC_ID << MRPC_INDEX)<<std::endl;
66 return true;
67 }
68 else
69 {
70 //std::cout << "MATTHIAS my mrpc is false " <<std::endl;
71 return false;
72 }
73}
74
75
76
77//----------------------------------------------------------------------------
78bool TofID::is_barrel (const Identifier& id) {
79
81
82 if(is_mrpc==true){return false;}
83 else
84 {
85 unsigned int pos = (id.get_value() & TofID::BARREL_EC_MASK) >> TofID::BARREL_EC_INDEX;
86 return (pos == BARREL_EC_MAX || pos == BARREL_EC_MIN) ? false : true;
87 }
88}
89
90
91bool TofID::is_barrel (const unsigned int barrel_ec) {
92 return (barrel_ec == BARRELCODE) ? true : false;
93}
94//----------------------------------------------------------------------------
95int TofID::barrel_ec (const Identifier& id ) {
96
98 //std::cout << "TofID is_mrpc()? " << is_mrpc << std::endl;
99 //if(is_mrpc==true){ std::cout << "TofID barrel_ec(id) - mrpc true! -> return " << ((id.get_value() & TofID::PARTID_MASK) >> TofID::PARTID_INDEX) << std::endl;}
100 //else { std::cout << "TofID barrel_ec(id) - mrpc false! -> return " << ((id.get_value() & TofID::BARREL_EC_MASK) >> TofID::BARREL_EC_INDEX) << std::endl;}
101 if(is_mrpc==true){ return ((id.get_value() & TofID::PARTID_MASK) >> TofID::PARTID_INDEX); }
102 else { return ((id.get_value() & TofID::BARREL_EC_MASK) >> TofID::BARREL_EC_INDEX);}
103
104
105
106}
107
108//----------------------------------------------------------------------------
109int TofID::layer (const Identifier& id) {
110
111 bool is_mrpc=TofID::is_mymrpc(id);
112 if(is_mrpc==true){ return 0;}
113 else {return ((id.get_value() & TofID::LAYER_MASK) >> TofID::LAYER_INDEX);}
114}
115
116//----------------------------------------------------------------------------
118
119 bool is_mrpc=TofID::is_mymrpc(id);
120 //std::cout << "TofID Identifier: " << id << std::endl;
121 //std::cout << "TofID is_mrpc()? " << is_mrpc << std::endl;
122 //if(is_mrpc==true){ std::cout << "TofID phimodule(id) - mrpc true! -> return " << ((id.get_value() & TofID::SCINNUM_MASK)) << std::endl;}
123 //else { std::cout << "TofID phimodule(id) - mrpc false! -> return " << ((id.get_value() & TofID::PHI_MASK) >> TofID::PHI_INDEX) << std::endl;}
124 if(is_mrpc==true){return ((id.get_value() & TofID::SCINNUM_MASK));}
125 else {return ((id.get_value() & TofID::PHI_MASK) >> TofID::PHI_INDEX); }
126}
127
128//----------------------------------------------------------------------------
129int TofID::end(const Identifier& id) {
130 bool is_mrpc=TofID::is_mymrpc(id);
131 if( is_mrpc==true){return 0;}
132 else { return ((id.get_value() & TofID::END_MASK) >> TofID::END_INDEX);}
133}
134
135
136
137//----------------------------------------------------------------------------
139 if (is_barrel(id)) {
140 return LAYER_BARREL_MAX;
141 } else {
142 return LAYER_ENDCAP_MAX;
143 }
144}
145
146//----------------------------------------------------------------------------
148 if (is_barrel(id)) {
149 return PHI_BARREL_MAX;
150 } else {
151 return PHI_ENDCAP_MAX;
152 }
153}
154
155//----------------------------------------------------------------------------
157 int layer,
158 int phi_module,
159 int end
160 ) {
161 assert ( values_ok(barrel_ec, layer, phi_module, end) );
162 unsigned int value = (BesDetectorID::TOF_ID << TOF_INDEX) |
163 (barrel_ec << BARREL_EC_INDEX)|
164 (layer << LAYER_INDEX) | (phi_module << PHI_INDEX) |
165 (end << END_INDEX);
166 return Identifier(value);
167}
168
169
171{
172 return Identifier(value);
173}
174
175
176
177Identifier TofID::cell_id_mrpc ( int partID, int scinNum)
178{
179 assert( values_ok_mrpc(partID, scinNum));
180 unsigned int value = (BesDetectorID::MRPC_ID << MRPC_INDEX) |
181 //(3 << MRPC_INDEX) | //This two digits will be my identifier for a MRPC signal, MRPC_INDEX = 27
182 (partID << PARTID_INDEX) | // Which partID, PARTID_INDEX = 12
183 (scinNum);
184
185 //std::cout << "Matthias cell_id_mrpc " << value << std::endl;
186 return Identifier(value); //returns a secured 32bit variable (hex)
187}
188
189Identifier TofID::cell_id_mrpc_mc ( int partID, int scinNum)
190{
191 assert( values_ok_mrpc_mc(partID, scinNum));
192 unsigned int value = (BesDetectorID::MRPC_ID << MRPC_INDEX) |
193 //(3 << MRPC_INDEX) | //This two digits will be my identifier for a MRPC signal, MRPC_INDEX = 27
194 (partID << PARTID_INDEX) | // Which partID, PARTID_INDEX = 12
195 (scinNum);
196 return Identifier(value); //returns a secured 32bit variable (hex)
197}
198
199
200unsigned int TofID::getIntID ( int barrel_ec,
201 int layer,
202 int phi_module,
203 int end
204 )
205{
206 unsigned int value = (BesDetectorID::TOF_ID << TOF_INDEX) |
207 (barrel_ec << BARREL_EC_INDEX)|
208 (layer << LAYER_INDEX) | (phi_module << PHI_INDEX) |
209 (end << END_INDEX);
210 return value;
211}
212
213
214
215
216unsigned int TofID::getIntID_mrpc ( int partID, int scinNum )
217{
218 unsigned int value = ((BesDetectorID::MRPC_ID << MRPC_INDEX) |
219 //(3 << MRPC_INDEX) | //This two digits will be my identifier for a MRPC signal, MRPC_INDEX = 27
220 (partID << PARTID_INDEX) | // Which partID, PARTID_INDEX = 12
221 (scinNum));
222 return value;
223}
224
225
226
228{
229 return LAYER_BARREL_MAX;
230}
231
233{
234 return LAYER_ENDCAP_MAX;
235}
236
238{
239 return PHI_BARREL_MAX;
240}
241
243{
244 return PHI_ENDCAP_MAX;
245}
247{
248 return BARREL_EC_MAX;
249}
250
252{
253 return BARREL_EC_MIN;
254}
255
256
bool is_mrpc(const Identifier &id) const
static Identifier cell_id(int barrel_ec, int layer, int phi_module, int end)
For a single crystal.
static value_type getIntID_mrpc(int partID, int scinNum)
static bool values_ok_mrpc(const unsigned int partID, const unsigned int scinNum)
static int end(const Identifier &id)
static value_type getPHI_BARREL_MAX()
static value_type getPHI_ENDCAP_MAX()
static bool values_ok_mrpc_mc(const unsigned int partID, const unsigned int scinNum)
static value_type getBARREL_EC_MIN()
static value_type getBARREL_EC_MAX()
static bool is_barrel(const Identifier &id)
Test for barrel.
static Identifier cell_id_mrpc(int partID, int scinNum)
static int phi_module(const Identifier &id)
static int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
static bool values_ok(const unsigned int barrel_ec, const unsigned int layer, const unsigned int phi_module, const unsigned int)
int phi_module_max(const Identifier &id)
Max/Min values for each field (error returns -999)
static value_type getLAYER_ENDCAP_MAX()
static value_type getIntID(int barrel_ec, int layer, int phi_module, int end)
static bool is_mymrpc(const Identifier &id)
static Identifier cell_id_mrpc_mc(int partID, int scinNum)
static int layer(const Identifier &id)
int layer_max(const Identifier &id)
static value_type getLAYER_BARREL_MAX()