CMS 3D CMS Logo

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

#include <HLTMuonMatchAndPlot.h>

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 

Public Member Functions

void analyze (edm::Handle< reco::MuonCollection > &, edm::Handle< reco::BeamSpot > &, edm::Handle< reco::VertexCollection > &, edm::Handle< trigger::TriggerEvent > &, edm::Handle< edm::TriggerResults > &, const edm::TriggerNames &)
 
void beginRun (DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)
 
void endRun (const edm::Run &, const edm::EventSetup &)
 
void fillEdges (size_t &nBins, float *&edges, const std::vector< double > &binning)
 
template<class T >
void fillMapFromPSet (std::map< std::string, T > &, const edm::ParameterSet &, const std::string &)
 
template<class T >
void fillMapFromPSet (map< string, T > &m, const ParameterSet &pset, const string &target)
 
 HLTMuonMatchAndPlot (const edm::ParameterSet &, std::string, std::string, bool)
 Constructor. More...
 
template<class T1 , class T2 >
std::vector< size_t > matchByDeltaR (const std::vector< T1 > &, const std::vector< T2 > &, const double maxDeltaR=NOMATCH)
 
template<class T1 , class T2 >
vector< size_t > matchByDeltaR (const vector< T1 > &collection1, const vector< T2 > &collection2, const double maxDeltaR)
 

Private Member Functions

void book1D (DQMStore::IBooker &, std::string, const std::string &, std::string)
 
void book2D (DQMStore::IBooker &, const std::string &, const std::string &, const std::string &, const std::string &)
 
reco::MuonCollection selectedMuons (const reco::MuonCollection &, const reco::BeamSpot &, bool, const StringCutObjectSelector< reco::Muon > &, double, double)
 
trigger::TriggerObjectCollection selectedTriggerObjects (const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &, bool hasTriggerCuts, const StringCutObjectSelector< trigger::TriggerObject > &triggerSelector)
 

Private Attributes

std::map< std::string, std::vector< double > > binParams_
 
unsigned int cutMinPt_
 
std::string destination_
 
bool hasProbeRecoCuts
 
bool hasTargetRecoCuts
 
bool hasTriggerCuts_
 
std::map< std::string, MonitorElement * > hists_
 
std::string hltPath_
 
std::string hltProcessName_
 
bool isLastFilter_
 
std::string moduleLabel_
 
std::map< std::string, double > plotCuts_
 
double probeD0Cut_
 
StringCutObjectSelector< reco::MuonprobeMuonSelector_
 
edm::ParameterSet probeParams_
 
double probeZ0Cut_
 
std::vector< std::string > requiredTriggers_
 
double targetD0Cut_
 
StringCutObjectSelector< reco::MuontargetMuonSelector_
 
edm::ParameterSet targetParams_
 
double targetptCutJpsi_
 
double targetptCutZ_
 
double targetZ0Cut_
 
std::string triggerLevel_
 
StringCutObjectSelector< trigger::TriggerObjecttriggerSelector_
 

Detailed Description

Match reconstructed muons to HLT objects and plot efficiencies.

Note that this is not a true EDAnalyzer;

Documentation available on the CMS TWiki: https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLTOfflinePerformance

Author
J. Slaunwhite, Jeff Klukas

Contanier class to handle vector of reconstructed muons matched to HLT objects used to plot efficiencies.

Note that this is not a true EDAnalyzer; rather, the intent is that one EDAnalyzer would call an instance of HLTMuonMatchAndPlotContainer

Documentation available on the CMS TWiki: https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLTOfflinePerformance

Author
C. Battilana

Definition at line 57 of file HLTMuonMatchAndPlot.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 59 of file HLTMuonMatchAndPlot.h.

◆ MonitorElement

Definition at line 60 of file HLTMuonMatchAndPlot.h.

Constructor & Destructor Documentation

◆ HLTMuonMatchAndPlot()

HLTMuonMatchAndPlot::HLTMuonMatchAndPlot ( const edm::ParameterSet ,
std::string  ,
std::string  ,
bool   
)

Constructor.

Definition at line 37 of file HLTMuonMatchAndPlot.cc.

References binParams_, reco::ceil(), cutMinPt_, fillMapFromPSet(), hltPath_, moduleLabel_, plotCuts_, muonDTDigis_cfi::pset, and triggerLevel_.

