ATLAS Offline Software
Loading...
Searching...
No Matches
LArReadoutModuleService.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "GaudiKernel/MsgStream.h"
8
9
10 // initialization of static member variables to shift bit fields
11 // of HardwareID in proper positions
12const unsigned int LArReadoutModuleService:: m_atlas_tb = 1 ; // bit 0
13const unsigned int LArReadoutModuleService:: m_barrel_ec = 2; // bit 1
14const unsigned int LArReadoutModuleService:: m_pos_neg = 4 ; // bit 2
15
16const unsigned int LArReadoutModuleService:: m_emhf = 8 ; // bits 3-4
17const unsigned int LArReadoutModuleService:: s_rosId = 32 ; // bits 5-9
18const unsigned int LArReadoutModuleService:: s_rodFragId = 1024 ; // bits 10-17
19const unsigned int LArReadoutModuleService:: s_rodCrate = 262144 ; // bits 18-19
20const unsigned int LArReadoutModuleService:: s_rodSlot = 1048576 ; // bits 20-23
21
30
31
32// Concrete methods for the LArReadoutModuleService
33
34//-----------------------------------------------------
36HWIdentifier 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) {
37
38
39 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) ;
40
41 if( errorReport.length() != 0 ) { // error detected
42 MsgStream msg(Athena::getMessageSvc(), " LArReadoutModuleService");
43 msg << MSG::ERROR << " createReadoutModuleID called with parameters: "
44 << l_atlas_tb << ", " << l_barrel_ec << ", " << l_pos_neg << ", " << l_em_hec_fcal
45 << ", " << l_rosId << ", " << l_rodFragId << ", " << l_rodCrate << ", " << l_rodSlot << endmsg;
46 msg << MSG::ERROR << errorReport << endmsg;
47 return {}; //Return (invalid) default instance
48 }
49
50 l_rodCrate = l_rodCrate-1;
51
52 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 +
53 l_rosId * s_rosId + l_rodFragId * s_rodFragId + l_rodCrate * s_rodCrate + l_rodSlot * s_rodSlot ;
54 HWIdentifier l_id(id_int) ;
55 return l_id ;
56}
57
58
59
60//-------------------------------------------------------------
61std::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)
62{
63 std::string l_std_str = "";
64
65 if( l_atlas_tb > 1 || l_atlas_tb < 0 ) { // check of atlas_tb
66 l_std_str += std::string("atlas_tb out of range ,") ;
67 }
68 if( l_barrel_ec > 1 || l_barrel_ec < 0 ) { // check of barrel_ec
69 l_std_str += std::string("barrel_ec out of range ,") ;
70 }
71 if( l_pos_neg > 1 || l_pos_neg < 0 ) { // check of pos_neg
72 l_std_str += std::string("pos_neg out of range ,") ;
73 }
74 if( l_em_hec_fcal > 2 || l_em_hec_fcal < 0 ) { // check of em_hec_fcal
75 l_std_str += std::string("em_hec_fcal out of range ,") ;
76 }
77 // check of rodID, rodFragId, rodCrate and rodSlot
78 if( l_barrel_ec == 0 && l_em_hec_fcal == 0 ) {
79 // EMB
80 if( l_rosId > 27 || l_rosId < 0) {
81 l_std_str += std::string("rosId out of range ,") ;
82 }
83 if( l_rodFragId > 223 || l_rodFragId < 0) {
84 l_std_str += std::string("rodFragId out of range ,") ;
85 }
86 if( l_rodCrate > 4 || l_rodCrate < 1) {
87 l_std_str += std::string("rodCrate out of range ,") ;
88 }
89 if( l_rodSlot > 14 || l_rodSlot < 1) {
90 l_std_str += std::string("rodSlot out of range ,") ;
91 }
92 }
93 if( l_barrel_ec == 1 && l_em_hec_fcal == 0 ) {
94 // EMEC
95 if( l_rosId > 17 || l_rosId < 0) {
96 l_std_str += std::string("rosId out of range ,") ;
97 }
98 if( l_rodFragId > 137 || l_rodFragId < 0) {
99 l_std_str += std::string("rodFragId out of range ,") ;
100 }
101 if( l_rodCrate > 3 || l_rodCrate < 1) {
102 l_std_str += std::string("rodCrate out of range ,") ;
103 }
104 if( l_rodSlot > 13 || l_rodSlot < 1) {
105 l_std_str += std::string("rodSlot out of range ,") ;
106 }
107 }
108 if( l_barrel_ec == 1 && l_em_hec_fcal == 1 ) {
109 // HEC
110 if( l_rosId > 2 || l_rosId < 0) {
111 l_std_str += std::string("rosId out of range ,") ;
112 }
113 if( l_rodFragId > 23 || l_rodFragId < 0) {
114 l_std_str += std::string("rodFragId out of range ,") ;
115 }
116// if( l_rodCrate > 1 || l_rodCrate < 1) {
117 if( l_rodCrate > 2 || l_rodCrate < 1) {
118 l_std_str += std::string("rodCrate out of range ,") ;
119 }
120 if( l_rodSlot > 6 || l_rodSlot < 1) {
121 l_std_str += std::string("rodSlot out of range ,") ;
122 }
123 }
124 if( l_barrel_ec == 1 && l_em_hec_fcal == 2 ) {
125 // FCAL
126 if( l_rosId > 1 || l_rosId < 0) {
127 l_std_str += std::string("rosId out of range ,") ;
128 }
129 if( l_rodFragId > 13 || l_rodFragId < 0) {
130 l_std_str += std::string("rodFragId out of range ,") ;
131 }
132 if( l_rodCrate > 2 || l_rodCrate < 1) {
133// if( l_rodCrate > 1 || l_rodCrate < 1) {
134 l_std_str += std::string("rodCrate out of range ,") ;
135 }
136 if( l_rodSlot > 4 || l_rodSlot < 1) {
137 l_std_str += std::string("rodSlot out of range ,") ;
138 }
139 }
140
141
142 return l_std_str;
143
144}
145
146//-------------------------------------------------------
148 return ( ((int) l_id.get_identifier32().get_compact()) & 1 ) ;
149}
150//-------------------------------------------------------
152 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 2 ) ) >> 1 ;
153}
154//------------------------------------------------------
156 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 4 ) ) >> 2 ;
157}
158//-------------------------------------------------------
160 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x18 ) ) >> 3 ;
161}
162//----------------------------------------------------------
164 int value=0 ;
165 int l_barrel_ec = ( ( ( (int) l_id.get_identifier32().get_compact() ) & 2 ) ) >> 1 ;
166 int l_pos_neg = ( ( ( (int) l_id.get_identifier32().get_compact() ) & 4 ) ) >> 2 ;
167 int l_emhf = ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x18 ) ) >> 3 ;
168 if(l_barrel_ec == 0) {
169 if(l_pos_neg == 1) {
170 value = s_LAR_EM_BARREL_A_SIDE ;
171 } else {
172 value = s_LAR_EM_BARREL_C_SIDE ;
173 }
174 }
175 else if(l_emhf == 0) {
176 if(l_pos_neg == 1) {
177 value = s_LAR_EM_ENDCAP_A_SIDE ;
178 } else {
179 value = s_LAR_EM_ENDCAP_C_SIDE ;
180 }
181 }
182 else if(l_emhf == 1) {
183 if(l_pos_neg == 1) {
185 } else {
187 }
188 }
189 else if(l_emhf == 2) {
190 if(l_pos_neg == 1) {
191 value = s_LAR_FCAL_A_SIDE ;
192 } else {
193 value = s_LAR_FCAL_C_SIDE ;
194 }
195 }
196
197 return value ;
198}
199//------------------------------------------------------------
201 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x3fc00 ) ) >> 10 ;
202}
203//------------------------------------------------------------
205 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x3fc00 ) ) >> 10 ;
206}
207//----------------------------------------------------------
209 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x3e0 ) ) >> 5 ;
210}
211//------------------------------------------------------------
213 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0x3fc00 ) ) >> 10 ;
214}
215//------------------------------------------------------------
217// Shift by 1, internally (0-3), external (1-4)
218 return ( ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0xc0000 ) ) >> 18 ) + 1 ;
219}
220//------------------------------------------------------------
222 return ( ( ( (int) l_id.get_identifier32().get_compact() ) & 0xf00000 ) ) >> 20 ;
223}
224
225//-------------------------------------------------------------
227 char * l_str = new char[200] ;
228 sprintf( l_str , "atlas_tb : %d, barrel_ec : %d, pos_neg: %d, em_hec_fcal: %d, rosId: %d, rodFragId: %d, rodCrate: %d, rodSlot: %d ",
229 atlas_tb(id) , barrel_ec(id) , pos_neg(id) , em_hec_fcal(id) , rosId(id) , rodFragId(id), rodCrate(id), rodSlot(id) ) ;
230 std::string str(l_str);
231 delete[] l_str ;
232 return str ;
233
234}
235//-------------------------------------------------------------
237 char * l_str = new char[200] ;
238 sprintf( l_str , "atlas_tb : %d, subDet : %x, rosId: %d, rodFragId: %d, rodCrate: %d, rodSlot: %d ",
239 atlas_tb(id) , subDet(id) , rosId(id) , rodFragId(id), rodCrate(id), rodSlot(id) ) ;
240 std::string str(l_str);
241 delete[] l_str ;
242 return str ;
243
244}
245
#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