5 #include "GaudiKernel/MsgStream.h"
44 m_pivot_WORs (cma.pivot_WORs()),
45 m_lowPt_WORs (cma.lowPt_WORs()),
46 m_highPt_WORs (cma.highPt_WORs()),
47 m_inversion (cma.inversion())
82 int first_ch_cabled = 32;
83 int last_ch_cabled = -1;
85 std::vector<int> multiplicity(max_st);
91 int local_strip =
start - (max_st - rpc_st);
92 int final_strip =
stop - (max_st - rpc_st);
95 chs += (local_strip >= 0) ? 0 : abs(local_strip) + 1;
100 if (chs <= first_ch_cabled) first_ch_cabled = chs;
102 if (local_strip <= 0) local_strip = 1;
108 if (local_strip > 0 && local_strip <= rpc_st) {
110 m_pivot[
i][0][chs] = cham * 100 + local_strip - 1;
111 m_pivot[
i][1][chs] = 10000 + cham * 100 + local_strip - 1;
113 m_pivot[
i][1][chs] = cham * 100 + local_strip - 1;
114 m_pivot[
i][0][chs] = 10000 + cham * 100 + local_strip - 1;
116 multiplicity[local_strip - 1 + (max_st - rpc_st)] = 1;
119 }
while (++local_strip <= final_strip);
121 if (chs - 1 >= last_ch_cabled) last_ch_cabled = chs - 1;
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());
143 if (
m_pivot[
ch][0][first_ch_cabled] >= 0)
break;
148 if (
m_pivot[
ch][0][last_ch_cabled] >= 0)
break;
165 int first_ch_cabled = 64;
166 int last_ch_cabled = -1;
172 WiredOR* wor = (*found).second;
180 int local_strip =
start - (max_st - rpc_st);
181 int final_strip =
stop - (max_st - rpc_st);
183 int chs = (
id().
Ixx_index() == 0) ? 40 - max_st / 2 : 0;
188 if (
E ==
'E') isBME =
true;
190 if (isBME &&
id().Ixx_index() == 1) {
196 if (isBME &&
id().Ixx_index() == 0) {
203 chs += (local_strip >= 0) ? 0 : abs(local_strip) + 1;
209 if (chs <= first_ch_cabled) first_ch_cabled = chs;
211 if (local_strip <= 0) local_strip = 1;
217 if (local_strip > 0 && local_strip <= rpc_st) {
219 m_lowPt[
r][0][chs] = cham * 100 + local_strip - 1;
220 m_lowPt[
r][1][chs] = 10000 + cham * 100 + local_strip - 1;
222 m_lowPt[
r][1][chs] = cham * 100 + local_strip - 1;
223 m_lowPt[
r][0][chs] = 10000 + cham * 100 + local_strip - 1;
226 multiplicity[local_strip - 1] = 1;
228 multiplicity[local_strip - 1 + (max_st - rpc_st)] = 1;
232 }
while (++local_strip <= final_strip);
235 if (chs - 1 >= last_ch_cabled) last_ch_cabled = chs - 1;
250 std::ostringstream disp;
251 disp <<
"EvenPhiCMA::cable_CMA_channels - out of bound array indices (m_lowPt)! Values:"
252 << first_ch_cabled <<
", " << last_ch_cabled
253 <<
" at " << __FILE__ <<
":" << __LINE__ ;
254 throw std::runtime_error(disp.str());
258 if (
m_lowPt[
ch][0][first_ch_cabled] >= 0)
break;
263 if (
m_lowPt[
ch][0][last_ch_cabled] >= 0)
break;
281 int first_ch_cabled = 64;
282 int last_ch_cabled = -1;
288 WiredOR* wor = (*found).second;
297 int local_strip =
start - (max_st - rpc_st);
298 int final_strip =
stop - (max_st - rpc_st);
300 int chs = (
id().
Ixx_index() == 0) ? 40 - max_st / 2 : 0;
306 if (abs(sEta) == 8 && L ==
'L') isBOE =
true;
307 if (isBOE &&
id().Ixx_index() == 1) {
313 if (isBOE &&
id().Ixx_index() == 0) {
319 chs += (local_strip >= 0) ? 0 : abs(local_strip) + 1;
324 if (chs <= first_ch_cabled) first_ch_cabled = chs;
326 if (local_strip <= 0) local_strip = 1;
332 bool skipChannel =
false;
333 if (isBOE &&
id().Ixx_index() == 1 && ((chs > 3 && chs < 8) || (chs > 39 && chs < 44))) skipChannel =
true;
334 if (isBOE &&
id().Ixx_index() == 0 && ((chs > 19 && chs < 24) || (chs > 55 && chs < 60))) skipChannel =
true;
338 if (local_strip > 0 && local_strip <= rpc_st) {
340 m_highPt[
r][0][chs] = cham * 100 + local_strip - 1;
341 m_highPt[
r][1][chs] = 10000 + cham * 100 + local_strip - 1;
343 m_highPt[
r][1][chs] = cham * 100 + local_strip - 1;
344 m_highPt[
r][0][chs] = 10000 + cham * 100 + local_strip - 1;
348 multiplicity[local_strip - 1] = 1;
350 multiplicity[local_strip - 1 + (max_st - rpc_st)] = 1;
354 }
while (++local_strip <= final_strip);
357 if (chs - 1 >= last_ch_cabled) last_ch_cabled = chs - 1;
372 std::ostringstream disp;
373 disp <<
"EvenPhiCMA::cable_CMA_channels - out of bound array indices (m_highPt)! Values:"
374 << first_ch_cabled <<
", " << last_ch_cabled
375 <<
" at " << __FILE__ <<
":" << __LINE__ ;
376 throw std::runtime_error(disp.str());
380 if (
m_highPt[
ch][0][first_ch_cabled] >= 0)
break;
385 if (
m_highPt[
ch][0][last_ch_cabled] >= 0)
break;
410 std::list<const EtaCMA*> CMAs =
setup.find_eta_CMAs_in_PAD(
id().PAD_index());
417 const EtaCMA* cmaFake = CMAs.back();
421 while (
cm != CMAs.end()) {
422 if (!(*cm)->pivot_station() || (*cm)->lowPt_start_ch() == -1)
cm = CMAs.erase(
cm);
426 int start_ch = (CMAs.size()) ? CMAs.front()->lowPt_start_ch() : cmaFake->
lowPt_start_ch();
427 int stop_ch = (CMAs.size()) ? CMAs.back()->lowPt_stop_ch() : cmaFake->
lowPt_stop_ch();
429 if (start_ch != -1 && stop_ch != -1) {
433 if (
start->readoutWORs().empty()) {
437 if (
stop->readoutWORs().empty()) {
463 std::list<const EtaCMA*> CMAs =
setup.find_eta_CMAs_in_PAD(
id().PAD_index());
470 const EtaCMA* cmaFake = CMAs.back();
474 while (
cm != CMAs.end()) {
475 if (!(*cm)->pivot_station() || (*cm)->highPt_start_ch() == -1)
cm = CMAs.erase(
cm);
479 int start_ch = (CMAs.size()) ? CMAs.front()->highPt_start_ch() : cmaFake->
highPt_start_ch();
480 int stop_ch = (CMAs.size()) ? CMAs.back()->highPt_stop_ch() : cmaFake->
highPt_stop_ch();
482 if (start_ch != -1 && stop_ch != -1) {
486 if (
start->readoutWORs().empty()) {
490 if (
stop->readoutWORs().empty()) {
518 if (
id().Ixx_index() == 0) {
522 }
else if (
id().Ixx_index() == 1) {
529 if (
id().Ixx_index() == 0) {
533 }
else if (
id().Ixx_index() == 1) {
546 max = (
max > (*it).second->give_max_phi_strips()) ?
max : (*it).second->give_max_phi_strips();
552 max = (
max > (*it).second->give_max_phi_strips()) ?
max : (*it).second->give_max_phi_strips();
558 max = (
max > (*it).second->give_max_phi_strips()) ?
max : (*it).second->give_max_phi_strips();
589 std::string LVL1_configuration_repository;
590 LVL1_configuration_repository =
"ATLAS.data";
594 SectorLogicSetup::SECTORlist::const_iterator
it = sectors.begin();
597 sprintf(s_tag,
"s%02d", *
it);
600 sprintf(t_tag,
"t%1d",
id().PAD_index());
602 char c_tag[4] = {
'_',
'c',
'0',
'\0'};
603 if (
id().phi_index() == 1) c_tag[2] =
'1';
605 std::ifstream CMAprogLow;
606 std::istringstream CMAprogLow_COOL;
608 for (
int i = 0;
i < 200; ++
i)
name[
i] =
'\0';
611 const std::map<std::string, std::string>* p_trigroads =
setup.GetPtoTrigRoads();
614 if (p_trigroads ==
nullptr) {
615 while (!CMAprogLow.is_open() &&
it != sectors.end()) {
616 std::ostringstream namestr;
617 for (
int i = 0;
i < 200; ++
i)
name[
i] =
'\0';
623 namestr <<
dir <<
"/" << s_tag <<
"_" << t_tag <<
"_pl" << c_tag <<
".txt" << std::ends;
625 namestr.str().copy(
name, namestr.str().length(), 0);
626 name[namestr.str().length()] = 0;
628 CMAprogLow.open(
name);
629 if (!CMAprogLow.is_open()) CMAprogLow.clear();
637 while (CMAprogLow_COOL.str().empty() &&
it != sectors.end()) {
638 std::ostringstream namestr;
639 for (
int i = 0;
i < 200; ++
i)
name[
i] =
'\0';
643 namestr << s_tag <<
"_" << t_tag <<
"_pl" << c_tag <<
".txt" << std::ends;
644 namestr.str().copy(
name, namestr.str().length(), 0);
645 name[namestr.str().length()] = 0;
646 std::map<std::string, std::string>::const_iterator itc;
647 itc = p_trigroads->find(
name);
648 if (itc != p_trigroads->end()) {
650 log <<
MSG::VERBOSE <<
"EvenPhiCMA low: key " <<
name <<
"found in the Trigger Road Map --> OK"
651 <<
", EvenPhiCMA low: key " << itc->second.c_str() <<
endmsg;
653 CMAprogLow_COOL.str(itc->second.c_str());
663 if (CMAprogLow.is_open()) {
664 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogLow,
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;
681 }
else if (!CMAprogLow_COOL.str().empty()) {
682 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogLow_COOL,
true);
683 if (program->
check()) {
685 if (
setup.cosmic()) {
689 for (
unsigned int i = 0;
i < 3; ++
i) {
692 log <<
MSG::DEBUG << s_tag <<
": " <<
id() <<
": low-pt: has threshold " <<
i
693 <<
" not programmed." <<
endmsg;
698 CMAprogLow_COOL.str(
"");
699 }
else if (
name[0] !=
'\0') {
707 std::ifstream CMAprogHigh;
708 std::istringstream CMAprogHigh_COOL;
710 it = sectors.begin();
712 if (p_trigroads ==
nullptr) {
713 while (!CMAprogHigh.is_open() &&
it != sectors.end()) {
714 std::ostringstream namestr;
715 for (
int i = 0;
i < 200; ++
i)
name[
i] =
'\0';
721 namestr <<
dir <<
"/" << 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;
726 CMAprogHigh.open(
name);
727 if (!CMAprogHigh.is_open()) CMAprogHigh.clear();
735 it = sectors.begin();
736 while (CMAprogHigh_COOL.str().empty() &&
it != sectors.end()) {
737 std::ostringstream namestr;
738 for (
int i = 0;
i < 200; ++
i)
name[
i] =
'\0';
742 namestr << s_tag <<
"_" << t_tag <<
"_ph" << c_tag <<
".txt" << std::ends;
743 namestr.str().copy(
name, namestr.str().length(), 0);
744 name[namestr.str().length()] = 0;
745 std::map<std::string, std::string>::const_iterator itc;
746 itc = p_trigroads->find(
name);
747 if (itc != p_trigroads->end()) {
749 log <<
MSG::VERBOSE <<
"EvenPhiCMA high: key " <<
name <<
"found in the Trigger Road Map --> OK"
750 <<
", EvenPhiCMA high: key " << itc->second.c_str() <<
endmsg;
752 CMAprogHigh_COOL.str(itc->second.c_str());
763 if (CMAprogHigh.is_open()) {
764 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogHigh,
true);
765 if (program->
check()) {
767 if (
setup.cosmic()) {
771 for (
unsigned int i = 0;
i < 3; ++
i) {
774 log <<
MSG::DEBUG << s_tag <<
": " <<
id() <<
": high-pt: has threshold " <<
i
775 <<
" not programmed." <<
endmsg;
781 }
else if (!CMAprogHigh_COOL.str().empty()) {
782 std::unique_ptr<CMAprogram> program = std::make_unique<CMAprogram>(CMAprogHigh_COOL,
true);
783 if (program->
check()) {
785 if (
setup.cosmic()) {
789 for (
unsigned int i = 0;
i < 3; ++
i) {
792 log <<
MSG::DEBUG << s_tag <<
": " <<
id() <<
": high-pt: has threshold " <<
i
793 <<
" not programmed." <<
endmsg;
798 CMAprogHigh_COOL.str(
"");
799 }
else if (
name[0] !=
'\0') {
812 SectorLogicSetup::SECTORlist::const_iterator
it = Sectors.begin();
815 WORlink::const_iterator wor;
819 WiredOR::RPClink::const_iterator link =
Linked.begin();
820 if ((*link).second->inversion(sector)) {
m_inversion =
true; }
826 WiredOR::RPClink::const_iterator link =
Linked.begin();
827 if ((*link).second->inversion(sector)) {
m_inversion =
true; }
833 WiredOR::RPClink::const_iterator link =
Linked.begin();
834 if ((*link).second->inversion(sector)) {
m_inversion =
true; }