Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve HLTMuonValidator and HLTMuonPlotter (no UB, consider only HLTFilter modules) #40753

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HLTriggerOffline/Muon/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/Utilities"/>
<use name="HLTrigger/HLTcore"/>
<use name="MuonAnalysis/MuonAssociators"/>
<flags EDM_PLUGIN="1"/>
83 changes: 43 additions & 40 deletions HLTriggerOffline/Muon/interface/HLTMuonPlotter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HLTriggerOffline_Muon_HLTMuonPlotter_H
#define HLTriggerOffline_Muon_HLTMuonPlotter_H
#ifndef HLTriggerOffline_Muon_HLTMuonPlotter_h
#define HLTriggerOffline_Muon_HLTMuonPlotter_h

/** \class HLTMuonPlotter
* Generate histograms for muon trigger efficiencies
Expand Down Expand Up @@ -34,13 +34,10 @@

#include "DQMServices/Core/interface/DQMStore.h"

#include <algorithm>
#include <cctype>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>

#include "TPRegexp.h"

Expand All @@ -51,20 +48,16 @@ class HLTMuonPlotter {
typedef L1MuonMatcherAlgoT<edm::Transition::BeginRun> L1MuonMatcherAlgoForDQM;

HLTMuonPlotter(const edm::ParameterSet &,
std::string,
const std::string &,
const std::vector<std::string> &,
const std::vector<std::string> &,
const edm::EDGetTokenT<trigger::TriggerEventWithRefs> &,
const edm::EDGetTokenT<reco::GenParticleCollection> &,
const edm::EDGetTokenT<reco::MuonCollection> &,
const L1MuonMatcherAlgoForDQM &);

~HLTMuonPlotter() {
delete genMuonSelector_;
delete recMuonSelector_;
}
~HLTMuonPlotter() = default;

void beginJob();
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &);
void analyze(const edm::Event &, const edm::EventSetup &);

Expand All @@ -88,43 +81,53 @@ class HLTMuonPlotter {
bool operator()(MatchStruct a, MatchStruct b) { return a.candBase->pt() > b.candBase->pt(); }
};

void analyzePath(const edm::Event &,
const std::string &,
const std::string &,
const std::vector<MatchStruct> &,
edm::Handle<trigger::TriggerEventWithRefs>);
void findMatches(std::vector<MatchStruct> &,
const l1t::MuonVectorRef &candsL1,
const std::vector<std::vector<const reco::RecoChargedCandidate *>> &);
void bookHist(DQMStore::IBooker &, std::string, std::string, std::string, std::string);

std::string hltPath_;
std::string hltProcessName_;
void bookHist(DQMStore::IBooker &, const std::string &, const std::string &, const std::string &, const std::string &);

std::vector<std::string> moduleLabels_;
std::vector<std::string> stepLabels_;
template <typename T>
std::string vector_to_string(std::vector<T> const &vec, std::string const &delimiter = " ") const;

edm::EDGetTokenT<trigger::TriggerEventWithRefs> hltTriggerSummaryRAW_;
edm::EDGetTokenT<reco::GenParticleCollection> genParticleLabel_;
edm::EDGetTokenT<reco::MuonCollection> recMuonLabel_;
std::string const hltPath_;
std::string const hltProcessName_;

std::vector<double> parametersEta_;
std::vector<double> parametersPhi_;
std::vector<double> parametersTurnOn_;
std::vector<std::string> const moduleLabels_;
std::vector<std::string> const stepLabels_;

double cutMinPt_;
double cutMaxEta_;
unsigned int cutMotherId_;
std::vector<double> cutsDr_;
std::string genMuonCut_;
std::string recMuonCut_;
edm::EDGetTokenT<trigger::TriggerEventWithRefs> const triggerEventWithRefsToken_;
edm::EDGetTokenT<reco::GenParticleCollection> const genParticleToken_;
edm::EDGetTokenT<reco::MuonCollection> const recMuonToken_;

StringCutObjectSelector<reco::GenParticle> *genMuonSelector_;
StringCutObjectSelector<reco::Muon> *recMuonSelector_;
StringCutObjectSelector<reco::GenParticle> const genMuonSelector_;
StringCutObjectSelector<reco::Muon> const recMuonSelector_;
std::vector<double> const cutsDr_;

std::vector<double> const parametersEta_;
std::vector<double> const parametersPhi_;
std::vector<double> const parametersTurnOn_;

L1MuonMatcherAlgoForDQM l1Matcher_;

std::map<std::string, MonitorElement *> elements_;
bool isInvalid_;

double cutMinPt_;
double cutMaxEta_;

std::unordered_map<std::string, MonitorElement *> elements_;
};

#endif
template <typename T>
std::string HLTMuonPlotter::vector_to_string(std::vector<T> const &vec, std::string const &delimiter) const {
if (vec.empty())
return "";
std::stringstream sstr;
for (auto const &foo : vec)
sstr << delimiter << foo;
auto ret = sstr.str();
ret.erase(0, delimiter.size());
return ret;
}

#endif // HLTriggerOffline_Muon_HLTMuonPlotter_h
6 changes: 3 additions & 3 deletions HLTriggerOffline/Muon/python/hltMuonValidator_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

hltProcessName = cms.string("HLT"),
hltPathsToCheck = cms.vstring(
"HLT_(L[12])?(Iso)?(Tk)?Mu[0-9]*(Open)?(_NoVertex)?(_eta2p1)?(_v[0-9]*)?$",
"HLT_(HighPt)?(L[12])?(Iso)?(Tk)?Mu[0-9]*(Open)?(_NoVertex)?(_eta2p1)?(_v[0-9]*)?$",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMSHLT-2277 renamed HLT_TkMu100 to HLT_HighPtTkMu100, and this change adds monitoring for the latter.

"HLT_Mu17_NoFilters?(_v[0-9]*)?$",
"HLT_Dimuon0_Jpsi_v10",
"HLT_Dimuon13_Jpsi_Barrel_v5",
"HLT_Dimuon0_Jpsi(_v[0-9]*)?$",
"HLT_Dimuon13_Jpsi_Barrel(_v[0-9]*)?$",
),

genParticleLabel = cms.string("genParticles" ),
Expand Down
Loading