ATLAS Offline Software
Loading...
Searching...
No Matches
LArReadoutModuleService.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8
9 // initialization of static member variables to shift bit fields
10 // of HardwareID in proper positions
11const unsigned int LArReadoutModuleService:: m_atlas_tb = 1 ; // bit 0
12const unsigned int LArReadoutModuleService:: m_barrel_ec = 2; // bit 1
13const unsigned int LArReadoutModuleService:: m_pos_neg = 4 ; // bit 2
14
15const unsigned int LArReadoutModuleService:: m_emhf = 8 ; // bits 3-4
16const unsigned int LArReadoutModuleService:: s_rosId = 32 ; // bits 5-9
17const unsigned int LArReadoutModuleService:: s_rodFragId = 1024 ; // bits 10-17
18const unsigned int LArReadoutModuleService:: s_rodCrate = 262144 ; // bits 18-19
19const unsigned int LArReadoutModuleService:: s_rodSlot = 1048576 ; // bits 20-23
20
29
30
31// Concrete methods for the LArReadoutModuleService
32
33//-----------------------------------------------------
35HWIdentifier LArReadoutModuleService::createReadoutModuleID(int l_atlas_tb, int l_barrel_ec, int l_pos_neg, int l_em_hec_fcal, int l_rosId, int l_rodFragId, int l_rodCrate, int l_rodSlot) {
36
37
38 std::string errorReport = checkReadoutModuleValues(l_atlas_tb, l_barrel_ec, l_pos_neg, l_em_hec_fcal, l_rosId, l_rodFragId, l_rodCrate, l_rodSlot) ;
39
40 if( errorReport.length() != 0 ) { // error detected
41 MsgStream msg(Athena::getMessageSvc(), " LArReadoutModuleService");
42 msg << MSG::ERROR << " createReadoutModuleID called with parameters: "
43 << l_atlas_tb << ", " << l_barrel_ec << ", " << l_pos_neg << ", " << l_em_hec_fcal
44 << ", " << l_rosId << ", " << l_rodFragId << ", " << l_rodCrate << ", " << l_rodSlot << endmsg;
45 msg << MSG::ERROR << errorReport << endmsg;
46 return {}; //Return (invalid) default instance
47 }
48
49 l_rodCrate = l_rodCrate-1;
50
51 unsigned int id_int = l_atlas_tb * m_atlas_tb + l_barrel_ec * m_barrel_ec + l_pos_neg * m_pos_neg + l_em_hec_fcal * m_emhf +
52 l_rosId * s_rosId + l_rodFragId * s_rodFragId + l_rodCrate * s_rodCrate + l_rodSlot * s_rodSlot ;
53 HWIdentifier l_id(id_int) ;
54 return l_id ;
55}
56
57
58
59//-------------------------------------------------------------
60std::string LArReadoutModuleService::checkReadoutModuleValues(int l_atlas_tb, int l_barrel_ec, int l_pos_neg, int l_em_hec_fcal, int l_rosId, int l_rodFragId, int l_rodCrate, int l_rodSlot)
61{
62 std::string l_std_str = "";
63
64 if( l_atlas_tb > 1 || l_atlas_tb < 0 ) { // check of atlas_tb
65 l_std_str += std::string("atlas_tb out of range ,") ;
66 }
67 if( l_barrel_ec > 1 || l_barrel_ec < 0 ) { // check of barrel_ec
68 l_std_str += std::string("barrel_ec out of range ,") ;
69 }
70 if( l_pos_neg > 1 || l_pos_neg < 0 ) { // check of pos_neg
71 l_std_str += std::string("pos_neg out of range ,") ;
72 }
73 if( l_em_hec_fcal > 2 || l_em_hec_fcal < 0 ) { // check of em_hec_fcal
74 l_std_str += std::string("em_hec_fcal out of range ,") ;
75 }
76 // check of rodID, rodFragId, rodCrate and rodSlot
77 if( l_barrel_ec == 0 && l_em_hec_fcal == 0 ) {
78 // EMB
79 if( l_rosId > 27 || l_rosId < 0) {
80 l_std_str += std::string("rosId out of range ,") ;
81 }
82 if( l_rodFragId > 223 || l_rodFragId < 0) {
83 l_std_str += std::string("rodFragId out of range ,") ;
84 }
85 if( l_rodCrate > 4 || l_rodCrate < 1) {
86 l_std_str += std::string("rodCrate out of range ,") ;
87 }
88 if( l_rodSlot > 14 || l_rodSlot < 1) {
89 l_std_str += std::string("rodSlot out of range ,") ;
90 }
91 }
92 if( l_barrel_ec == 1 && l_em_hec_fcal == 0 ) {
93 // EMEC
94 if( l_rosId > 17 || l_rosId < 0) {
95 l_std_str += std::string("rosId out of range ,") ;
96 }
97 if( l_rodFragId > 137 || l_rodFragId < 0) {
98 l_std_str += std::string("rodFragId out of range ,") ;
99 }
100 if( l_rodCrate > 3 || l_rodCrate < 1) {
101 l_std_str += std::string("rodCrate out of range ,") ;
102 }
103 if( l_rodSlot > 13 || l_rodSlot < 1) {
104 l_std_str += std::string("rodSlot out of range ,") ;
105 }
106 }
107 if( l_barrel_ec == 1 && l_em_hec_fcal == 1 ) {
108 // HEC
109 if( l_rosId > 2 || l_rosId < 0) {
110 l_std_str += std::string("rosId out of range ,") ;
111 }
112 if( l_rodFragId > 23 || l_rodFragId < 0) {
113 l_std_str += std::string("rodFragId out of range ,") ;
114 }
115// if( l_rodCrate > 1 || l_rodCrate < 1) {
116 if( l_rodCrate > 2 || l_rodCrate < 1) {
117 l_std_str += std::string("rodCrate out of range ,") ;
118 }
119 if( l_rodSlot > 6 || l_rodSlot < 1) {
120 l_std_str += std::string("rodSlot out of range ,") ;
121 }
122 }
123 if( l_barrel_ec == 1 && l_em_hec_fcal == 2 ) {
124 // FCAL
125 if( l_rosId > 1 || l_rosId < 0) {
126 l_std_str += std::string("rosId out of range ,") ;
127 }
128 if( l_rodFragId > 13 || l_rodFragId < 0) {
129 l_std_str += std::string("rodFragId out of range ,") ;
130 }
131 if( l_rodCrate > 2 || l_rodCrate < 1) {
132// if( l_rodCrate > 1 || l_rodCrate < 1) {
133 l_std_str += std::string("rodCrate out of range ,") ;
134 }
135 if( l_rodSlot > 4 || l_rodSlot < 1) {
136 l_std_str += std::string("rodSlot out of range ,") ;
137 }
138 }
139
140
141 return l_std_str;
142
143}
144
145//-------------------------------------------------------
147 return ( ((int) l_id.get_identifier32().get_compact()) & 1 ) ;
148}
149//-------------------------------------------------------
151 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 2 ) ) >> 1 ;
152}
153//------------------------------------------------------
155 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 4 ) ) >> 2 ;
156}
157//-------------------------------------------------------
159 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x18 ) ) >> 3 ;
160}
161//----------------------------------------------------------
163 int value=0 ;
164 int l_barrel_ec = ( ( ( (int) l_id.get_identifier32().get_compact() ) & 2 ) ) >> 1 ;
165 int l_pos_neg = ( ( ( (int) l_id.get_identifier32().get_compact() ) & 4 ) ) >> 2 ;
166 int l_emhf = ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x18 ) ) >> 3 ;
167 if(l_barrel_ec == 0) {
168 if(l_pos_neg == 1) {
169 value = s_LAR_EM_BARREL_A_SIDE ;
170 } else {
171 value = s_LAR_EM_BARREL_C_SIDE ;
172 }
173 }
174 else if(l_emhf == 0) {
175 if(l_pos_neg == 1) {
176 value = s_LAR_EM_ENDCAP_A_SIDE ;
177 } else {
178 value = s_LAR_EM_ENDCAP_C_SIDE ;
179 }
180 }
181 else if(l_emhf == 1) {
182 if(l_pos_neg == 1) {
184 } else {
186 }
187 }
188 else if(l_emhf == 2) {
189 if(l_pos_neg == 1) {
190 value = s_LAR_FCAL_A_SIDE ;
191 } else {
192 value = s_LAR_FCAL_C_SIDE ;
193 }
194 }
195
196 return value ;
197}
198//------------------------------------------------------------
200 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x3fc00 ) ) >> 10 ;
201}
202//------------------------------------------------------------
204 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x3fc00 ) ) >> 10 ;
205}
206//----------------------------------------------------------
208 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x3e0 ) ) >> 5 ;
209}
210//------------------------------------------------------------
212 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x3fc00 ) ) >> 10 ;
213}
214//------------------------------------------------------------
216// Shift by 1, internally (0-3), external (1-4)
217 return ( ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0xc0000 ) ) >> 18 ) + 1 ;
218}
219//------------------------------------------------------------
221 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0xf00000 ) ) >> 20 ;
222}
223
224//-------------------------------------------------------------
226 char * l_str = new char[200] ;
227 sprintf( l_str , "atlas_tb : %d, barrel_ec : %d, pos_neg: %d, em_hec_fcal: %d, rosId: %d, rodFragId: %d, rodCrate: %d, rodSlot: %d ",
228 atlas_tb(id) , barrel_ec(id) , pos_neg(id) , em_hec_fcal(id) , rosId(id) , rodFragId(id), rodCrate(id), rodSlot(id) ) ;
229 std::string str(l_str);
230 delete[] l_str ;
231 return str ;
232
233}
234//-------------------------------------------------------------
236 char * l_str = new char[200] ;
237 sprintf( l_str , "atlas_tb : %d, subDet : %x, rosId: %d, rodFragId: %d, rodCrate: %d, rodSlot: %d ",
238 atlas_tb(id) , subDet(id) , rosId(id) , rodFragId(id), rodCrate(id), rodSlot(id) ) ;
239 std::string str(l_str);
240 delete[] l_str ;
241 return str ;
242
243}
244
#define endmsg
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
static const unsigned int s_rosId
static int rodSlot(const HWIdentifier &id)
return ROD slot number
static int pos_neg(const HWIdentifier &id)
return side positive side : 1 negative side : 0
static int robFragId(const HWIdentifier &id)
return ROB fragment identifier ( == ROL == RODFrag identifier )
static const unsigned int m_emhf
static const unsigned int m_atlas_tb
static int rodCrate(const HWIdentifier &id)
return ROD crate number
static int rol(const HWIdentifier &id)
return ROL identifier ( == RODFrag == ROBFrag identifier )
static const unsigned int m_pos_neg
static int rosId(const HWIdentifier &id)
return ROS identifier
static const unsigned int m_barrel_ec
static std::string checkReadoutModuleValues(int atlas_tb, int barrel_ec, int pos_neg, int em_hec_fcal, int rosId, int rodFragId, int rodCrate, int rodSlot)
static const unsigned int s_rodCrate
static int subDet(const HWIdentifier &id)
return sub-detector identifier
static int barrel_ec(const HWIdentifier &id)
return location (0: barrel or 1: end cap )
static int rodFragId(const HWIdentifier &id)
return ROD fragment identifier ( == ROL == ROB identifier )
static HWIdentifier createReadoutModuleID(int atlas_tb, int barrel_ec, int pos_neg, int em_hec_fcal, int rosId, int rodFragId, int rodCrate, int rodSlot)
create a HWIdentifier valid parameter values atlas_tb : 0 atlas , 1 test beam barrel_ec : 0 bar...
static std::string cnvToStringTDAQ(const HWIdentifier &id)
convert a HWIdentifier into a STL string, TDAQ convention for sub-detector numbering
static const unsigned int s_rodSlot
static std::string cnvToString(const HWIdentifier &id)
convert a HWIdentifier into a STL string
static int em_hec_fcal(const HWIdentifier &id)
return subdetector em : 0, hec : 1, fcal : 2
static int atlas_tb(const HWIdentifier &id)
return 0 for ATLAS , 1 for Test Beam
static const unsigned int s_rodFragId
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
MsgStream & msg
Definition testRead.cxx:32