ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcCablingService.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include <string>
8#include <iostream>
9#include <algorithm>
10
11// Singleton methods
12
13//------------------------------------------------------------
15{
16 static const ZdcCablingService svc (nullptr);//, nullptr);
17 return &svc;
18}
19
20//-------------------------------------------------------------
24
25// default constructor
26
27//-------------------------------------------------------------
28ZdcCablingService::ZdcCablingService (const ZdcID* zdcID) // const ZdcHardwareID* zdcHWID)
29 : m_dbFilled(0) , m_zdcID(zdcID) //, m_zdcHWID(zdcHWID)
30{
31
32 ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "ZdcCablingSevice");
33 if (!m_zdcID) {
34 if (detStore->retrieve (m_zdcID).isFailure()) {
35 std::abort();
36 }
37 }
38
40 fillDB();
41
42}
43
45{
46
47 if (m_dbFilled) return;
48 m_dbFilled = true;
49
50 int side_db[16][16] = {
51 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
52 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
53 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
54 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
55 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
56 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
57 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
58 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
59 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
60 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
61 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
62 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
63 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
64 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
65 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
66 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
67 };
68
69 /* //original version Nov 2009
70
71 int module_db[8][16] =
72 {
73 {1,1,1,1,0,0,0,0,3,3,3,3,2,2,2,2},
74 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
75 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
76 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
77 {1,1,1,1,0,0,0,0,3,3,3,3,2,2,2,2},
78 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
79 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
80 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
81 };
82 */
83
84 int module_db[16][16] =
85 {
86 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
87 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
88 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
89 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
90 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
91 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
92 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
93 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
94 {3,3,3,3,0,0,0,0,1,1,1,1,2,2,2,2},
95 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
96 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
97 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
98 {3,3,3,3,0,0,0,0,1,1,1,1,2,2,2,2},
99 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
100 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
101 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
102 };
103
104 int type_db[16][16] =
105 {
106 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
107 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
108 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
109 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
110 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
111 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
112 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
113 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
114 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
115 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
116 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
117 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
118 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
119 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
120 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
121 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
122 };
123
124 int channel_db[16][16] =
125 {
126 {8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15},
127 {24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31},
128 {40,40,41,41,42,42,43,43,44,44,45,45,46,46,47,47},
129 {56,56,57,57,58,58,59,59,60,60,61,61,62,62,63,63},
130 {0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7},
131 {16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23},
132 {32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39},
133 {48,48,49,49,50,50,51,51,52,52,53,53,54,54,55,55},
134 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
135 {1,1,5,5,0,0,4,4,3,3,7,7,2,2,6,6},
136 {12,12,8,8,13,13,9,9,14,14,10,10,15,15,11,11},
137 {20,20,16,16,21,21,17,17,22,22,18,18,23,23,19,19},
138 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
139 {1,1,5,5,0,0,4,4,3,3,7,7,2,2,6,6},
140 {12,12,8,8,13,13,9,9,14,14,10,10,15,15,11,11},
141 {20,20,16,16,21,21,17,17,22,22,18,18,23,23,19,19},
142 };
143
144 /*
145 // the old one
146 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
147 {4,4,0,0,5,5,1,1,6,6,2,2,7,7,3,3},
148 {9,9,13,13,8,8,12,12,11,11,15,15,10,10,14,14},
149 {17,17,21,21,16,16,20,20,19,19,23,23,18,18,22,22}
150 */
151
152 int gain_db[16][16] =
153 {
154 {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}, // EM Pix
155 {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}, // EM Pix
156 {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}, // EM Pix
157 {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}, // EM Pix
158 {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}, // EM Pix
159 {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}, // EM Pix
160 {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}, // EM Pix
161 {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}, // EM Pix
162 {1,1,0,0,0,0,1,1,1,1,0,0,1,1,0,0}, // HAD2,EM,HAD0,HAD1
163 {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}, // HAD0 Pix
164 {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}, // HAD0 Pix
165 {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}, // HAD0 Pix
166 {1,1,0,0,0,0,1,1,1,1,0,0,1,1,0,0}, // HAD2,EM,HAD0,HAD1
167 {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}, // HAD0 Pix
168 {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}, // HAD0 Pix
169 {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1} // HAD0 Pix
170 };
171
172 int delay_db[16][16] =
173 {
174 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
175 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
176 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
177 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
178 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
179 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
180 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
181 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
182 //{1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0},
183 {1,0,1,0,0,1,0,1,1,0,1,0,1,0,1,0},
184 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
185 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
186 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
187 //{1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0},
188 {1,0,1,0,0,1,0,1,1,0,1,0,1,0,1,0},
189 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
190 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
191 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
192 };
193
194 int hv_db[16][16] =
195 {
196 {224,224,224,224,212,212,212,212,213,213,213,213,214,214,214,214},
197 {221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221},
198 {222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222},
199 {223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223},
200 {224,224,224,224,212,212,212,212,213,213,213,213,214,214,214,214},
201 {221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221},
202 {222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222},
203 {223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223},
204 {224,224,224,224,212,212,212,212,213,213,213,213,214,214,214,214},
205 {221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221},
206 {222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222},
207 {223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223},
208 {224,224,224,224,212,212,212,212,213,213,213,213,214,214,214,214},
209 {221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221},
210 {222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222},
211 {223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223}
212 };
213
214 int ppm_db[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
215
216 // this is a mess. need to derive crate_index and m_crate_index from the crate_db, but not right this second
217 //int crate_db[8] = {12,12,12,12,14,14,14,14};
218 int crate_index[16] ={0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
219 m_ncrate = 4;
220 m_crate_index[0] = 10;
221 m_crate_index[1] = 11;
222 m_crate_index[2] = 12;
223 m_crate_index[3] = 14;
224
225 // lookup table side/module/type/channel/gain/delay
226
227 for (int i = 0; i < 16; i++) {
228 for (int j = 0; j < 16; j++) {
229 int ic = crate_index[i]; // crate index
230 int icc = i * 16 + j - 64 * ic; // channel index
231 m_side_db[ic][icc] = side_db[i][j];
232 m_module_db[ic][icc] = module_db[i][j];
233 m_type_db[ic][icc] = type_db[i][j];
234 m_channel_db[ic][icc] = channel_db[i][j];
235 m_gain_db[ic][icc] = gain_db[i][j];
236 m_delay_db[ic][icc] = delay_db[i][j];
237 m_hv_db[ic][icc] = hv_db[i][j];
238 m_ppm_db[ic] = ppm_db[i];
239 // m_crate_lookup[m_side_db[i][j]][m_module_db[i][j]][m_type_db[i][j]] =
240 // ic;
241 // m_channel_lookup[m_side_db[i][j]][m_module_db[i][j]][m_type_db[i][j]][j][m_gain_db[i][j]][m_delay_db[i][j]]
242 // = icc;
243 }
244 }
245}
246
247// destructor
248
249//-------------------------------------------------------------
253
254void
256{
257 m_connected[ppm][channel] = true;
258}
259
260//
261// Convert ZdcID to Trigger Tower ID
262//
263
264/*
265Identifier ZdcCablingService::h2s_side_id ( const HWIdentifier & hwid ) const
266 throw (ZdcID_Exception)
267{
268 int ppm = m_zdcHWID->ppm (hwid);
269 int channel = m_zdcHWID->channel (hwid);
270 int side = hwid2side (ppm,channel);
271 return m_zdcID->side_id(side);
272}
273
274Identifier ZdcCablingService::h2s_type_id ( const HWIdentifier & hwid ) const
275 throw (ZdcID_Exception)
276{
277 int ppm = m_zdcHWID->ppm (hwid);
278 int channel = m_zdcHWID->channel (hwid);
279 int type = hwid2type (ppm,channel);
280 return m_zdcID->type_id(side);
281}
282
283Identifier ZdcCablingService::h2s_module_id ( const HWIdentifier & hwid ) const
284 throw (ZdcID_Exception)
285{
286 int ppm = m_zdcHWID->ppm (hwid);
287 int channel = m_zdcHWID->channel (hwid);
288 int side = hwid2side (ppm,channel);
289 return m_zdcID->module_id(side);
290}
291
292Identifier ZdcCablingService::h2s_gain_id ( const HWIdentifier & hwid ) const
293 throw (ZdcID_Exception)
294{
295 int ppm = m_zdcHWID->ppm (hwid);
296 int channel = m_zdcHWID->channel (hwid);
297 int side = hwid2side (ppm,channel);
298 return m_zdcID->side_id(side);
299}
300
301Identifier ZdcCablingService::h2s_delay_id ( const HWIdentifier & hwid ) const
302 throw (ZdcID_Exception)
303{
304 int ppm = m_zdcHWID->ppm (hwid);
305 int channel = m_zdcHWID->channel (hwid);
306 int side = hwid2side (ppm,channel);
307 return m_zdcID->side_id(side);
308}
309*/
310
311/*
312Identifier ZdcCablingService::h2s_channel_id ( const HWIdentifier & hwid ) const
313 throw (ZdcID_Exception)
314{
315 int ppm = m_zdcHWID->ppm (hwid);
316 int channel = m_zdcHWID->channel (hwid);
317 int side = hwid2side (ppm,channel);
318 int module = hwid2module (ppm,channel);
319 int type = hwid2type (ppm,channel);
320 int channel = hwid2channel (ppm,channel);
321 return m_zdcID->channel_id(side,module,type,channel);
322}
323*/
324
325
326Identifier ZdcCablingService::h2s_channel_id ( int crate, int channel ) const
327{
328
329 int side = hwid2side (crate,channel);
330 int module = hwid2module (crate,channel);
331 int type = hwid2type (crate,channel);
332 int chan = hwid2channel (crate,channel);
333
334 //std::cout << "ZCS: side=" << side << " module=" << module << " type=" << type << " chan=" << chan << std::endl;
335 return m_zdcID->channel_id(side,module,type,chan);
336}
337
338
339/*
340HWIdentifier ZdcCablingService::s2h_channel_hwid (const Identifier & id) const
341{
342 int side = m_zdcID->side(id);
343 int type = m_zdcID->type(id);
344 int module = m_zdcID->module(id);
345 int channel = m_zdcID->channel(id);
346 int gain = 0;
347 int delay = 0;
348
349 int ppm = swid2ppm(side,module,type);
350 int hwchannel = swid2channel(side,module,type,channel,gain,delay);
351
352 return m_zdcHWID->channel_id(ppm,hwchannel);
353}
354*/
355
356/*
357HWIdentifier ZdcCablingService::s2h_ppm_hwid (const Identifier & id) const
358{
359 int side = m_zdcID->side(id);
360 int module = m_zdcID->module(id);
361 int type = m_zdcID->type(id);
362 int channel = m_zdcID->channel(id);
363 int ppm = swid2ppm(side,module,type);
364 return m_zdcHWID->ppm_id(ppm);
365}
366*/
367
368int
369ZdcCablingService::hwid2side ( int crate, int channel ) const
370{
371 int ic = crate_index_lookup(crate);
372 if (ic<0) return -1;
373
374 int side = m_side_db[ic][channel];
375 return side;
376}
377
378int ZdcCablingService::hwid2module ( int crate, int channel ) const
379{
380 int ic = crate_index_lookup(crate);
381 if (ic<0) return -1;
382
383 int module = m_module_db[ic][channel];
384 return module;
385}
386
387int ZdcCablingService::hwid2type ( int crate, int channel ) const
388{
389 int ic = crate_index_lookup(crate);
390 if (ic<0) return -1;
391
392 int type = m_type_db[ic][channel];
393 return type;
394}
395
396
397int ZdcCablingService::hwid2channel ( int crate, int channel ) const
398{
399 int ic = crate_index_lookup(crate);
400 if (ic<0) return -1;
401
402 int chan = m_channel_db[ic][channel];
403 return chan;
404}
405
406
407int ZdcCablingService::hwid2gain ( int crate, int channel ) const
408{
409 int ic = crate_index_lookup(crate);
410 if (ic<0) return -1;
411
412 int gain = m_gain_db[ic][channel];
413 //std::cout << "crate =" << crate << " channel="<<channel<< " ic="<<ic<<" channel="<<channel<<" gain=" << gain<<std::endl;
414 return gain;
415}
416
417int ZdcCablingService::hwid2delay ( int crate, int channel ) const
418{
419
420 int ic = crate_index_lookup(crate);
421 if (ic<0) return -1;
422
423 int delay = m_delay_db[ic][channel];
424 //std::cout << "crate =" << crate << " channel="<<channel<< " ic="<<ic<<" channel="<<channel<<" delay=" << delay<<std::endl;
425 return delay;
426}
427
428int ZdcCablingService::hwid2hv ( int crate, int channel ) const
429{
430 int ic = crate_index_lookup(crate);
431 if (ic<0) return -1;
432
433 int hv = m_hv_db[ic][channel];
434 return hv;
435}
436
437
438
440{
441 // mapping from module (offline id) to drawer (onile id)
442 // NC - not connected
443 //const int NC = 65;
444 //const int PB = 0;
445 // PB - possibly broken E3, but for the moment assume that this channel is still alive
446
447}
448
449
450/*
451int ZdcCablingService::swid2ppm( int side, int module, int type) const
452{
453 int ppm = m_ppm_lookup[side][module][type];
454 return ppm;
455}
456
457int ZdcCablingService::swid2channel(int side, int module, int type, int channel, int gain, int delay) const
458{
459 int hwchannel = m_channel_lookup[side][module][type][channel][gain][delay];
460 return hwchannel;
461}
462*/
463
double delay(std::size_t d)
int hwid2type(int crate, int channel) const
void setConnected(int ppm, int channel)
int hwid2side(int crate, int channel) const
static void deleteInstance()
delete service instance
int crate_index_lookup(int &crate) const
int hwid2hv(int crate, int channel) const
ZdcCablingService(const ZdcID *zdcID)
Default constructor protected.
int hwid2gain(int crate, int channel) const
int hwid2channel(int crate, int channel) const
static const ZdcCablingService * getInstance()
get pointer to service instance
const ZdcID * m_zdcID
virtual ~ZdcCablingService()
Destructor protected.
int hwid2delay(int crate, int channel) const
int hwid2module(int crate, int channel) const
Identifier h2s_channel_id(int crate, int channel) const
Definition ZdcID.h:25