38  : hltProcessName_(pset.getParameter<string>("hltProcessName")),
39  destination_(pset.getUntrackedParameter<string>("destination")),
40  requiredTriggers_(pset.getUntrackedParameter<vstring>("requiredTriggers")),
41  targetParams_(pset.getParameterSet("targetParams")),
42  probeParams_(pset.getParameterSet("probeParams")),
45  isLastFilter_(islastfilter),
49  targetZ0Cut_(targetParams_.getUntrackedParameter<double>("z0Cut", 0.)),
50  targetD0Cut_(targetParams_.getUntrackedParameter<double>("d0Cut", 0.)),
51  targetptCutZ_(targetParams_.getUntrackedParameter<double>("ptCut_Z", 20.)),
52  targetptCutJpsi_(targetParams_.getUntrackedParameter<double>("ptCut_Jpsi", 20.)),
53  probeMuonSelector_(probeParams_.getUntrackedParameter<string>("recoCuts", "")),
54  probeZ0Cut_(probeParams_.getUntrackedParameter<double>("z0Cut", 0.)),
55  probeD0Cut_(probeParams_.getUntrackedParameter<double>("d0Cut", 0.)),
58  // Create std::map<string, T> from ParameterSets.
59  fillMapFromPSet(binParams_, pset, "binParams");
60  fillMapFromPSet(plotCuts_, pset, "plotCuts");
61 
62  // Get the trigger level.
63  triggerLevel_ = "L3";
64  TPRegexp levelRegexp("L[1-3]");
65  // size_t nModules = moduleLabels_.size();
66  // cout << moduleLabel_ << " " << hltPath_ << endl;
67  TObjArray* levelArray = levelRegexp.MatchS(moduleLabel_);
68  if (levelArray->GetEntriesFast() > 0) {
69  triggerLevel_ = static_cast<const char*>(((TObjString*)levelArray->At(0))->GetString());
70  }
71  delete levelArray;
72 
73  // Get the pT cut by parsing the name of the HLT path.
74  cutMinPt_ = 3;
75  TPRegexp ptRegexp("Mu([0-9]*)");
76  TObjArray* objArray = ptRegexp.MatchS(hltPath_);
77  if (objArray->GetEntriesFast() >= 2) {
78  auto* ptCutString = (TObjString*)objArray->At(1);
79  cutMinPt_ = atoi(ptCutString->GetString());
80  cutMinPt_ = ceil(cutMinPt_ * plotCuts_["minPtFactor"]);
81  }
82  delete objArray;
83 }
constexpr int32_t ceil(float num)
StringCutObjectSelector< reco::Muon > probeMuonSelector_
vector< string > vstring
Definition: ExoticaDQM.cc:8
edm::ParameterSet targetParams_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::map< std::string, std::vector< double > > binParams_
std::vector< std::string > requiredTriggers_
T getUntrackedParameter(std::string const &, T const &) const
void fillMapFromPSet(std::map< std::string, T > &, const edm::ParameterSet &, const std::string &)
StringCutObjectSelector< reco::Muon > targetMuonSelector_
edm::ParameterSet probeParams_
StringCutObjectSelector< trigger::TriggerObject > triggerSelector_
std::map< std::string, double > plotCuts_
def move(src, dest)
Definition: eostools.py:511

Member Function Documentation

◆ analyze()

void HLTMuonMatchAndPlot::analyze ( edm::Handle< reco::MuonCollection > &  allMuons,
edm::Handle< reco::BeamSpot > &  beamSpot,
edm::Handle< reco::VertexCollection > &  vertices,
edm::Handle< trigger::TriggerEvent > &  triggerSummary,
edm::Handle< edm::TriggerResults > &  triggerResults,
const edm::TriggerNames trigNames 
)

Definition at line 127 of file HLTMuonMatchAndPlot.cc.

