CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
HLTMuonPlotter Class Reference

#include <HLTMuonPlotter.h>

Classes

struct  matchesByDescendingPt
 
struct  MatchStruct
 

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef L1MuonMatcherAlgoT< edm::Transition::BeginRunL1MuonMatcherAlgoForDQM
 
typedef dqm::legacy::MonitorElement MonitorElement
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 
void beginRun (DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)
 
 HLTMuonPlotter (const edm::ParameterSet &, 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 ()=default
 

Private Member Functions

void bookHist (DQMStore::IBooker &, const std::string &, const std::string &, const std::string &, const std::string &)
 
void findMatches (std::vector< MatchStruct > &, const l1t::MuonVectorRef &candsL1, const std::vector< std::vector< const reco::RecoChargedCandidate *>> &)
 
template<typename T >
std::string vector_to_string (std::vector< T > const &vec, std::string const &delimiter=" ") const
 

Private Attributes

double cutMaxEta_
 
double cutMinPt_
 
std::vector< double > const cutsDr_
 
std::unordered_map< std::string, MonitorElement * > elements_
 
StringCutObjectSelector< reco::GenParticle > const genMuonSelector_
 
edm::EDGetTokenT< reco::GenParticleCollection > const genParticleToken_
 
std::string const hltPath_
 
std::string const hltProcessName_
 
bool isInvalid_
 
L1MuonMatcherAlgoForDQM l1Matcher_
 
std::vector< std::string > const moduleLabels_
 
std::vector< double > const parametersEta_
 
std::vector< double > const parametersPhi_
 
std::vector< double > const parametersTurnOn_
 
StringCutObjectSelector< reco::Muon > const recMuonSelector_
 
edm::EDGetTokenT< reco::MuonCollection > const recMuonToken_
 
std::vector< std::string > const stepLabels_
 
edm::EDGetTokenT< trigger::TriggerEventWithRefs > const triggerEventWithRefsToken_
 

Detailed Description

Generate histograms for muon trigger efficiencies Documentation available on the CMS TWiki: https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLTOfflinePerformance

Author
J. Klukas, M. Vander Donckt, J. Alcaraz

Definition at line 44 of file HLTMuonPlotter.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 46 of file HLTMuonPlotter.h.

◆ L1MuonMatcherAlgoForDQM

Definition at line 48 of file HLTMuonPlotter.h.

◆ MonitorElement

Definition at line 47 of file HLTMuonPlotter.h.

Constructor & Destructor Documentation

◆ HLTMuonPlotter()

HLTMuonPlotter::HLTMuonPlotter ( const edm::ParameterSet pset,
const std::string &  hltPath,
const std::vector< std::string > &  moduleLabels,
const std::vector< std::string > &  stepLabels,
const edm::EDGetTokenT< trigger::TriggerEventWithRefs > &  triggerEventWithRefsToken,
const edm::EDGetTokenT< reco::GenParticleCollection > &  genParticlesToken,
const edm::EDGetTokenT< reco::MuonCollection > &  recoMuonsToken,
const L1MuonMatcherAlgoForDQM l1Matcher 
)

Definition at line 26 of file HLTMuonPlotter.cc.

References submitPVResolutionJobs::err, custom_jme_cff::foo, hltPath_, isInvalid_, moduleLabels_, and stepLabels_.

34  : hltPath_(hltPath),
35  hltProcessName_(pset.getParameter<std::string>("hltProcessName")),
36  moduleLabels_(moduleLabels),
37  stepLabels_(stepLabels),
38  triggerEventWithRefsToken_(triggerEventWithRefsToken),
39  genParticleToken_(genParticlesToken),
40  recMuonToken_(recoMuonsToken),
41  genMuonSelector_(pset.getParameter<std::string>("genMuonCut")),
42  recMuonSelector_(pset.getParameter<std::string>("recMuonCut")),
43  cutsDr_(pset.getParameter<std::vector<double>>("cutsDr")),
44  parametersEta_(pset.getParameter<std::vector<double>>("parametersEta")),
45  parametersPhi_(pset.getParameter<std::vector<double>>("parametersPhi")),
46  parametersTurnOn_(pset.getParameter<std::vector<double>>("parametersTurnOn")),
47  l1Matcher_(l1Matcher),
48  isInvalid_(false) {
49  if (moduleLabels_.empty()) {
50  edm::LogError("HLTMuonPlotter") << "Invalid inputs: 'moduleLabels_' is empty."
51  << "\nMonitorElements for HLT path '" << hltPath_ << "' will not be produced.";
52  isInvalid_ = true;
53  } else if (stepLabels_.size() != moduleLabels_.size() + 1) {
54  edm::LogError err("HLTMuonPlotter");
55  err << "Invalid inputs: 'stepLabels_.size()' must equal 'moduleLabels_.size() + 1'.";
56  err << "\nMonitorElements for HLT path '" << hltPath_ << "' will not be produced.";
57  err << "\n stepLabels_ = (";
58  for (auto const &foo : stepLabels_)
59  err << " " << foo;
60  err << " )";
61  err << "\n moduleLabels_ = (";
62  for (auto const &foo : moduleLabels_)
63  err << " " << foo;
64  err << " )";
65  isInvalid_ = true;
66  }
67 }
std::string const hltPath_
StringCutObjectSelector< reco::Muon > const recMuonSelector_
Log< level::Error, false > LogError
std::string const hltProcessName_
edm::EDGetTokenT< trigger::TriggerEventWithRefs > const triggerEventWithRefsToken_
std::vector< double > const cutsDr_
std::vector< double > const parametersTurnOn_
std::vector< std::string > const moduleLabels_
std::vector< double > const parametersEta_
edm::EDGetTokenT< reco::GenParticleCollection > const genParticleToken_
std::vector< double > const parametersPhi_
L1MuonMatcherAlgoForDQM l1Matcher_
edm::EDGetTokenT< reco::MuonCollection > const recMuonToken_
std::vector< std::string > const stepLabels_
StringCutObjectSelector< reco::GenParticle > const genMuonSelector_

◆ ~HLTMuonPlotter()

HLTMuonPlotter::~HLTMuonPlotter ( )
default

Member Function Documentation

◆ analyze()

void HLTMuonPlotter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 117 of file HLTMuonPlotter.cc.

References funct::abs(), submitPVResolutionJobs::count, cutMaxEta_, cutMinPt_, elements_, PVValHelper::eta, spr::find(), findMatches(), genMuonSelector_, EgammaValidation_cff::genp, genParticleToken_, hltPath_, hltProcessName_, mps_fire::i, heavyIonCSV_trainingSettings::idx, iEvent, ProducerED_cfi::InputTag, isInvalid_, dqmiolumiharvest::j, personalPlayback::level, LogTrace, oniaPATMuonsWithTrigger_cff::matches, moduleLabels_, phi, findAndChange::post, findAndChange::pre, DiDispStaMuonMonitor_cfi::pt, push_back(), recMuonSelector_, recMuonToken_, edm::path_configuration::removeSchedulingTokensFromModuleLabel(), jetUpdater_cfi::sort, source, CalibrationSummaryClient_cfi::sources, stepLabels_, AlCaHLTBitMon_QueryRunRegistry::string, triggerEventWithRefsToken_, trigger::TriggerL1Mu, trigger::TriggerMuon, and vector_to_string().

117  {
118  if (isInvalid_)
119  return;
120 
121  auto const triggerEventWithRefsHandle = iEvent.getHandle(triggerEventWithRefsToken_);
122  if (triggerEventWithRefsHandle.failedToGet()) {
123  edm::LogError("HLTMuonPlotter") << "No trigger summary found";
124  return;
125  }
126 
127  auto const recoMuonsHandle = iEvent.getHandle(recMuonToken_);
128  auto const genParticlesHandle = iEvent.getHandle(genParticleToken_);
129 
130  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] --------------";
131  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] Event: " << iEvent.id();
132 
133  const int nFilters = moduleLabels_.size();
134  const int nSteps = stepLabels_.size();
135  const bool hasStepL1 = (stepLabels_.size() > 1 and stepLabels_[1] == "L1");
136  const int nStepsHlt = hasStepL1 ? nSteps - 2 : nSteps - 1;
137  const bool isDoubleMuonPath = (hltPath_.find("Double") != std::string::npos);
138  const int nObjectsToPassPath = (isDoubleMuonPath) ? 2 : 1;
139 
140  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] HLTPath=" << hltPath_ << " nFilters=" << nFilters
141  << " nSteps=" << nSteps << " hasStepL1=" << hasStepL1 << " nStepsHlt=" << nStepsHlt
142  << " isDoubleMuonPath=" << isDoubleMuonPath
143  << " nObjectsToPassPath=" << nObjectsToPassPath;
144 
145  if (nFilters + 1 == nSteps) {
146  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] stepLabels | moduleLabels";
147  for (int istep = 0; istep < nSteps; ++istep) {
148  if (istep == 0)
149  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] " << stepLabels_[istep] << " | [N/A]";
150  else
151  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] " << stepLabels_[istep] << " | " << moduleLabels_[istep - 1];
152  }
153  }
154 
155  std::vector<std::string> sources;
156  if (genParticlesHandle.isValid())
157  sources.push_back("gen");
158  if (recoMuonsHandle.isValid())
159  sources.push_back("rec");
160 
161  for (size_t sourceNo = 0; sourceNo < sources.size(); sourceNo++) {
162  std::string const &source = sources[sourceNo];
163 
164  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] source=" << source;
165 
166  // Make each good gen/rec muon into the base cand for a MatchStruct
167  std::vector<MatchStruct> matches;
168 
169  if (source == "gen") {
170  if (genParticlesHandle.isValid()) {
171  matches.reserve(matches.size() + genParticlesHandle->size());
172  for (auto const &genp : *genParticlesHandle)
173  if (genMuonSelector_(genp))
174  matches.emplace_back(MatchStruct(&genp));
175  }
176  } else if (source == "rec") {
177  if (recoMuonsHandle.isValid()) {
178  matches.reserve(matches.size() + recoMuonsHandle->size());
179  for (auto const &recomu : *recoMuonsHandle)
180  if (recMuonSelector_(recomu))
181  matches.emplace_back(MatchStruct(&recomu));
182  }
183  }
184 
185  // Sort the MatchStructs by pT for later filling of turn-on curve
186  std::sort(matches.begin(), matches.end(), matchesByDescendingPt());
187 
188  l1t::MuonVectorRef candsL1;
189  std::vector<std::vector<reco::RecoChargedCandidateRef>> refsHlt(nStepsHlt);
190  std::vector<std::vector<const reco::RecoChargedCandidate *>> candsHlt(nStepsHlt);
191 
192  for (int idx = 0; idx < nFilters; ++idx) {
193  auto const moduleLabelStripped =
195  auto const iTag = edm::InputTag(moduleLabelStripped, "", hltProcessName_);
196  auto const iFilter = triggerEventWithRefsHandle->filterIndex(iTag);
197  auto const iFilterValid = (iFilter < triggerEventWithRefsHandle->size());
198 
199  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] InputTag[" << idx << "]: " << moduleLabels_[idx]
200  << "::" << hltProcessName_ << " (filterIndex = " << iFilter
201  << ", valid = " << iFilterValid << ")";
202 
203  if (iFilterValid) {
204  if (idx == 0 and hasStepL1)
205  triggerEventWithRefsHandle->getObjects(iFilter, trigger::TriggerL1Mu, candsL1);
206  else {
207  auto const hltStep = hasStepL1 ? idx - 1 : idx;
208  triggerEventWithRefsHandle->getObjects(iFilter, trigger::TriggerMuon, refsHlt[hltStep]);
209  }
210  } else
211  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] No collection with " << iTag;
212  }
213 
214  for (int i = 0; i < nStepsHlt; i++) {
215  for (size_t j = 0; j < refsHlt[i].size(); j++) {
216  if (refsHlt[i][j].isAvailable())
217  candsHlt[i].push_back(&*refsHlt[i][j]);
218  else
219  edm::LogWarning("HLTMuonPlotter") << "Ref refsHlt[i][j]: product not available " << i << " " << j;
220  }
221  }
222 
223  // Add trigger objects to the MatchStructs
224  findMatches(matches, candsL1, candsHlt);
225 
226  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] Number of Candidates = " << matches.size();
227 
228  for (auto const &match_i : matches) {
229  if (!match_i.candBase)
230  continue;
231  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] CandBase: pt=" << match_i.candBase->pt()
232  << " eta=" << match_i.candBase->eta() << " phi=" << match_i.candBase->phi();
233  if (match_i.candL1)
234  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] CandL1: pt=" << match_i.candL1->pt()
235  << " eta=" << match_i.candL1->eta() << " phi=" << match_i.candL1->phi();
236  else
237  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] CandL1: NULL";
238 
239  int ihlt = -1;
240  for (auto const *chlt : match_i.candHlt) {
241  ++ihlt;
242  if (chlt)
243  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] CandHLT[" << ihlt << "]: pt=" << chlt->pt()
244  << " eta=" << chlt->eta() << " phi=" << chlt->phi();
245  else
246  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] CandHLT[" << ihlt << "]: NULL";
247  }
248  }
249 
250  std::vector<size_t> matchesInEtaRange;
251  std::vector<bool> hasMatch(matches.size(), true);
252 
253  for (int step = 0; step < nSteps; step++) {
254  int const hltStep = hasStepL1 ? step - 2 : step - 1;
255  size_t level = 0;
256  if ((stepLabels_[step].find("L3TkIso") != std::string::npos) ||
257  (stepLabels_[step].find("TkTkIso") != std::string::npos))
258  level = 6;
259  else if ((stepLabels_[step].find("L3HcalIso") != std::string::npos) ||
260  (stepLabels_[step].find("TkEcalIso") != std::string::npos))
261  level = 5;
262  else if ((stepLabels_[step].find("L3EcalIso") != std::string::npos) ||
263  (stepLabels_[step].find("TkEcalIso") != std::string::npos))
264  level = 4;
265  else if ((stepLabels_[step].find("L3") != std::string::npos) ||
266  (stepLabels_[step].find("Tk") != std::string::npos))
267  level = 3;
268  else if (stepLabels_[step].find("L2") != std::string::npos)
269  level = 2;
270  else if (stepLabels_[step].find("L1") != std::string::npos)
271  level = 1;
272 
273  for (size_t j = 0; j < matches.size(); j++) {
274  if (level == 0) {
275  if (std::abs(matches[j].candBase->eta()) < cutMaxEta_)
276  matchesInEtaRange.push_back(j);
277  } else if (level == 1) {
278  if (matches[j].candL1 == nullptr)
279  hasMatch[j] = false;
280  } else if (level >= 2) {
281  if (matches[j].candHlt.at(hltStep) == nullptr)
282  hasMatch[j] = false;
283  else if (!hasMatch[j]) {
284  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] match found for " << source << " candidate " << j
285  << " in HLT step " << hltStep << " of " << nStepsHlt
286  << " without previous match!";
287  break;
288  }
289  }
290  }
291 
292  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] (step=" << step << ", level=" << level
293  << ", hltStep=" << hltStep << ") matchesInEtaRange: [ "
294  << this->vector_to_string(matchesInEtaRange) << " ]";
295 
296  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] (step=" << step << ", level=" << level
297  << ", hltStep=" << hltStep << ") hasMatch: [ " << this->vector_to_string(hasMatch)
298  << " ]";
299 
300  if (std::count(hasMatch.begin(), hasMatch.end(), true) < nObjectsToPassPath)
301  break;
302 
303  std::string const pre = source + "Pass";
304  std::string const post = "_" + stepLabels_[step];
305 
306  for (size_t j = 0; j < matches.size(); j++) {
307  float const pt = matches[j].candBase->pt();
308  float const eta = matches[j].candBase->eta();
309  float const phi = matches[j].candBase->phi();
310  if (hasMatch[j]) {
311  if (!matchesInEtaRange.empty() && j == matchesInEtaRange[0]) {
312  elements_[pre + "MaxPt1" + post]->Fill(pt);
313  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] FILL(" << pre + "MaxPt1" + post << ") value = " << pt;
314  }
315  if (matchesInEtaRange.size() >= 2 && j == matchesInEtaRange[1]) {
316  elements_[pre + "MaxPt2" + post]->Fill(pt);
317  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] FILL(" << pre + "MaxPt2" + post << ") value = " << pt;
318  }
319  if (pt > cutMinPt_) {
320  elements_[pre + "Eta" + post]->Fill(eta);
321  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] FILL(" << pre + "Eta" + post << ") value = " << eta;
322  if (std::abs(eta) < cutMaxEta_) {
323  elements_[pre + "Phi" + post]->Fill(phi);
324  LogTrace("HLTMuonPlotter") << "[HLTMuonPlotter] FILL(" << pre + "Phi" + post << ") value = " << phi;
325  }
326  }
327  }
328  }
329  }
330  } // End loop over sources
331 }
std::string const hltPath_
genp
produce generated paricles in acceptance #
enum start value shifted to 81 so as to avoid clashes with PDG codes
std::string removeSchedulingTokensFromModuleLabel(std::string iLabel)
StringCutObjectSelector< reco::Muon > const recMuonSelector_
Log< level::Error, false > LogError
std::string const hltProcessName_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::EDGetTokenT< trigger::TriggerEventWithRefs > const triggerEventWithRefsToken_
#define LogTrace(id)
void findMatches(std::vector< MatchStruct > &, const l1t::MuonVectorRef &candsL1, const std::vector< std::vector< const reco::RecoChargedCandidate *>> &)
std::vector< MuonRef > MuonVectorRef
Definition: Muon.h:15
int iEvent
Definition: GenABIO.cc:224
std::unordered_map< std::string, MonitorElement * > elements_
std::string vector_to_string(std::vector< T > const &vec, std::string const &delimiter=" ") const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::string > const moduleLabels_
edm::EDGetTokenT< reco::GenParticleCollection > const genParticleToken_
edm::EDGetTokenT< reco::MuonCollection > const recMuonToken_
Helper structure to order MatchStruct.
Definition: MatchStruct.h:58
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
std::vector< std::string > const stepLabels_
step
Definition: StallMonitor.cc:83
Log< level::Warning, false > LogWarning
StringCutObjectSelector< reco::GenParticle > const genMuonSelector_
static std::string const source
Definition: EdmProvDump.cc:49

