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