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