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