35 trigGeomUtils(nullptr),
36 isLocalRun(ps.getUntrackedParameter<bool>(
"localrun",
true)) {
41 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask") <<
"[DTLocalTriggerTask]: Constructor" << endl;
46 tm_Token_ = consumes<L1MuDTChambPhContainer>(
66 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask")
67 <<
"[DTLocalTriggerTask]: analyzed " <<
nevents <<
" events" << endl;
82 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask") <<
"[DTLocalTriggerTask]: bookHistograms" << endl;
86 vector<string> trigSources;
88 trigSources.push_back(
"");
90 trigSources.push_back(
"_DTonly");
91 trigSources.push_back(
"_NoDT");
92 trigSources.push_back(
"_DTalso");
94 vector<string>::const_iterator trigSrcIt = trigSources.begin();
95 vector<string>::const_iterator trigSrcEnd = trigSources.end();
103 for (
int wh = -2; wh < 3; ++wh) {
104 for (
int sect = 1; sect < 13; ++sect) {
108 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_BXvsQual" + (*trigSrcIt));
109 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_QualvsPhirad" + (*trigSrcIt));
115 for (; trigSrcIt != trigSrcEnd; ++trigSrcIt) {
116 for (
int wh = -2; wh < 3; ++wh) {
117 for (
int sect = 1; sect < 13; ++sect) {
122 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_BXvsQual_In" + (*trigSrcIt));
124 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_QualvsPhirad_In" + (*trigSrcIt));
125 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_QualvsPhibend_In" + (*trigSrcIt));
127 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_Flag1stvsQual_In" + (*trigSrcIt));
128 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_FlagUpDownvsQual_In" + (*trigSrcIt));
130 bookHistos(ibooker, dtChId,
"LocalTriggerPhiIn",
"TM_BestQual_In" + (*trigSrcIt));
132 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_PositionvsBX" + (*trigSrcIt));
133 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_QualityvsBX" + (*trigSrcIt));
135 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_PositionvsQual" + (*trigSrcIt));
137 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_ThetaBXvsQual" + (*trigSrcIt));
138 bookHistos(ibooker, dtChId,
"LocalTriggerTheta",
"TM_ThetaBestQual" + (*trigSrcIt));
142 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhitkvsPhitrig" + (*trigSrcIt));
143 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhibtkvsPhibtrig" + (*trigSrcIt));
144 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhiResidual" + (*trigSrcIt));
145 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhiResidualvsLUTPhi" + (*trigSrcIt));
146 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhibResidual" + (*trigSrcIt));
147 bookHistos(ibooker, dtChId,
"Segment",
"TM_HitstkvsQualtrig" + (*trigSrcIt));
148 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackPosvsAngle" + (*trigSrcIt));
149 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackPosvsAngleandTrig" + (*trigSrcIt));
150 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackPosvsAngleandTrigHHHL" + (*trigSrcIt));
152 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackThetaPosvsAngle" + (*trigSrcIt));
153 bookHistos(ibooker, dtChId,
"Segment",
"TM_TrackThetaPosvsAngleandTrig" + (*trigSrcIt));
157 "TM_TrackThetaPosvsAngleandTrigH" + (*trigSrcIt));
163 for (
int sect = 13; sect < 15; ++sect) {
167 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhitkvsPhitrig" + (*trigSrcIt));
168 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhibtkvsPhibtrig" + (*trigSrcIt));
169 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhiResidual" + (*trigSrcIt));
170 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhiResidualvsLUTPhi" + (*trigSrcIt));
171 bookHistos(ibooker, dtChId,
"Segment",
"TM_PhibResidual" + (*trigSrcIt));
181 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask") <<
"[DTLocalTriggerTask]: Begin of LS transition" << endl;
184 for (map<uint32_t, map<string, MonitorElement*> >::const_iterator
histo =
digiHistos.begin();
187 for (map<string, MonitorElement*>::const_iterator ht = (*histo).second.begin(); ht != (*histo).second.end();
189 (*ht).second->Reset();
216 vector<L1MuDTChambPhDigi>
const* l1PhTrig = l1DTTPGPh->getContainer();
221 vector<L1MuDTChambThDigi>
const* l1ThTrig = l1DTTPGTh->getContainer();
235 if (histoTag ==
"TM_ErrorsChamberID") {
247 int wh = dtCh.
wheel();
260 string histoType = histoTag.substr(3, histoTag.find(
'_', 3) - 3);
265 string histoName = histoTag +
"_W" + wheel.str() +
"_Sec" + sector.str() +
"_St" + station.str();
267 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask")
268 <<
"[DTLocalTriggerTask]: booking " <<
topFolder() <<
"Wheel" << wheel.str() <<
"/Sector" << sector.str()
269 <<
"/Station" << station.str() <<
"/" << folder <<
"/" << histoName << endl;
271 if (histoType.find(
"BX") != string::npos) {
272 if (histoTag.substr(0, 2) ==
"TM") {
276 rangeBX = (int)(maxBX - minBX);
279 if (folder ==
"LocalTriggerPhiIn") {
280 if (histoType ==
"BXvsQual") {
282 ibooker.
book2D(histoName,
"BX vs trigger quality", 7, -0.5, 6.5, rangeBX, minBX, maxBX);
286 if (histoType ==
"BestQual") {
288 ibooker.
book1D(histoName,
"Trigger quality of best primitives", 7, -0.5, 6.5);
292 if (histoType ==
"QualvsPhirad") {
294 ibooker.
book2D(histoName,
"Trigger quality vs local position", 100, -500., 500., 7, -0.5, 6.5);
298 if (histoType ==
"QualvsPhibend") {
300 ibooker.
book2D(histoName,
"Trigger quality vs local direction", 200, -40., 40., 7, -0.5, 6.5);
304 if (histoType ==
"Flag1stvsQual") {
306 ibooker.
book2D(histoName,
"1st/2nd trig flag vs quality", 7, -0.5, 6.5, 2, -0.5, 1.5);
310 if (histoType ==
"FlagUpDownvsQual") {
312 ibooker.
book2D(histoName,
"Up/Down trig flag vs quality", 7, -0.5, 6.5, 2, -0.5, 1.5);
317 }
else if (folder ==
"LocalTriggerTheta") {
318 if (histoType ==
"PositionvsBX") {
320 ibooker.
book2D(histoName,
"Theta trigger position vs BX", rangeBX, minBX, maxBX, 7, -0.5, 6.5);
323 if (histoType ==
"PositionvsQual") {
325 ibooker.
book2D(histoName,
"Theta trigger position vs quality", 2, 0.5, 2.5, 7, -0.5, 6.5);
329 if (histoType ==
"ThetaBXvsQual") {
331 ibooker.
book2D(histoName,
"BX vs trigger quality", 2, 0.5, 2.5, rangeBX, minBX, maxBX);
334 if (histoType ==
"ThetaBestQual") {
336 histoName,
"Trigger quality of best primitives (theta)", 2, 0.5, 2.5);
341 }
else if (folder ==
"Segment") {
342 if (histoType.find(
"TrackThetaPosvsAngle") == 0) {
343 string histoLabel =
"Position vs Angle (theta)";
344 if (histoType.find(
"andTrigH") != string::npos)
345 histoLabel +=
" for H triggers";
346 else if (histoType.find(
"andTrig") != string::npos)
347 histoLabel +=
" for triggers";
352 (
digiHistos[dtCh.
rawId()])[histoTag] = ibooker.
book2D(histoName, histoLabel, 16, -40., 40., nbins, min, max);
355 if (histoType.find(
"TrackPosvsAngle") == 0) {
360 string histoLabel =
"Position vs Angle (phi)";
361 if (histoType.find(
"andTrigHHHL") != string::npos)
362 histoLabel +=
" for HH/HL triggers";
363 else if (histoType.find(
"andTrig") != string::npos)
364 histoLabel +=
" for triggers";
366 (
digiHistos[dtCh.
rawId()])[histoTag] = ibooker.
book2D(histoName, histoLabel, 16, -40., 40., nbins, min, max);
369 if (histoType ==
"PhitkvsPhitrig") {
371 ibooker.
book2D(histoName,
"Local position: segment vs trigger", 100, -500., 500., 100, -500., 500.);
374 if (histoType ==
"PhibtkvsPhibtrig") {
376 ibooker.
book2D(histoName,
"Local direction : segment vs trigger", 200, -40., 40., 200, -40., 40.);
379 if (histoType ==
"PhiResidual") {
381 histoName,
"Trigger local position - Segment local position (correlated triggers)", 400, -10., 10.);
384 if (histoType ==
"PhibResidual") {
386 histoName,
"Trigger local direction - Segment local direction (correlated triggers)", 500, -10., 10.);
389 if (histoType ==
"HitstkvsQualtrig") {
391 ibooker.
book2D(histoName,
"Segment hits (phi) vs trigger quality", 7, -0.5, 6.5, 10, 0.5, 10.5);
402 string histoType = histoTag.substr(3, histoTag.find(
'_', 3) - 3);
406 string histoName = histoTag +
"_W" + wheel.str();
408 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerTask")
409 <<
"[DTLocalTriggerTask]: booking " <<
topFolder() <<
"Wheel" << wheel.str() <<
"/" << histoName << endl;
413 std::vector<L1MuDTChambThDigi>
const* thTrigs) {
421 for (
int i = 0;
i < 5; ++
i) {
422 for (
int j = 0;
j < 6; ++
j) {
423 for (
int k = 0;
k < 13; ++
k) {
430 vector<L1MuDTChambPhDigi>::const_iterator iph = phTrigs->begin();
431 vector<L1MuDTChambPhDigi>::const_iterator iphe = phTrigs->end();
432 for (; iph != iphe; ++iph) {
433 int phwheel = iph->whNum();
434 int phsec = iph->scNum() + 1;
435 int phst = iph->stNum();
436 int phbx = iph->bxNum();
437 int phcode = iph->code();
438 int phi1st = iph->Ts2Tag();
439 int updown = iph->UpDownTag();
447 if (phcode >
phcode_best[phwheel + 3][phst][phsec] && phcode < 7) {
449 iphbest[phwheel + 3][phst][phsec] = &(*iph);
456 uint32_t indexCh = dtChId.
rawId();
458 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
461 innerME.find(
"TM_BXvsQual" +
trigsrc)->second->Fill(phcode, phbx - phi1st);
462 innerME.find(
"TM_QualvsPhirad" +
trigsrc)->second->Fill(x, phcode);
464 innerME.find(
"TM_BXvsQual_In" +
trigsrc)
465 ->second->Fill(phcode, phbx - phi1st);
466 innerME.find(
"TM_Flag1stvsQual_In" +
trigsrc)
467 ->second->Fill(phcode, phi1st);
468 innerME.find(
"TM_FlagUpDownvsQual_In" +
trigsrc)
469 ->second->Fill(phcode, updown);
471 innerME.find(
"TM_QualvsPhirad_In" +
trigsrc)->second->Fill(x, phcode);
472 innerME.find(
"TM_QualvsPhibend_In" +
trigsrc)->second->Fill(angle, phcode);
479 vector<L1MuDTChambThDigi>::const_iterator ith = thTrigs->begin();
480 vector<L1MuDTChambThDigi>::const_iterator ithe = thTrigs->end();
481 for (; ith != ithe; ++ith) {
482 int thwheel = ith->whNum();
483 int thsec = ith->scNum() + 1;
484 int thst = ith->stNum();
485 int thbx = ith->bxNum();
487 for (
int pos = 0; pos < 7; pos++) {
488 thcode[pos] = ith->code(pos);
490 if (thcode[pos] >
thcode_best[thwheel + 3][thst][thsec]) {
491 thcode_best[thwheel + 3][thst][thsec] = thcode[pos];
492 ithbest[thwheel + 3][thst][thsec] = &(*ith);
497 uint32_t indexCh = dtChId.
rawId();
499 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
501 for (
int pos = 0; pos < 7; pos++) {
502 if (thcode[pos] > 0) {
503 innerME.find(
"TM_PositionvsBX" +
trigsrc)->second->Fill(thbx, pos);
504 innerME.find(
"TM_PositionvsQual" +
trigsrc)
505 ->second->Fill(thcode[pos], pos);
506 innerME.find(
"TM_ThetaBXvsQual" +
trigsrc)
507 ->second->Fill(thcode[pos], thbx);
515 for (
int st = 1; st < 5; ++st) {
516 for (
int wh = -2; wh < 3; ++wh) {
517 for (
int sc = 1; sc < 13; ++sc) {
520 uint32_t indexCh =
id.rawId();
521 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
523 innerME.find(
"TM_BestQual_In" +
trigsrc)
528 uint32_t indexCh =
id.rawId();
529 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
531 innerME.find(
"TM_ThetaBestQual" +
trigsrc)
544 memset(
track_ok,
false, 450 *
sizeof(
bool));
547 vector<const DTRecSegment4D*> best4DSegments;
550 for (chamberId = segments4D->id_begin(); chamberId != segments4D->id_end(); ++chamberId) {
556 for (track = range.first; track != range.second; ++track) {
557 if ((*track).hasPhi()) {
558 dof = (*track).phiSegment()->degreesOfFreedom();
563 int wheel = (*track).chamberId().wheel();
564 int sector = (*track).chamberId().sector();
565 int station = (*track).chamberId().station();
568 }
else if (sector == 14) {
576 best4DSegments.push_back(tmpBest);
579 vector<const DTRecSegment4D*>::const_iterator btrack;
581 for (btrack = best4DSegments.begin(); btrack != best4DSegments.end(); ++btrack) {
582 if ((*btrack)->hasPhi()) {
584 int wheel = (*btrack)->chamberId().wheel();
585 int station = (*btrack)->chamberId().station();
586 int sector = (*btrack)->chamberId().sector();
588 float x_track, y_track, x_angle, y_angle;
590 int nHitsPhi = (*btrack)->phiSegment()->degreesOfFreedom() + 2;
593 uint32_t indexCh = dtChId.
rawId();
594 map<string, MonitorElement*>& innerMECh =
digiHistos[indexCh];
598 indexCh = dtChIdSC.
rawId();
599 map<string, MonitorElement*>& innerME =
digiHistos[indexCh];
602 innerME.find(
"TM_HitstkvsQualtrig" +
trigsrc)->second->Fill(
phcode_best[wheel + 3][station][scsector], nHitsPhi);
604 if (
phcode_best[wheel + 3][station][scsector] > 3 && nHitsPhi >= 7) {
609 innerMECh.find(
"TM_PhitkvsPhitrig" +
trigsrc)->second->Fill(x_trigger, x_track);
610 innerMECh.find(
"TM_PhibtkvsPhibtrig" +
trigsrc)->second->Fill(angle_trigger, x_angle);
611 innerMECh.find(
"TM_PhiResidual" +
trigsrc)->second->Fill(x_trigger - x_track);
612 innerMECh.find(
"TM_PhibResidual" +
trigsrc)->second->Fill(angle_trigger - x_angle);
618 bool trigFlagTM =
false;
619 for (
int ist = 1; ist < 5; ist++) {
620 if (ist != station &&
phcode_best[wheel + 3][ist][scsector] >= 2 &&
627 if (trigFlagTM && fabs(x_angle) < 40. && nHitsPhi >= 7) {
629 innerME.find(
"TM_TrackPosvsAngle" +
trigsrc)->second->Fill(x_angle, x_track);
631 innerME.find(
"TM_TrackPosvsAngleandTrig" +
trigsrc)->second->Fill(x_angle, x_track);
632 if (
phcode_best[wheel + 3][station][scsector] > 4) {
633 innerME.find(
"TM_TrackPosvsAngleandTrigHHHL" +
trigsrc)->second->Fill(x_angle, x_track);
638 if ((*btrack)->hasZed() && trigFlagTM && fabs(y_angle) < 40. &&
639 (*btrack)->zSegment()->degreesOfFreedom() >= 1) {
641 innerME.find(
"TM_TrackThetaPosvsAngle" +
trigsrc)->second->Fill(y_angle, y_track);
642 if (
thcode_best[wheel + 3][station][scsector] > 0) {
643 innerME.find(
"TM_TrackThetaPosvsAngleandTrig" +
trigsrc)->second->Fill(y_angle, y_track);
644 if (
thcode_best[wheel + 3][station][scsector] == 2) {
645 innerME.find(
"TM_TrackThetaPosvsAngleandTrigH" +
trigsrc)->second->Fill(y_angle, y_track);
659 TAxis* axis =
nullptr;
661 axis = histo->GetXaxis();
662 }
else if (iaxis == 2) {
663 axis = histo->GetYaxis();
668 string labels[7] = {
"LI",
"LO",
"HI",
"HO",
"LL",
"HL",
"HH"};
669 int istart = axis->GetXmin() < -1 ? 2 : 1;
670 for (
int i = 0;
i < 7;
i++) {
671 axis->SetBinLabel(
i + istart, labels[
i].c_str());
680 TAxis* axis =
nullptr;
682 axis = histo->GetXaxis();
683 }
else if (iaxis == 2) {
684 axis = histo->GetYaxis();
689 string labels[2] = {
"L",
"H"};
690 int istart = axis->GetXmin() < -1 ? 2 : 1;
691 for (
int i = 0;
i < 2;
i++) {
692 axis->SetBinLabel(
i + istart, labels[
i].c_str());
701 for (std::vector<LTCDigi>::const_iterator ltc_it = ltcdigis->begin(); ltc_it != ltcdigis->end(); ltc_it++) {
702 size_t otherTriggerSum = 0;
703 for (
size_t i = 1;
i < 6;
i++) {
704 otherTriggerSum += size_t((*ltc_it).HasTriggered(
i));
706 if ((*ltc_it).HasTriggered(0) && otherTriggerSum == 0)
708 else if (!(*ltc_it).HasTriggered(0))
710 else if ((*ltc_it).HasTriggered(0) && otherTriggerSum > 0)
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
const int wheelArrayShift
const edm::EventSetup & c
std::pair< const_iterator, const_iterator > range
iterator range
void thetaRange(const DTChamberId &id, float &min, float &max, int &nbins, float step=15)
Compute theta range in local chamber coordinates.
uint16_t *__restrict__ id
virtual void setCurrentFolder(std::string const &fullpath)
void runTMAnalysis(std::vector< L1MuDTChambPhDigi > const *phTrigs, std::vector< L1MuDTChambThDigi > const *thTrigs)
Run analysis on TM data.
edm::EDGetTokenT< LTCDigiCollection > ltcDigiCollectionToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Beginrun.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Book the histograms.
float trigDir(const L1MuDTChambPhDigi *trig)
Return local direction (trigger RF) for a given trigger primitive.
constexpr uint32_t rawId() const
get the raw id
void setQLabelsTheta(MonitorElement *me, short int iaxis)
MonitorElement * tm_IDDataErrorPlot
void runSegmentAnalysis(edm::Handle< DTRecSegment4DCollection > &segments4D)
Run analysis using DT 4D segments.
const uint16_t range(const Frame &aFrame)
bool getData(T &iHolder) const
C::const_iterator const_iterator
constant access iterator type
edm::EDGetTokenT< DTRecSegment4DCollection > seg_Token_
edm::EDGetTokenT< L1MuDTChambPhContainer > tm_Token_
const DTGeometry * muonGeom
void trigToSeg(int st, float &x, float dir)
Compute Trigger x coordinate in chamber RF.
edm::EDGetTokenT< L1MuDTChambThContainer > tmTh_Token_
DTLocalTriggerTask(const edm::ParameterSet &ps)
Constructor.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
edm::EDGetTokenT< DTLocalTriggerCollection > ros_Token_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
void phiRange(const DTChamberId &id, float &min, float &max, int &nbins, float step=15)
Compute phi range in local chamber coordinates.
void bookHistos(DQMStore::IBooker &, const DTChamberId &dtCh, std::string folder, std::string histoTag)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
T getParameter(std::string const &) const
LuminosityBlockNumber_t luminosityBlock() const
void setQLabels(MonitorElement *me, short int iaxis)
Set Quality labels.
edm::ParameterSet parameters
DTTrigGeomUtils * trigGeomUtils
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
To reset the MEs.
void bookWheelHistos(DQMStore::IBooker &, int wh, std::string histoTag)
Book the histograms.
void triggerSource(const edm::Event &e)
Get the L1A source.
float trigPos(const L1MuDTChambPhDigi *trig)
Return local position (trigger RF) for a given trigger primitive.
int station() const
Return the station number.
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
int wheel() const
Return the wheel number.
std::string & topFolder()
Get the Top folder (different between Physics and TP and TM)
void bookBarrelHistos(DQMStore::IBooker &, std::string histoTag)
Book the histograms.
std::map< uint32_t, std::map< std::string, MonitorElement * > > digiHistos
~DTLocalTriggerTask() override
Destructor.
void computeSCCoordinates(const DTRecSegment4D *track, int &scsec, float &x, float &xdir, float &y, float &ydir)
Compute track coordinates with SC sector numbering.
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)