23 using namespace trigger;
29 const std::vector<string> &moduleLabels,
30 const std::vector<string> &stepLabels,
37 l1Matcher_(pset, esTokens) {
67 if (
hltPath_.find(
"eta2p1") != string::npos)
72 TPRegexp ptRegexp(
"Mu([0-9]+)");
73 TObjArray *regexArray = ptRegexp.MatchS(
hltPath_);
74 if (regexArray->GetEntriesFast() == 2) {
75 threshold = atoi(((TObjString *)regexArray->At(1))->GetString());
85 string baseDir =
"HLT/Muon/Distributions/";
88 vector<string> sources(2);
97 for (
size_t i = 0;
i < sources.size();
i++) {
109 LogTrace(
"HLTMuonVal") <<
"In HLTMuonPlotter::analyze, "
110 <<
"Event: " << iEvent.
id();
122 LogError(
"HLTMuonVal") <<
"No trigger summary found";
128 vector<string> sources;
130 sources.push_back(
"gen");
132 sources.push_back(
"rec");
134 for (
size_t sourceNo = 0; sourceNo < sources.size(); sourceNo++) {
135 string source = sources[sourceNo];
144 vector<MatchStruct> matches;
145 if (source ==
"gen" && genParticles.
isValid())
146 for (
size_t i = 0;
i < genParticles->size();
i++)
149 if (source ==
"rec" && recMuons.
isValid())
150 for (
size_t i = 0;
i < recMuons->size();
i++)
157 const bool isDoubleMuonPath = (
hltPath_.find(
"Double") != string::npos);
160 const size_t nStepsHlt = nSteps - 2;
161 const int nObjectsToPassPath = (isDoubleMuonPath) ? 2 : 1;
163 vector<vector<RecoChargedCandidateRef>> refsHlt(nStepsHlt);
164 vector<vector<const RecoChargedCandidate *>> candsHlt(nStepsHlt);
166 for (
size_t i = 0;
i < nFilters;
i++) {
167 const int hltStep =
i - 1;
169 size_t iFilter = rawTriggerEvent->filterIndex(tag);
170 if (iFilter < rawTriggerEvent->
size()) {
172 rawTriggerEvent->getObjects(iFilter,
TriggerL1Mu, candsL1);
174 rawTriggerEvent->getObjects(iFilter,
TriggerMuon, refsHlt[hltStep]);
176 LogTrace(
"HLTMuonVal") <<
"No collection with label " <<
tag;
178 for (
size_t i = 0;
i < nStepsHlt;
i++)
179 for (
size_t j = 0;
j < refsHlt[
i].size();
j++)
180 if (refsHlt[
i][
j].isAvailable()) {
181 candsHlt[
i].push_back(&*refsHlt[
i][
j]);
183 LogWarning(
"HLTMuonPlotter") <<
"Ref refsHlt[i][j]: product not available " <<
i <<
" " <<
j;
189 vector<size_t> matchesInEtaRange;
190 vector<bool> hasMatch(matches.size(),
true);
193 size_t hltStep = (
step >= 2) ?
step - 2 : 0;
195 hltStep = hltStep - 1;
212 for (
size_t j = 0;
j < matches.size();
j++) {
215 matchesInEtaRange.push_back(
j);
216 }
else if (level == 1) {
217 if (matches[
j].candL1 ==
nullptr)
219 }
else if (level >= 2) {
220 if (matches[
j].candHlt[hltStep] ==
nullptr)
222 else if (!hasMatch[
j]) {
223 LogTrace(
"HLTMuonVal") <<
"Match found for HLT step " << hltStep <<
" of " << nStepsHlt
224 <<
" without previous match!";
230 if (
std::count(hasMatch.begin(), hasMatch.end(),
true) < nObjectsToPassPath)
233 string pre = source +
"Pass";
236 for (
size_t j = 0;
j < matches.size();
j++) {
237 float pt = matches[
j].candBase->pt();
238 float eta = matches[
j].candBase->eta();
239 float phi = matches[
j].candBase->phi();
241 if (!matchesInEtaRange.empty() && j == matchesInEtaRange[0])
243 if (matchesInEtaRange.size() >= 2 && j == matchesInEtaRange[1])
246 elements_[pre +
"Eta" + post]->Fill(eta);
248 elements_[pre +
"Phi" + post]->Fill(phi);
257 std::tuple<edm::EDGetTokenT<trigger::TriggerEventWithRefs>,
268 std::tuple<edm::EDGetTokenT<trigger::TriggerEventWithRefs>,
271 myTuple(_hltTriggerSummaryRAW, _genParticleLabel, _recMuonLabel);
276 std::tuple<edm::ESGetToken<MagneticField, IdealMagneticFieldRecord>,
287 const std::vector<vector<const RecoChargedCandidate *>> &candsHlt) {
288 set<size_t>::iterator it;
290 set<size_t> indicesL1;
291 for (
size_t i = 0;
i < candsL1.size();
i++)
294 vector<set<size_t>> indicesHlt(candsHlt.size());
295 for (
size_t i = 0;
i < candsHlt.size();
i++)
296 for (
size_t j = 0;
j < candsHlt[
i].size();
j++)
299 for (
size_t i = 0;
i < matches.size();
i++) {
302 double bestDeltaR =
cutsDr_[0];
304 for (it = indicesL1.begin(); it != indicesL1.end(); it++) {
305 if (candsL1[*it].isAvailable()) {
306 double dR =
deltaR(cand->
eta(), cand->
phi(), candsL1[*it]->eta(), candsL1[*it]->phi());
307 if (dR < bestDeltaR) {
320 LogWarning(
"HLTMuonPlotter") <<
"Ref candsL1[*it]: product not available " << *it;
324 if (bestMatch !=
kNull)
326 indicesL1.erase(bestMatch);
328 matches[
i].candHlt.assign(candsHlt.size(),
nullptr);
329 for (
size_t j = 0;
j < candsHlt.size();
j++) {
330 size_t level = (candsHlt.size() == 4) ? (
j < 2) ? 2 : 3 : (candsHlt.size() == 2) ? (
j < 1) ? 2 : 3 : 2;
331 bestDeltaR =
cutsDr_[level - 2];
333 for (it = indicesHlt[
j].
begin(); it != indicesHlt[
j].end(); it++) {
334 double dR =
deltaR(cand->
eta(), cand->
phi(), candsHlt[
j][*it]->eta(), candsHlt[
j][*it]->phi());
335 if (dR < bestDeltaR) {
340 if (bestMatch !=
kNull)
342 indicesHlt[
j].erase(bestMatch);
356 string sourceUpper =
source;
357 sourceUpper[0] = toupper(sourceUpper[0]);
358 string name = source +
"Pass" + type +
"_" +
label;
361 if (type.find(
"MaxPt") != string::npos) {
362 string desc = (type ==
"MaxPt1") ?
"Leading" :
"Next-to-Leading";
363 string title =
"pT of " + desc +
" " + sourceUpper +
" Muon " +
"matched to " +
label;
365 float *edges =
new float[nBins + 1];
366 for (
size_t i = 0;
i < nBins + 1;
i++)
368 h =
new TH1F(name.c_str(), title.c_str(), nBins, edges);
372 string symbol = (type ==
"Eta") ?
"#eta" :
"#phi";
373 string title = symbol +
" of " + sourceUpper +
" Muons " +
"matched to " +
label;
375 int nBins = (int)params[0];
376 double min = params[1];
377 double max = params[2];
378 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
constexpr int32_t ceil(float num)
hltriggeroffline::L1MuonMatcherAlgo l1Matcher_
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
HLTMuonPlotter(const edm::ParameterSet &, std::string, const std::vector< std::string > &, const std::vector< std::string > &, const std::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection >> &, const ESTokens &)
virtual void setCurrentFolder(std::string const &fullpath)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
enum start value shifted to 81 so as to avoid clashes with PDG codes
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)
std::vector< double > parametersEta_
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::string > moduleLabels_
std::vector< Muon > MuonCollection
collection of Muon objects
std::vector< MuonRef > MuonVectorRef
vector< ParameterSet > Parameters
void findMatches(std::vector< MatchStruct > &, const l1t::MuonVectorRef &candsL1, const std::vector< std::vector< const reco::RecoChargedCandidate * >> &)
std::vector< double > cutsDr_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
edm::EDGetTokenT< reco::MuonCollection > recMuonLabel_
void analyze(const edm::Event &, const edm::EventSetup &)
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
StringCutObjectSelector< reco::GenParticle > * genMuonSelector_
hltriggeroffline::L1MuonMatcherAlgo::ESTokens ESTokens
std::vector< std::string > stepLabels_
void bookHist(DQMStore::IBooker &, std::string, std::string, std::string, std::string)
T getParameter(std::string const &) const
StringCutObjectSelector< reco::Muon > * recMuonSelector_
std::vector< double > parametersPhi_
void init(const edm::EventSetup &iSetup)
std::map< std::string, MonitorElement * > elements_
std::string hltProcessName_
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< reco::GenParticleCollection > genParticleLabel_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
static std::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection > > getTokens(const edm::ParameterSet &, edm::ConsumesCollector &&)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
edm::EDGetTokenT< trigger::TriggerEventWithRefs > hltTriggerSummaryRAW_
std::vector< double > parametersTurnOn_
static std::string const source
static std::tuple< edm::ESGetToken< MagneticField, IdealMagneticFieldRecord >, edm::ESGetToken< Propagator, TrackingComponentsRecord >, edm::ESGetToken< Propagator, TrackingComponentsRecord >, edm::ESGetToken< Propagator, TrackingComponentsRecord >, edm::ESGetToken< MuonDetLayerGeometry, MuonRecoGeometryRecord > > getESTokens(edm::ConsumesCollector)
tuple size
Write out results.
virtual double phi() const =0
momentum azimuthal angle
static ESTokens getESTokens(edm::ConsumesCollector)
virtual double eta() const =0
momentum pseudorapidity