◆ beginRun()

void HLTMuonPlotter::beginRun ( DQMStore::IBooker iBooker,
const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 69 of file HLTMuonPlotter.cc.

References ALCARECODTCalibSynchDQM_cff::baseDir, dqm::implementation::IBooker::bookFloat(), bookHist(), reco::ceil(), cutMaxEta_, cutMinPt_, elements_, hltPath_, mps_fire::i, L1MuonMatcherAlgoT< Tr >::init(), isInvalid_, dqmiolumiharvest::j, l1Matcher_, dqm::implementation::NavigatorBase::setCurrentFolder(), source, CalibrationSummaryClient_cfi::sources, stepLabels_, AlCaHLTBitMon_QueryRunRegistry::string, and DiMuonV_cfg::threshold.

69  {
70  if (isInvalid_)
71  return;
72 
73  l1Matcher_.init(iSetup);
74 
75  cutMaxEta_ = 2.4;
76  if (hltPath_.find("eta2p1") != std::string::npos)
77  cutMaxEta_ = 2.1;
78 
79  // Choose a pT cut for gen/rec muons based on the pT cut in the hltPath_
80  unsigned int threshold = 0;
81  TPRegexp ptRegexp("Mu([0-9]+)");
82  TObjArray *regexArray = ptRegexp.MatchS(hltPath_);
83  if (regexArray->GetEntriesFast() == 2) {
84  threshold = atoi(((TObjString *)regexArray->At(1))->GetString());
85  }
86  delete regexArray;
87  // We select a whole number min pT cut slightly above the hltPath_'s final
88  // pt threshold, then subtract a bit to let through particle gun muons with
89  // exact integer pT:
90  cutMinPt_ = ceil(threshold * 1.1) - 0.01;
91  if (cutMinPt_ < 0.)
92  cutMinPt_ = 0.;
93 
94  std::string baseDir = "HLT/Muon/Distributions/";
96 
97  std::vector<std::string> sources(2);
98  sources[0] = "gen";
99  sources[1] = "rec";
100 
101  elements_["CutMinPt"] = iBooker.bookFloat("CutMinPt");
102  elements_["CutMaxEta"] = iBooker.bookFloat("CutMaxEta");
103  elements_["CutMinPt"]->Fill(cutMinPt_);
104  elements_["CutMaxEta"]->Fill(cutMaxEta_);
105 
106  for (size_t i = 0; i < sources.size(); i++) {
108  for (size_t j = 0; j < stepLabels_.size(); j++) {
109  bookHist(iBooker, hltPath_, stepLabels_[j], source, "Eta");
110  bookHist(iBooker, hltPath_, stepLabels_[j], source, "Phi");
111  bookHist(iBooker, hltPath_, stepLabels_[j], source, "MaxPt1");
112  bookHist(iBooker, hltPath_, stepLabels_[j], source, "MaxPt2");
113  }
114  }
115 }
void bookHist(DQMStore::IBooker &, const std::string &, const std::string &, const std::string &, const std::string &)
constexpr int32_t ceil(float num)
std::string const hltPath_
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void init(const edm::EventSetup &iSetup)
Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators...
std::unordered_map< std::string, MonitorElement * > elements_
L1MuonMatcherAlgoForDQM l1Matcher_
std::vector< std::string > const stepLabels_
static std::string const source
Definition: EdmProvDump.cc:49

◆ bookHist()

void HLTMuonPlotter::bookHist ( DQMStore::IBooker iBooker,
const std::string &  path,
const std::string &  label,
const std::string &  source,
const std::string &  type 
)
private

Definition at line 395 of file HLTMuonPlotter.cc.

References dqm::implementation::IBooker::book1D(), submitPVResolutionJobs::desc, SelectiveReadoutTask_cfi::edges, elements_, h, mps_fire::i, createfilelist::int, label, SiStripPI::max, SiStripPI::min, Skims_PA_cff::name, seedmultiplicitymonitor_newtracking_cfi::nBins, parametersEta_, parametersPhi_, parametersTurnOn_, submitPVValidationJobs::params, source, AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

Referenced by beginRun().

399  {
400  std::string sourceUpper = source;
401  sourceUpper[0] = toupper(sourceUpper[0]);
402  std::string name = source + "Pass" + type + "_" + label;
403  TH1F *h;
404 
405  if (type.find("MaxPt") != std::string::npos) {
406  std::string desc = (type == "MaxPt1") ? "Leading" : "Next-to-Leading";
407  std::string title = "pT of " + desc + " " + sourceUpper + " Muon " + "matched to " + label;
408  const size_t nBins = parametersTurnOn_.size() - 1;
409  float *edges = new float[nBins + 1];
410  for (size_t i = 0; i < nBins + 1; i++)
412  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
413  } else {
414  std::string symbol = (type == "Eta") ? "#eta" : "#phi";
415  std::string title = symbol + " of " + sourceUpper + " Muons " + "matched to " + label;
416  std::vector<double> params = (type == "Eta") ? parametersEta_ : parametersPhi_;
417  int nBins = (int)params[0];
418  double min = params[1];
419  double max = params[2];
420  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
421  }
422 
423  h->Sumw2();
424  elements_[name] = iBooker.book1D(name, h);
425  delete h;
426 }
char const * label
std::unordered_map< std::string, MonitorElement * > elements_
std::vector< double > const parametersTurnOn_
std::vector< double > const parametersEta_
std::vector< double > const parametersPhi_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
static std::string const source
Definition: EdmProvDump.cc:49

◆ findMatches()

void HLTMuonPlotter::findMatches ( std::vector< MatchStruct > &  matches,
const l1t::MuonVectorRef candsL1,
const std::vector< std::vector< const reco::RecoChargedCandidate *>> &  candsHlt 
)
private

Definition at line 333 of file HLTMuonPlotter.cc.

References deltar::bestMatch(), cutsDr_, PbPb_ZMuSkimMuonDPG_cff::deltaR, HGC3DClusterGenMatchSelector_cfi::dR, mps_fire::i, edm::eventsetup::heterocontainer::insert(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, personalPlayback::level, and oniaPATMuonsWithTrigger_cff::matches.

Referenced by analyze().

335  {
336  std::set<size_t>::iterator it;
337 
338  std::set<size_t> indicesL1;
339  for (size_t i = 0; i < candsL1.size(); i++)
340  indicesL1.insert(i);
341 
342  std::vector<set<size_t>> indicesHlt(candsHlt.size());
343  for (size_t i = 0; i < candsHlt.size(); i++)
344  for (size_t j = 0; j < candsHlt[i].size(); j++)
345  indicesHlt[i].insert(j);
346 
347  for (size_t i = 0; i < matches.size(); i++) {
348  const reco::Candidate *cand = matches[i].candBase;
349 
350  double bestDeltaR = cutsDr_[0];
351  size_t bestMatch = kNull;
352  for (it = indicesL1.begin(); it != indicesL1.end(); it++) {
353  if (candsL1[*it].isAvailable()) {
354  double dR = deltaR(cand->eta(), cand->phi(), candsL1[*it]->eta(), candsL1[*it]->phi());
355  if (dR < bestDeltaR) {
356  bestMatch = *it;
357  bestDeltaR = dR;
358  }
359  // TrajectoryStateOnSurface propagated;
360  // float dR = 999., dPhi = 999.;
361  // bool isValid = l1Matcher_.match(* cand, * candsL1[*it],
362  // dR, dPhi, propagated);
363  // if (isValid && dR < bestDeltaR) {
364  // bestMatch = *it;
365  // bestDeltaR = dR;
366  // }
367  } else {
368  edm::LogWarning("HLTMuonPlotter") << "Ref candsL1[*it]: product not available " << *it;
369  }
370  }
371 
372  if (bestMatch != kNull)
373  matches[i].candL1 = &*candsL1[bestMatch];
374  indicesL1.erase(bestMatch);
375 
376  matches[i].candHlt.assign(candsHlt.size(), nullptr);
377  for (size_t j = 0; j < candsHlt.size(); j++) {
378  size_t level = (candsHlt.size() == 4) ? (j < 2) ? 2 : 3 : (candsHlt.size() == 2) ? (j < 1) ? 2 : 3 : 2;
379  bestDeltaR = cutsDr_[level - 2];
380  bestMatch = kNull;
381  for (it = indicesHlt[j].begin(); it != indicesHlt[j].end(); it++) {
382  double dR = deltaR(cand->eta(), cand->phi(), candsHlt[j][*it]->eta(), candsHlt[j][*it]->phi());
383  if (dR < bestDeltaR) {
384  bestMatch = *it;
385  bestDeltaR = dR;
386  }
387  }
388  if (bestMatch != kNull)
389  matches[i].candHlt[j] = candsHlt[j][bestMatch];
390  indicesHlt[j].erase(bestMatch);
391  }
392  }
393 }
std::vector< double > const cutsDr_
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
def bestMatch(object, matchCollection)
Definition: deltar.py:138
Log< level::Warning, false > LogWarning

◆ vector_to_string()

template<typename T >
std::string HLTMuonPlotter::vector_to_string ( std::vector< T > const &  vec,
std::string const &  delimiter = " " 
) const
private

Definition at line 122 of file HLTMuonPlotter.h.

References makeHLTPrescaleTable::delimiter, custom_jme_cff::foo, and runTheMatrix::ret.

Referenced by analyze().

122  {
123  if (vec.empty())
124  return "";
125  std::stringstream sstr;
126  for (auto const &foo : vec)
127  sstr << delimiter << foo;
128  auto ret = sstr.str();
129  ret.erase(0, delimiter.size());
130  return ret;
131 }
ret
prodAgent to be discontinued

Member Data Documentation

◆ cutMaxEta_

double HLTMuonPlotter::cutMaxEta_
private

Definition at line 116 of file HLTMuonPlotter.h.

Referenced by analyze(), and beginRun().

◆ cutMinPt_

double HLTMuonPlotter::cutMinPt_
private

Definition at line 115 of file HLTMuonPlotter.h.

Referenced by analyze(), and beginRun().

◆ cutsDr_

std::vector<double> const HLTMuonPlotter::cutsDr_
private

Definition at line 105 of file HLTMuonPlotter.h.

Referenced by findMatches().

◆ elements_

std::unordered_map<std::string, MonitorElement *> HLTMuonPlotter::elements_
private

Definition at line 118 of file HLTMuonPlotter.h.

Referenced by analyze(), beginRun(), and bookHist().

◆ genMuonSelector_

StringCutObjectSelector<reco::GenParticle> const HLTMuonPlotter::genMuonSelector_
private

Definition at line 103 of file HLTMuonPlotter.h.

Referenced by analyze().

◆ genParticleToken_

edm::EDGetTokenT<reco::GenParticleCollection> const HLTMuonPlotter::genParticleToken_
private

Definition at line 100 of file HLTMuonPlotter.h.

Referenced by analyze().

◆ hltPath_

std::string const HLTMuonPlotter::hltPath_
private

Definition at line 93 of file HLTMuonPlotter.h.

Referenced by analyze(), beginRun(), and HLTMuonPlotter().

◆ hltProcessName_

std::string const HLTMuonPlotter::hltProcessName_
private

Definition at line 94 of file HLTMuonPlotter.h.

Referenced by analyze().

◆ isInvalid_

bool HLTMuonPlotter::isInvalid_
private

Definition at line 113 of file HLTMuonPlotter.h.

Referenced by analyze(), beginRun(), and HLTMuonPlotter().

◆ l1Matcher_

L1MuonMatcherAlgoForDQM HLTMuonPlotter::l1Matcher_
private

Definition at line 111 of file HLTMuonPlotter.h.

Referenced by beginRun().

◆ moduleLabels_

std::vector<std::string> const HLTMuonPlotter::moduleLabels_
private

Definition at line 96 of file HLTMuonPlotter.h.

Referenced by analyze(), and HLTMuonPlotter().

◆ parametersEta_

std::vector<double> const HLTMuonPlotter::parametersEta_
private

Definition at line 107 of file HLTMuonPlotter.h.

Referenced by bookHist().

◆ parametersPhi_

std::vector<double> const HLTMuonPlotter::parametersPhi_
private

Definition at line 108 of file HLTMuonPlotter.h.

Referenced by bookHist().

◆ parametersTurnOn_

std::vector<double> const HLTMuonPlotter::parametersTurnOn_
private

Definition at line 109 of file HLTMuonPlotter.h.

Referenced by bookHist().

◆ recMuonSelector_

StringCutObjectSelector<reco::Muon> const HLTMuonPlotter::recMuonSelector_
private

Definition at line 104 of file HLTMuonPlotter.h.

Referenced by analyze().

◆ recMuonToken_

edm::EDGetTokenT<reco::MuonCollection> const HLTMuonPlotter::recMuonToken_
private

Definition at line 101 of file HLTMuonPlotter.h.

Referenced by analyze().

◆ stepLabels_

std::vector<std::string> const HLTMuonPlotter::stepLabels_
private

Definition at line 97 of file HLTMuonPlotter.h.

Referenced by analyze(), beginRun(), and HLTMuonPlotter().

◆ triggerEventWithRefsToken_

edm::EDGetTokenT<trigger::TriggerEventWithRefs> const HLTMuonPlotter::triggerEventWithRefsToken_
private

Definition at line 99 of file HLTMuonPlotter.h.

Referenced by analyze().