ATLAS Offline Software
Loading...
Searching...
No Matches
SectorLogicSetup.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9#include <iomanip>
10
11using namespace RPC_CondCabling;
12
13SectorLogicSetup::SectorLogicSetup(int type, const std::string& database, const std::string& layout, bool conf) :
14 BaseObject(Logic, "Sector Logic Map"),
18 m_online_database (database),
20 m_cosmic (conf)
21{
22}
23
24std::string SectorLogicSetup::no_elements(const std::string& tech, int stat) {
25 std::ostringstream disp;
26 disp << "No " << tech << " elements for Sector Type " << m_sector_type;
27 if (stat) disp << ", station " << stat;
28 disp << "!" << std::endl;
29 return disp.str();
30}
31
33 if (!station) return;
34 typedef StationMap::const_iterator cIter;
35 std::pair<cIter, cIter> p = m_stations.equal_range(type);
36 for (cIter it = p.first; it != p.second; ++it) {
37 if ((*it).second == station) return;
38 }
39 m_stations.insert(StationMap::value_type(type, station));
40}
41
42bool SectorLogicSetup::setup(MsgStream& log) {
43 using sIter = StationMap::const_iterator;
44
45 bool RPCsetup = true;
47 for (sIter it = m_stations.begin(); it != m_stations.end(); ++it) {
48 int key = (*it).second * 100;
49 RPCmap::iterator lower = m_RPCs.lower_bound(key);
50 RPCmap::iterator upper = m_RPCs.upper_bound(key + 99);
51 int size = distance(lower, upper);
52 if (size) {
53 for (RPCmap::iterator rpc = lower; rpc != upper; ++rpc) RPCsetup &= (*rpc).second.setup(*this);
54 } else {
55 log << MSG::ERROR << no_elements("RPC", (*it).second) << endmsg;
56 RPCsetup = false;
57 }
58 }
59 bool WORsetup = true;
61 for (sIter it = m_stations.begin(); it != m_stations.end(); ++it) {
62 int key = (*it).second * 100;
63 WORmap::iterator lower = m_WORs.lower_bound(key);
64 WORmap::iterator upper = m_WORs.upper_bound(key + 99);
65 int size = distance(lower, upper);
66 if (size) {
67 for (WORmap::iterator wor = lower; wor != upper; ++wor) WORsetup &= (*wor).second.setup(*this);
68 } else {
69 log << MSG::ERROR << no_elements("WOR", (*it).second) << endmsg;
70 WORsetup = false;
71 }
72 }
73
74 bool EtaCMAsetup = true;
75 bool EvenPhiCMAsetup = true;
76 bool OddPhiCMAsetup = true;
78 if (!m_etaCMAs.empty()) {
79 SectorLogicSetup::EtaCMAmap::iterator it;
80 for (it = m_etaCMAs.begin(); it != m_etaCMAs.end(); ++it) { EtaCMAsetup &= (*it).second.setup(*this, log); }
81
82 } else {
83 log << MSG::ERROR << no_elements("EtaCMA", 0) << endmsg;
84 EtaCMAsetup = false;
85 }
86
87 if (!m_evenphiCMAs.empty()) {
88 SectorLogicSetup::EvenPhiCMAmap::iterator it;
89 for (it = m_evenphiCMAs.begin(); it != m_evenphiCMAs.end(); ++it) EvenPhiCMAsetup &= (*it).second.setup(*this, log);
90 }
91
92 if (!m_oddphiCMAs.empty()) {
93 SectorLogicSetup::OddPhiCMAmap::iterator it;
94 for (it = m_oddphiCMAs.begin(); it != m_oddphiCMAs.end(); ++it) OddPhiCMAsetup &= (*it).second.setup(*this, log);
95 }
96
97 return RPCsetup & WORsetup & EtaCMAsetup & EvenPhiCMAsetup & OddPhiCMAsetup;
98}
99
101 using sIter = StationMap::const_iterator;
102 using rIter = RPCmap::iterator;
103 using wIter = WORmap::iterator;
104 std::pair<sIter, sIter> pivot = m_stations.equal_range(Pivot);
105
106 bool RPCcheck = true;
108 for (sIter stat = pivot.first; stat != pivot.second; ++stat) {
109 int Lkey = (*stat).second * 100;
110 int Ukey = (*stat).second * 100 + 99;
111 for (rIter it = m_RPCs.lower_bound(Lkey); it != m_RPCs.upper_bound(Ukey); ++it) { RPCcheck &= (*it).second.check(); }
112 }
113
114 bool WORcheck = true;
116 for (sIter stat = pivot.first; stat != pivot.second; ++stat) {
117 int Lkey = (*stat).second * 100;
118 int Ukey = (*stat).second * 100 + 99;
119 for (wIter it = m_WORs.lower_bound(Lkey); it != m_WORs.upper_bound(Ukey); ++it) {}
120 }
121
122 return RPCcheck & WORcheck;
123}
124
126 RPCmap::iterator result = m_RPCs.find(stat * 100 + num);
127 if (result != m_RPCs.end())
128 return &(*result).second;
129 else
130 return nullptr;
131}
132
133const RPCchamber* SectorLogicSetup::find_chamber(int stat, int num) const {
134 RPCmap::const_iterator result = m_RPCs.find(stat * 100 + num);
135 if (result != m_RPCs.end())
136 return &(*result).second;
137 else
138 return nullptr;
139}
140
142 WORmap::iterator result = m_WORs.find(stat * 100 + num);
143 if (result != m_WORs.end())
144 return &(*result).second;
145 else
146 return nullptr;
147}
148
150 WORmap::iterator result = m_WORs.find(wor.station() * 100 + wor.number());
151 WORmap::iterator begin = m_WORs.lower_bound(wor.station() * 100);
152 if (result == m_WORs.end() || result == begin) return nullptr;
153 --result;
154 return &(*result).second;
155}
156
158 EtaCMAmap::iterator result = m_etaCMAs.find(cma.id());
159 if (result == m_etaCMAs.end() || result == m_etaCMAs.begin()) return nullptr;
160 --result;
161 return &(*result).second;
162}
163
165 EvenPhiCMAmap::iterator result = m_evenphiCMAs.find(cma.id());
166 if (result == m_evenphiCMAs.end() || result == m_evenphiCMAs.begin()) return nullptr;
167 --result;
168 return &(*result).second;
169}
170
172 OddPhiCMAmap::iterator result = m_oddphiCMAs.find(cma.id());
173 if (result == m_oddphiCMAs.end() || result == m_oddphiCMAs.begin()) return nullptr;
174 --result;
175 return &(*result).second;
176}
177
178std::list<const EtaCMA*> SectorLogicSetup::find_eta_CMAs_in_PAD(int pad) {
179 std::list<const EtaCMA*> CMAlist;
180 EtaCMAmap::const_iterator it = m_etaCMAs.begin();
181 while (it != m_etaCMAs.end()) {
182 const EtaCMA* cma = &(*it).second;
183 if (cma->id().PAD_index() == pad) CMAlist.push_back(cma);
184 ++it;
185 }
186 return CMAlist;
187}
188
189SectorLogicSetup::EvenPhiCMAmap::const_iterator SectorLogicSetup::find_evenphiCMA(int PAD, int Ixx) const {
190 EvenPhiCMAmap::const_iterator it = m_evenphiCMAs.begin();
191 while (it != m_evenphiCMAs.end()) {
192 const EvenPhiCMA* cma = &(*it).second;
193 if (cma->id().PAD_index() == PAD && cma->id().Ixx_index() == Ixx) return it;
194 ++it;
195 }
196 return m_evenphiCMAs.end();
197}
198
199SectorLogicSetup::OddPhiCMAmap::const_iterator SectorLogicSetup::find_oddphiCMA(int PAD, int Ixx) const {
200 OddPhiCMAmap::const_iterator it = m_oddphiCMAs.begin();
201 while (it != m_oddphiCMAs.end()) {
202 const OddPhiCMA* cma = &(*it).second;
203 if (cma->id().PAD_index() == PAD && cma->id().Ixx_index() == Ixx) return it;
204 ++it;
205 }
206 return m_oddphiCMAs.end();
207}
208
209SectorLogicSetup::EtaCMAmap::const_iterator SectorLogicSetup::find_etaCMA(int PAD, int Ixx) const {
210 EtaCMAmap::const_iterator it = m_etaCMAs.begin();
211 while (it != m_etaCMAs.end()) {
212 const EtaCMA* cma = &(*it).second;
213 if (cma->id().PAD_index() == PAD && cma->id().Ixx_index() == Ixx) return it;
214 ++it;
215 }
216 return m_etaCMAs.end();
217}
218
219SectorLogicSetup::EvenPhiCMAmap::iterator SectorLogicSetup::find_evenphiCMA(int PAD, int Ixx) {
220 EvenPhiCMAmap::iterator it = m_evenphiCMAs.begin();
221 while (it != m_evenphiCMAs.end()) {
222 const EvenPhiCMA* cma = &(*it).second;
223 if (cma->id().PAD_index() == PAD && cma->id().Ixx_index() == Ixx) return it;
224 ++it;
225 }
226 return m_evenphiCMAs.end();
227}
228
229SectorLogicSetup::OddPhiCMAmap::iterator SectorLogicSetup::find_oddphiCMA(int PAD, int Ixx) {
230 OddPhiCMAmap::iterator it = m_oddphiCMAs.begin();
231 while (it != m_oddphiCMAs.end()) {
232 const OddPhiCMA* cma = &(*it).second;
233 if (cma->id().PAD_index() == PAD && cma->id().Ixx_index() == Ixx) return it;
234 ++it;
235 }
236 return m_oddphiCMAs.end();
237}
238
239SectorLogicSetup::EtaCMAmap::iterator SectorLogicSetup::find_etaCMA(int PAD, int Ixx) {
240 EtaCMAmap::iterator it = m_etaCMAs.begin();
241 while (it != m_etaCMAs.end()) {
242 const EtaCMA* cma = &(*it).second;
243 if (cma->id().PAD_index() == PAD && cma->id().Ixx_index() == Ixx) return it;
244 ++it;
245 }
246 return m_etaCMAs.end();
247}
248
249bool SectorLogicSetup::global_strip_add(ViewType side, HalfType h_barrel, int station, int rpc_index, int strip_number,
250 int& global_address) const {
251 RPCmap::const_iterator result = m_RPCs.find(station * 100 + rpc_index);
252 if (result == m_RPCs.end()) return false;
253 return (*result).second.global_strip(side, h_barrel, strip_number, global_address);
254}
255
256bool SectorLogicSetup::local_strip_add(ViewType side, int station, int global_address, int& rpc_index, int& strip_number) const {
257 if (side == Eta) {
258 RPCmap::const_iterator it = m_RPCs.lower_bound(station * 100);
259 while (it != m_RPCs.upper_bound(station * 100 + 99)) {
260 if ((*it).second.Gstrip_2_Lnumber(side, global_address, strip_number)) {
261 rpc_index = (*it).second.number();
262 return true;
263 }
264 ++it;
265 }
266 }
267 if (side == Phi) { return false; }
268
269 return false;
270}
271
272bool SectorLogicSetup::global_conn_add(ViewType side, HalfType h_barrel, int station, int rpc_index, int strip_number, int& global_address,
273 int& low_eta_strips, int& hi_eta_strips) const {
274 RPCmap::const_iterator result = m_RPCs.find(station * 100 + rpc_index);
275 if (result == m_RPCs.end()) return false;
276 return (*result).second.global_connector(side, h_barrel, strip_number, global_address, low_eta_strips, hi_eta_strips);
277}
278
279bool SectorLogicSetup::local_conn_add(ViewType side, int station, int global_address, int& c_number, int& rpc_index,
280 int& strip_number) const {
281 if (side == Eta) {
282 RPCmap::const_iterator it = m_RPCs.lower_bound(station * 100);
283 while (it != m_RPCs.upper_bound(station * 100 + 99)) {
284 if ((*it).second.Gconn_2_Lnumber(side, global_address, c_number, strip_number)) {
285 rpc_index = (*it).second.number();
286 return true;
287 }
288 ++it;
289 }
290 }
291 if (side == Phi) { return false; }
292
293 return false;
294}
295
296const CMAparameters::CMAlist SectorLogicSetup::give_CMAs(const int sector, const ViewType side, const int station,
297 const int cabling_code) const {
299 if (side == Eta) {
300 EtaCMAmap::const_iterator it = m_etaCMAs.begin();
301 while (it != m_etaCMAs.end()) {
302 const CMAinput IO = (*it).second.whichCMAinput(station);
303 const CMAparameters* cma = (*it).second.test(IO, cabling_code);
304 if (cma) list.push_back(cma);
305 ++it;
306 }
307 } else if (side == Phi) {
308 if (sector % 2) { // odd
309 OddPhiCMAmap::const_iterator it = m_oddphiCMAs.begin();
310 while (it != m_oddphiCMAs.end()) {
311 const CMAinput IO = (*it).second.whichCMAinput(station);
312 const CMAparameters* cma = (*it).second.test(IO, cabling_code);
313 if (cma) list.push_back(cma);
314 ++it;
315 }
316 } else { // even
317 EvenPhiCMAmap::const_iterator it = m_evenphiCMAs.begin();
318 while (it != m_evenphiCMAs.end()) {
319 const CMAinput IO = (*it).second.whichCMAinput(station);
320 const CMAparameters* cma = (*it).second.test(IO, cabling_code);
321 if (cma) list.push_back(cma);
322 ++it;
323 }
324 }
325 }
326 return list;
327}
328
330 const CMAidentity& PHI,
331 unsigned int& firstEtaCode, unsigned int& lastEtaCode,
332 unsigned int& firstPhiCode, unsigned int& lastPhiCode) const {
333 EtaCMAmap::const_iterator etaCMA = find_etaCMA(ETA.PAD_index(), ETA.Ixx_index());
334 if (etaCMA == m_etaCMAs.end()) return false;
335
336 firstEtaCode = (*etaCMA).second.first_pivot_code();
337 lastEtaCode = (*etaCMA).second.last_pivot_code();
338
339 if (PHI.coverage() == OddSectors) {
340 OddPhiCMAmap::const_iterator phiCMA = find_oddphiCMA(PHI.PAD_index(), PHI.Ixx_index());
341 if (phiCMA == m_oddphiCMAs.end()) return false;
342 firstPhiCode = (*phiCMA).second.first_pivot_code();
343 lastPhiCode = (*phiCMA).second.last_pivot_code();
344 } else if (PHI.coverage() == EvenSectors) {
345 EvenPhiCMAmap::const_iterator phiCMA = find_evenphiCMA(PHI.PAD_index(), PHI.Ixx_index());
346 if (phiCMA == m_evenphiCMAs.end()) return false;
347 firstPhiCode = (*phiCMA).second.first_pivot_code();
348 lastPhiCode = (*phiCMA).second.last_pivot_code();
349 } else
350 return false;
351
352 return firstEtaCode != lastEtaCode;
353}
354
356 const CMAidentity& PHI,
357 unsigned int& firstEtaCode, unsigned int& lastEtaCode,
358 unsigned int& firstPhiCode, unsigned int& lastPhiCode) const {
359 EtaCMAmap::const_iterator etaCMA = find_etaCMA(ETA.PAD_index(), ETA.Ixx_index());
360 if (etaCMA == m_etaCMAs.end()) return false;
361
362 firstEtaCode = (*etaCMA).second.first_lowPt_code();
363 lastEtaCode = (*etaCMA).second.last_lowPt_code();
364
365 if (PHI.coverage() == OddSectors) {
366 OddPhiCMAmap::const_iterator phiCMA = find_oddphiCMA(PHI.PAD_index(), PHI.Ixx_index());
367 if (phiCMA == m_oddphiCMAs.end()) return false;
368 firstPhiCode = (*phiCMA).second.first_lowPt_code();
369 lastPhiCode = (*phiCMA).second.last_lowPt_code();
370 } else if (PHI.coverage() == EvenSectors) {
371 EvenPhiCMAmap::const_iterator phiCMA = find_evenphiCMA(PHI.PAD_index(), PHI.Ixx_index());
372 if (phiCMA == m_evenphiCMAs.end()) return false;
373 firstPhiCode = (*phiCMA).second.first_lowPt_code();
374 lastPhiCode = (*phiCMA).second.last_lowPt_code();
375 } else
376 return false;
377
378 return true;
379}
380
382 const CMAidentity& PHI,
383 unsigned int& firstEtaCode, unsigned int& lastEtaCode,
384 unsigned int& firstPhiCode, unsigned int& lastPhiCode) const {
385 EtaCMAmap::const_iterator etaCMA = find_etaCMA(ETA.PAD_index(), ETA.Ixx_index());
386 if (etaCMA == m_etaCMAs.end()) return false;
387
388 firstEtaCode = (*etaCMA).second.first_highPt_code();
389 lastEtaCode = (*etaCMA).second.last_highPt_code();
390
391 if (PHI.coverage() == OddSectors) {
392 OddPhiCMAmap::const_iterator phiCMA = find_oddphiCMA(PHI.PAD_index(), PHI.Ixx_index());
393 if (phiCMA == m_oddphiCMAs.end()) return false;
394 firstPhiCode = (*phiCMA).second.first_highPt_code();
395 lastPhiCode = (*phiCMA).second.last_highPt_code();
396 } else if (PHI.coverage() == EvenSectors) {
397 EvenPhiCMAmap::const_iterator phiCMA = find_evenphiCMA(PHI.PAD_index(), PHI.Ixx_index());
398 if (phiCMA == m_evenphiCMAs.end()) return false;
399 firstPhiCode = (*phiCMA).second.first_highPt_code();
400 lastPhiCode = (*phiCMA).second.last_highPt_code();
401 } else
402 return false;
403
404 return true;
405}
406
407bool SectorLogicSetup::give_LowPt_layout(const CMAidentity& ID, unsigned short int& start_pivot_ch, unsigned int& start_pivot_code,
408 unsigned short int& stop_pivot_ch, unsigned int& stop_pivot_code,
409 unsigned short int& start_confirm_ch, unsigned int& start_confirm_code,
410 unsigned short int& stop_confirm_ch, unsigned int& stop_confirm_code) const {
411 if (ID.type() == Eta) {
412 EtaCMAmap::const_iterator etaCMA = find_etaCMA(ID.PAD_index(), ID.Ixx_index());
413 if (etaCMA == m_etaCMAs.end()) return false;
414
415 start_pivot_code = (*etaCMA).second.first_pivot_code();
416 stop_pivot_code = (*etaCMA).second.last_pivot_code();
417 start_confirm_code = (*etaCMA).second.first_lowPt_code();
418 stop_confirm_code = (*etaCMA).second.last_lowPt_code();
419
420 start_pivot_ch = (*etaCMA).second.first_pivot_channel();
421 stop_pivot_ch = (*etaCMA).second.last_pivot_channel();
422 start_confirm_ch = (*etaCMA).second.first_lowPt_channel();
423 stop_confirm_ch = (*etaCMA).second.last_lowPt_channel();
424 } else {
425 if (ID.coverage() == OddSectors) {
426 OddPhiCMAmap::const_iterator phiCMA = find_oddphiCMA(ID.PAD_index(), ID.Ixx_index());
427 if (phiCMA == m_oddphiCMAs.end()) return false;
428
429 start_pivot_code = (*phiCMA).second.first_pivot_code();
430 stop_pivot_code = (*phiCMA).second.last_pivot_code();
431 start_confirm_code = (*phiCMA).second.first_lowPt_code();
432 stop_confirm_code = (*phiCMA).second.last_lowPt_code();
433
434 start_pivot_ch = (*phiCMA).second.first_pivot_channel();
435 stop_pivot_ch = (*phiCMA).second.last_pivot_channel();
436 start_confirm_ch = (*phiCMA).second.first_lowPt_channel();
437 stop_confirm_ch = (*phiCMA).second.last_lowPt_channel();
438 } else {
439 EvenPhiCMAmap::const_iterator phiCMA = find_evenphiCMA(ID.PAD_index(), ID.Ixx_index());
440 if (phiCMA == m_evenphiCMAs.end()) return false;
441 start_pivot_code = (*phiCMA).second.first_pivot_code();
442 stop_pivot_code = (*phiCMA).second.last_pivot_code();
443 start_confirm_code = (*phiCMA).second.first_lowPt_code();
444 stop_confirm_code = (*phiCMA).second.last_lowPt_code();
445
446 start_pivot_ch = (*phiCMA).second.first_pivot_channel();
447 stop_pivot_ch = (*phiCMA).second.last_pivot_channel();
448 start_confirm_ch = (*phiCMA).second.first_lowPt_channel();
449 stop_confirm_ch = (*phiCMA).second.last_lowPt_channel();
450 }
451 }
452
453 return !(start_confirm_ch == 999 || stop_confirm_ch == 999);
454}
455
456bool SectorLogicSetup::give_HighPt_layout(const CMAidentity& ID, unsigned short int& start_pivot_ch, unsigned int& start_pivot_code,
457 unsigned short int& stop_pivot_ch, unsigned int& stop_pivot_code,
458 unsigned short int& start_confirm_ch, unsigned int& start_confirm_code,
459 unsigned short int& stop_confirm_ch, unsigned int& stop_confirm_code) const {
460 if (ID.type() == Eta) {
461 EtaCMAmap::const_iterator etaCMA = find_etaCMA(ID.PAD_index(), ID.Ixx_index());
462 if (etaCMA == m_etaCMAs.end()) return false;
463
464 start_pivot_code = (*etaCMA).second.first_pivot_code();
465 stop_pivot_code = (*etaCMA).second.last_pivot_code();
466 start_confirm_code = (*etaCMA).second.first_highPt_code();
467 stop_confirm_code = (*etaCMA).second.last_highPt_code();
468
469 start_pivot_ch = (*etaCMA).second.first_pivot_channel();
470 stop_pivot_ch = (*etaCMA).second.last_pivot_channel();
471 start_confirm_ch = (*etaCMA).second.first_highPt_channel();
472 stop_confirm_ch = (*etaCMA).second.last_highPt_channel();
473 } else {
474 if (ID.coverage() == OddSectors) {
475 OddPhiCMAmap::const_iterator phiCMA = find_oddphiCMA(ID.PAD_index(), ID.Ixx_index());
476 if (phiCMA == m_oddphiCMAs.end()) return false;
477
478 start_pivot_code = (*phiCMA).second.first_pivot_code();
479 stop_pivot_code = (*phiCMA).second.last_pivot_code();
480 start_confirm_code = (*phiCMA).second.first_highPt_code();
481 stop_confirm_code = (*phiCMA).second.last_highPt_code();
482
483 start_pivot_ch = (*phiCMA).second.first_pivot_channel();
484 stop_pivot_ch = (*phiCMA).second.last_pivot_channel();
485 start_confirm_ch = (*phiCMA).second.first_highPt_channel();
486 stop_confirm_ch = (*phiCMA).second.last_highPt_channel();
487 } else {
488 EvenPhiCMAmap::const_iterator phiCMA = find_evenphiCMA(ID.PAD_index(), ID.Ixx_index());
489 if (phiCMA == m_evenphiCMAs.end()) return false;
490 start_pivot_code = (*phiCMA).second.first_pivot_code();
491 stop_pivot_code = (*phiCMA).second.last_pivot_code();
492 start_confirm_code = (*phiCMA).second.first_highPt_code();
493 stop_confirm_code = (*phiCMA).second.last_highPt_code();
494
495 start_pivot_ch = (*phiCMA).second.first_pivot_channel();
496 stop_pivot_ch = (*phiCMA).second.last_pivot_channel();
497 start_confirm_ch = (*phiCMA).second.first_highPt_channel();
498 stop_confirm_ch = (*phiCMA).second.last_highPt_channel();
499 }
500 }
501
502 return !(start_confirm_ch == 999 || stop_confirm_ch == 999);
503}
504
506 if (CMA.type() == Eta) {
507 EtaCMAmap::const_iterator etaCMA = find_etaCMA(CMA.PAD_index(), CMA.Ixx_index());
508 return (etaCMA != m_etaCMAs.end()) ? &((*etaCMA).second) : nullptr;
509 }
510 if (CMA.type() == Phi) {
511 if (CMA.coverage() == EvenSectors) {
512 EvenPhiCMAmap::const_iterator phiCMA = find_evenphiCMA(CMA.PAD_index(), CMA.Ixx_index());
513 return (phiCMA != m_evenphiCMAs.end()) ? &((*phiCMA).second) : nullptr;
514 }
515 if (CMA.coverage() == OddSectors) {
516 OddPhiCMAmap::const_iterator phiCMA = find_oddphiCMA(CMA.PAD_index(), CMA.Ixx_index());
517 return (phiCMA != m_oddphiCMAs.end()) ? &((*phiCMA)).second : nullptr;
518 }
519 }
520
521 return nullptr;
522}
523
525 L1RPCcabCorrection type, CMAinput it, unsigned int ly, unsigned short int Channel1,
526 unsigned short int Channel2, short int number) const {
527 if (CMA.type() == Eta) {
528 EtaCMAmap::const_iterator etaCMA = find_etaCMA(CMA.PAD_index(), CMA.Ixx_index());
529 return (*etaCMA).second.correct(type, it, ly, Channel1, Channel2, number);
530 }
531 if (CMA.type() == Phi) {
532 if (CMA.coverage() == EvenSectors) {
533 EvenPhiCMAmap::const_iterator phiCMA = find_evenphiCMA(CMA.PAD_index(), CMA.Ixx_index());
534 return (*phiCMA).second.correct(type, it, ly, Channel1, Channel2, number);
535 }
536 if (CMA.coverage() == OddSectors) {
537 OddPhiCMAmap::const_iterator phiCMA = find_oddphiCMA(CMA.PAD_index(), CMA.Ixx_index());
538 return (*phiCMA).second.correct(type, it, ly, Channel1, Channel2, number);
539 }
540 }
541 return false;
542}
543
544std::list<unsigned int> SectorLogicSetup::give_strip_code(const CMAidentity& CMA,
545 int logic_sector, unsigned short int lh, unsigned short int ijk,
546 unsigned short int Channel) const {
547 std::list<unsigned int> StripCodes;
548
549 if (CMA.type() == Eta) {
550 EtaCMAmap::const_iterator etaCMA = find_etaCMA(CMA.PAD_index(), CMA.Ixx_index());
551
552 if (etaCMA == m_etaCMAs.end()) return StripCodes;
553 (*etaCMA).second.give_strip_code(logic_sector, lh, ijk, Channel, StripCodes);
554 }
555 if (CMA.type() == Phi) {
556 if (CMA.coverage() == EvenSectors) {
557 EvenPhiCMAmap::const_iterator phiCMA = find_evenphiCMA(CMA.PAD_index(), CMA.Ixx_index());
558 if (phiCMA == m_evenphiCMAs.end()) return StripCodes;
559 (*phiCMA).second.give_strip_code(logic_sector, lh, ijk, Channel, StripCodes);
560 }
561 if (CMA.coverage() == OddSectors) {
562 OddPhiCMAmap::const_iterator phiCMA = find_oddphiCMA(CMA.PAD_index(), CMA.Ixx_index());
563 if (phiCMA == m_oddphiCMAs.end()) return StripCodes;
564 (*phiCMA).second.give_strip_code(logic_sector, lh, ijk, Channel, StripCodes);
565 }
566 }
567
568 return StripCodes;
569}
570
572 m_sectors.push_back(sector);
573
574 std::ostringstream str;
575 if (sector < 32) {
576 str << std::setw(3) << sector << std::ends;
577 m_negative_sector += str.str();
578 } else {
579 str << std::setw(3) << sector - 32 << std::ends;
580 m_positive_sector += str.str();
581 }
582
583 return *this;
584}
585
586void SectorLogicSetup::PrintElement(std::ostream& stream, int station, const std::string& ele, int obj, bool detail) const {
587 int klw = station * 100;
588 int khg = station * 100 + 99;
589
590 if (station == 0) khg = 10 * 100 + 99;
591
592 bool all = ele == name() || ele.empty();
593 bool printed = false;
594
595 bool nRPC = !m_RPCs.empty();
596 bool nWOR = !m_WORs.empty();
597 bool nEtaCMA = !m_etaCMAs.empty();
598 bool nEvenPhiCMA = !m_evenphiCMAs.empty();
599 bool nOddPhiCMA = !m_oddphiCMAs.empty();
600
601 stream << name() << " type n. " << sector_type() << std::endl;
602 stream << "It applies to negative logic sector n. ";
603 stream << negative_sector() << std::endl;
604 stream << " logic sector n. ";
605 stream << positive_sector() << std::endl;
606
607 if (nRPC && (ele == (*m_RPCs.begin()).second.name() || all)) {
608 printed = true;
609 RPCmap::const_iterator low = m_RPCs.lower_bound(klw);
610 RPCmap::const_iterator high = m_RPCs.upper_bound(khg);
611 stream << "It contains " << distance(low, high);
612 stream << " RPCs chamber on station " << station << std::endl;
613
614 for (RPCmap::const_iterator it = low; it != high; ++it) {
615 if (!obj)
616 (*it).second.Print(stream, detail);
617 else if (obj == (*it).second.number())
618 (*it).second.Print(stream, detail);
619 }
620 }
621
622 if (nWOR && (ele == (*m_WORs.begin()).second.name() || all)) {
623 printed = true;
624 WORmap::const_iterator low = m_WORs.lower_bound(klw);
625 WORmap::const_iterator high = m_WORs.upper_bound(khg);
626 stream << "It contains " << distance(low, high);
627 stream << " WORs links on station " << station << std::endl;
628
629 for (WORmap::const_iterator it = low; it != high; ++it) {
630 if (!obj)
631 (*it).second.Print(stream, detail);
632 else if (obj == (*it).second.number())
633 (*it).second.Print(stream, detail);
634 }
635 }
636
637 if (nEtaCMA && (ele == (*m_etaCMAs.begin()).second.name() || all)) {
638 printed = true;
639 stream << "It contains " << m_etaCMAs.size() << " eta CMA:" << std::endl;
640 EtaCMAmap::const_iterator ei;
641 for (ei = m_etaCMAs.begin(); ei != m_etaCMAs.end(); ++ei) {
642 if (!obj)
643 (*ei).second.Print(stream, detail);
644 else if (obj == (*ei).second.number())
645 (*ei).second.Print(stream, detail);
646 }
647 }
648
649 if (nEvenPhiCMA && (ele == (*m_evenphiCMAs.begin()).second.name() || all)) {
650 printed = true;
651 stream << "It contains ";
652 stream << m_evenphiCMAs.size() << " even phi CMA:" << std::endl;
653 EvenPhiCMAmap::const_iterator ev;
654
655 for (ev = m_evenphiCMAs.begin(); ev != m_evenphiCMAs.end(); ++ev) {
656 if (!obj)
657 (*ev).second.Print(stream, detail);
658 else if (obj == (*ev).second.number())
659 (*ev).second.Print(stream, detail);
660 }
661 }
662
663 if (nOddPhiCMA && (ele == (*m_oddphiCMAs.begin()).second.name() || all)) {
664 printed = true;
665 stream << "It contains ";
666 stream << m_oddphiCMAs.size() << " odd phi CMA:" << std::endl;
667 OddPhiCMAmap::const_iterator od;
668
669 for (od = m_oddphiCMAs.begin(); od != m_oddphiCMAs.end(); ++od) {
670 if (!obj)
671 (*od).second.Print(stream, detail);
672 else if (obj == (*od).second.number())
673 (*od).second.Print(stream, detail);
674 }
675 }
676
677 if (ele == "CMA") {
678 printed = true;
679
680 stream << "It contains " << m_etaCMAs.size() << " eta CMA:" << std::endl;
681 EtaCMAmap::const_iterator ei;
682 stream << "nome=" << (*m_etaCMAs.begin()).second.name() << std::endl;
683 for (ei = m_etaCMAs.begin(); ei != m_etaCMAs.end(); ++ei) {
684 if (!obj)
685 (*ei).second.Print(stream, detail);
686 else if (obj == (*ei).second.number())
687 (*ei).second.Print(stream, detail);
688 }
689
690 stream << "plus ";
691 stream << m_evenphiCMAs.size() << " even phi CMA:" << std::endl;
692 EvenPhiCMAmap::const_iterator ev;
693 for (ev = m_evenphiCMAs.begin(); ev != m_evenphiCMAs.end(); ++ev) {
694 if (!obj)
695 (*ev).second.Print(stream, detail);
696 else if (obj == (*ev).second.number())
697 (*ev).second.Print(stream, detail);
698 }
699
700 stream << "plus ";
701 stream << m_oddphiCMAs.size() << " odd phi CMA:" << std::endl;
702 OddPhiCMAmap::const_iterator od;
703 for (od = m_oddphiCMAs.begin(); od != m_oddphiCMAs.end(); ++od) {
704 if (!obj)
705 (*od).second.Print(stream, detail);
706 else if (obj == (*od).second.number())
707 (*od).second.Print(stream, detail);
708 }
709 }
710
711 if (!printed) {
712 stream << std::endl;
713 stream << "No " << ele << " elements are present into this map!" << std::endl;
714 }
715}
716
717std::ostream& operator<<(std::ostream& stream, const SectorLogicSetup& setup) {
718 setup.PrintElement(stream, 0, setup.name(), 0, false);
719 return stream;
720}
721
723 while (std::unique_ptr<RPCchamber> cham = data.give_rpc()) {
724 int key = data.station() * 100;
725 std::pair<RPCmap::iterator, bool> ins = m_RPCs.insert(RPCmap::value_type(key + cham->number(), *cham));
726
727 RPCmap::iterator lower = m_RPCs.lower_bound(key);
728 RPCmap::iterator upper = m_RPCs.upper_bound(key + 99);
729 RPCmap::iterator current = (ins.first);
730
731 if (ins.second) {
732 if (current != lower) --current;
733 while (current != upper) {
734 int div = ((*current).second.number()) ? 1 : 2;
735 int eta_st = (*current).second.eta_strips() / div;
736 int eta_st_of = (*current).second.eta_strip_global() / div;
737 int eta_co = (*current).second.eta_connectors() / div;
738 int eta_co_of = (*current).second.eta_conn_global() / div;
739 ++current;
740 if (current != m_RPCs.end()) {
741 (*current).second.set_eta_st_global(eta_st + eta_st_of);
742 (*current).second.set_eta_co_global(eta_co + eta_co_of);
743 }
744 }
745 } else {
746 std::ostringstream display;
747 PrintElement(display, data.station(), "RPC", 0, false);
748 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "SectorLogicSetup") << "Error in inserting chamber:"
749 << std::endl << *cham << std::endl << "in " << display.str() << endmsg;
750 return ins.second;
751 }
752 }
753 return true;
754}
755
757 while (std::unique_ptr<WiredOR> Wor = data.give_wor()) {
758 int key = data.station() * 100;
759 std::pair<WORmap::iterator, bool> ins = m_WORs.insert(WORmap::value_type(key + Wor->number(), *Wor));
760
761 if (!ins.second) {
762 std::ostringstream display;
763 PrintElement(display, data.station(), "WOR", 0, false);
764 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "SectorLogicSetup") << "Error in inserting WOR:"
765 << std::endl << *Wor << std::endl << "in " << display.str() << endmsg;
766 return ins.second;
767 }
768 }
769 return true;
770}
771
773 while (std::unique_ptr<EtaCMA> CMA{data.give_eta_cma()}) {
774 std::pair<EtaCMAmap::iterator, bool> ins = m_etaCMAs.insert(EtaCMAmap::value_type(CMA->id(), *CMA));
775 if (!ins.second) {
776 EtaCMAmap::iterator inserted = m_etaCMAs.find(CMA->id());
777
778 int cma_start = CMA->pivot_start_ch();
779 int ins_start = (*inserted).second.pivot_start_ch();
780 if (cma_start * ins_start > 0) {
781 std::ostringstream display;
782 PrintElement(display, 0, CMA->name(), 0, false);
783 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "SectorLogicSetup") << "Error in inserting Eta CMA:"
784 << std::endl << *CMA << std::endl << "in " << display.str() << endmsg;
785 return ins.second;
786 }
787 (*inserted).second += *CMA;
788 }
789
790 get_station(LowPt, CMA->lowPt_station());
791 get_station(Pivot, CMA->pivot_station());
792 get_station(HighPt, CMA->highPt_station());
793 }
794
795 while (std::unique_ptr<EvenPhiCMA> CMA{data.give_evenphi_cma()}) {
796 std::pair<EvenPhiCMAmap::iterator, bool> ins = m_evenphiCMAs.insert(EvenPhiCMAmap::value_type(CMA->id(), *CMA));
797 if (!ins.second) {
798 std::ostringstream display;
799 PrintElement(display, 0, CMA->name(), 0, false);
800 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "SectorLogicSetup") << "Error in inserting even Phi CMA:"
801 << std::endl << *CMA << std::endl << "in " << display.str() << endmsg;
802 return ins.second;
803 }
804 }
805
806 while (std::unique_ptr<OddPhiCMA> CMA{data.give_oddphi_cma()}) {
807 std::pair<OddPhiCMAmap::iterator, bool> ins = m_oddphiCMAs.insert(OddPhiCMAmap::value_type(CMA->id(), *CMA));
808 if (!ins.second) {
809 std::ostringstream display;
810 PrintElement(display, 0, CMA->name(), 0, false);
811 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "SectorLogicSetup") << "Error in inserting odd Phi CMA:"
812 << std::endl << *CMA << std::endl << "in " << display.str() << endmsg;
813 return ins.second;
814 }
815 }
816
817 return true;
818}
819
821 while (std::unique_ptr<EtaCMA> CMA = data.give_eta_cma()) {
822 std::pair<EtaCMAmap::iterator, bool> ins = m_etaCMAs.insert(EtaCMAmap::value_type(CMA->id(), *CMA));
823 if (!ins.second) {
824 EtaCMAmap::iterator inserted = m_etaCMAs.find(CMA->id());
825
826 int cma_start = CMA->pivot_start_ch();
827 int ins_start = (*inserted).second.pivot_start_ch();
828 if (cma_start * ins_start > 0) {
829 std::ostringstream display;
830 PrintElement(display, 0, "CMA", 0, false);
831 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "SectorLogicSetup") << "Error in inserting Eta CMA:"
832 << std::endl << *CMA << std::endl << "in " << display.str() << endmsg;
833 return ins.second;
834 }
835 (*inserted).second += *CMA;
836 }
837 }
838 return true;
839}
840
842 if (!m_negative_sector.empty() && m_positive_sector.empty()) return Negative;
843 if (m_negative_sector.empty() && !m_positive_sector.empty()) return Positive;
844 return NoHalf;
845}
846
847void SectorLogicSetup::SetPtoTrigRoads(const std::map<std::string, std::string>* RPC_trigroads) { m_trigroads = RPC_trigroads; }
#define endmsg
@ Logic
Definition BaseObject.h:11
@ OddSectors
Definition CMAidentity.h:14
@ EvenSectors
Definition CMAidentity.h:14
CMAinput
@ LowPt
@ HighPt
@ Pivot
L1RPCcabCorrection
std::vector< Identifier > ID
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
int upper(int c)
ViewType
Definition RPCdef.h:8
HalfType
Definition RPCdef.h:9
@ NoHalf
Definition RPCdef.h:9
@ Positive
Definition RPCdef.h:9
@ Negative
Definition RPCdef.h:9
BaseObject(ObjectType, const std::string &)
Definition BaseObject.cxx:7
const std::string & name() const
Definition BaseObject.h:23
ViewType type() const
int Ixx_index() const
static bool coverage(const std::string &, CMAcoverage &)
int PAD_index() const
const CMAidentity & id() const
const CMAparameters * test(CMAinput, int) const
std::list< const CMAparameters * > CMAlist
int number() const
int station() const
void SetPtoTrigRoads(const std::map< std::string, std::string > *)
bool give_HighPt_layout(const CMAidentity &ID, unsigned short int &start_pivot_ch, unsigned int &start_pivot_code, unsigned short int &stop_pivot_ch, unsigned int &stop_pivot_code, unsigned short int &start_confirm_ch, unsigned int &start_confirm_code, unsigned short int &stop_confirm_ch, unsigned int &stop_confirm_code) const
OddPhiCMAmap::const_iterator find_oddphiCMA(int Eta, int Phi) const
std::string no_elements(const std::string &, int)
bool local_strip_add(ViewType, int, int, int &, int &) const
bool local_conn_add(ViewType, int, int, int &, int &, int &) const
const std::string & negative_sector() const
const std::map< std::string, std::string > * m_trigroads
const CMAparameters * give_CMA(const CMAidentity &CMA) const
EtaCMA * previousCMA(const EtaCMA &)
bool give_HighPt_borders(const CMAidentity &ETA, const CMAidentity &PHI, unsigned int &firstEtaCode, unsigned int &lastEtaCode, unsigned int &firstPhiCode, unsigned int &lastPhiCode) const
const std::string & layout() const
WiredOR * previousWOR(const WiredOR &)
bool global_conn_add(ViewType, HalfType, int, int, int, int &, int &, int &) const
bool give_RoI_borders(const CMAidentity &ETA, const CMAidentity &PHI, unsigned int &firstEtaCode, unsigned int &lastEtaCode, unsigned int &firstPhiCode, unsigned int &lastPhiCode) const
EtaCMAmap::const_iterator find_etaCMA(int Eta, int Phi) const
bool give_LowPt_layout(const CMAidentity &ID, unsigned short int &start_pivot_ch, unsigned int &start_pivot_code, unsigned short int &stop_pivot_ch, unsigned int &stop_pivot_code, unsigned short int &start_confirm_ch, unsigned int &start_confirm_code, unsigned short int &stop_confirm_ch, unsigned int &stop_confirm_code) const
const CMAparameters::CMAlist give_CMAs(const int, const ViewType, const int, const int) const
SectorLogicSetup(int, const std::string &, const std::string &, bool)
bool give_LowPt_borders(const CMAidentity &ETA, const CMAidentity &PHI, unsigned int &firstEtaCode, unsigned int &lastEtaCode, unsigned int &firstPhiCode, unsigned int &lastPhiCode) const
bool correct(const CMAidentity &CMA, L1RPCcabCorrection type, CMAinput it, unsigned int layer, unsigned short int Channel1, unsigned short int Channel2, short int num) const
const RPCchamber * find_chamber(int, int) const
bool global_strip_add(ViewType, HalfType, int, int, int, int &) const
const std::string & positive_sector() const
EvenPhiCMAmap::const_iterator find_evenphiCMA(int Eta, int Phi) const
void PrintElement(std::ostream &, int, const std::string &, int, bool) const
std::list< unsigned int > give_strip_code(const CMAidentity &CMA, int logic_sector, unsigned short int lh, unsigned short int ijk, unsigned short int Channel) const
std::list< const EtaCMA * > find_eta_CMAs_in_PAD(int)
int ev
Definition globals.cxx:25
X & operator<<(X &stream, CMAcablingdata &data)
std::string number(const double &d, const std::string &s)
Definition utils.cxx:186