ATLAS Offline Software
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
11 const unsigned int LArReadoutModuleService:: m_atlas_tb = 1 ; // bit 0
12 const unsigned int LArReadoutModuleService:: m_barrel_ec = 2; // bit 1
13 const unsigned int LArReadoutModuleService:: m_pos_neg = 4 ; // bit 2
14 
15 const unsigned int LArReadoutModuleService:: m_emhf = 8 ; // bits 3-4
16 const unsigned int LArReadoutModuleService:: s_rosId = 32 ; // bits 5-9
17 const unsigned int LArReadoutModuleService:: s_rodFragId = 1024 ; // bits 10-17
18 const unsigned int LArReadoutModuleService:: s_rodCrate = 262144 ; // bits 18-19
19 const unsigned int LArReadoutModuleService:: s_rodSlot = 1048576 ; // bits 20-23
20 
29 
30 
31 // Concrete methods for the LArReadoutModuleService
32 
33 //-----------------------------------------------------
35 HWIdentifier 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 //-------------------------------------------------------------
60 std::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) {
170  } else {
172  }
173  }
174  else if(l_emhf == 0) {
175  if(l_pos_neg == 1) {
177  } else {
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) {
191  } else {
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 
LArReadoutModuleService::barrel_ec
static int barrel_ec(const HWIdentifier &id)
return location (0: barrel or 1: end cap )
Definition: LArReadoutModuleService.cxx:150
LArReadoutModuleService::s_rodFragId
static const unsigned int s_rodFragId
Definition: LArReadoutModuleService.h:135
LArReadoutModuleService::m_pos_neg
static const unsigned int m_pos_neg
Definition: LArReadoutModuleService.h:130
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
LArReadoutModuleService::createReadoutModuleID
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...
Definition: LArReadoutModuleService.cxx:35
LArReadoutModuleService::subDet
static int subDet(const HWIdentifier &id)
return sub-detector identifier
Definition: LArReadoutModuleService.cxx:162
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LArReadoutModuleService::rodFragId
static int rodFragId(const HWIdentifier &id)
return ROD fragment identifier ( == ROL == ROB identifier )
Definition: LArReadoutModuleService.cxx:211
LArReadoutModuleService::s_rodSlot
static const unsigned int s_rodSlot
Definition: LArReadoutModuleService.h:137
athena.value
value
Definition: athena.py:122
LArReadoutModuleService::cnvToStringTDAQ
static std::string cnvToStringTDAQ(const HWIdentifier &id)
convert a HWIdentifier into a STL string, TDAQ convention for sub-detector numbering
Definition: LArReadoutModuleService.cxx:235
LArReadoutModuleService::m_barrel_ec
static const unsigned int m_barrel_ec
Definition: LArReadoutModuleService.h:129
HWIdentifier
Definition: HWIdentifier.h:13
LArReadoutModuleService.h
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
LArReadoutModuleService::m_emhf
static const unsigned int m_emhf
Definition: LArReadoutModuleService.h:133
LArReadoutModuleService::s_LAR_FCAL_C_SIDE
static const int s_LAR_FCAL_C_SIDE
Definition: LArReadoutModuleService.h:146
LArReadoutModuleService::s_LAR_EM_BARREL_A_SIDE
static const int s_LAR_EM_BARREL_A_SIDE
Definition: LArReadoutModuleService.h:139
LArReadoutModuleService::s_LAR_FCAL_A_SIDE
static const int s_LAR_FCAL_A_SIDE
Definition: LArReadoutModuleService.h:145
Identifier32::get_compact
value_type get_compact(void) const
Get the compact id.
Definition: Identifier32.h:171
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LArReadoutModuleService::pos_neg
static int pos_neg(const HWIdentifier &id)
return side positive side : 1 negative side : 0
Definition: LArReadoutModuleService.cxx:154
LArReadoutModuleService::rodCrate
static int rodCrate(const HWIdentifier &id)
return ROD crate number
Definition: LArReadoutModuleService.cxx:215
LArReadoutModuleService::robFragId
static int robFragId(const HWIdentifier &id)
return ROB fragment identifier ( == ROL == RODFrag identifier )
Definition: LArReadoutModuleService.cxx:199
LArReadoutModuleService::s_rodCrate
static const unsigned int s_rodCrate
Definition: LArReadoutModuleService.h:136
LArReadoutModuleService::s_LAR_HAD_ENDCAP_A_SIDE
static const int s_LAR_HAD_ENDCAP_A_SIDE
Definition: LArReadoutModuleService.h:143
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
LArReadoutModuleService::rol
static int rol(const HWIdentifier &id)
return ROL identifier ( == RODFrag == ROBFrag identifier )
Definition: LArReadoutModuleService.cxx:203
LArReadoutModuleService::atlas_tb
static int atlas_tb(const HWIdentifier &id)
return 0 for ATLAS , 1 for Test Beam
Definition: LArReadoutModuleService.cxx:146
LArReadoutModuleService::checkReadoutModuleValues
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)
Definition: LArReadoutModuleService.cxx:60
LArReadoutModuleService::s_LAR_EM_BARREL_C_SIDE
static const int s_LAR_EM_BARREL_C_SIDE
Definition: LArReadoutModuleService.h:140
LArReadoutModuleService::em_hec_fcal
static int em_hec_fcal(const HWIdentifier &id)
return subdetector em : 0, hec : 1, fcal : 2
Definition: LArReadoutModuleService.cxx:158
LArReadoutModuleService::s_LAR_HAD_ENDCAP_C_SIDE
static const int s_LAR_HAD_ENDCAP_C_SIDE
Definition: LArReadoutModuleService.h:144
LArReadoutModuleService::rodSlot
static int rodSlot(const HWIdentifier &id)
return ROD slot number
Definition: LArReadoutModuleService.cxx:220
LArReadoutModuleService::s_rosId
static const unsigned int s_rosId
Definition: LArReadoutModuleService.h:134
Identifier::get_identifier32
Identifier32 get_identifier32(void) const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArReadoutModuleService::cnvToString
static std::string cnvToString(const HWIdentifier &id)
convert a HWIdentifier into a STL string
Definition: LArReadoutModuleService.cxx:225
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
LArReadoutModuleService::s_LAR_EM_ENDCAP_A_SIDE
static const int s_LAR_EM_ENDCAP_A_SIDE
Definition: LArReadoutModuleService.h:141
LArReadoutModuleService::s_LAR_EM_ENDCAP_C_SIDE
static const int s_LAR_EM_ENDCAP_C_SIDE
Definition: LArReadoutModuleService.h:142
LArReadoutModuleService::m_atlas_tb
static const unsigned int m_atlas_tb
Definition: LArReadoutModuleService.h:128
LArReadoutModuleService::rosId
static int rosId(const HWIdentifier &id)
return ROS identifier
Definition: LArReadoutModuleService.cxx:207