References allMuons_cfi::allMuons, pwdgSkimBPark_cfi::beamSpot, cutMinPt_, EFFICIENCY_SUFFIXES, hasProbeRecoCuts, hasTargetRecoCuts, hasTriggerCuts_, hists_, HLT_2022v12_cff::hltMuons, hltPath_, mps_fire::i, isLastFilter_, matchByDeltaR(), oniaPATMuonsWithTrigger_cff::matches, plotCuts_, probeD0Cut_, probeMuonSelector_, probeZ0Cut_, requiredTriggers_, selectedMuons(), selectedTriggerObjects(), makePlotsFromDump::suffix, targetD0Cut_, targetMuonSelector_, targetZ0Cut_, HLT_2022v12_cff::track, triggerLevel_, triggerResults, triggerSelector_, HLTMuonOfflineAnalyzer_cfi::triggerSummary, and trigNames.

132  {
133  /*
134  if(gen != 0) {
135  for(g_part = gen->begin(); g_part != gen->end(); g_part++){
136  if( abs(g_part->pdgId()) == 13) {
137  if(!( g_part->status() ==1 || (g_part->status() ==2 && abs(g_part->pdgId())==5))) continue;
138  bool GenMomExists (true);
139  bool GenGrMomExists(true);
140  if( g_part->pt() < 10.0 ) continue;
141  if( fabs(g_part->eta()) > 2.4 ) continue;
142  int gen_id= g_part->pdgId();
143  const GenParticle* gen_lept = &(*g_part);
144  // get mother of gen_lept
145  const GenParticle* gen_mom = static_cast<const GenParticle*> (gen_lept->mother());
146  if(gen_mom==NULL) GenMomExists=false;
147  int m_id=-999;
148  if(GenMomExists) m_id = gen_mom->pdgId();
149  if(m_id != gen_id || !GenMomExists);
150  else{
151  int id= m_id;
152  while(id == gen_id && GenMomExists){
153  gen_mom = static_cast<const GenParticle*> (gen_mom->mother());
154  if(gen_mom==NULL){
155  GenMomExists=false;
156  }
157  if(GenMomExists) id=gen_mom->pdgId();
158  }
159  }
160  if(GenMomExists) m_id = gen_mom->pdgId();
161  gen_leptsp.push_back(gen_lept);
162  gen_momsp.push_back(gen_mom);
163  }
164  }
165  }
166  std::vector<GenParticle> gen_lepts;
167  for(size_t i = 0; i < gen_leptsp.size(); i++) {
168  gen_lepts.push_back(*gen_leptsp[i]);
169  }
170  */
171 
172  // Select objects based on the configuration.
173  MuonCollection targetMuons =
175  MuonCollection probeMuons =
177  TriggerObjectCollection allTriggerObjects = triggerSummary->getObjects();
180  // Fill plots for HLT muons.
181 
182  // Find the best trigger object matches for the targetMuons.
183  vector<size_t> matches = matchByDeltaR(targetMuons, hltMuons, plotCuts_[triggerLevel_ + "DeltaR"]);
184 
185  // Fill plots for matched muons.
186  for (size_t i = 0; i < targetMuons.size(); i++) {
187  Muon& muon = targetMuons[i];
188 
189  // Fill numerators and denominators for efficiency plots.
190  for (const auto& suffix : EFFICIENCY_SUFFIXES) {
191  // If no match was found, then the numerator plots don't get filled.
192  if (suffix == "numer" && matches[i] >= targetMuons.size())
193  continue;
194 
195  if (muon.pt() > cutMinPt_) {
196  hists_["efficiencyEta_" + suffix]->Fill(muon.eta());
197  }
198 
199  if (fabs(muon.eta()) < plotCuts_["maxEta"]) {
200  hists_["efficiencyTurnOn_" + suffix]->Fill(muon.pt());
201  }
202 
203  if (muon.pt() > cutMinPt_ && fabs(muon.eta()) < plotCuts_["maxEta"]) {
204  const Track* track = nullptr;
205  if (muon.isTrackerMuon())
206  track = &*muon.innerTrack();
207  else if (muon.isStandAloneMuon())
208  track = &*muon.outerTrack();
209  if (track) {
210  hists_["efficiencyPhi_" + suffix]->Fill(muon.phi());
211 
212  if (isLastFilter_) {
213  hists_["efficiencyCharge_" + suffix]->Fill(muon.charge());
214  }
215  }
216  }
217  } // finish loop numerator / denominator...
218 
219  if (!isLastFilter_)
220  continue;
221  // Fill plots for tag and probe
222  // Muon cannot be a tag because doesn't match an hlt muon
223  if (matches[i] >= targetMuons.size())
224  continue;
225  } // End loop over targetMuons.
226 
227  // fill eff histograms for reference trigger method
228  // Denominator: events passing reference trigger and two target muons
229  // Numerator: events in the denominator with two target muons
230  // matched to hlt muons
231  if (!isLastFilter_)
232  return;
233  unsigned int numTriggers = trigNames.size();
234  bool passTrigger = false;
235  if (requiredTriggers_.empty())
236  passTrigger = true;
237  for (auto const& requiredTrigger : requiredTriggers_) {
238  for (unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
239  passTrigger = (trigNames.triggerName(hltIndex).find(requiredTrigger) != std::string::npos &&
240  triggerResults->wasrun(hltIndex) && triggerResults->accept(hltIndex));
241  if (passTrigger)
242  break;
243  }
244  }
245 
246  int nMatched = 0;
247  for (unsigned long matche : matches) {
248  if (matche < targetMuons.size())
249  nMatched++;
250  }
251 
252  string nonSameSignPath = hltPath_;
253  bool ssPath = false;
254  if (nonSameSignPath.rfind("_SameSign") < nonSameSignPath.length()) {
255  ssPath = true;
256  nonSameSignPath = boost::replace_all_copy<string>(nonSameSignPath, "_SameSign", "");
257  nonSameSignPath = nonSameSignPath.substr(0, nonSameSignPath.rfind("_v") + 2);
258  }
259  bool passTriggerSS = false;
260  if (ssPath) {
261  for (unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
262  passTriggerSS =
263  passTriggerSS || (trigNames.triggerName(hltIndex).substr(0, nonSameSignPath.size()) == nonSameSignPath &&
264  triggerResults->wasrun(hltIndex) && triggerResults->accept(hltIndex));
265  }
266  }
267 
268  string nonDZPath = hltPath_;
269  bool dzPath = false;
270  if (nonDZPath.rfind("_DZ") < nonDZPath.length()) {
271  dzPath = true;
272  nonDZPath = boost::replace_all_copy<string>(nonDZPath, "_DZ", "");
273  nonDZPath = nonDZPath.substr(0, nonDZPath.rfind("_v") + 2);
274  }
275  bool passTriggerDZ = false;
276  if (dzPath) {
277  for (unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
278  passTriggerDZ = passTriggerDZ || (trigNames.triggerName(hltIndex).find(nonDZPath) != std::string::npos &&
279  triggerResults->wasrun(hltIndex) && triggerResults->accept(hltIndex));
280  }
281  }
282 
283 } // End analyze() method.
reco::MuonCollection selectedMuons(const reco::MuonCollection &, const reco::BeamSpot &, bool, const StringCutObjectSelector< reco::Muon > &, double, double)
StringCutObjectSelector< reco::Muon > probeMuonSelector_
const std::string EFFICIENCY_SUFFIXES[2]
std::map< std::string, MonitorElement * > hists_
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
std::vector< std::string > requiredTriggers_
std::vector< size_t > matchByDeltaR(const std::vector< T1 > &, const std::vector< T2 > &, const double maxDeltaR=NOMATCH)
Definition: Muon.py:1
trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &, bool hasTriggerCuts, const StringCutObjectSelector< trigger::TriggerObject > &triggerSelector)
static std::string const triggerResults
Definition: EdmProvDump.cc:44
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
StringCutObjectSelector< reco::Muon > targetMuonSelector_
StringCutObjectSelector< trigger::TriggerObject > triggerSelector_
std::map< std::string, double > plotCuts_

