From 6007101c9711971fcc147b16b7924e219aa61185 Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 1 Sep 2022 10:34:23 +0200 Subject: [PATCH 1/5] Simplify L1TPhase2MuonOffline --- .../interface/L1TPhase2MuonOffline.h | 38 +++++-------------- .../L1Trigger/src/L1TPhase2MuonOffline.cc | 15 ++++---- 2 files changed, 17 insertions(+), 36 deletions(-) diff --git a/DQMOffline/L1Trigger/interface/L1TPhase2MuonOffline.h b/DQMOffline/L1Trigger/interface/L1TPhase2MuonOffline.h index f93b2bf368c52..bbd80e78ed884 100644 --- a/DQMOffline/L1Trigger/interface/L1TPhase2MuonOffline.h +++ b/DQMOffline/L1Trigger/interface/L1TPhase2MuonOffline.h @@ -11,23 +11,17 @@ // DataFormats #include "DataFormats/L1Trigger/interface/Muon.h" #include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" -#include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" -#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/HepMCCandidate/interface/GenParticle.h" #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h" #include "DataFormats/L1Trigger/interface/L1MuonParticle.h" -#include "DataFormats/Math/interface/deltaR.h" #include "DataFormats/Math/interface/deltaPhi.h" // FWCore #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/LuminosityBlock.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -35,20 +29,6 @@ #include "DQMServices/Core/interface/DQMStore.h" #include "DQMServices/Core/interface/DQMEDAnalyzer.h" -// HLTrigger -#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h" - -// Common tools -#include "TrackingTools/TransientTrack/interface/TransientTrack.h" -#include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h" -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/PatternTools/interface/Trajectory.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" -#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" -#include "TrackingTools/Records/interface/TrackingComponentsRecord.h" -#include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h" - #include #include "TRegexp.h" #include @@ -63,7 +43,7 @@ class GenMuonGMTPair; class L1TPhase2MuonOffline : public DQMEDAnalyzer { public: L1TPhase2MuonOffline(const edm::ParameterSet& ps); - ~L1TPhase2MuonOffline() override; + ~L1TPhase2MuonOffline() override = default; enum MuType { kSAMuon, kTkMuon, kNMuTypes }; enum VarType { kPt, kEta, kPhi, kIso, kQual, kZ0, kD0, kNVarTypes }; @@ -105,13 +85,13 @@ class L1TPhase2MuonOffline : public DQMEDAnalyzer { const std::vector muonTypes_; const std::vector effTypes_; const std::vector resTypes_; - const std::vector varTypes_; + // const std::vector varTypes_; const std::vector etaRegions_; const std::vector qualLevels_; // maps with histogram name bits - std::map effNames_; - std::map effLabels_; + // std::map effNames_; + // std::map effLabels_; std::map resNames_; std::map resLabels_; std::map etaNames_; @@ -143,11 +123,11 @@ class L1TPhase2MuonOffline : public DQMEDAnalyzer { std::vector gmtTkMuonPairs_; std::vector> cuts_; - float lsb_pt = Phase2L1GMT::LSBpt; - float lsb_phi = Phase2L1GMT::LSBphi; - float lsb_eta = Phase2L1GMT::LSBeta; - float lsb_z0 = Phase2L1GMT::LSBSAz0; - float lsb_d0 = Phase2L1GMT::LSBSAd0; + const float lsb_pt = Phase2L1GMT::LSBpt; + const float lsb_phi = Phase2L1GMT::LSBphi; + const float lsb_eta = Phase2L1GMT::LSBeta; + const float lsb_z0 = Phase2L1GMT::LSBSAz0; + const float lsb_d0 = Phase2L1GMT::LSBSAd0; }; // diff --git a/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc b/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc index bf27404c4c747..8e1269d25dacb 100644 --- a/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc +++ b/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc @@ -11,7 +11,6 @@ #include "DataFormats/L1TMuonPhase2/interface/Constants.h" using namespace reco; -using namespace trigger; using namespace edm; using namespace std; using namespace l1t; @@ -47,9 +46,11 @@ GenMuonGMTPair::GenMuonGMTPair(const GenMuonGMTPair& muonGmtPair) { } float GenMuonGMTPair::dR() { - float dEta = gmtmu_ ? (gmtEta_ - muEta_) : 999.; - float dPhi = gmtmu_ ? reco::deltaPhi(gmtPhi_, muPhi_) : 999.; - return sqrt(dEta * dEta + dPhi * dPhi); + if (!gmtmu_) + return 9999.; + float dEta = gmtEta_ - muEta_; + float dPhi = reco::deltaPhi(gmtPhi_, muPhi_); + return std::sqrt(dEta * dEta + dPhi * dPhi); } L1TPhase2MuonOffline::EtaRegion GenMuonGMTPair::etaRegion() const { @@ -140,8 +141,6 @@ L1TPhase2MuonOffline::L1TPhase2MuonOffline(const ParameterSet& ps) } } -//_____________________________________________________________________ -L1TPhase2MuonOffline::~L1TPhase2MuonOffline() {} //---------------------------------------------------------------------- void L1TPhase2MuonOffline::dqmBeginRun(const edm::Run& run, const edm::EventSetup& iSetup) { edm::LogInfo("L1TPhase2MuonOFfline") << "L1TPhase2MuonOffline::dqmBeginRun" << endl; @@ -176,6 +175,9 @@ void L1TPhase2MuonOffline::analyze(const Event& iEvent, const EventSetup& eventS } edm::LogInfo("L1TPhase2MuonOffline") << "L1TPhase2MuonOffline::analyze() N of genmus: " << genmus.size() << endl; + if (genmus.empty()) + return; + // Collect both muon collection: iEvent.getByToken(gmtMuonToken_, gmtSAMuon_); iEvent.getByToken(gmtTkMuonToken_, gmtTkMuon_); @@ -291,7 +293,6 @@ void L1TPhase2MuonOffline::fillEfficiencyHistos() { efficiencyDen_[kSAMuon][eta][q][var]->Fill(varToFill); if (muIt.gmtPt() < 0) continue; // gmt muon does not exits - if (muIt.gmtQual() < q * 4) continue; //quality requirements if (var != kEffPt && muIt.gmtPt() < gmtPtCut) From 6cc53e1a005ce77d9a8b104362b94cb192265a4e Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 1 Sep 2022 10:56:11 +0200 Subject: [PATCH 2/5] Fill control histos even if there are no gen muons --- DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc b/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc index 8e1269d25dacb..de02a93863ec6 100644 --- a/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc +++ b/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc @@ -175,9 +175,6 @@ void L1TPhase2MuonOffline::analyze(const Event& iEvent, const EventSetup& eventS } edm::LogInfo("L1TPhase2MuonOffline") << "L1TPhase2MuonOffline::analyze() N of genmus: " << genmus.size() << endl; - if (genmus.empty()) - return; - // Collect both muon collection: iEvent.getByToken(gmtMuonToken_, gmtSAMuon_); iEvent.getByToken(gmtTkMuonToken_, gmtTkMuon_); @@ -187,6 +184,8 @@ void L1TPhase2MuonOffline::analyze(const Event& iEvent, const EventSetup& eventS fillControlHistos(); // Match each muon to a gen muon, if possible. + if (genmus.empty()) + return; edm::LogInfo("L1TPhase2MuonOffline") << "L1TPhase2MuonOffline::analyze() calling matchMuonsToGen() " << endl; matchMuonsToGen(genmus); @@ -210,6 +209,7 @@ void L1TPhase2MuonOffline::bookControlHistos(DQMStore::IBooker& ibooker, MuType controlHistos_[mutype][kZ0] = ibooker.book1D(muonNames_[mutype] + "Z0", "MuonZ0; Z_{0}", 50, 0, 50.0); controlHistos_[mutype][kD0] = ibooker.book1D(muonNames_[mutype] + "D0", "MuonD0; D_{0}", 50, 0, 200.); } + void L1TPhase2MuonOffline::bookEfficiencyHistos(DQMStore::IBooker& ibooker, MuType mutype) { edm::LogInfo("L1TPhase2MuonOffline") << "L1TPhase2MuonOffline::bookEfficiencyHistos()" << endl; @@ -240,6 +240,7 @@ void L1TPhase2MuonOffline::bookEfficiencyHistos(DQMStore::IBooker& ibooker, MuTy } } } + void L1TPhase2MuonOffline::bookResolutionHistos(DQMStore::IBooker& ibooker, MuType mutype) { edm::LogInfo("L1TPhase2MuonOffline") << "L1TPhase2MuonOffline::bookResolutionHistos()" << endl; @@ -281,6 +282,7 @@ void L1TPhase2MuonOffline::fillControlHistos() { controlHistos_[kTkMuon][kD0]->Fill(lsb_d0 * muIt.hwD0()); } } + void L1TPhase2MuonOffline::fillEfficiencyHistos() { for (const auto& muIt : gmtSAMuonPairs_) { auto eta = muIt.etaRegion(); @@ -315,7 +317,6 @@ void L1TPhase2MuonOffline::fillEfficiencyHistos() { efficiencyDen_[kTkMuon][eta][q][var]->Fill(varToFill); if (muIt.gmtPt() < 0) continue; // gmt muon does not exits - if (muIt.gmtQual() < q * 4) continue; //quality requirements if (var != kEffPt && muIt.gmtPt() < gmtPtCut) @@ -326,6 +327,7 @@ void L1TPhase2MuonOffline::fillEfficiencyHistos() { } } } + void L1TPhase2MuonOffline::fillResolutionHistos() { for (const auto& muIt : gmtSAMuonPairs_) { if (muIt.gmtPt() < 0) @@ -359,6 +361,7 @@ void L1TPhase2MuonOffline::fillResolutionHistos() { } } } + //_____________________________________________________________________ void L1TPhase2MuonOffline::matchMuonsToGen(std::vector genmus) { gmtSAMuonPairs_.clear(); From 1ce48c81cfbc620216b8d7a0ac726a53821af8dd Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 1 Sep 2022 16:37:16 +0200 Subject: [PATCH 3/5] A fix for L1TPhase2MuonOffline::matchMuonsToGen --- .../interface/L1TPhase2MuonOffline.h | 2 +- .../L1Trigger/src/L1TPhase2MuonOffline.cc | 26 ++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/DQMOffline/L1Trigger/interface/L1TPhase2MuonOffline.h b/DQMOffline/L1Trigger/interface/L1TPhase2MuonOffline.h index bbd80e78ed884..36b0f128ea118 100644 --- a/DQMOffline/L1Trigger/interface/L1TPhase2MuonOffline.h +++ b/DQMOffline/L1Trigger/interface/L1TPhase2MuonOffline.h @@ -139,7 +139,7 @@ class GenMuonGMTPair { GenMuonGMTPair(const GenMuonGMTPair& muongmtPair); ~GenMuonGMTPair(){}; - float dR(); + float dR2(); float pt() const { return mu_->pt(); }; float eta() const { return mu_->eta(); }; float phi() const { return mu_->phi(); }; diff --git a/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc b/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc index de02a93863ec6..d586628757fa1 100644 --- a/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc +++ b/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc @@ -45,12 +45,12 @@ GenMuonGMTPair::GenMuonGMTPair(const GenMuonGMTPair& muonGmtPair) { muPhi_ = muonGmtPair.muPhi_; } -float GenMuonGMTPair::dR() { +float GenMuonGMTPair::dR2() { if (!gmtmu_) - return 9999.; + return 999.; float dEta = gmtEta_ - muEta_; float dPhi = reco::deltaPhi(gmtPhi_, muPhi_); - return std::sqrt(dEta * dEta + dPhi * dPhi); + return dEta * dEta + dPhi * dPhi; } L1TPhase2MuonOffline::EtaRegion GenMuonGMTPair::etaRegion() const { @@ -372,22 +372,34 @@ void L1TPhase2MuonOffline::matchMuonsToGen(std::vector for (const reco::GenParticle* gen : genmus) { edm::LogInfo("L1TPhase2MuonOffline") << "Looping on genmus: " << gen << endl; GenMuonGMTPair pairBestCand(&(*gen), nullptr); + float dr2Best = maxGmtMuonDR_ * maxGmtMuonDR_; + bool matchFound = false; for (auto& muIt : *gmtSAMuon_) { GenMuonGMTPair pairTmpCand(&(*gen), &(muIt)); - if ((pairTmpCand.dR() < maxGmtMuonDR_) && (pairTmpCand.dR() < pairBestCand.dR())) { + float dr2Tmp = pairTmpCand.dR2(); + if (dr2Tmp < dr2Best) { + dr2Best = dr2Tmp; pairBestCand = pairTmpCand; + matchFound = true; } } - gmtSAMuonPairs_.emplace_back(pairBestCand); + if (matchFound) + gmtSAMuonPairs_.emplace_back(pairBestCand); GenMuonGMTPair pairBestCand2(&(*gen), nullptr); + dr2Best = maxGmtMuonDR_ * maxGmtMuonDR_; + matchFound = false; for (auto& tkmuIt : *gmtTkMuon_) { GenMuonGMTPair pairTmpCand(&(*gen), &(tkmuIt)); - if ((pairTmpCand.dR() < maxGmtMuonDR_) && (pairTmpCand.dR() < pairBestCand2.dR())) { + float dr2Tmp = pairTmpCand.dR2(); + if (dr2Tmp < dr2Best) { + dr2Best = dr2Tmp; pairBestCand2 = pairTmpCand; + matchFound = true; } } - gmtTkMuonPairs_.emplace_back(pairBestCand2); + if (matchFound) + gmtTkMuonPairs_.emplace_back(pairBestCand2); } edm::LogInfo("L1TPhase2MuonOffline") << "L1TPhase2MuonOffline::matchMuonsToGen() gmtSAMuons: " << gmtSAMuonPairs_.size() << endl; From 28146c18cf1a1fdb8d734ce0481c35b475c512ad Mon Sep 17 00:00:00 2001 From: Andrea Date: Sat, 3 Sep 2022 10:35:37 +0200 Subject: [PATCH 4/5] revert the requirement of having an associated L1T muon --- .../L1Trigger/src/L1TPhase2MuonOffline.cc | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc b/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc index d586628757fa1..e7fd0b7faee0c 100644 --- a/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc +++ b/DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc @@ -289,17 +289,15 @@ void L1TPhase2MuonOffline::fillEfficiencyHistos() { for (const auto var : effTypes_) { auto varToFill = muIt.getVar(var); for (const auto& cut : cuts_) { - const auto gmtPtCut = cut.first; const auto q = cut.second; - efficiencyDen_[kSAMuon][eta][q][var]->Fill(varToFill); if (muIt.gmtPt() < 0) - continue; // gmt muon does not exits + continue; // there is not an assciated gmt muon if (muIt.gmtQual() < q * 4) continue; //quality requirements + const auto gmtPtCut = cut.first; if (var != kEffPt && muIt.gmtPt() < gmtPtCut) continue; // pt requirement - efficiencyNum_[kSAMuon][eta][q][var]->Fill(varToFill); } } @@ -311,17 +309,15 @@ void L1TPhase2MuonOffline::fillEfficiencyHistos() { for (const auto var : effTypes_) { auto varToFill = muIt.getVar(var); for (const auto& cut : cuts_) { - const auto gmtPtCut = cut.first; const auto q = cut.second; - efficiencyDen_[kTkMuon][eta][q][var]->Fill(varToFill); if (muIt.gmtPt() < 0) - continue; // gmt muon does not exits + continue; // there is not an assciated gmt muon if (muIt.gmtQual() < q * 4) continue; //quality requirements + const auto gmtPtCut = cut.first; if (var != kEffPt && muIt.gmtPt() < gmtPtCut) continue; // pt requirement - efficiencyNum_[kTkMuon][eta][q][var]->Fill(varToFill); } } @@ -373,33 +369,27 @@ void L1TPhase2MuonOffline::matchMuonsToGen(std::vector edm::LogInfo("L1TPhase2MuonOffline") << "Looping on genmus: " << gen << endl; GenMuonGMTPair pairBestCand(&(*gen), nullptr); float dr2Best = maxGmtMuonDR_ * maxGmtMuonDR_; - bool matchFound = false; for (auto& muIt : *gmtSAMuon_) { GenMuonGMTPair pairTmpCand(&(*gen), &(muIt)); float dr2Tmp = pairTmpCand.dR2(); if (dr2Tmp < dr2Best) { dr2Best = dr2Tmp; pairBestCand = pairTmpCand; - matchFound = true; } } - if (matchFound) - gmtSAMuonPairs_.emplace_back(pairBestCand); + gmtSAMuonPairs_.emplace_back(pairBestCand); GenMuonGMTPair pairBestCand2(&(*gen), nullptr); dr2Best = maxGmtMuonDR_ * maxGmtMuonDR_; - matchFound = false; for (auto& tkmuIt : *gmtTkMuon_) { GenMuonGMTPair pairTmpCand(&(*gen), &(tkmuIt)); float dr2Tmp = pairTmpCand.dR2(); if (dr2Tmp < dr2Best) { dr2Best = dr2Tmp; pairBestCand2 = pairTmpCand; - matchFound = true; } } - if (matchFound) - gmtTkMuonPairs_.emplace_back(pairBestCand2); + gmtTkMuonPairs_.emplace_back(pairBestCand2); } edm::LogInfo("L1TPhase2MuonOffline") << "L1TPhase2MuonOffline::matchMuonsToGen() gmtSAMuons: " << gmtSAMuonPairs_.size() << endl; From 1a084d946878d11e6fcc85687c63aa1bd6c3b2a3 Mon Sep 17 00:00:00 2001 From: ccaillol Date: Wed, 31 Aug 2022 10:54:44 +0200 Subject: [PATCH 5/5] L1T DQM bug fix --- DQMOffline/L1Trigger/src/L1TRate_Offline.cc | 12 ++++++------ .../L1Trigger/src/L1TStage2CaloLayer2Offline.cc | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/DQMOffline/L1Trigger/src/L1TRate_Offline.cc b/DQMOffline/L1Trigger/src/L1TRate_Offline.cc index 5e0bf1a9a0202..ab7b8781483d9 100644 --- a/DQMOffline/L1Trigger/src/L1TRate_Offline.cc +++ b/DQMOffline/L1Trigger/src/L1TRate_Offline.cc @@ -505,14 +505,14 @@ bool L1TRate_Offline::getXSexFitsPython(const edm::ParameterSet& ps) { foundFit = true; break; } + } - if (!foundFit) { - noError = false; + if (!foundFit) { + noError = false; - int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_PY_MISSING_FIT); - eCount++; - m_ErrorMonitor->getTH1()->SetBinContent(WARNING_PY_MISSING_FIT, eCount); - } + int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_PY_MISSING_FIT); + eCount++; + m_ErrorMonitor->getTH1()->SetBinContent(WARNING_PY_MISSING_FIT, eCount); } } } diff --git a/DQMOffline/L1Trigger/src/L1TStage2CaloLayer2Offline.cc b/DQMOffline/L1Trigger/src/L1TStage2CaloLayer2Offline.cc index 8256cdeab9130..7ddb3f5de0915 100644 --- a/DQMOffline/L1Trigger/src/L1TStage2CaloLayer2Offline.cc +++ b/DQMOffline/L1Trigger/src/L1TStage2CaloLayer2Offline.cc @@ -422,7 +422,6 @@ void L1TStage2CaloLayer2Offline::fillJets(edm::Event const& e, const unsigned in minDeltaR = currentDeltaR; closestL1Jet = *jet; foundMatch = true; - break; } } // }