Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CSCcablingSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GaudiKernel/ISvcLocator.h"
6 #include "GaudiKernel/MsgStream.h"
7 
10 
15 
16 // Author: Ketevi A. Assamagan - may 2007
17 
18 
20 
21  // Retrieve geometry config information from the database (RUN1, RUN2, etc...)
22  SmartIF<IRDBAccessSvc> rdbAccess{service("RDBAccessSvc")};
23  ATH_CHECK( rdbAccess.isValid() );
24 
25  SmartIF<IGeoModelSvc> geoModel{service("GeoModelSvc")};
26  if (!geoModel) {
27  ATH_MSG_ERROR( "Could not locate GeoModelSvc" );
28  } else {
29  // check the DetDescr version
30  std::string atlasVersion = geoModel->atlasVersion();
31 
32  IRDBRecordset_ptr atlasCommonRec = rdbAccess->getRecordsetPtr("AtlasCommon",atlasVersion,"ATLAS");
33  if(atlasCommonRec->size()==0) {
34  m_run1 = true;
35  } else {
36  std::string configVal = (*atlasCommonRec)[0]->getString("CONFIG");
37  if(configVal=="RUN1"){
38  m_run1 = true;
39  } else if(configVal=="RUN2" || configVal=="RUN3" || configVal=="RUN4") {
40  m_run1 = false;
41  } else {
42  ATH_MSG_FATAL("Unexpected value for geometry config read from the database: " << configVal);
43  return StatusCode::FAILURE;
44  }
45  }
46  }
47  m_rod = (m_run1 ? 8 : 16);
48  m_max = m_side * m_rod;
49 
50  return StatusCode::SUCCESS;
51 }
52 
54 bool CSCcablingSvc::onlineId(const uint16_t subDetectorID, const uint16_t offlineID, uint32_t& rodId) const {
55 
56  bool check = subDetectorID == 0x6A || subDetectorID == 0x69;
57  uint16_t id = 0xFFFF;
58  check = check && this->onlineId(offlineID, id);
59  rodId = (subDetectorID << 16) | id;
60  return check;
61 }
62 
63 bool CSCcablingSvc::onlineId(const uint16_t offlineID, uint16_t& rodId) const {
64 
65  bool check = true;
66  switch ( offlineID ) {
67  case 0x0 :
68  rodId = 0x0005;
69  break;
70  case 0x1 :
71  rodId = 0x0007;
72  break;
73  case 0x2 :
74  rodId = 0x0009;
75  break;
76  case 0x3 :
77  rodId = 0x0011;
78  break;
79  case 0x4 :
80  rodId = 0x0015; // slot 13 reserved
81  break;
82  case 0x5 :
83  rodId = 0x0017;
84  break;
85  case 0x6 :
86  rodId = 0x0019;
87  break;
88  case 0x7 :
89  rodId = 0x0021;
90  break;
91  default :
92  check = false;
93  rodId = 0xFFFF;
94  }
95 
96  if((offlineID & 0x1F) & 0x10){
97  check = true;
98  // uses Rod Ids in 0x10 - 0x1F
99  rodId = 0x80 | (0xF & offlineID);
100  }
101  return check;
102 }
103 
105 bool CSCcablingSvc::offlineId(const uint32_t onlineIdentifier, uint16_t& rodId ) const {
106  bool check = true;
107  uint16_t id = onlineIdentifier & 0xFFFF;
108  switch ( id ) {
109  case 0x0005 :
110  rodId = 0x0;
111  break;
112  case 0x0007 :
113  rodId = 0x1;
114  break;
115  case 0x0009 :
116  rodId = 0x2;
117  break;
118  case 0x0011 :
119  rodId = 0x3;
120  break;
121  case 0x0015 :
122  rodId = 0x4; // slot 13 reserved
123  break;
124  case 0x0017 :
125  rodId = 0x5;
126  break;
127  case 0x0019 :
128  rodId = 0x6;
129  break;
130  case 0x0021 :
131  rodId = 0x7;
132  break;
133  case 0x000A :
134  rodId = 0x0; // cosmic test simulation
135  break;
136  case 0x000C :
137  rodId = 0x1; // cosmic test simulation
138  break;
139  default :
140  check = false;
141  rodId = 0xFFFF;
142  }
143  // new online Rod 0x80 - 0x8F range Oct. 2014
144  if(!check && (id & 0x70) == 0){
145  check = true;
146  if( id & 1 ) {
147  rodId = (((id & 0xf) >> 1) | 0x10);
148  } else {
149  rodId = (((id & 0xf) >> 1) | 0x18);
150  }
151  }
152 
153  return check;
154 }
155 
157 bool CSCcablingSvc::is_rodId (const uint16_t rodId ) const {
158 
159  bool check = rodId == 0x5 || rodId == 0x7 || rodId == 0x9 || rodId == 0x11 ||
160  rodId == 0x15 || rodId == 0x17 || rodId == 0x19 || rodId == 0x21;
161 
162  // new online Rod 0x80 - 0x8F range Oct. 2014
163  if((rodId & 0x70) == 0) check = true;
164 
165  return check;
166 }
167 
169 bool CSCcablingSvc::is_offlineRodId (const uint16_t rodId ) const {
170 
171  bool check = rodId == 0x0 || rodId == 0x1 || rodId == 0x2 || rodId == 0x3 ||
172  rodId == 0x4 || rodId == 0x5 || rodId == 0x6 || rodId == 0x7;
173 
174  // new offline Rod range 0x10 - 0x1F Oct. 2014
175  if((0x10 & rodId)==0x10) check = true;
176  return check;
177 }
178 
180 uint16_t CSCcablingSvc::collectionId(const uint16_t subDetectorId, const uint16_t rodId) const {
181 
182  uint16_t subId = (subDetectorId == 0x6A) ? 0 : 1;
183  uint16_t onlineColId = subId*this->nROD()+rodId;
184 
185  // new offline Rod range 0x10 - 0x1F Oct. 2014
186  // double number of rods
187  if((rodId & 0x10) == 0x10){
188  onlineColId = subId*this->nROD() + rodId - 16;
189  } else {
190  onlineColId = subId*this->nROD() + rodId;
191  }
192 
193  return onlineColId;
194 }
195 
196 void CSCcablingSvc::hash2Rob(const unsigned int& hashid, uint32_t& robid) const {
197  if(m_run1){
198  switch (hashid){
199  case 0:
200  case 16:
201  case 8:
202  case 24:
203  robid = 0x05;
204  break;
205  case 1:
206  case 17:
207  case 9:
208  case 25:
209  robid = 0x07;
210  break;
211  case 2:
212  case 18:
213  case 10:
214  case 26:
215  robid = 0x09;
216  break;
217  case 3:
218  case 19:
219  case 11:
220  case 27:
221  robid = 0x11;
222  break;
223  case 4:
224  case 20:
225  case 12:
226  case 28:
227  robid = 0x15;
228  break;
229  case 5:
230  case 21:
231  case 13:
232  case 29:
233  robid = 0x17;
234  break;
235  case 6:
236  case 22:
237  case 14:
238  case 30:
239  robid = 0x19;
240  break;
241  case 7:
242  case 23:
243  case 15:
244  case 31:
245  robid = 0x21;
246  break;
247  default:
248  robid = 0xffff;
249  break;
250  }
251  } else {
252  switch (hashid){
253  case 16:
254  case 24:
255  robid = 0x80;
256  break;
257  case 17:
258  case 25:
259  robid = 0x82;
260  break;
261  case 18:
262  case 26:
263  robid = 0x84;
264  break;
265  case 19:
266  case 27:
267  robid = 0x86;
268  break;
269  case 20:
270  case 28:
271  robid = 0x88;
272  break;
273  case 21:
274  case 29:
275  robid = 0x8a;
276  break;
277  case 22:
278  case 30:
279  robid = 0x8c;
280  break;
281  case 23:
282  case 31:
283  robid = 0x8e;
284  break;
285  case 0:
286  case 8:
287  robid = 0x81;
288  break;
289  case 1:
290  case 9:
291  robid = 0x83;
292  break;
293  case 2:
294  case 10:
295  robid = 0x85;
296  break;
297  case 3:
298  case 11:
299  robid = 0x87;
300  break;
301  case 4:
302  case 12:
303  robid = 0x89;
304  break;
305  case 5:
306  case 13:
307  robid = 0x8b;
308  break;
309  case 6:
310  case 14:
311  robid = 0x8d;
312  break;
313  case 7:
314  case 15:
315  robid = 0x8f;
316  break;
317  default:
318  robid = 0xffff;
319  break;
320  }
321  }
322 }
323 
324 
325 
326 void CSCcablingSvc::hash2Rod(const unsigned int& hashid, uint32_t& rodid) const {
327  if(m_run1){
328  rodid = hashid & 7;
329  } else {
330  if (hashid<8)
331  rodid = hashid;
332  else if (hashid<24)
333  rodid = hashid-8;
334  else
335  rodid = hashid-16;
336  rodid |= 0x10;
337  }
338 }
339 
340 void CSCcablingSvc::hash2SubdetectorId(const unsigned int& hashid, uint32_t& subdetectorid) const {
341  if ((hashid >= 8 && hashid <= 15) || (hashid >= 24))
342  subdetectorid = 0x69;
343  else
344  subdetectorid = 0x6a;
345 }
346 
347 void CSCcablingSvc::hash2RobFull(const unsigned int& hashid, uint32_t& robid) const {
348  uint32_t shortRobID = 0xffff;
349  hash2Rob(hashid, shortRobID);
350 
351  uint32_t subdetectorid = 0;
352  hash2SubdetectorId(hashid, subdetectorid);
353 
354  robid = (subdetectorid << 16) | shortRobID;
355 }
356 
357 void CSCcablingSvc::hash2CollectionId(const unsigned int& hashid, uint16_t& collectionid) const {
358  uint32_t rodid = 0xffff;
359  hash2Rod(hashid, rodid);
360 
361  uint32_t subdetectorid = 0;
362  hash2SubdetectorId(hashid, subdetectorid);
363 
364  collectionid = collectionId(subdetectorid, rodid);
365 }
CSCcablingSvc::offlineId
bool offlineId(const uint32_t onlineIdentifier, uint16_t &rodId) const
reverse map of online ID into offline ROD ID
Definition: CSCcablingSvc.cxx:105
CSCcablingSvc::m_run1
Gaudi::Property< bool > m_run1
Definition: CSCcablingSvc.h:65
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
CSCcablingSvc::m_rod
unsigned int m_rod
Definition: CSCcablingSvc.h:62
IGeometryDBSvc.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CSCcablingSvc::onlineId
bool onlineId(const uint16_t subdetectorID, const uint16_t offlineID, uint32_t &rodId) const
map offline ROD identifier to online ID
Definition: CSCcablingSvc.cxx:54
CSCcablingSvc::m_max
unsigned int m_max
Definition: CSCcablingSvc.h:63
CSCcablingSvc::hash2Rod
void hash2Rod(const unsigned int &, uint32_t &) const
map PRD collection ID into offline ROD ID
Definition: CSCcablingSvc.cxx:326
CSCcablingSvc::nROD
unsigned int nROD() const
Definition: CSCcablingSvc.h:41
CSCcablingSvc::is_rodId
bool is_rodId(const uint16_t rodId) const
check that we have the correct online ROD id
Definition: CSCcablingSvc.cxx:157
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CSCcablingSvc::hash2Rob
void hash2Rob(const unsigned int &, uint32_t &) const
map PRD collection ID into short ROB ID, e.g.
Definition: CSCcablingSvc.cxx:196
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CSCcablingSvc::collectionId
uint16_t collectionId(const uint16_t subdetectorId, const uint16_t rodId) const
calculate the collection Identifier
Definition: CSCcablingSvc.cxx:180
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
CSCcablingSvc::hash2SubdetectorId
void hash2SubdetectorId(const unsigned int &, uint32_t &) const
map PRD collection ID into subdetector ID, i.e.
Definition: CSCcablingSvc.cxx:340
CSCcablingSvc::hash2RobFull
void hash2RobFull(const unsigned int &, uint32_t &) const
map PRD collection ID into full ROB ID (with subdetector ID), e.g.
Definition: CSCcablingSvc.cxx:347
LArNewCalib_Delay_OFC_Cali.check
check
Definition: LArNewCalib_Delay_OFC_Cali.py:289
CSCcablingSvc::is_offlineRodId
bool is_offlineRodId(const uint16_t rodId) const
check that we have the correct offline ROD id
Definition: CSCcablingSvc.cxx:169
python.CaloAddPedShiftConfig.default
default
Definition: CaloAddPedShiftConfig.py:43
CSCcablingSvc::hash2CollectionId
void hash2CollectionId(const unsigned int &, uint16_t &) const
map PRD collection ID into RDO collection ID
Definition: CSCcablingSvc.cxx:357
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
CSCcablingSvc::m_side
unsigned int m_side
Definition: CSCcablingSvc.h:61
CSCcablingSvc::initialize
virtual StatusCode initialize() override
Definition: CSCcablingSvc.cxx:19
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
IGeoModelSvc.h
CSCcablingSvc.h