5 #include "GaudiKernel/MsgStream.h"
43 m_pivot_WORs (cma.pivot_WORs()),
44 m_lowPt_WORs (cma.lowPt_WORs()),
45 m_highPt_WORs (cma.highPt_WORs()),
46 m_inversion (cma.inversion())
72 throw std::runtime_error(
"Channel not found in OddPhiCMA::cable_CMA_channels");
83 int first_ch_cabled = 32;
84 int last_ch_cabled = -1;
86 std::vector<int> multiplicity(max_st);
92 int local_strip = max_st - (max_st -
start);
93 int final_strip = max_st - (max_st -
stop);
100 if (chs <= first_ch_cabled) first_ch_cabled = chs;
107 if (local_strip > 0 && local_strip <= rpc_st) {
109 m_pivot[
i][0][chs] = cham * 100 + local_strip - 1;
110 m_pivot[
i][1][chs] = 10000 + cham * 100 + local_strip - 1;
112 m_pivot[
i][1][chs] = cham * 100 + local_strip - 1;
113 m_pivot[
i][0][chs] = 10000 + cham * 100 + local_strip - 1;
115 multiplicity[local_strip - 1] = 1;
118 }
while (--local_strip >= final_strip);
120 if (chs - 1 >= last_ch_cabled) last_ch_cabled = chs - 1;
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());
143 if (
m_pivot[
ch][0][last_ch_cabled] >= 0)
break;
149 if (
m_pivot[
ch][0][first_ch_cabled] >= 0)
break;
158 throw std::runtime_error(
"Channel not found in OddPhiCMA::cable_CMA_channels");
169 int first_ch_cabled = 64;
170 int last_ch_cabled = -1;
177 throw std::runtime_error(
"Channel not found in OddPhiCMA::cable_CMA_channels");
179 WiredOR* wor = (*found).second;
187 int local_strip = max_st - (max_st -
start);
188 int final_strip = max_st - (max_st -
stop);
190 int chs = (
id().
Ixx_index() == 0) ? 40 - max_st / 2 : 0;
194 if (
E ==
'E' &&
id().Ixx_index() == 1) {
200 if (
E ==
'E' &&
id().Ixx_index() == 0) {
207 if (chs <= first_ch_cabled) first_ch_cabled = chs;
213 if (local_strip > 0 && local_strip <= rpc_st) {
215 m_lowPt[
r][0][chs] = cham * 100 + local_strip - 1;
216 m_lowPt[
r][1][chs] = 10000 + cham * 100 + local_strip - 1;
218 m_lowPt[
r][1][chs] = cham * 100 + local_strip - 1;
219 m_lowPt[
r][0][chs] = 10000 + cham * 100 + local_strip - 1;
222 multiplicity[local_strip - 1] = 1;
224 multiplicity[local_strip - 1 + (max_st - rpc_st)] = 1;
228 }
while (--local_strip >= final_strip);
231 if (chs - 1 >= last_ch_cabled) last_ch_cabled = chs - 1;
240 if (last_ch_cabled < 0) {
241 throw std::runtime_error(std::string(
"RPC_CondCabling: OddPhiCMA - neg. array idx at ") +
246 if (
m_lowPt[
ch][0][last_ch_cabled] >= 0)
break;
251 if (
m_lowPt[
ch][0][first_ch_cabled] >= 0)
break;
261 throw std::runtime_error(
"Channel not found in OddPhiCMA::cable_CMA_channels");
272 int first_ch_cabled = 64;
273 int last_ch_cabled = -1;
280 throw std::runtime_error(
"Channel not found in OddPhiCMA::cable_CMA_channels");
290 int local_strip = max_st - (max_st -
start);
291 int final_strip = max_st - (max_st -
stop);
293 int chs = (
id().
Ixx_index() == 0) ? 40 - max_st / 2 : 0;
299 if (abs(sEta) == 8 && L ==
'L') isBOE =
true;
300 if (isBOE &&
id().Ixx_index() == 1) {
306 if (isBOE &&
id().Ixx_index() == 0) {
312 if (chs <= first_ch_cabled) first_ch_cabled = chs;
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;
325 if (local_strip > 0 && local_strip <= rpc_st) {
327 m_highPt[
r][0][chs] = cham * 100 + local_strip - 1;
328 m_highPt[
r][1][chs] = 10000 + cham * 100 + local_strip - 1;
330 m_highPt[
r][1][chs] = cham * 100 + local_strip - 1;
331 m_highPt[
r][0][chs] = 10000 + cham * 100 + local_strip - 1;
334 multiplicity[local_strip - 1] = 1;
336 multiplicity[local_strip - 1 + (max_st - rpc_st)] = 1;
342 }
while (--local_strip >= final_strip);
345 if (chs - 1 >= last_ch_cabled) last_ch_cabled = chs - 1;
354 if (last_ch_cabled < 0) {
355 throw std::runtime_error(std::string(
"RPC_CondCabling: OddPhiCMA - neg. array idx at ") +
360 if (
m_highPt[
ch][0][last_ch_cabled] >= 0)
break;
365 if (
m_highPt[
ch][0][first_ch_cabled] >= 0)
break;
390 std::list<const EtaCMA*> CMAs =
setup.find_eta_CMAs_in_PAD(
id().PAD_index());
397 const EtaCMA* cmaFake = CMAs.back();
401 while (
cm != CMAs.end()) {
402 if (!(*cm)->pivot_station() || (*cm)->lowPt_start_ch() == -1)
cm = CMAs.erase(
cm);
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();
409 if (start_ch != -1 && stop_ch != -1) {
413 if (
start->readoutWORs().empty()) {
417 if (
stop->readoutWORs().empty()) {
443 std::list<const EtaCMA*> CMAs =
setup.find_eta_CMAs_in_PAD(
id().PAD_index());
450 const EtaCMA* cmaFake = CMAs.back();
454 while (
cm != CMAs.end()) {
455 if (!(*cm)->pivot_station() || (*cm)->highPt_start_ch() == -1)
cm = CMAs.erase(
cm);
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();
462 if (start_ch != -1 && stop_ch != -1) {
466 if (
start->readoutWORs().empty()) {
470 if (
stop->readoutWORs().empty()) {
498 if (
id().Ixx_index() == 0) {
503 if (
id().Ixx_index() == 1) {
510 if (
id().Ixx_index() == 0) {
515 if (
id().Ixx_index() == 1) {
528 max = (
max > (*it).second->give_max_phi_strips()) ?
max : (*it).second->give_max_phi_strips();
534 max = (
max > (*it).second->give_max_phi_strips()) ?
max : (*it).second->give_max_phi_strips();
540 max = (
max > (*it).second->give_max_phi_strips()) ?
max : (*it).second->give_max_phi_strips();
571 std::string LVL1_configuration_repository;
572 LVL1_configuration_repository =
"ATLAS.121108";
576 SectorLogicSetup::SECTORlist::const_iterator
it = sectors.begin();
579 sprintf(s_tag,
"s%02d", *
it);
582 sprintf(t_tag,
"t%1d",
id().PAD_index());
584 char c_tag[4] = {
'_',
'c',
'0',
'\0'};
585 if (
id().phi_index() == 1) c_tag[2] =
'1';
587 std::ifstream CMAprogLow;
588 std::istringstream CMAprogLow_COOL;
590 for (
int i = 0;
i < 200; ++
i)
name[
i] =
'\0';
593 const std::map<std::string, std::string>* p_trigroads =
setup.GetPtoTrigRoads();
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';
605 namestr <<
dir <<
"/" << s_tag <<
"_" << t_tag <<
"_pl" << c_tag <<
".txt" << std::ends;
607 namestr.str().copy(
name, namestr.str().length(), 0);
608 name[namestr.str().length()] = 0;
610 CMAprogLow.open(
name);
611 if (!CMAprogLow.is_open()) CMAprogLow.clear();
619 while (CMAprogLow_COOL.str().empty() &&
it != sectors.end()) {
620 std::ostringstream namestr;
621 for (
int i = 0;
i < 200; ++
i)
name[
i] =
'\0';
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()) {
632 log <<
MSG::VERBOSE <<
"OddPhiCMA low: key " <<
name <<
"found in the Trigger Road Map --> OK"
633 <<
", OddPhiCMA low: key " << itc->second.c_str() <<
endmsg;
635 CMAprogLow_COOL.str(itc->second.c_str());
645 if (CMAprogLow.is_open()) {
646 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogLow,
true);
647 if (program->
check()) {
649 if (
setup.cosmic()) {
653 for (
unsigned int i = 0;
i < 3; ++
i) {
656 log <<
MSG::DEBUG << s_tag <<
": " <<
id() <<
": low-pt: has threshold " <<
i
657 <<
" not programmed." <<
endmsg;
663 }
else if (!CMAprogLow_COOL.str().empty()) {
664 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogLow_COOL,
true);
665 if (program->
check()) {
667 if (
setup.cosmic()) {
671 for (
unsigned int i = 0;
i < 3; ++
i) {
674 log <<
MSG::DEBUG << s_tag <<
": " <<
id() <<
": low-pt: has threshold " <<
i
675 <<
" not programmed." <<
endmsg;
680 CMAprogLow_COOL.str(
"");
681 }
else if (
name[0] !=
'\0') {
689 std::ifstream CMAprogHigh;
690 std::istringstream CMAprogHigh_COOL;
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';
702 namestr <<
dir <<
"/" << s_tag <<
"_" << t_tag <<
"_ph" << c_tag <<
".txt" << std::ends;
704 namestr.str().copy(
name, namestr.str().length(), 0);
705 name[namestr.str().length()] = 0;
707 CMAprogHigh.open(
name);
708 if (!CMAprogHigh.is_open()) CMAprogHigh.clear();
716 while (CMAprogHigh_COOL.str().empty() &&
it != sectors.end()) {
717 std::ostringstream namestr;
718 for (
int i = 0;
i < 200; ++
i)
name[
i] =
'\0';
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()) {
729 log <<
MSG::VERBOSE <<
"OddPhiCMA high: key " <<
name <<
"found in the Trigger Road Map --> OK"
730 <<
", OddPhiCMA high: key " << itc->second.c_str() <<
endmsg;
732 CMAprogHigh_COOL.str(itc->second.c_str());
743 if (CMAprogHigh.is_open()) {
744 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogHigh,
true);
745 if (program->
check()) {
747 if (
setup.cosmic()) {
751 for (
unsigned int i = 0;
i < 3; ++
i) {
754 log <<
MSG::DEBUG << s_tag <<
": " <<
id() <<
": high-pt: has threshold " <<
i
755 <<
" not programmed." <<
endmsg;
761 }
else if (!CMAprogHigh_COOL.str().empty()) {
762 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogHigh_COOL,
true);
763 if (program->
check()) {
765 if (
setup.cosmic()) {
769 for (
unsigned int i = 0;
i < 3; ++
i) {
772 log <<
MSG::DEBUG << s_tag <<
": " <<
id() <<
": high-pt: has threshold " <<
i
773 <<
" not programmed." <<
endmsg;
778 CMAprogHigh_COOL.str(
"");
779 }
else if (
name[0] !=
'\0') {
792 SectorLogicSetup::SECTORlist::const_iterator
it = Sectors.begin();
795 WORlink::const_iterator wor;
799 WiredOR::RPClink::const_iterator link =
Linked.begin();
800 if ((*link).second->inversion(sector)) {
m_inversion =
true; }
806 WiredOR::RPClink::const_iterator link =
Linked.begin();
807 if ((*link).second->inversion(sector)) {
m_inversion =
true; }
813 WiredOR::RPClink::const_iterator link =
Linked.begin();
814 if ((*link).second->inversion(sector)) {
m_inversion =
true; }