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