ATLAS Offline Software
Loading...
Searching...
No Matches
OddPhiCMA.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "GaudiKernel/MsgStream.h"
7
11#include <stdexcept>
12
13#include <fstream>
14
15using namespace RPC_CondCabling;
16
20bool OddPhiCMA::inversion(void) const { return m_inversion; }
21
23 m_inversion = false;
25
26 // Set the memory for storing the cabling data
27 if (!pivot_station()) {
30 }
31 if (!lowPt_station()) {
34 }
35 if (!highPt_station()) {
38 }
39}
40
50
51OddPhiCMA::~OddPhiCMA() = default;
52
54 if (this != &cma) {
56 m_pivot_WORs.clear();
58 m_lowPt_WORs.clear();
60 m_highPt_WORs.clear();
62 m_inversion = cma.inversion();
63 }
64 return *this;
65}
66
68 if (pivot_station()) // Check and connect strips with Pivot matrix channels
69 {
70 WORlink::iterator found = m_pivot_WORs.find(pivot_start_ch());
71 if (found == m_pivot_WORs.end()){
72 throw std::runtime_error("Channel not found in OddPhiCMA::cable_CMA_channels");
73 }
74 WiredOR* wor = found->second;
75
78
79 int start = pivot_start_st();
80 int stop = pivot_stop_st();
81 int max_st = wor->give_max_phi_strips();
82
83 int first_ch_cabled = 32;
84 int last_ch_cabled = -1;
85
86 std::vector<int> multiplicity(max_st);
87
88 for (int i = 0; i < m_pivot_rpc_read; ++i) {
89 const RPCchamber* rpc = wor->connected_rpc(i);
90 int rpc_st = rpc->phi_strips();
91 int cham = rpc->number();
92 int local_strip = max_st - (max_st - start);
93 int final_strip = max_st - (max_st - stop);
94
95 int chs = (id().Ixx_index() == 0) ? pivot_channels - std::abs(stop - start) - 1 : 0;
96 if (chs >= pivot_channels) {
97 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << noMoreChannels("Pivot");
98 return false;
99 }
100 if (chs <= first_ch_cabled) first_ch_cabled = chs;
101
102 do {
103 if (chs == pivot_channels) {
104 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << noMoreChannels("Pivot");
105 return false;
106 }
107 if (local_strip > 0 && local_strip <= rpc_st) {
108 if (rpc->ijk_phiReadout() == 1) {
109 m_pivot[i][0][chs] = cham * 100 + local_strip - 1;
110 m_pivot[i][1][chs] = 10000 + cham * 100 + local_strip - 1;
111 } else {
112 m_pivot[i][1][chs] = cham * 100 + local_strip - 1;
113 m_pivot[i][0][chs] = 10000 + cham * 100 + local_strip - 1;
114 }
115 multiplicity[local_strip - 1] = 1;
116 }
117 ++chs;
118 } while (--local_strip >= final_strip);
119
120 if (chs - 1 >= last_ch_cabled) last_ch_cabled = chs - 1;
121 if (chs > m_active_pivot_chs) m_active_pivot_chs = chs;
122 }
123 wor->add_odd_read_mul(multiplicity);
124
125 // Set first and last connectors code
126 int code = pivot_station() * 100000 + 1 * 100000000;
127 int ch = 0;
128
129 // first_ch_cabled and last_ch_cabled are initialized with "out-of-bound" values
130 // of the m_pivot array; proper values should be assigned during the loop;
131 // the init values though are "misused" for certain conditions, too, therefore
132 // they cannot be changed; but the following if should NEVER fire.
133 if (first_ch_cabled >= pivot_channels || last_ch_cabled < 0) {
134 std::ostringstream disp;
135 disp << "OddPhiCMA::cable_CMA_channels - out of bound array indices! Values:"
136 << first_ch_cabled << ", " << last_ch_cabled
137 << " at " << __FILE__ << ":" << __LINE__ ;
138 throw std::runtime_error(disp.str());
139 }
140
141 // get LowPhi code
142 for (ch = 0; ch < m_pivot_rpc_read; ++ch)
143 if (m_pivot[ch][0][last_ch_cabled] >= 0) break;
144 if (ch == m_pivot_rpc_read) --ch;
145 m_first_pivot_code = code + m_pivot[ch][0][last_ch_cabled];
146
147 // get HighPhi code
148 for (ch = 0; ch < m_pivot_rpc_read; ++ch)
149 if (m_pivot[ch][0][first_ch_cabled] >= 0) break;
150 if (ch == m_pivot_rpc_read) --ch;
151 m_last_pivot_code = code + m_pivot[ch][0][first_ch_cabled];
152 }
153
154 if (lowPt_station() && lowPt_start_ch() != -1) { // Check and connect strips with Low Pt matrix channels
155 for (int i = lowPt_start_ch(); i <= lowPt_stop_ch(); ++i) {
156 WORlink::iterator found = m_lowPt_WORs.find(i);
157 if (found == m_lowPt_WORs.end()){
158 throw std::runtime_error("Channel not found in OddPhiCMA::cable_CMA_channels");
159 }
160 m_lowPt_rpc_read += (*found).second->RPCacquired();
161 }
162
164
165 int start = lowPt_start_st();
166 int stop = lowPt_stop_st();
167 int max_st = get_max_strip_readout(lowPt_station());
168
169 int first_ch_cabled = 64;
170 int last_ch_cabled = -1;
171
172 int r = 0;
173
174 for (int w = lowPt_start_ch(); w <= lowPt_stop_ch(); ++w) {
175 WORlink::iterator found = m_lowPt_WORs.find(w);
176 if (found == m_lowPt_WORs.end()){
177 throw std::runtime_error("Channel not found in OddPhiCMA::cable_CMA_channels");
178 }
179 WiredOR* wor = (*found).second;
180 std::vector<int> multiplicity(wor->give_max_phi_strips(), 0);
181
182 for (int i = 0; i < wor->RPCacquired(); ++i) {
183 const RPCchamber* rpc = wor->connected_rpc(i);
184
185 int rpc_st = rpc->phi_strips();
186 int cham = rpc->number();
187 int local_strip = max_st - (max_st - start);
188 int final_strip = max_st - (max_st - stop);
189
190 int chs = (id().Ixx_index() == 0) ? 40 - max_st / 2 : 0;
191
192 char E = rpc->chamber_name()[2];
193
194 if (E == 'E' && id().Ixx_index() == 1) {
195 // ok for sector 23 (side C [and side A], cm1, ijk=2 and 3)
196 chs = 8;
197 local_strip = 32;
198 final_strip = 1;
199 }
200 if (E == 'E' && id().Ixx_index() == 0) {
201 // ok for sector 23 (side C [and side A], cm0, ijk=2 and 3)
202 chs = 24;
203 local_strip = 32;
204 final_strip = 1;
205 }
206
207 if (chs <= first_ch_cabled) first_ch_cabled = chs;
208 do {
209 if (chs == confirm_channels) {
210 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << noMoreChannels("Low Pt");
211 return false;
212 }
213 if (local_strip > 0 && local_strip <= rpc_st) {
214 if (rpc->ijk_phiReadout() == 1) {
215 m_lowPt[r][0][chs] = cham * 100 + local_strip - 1;
216 m_lowPt[r][1][chs] = 10000 + cham * 100 + local_strip - 1;
217 } else {
218 m_lowPt[r][1][chs] = cham * 100 + local_strip - 1;
219 m_lowPt[r][0][chs] = 10000 + cham * 100 + local_strip - 1;
220 }
221 if (max_st > wor->give_max_phi_strips()) {
222 multiplicity[local_strip - 1] = 1;
223 } else {
224 multiplicity[local_strip - 1 + (max_st - rpc_st)] = 1;
225 }
226 }
227 ++chs;
228 } while (--local_strip >= final_strip);
229
230 ++r;
231 if (chs - 1 >= last_ch_cabled) last_ch_cabled = chs - 1;
232 if (chs > m_active_lowPt_chs) m_active_lowPt_chs = chs;
233 }
234 wor->add_odd_read_mul(multiplicity);
235
236 // Set first and last connectors code
237 int code = lowPt_station() * 100000 + 1 * 100000000;
238 int ch = 0;
239
240 if (last_ch_cabled < 0) {
241 throw std::runtime_error(std::string("RPC_CondCabling: OddPhiCMA - neg. array idx at ") +
242 __FILE__ + ":" + std::to_string(__LINE__));
243 }
244
245 for (ch = 0; ch < m_lowPt_rpc_read; ++ch)
246 if (m_lowPt[ch][0][last_ch_cabled] >= 0) break;
247 if (ch == m_lowPt_rpc_read) --ch;
248 m_first_lowPt_code = code + m_lowPt[ch][0][last_ch_cabled];
249
250 for (ch = 0; ch < m_lowPt_rpc_read; ++ch)
251 if (m_lowPt[ch][0][first_ch_cabled] >= 0) break;
252 if (ch == m_lowPt_rpc_read) --ch;
253 m_last_lowPt_code = code + m_lowPt[ch][0][first_ch_cabled];
254 }
255 }
256
257 if (highPt_station() && highPt_start_ch() != -1) { // Check and connect strips with High Pt matrix channels
258 for (int i = highPt_start_ch(); i <= highPt_stop_ch(); ++i) {
259 WORlink::iterator found = m_highPt_WORs.find(i);
260 if (found == m_highPt_WORs.end()){
261 throw std::runtime_error("Channel not found in OddPhiCMA::cable_CMA_channels");
262 }
263 m_highPt_rpc_read += (*found).second->RPCacquired();
264 }
265
267
268 int start = highPt_start_st();
269 int stop = highPt_stop_st();
271
272 int first_ch_cabled = 64;
273 int last_ch_cabled = -1;
274
275 int r = 0;
276
277 for (int w = highPt_start_ch(); w <= highPt_stop_ch(); ++w) {
278 WORlink::iterator found = m_highPt_WORs.find(w);
279 if (found == m_highPt_WORs.end()){
280 throw std::runtime_error("Channel not found in OddPhiCMA::cable_CMA_channels");
281 }
282 WiredOR* wor = found->second;
283 std::vector<int> multiplicity(wor->give_max_phi_strips(), 0);
284
285 for (int i = 0; i < wor->RPCacquired(); ++i) {
286 const RPCchamber* rpc = wor->connected_rpc(i);
287
288 int rpc_st = rpc->phi_strips();
289 int cham = rpc->number();
290 int local_strip = max_st - (max_st - start);
291 int final_strip = max_st - (max_st - stop);
292
293 int chs = (id().Ixx_index() == 0) ? 40 - max_st / 2 : 0;
294
295 char L = rpc->chamber_name()[2];
296 int sEta = rpc->stationEta();
297
298 bool isBOE = false;
299 if (abs(sEta) == 8 && L == 'L') isBOE = true;
300 if (isBOE && id().Ixx_index() == 1) {
301 chs = 0;
302 local_strip = 52;
303 final_strip = 1;
304 }
305
306 if (isBOE && id().Ixx_index() == 0) {
307 chs = 4;
308 final_strip = 13;
309 local_strip = 64;
310 }
311
312 if (chs <= first_ch_cabled) first_ch_cabled = chs;
313 do {
314 if (chs == confirm_channels) {
315 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << noMoreChannels("High Pt");
316 return false;
317 }
318
319 bool skipChannel = false;
320 if (isBOE && id().Ixx_index() == 1 && ((chs > 3 && chs < 8) || (chs > 39 && chs < 44))) skipChannel = true;
321 if (isBOE && id().Ixx_index() == 0 && ((chs > 19 && chs < 24) || (chs > 55 && chs < 60))) skipChannel = true;
322 if (skipChannel) {
323 ++local_strip;
324 } else {
325 if (local_strip > 0 && local_strip <= rpc_st) {
326 if (rpc->ijk_phiReadout() == 1) {
327 m_highPt[r][0][chs] = cham * 100 + local_strip - 1;
328 m_highPt[r][1][chs] = 10000 + cham * 100 + local_strip - 1;
329 } else {
330 m_highPt[r][1][chs] = cham * 100 + local_strip - 1;
331 m_highPt[r][0][chs] = 10000 + cham * 100 + local_strip - 1;
332 }
333 if (max_st > wor->give_max_phi_strips()) {
334 multiplicity[local_strip - 1] = 1;
335 } else {
336 multiplicity[local_strip - 1 + (max_st - rpc_st)] = 1;
337 }
338 }
339 }
340
341 ++chs;
342 } while (--local_strip >= final_strip);
343
344 ++r;
345 if (chs - 1 >= last_ch_cabled) last_ch_cabled = chs - 1;
347 }
348 wor->add_odd_read_mul(multiplicity);
349
350 // Set first and last connectors code
351 int code = highPt_station() * 100000 + 1 * 100000000;
352 int ch = 0;
353
354 if (last_ch_cabled < 0) {
355 throw std::runtime_error(std::string("RPC_CondCabling: OddPhiCMA - neg. array idx at ") +
356 __FILE__ + ":" + std::to_string(__LINE__));
357 }
358
359 for (ch = 0; ch < m_highPt_rpc_read; ++ch)
360 if (m_highPt[ch][0][last_ch_cabled] >= 0) break;
361 if (ch == m_highPt_rpc_read) --ch;
362 m_first_highPt_code = code + m_highPt[ch][0][last_ch_cabled];
363
364 for (ch = 0; ch < m_highPt_rpc_read; ++ch)
365 if (m_highPt[ch][0][first_ch_cabled] >= 0) break;
366 if (ch == m_highPt_rpc_read) --ch;
367 m_last_highPt_code = code + m_highPt[ch][0][first_ch_cabled];
368 }
369 }
370
371 return true;
372}
373
375 if (pivot_station()) // Check and connect Pivot chambers
376 {
377 for (int i = pivot_start_ch(); i <= pivot_stop_ch(); ++i) {
378 WiredOR* wor = setup.find_wor(pivot_station(), i);
379 if (wor) {
380 wor->add_cma(this);
381 m_pivot_WORs.insert(WORlink::value_type(i, wor));
382 } else {
383 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << no_connection_error("WOR", i);
384 return false;
385 }
386 }
387 }
388 if (lowPt_station()) // Check and connect Low Pt plane chambers
389 {
390 std::list<const EtaCMA*> CMAs = setup.find_eta_CMAs_in_PAD(id().PAD_index());
391 if (CMAs.empty()) {
392 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << "have no Eta matrix into PAD!";
393 return false;
394 }
395
396 // get last CMA fake
397 const EtaCMA* cmaFake = CMAs.back();
398
399 // remove fake CMAs
400 std::list<const EtaCMA*>::iterator cm = CMAs.begin();
401 while (cm != CMAs.end()) {
402 if (!(*cm)->pivot_station() || (*cm)->lowPt_start_ch() == -1) cm = CMAs.erase(cm);
403 ++cm;
404 }
405
406 int start_ch = (CMAs.size()) ? CMAs.front()->lowPt_start_ch() : cmaFake->lowPt_start_ch();
407 int stop_ch = (CMAs.size()) ? CMAs.back()->lowPt_stop_ch() : cmaFake->lowPt_stop_ch();
408
409 if (start_ch != -1 && stop_ch != -1) {
410 RPCchamber* start = setup.find_chamber(lowPt_station(), start_ch);
411 RPCchamber* stop = setup.find_chamber(lowPt_station(), stop_ch);
412
413 if (start->readoutWORs().empty()) {
414 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << no_wor_readout(start->number(), lowPt_station());
415 return false;
416 }
417 if (stop->readoutWORs().empty()) {
418 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << no_wor_readout(stop->number(), lowPt_station());
419 return false;
420 }
421
422 m_lowPt_start_ch = start->readoutWORs().front()->number();
423 m_lowPt_stop_ch = stop->readoutWORs().front()->number();
424 int max = 0;
425
426 for (int i = lowPt_start_ch(); i <= lowPt_stop_ch(); ++i) {
427 WiredOR* wor = setup.find_wor(lowPt_station(), i);
428 if (wor) {
429 wor->add_cma(this);
430 m_lowPt_WORs.insert(WORlink::value_type(i, wor));
431 if (wor->give_max_phi_strips() > max) max = wor->give_max_phi_strips();
432 } else {
433 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << no_connection_error("WOR", i);
434 return false;
435 }
436 }
437
439 }
440 }
441 if (highPt_station()) // Check and connect High Pt plane chambers
442 {
443 std::list<const EtaCMA*> CMAs = setup.find_eta_CMAs_in_PAD(id().PAD_index());
444 if (CMAs.empty()) {
445 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << "have no Eta matrix into PAD!";
446 return false;
447 }
448
449 // get last CMA fake
450 const EtaCMA* cmaFake = CMAs.back();
451
452 // remove fake CMAs
453 std::list<const EtaCMA*>::iterator cm = CMAs.begin();
454 while (cm != CMAs.end()) {
455 if (!(*cm)->pivot_station() || (*cm)->highPt_start_ch() == -1) cm = CMAs.erase(cm);
456 ++cm;
457 }
458
459 int start_ch = (CMAs.size()) ? CMAs.front()->highPt_start_ch() : cmaFake->highPt_start_ch();
460 int stop_ch = (CMAs.size()) ? CMAs.back()->highPt_stop_ch() : cmaFake->highPt_stop_ch();
461
462 if (start_ch != -1 && stop_ch != -1) {
463 RPCchamber* start = setup.find_chamber(highPt_station(), start_ch);
464 RPCchamber* stop = setup.find_chamber(highPt_station(), stop_ch);
465
466 if (start->readoutWORs().empty()) {
467 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << no_wor_readout(start->number(), highPt_station());
468 return false;
469 }
470 if (stop->readoutWORs().empty()) {
471 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << no_wor_readout(stop->number(), highPt_station());
472 return false;
473 }
474
475 m_highPt_start_ch = start->readoutWORs().front()->number();
476 m_highPt_stop_ch = stop->readoutWORs().front()->number();
477 int max = 0;
478
479 for (int i = highPt_start_ch(); i <= highPt_stop_ch(); ++i) {
480 WiredOR* wor = setup.find_wor(highPt_station(), i);
481 if (wor) {
482 wor->add_cma(this);
483 m_highPt_WORs.insert(WORlink::value_type(i, wor));
484 if (wor->give_max_phi_strips() > max) max = wor->give_max_phi_strips();
485 } else {
486 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << no_connection_error("WOR", i);
487 return false;
488 }
489 }
491 }
492 }
493 return true;
494}
495
497 if (stat == lowPt_station()) {
498 if (id().Ixx_index() == 0) {
500 m_lowPt_stop_st = max - confirm_channels + 1 + (40 - max / 2);
501 if (m_lowPt_stop_st <= 0) m_lowPt_stop_st = 1;
502 }
503 if (id().Ixx_index() == 1) {
504 m_lowPt_stop_st = 1;
507 }
508
509 } else if (stat == highPt_station()) {
510 if (id().Ixx_index() == 0) {
512 m_highPt_stop_st = max - confirm_channels + 1 + (40 - max / 2);
514 }
515 if (id().Ixx_index() == 1) {
519 }
520 }
521}
522
524 int max = 0;
525 if (stat == pivot_station()) {
526 OddPhiCMA::WORlink::const_iterator it = m_pivot_WORs.begin();
527 while (it != m_pivot_WORs.end()) {
528 max = (max > (*it).second->give_max_phi_strips()) ? max : (*it).second->give_max_phi_strips();
529 ++it;
530 }
531 } else if (stat == lowPt_station()) {
532 OddPhiCMA::WORlink::const_iterator it = m_lowPt_WORs.begin();
533 while (it != m_lowPt_WORs.end()) {
534 max = (max > (*it).second->give_max_phi_strips()) ? max : (*it).second->give_max_phi_strips();
535 ++it;
536 }
537 } else if (stat == highPt_station()) {
538 OddPhiCMA::WORlink::const_iterator it = m_highPt_WORs.begin();
539 while (it != m_highPt_WORs.end()) {
540 max = (max > (*it).second->give_max_phi_strips()) ? max : (*it).second->give_max_phi_strips();
541 ++it;
542 }
543 }
544 return max;
545}
546
548 OddPhiCMA* prev = setup.previousCMA(*this);
549 if (prev && pivot_station()) {
550 if (pivot_start_ch() == prev->pivot_stop_ch()) {
551 if (!(pivot_start_st() == prev->pivot_stop_st() - 1)) {
552 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << two_obj_error_message("strips mismatch", prev);
553 return false;
554 }
555 } else if (!(pivot_start_ch() == prev->pivot_stop_ch() + 1)) {
556 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "OddPhiCMA") << two_obj_error_message("chambers mismatch", prev);
557 return false;
558 } else {
559 }
560 } else {
561 }
562
563 if (!connect(setup)) return false;
564
565 if (!cable_CMA_channels()) return false;
566
567 // invert the strip cabling if needed
568 // if( !doInversion(setup) ) return false;
569
570 // only 1 repository allowed so far
571 std::string LVL1_configuration_repository;
572 LVL1_configuration_repository = "ATLAS.121108";
573
574 // Read the program file if exist
575 SectorLogicSetup::SECTORlist sectors = setup.sectors();
576 SectorLogicSetup::SECTORlist::const_iterator it = sectors.begin();
577
578 char s_tag[4];
579 sprintf(s_tag, "s%02d", *it);
580
581 char t_tag[3];
582 sprintf(t_tag, "t%1d", id().PAD_index());
583
584 char c_tag[4] = {'_', 'c', '0', '\0'};
585 if (id().phi_index() == 1) c_tag[2] = '1';
586
587 std::ifstream CMAprogLow;
588 std::istringstream CMAprogLow_COOL;
589 char name[200];
590 for (int i = 0; i < 200; ++i) name[i] = '\0';
591
592 // LB retrieve the pointer to the map of the trigger roads
593 const std::map<std::string, std::string>* p_trigroads = setup.GetPtoTrigRoads();
594
595 // Read trigger configurations from files
596 if (p_trigroads == nullptr) {
597 while (!CMAprogLow.is_open() && it != sectors.end()) {
598 std::ostringstream namestr;
599 for (int i = 0; i < 200; ++i) name[i] = '\0';
600
601 if ((*it) % 2 != 0) // load only the Phi program of the Odd sectors
602 {
603 std::string dir;
604 dir = setup.online_database();
605 namestr << dir << "/" << s_tag << "_" << t_tag << "_pl" << c_tag << ".txt" << std::ends; // M.C. search for local files
606
607 namestr.str().copy(name, namestr.str().length(), 0);
608 name[namestr.str().length()] = 0;
609
610 CMAprogLow.open(name);
611 if (!CMAprogLow.is_open()) CMAprogLow.clear();
612 namestr.clear();
613 }
614 ++it;
615 }
616 }
617 // Trigger configuration loaded from COOL
618 else {
619 while (CMAprogLow_COOL.str().empty() && it != sectors.end()) {
620 std::ostringstream namestr;
621 for (int i = 0; i < 200; ++i) name[i] = '\0';
622
623 if ((*it) % 2 != 0) // load only the Phi program of the Odd sectors
624 {
625 namestr << s_tag << "_" << t_tag << "_pl" << c_tag << ".txt" << std::ends;
626 namestr.str().copy(name, namestr.str().length(), 0);
627 name[namestr.str().length()] = 0;
628 std::map<std::string, std::string>::const_iterator itc;
629 itc = p_trigroads->find(name);
630 if (itc != p_trigroads->end()) {
631 if (log.level() <= MSG::VERBOSE) {
632 log << MSG::VERBOSE << "OddPhiCMA low: key " << name << "found in the Trigger Road Map --> OK"
633 << ", OddPhiCMA low: key " << itc->second.c_str() << endmsg;
634 }
635 CMAprogLow_COOL.str(itc->second.c_str());
636 if (log.level() <= MSG::VERBOSE) {
637 log << MSG::VERBOSE << "CMAPROGLOW " << CMAprogLow_COOL.str() << endmsg;
638 }
639 }
640 }
641 ++it;
642 namestr.clear();
643 }
644 }
645 if (CMAprogLow.is_open()) {
646 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogLow, true);
647 if (program->check()) {
648 m_lowPt_program = std::move(program);
649 if (setup.cosmic()) {
650 m_lowPt_program->open_threshold(0);
651 m_lowPt_program->open_threshold(1);
652 }
653 for (unsigned int i = 0; i < 3; ++i) {
654 if (!m_lowPt_program->hasProgrammed(i)) {
655 if (log.level() <= MSG::DEBUG) {
656 log << MSG::DEBUG << s_tag << ": " << id() << ": low-pt: has threshold " << i
657 << " not programmed." << endmsg;
658 }
659 }
660 }
661 }
662 CMAprogLow.close();
663 } else if (!CMAprogLow_COOL.str().empty()) {
664 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogLow_COOL, true);
665 if (program->check()) {
666 m_lowPt_program = std::move(program);
667 if (setup.cosmic()) {
668 m_lowPt_program->open_threshold(0);
669 m_lowPt_program->open_threshold(1);
670 }
671 for (unsigned int i = 0; i < 3; ++i) {
672 if (!m_lowPt_program->hasProgrammed(i)) {
673 if (log.level() <= MSG::DEBUG) {
674 log << MSG::DEBUG << s_tag << ": " << id() << ": low-pt: has threshold " << i
675 << " not programmed." << endmsg;
676 }
677 }
678 }
679 }
680 CMAprogLow_COOL.str("");
681 } else if (name[0] != '\0') {
682 if (log.level() <= MSG::DEBUG) {
683 log << MSG::DEBUG << name << " not found! Putting a dummy configuration" << endmsg;
684 }
685 m_lowPt_program = std::make_unique<CMAprogram>();
686 m_lowPt_program->open_threshold(0);
687 }
688
689 std::ifstream CMAprogHigh;
690 std::istringstream CMAprogHigh_COOL;
691
692 it = sectors.begin();
693 if (p_trigroads == nullptr) {
694 while (!CMAprogHigh.is_open() && it != sectors.end()) {
695 std::ostringstream namestr;
696 for (int i = 0; i < 200; ++i) name[i] = '\0';
697
698 if ((*it) % 2 != 0) // load only the Phi program of the Odd sectors
699 {
700 std::string dir;
701 dir = setup.online_database();
702 namestr << dir << "/" << s_tag << "_" << t_tag << "_ph" << c_tag << ".txt" << std::ends;
703
704 namestr.str().copy(name, namestr.str().length(), 0);
705 name[namestr.str().length()] = 0;
706
707 CMAprogHigh.open(name);
708 if (!CMAprogHigh.is_open()) CMAprogHigh.clear();
709 namestr.clear();
710 }
711 ++it;
712 }
713 }
714 // Trigger configuration loaded from COOL
715 else {
716 while (CMAprogHigh_COOL.str().empty() && it != sectors.end()) {
717 std::ostringstream namestr;
718 for (int i = 0; i < 200; ++i) name[i] = '\0';
719
720 if ((*it) % 2 != 0) // load only the Phi program of the Odd sectors
721 {
722 namestr << s_tag << "_" << t_tag << "_ph" << c_tag << ".txt" << std::ends;
723 namestr.str().copy(name, namestr.str().length(), 0);
724 name[namestr.str().length()] = 0;
725 std::map<std::string, std::string>::const_iterator itc;
726 itc = p_trigroads->find(name);
727 if (itc != p_trigroads->end()) {
728 if (log.level() <= MSG::VERBOSE) {
729 log << MSG::VERBOSE << "OddPhiCMA high: key " << name << "found in the Trigger Road Map --> OK"
730 << ", OddPhiCMA high: key " << itc->second.c_str() << endmsg;
731 }
732 CMAprogHigh_COOL.str(itc->second.c_str());
733 if (log.level() <= MSG::VERBOSE) {
734 log << MSG::VERBOSE << "CMAPROGHIGH " << CMAprogHigh_COOL.str() << endmsg;
735 }
736 }
737 }
738 ++it;
739 namestr.clear();
740 }
741 }
742
743 if (CMAprogHigh.is_open()) {
744 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogHigh, true);
745 if (program->check()) {
746 m_highPt_program = std::move(program);
747 if (setup.cosmic()) {
748 m_highPt_program->open_threshold(0);
749 m_highPt_program->open_threshold(1);
750 }
751 for (unsigned int i = 0; i < 3; ++i) {
752 if (!m_highPt_program->hasProgrammed(i)) {
753 if (log.level() <= MSG::DEBUG) {
754 log << MSG::DEBUG << s_tag << ": " << id() << ": high-pt: has threshold " << i
755 << " not programmed." << endmsg;
756 }
757 }
758 }
759 }
760 CMAprogHigh.close();
761 } else if (!CMAprogHigh_COOL.str().empty()) {
762 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogHigh_COOL, true);
763 if (program->check()) {
764 m_highPt_program = std::move(program);
765 if (setup.cosmic()) {
766 m_highPt_program->open_threshold(0);
767 m_highPt_program->open_threshold(1);
768 }
769 for (unsigned int i = 0; i < 3; ++i) {
770 if (!m_highPt_program->hasProgrammed(i)) {
771 if (log.level() <= MSG::DEBUG) {
772 log << MSG::DEBUG << s_tag << ": " << id() << ": high-pt: has threshold " << i
773 << " not programmed." << endmsg;
774 }
775 }
776 }
777 }
778 CMAprogHigh_COOL.str("");
779 } else if (name[0] != '\0') {
780 if (log.level() <= MSG::DEBUG) {
781 log << MSG::DEBUG << name << " not found! Putting a dummy configuration" << endmsg;
782 }
783 m_highPt_program = std::make_unique<CMAprogram>();
784 m_highPt_program->open_threshold(0);
785 }
786
787 return true;
788}
789
791 SectorLogicSetup::SECTORlist Sectors = setup.sectors();
792 SectorLogicSetup::SECTORlist::const_iterator it = Sectors.begin();
793 int sector = *it;
794
795 WORlink::const_iterator wor;
796 if (lowPt_station() && lowPt_number_co() != -1) {
797 wor = m_lowPt_WORs.begin();
798 WiredOR::RPClink Linked = (*wor).second->RPCread();
799 WiredOR::RPClink::const_iterator link = Linked.begin();
800 if ((*link).second->inversion(sector)) { m_inversion = true; }
801 }
802
803 if (pivot_station()) {
804 wor = m_pivot_WORs.begin();
805 WiredOR::RPClink Linked = (*wor).second->RPCread();
806 WiredOR::RPClink::const_iterator link = Linked.begin();
807 if ((*link).second->inversion(sector)) { m_inversion = true; }
808 }
809
810 if (highPt_station() && highPt_number_co() != -1) {
811 wor = m_highPt_WORs.begin();
812 WiredOR::RPClink Linked = (*wor).second->RPCread();
813 WiredOR::RPClink::const_iterator link = Linked.begin();
814 if ((*link).second->inversion(sector)) { m_inversion = true; }
815 }
816
817 if (m_inversion) m_id->inversion();
818
819 return true;
820}
#define endmsg
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.
#define max(a, b)
Definition cfImp.cxx:41
const std::string & name() const
Definition BaseObject.h:23
int Ixx_index() const
int highPt_number_co() const
std::string no_wor_readout(int, int)
int pivot_stop_st() const
int pivot_stop_ch() const
int highPt_stop_st() const
CMAconfiguration m_conf_type
int pivot_station() const
static constexpr int confirm_channels
int(* m_lowPt)[2][confirm_channels]
int(* m_pivot)[2][pivot_channels]
CMAparameters & operator=(const CMAparameters &)
int pivot_start_st() const
int highPt_start_st() const
unsigned int m_last_pivot_code
unsigned int m_last_lowPt_code
int lowPt_stop_st() const
const CMAidentity & id() const
int lowPt_start_st() const
int lowPt_number_co() const
unsigned int m_first_pivot_code
std::string two_obj_error_message(const std::string &, CMAparameters *)
int lowPt_stop_ch() const
int highPt_station() const
std::string noMoreChannels(const std::string &stat)
int lowPt_station() const
void create_highPt_map(int)
unsigned int m_first_highPt_code
std::unique_ptr< CMAprogram > m_lowPt_program
std::unique_ptr< CMAidentity > m_id
int highPt_stop_ch() const
int highPt_start_ch() const
unsigned int m_last_highPt_code
int lowPt_start_ch() const
void create_pivot_map(int)
void create_lowPt_map(int)
std::unique_ptr< CMAprogram > m_highPt_program
unsigned int m_first_lowPt_code
CMAparameters(const parseParams &parse)
int(* m_highPt)[2][confirm_channels]
int pivot_start_ch() const
static constexpr int pivot_channels
std::string no_connection_error(const std::string &, int) const
int number() const
OddPhiCMA & operator=(const OddPhiCMA &)
Definition OddPhiCMA.cxx:53
bool setup(SectorLogicSetup &, MsgStream &)
OddPhiCMA(const parseParams &parse)
Definition OddPhiCMA.cxx:22
const WORlink & pivot_WORs(void) const
Definition OddPhiCMA.cxx:17
bool doInversion(SectorLogicSetup &)
std::map< int, WiredOR *, std::less< int > > WORlink
Definition OddPhiCMA.h:22
const WORlink & lowPt_WORs(void) const
Definition OddPhiCMA.cxx:18
const WORlink & highPt_WORs(void) const
Definition OddPhiCMA.cxx:19
bool connect(SectorLogicSetup &)
bool inversion(void) const
Definition OddPhiCMA.cxx:20
void get_confirm_strip_boundaries(int, int)
const std::string & chamber_name() const
std::map< int, const RPCchamber *, std::less< int > > RPClink
Definition WiredOR.h:28
int RPCacquired() const
Definition WiredOR.h:89
const RPCchamber * connected_rpc(int) const
Definition WiredOR.cxx:48
void add_cma(const CMAparameters *)
Definition WiredOR.cxx:58
int give_max_phi_strips() const
Definition WiredOR.cxx:34
void add_odd_read_mul(ReadoutCh &)
Definition WiredOR.cxx:64
std::map< std::string, std::string > parse(const std::string &list)
int r
Definition globals.cxx:22