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