27 : m_muon(
muon), m_regMu(regMu) {
113 m_resTypes({kResPt, kResQOverPt, kResPhi, kResEta}),
114 m_etaRegions({kEtaRegionAll, kEtaRegionBmtf, kEtaRegionOmtf, kEtaRegionEmtf}),
115 m_qualLevelsRes({kQualAll}),
116 m_effStrings({{kEffPt,
"pt"}, {kEffPhi,
"phi"}, {kEffEta,
"eta"}, {kEffVtx,
"vtx"}}),
117 m_effLabelStrings({{kEffPt,
"p_{T} (GeV)"}, {kEffPhi,
"#phi"}, {kEffEta,
"#eta"}, {kEffVtx,
"# vertices"}}),
118 m_resStrings({{kResPt,
"pt"},
119 {kRes1OverPt,
"1overpt"},
120 {kResQOverPt,
"qoverpt"},
123 {kResCh,
"charge"}}),
124 m_resLabelStrings({{kResPt,
"(p_{T}^{L1} - p_{T}^{reco})/p_{T}^{reco}"},
125 {kRes1OverPt,
"(p_{T}^{reco} - p_{T}^{L1})/p_{T}^{L1}"},
126 {kResQOverPt,
"(q^{L1}*q^{reco}*p_{T}^{reco} - p_{T}^{L1})/p_{T}^{L1}"},
127 {kResPhi,
"#phi_{L1} - #phi_{reco}"},
128 {kResEta,
"#eta_{L1} - #eta_{reco}"},
129 {kResCh,
"charge^{L1} - charge^{reco}"}}),
130 m_etaStrings({{kEtaRegionAll,
"etaMin0_etaMax2p4"},
131 {kEtaRegionBmtf,
"etaMin0_etaMax0p83"},
132 {kEtaRegionOmtf,
"etaMin0p83_etaMax1p24"},
133 {kEtaRegionEmtf,
"etaMin1p24_etaMax2p4"}}),
135 {{kQualAll,
"qualAll"}, {kQualOpen,
"qualOpen"}, {kQualDouble,
"qualDouble"}, {kQualSingle,
"qualSingle"}}),
136 m_verbose(ps.getUntrackedParameter<
bool>(
"verbose")),
137 m_HistFolder(ps.getUntrackedParameter<
string>(
"histFolder")),
138 m_TagPtCut(ps.getUntrackedParameter<
double>(
"tagPtCut")),
139 m_recoToL1PtCutFactor(ps.getUntrackedParameter<
double>(
"recoToL1PtCutFactor")),
140 m_cutsVPSet(ps.getUntrackedParameter<std::vector<edm::ParameterSet>>(
"cuts")),
141 m_MuonInputTag(consumes<reco::MuonCollection>(ps.getUntrackedParameter<
InputTag>(
"muonInputTag"))),
142 m_GmtInputTag(consumes<l1t::MuonBxCollection>(ps.getUntrackedParameter<
InputTag>(
"gmtInputTag"))),
143 m_VtxInputTag(consumes<VertexCollection>(ps.getUntrackedParameter<
InputTag>(
"vtxInputTag"))),
144 m_BsInputTag(consumes<BeamSpot>(ps.getUntrackedParameter<
InputTag>(
"bsInputTag"))),
145 m_trigInputTag(consumes<trigger::TriggerEvent>(ps.getUntrackedParameter<
InputTag>(
"trigInputTag"))),
146 m_trigProcess(ps.getUntrackedParameter<
string>(
"trigProcess")),
147 m_trigProcess_token(consumes<edm::TriggerResults>(ps.getUntrackedParameter<
InputTag>(
"trigProcess_token"))),
148 m_trigNames(ps.getUntrackedParameter<vector<string>>(
"triggerNames")),
149 m_effVsPtBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPtBins")),
150 m_effVsPhiBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPhiBins")),
151 m_effVsEtaBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsEtaBins")),
152 m_effVsVtxBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsVtxBins")),
153 m_useAtVtxCoord(ps.getUntrackedParameter<
bool>(
"useL1AtVtxCoord")),
155 m_minTagProbeDR(0.5),
156 m_maxHltMuonDR(0.1) {
158 cout <<
"[L1TMuonDQMOffline:] ____________ Storage initialization ____________ " << endl;
160 for (
const auto& cutsPSet : m_cutsVPSet) {
161 const auto qCut = cutsPSet.getUntrackedParameter<
int>(
"qualCut");
162 QualLevel qLevel = kQualAll;
164 qLevel = kQualSingle;
165 }
else if (qCut > 7) {
166 qLevel = kQualDouble;
167 }
else if (qCut > 3) {
170 m_cuts.emplace_back(std::make_pair(cutsPSet.getUntrackedParameter<
int>(
"ptCut"), qLevel));
179 cout <<
"[L1TMuonDQMOffline:] Called beginRun." << endl;
192 vector<string>::const_iterator trigNamesIt =
m_trigNames.begin();
193 vector<string>::const_iterator trigNamesEnd =
m_trigNames.end();
195 for (; trigNamesIt != trigNamesEnd; ++trigNamesIt) {
196 TString tNameTmp = TString(*trigNamesIt);
197 TRegexp tNamePattern = TRegexp(tNameTmp,
true);
202 if (tmpName.Contains(tNamePattern)) {
208 cout <<
"[L1TMuonDQMOffline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
236 cout <<
"[L1TMuonDQMOffline:] Computing efficiencies" << endl;
238 vector<MuonGmtPair>::const_iterator muonGmtPairsIt =
m_MuonGmtPairs.begin();
239 vector<MuonGmtPair>::const_iterator muonGmtPairsEnd =
m_MuonGmtPairs.end();
245 for (; muonGmtPairsIt != muonGmtPairsEnd; ++muonGmtPairsIt) {
247 if ((muonGmtPairsIt->etaRegion() !=
kEtaRegionOut) && (muonGmtPairsIt->gmtPt() > 0)) {
248 regsToFill[1] = muonGmtPairsIt->etaRegion();
251 const auto varToFill = muonGmtPairsIt->getDeltaVar(
var);
252 std::get<0>(histoKeyRes) =
var;
254 for (
const auto regToFill : regsToFill) {
255 std::get<1>(histoKeyRes) = regToFill;
260 if (muonGmtPairsIt->gmtQual() >=
qualCut) {
261 std::get<2>(histoKeyRes) = qualLevel;
271 unsigned int cutsCounter = 0;
273 const auto gmtPtCut =
cut.first;
274 const auto qualLevel =
cut.second;
275 const bool gmtAboveCut = (muonGmtPairsIt->gmtPt() > gmtPtCut);
281 regsToFill[1] = muonGmtPairsIt->etaRegion();
289 varToFill = static_cast<double>(
nVtx);
291 varToFill = muonGmtPairsIt->getVar(
var);
297 std::get<0>(histoKeyEffDenVar) =
var;
299 for (
const auto regToFill : regsToFill) {
301 if (cutsCounter == 0) {
305 std::get<2>(histoKeyEffDenVar) = regToFill;
311 std::get<0>(histoKeyEffNumVar) =
var;
313 if (gmtAboveCut && muonGmtPairsIt->gmtQual() >= qualLevel * 4) {
318 std::get<3>(histoKeyEffNumVar) = qualLevel;
320 for (
const auto regToFill : regsToFill) {
321 std::get<2>(histoKeyEffNumVar) = regToFill;
333 cout <<
"[L1TMuonDQMOffline:] Computation finished" << endl;
339 cout <<
"[L1TMuonDQMOffline:] Booking Control Plot Histos" << endl;
345 ibooker.
book2D(
"NTightVsAll",
"NTightVsAll; # muons; # tight muons", 20, -0.5, 19.5, 16, -0.5, 15.5);
347 ibooker.
book2D(
"NProbesVsTight",
"NProbesVsTight; # tight muons; # probe muons", 8, -0.5, 7.5, 8, -0.5, 7.5);
358 ibooker.
book1D(
"TagMuonProbeMuonDeltaR",
"TagMuonProbeMuonDeltaR; #DeltaR", 50, 0., 5.0);
371 const auto gmtPtCut =
cut.first;
372 const auto qualLevel =
cut.second;
390 const int gmtPtCut =
cut.first;
399 const auto gmtPtCut =
cut.first;
400 const auto qualLevel =
cut.second;
414 cout <<
"[L1TMuonOffline:] Booking Resolution Plot Histos" << endl;
434 unsigned int nVtx = 0;
437 for (
const auto& vertexIt : *
vertex) {
438 if (vertexIt.isValid() && !vertexIt.isFake()) {
451 bool hasPrimaryVertex =
false;
454 vector<Vertex>::const_iterator vertexIt =
vertex->begin();
455 vector<Vertex>::const_iterator vertexEnd =
vertex->end();
457 for (; vertexIt != vertexEnd; ++vertexIt) {
458 if (vertexIt->isValid() && !vertexIt->isFake()) {
459 posVtx = vertexIt->position();
460 errVtx = vertexIt->error();
461 hasPrimaryVertex =
true;
467 if (!hasPrimaryVertex) {
469 errVtx(0, 0) =
beamSpot->BeamWidthX();
470 errVtx(1, 1) =
beamSpot->BeamWidthY();
480 cout <<
"[L1TMuonDQMOffline:] Getting tight muons" << endl;
482 MuonCollection::const_iterator muonIt =
muons->begin();
483 MuonCollection::const_iterator muonEnd =
muons->end();
485 for (; muonIt != muonEnd; ++muonIt) {
497 cout <<
"[L1TMuonDQMOffline:] getting probe muons" << endl;
499 std::vector<const reco::Muon*> tagMuonsInHist;
501 tagMuonsInHist.clear();
503 vector<const reco::Muon*>::const_iterator probeCandIt =
m_TightMuons.begin();
504 vector<const reco::Muon*>::const_iterator tightMuonsEnd =
m_TightMuons.end();
506 for (; probeCandIt != tightMuonsEnd; ++probeCandIt) {
507 bool isProbe =
false;
508 vector<const reco::Muon*>::const_iterator tagCandIt =
m_TightMuons.begin();
511 for (; tagCandIt != tightMuonsEnd; ++tagCandIt) {
512 bool tagMuonAlreadyInHist =
false;
513 bool tagHasTrig =
false;
514 float eta = (*tagCandIt)->eta();
515 float phi = (*tagCandIt)->phi();
516 float pt = (*tagCandIt)->pt();
517 float dEta =
eta - (*probeCandIt)->eta();
518 float dPhi =
phi - (*probeCandIt)->phi();
525 isProbe |= tagHasTrig;
528 for (vector<const reco::Muon*>::const_iterator tagMuonsInHistIt = tagMuonsInHist.begin();
529 tagMuonsInHistIt != tagMuonsInHist.end();
530 ++tagMuonsInHistIt) {
531 if ((*tagCandIt) == (*tagMuonsInHistIt)) {
532 tagMuonAlreadyInHist =
true;
536 if (tagMuonAlreadyInHist ==
false)
537 tagMuonsInHist.push_back((*tagCandIt));
539 if (tagMuonAlreadyInHist ==
false) {
558 cout <<
"[L1TMuonDQMOffline:] Getting muon GMT pairs" << endl;
560 vector<const reco::Muon*>::const_iterator probeMuIt =
m_ProbeMuons.begin();
561 vector<const reco::Muon*>::const_iterator probeMuEnd =
m_ProbeMuons.end();
566 for (; probeMuIt != probeMuEnd; ++probeMuIt) {
574 gmtIt = gmtCands->
begin(0);
576 for (; gmtIt != gmtEnd; ++gmtIt) {
580 pairBestCand = pairTmpCand;
590 double matchDeltaR = 9999;
594 vector<int>::const_iterator trigIndexIt =
m_trigIndices.begin();
595 vector<int>::const_iterator trigIndexEnd =
m_trigIndices.end();
597 for (; trigIndexIt != trigIndexEnd; ++trigIndexIt) {
602 if (hltFilterIndex < triggerEvent->sizeFilters()) {
605 const unsigned nTriggers = triggerVids.size();
606 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
608 double dRtmp =
deltaR((*
mu), trigObject);
609 if (dRtmp < matchDeltaR)
639 return {50, -2., 2.};
641 return {50, -2., 2.};
643 return {50, -2., 2.};
645 return {96, -0.2, 0.2};
647 return {100, -0.1, 0.1};