◆ beginRun()

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

Definition at line 85 of file HLTMuonMatchAndPlot.cc.

References ALCARECODTCalibSynchDQM_cff::baseDir, book1D(), destination_, EFFICIENCY_SUFFIXES, hltPath_, isLastFilter_, moduleLabel_, dqm::implementation::NavigatorBase::setCurrentFolder(), and makePlotsFromDump::suffix.

85  {
86  TPRegexp suffixPtCut("Mu[0-9]+$");
87 
88  string baseDir = destination_;
89  if (baseDir[baseDir.size() - 1] != '/')
90  baseDir += '/';
91  string pathSansSuffix = hltPath_;
92  if (hltPath_.rfind("_v") < hltPath_.length())
93  pathSansSuffix = hltPath_.substr(0, hltPath_.rfind("_v"));
94 
95  if (isLastFilter_)
96  iBooker.setCurrentFolder(baseDir + pathSansSuffix);
97  else
98  iBooker.setCurrentFolder(baseDir + pathSansSuffix + "/" + moduleLabel_);
99 
100  // Form is book1D(name, binningType, title) where 'binningType' is used
101  // to fetch the bin settings from binParams_.
102 
103  for (const auto& suffix : EFFICIENCY_SUFFIXES) {
104  if (isLastFilter_)
105  iBooker.setCurrentFolder(baseDir + pathSansSuffix);
106  else
107  iBooker.setCurrentFolder(baseDir + pathSansSuffix + "/" + moduleLabel_);
108 
109  book1D(iBooker, "efficiencyEta_" + suffix, "eta", ";#eta;");
110  book1D(iBooker, "efficiencyPhi_" + suffix, "phi", ";#phi;");
111  book1D(iBooker, "efficiencyTurnOn_" + suffix, "pt", ";p_{T};");
112 
113  if (isLastFilter_)
114  iBooker.setCurrentFolder(baseDir + pathSansSuffix);
115  else
116  iBooker.setCurrentFolder(baseDir + pathSansSuffix + "/" + moduleLabel_);
117 
118  if (!isLastFilter_)
119  continue; //this will be plotted only for the last filter
120 
121  book1D(iBooker, "efficiencyCharge_" + suffix, "charge", ";charge;");
122  }
123 }
const std::string EFFICIENCY_SUFFIXES[2]
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
void book1D(DQMStore::IBooker &, std::string, const std::string &, std::string)

