35 : trigGeomUtils(nullptr), isLocalRun(ps.getUntrackedParameter<
bool>(
"localrun",
true)) {
40 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask") <<
"[DTLocalTriggerTask]: Constructor" << endl;
45 tm_Token_ = consumes<L1MuDTChambPhContainer>(
65 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask")
66 <<
"[DTLocalTriggerTask]: analyzed " <<
nevents <<
" events" << endl;
81 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask") <<
"[DTLocalTriggerTask]: bookHistograms" << endl;
85 vector<string> trigSources;
87 trigSources.push_back(
"");
89 trigSources.push_back(
"_DTonly");
90 trigSources.push_back(
"_NoDT");
91 trigSources.push_back(
"_DTalso");
93 vector<string>::const_iterator trigSrcIt = trigSources.begin();
94 vector<string>::const_iterator trigSrcEnd = trigSources.end();
102 for (
int wh = -2; wh < 3; ++wh) {
103 for (
int sect = 1; sect < 13; ++sect) {
107 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_BXvsQual" + (*trigSrcIt));
108 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_QualvsPhirad" + (*trigSrcIt));
114 for (; trigSrcIt != trigSrcEnd; ++trigSrcIt) {
115 for (
int wh = -2; wh < 3; ++wh) {
116 for (
int sect = 1; sect < 13; ++sect) {
121 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_BXvsQual_In" + (*trigSrcIt));
123 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_QualvsPhirad_In" + (*trigSrcIt));
124 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_QualvsPhibend_In" + (*trigSrcIt));
126 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_Flag1stvsQual_In" + (*trigSrcIt));
127 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_FlagUpDownvsQual_In" + (*trigSrcIt));
129 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_BestQual_In" + (*trigSrcIt));
131 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_PositionvsBX" + (*trigSrcIt));
132 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_QualityvsBX" + (*trigSrcIt));
134 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_PositionvsQual" + (*trigSrcIt));
136 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_ThetaBXvsQual" + (*trigSrcIt));
137 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_ThetaBestQual" + (*trigSrcIt));
141 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhitkvsPhitrig" + (*trigSrcIt));
142 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhibtkvsPhibtrig" + (*trigSrcIt));
143 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhiResidual" + (*trigSrcIt));
144 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhiResidualvsLUTPhi" + (*trigSrcIt));
145 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhibResidual" + (*trigSrcIt));
146 bookHistos(ibooker, dtChId,
"Segment",
"TM_HitstkvsQualtrig" + (*trigSrcIt));
147 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackPosvsAngle" + (*trigSrcIt));
148 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackPosvsAngleandTrig" + (*trigSrcIt));
149 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackPosvsAngleandTrigHHHL" + (*trigSrcIt));
151 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackThetaPosvsAngle" + (*trigSrcIt));
152 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackThetaPosvsAngleandTrig" + (*trigSrcIt));
156 "TM_TrackThetaPosvsAngleandTrigH" + (*trigSrcIt));
162 for (
int sect = 13; sect < 15; ++sect) {
166 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhitkvsPhitrig" + (*trigSrcIt));
167 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhibtkvsPhibtrig" + (*trigSrcIt));
168 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhiResidual" + (*trigSrcIt));
169 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhiResidualvsLUTPhi" + (*trigSrcIt));
170 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhibResidual" + (*trigSrcIt));
180 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask") <<
"[DTLocalTriggerTask]: Begin of LS transition" << endl;
183 for (
map<uint32_t, map<string, MonitorElement*> >::const_iterator
histo =
digiHistos.begin();
186 for (map<string, MonitorElement*>::const_iterator ht = (*histo).second.begin(); ht != (*histo).second.end();
188 (*ht).second->Reset();
215 vector<L1MuDTChambPhDigi>
const* l1PhTrig = l1DTTPGPh->
getContainer();
220 vector<L1MuDTChambThDigi>
const* l1ThTrig = l1DTTPGTh->
getContainer();
234 if (
histoTag ==
"TM_ErrorsChamberID") {
246 int wh = dtCh.
wheel();
266 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask")
267 <<
"[DTLocalTriggerTask]: booking " <<
topFolder() <<
"Wheel" <<
wheel.str() <<
"/Sector" << sector.str()
270 if (histoType.find(
"BX") != string::npos) {
271 if (
histoTag.substr(0, 2) ==
"TM") {
278 if (
folder ==
"LocalTriggerPhiIn") {
279 if (histoType ==
"BXvsQual") {
285 if (histoType ==
"BestQual") {
287 ibooker.
book1D(
histoName,
"Trigger quality of best primitives", 7, -0.5, 6.5);
291 if (histoType ==
"QualvsPhirad") {
293 ibooker.
book2D(
histoName,
"Trigger quality vs local position", 100, -500., 500., 7, -0.5, 6.5);
297 if (histoType ==
"QualvsPhibend") {
299 ibooker.
book2D(
histoName,
"Trigger quality vs local direction", 200, -40., 40., 7, -0.5, 6.5);
303 if (histoType ==
"Flag1stvsQual") {
305 ibooker.
book2D(
histoName,
"1st/2nd trig flag vs quality", 7, -0.5, 6.5, 2, -0.5, 1.5);
309 if (histoType ==
"FlagUpDownvsQual") {
311 ibooker.
book2D(
histoName,
"Up/Down trig flag vs quality", 7, -0.5, 6.5, 2, -0.5, 1.5);
316 }
else if (
folder ==
"LocalTriggerTheta") {
317 if (histoType ==
"PositionvsBX") {
322 if (histoType ==
"PositionvsQual") {
324 ibooker.
book2D(
histoName,
"Theta trigger position vs quality", 2, 0.5, 2.5, 7, -0.5, 6.5);
328 if (histoType ==
"ThetaBXvsQual") {
333 if (histoType ==
"ThetaBestQual") {
335 histoName,
"Trigger quality of best primitives (theta)", 2, 0.5, 2.5);
340 }
else if (
folder ==
"Segment") {
341 if (histoType.find(
"TrackThetaPosvsAngle") == 0) {
342 string histoLabel =
"Position vs Angle (theta)";
343 if (histoType.find(
"andTrigH") != string::npos)
345 else if (histoType.find(
"andTrig") != string::npos)
354 if (histoType.find(
"TrackPosvsAngle") == 0) {
359 string histoLabel =
"Position vs Angle (phi)";
360 if (histoType.find(
"andTrigHHHL") != string::npos)
362 else if (histoType.find(
"andTrig") != string::npos)
368 if (histoType ==
"PhitkvsPhitrig") {
370 ibooker.
book2D(
histoName,
"Local position: segment vs trigger", 100, -500., 500., 100, -500., 500.);
373 if (histoType ==
"PhibtkvsPhibtrig") {
375 ibooker.
book2D(
histoName,
"Local direction : segment vs trigger", 200, -40., 40., 200, -40., 40.);
378 if (histoType ==
"PhiResidual") {
380 histoName,
"Trigger local position - Segment local position (correlated triggers)", 400, -10., 10.);
383 if (histoType ==
"PhibResidual") {
385 histoName,
"Trigger local direction - Segment local direction (correlated triggers)", 500, -10., 10.);
388 if (histoType ==
"HitstkvsQualtrig") {
390 ibooker.
book2D(
histoName,
"Segment hits (phi) vs trigger quality", 7, -0.5, 6.5, 10, 0.5, 10.5);
407 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask")
412 std::vector<L1MuDTChambThDigi>
const* thTrigs) {
420 for (
int i = 0;
i < 5; ++
i) {
421 for (
int j = 0;
j < 6; ++
j) {
422 for (
int k = 0;
k < 13; ++
k) {
429 vector<L1MuDTChambPhDigi>::const_iterator iph = phTrigs->begin();
430 vector<L1MuDTChambPhDigi>::const_iterator iphe = phTrigs->end();
431 for (; iph != iphe; ++iph) {
432 int phwheel = iph->whNum();
433 int phsec = iph->scNum() + 1;
434 int phst = iph->stNum();
435 int phbx = iph->bxNum();
436 int phcode = iph->code();
437 int phi1st = iph->Ts2Tag();
438 int updown = iph->UpDownTag();
446 if (phcode >
phcode_best[phwheel + 3][phst][phsec] && phcode < 7) {
448 iphbest[phwheel + 3][phst][phsec] = &(*iph);
455 uint32_t indexCh = dtChId.
rawId();
457 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
460 innerME.find(
"TM_BXvsQual" +
trigsrc)->second->Fill(phcode, phbx - phi1st);
461 innerME.find(
"TM_QualvsPhirad" +
trigsrc)->second->Fill(
x, phcode);
463 innerME.find(
"TM_BXvsQual_In" +
trigsrc)
464 ->second->Fill(phcode, phbx - phi1st);
465 innerME.find(
"TM_Flag1stvsQual_In" +
trigsrc)
466 ->second->Fill(phcode, phi1st);
467 innerME.find(
"TM_FlagUpDownvsQual_In" +
trigsrc)
468 ->second->Fill(phcode, updown);
470 innerME.find(
"TM_QualvsPhirad_In" +
trigsrc)->second->Fill(
x, phcode);
471 innerME.find(
"TM_QualvsPhibend_In" +
trigsrc)->second->Fill(
angle, phcode);
478 vector<L1MuDTChambThDigi>::const_iterator ith = thTrigs->begin();
479 vector<L1MuDTChambThDigi>::const_iterator ithe = thTrigs->end();
480 for (; ith != ithe; ++ith) {
481 int thwheel = ith->whNum();
482 int thsec = ith->scNum() + 1;
483 int thst = ith->stNum();
484 int thbx = ith->bxNum();
487 thcode[
pos] = ith->code(
pos);
491 ithbest[thwheel + 3][thst][thsec] = &(*ith);
496 uint32_t indexCh = dtChId.
rawId();
498 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
501 if (thcode[
pos] > 0) {
502 innerME.find(
"TM_PositionvsBX" +
trigsrc)->second->Fill(thbx,
pos);
503 innerME.find(
"TM_PositionvsQual" +
trigsrc)
504 ->second->Fill(thcode[
pos],
pos);
505 innerME.find(
"TM_ThetaBXvsQual" +
trigsrc)
506 ->second->Fill(thcode[
pos], thbx);
514 for (
int st = 1; st < 5; ++st) {
515 for (
int wh = -2; wh < 3; ++wh) {
516 for (
int sc = 1; sc < 13; ++sc) {
519 uint32_t indexCh =
id.rawId();
520 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
522 innerME.find(
"TM_BestQual_In" +
trigsrc)
527 uint32_t indexCh =
id.rawId();
528 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
530 innerME.find(
"TM_ThetaBestQual" +
trigsrc)
543 memset(
track_ok,
false, 450 *
sizeof(
bool));
546 vector<const DTRecSegment4D*> best4DSegments;
549 for (chamberId = segments4D->id_begin(); chamberId != segments4D->id_end(); ++chamberId) {
556 if ((*track).hasPhi()) {
557 dof = (*track).phiSegment()->degreesOfFreedom();
562 int wheel = (*track).chamberId().wheel();
563 int sector = (*track).chamberId().sector();
564 int station = (*track).chamberId().station();
567 }
else if (sector == 14) {
575 best4DSegments.push_back(tmpBest);
578 vector<const DTRecSegment4D*>::const_iterator btrack;
580 for (btrack = best4DSegments.begin(); btrack != best4DSegments.end(); ++btrack) {
581 if ((*btrack)->hasPhi()) {
583 int wheel = (*btrack)->chamberId().wheel();
584 int station = (*btrack)->chamberId().station();
585 int sector = (*btrack)->chamberId().sector();
587 float x_track, y_track, x_angle, y_angle;
589 int nHitsPhi = (*btrack)->phiSegment()->degreesOfFreedom() + 2;
592 uint32_t indexCh = dtChId.
rawId();
593 map<string, MonitorElement*>& innerMECh =
digiHistos[indexCh];
597 indexCh = dtChIdSC.
rawId();
598 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
608 innerMECh.find(
"TM_PhitkvsPhitrig" +
trigsrc)->second->Fill(x_trigger, x_track);
609 innerMECh.find(
"TM_PhibtkvsPhibtrig" +
trigsrc)->second->Fill(angle_trigger, x_angle);
610 innerMECh.find(
"TM_PhiResidual" +
trigsrc)->second->Fill(x_trigger - x_track);
611 innerMECh.find(
"TM_PhibResidual" +
trigsrc)->second->Fill(angle_trigger - x_angle);
617 bool trigFlagTM =
false;
618 for (
int ist = 1; ist < 5; ist++) {
626 if (trigFlagTM && fabs(x_angle) < 40. && nHitsPhi >= 7) {
628 innerME.find(
"TM_TrackPosvsAngle" +
trigsrc)->second->Fill(x_angle, x_track);
630 innerME.find(
"TM_TrackPosvsAngleandTrig" +
trigsrc)->second->Fill(x_angle, x_track);
632 innerME.find(
"TM_TrackPosvsAngleandTrigHHHL" +
trigsrc)->second->Fill(x_angle, x_track);
637 if ((*btrack)->hasZed() && trigFlagTM && fabs(y_angle) < 40. &&
638 (*btrack)->zSegment()->degreesOfFreedom() >= 1) {
640 innerME.find(
"TM_TrackThetaPosvsAngle" +
trigsrc)->second->Fill(y_angle, y_track);
642 innerME.find(
"TM_TrackThetaPosvsAngleandTrig" +
trigsrc)->second->Fill(y_angle, y_track);
644 innerME.find(
"TM_TrackThetaPosvsAngleandTrigH" +
trigsrc)->second->Fill(y_angle, y_track);
658 TAxis* axis =
nullptr;
660 axis =
histo->GetXaxis();
661 }
else if (iaxis == 2) {
662 axis =
histo->GetYaxis();
667 string labels[7] = {
"LI",
"LO",
"HI",
"HO",
"LL",
"HL",
"HH"};
668 int istart = axis->GetXmin() < -1 ? 2 : 1;
669 for (
int i = 0;
i < 7;
i++) {
670 axis->SetBinLabel(
i + istart,
labels[
i].c_str());
679 TAxis* axis =
nullptr;
681 axis =
histo->GetXaxis();
682 }
else if (iaxis == 2) {
683 axis =
histo->GetYaxis();
688 string labels[2] = {
"L",
"H"};
689 int istart = axis->GetXmin() < -1 ? 2 : 1;
690 for (
int i = 0;
i < 2;
i++) {
691 axis->SetBinLabel(
i + istart,
labels[
i].c_str());
700 for (std::vector<LTCDigi>::const_iterator ltc_it = ltcdigis->begin(); ltc_it != ltcdigis->end(); ltc_it++) {
701 size_t otherTriggerSum = 0;
702 for (
size_t i = 1;
i < 6;
i++) {
703 otherTriggerSum += size_t((*ltc_it).HasTriggered(
i));
705 if ((*ltc_it).HasTriggered(0) && otherTriggerSum == 0)
707 else if (!(*ltc_it).HasTriggered(0))
709 else if ((*ltc_it).HasTriggered(0) && otherTriggerSum > 0)