14 dropLowQualityCLCTsNoGEMs_ME1a_(tmbParams_.getParameter<
bool>(
"dropLowQualityCLCTsNoGEMs_ME1a")),
15 dropLowQualityCLCTsNoGEMs_ME1b_(tmbParams_.getParameter<
bool>(
"dropLowQualityCLCTsNoGEMs_ME1b")),
16 dropLowQualityALCTsNoGEMs_ME1a_(tmbParams_.getParameter<
bool>(
"dropLowQualityALCTsNoGEMs_ME1a")),
17 dropLowQualityALCTsNoGEMs_ME1b_(tmbParams_.getParameter<
bool>(
"dropLowQualityALCTsNoGEMs_ME1b")),
18 buildLCTfromALCTandGEM_ME1a_(tmbParams_.getParameter<
bool>(
"buildLCTfromALCTandGEM_ME1a")),
19 buildLCTfromALCTandGEM_ME1b_(tmbParams_.getParameter<
bool>(
"buildLCTfromALCTandGEM_ME1b")),
20 buildLCTfromCLCTandGEM_ME1a_(tmbParams_.getParameter<
bool>(
"buildLCTfromCLCTandGEM_ME1a")),
21 buildLCTfromCLCTandGEM_ME1b_(tmbParams_.getParameter<
bool>(
"buildLCTfromCLCTandGEM_ME1b")),
22 promoteCLCTGEMquality_ME1a_(tmbParams_.getParameter<
bool>(
"promoteCLCTGEMquality_ME1a")),
23 promoteCLCTGEMquality_ME1b_(tmbParams_.getParameter<
bool>(
"promoteCLCTGEMquality_ME1b")) {
25 edm::LogError(
"CSCGEMMotherboardME11|SetupError") <<
"+++ TMB constructed while runPhase2 is not set! +++\n";
29 edm::LogError(
"CSCGEMMotherboardME11|SetupError") <<
"+++ TMB constructed while runME11ILT_ is not set! +++\n";
33 tmbLUT_ = std::make_unique<CSCGEMMotherboardLUTME11>();
34 cscTmbLUT_ = std::make_unique<CSCMotherboardLUTME11>();
40 edm::LogError(
"CSCGEMMotherboardME11|SetupError") <<
"+++ TMB constructed while runPhase2 is not set! +++\n";
44 edm::LogError(
"CSCGEMMotherboardME11|SetupError") <<
"+++ TMB constructed while runME11ILT_ is not set! +++\n";
65 unsigned alctBits =
alctProc->getHighMultiplictyBits();
68 if (
gem_g !=
nullptr) {
70 edm::LogInfo(
"CSCGEMMotherboardME11|SetupInfo") <<
"+++ run() called for GEM-CSC integrated trigger! +++ \n";
77 <<
"+++ run() called for GEM-CSC integrated trigger without valid GEM geometry! +++ \n";
83 <<
"+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
99 int used_clct_mask[20];
100 for (
int b = 0;
b < 20;
b++)
101 used_clct_mask[
b] = 0;
103 const bool hasPads(!
pads_.empty());
104 const bool hasCoPads(hasPads and !
coPads_.empty());
107 LogTrace(
"CSCGEMMotherboardME11") <<
"hascopads " << hasCoPads << std::endl;
111 if (
alctProc->getBestALCT(bx_alct).isValid()) {
119 <<
"========================================================================\n"
120 <<
"ALCT-CLCT matching in ME1/1 chamber: " <<
cscId_ <<
"\n"
121 <<
"------------------------------------------------------------------------\n"
122 <<
"+++ Best ALCT Details: " <<
alctProc->getBestALCT(bx_alct) <<
"\n"
123 <<
"+++ Second ALCT Details: " <<
alctProc->getSecondALCT(bx_alct) << std::endl;
129 <<
"------------------------------------------------------------------------ \n"
130 <<
"Attempt ALCT-CLCT matching in ME1/b in bx range: [" << bx_clct_start <<
"," << bx_clct_stop <<
"]"
135 int nSuccesFulMatches = 0;
136 for (
int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++) {
141 if (
clctProc->getBestCLCT(bx_clct).isValid()) {
143 LogTrace(
"CSCGEMMotherboardME11") <<
"++Valid ME1b CLCT: " <<
clctProc->getBestCLCT(bx_clct) << std::endl;
146 matches<GEMPadDigi> mPads;
147 matchingPads<GEMPadDigi>(
clctProc->getBestCLCT(bx_clct),
152 matches<GEMCoPadDigi> mCoPads;
153 matchingPads<GEMCoPadDigi>(
clctProc->getBestCLCT(bx_clct),
159 const bool lowQualityCLCT(
clctProc->getBestCLCT(bx_clct).getQuality() <= 3);
160 const bool hasMatchingPads(!mPads.empty()
or !mCoPads.empty());
163 LogTrace(
"CSCGEMMotherboardME11") <<
"Dropping low quality CLCT without matching GEM pads "
164 <<
clctProc->getBestCLCT(bx_clct) << std::endl;
169 LogTrace(
"CSCGEMMotherboardME11") <<
"mPads " << mPads.size() <<
" "
170 <<
" mCoPads " << mCoPads.size() << std::endl;
171 for (
auto p : mPads) {
172 LogTrace(
"CSCGEMMotherboardME11") <<
p.first <<
" " <<
p.second << std::endl;
174 for (
auto p : mCoPads) {
175 LogTrace(
"CSCGEMMotherboardME11") <<
p.first <<
" " <<
p.second << std::endl;
179 int mbx = bx_clct - bx_clct_start;
189 if (
allLCTs(bx_alct, mbx, 0).isValid()) {
191 used_clct_mask[bx_clct] += 1;
195 <<
"Successful ALCT-CLCT match in ME1b: bx_alct = " << bx_alct <<
"; match window: [" << bx_clct_start
196 <<
"; " << bx_clct_stop <<
"]; bx_clct = " << bx_clct <<
"\n"
197 <<
"+++ Best CLCT Details: " <<
clctProc->getBestCLCT(bx_clct) <<
"\n"
198 <<
"+++ Second CLCT Details: " <<
clctProc->getSecondCLCT(bx_clct) << std::endl;
199 if (
allLCTs(bx_alct, mbx, 0).isValid()) {
200 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #1 " <<
allLCTs(bx_alct, mbx, 0) << std::endl;
201 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 0).getALCT() << std::endl;
202 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 0).getCLCT() << std::endl;
203 if (
allLCTs(bx_alct, mbx, 0).getType() == 2)
204 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 0).getGEM1() << std::endl;
205 if (
allLCTs(bx_alct, mbx, 0).getType() == 3)
207 <<
allLCTs(bx_alct, mbx, 0).getGEM1() <<
" " <<
allLCTs(bx_alct, mbx, 0).getGEM2() << std::endl;
210 if (
allLCTs(bx_alct, mbx, 1).isValid()) {
211 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #2 " <<
allLCTs(bx_alct, mbx, 1) << std::endl;
212 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 1).getALCT() << std::endl;
213 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 1).getCLCT() << std::endl;
214 if (
allLCTs(bx_alct, mbx, 1).getType() == 2)
215 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 1).getGEM1() << std::endl;
216 if (
allLCTs(bx_alct, mbx, 1).getType() == 3)
218 <<
allLCTs(bx_alct, mbx, 1).getGEM1() <<
" " <<
allLCTs(bx_alct, mbx, 1).getGEM2() << std::endl;
225 LogTrace(
"CSCGEMMotherboardME11") <<
"No valid LCT is built from ALCT-CLCT matching in ME1b" << std::endl;
230 int nSuccesFulGEMMatches = 0;
233 LogTrace(
"CSCGEMMotherboardME11") <<
"++No valid ALCT-CLCT matches in ME1b" << std::endl;
234 for (
int bx_gem = bx_copad_start; bx_gem <= bx_copad_stop; bx_gem++) {
240 matches<GEMCoPadDigi> copads;
241 matchingPads<CSCALCTDigi, GEMCoPadDigi>(
246 <<
"\t++Number of matching GEM CoPads in BX " << bx_alct <<
" : " << copads.size() << std::endl;
247 if (copads.empty()) {
257 if (
allLCTs(bx_alct, 0, 0).isValid()) {
258 ++nSuccesFulGEMMatches;
262 <<
"Successful ALCT-GEM CoPad match in ME1b: bx_alct = " << bx_alct <<
"\n\n"
263 <<
"------------------------------------------------------------------------" << std::endl
265 if (
allLCTs(bx_alct, 0, 0).isValid()) {
266 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #1 " <<
allLCTs(bx_alct, 0, 0) << std::endl;
267 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, 0, 0).getALCT() << std::endl;
268 if (
allLCTs(bx_alct, 0, 0).getType() == 4)
270 <<
allLCTs(bx_alct, 0, 0).getGEM1() <<
" " <<
allLCTs(bx_alct, 0, 0).getGEM2() << std::endl
274 <<
"No valid LCT is built from ALCT-GEM matching in ME1b" << std::endl;
276 if (
allLCTs(bx_alct, 0, 1).isValid()) {
277 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #2 " <<
allLCTs(bx_alct, 0, 1) << std::endl;
278 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, 0, 1).getALCT() << std::endl;
279 if (
allLCTs(bx_alct, 0, 1).getType() == 4)
281 <<
allLCTs(bx_alct, 0, 1).getGEM1() <<
" " <<
allLCTs(bx_alct, 0, 1).getGEM2() << std::endl
294 <<
"========================================================================" << std::endl
295 <<
"Summary: " << std::endl;
296 if (nSuccesFulMatches > 1)
298 <<
"Too many successful ALCT-CLCT matches in ME1/1: " << nSuccesFulMatches <<
", CSCDetId " <<
cscId_
299 <<
", bx_alct = " << bx_alct <<
"; match window: [" << bx_clct_start <<
"; " << bx_clct_stop <<
"]"
301 else if (nSuccesFulMatches == 1)
303 <<
"1 successful ALCT-CLCT match in ME1/1: "
304 <<
" CSCDetId " <<
cscId_ <<
", bx_alct = " << bx_alct <<
"; match window: [" << bx_clct_start <<
"; "
305 << bx_clct_stop <<
"]" << std::endl;
306 else if (nSuccesFulGEMMatches == 1)
308 <<
"1 successful ALCT-GEM match in ME1/1: "
309 <<
" CSCDetId " <<
cscId_ <<
", bx_alct = " << bx_alct <<
"; match window: [" << bx_clct_start <<
"; "
310 << bx_clct_stop <<
"]" << std::endl;
312 LogTrace(
"CSCGEMMotherboardME11") <<
"Unsuccessful ALCT-CLCT match in ME1/1: "
313 <<
"CSCDetId " <<
cscId_ <<
", bx_alct = " << bx_alct <<
"; match window: ["
314 << bx_clct_start <<
"; " << bx_clct_stop <<
"]" << std::endl;
319 if (!coPads.empty()) {
326 for (
int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++) {
331 if (
clctProc->getBestCLCT(bx_clct).isValid()) {
336 int mbx = bx_clct - bx_clct_start;
342 if (
allLCTs(bx_alct, mbx, 0).isValid()) {
343 used_clct_mask[bx_clct] += 1;
348 <<
"Successful GEM-CLCT match in ME1b: bx_alct = " << bx_alct <<
"; match window: ["
349 << bx_clct_start <<
"; " << bx_clct_stop <<
"]; bx_clct = " << bx_clct <<
"\n"
350 <<
"+++ Best CLCT Details: " <<
clctProc->getBestCLCT(bx_clct) <<
"\n"
351 <<
"+++ Second CLCT Details: " <<
clctProc->getSecondCLCT(bx_clct) << std::endl;
353 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #1 " <<
allLCTs(bx_alct, mbx, 0) << std::endl;
354 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 0).getALCT() << std::endl;
355 if (
allLCTs(bx_alct, mbx, 0).getType() == 5)
357 <<
allLCTs(bx_alct, mbx, 0).getGEM1() <<
" " <<
allLCTs(bx_alct, mbx, 0).getGEM2() << std::endl
360 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #2 " <<
allLCTs(bx_alct, mbx, 1) << std::endl;
361 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 1).getALCT() << std::endl;
362 if (
allLCTs(bx_alct, mbx, 1).getType() == 5)
364 <<
allLCTs(bx_alct, mbx, 1).getGEM1() <<
" " <<
allLCTs(bx_alct, mbx, 1).getGEM2() << std::endl
379 LogTrace(
"CSCGEMMotherboardME11") <<
"======================================================================== \n"
380 <<
"Counting the final LCTs in CSCGEMMotherboard ME11\n"
381 <<
"======================================================================== \n"
383 unsigned int n1b = 0, n1a = 0;
386 LogTrace(
"CSCGEMMotherboardME11") <<
"1b LCT " << n1b <<
" " <<
p << std::endl;
391 LogTrace(
"CSCGEMMotherboardME11") <<
"1a LCT " << n1a <<
" " <<
p << std::endl;
404 std::vector<CSCCorrelatedLCTDigi> tmpV;
419 std::vector<CSCCorrelatedLCTDigi> all_lcts;
432 LogTrace(
"CSCGEMMotherboardME11") <<
"tmb_cross_bx_algo error" << std::endl;
436 for (
const auto& lct : all_lcts) {
440 int bx = lct.getBX();
458 if (bx_readout == -1)
466 for (
const auto& lct : tmpV) {
483 LCTs.erase(LCTs.begin() +
max_lcts, LCTs.end());
491 std::vector<CSCCorrelatedLCTDigi> LCTs_tmp;
495 for (
const auto&
p : LCTs_tmp) {
523 if (secondALCT == bestALCT)
525 if (secondCLCT == bestCLCT)
537 const int code = (ok11 << 3) | (ok12 << 2) | (ok21 << 1) | (ok22);
541 LogTrace(
"CSCGEMMotherboardME11") <<
"debug correlateLCTs in ME11" <<
cscId_ <<
"\n"
542 <<
"ALCT1: " << bestALCT <<
"\n"
543 <<
"ALCT2: " << secondALCT <<
"\n"
544 <<
"CLCT1: " << bestCLCT <<
"\n"
545 <<
"CLCT2: " << secondCLCT <<
"\n"
546 <<
"ok 11 12 21 22 code = " << ok11 <<
" " << ok12 <<
" " << ok21 <<
" " << ok22
547 <<
" " << code << std::endl;
575 LogTrace(
"CSCGEMMotherboardME11") <<
"lut 0 1 = " << lut[code][0] <<
" " << lut[code][1] << std::endl;
578 const GEMCoPadDigi& bb_copad = bestMatchingPad<GEMCoPadDigi>(bestALCT, bestCLCT, copads);
579 const GEMCoPadDigi& bs_copad = bestMatchingPad<GEMCoPadDigi>(bestALCT, secondCLCT, copads);
580 const GEMCoPadDigi& sb_copad = bestMatchingPad<GEMCoPadDigi>(secondALCT, bestCLCT, copads);
581 const GEMCoPadDigi& ss_copad = bestMatchingPad<GEMCoPadDigi>(secondALCT, secondCLCT, copads);
584 const GEMPadDigi& bb_pad = bestMatchingPad<GEMPadDigi>(bestALCT, bestCLCT, pads);
585 const GEMPadDigi& bs_pad = bestMatchingPad<GEMPadDigi>(bestALCT, secondCLCT, pads);
586 const GEMPadDigi& sb_pad = bestMatchingPad<GEMPadDigi>(secondALCT, bestCLCT, pads);
587 const GEMPadDigi& ss_pad = bestMatchingPad<GEMPadDigi>(secondALCT, secondCLCT, pads);
590 const bool ok_bb_copad = ok11 == 1 and ok_bb and bb_copad.
isValid();
591 const bool ok_bs_copad = ok12 == 1 and ok_bs and bs_copad.
isValid();
592 const bool ok_sb_copad = ok21 == 1 and ok_sb and sb_copad.
isValid();
593 const bool ok_ss_copad = ok22 == 1 and ok_ss and ss_copad.
isValid();
595 const bool ok_bb_pad = ok11 == 1 and ok_bb and bb_pad.
isValid();
596 const bool ok_bs_pad = ok12 == 1 and ok_bs and bs_pad.
isValid();
597 const bool ok_sb_pad = ok21 == 1 and ok_sb and sb_pad.
isValid();
598 const bool ok_ss_pad = ok22 == 1 and ok_ss and ss_pad.
isValid();
600 switch (lut[code][0]) {
638 LogTrace(
"CSCGEMMotherboardME11") <<
"lct1: " << lct1 << std::endl;
640 switch (lut[code][1]) {
670 LogTrace(
"CSCGEMMotherboardME11") <<
"lct2: " << lct2 << std::endl;
673 LogTrace(
"CSCGEMMotherboardME11") <<
"out of correlateLCTs" << std::endl;