◆ book1D()

void HLTMuonMatchAndPlot::book1D ( DQMStore::IBooker ,
std::string  ,
const std::string &  ,
std::string   
)
private

Definition at line 426 of file HLTMuonMatchAndPlot.cc.

References binParams_, dqm::implementation::IBooker::book1D(), SelectiveReadoutTask_cfi::edges, fillEdges(), hists_, Skims_PA_cff::name, seedmultiplicitymonitor_newtracking_cfi::nBins, and runGCPTkAlMap::title.

Referenced by beginRun().

426  {
427  /* Properly delete the array of floats that has been allocated on
428  * the heap by fillEdges. Avoid multiple copies and internal ROOT
429  * clones by simply creating the histograms directly in the DQMStore
430  * using the appropriate book1D method to handle the variable bins
431  * case. */
432 
433  size_t nBins;
434  float* edges = nullptr;
435  fillEdges(nBins, edges, binParams_[binningType]);
436  hists_[name] = iBooker.book1D(name, title, nBins, edges);
437  if (hists_[name])
438  if (hists_[name]->getTH1F()->GetSumw2N())
439  hists_[name]->enableSumw2();
440 
441  if (edges)
442  delete[] edges;
443 }
std::map< std::string, std::vector< double > > binParams_
std::map< std::string, MonitorElement * > hists_
void fillEdges(size_t &nBins, float *&edges, const std::vector< double > &binning)

◆ book2D()

void HLTMuonMatchAndPlot::book2D ( DQMStore::IBooker ,
const std::string &  ,
const std::string &  ,
const std::string &  ,
const std::string &   
)
private

Definition at line 445 of file HLTMuonMatchAndPlot.cc.

References binParams_, dqm::implementation::IBooker::book2D(), fillEdges(), hists_, Skims_PA_cff::name, and runGCPTkAlMap::title.

449  {
450  /* Properly delete the arrays of floats that have been allocated on
451  * the heap by fillEdges. Avoid multiple copies and internal ROOT
452  * clones by simply creating the histograms directly in the DQMStore
453  * using the appropriate book2D method to handle the variable bins
454  * case. */
455 
456  size_t nBinsX;
457  float* edgesX = nullptr;
458  fillEdges(nBinsX, edgesX, binParams_[binningTypeX]);
459 
460  size_t nBinsY;
461  float* edgesY = nullptr;
462  fillEdges(nBinsY, edgesY, binParams_[binningTypeY]);
463 
464  hists_[name] = iBooker.book2D(name.c_str(), title.c_str(), nBinsX, edgesX, nBinsY, edgesY);
465  if (hists_[name])
466  if (hists_[name]->getTH2F()->GetSumw2N())
467  hists_[name]->enableSumw2();
468 
469  if (edgesX)
470  delete[] edgesX;
471  if (edgesY)
472  delete[] edgesY;
473 }
std::map< std::string, std::vector< double > > binParams_
std::map< std::string, MonitorElement * > hists_
void fillEdges(size_t &nBins, float *&edges, const std::vector< double > &binning)

