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