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";
63 unsigned alctBits =
alctProc->getHighMultiplictyBits();
66 if (
gem_g !=
nullptr) {
68 edm::LogInfo(
"CSCGEMMotherboardME11|SetupInfo") <<
"+++ run() called for GEM-CSC integrated trigger! +++ \n";
75 <<
"+++ run() called for GEM-CSC integrated trigger without valid GEM geometry! +++ \n";
81 <<
"+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
97 int used_clct_mask[20];
98 for (
int b = 0;
b < 20;
b++)
99 used_clct_mask[
b] = 0;
101 const bool hasPads(!
pads_.empty());
102 const bool hasCoPads(hasPads and !
coPads_.empty());
105 LogTrace(
"CSCGEMMotherboardME11") <<
"hascopads " << hasCoPads << std::endl;
109 if (
alctProc->getBestALCT(bx_alct).isValid()) {
117 <<
"========================================================================\n"
118 <<
"ALCT-CLCT matching in ME1/1 chamber: " <<
cscId_ <<
"\n"
119 <<
"------------------------------------------------------------------------\n"
120 <<
"+++ Best ALCT Details: " <<
alctProc->getBestALCT(bx_alct) <<
"\n"
121 <<
"+++ Second ALCT Details: " <<
alctProc->getSecondALCT(bx_alct) << std::endl;
127 <<
"------------------------------------------------------------------------ \n"
128 <<
"Attempt ALCT-CLCT matching in ME1/b in bx range: [" << bx_clct_start <<
"," << bx_clct_stop <<
"]"
133 int nSuccesFulMatches = 0;
134 for (
int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++) {
139 if (
clctProc->getBestCLCT(bx_clct).isValid()) {
141 LogTrace(
"CSCGEMMotherboardME11") <<
"++Valid ME1b CLCT: " <<
clctProc->getBestCLCT(bx_clct) << std::endl;
144 matches<GEMPadDigi> mPads;
145 matchingPads<GEMPadDigi>(
clctProc->getBestCLCT(bx_clct),
150 matches<GEMCoPadDigi> mCoPads;
151 matchingPads<GEMCoPadDigi>(
clctProc->getBestCLCT(bx_clct),
157 const bool lowQualityCLCT(
clctProc->getBestCLCT(bx_clct).getQuality() <= 3);
158 const bool hasMatchingPads(!mPads.empty()
or !mCoPads.empty());
161 LogTrace(
"CSCGEMMotherboardME11") <<
"Dropping low quality CLCT without matching GEM pads "
162 <<
clctProc->getBestCLCT(bx_clct) << std::endl;
167 LogTrace(
"CSCGEMMotherboardME11") <<
"mPads " << mPads.size() <<
" "
168 <<
" mCoPads " << mCoPads.size() << std::endl;
169 for (
auto p : mPads) {
170 LogTrace(
"CSCGEMMotherboardME11") <<
p.first <<
" " <<
p.second << std::endl;
172 for (
auto p : mCoPads) {
173 LogTrace(
"CSCGEMMotherboardME11") <<
p.first <<
" " <<
p.second << std::endl;
177 int mbx = bx_clct - bx_clct_start;
187 if (
allLCTs(bx_alct, mbx, 0).isValid()) {
189 used_clct_mask[bx_clct] += 1;
193 <<
"Successful ALCT-CLCT match in ME1b: bx_alct = " << bx_alct <<
"; match window: [" << bx_clct_start
194 <<
"; " << bx_clct_stop <<
"]; bx_clct = " << bx_clct <<
"\n"
195 <<
"+++ Best CLCT Details: " <<
clctProc->getBestCLCT(bx_clct) <<
"\n"
196 <<
"+++ Second CLCT Details: " <<
clctProc->getSecondCLCT(bx_clct) << std::endl;
198 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #1 " <<
allLCTs(bx_alct, mbx, 0) << std::endl;
199 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 0).getALCT() << std::endl;
200 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 0).getCLCT() << std::endl;
201 if (
allLCTs(bx_alct, mbx, 0).getType() == 2)
202 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 0).getGEM1() << std::endl;
203 if (
allLCTs(bx_alct, mbx, 0).getType() == 3)
205 <<
allLCTs(bx_alct, mbx, 0).getGEM1() <<
" " <<
allLCTs(bx_alct, mbx, 0).getGEM2() << std::endl;
209 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #2 " <<
allLCTs(bx_alct, mbx, 1) << std::endl;
210 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 1).getALCT() << std::endl;
211 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 1).getCLCT() << std::endl;
212 if (
allLCTs(bx_alct, mbx, 1).getType() == 2)
213 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 1).getGEM1() << std::endl;
214 if (
allLCTs(bx_alct, mbx, 1).getType() == 3)
216 <<
allLCTs(bx_alct, mbx, 1).getGEM1() <<
" " <<
allLCTs(bx_alct, mbx, 1).getGEM2() << std::endl;
223 LogTrace(
"CSCGEMMotherboardME11") <<
"No valid LCT is built from ALCT-CLCT matching in ME1b" << std::endl;
228 int nSuccesFulGEMMatches = 0;
231 LogTrace(
"CSCGEMMotherboardME11") <<
"++No valid ALCT-CLCT matches in ME1b" << std::endl;
232 for (
int bx_gem = bx_copad_start; bx_gem <= bx_copad_stop; bx_gem++) {
238 matches<GEMCoPadDigi> copads;
239 matchingPads<CSCALCTDigi, GEMCoPadDigi>(
244 <<
"\t++Number of matching GEM CoPads in BX " << bx_alct <<
" : " << copads.size() << std::endl;
245 if (copads.empty()) {
255 if (
allLCTs(bx_alct, 0, 0).isValid()) {
256 ++nSuccesFulGEMMatches;
260 <<
"Successful ALCT-GEM CoPad match in ME1b: bx_alct = " << bx_alct <<
"\n\n"
261 <<
"------------------------------------------------------------------------" << std::endl
264 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #1 " <<
allLCTs(bx_alct, 0, 0) << std::endl;
265 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, 0, 0).getALCT() << std::endl;
266 if (
allLCTs(bx_alct, 0, 0).getType() == 4)
268 <<
allLCTs(bx_alct, 0, 0).getGEM1() <<
" " <<
allLCTs(bx_alct, 0, 0).getGEM2() << std::endl
272 <<
"No valid LCT is built from ALCT-GEM matching in ME1b" << std::endl;
275 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #2 " <<
allLCTs(bx_alct, 0, 1) << std::endl;
276 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, 0, 1).getALCT() << std::endl;
277 if (
allLCTs(bx_alct, 0, 1).getType() == 4)
279 <<
allLCTs(bx_alct, 0, 1).getGEM1() <<
" " <<
allLCTs(bx_alct, 0, 1).getGEM2() << std::endl
292 <<
"========================================================================" << std::endl
293 <<
"Summary: " << std::endl;
294 if (nSuccesFulMatches > 1)
296 <<
"Too many successful ALCT-CLCT matches in ME1/1: " << nSuccesFulMatches <<
", CSCDetId " <<
cscId_
297 <<
", bx_alct = " << bx_alct <<
"; match window: [" << bx_clct_start <<
"; " << bx_clct_stop <<
"]"
299 else if (nSuccesFulMatches == 1)
301 <<
"1 successful ALCT-CLCT match in ME1/1: "
302 <<
" CSCDetId " <<
cscId_ <<
", bx_alct = " << bx_alct <<
"; match window: [" << bx_clct_start <<
"; "
303 << bx_clct_stop <<
"]" << std::endl;
304 else if (nSuccesFulGEMMatches == 1)
306 <<
"1 successful ALCT-GEM match in ME1/1: "
307 <<
" CSCDetId " <<
cscId_ <<
", bx_alct = " << bx_alct <<
"; match window: [" << bx_clct_start <<
"; "
308 << bx_clct_stop <<
"]" << std::endl;
310 LogTrace(
"CSCGEMMotherboardME11") <<
"Unsuccessful ALCT-CLCT match in ME1/1: "
311 <<
"CSCDetId " <<
cscId_ <<
", bx_alct = " << bx_alct <<
"; match window: ["
312 << bx_clct_start <<
"; " << bx_clct_stop <<
"]" << std::endl;
317 if (!coPads.empty()) {
324 for (
int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++) {
329 if (
clctProc->getBestCLCT(bx_clct).isValid()) {
334 int mbx = bx_clct - bx_clct_start;
340 if (
allLCTs(bx_alct, mbx, 0).isValid()) {
341 used_clct_mask[bx_clct] += 1;
346 <<
"Successful GEM-CLCT match in ME1b: bx_alct = " << bx_alct <<
"; match window: ["
347 << bx_clct_start <<
"; " << bx_clct_stop <<
"]; bx_clct = " << bx_clct <<
"\n"
348 <<
"+++ Best CLCT Details: " <<
clctProc->getBestCLCT(bx_clct) <<
"\n"
349 <<
"+++ Second CLCT Details: " <<
clctProc->getSecondCLCT(bx_clct) << std::endl;
351 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #1 " <<
allLCTs(bx_alct, mbx, 0) << std::endl;
352 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 0).getALCT() << std::endl;
353 if (
allLCTs(bx_alct, mbx, 0).getType() == 5)
355 <<
allLCTs(bx_alct, mbx, 0).getGEM1() <<
" " <<
allLCTs(bx_alct, mbx, 0).getGEM2() << std::endl
358 LogTrace(
"CSCGEMMotherboardME11") <<
"LCT #2 " <<
allLCTs(bx_alct, mbx, 1) << std::endl;
359 LogTrace(
"CSCGEMMotherboardME11") <<
allLCTs(bx_alct, mbx, 1).getALCT() << std::endl;
360 if (
allLCTs(bx_alct, mbx, 1).getType() == 5)
362 <<
allLCTs(bx_alct, mbx, 1).getGEM1() <<
" " <<
allLCTs(bx_alct, mbx, 1).getGEM2() << std::endl
377 LogTrace(
"CSCGEMMotherboardME11") <<
"======================================================================== \n"
378 <<
"Counting the final LCTs in CSCGEMMotherboard ME11\n"
379 <<
"======================================================================== \n"
381 unsigned int n1b = 0, n1a = 0;
384 LogTrace(
"CSCGEMMotherboardME11") <<
"1b LCT " << n1b <<
" " <<
p << std::endl;
389 LogTrace(
"CSCGEMMotherboardME11") <<
"1a LCT " << n1a <<
" " <<
p << std::endl;
402 std::vector<CSCCorrelatedLCTDigi> tmpV;
417 std::vector<CSCCorrelatedLCTDigi> all_lcts;
430 LogTrace(
"CSCGEMMotherboardME11") <<
"tmb_cross_bx_algo error" << std::endl;
434 for (
const auto& lct : all_lcts) {
438 int bx = lct.getBX();
456 if (bx_readout == -1)
464 for (
const auto& lct : tmpV) {
481 LCTs.erase(LCTs.begin() +
max_lcts, LCTs.end());
489 std::vector<CSCCorrelatedLCTDigi> LCTs_tmp;
493 for (
const auto&
p : LCTs_tmp) {
521 if (secondALCT == bestALCT)
523 if (secondCLCT == bestCLCT)
535 const int code = (ok11 << 3) | (ok12 << 2) | (ok21 << 1) | (ok22);
539 LogTrace(
"CSCGEMMotherboardME11") <<
"debug correlateLCTs in ME11" <<
cscId_ <<
"\n"
540 <<
"ALCT1: " << bestALCT <<
"\n"
541 <<
"ALCT2: " << secondALCT <<
"\n"
542 <<
"CLCT1: " << bestCLCT <<
"\n"
543 <<
"CLCT2: " << secondCLCT <<
"\n"
544 <<
"ok 11 12 21 22 code = " << ok11 <<
" " << ok12 <<
" " << ok21 <<
" " << ok22
545 <<
" " << code << std::endl;
573 LogTrace(
"CSCGEMMotherboardME11") <<
"lut 0 1 = " << lut[code][0] <<
" " << lut[code][1] << std::endl;
576 const GEMCoPadDigi& bb_copad = bestMatchingPad<GEMCoPadDigi>(bestALCT, bestCLCT, copads);
577 const GEMCoPadDigi& bs_copad = bestMatchingPad<GEMCoPadDigi>(bestALCT, secondCLCT, copads);
578 const GEMCoPadDigi& sb_copad = bestMatchingPad<GEMCoPadDigi>(secondALCT, bestCLCT, copads);
579 const GEMCoPadDigi& ss_copad = bestMatchingPad<GEMCoPadDigi>(secondALCT, secondCLCT, copads);
582 const GEMPadDigi& bb_pad = bestMatchingPad<GEMPadDigi>(bestALCT, bestCLCT, pads);
583 const GEMPadDigi& bs_pad = bestMatchingPad<GEMPadDigi>(bestALCT, secondCLCT, pads);
584 const GEMPadDigi& sb_pad = bestMatchingPad<GEMPadDigi>(secondALCT, bestCLCT, pads);
585 const GEMPadDigi& ss_pad = bestMatchingPad<GEMPadDigi>(secondALCT, secondCLCT, pads);
588 const bool ok_bb_copad = ok11 == 1 and ok_bb and bb_copad.
isValid();
589 const bool ok_bs_copad = ok12 == 1 and ok_bs and bs_copad.
isValid();
590 const bool ok_sb_copad = ok21 == 1 and ok_sb and sb_copad.
isValid();
591 const bool ok_ss_copad = ok22 == 1 and ok_ss and ss_copad.
isValid();
593 const bool ok_bb_pad = ok11 == 1 and ok_bb and bb_pad.
isValid();
594 const bool ok_bs_pad = ok12 == 1 and ok_bs and bs_pad.
isValid();
595 const bool ok_sb_pad = ok21 == 1 and ok_sb and sb_pad.
isValid();
596 const bool ok_ss_pad = ok22 == 1 and ok_ss and ss_pad.
isValid();
598 switch (lut[code][0]) {
636 LogTrace(
"CSCGEMMotherboardME11") <<
"lct1: " << lct1 << std::endl;
638 switch (lut[code][1]) {
668 LogTrace(
"CSCGEMMotherboardME11") <<
"lct2: " << lct2 << std::endl;
671 LogTrace(
"CSCGEMMotherboardME11") <<
"out of correlateLCTs" << std::endl;