◆ endRun()

void HLTMuonMatchAndPlot::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 125 of file HLTMuonMatchAndPlot.cc.

125 {}

◆ fillEdges()

void HLTMuonMatchAndPlot::fillEdges ( size_t &  nBins,
float *&  edges,
const std::vector< double > &  binning 
)

Definition at line 286 of file HLTMuonMatchAndPlot.cc.

References pileupCalc::binning, SelectiveReadoutTask_cfi::edges, mps_fire::i, SiStripPI::min, and seedmultiplicitymonitor_newtracking_cfi::nBins.

Referenced by book1D(), and book2D().

286  {
287  if (binning.size() < 3) {
288  LogWarning("HLTMuonVal") << "Invalid binning parameters!";
289  return;
290  }
291 
292  // Fixed-width binning.
293  if (binning.size() == 3) {
294  nBins = binning[0];
295  edges = new float[nBins + 1];
296  const double min = binning[1];
297  const double binwidth = (binning[2] - binning[1]) / nBins;
298  for (size_t i = 0; i <= nBins; i++)
299  edges[i] = min + (binwidth * i);
300  }
301 
302  // Variable-width binning.
303  else {
304  nBins = binning.size() - 1;
305  edges = new float[nBins + 1];
306  for (size_t i = 0; i <= nBins; i++)
307  edges[i] = binning[i];
308  }
309 }
Log< level::Warning, false > LogWarning

◆ fillMapFromPSet() [1/2]

template<class T >
void HLTMuonMatchAndPlot::fillMapFromPSet ( std::map< std::string, T > &  ,
const edm::ParameterSet ,
const std::string &   
)

Referenced by HLTMuonMatchAndPlot().

◆ fillMapFromPSet() [2/2]

template<class T >
void HLTMuonMatchAndPlot::fillMapFromPSet ( map< string, T > &  m,
const ParameterSet pset,
const string &  target 
)

Definition at line 315 of file HLTMuonMatchAndPlot.cc.

References edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::ParameterSet::getUntrackedParameter(), visualization-live-secondInstance_cfg::m, names, muonDTDigis_cfi::pset, and filterCSVwithJSON::target.

315  {
316  // Get the ParameterSet with name 'target' from 'pset'
317  ParameterSet targetPset;
318  if (pset.existsAs<ParameterSet>(target, true)) // target is tracked
319  targetPset = pset.getParameterSet(target);
320  else if (pset.existsAs<ParameterSet>(target, false)) // target is untracked
321  targetPset = pset.getUntrackedParameterSet(target);
322 
323  // Get the parameter names from targetPset
324  vector<string> names = targetPset.getParameterNames();
325  vector<string>::const_iterator iter;
326 
327  for (iter = names.begin(); iter != names.end(); ++iter) {
328  if (targetPset.existsAs<T>(*iter, true)) // target is tracked
329  m[*iter] = targetPset.getParameter<T>(*iter);
330  else if (targetPset.existsAs<T>(*iter, false)) // target is untracked
331  m[*iter] = targetPset.getUntrackedParameter<T>(*iter);
332  }
333 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
const std::string names[nVars_]
T getUntrackedParameter(std::string const &, T const &) const
long double T
std::vector< std::string > getParameterNames() const

◆ matchByDeltaR() [1/2]

template<class T1 , class T2 >
std::vector<size_t> HLTMuonMatchAndPlot::matchByDeltaR ( const std::vector< T1 > &  ,
const std::vector< T2 > &  ,
const double  maxDeltaR = NOMATCH 
)

Referenced by analyze().

◆ matchByDeltaR() [2/2]

template<class T1 , class T2 >
vector<size_t> HLTMuonMatchAndPlot::matchByDeltaR ( const vector< T1 > &  collection1,
const vector< T2 > &  collection2,
const double  maxDeltaR 
)

Definition at line 337 of file HLTMuonMatchAndPlot.cc.

References PbPb_ZMuSkimMuonDPG_cff::deltaR, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, ewkMuLumiMonitorDQM_cfi::maxDeltaR, HLT_2022v12_cff::minDeltaR, NOMATCH, and mps_fire::result.

339  {
340  const size_t n1 = collection1.size();
341  const size_t n2 = collection2.size();
342 
343  vector<size_t> result(n1, -1);
344  vector<vector<double> > deltaRMatrix(n1, vector<double>(n2, NOMATCH));
345 
346  for (size_t i = 0; i < n1; i++)
347  for (size_t j = 0; j < n2; j++) {
348  deltaRMatrix[i][j] = deltaR(collection1[i], collection2[j]);
349  }
350 
351  // Run through the matrix n1 times to make sure we've found all matches.
352  for (size_t k = 0; k < n1; k++) {
353  size_t i_min = -1;
354  size_t j_min = -1;
355  double minDeltaR = maxDeltaR;
356  // find the smallest deltaR
357  for (size_t i = 0; i < n1; i++)
358  for (size_t j = 0; j < n2; j++)
359  if (deltaRMatrix[i][j] < minDeltaR) {
360  i_min = i;
361  j_min = j;
362  minDeltaR = deltaRMatrix[i][j];
363  }
364  // If a match has been made, save it and make those candidates unavailable.
365  if (minDeltaR < maxDeltaR) {
366  result[i_min] = j_min;
367  deltaRMatrix[i_min] = vector<double>(n2, NOMATCH);
368  for (size_t i = 0; i < n1; i++)
369  deltaRMatrix[i][j_min] = NOMATCH;
370  }
371  }
372 
373  return result;
374 }
const double NOMATCH

◆ selectedMuons()

MuonCollection HLTMuonMatchAndPlot::selectedMuons ( const reco::MuonCollection allMuons,
const reco::BeamSpot beamSpot,
bool  hasRecoCuts,
const StringCutObjectSelector< reco::Muon > &  selector,
double  d0Cut,
double  z0Cut 
)
private

Definition at line 376 of file HLTMuonMatchAndPlot.cc.

References allMuons_cfi::allMuons, pwdgSkimBPark_cfi::beamSpot, TrackSplittingMonitor_cfi::d0Cut, amptDefaultParameters_cff::mu, HLT_2022v12_cff::track, and HLTMuonOfflineAnalyzer_cff::z0Cut.

Referenced by analyze().

381  {
382  // If there is no selector (recoCuts does not exists), return an empty collection.
383  if (!hasRecoCuts)
384  return MuonCollection();
385 
386  MuonCollection reducedMuons;
387  for (auto const& mu : allMuons) {
388  const Track* track = nullptr;
389  if (mu.isTrackerMuon())
390  track = &*mu.innerTrack();
391  else if (mu.isStandAloneMuon())
392  track = &*mu.outerTrack();
393  if (track && selector(mu) && fabs(track->dxy(beamSpot.position())) < d0Cut &&
394  fabs(track->dz(beamSpot.position())) < z0Cut)
395  reducedMuons.push_back(mu);
396  }
397 
398  return reducedMuons;
399 }
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9

◆ selectedTriggerObjects()

TriggerObjectCollection HLTMuonMatchAndPlot::selectedTriggerObjects ( const trigger::TriggerObjectCollection triggerObjects,
const trigger::TriggerEvent triggerSummary,
bool  hasTriggerCuts,
const StringCutObjectSelector< trigger::TriggerObject > &  triggerSelector 
)
private

Definition at line 401 of file HLTMuonMatchAndPlot.cc.

References hltProcessName_, crabWrapper::key, relativeConstraints::keys, moduleLabel_, triggerMatchMonitor_cfi::triggerObjects, and HLTMuonOfflineAnalyzer_cfi::triggerSummary.

Referenced by analyze().

405  {
406  if (!hasTriggerCuts)
407  return TriggerObjectCollection();
408 
409  InputTag filterTag(moduleLabel_, "", hltProcessName_);
410  size_t filterIndex = triggerSummary.filterIndex(filterTag);
411 
412  TriggerObjectCollection selectedObjects;
413 
414  if (filterIndex < triggerSummary.sizeFilters()) {
415  const Keys& keys = triggerSummary.filterKeys(filterIndex);
416  for (unsigned short key : keys) {
417  TriggerObject foundObject = triggerObjects[key];
418  if (triggerSelector(foundObject))
419  selectedObjects.push_back(foundObject);
420  }
421  }
422 
423  return selectedObjects;
424 }
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
std::vector< size_type > Keys

Member Data Documentation

◆ binParams_

std::map<std::string, std::vector<double> > HLTMuonMatchAndPlot::binParams_
private

Definition at line 103 of file HLTMuonMatchAndPlot.h.

Referenced by book1D(), book2D(), and HLTMuonMatchAndPlot().

◆ cutMinPt_

unsigned int HLTMuonMatchAndPlot::cutMinPt_
private

Definition at line 110 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

◆ destination_

std::string HLTMuonMatchAndPlot::destination_
private

Definition at line 101 of file HLTMuonMatchAndPlot.h.

Referenced by beginRun().

◆ hasProbeRecoCuts

bool HLTMuonMatchAndPlot::hasProbeRecoCuts
private

Definition at line 118 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ hasTargetRecoCuts

bool HLTMuonMatchAndPlot::hasTargetRecoCuts
private

Definition at line 117 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ hasTriggerCuts_

bool HLTMuonMatchAndPlot::hasTriggerCuts_
private

Definition at line 130 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ hists_

std::map<std::string, MonitorElement *> HLTMuonMatchAndPlot::hists_
private

Definition at line 114 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), book1D(), and book2D().

◆ hltPath_

std::string HLTMuonMatchAndPlot::hltPath_
private

Definition at line 111 of file HLTMuonMatchAndPlot.h.

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

◆ hltProcessName_

std::string HLTMuonMatchAndPlot::hltProcessName_
private

Definition at line 100 of file HLTMuonMatchAndPlot.h.

Referenced by selectedTriggerObjects().

◆ isLastFilter_

bool HLTMuonMatchAndPlot::isLastFilter_
private

Definition at line 113 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and beginRun().

◆ moduleLabel_

std::string HLTMuonMatchAndPlot::moduleLabel_
private

◆ plotCuts_

std::map<std::string, double> HLTMuonMatchAndPlot::plotCuts_
private

Definition at line 104 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

◆ probeD0Cut_

double HLTMuonMatchAndPlot::probeD0Cut_
private

Definition at line 127 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ probeMuonSelector_

StringCutObjectSelector<reco::Muon> HLTMuonMatchAndPlot::probeMuonSelector_
private

Definition at line 125 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ probeParams_

edm::ParameterSet HLTMuonMatchAndPlot::probeParams_
private

Definition at line 106 of file HLTMuonMatchAndPlot.h.

◆ probeZ0Cut_

double HLTMuonMatchAndPlot::probeZ0Cut_
private

Definition at line 126 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ requiredTriggers_

std::vector<std::string> HLTMuonMatchAndPlot::requiredTriggers_
private

Definition at line 102 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ targetD0Cut_

double HLTMuonMatchAndPlot::targetD0Cut_
private

Definition at line 122 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ targetMuonSelector_

StringCutObjectSelector<reco::Muon> HLTMuonMatchAndPlot::targetMuonSelector_
private

Definition at line 120 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ targetParams_

edm::ParameterSet HLTMuonMatchAndPlot::targetParams_
private

Definition at line 105 of file HLTMuonMatchAndPlot.h.

◆ targetptCutJpsi_

double HLTMuonMatchAndPlot::targetptCutJpsi_
private

Definition at line 124 of file HLTMuonMatchAndPlot.h.

◆ targetptCutZ_

double HLTMuonMatchAndPlot::targetptCutZ_
private

Definition at line 123 of file HLTMuonMatchAndPlot.h.

◆ targetZ0Cut_

double HLTMuonMatchAndPlot::targetZ0Cut_
private

Definition at line 121 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ triggerLevel_

std::string HLTMuonMatchAndPlot::triggerLevel_
private

Definition at line 109 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

◆ triggerSelector_

StringCutObjectSelector<trigger::TriggerObject> HLTMuonMatchAndPlot::triggerSelector_
private

Definition at line 129 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().