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)
 
trigger::TriggerObjectCollection selectedTriggerObjects (const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &)
 

Private Attributes

std::map< std::string, std::vector< double > > binParams_
 
unsigned int cutMinPt_
 
std::string destination_
 
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_
 
bool probeIsMuonGlb_
 
double probeMuonEtaMax_
 
double probeMuonEtaMin_
 
edm::ParameterSet probeParams_
 
double probeZ0Cut_
 
std::vector< std::string > requiredTriggers_
 
double targetD0Cut_
 
bool targetIsMuonGlb_
 
double targetMuonEtaMax_
 
double targetMuonEtaMin_
 
edm::ParameterSet targetParams_
 
double targetptCutJpsi_
 
double targetptCutZ_
 
double targetZ0Cut_
 
double triggerEtaMaxCut_
 
double triggerEtaMinCut_
 
std::string triggerLevel_
 

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 55 of file HLTMuonMatchAndPlot.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 57 of file HLTMuonMatchAndPlot.h.

◆ MonitorElement

Definition at line 58 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),
46  targetMuonEtaMax_(targetParams_.getUntrackedParameter<double>("recoMaxEtaCut", 0.)),
47  targetMuonEtaMin_(targetParams_.getUntrackedParameter<double>("recoMinEtaCut", 0.)),
48  targetIsMuonGlb_(targetParams_.getUntrackedParameter<bool>("recoGlbMuCut", false)),
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  probeMuonEtaMax_(probeParams_.getUntrackedParameter<double>("recoMaxEtaCut", 0.)),
54  probeMuonEtaMin_(probeParams_.getUntrackedParameter<double>("recoMinEtaCut", 0.)),
55  probeIsMuonGlb_(probeParams_.getUntrackedParameter<bool>("recoGlbMuCut", false)),
56  probeZ0Cut_(probeParams_.getUntrackedParameter<double>("z0Cut", 0.)),
57  probeD0Cut_(probeParams_.getUntrackedParameter<double>("d0Cut", 0.)),
58  triggerEtaMaxCut_(targetParams_.getUntrackedParameter<double>("hltMaxEtaCut", 0.)),
59  triggerEtaMinCut_(targetParams_.getUntrackedParameter<double>("hltMinEtaCut", 0.)) {
60  // Create std::map<string, T> from ParameterSets.
61  fillMapFromPSet(binParams_, pset, "binParams");
62  fillMapFromPSet(plotCuts_, pset, "plotCuts");
63 
64  // Get the trigger level.
65  triggerLevel_ = "L3";
66  TPRegexp levelRegexp("L[1-3]");
67  // size_t nModules = moduleLabels_.size();
68  // cout << moduleLabel_ << " " << hltPath_ << endl;
69  TObjArray* levelArray = levelRegexp.MatchS(moduleLabel_);
70  if (levelArray->GetEntriesFast() > 0) {
71  triggerLevel_ = static_cast<const char*>(((TObjString*)levelArray->At(0))->GetString());
72  }
73  delete levelArray;
74 
75  // Get the pT cut by parsing the name of the HLT path.
76  cutMinPt_ = 3;
77  TPRegexp ptRegexp("Mu([0-9]*)");
78  TObjArray* objArray = ptRegexp.MatchS(hltPath_);
79  if (objArray->GetEntriesFast() >= 2) {
80  auto* ptCutString = (TObjString*)objArray->At(1);
81  cutMinPt_ = atoi(ptCutString->GetString());
82  cutMinPt_ = ceil(cutMinPt_ * plotCuts_["minPtFactor"]);
83  }
84  delete objArray;
85 }
constexpr int32_t ceil(float num)
vector< string > vstring
Definition: ExoticaDQM.cc:8
edm::ParameterSet targetParams_
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 &)
edm::ParameterSet probeParams_
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 129 of file HLTMuonMatchAndPlot.cc.

References allMuons_cfi::allMuons, pwdgSkimBPark_cfi::beamSpot, cutMinPt_, EFFICIENCY_SUFFIXES, hists_, HLT_2022v12_cff::hltMuons, hltPath_, mps_fire::i, isLastFilter_, matchByDeltaR(), oniaPATMuonsWithTrigger_cff::matches, plotCuts_, requiredTriggers_, selectedMuons(), selectedTriggerObjects(), makePlotsFromDump::suffix, HLT_2022v12_cff::track, triggerLevel_, triggerResults, HLTMuonOfflineAnalyzer_cfi::triggerSummary, and trigNames.

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

◆ beginRun()

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

Definition at line 87 of file HLTMuonMatchAndPlot.cc.

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

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

419  {
420  /* Properly delete the array of floats that has been allocated on
421  * the heap by fillEdges. Avoid multiple copies and internal ROOT
422  * clones by simply creating the histograms directly in the DQMStore
423  * using the appropriate book1D method to handle the variable bins
424  * case. */
425 
426  size_t nBins;
427  float* edges = nullptr;
428  fillEdges(nBins, edges, binParams_[binningType]);
429  hists_[name] = iBooker.book1D(name, title, nBins, edges);
430  if (hists_[name])
431  if (hists_[name]->getTH1F()->GetSumw2N())
432  hists_[name]->enableSumw2();
433 
434  if (edges)
435  delete[] edges;
436 }
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 438 of file HLTMuonMatchAndPlot.cc.

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

442  {
443  /* Properly delete the arrays of floats that have been allocated on
444  * the heap by fillEdges. Avoid multiple copies and internal ROOT
445  * clones by simply creating the histograms directly in the DQMStore
446  * using the appropriate book2D method to handle the variable bins
447  * case. */
448 
449  size_t nBinsX;
450  float* edgesX = nullptr;
451  fillEdges(nBinsX, edgesX, binParams_[binningTypeX]);
452 
453  size_t nBinsY;
454  float* edgesY = nullptr;
455  fillEdges(nBinsY, edgesY, binParams_[binningTypeY]);
456 
457  hists_[name] = iBooker.book2D(name.c_str(), title.c_str(), nBinsX, edgesX, nBinsY, edgesY);
458  if (hists_[name])
459  if (hists_[name]->getTH2F()->GetSumw2N())
460  hists_[name]->enableSumw2();
461 
462  if (edgesX)
463  delete[] edgesX;
464  if (edgesY)
465  delete[] edgesY;
466 }
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 127 of file HLTMuonMatchAndPlot.cc.

127 {}

◆ fillEdges()

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

Definition at line 285 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().

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

314  {
315  // Get the ParameterSet with name 'target' from 'pset'
316  ParameterSet targetPset;
317  if (pset.existsAs<ParameterSet>(target, true)) // target is tracked
318  targetPset = pset.getParameterSet(target);
319  else if (pset.existsAs<ParameterSet>(target, false)) // target is untracked
320  targetPset = pset.getUntrackedParameterSet(target);
321 
322  // Get the parameter names from targetPset
323  vector<string> names = targetPset.getParameterNames();
324  vector<string>::const_iterator iter;
325 
326  for (iter = names.begin(); iter != names.end(); ++iter) {
327  if (targetPset.existsAs<T>(*iter, true)) // target is tracked
328  m[*iter] = targetPset.getParameter<T>(*iter);
329  else if (targetPset.existsAs<T>(*iter, false)) // target is untracked
330  m[*iter] = targetPset.getUntrackedParameter<T>(*iter);
331  }
332 }
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 336 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.

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

◆ selectedMuons()

MuonCollection HLTMuonMatchAndPlot::selectedMuons ( const reco::MuonCollection allMuons,
const reco::BeamSpot beamSpot,
bool  isTargetMuons 
)
private

Definition at line 375 of file HLTMuonMatchAndPlot.cc.

References funct::abs(), allMuons_cfi::allMuons, pwdgSkimBPark_cfi::beamSpot, TrackSplittingMonitor_cfi::d0Cut, amptDefaultParameters_cff::mu, probeD0Cut_, probeIsMuonGlb_, probeMuonEtaMax_, probeMuonEtaMin_, probeZ0Cut_, targetD0Cut_, targetIsMuonGlb_, targetMuonEtaMax_, targetMuonEtaMin_, targetZ0Cut_, HLT_2022v12_cff::track, and HLTMuonOfflineAnalyzer_cff::z0Cut.

Referenced by analyze().

377  {
378  MuonCollection reducedMuons;
379  double RecoMuonEtaMax = isTargetMuons ? targetMuonEtaMax_ : probeMuonEtaMax_;
380  double RecoMuonEtaMin = isTargetMuons ? targetMuonEtaMin_ : probeMuonEtaMin_;
381  bool IsMuonGlb = isTargetMuons ? targetIsMuonGlb_ : probeIsMuonGlb_;
382  double d0Cut = isTargetMuons ? targetD0Cut_ : probeD0Cut_;
383  double z0Cut = isTargetMuons ? targetZ0Cut_ : probeZ0Cut_;
384 
385  for (auto const& mu : allMuons) {
386  const Track* track = nullptr;
387  if (mu.isTrackerMuon())
388  track = &*mu.innerTrack();
389  else if (mu.isStandAloneMuon())
390  track = &*mu.outerTrack();
391  // minimun ID (requested for cosmics) is being a StandAlone muon
392  bool muID = IsMuonGlb ? mu.isGlobalMuon() : mu.isStandAloneMuon();
393  if (track && muID && abs(mu.eta()) < RecoMuonEtaMax && abs(mu.eta()) >= RecoMuonEtaMin &&
394  fabs(track->dxy(beamSpot.position())) < d0Cut && 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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ selectedTriggerObjects()

TriggerObjectCollection HLTMuonMatchAndPlot::selectedTriggerObjects ( const trigger::TriggerObjectCollection triggerObjects,
const trigger::TriggerEvent triggerSummary 
)
private

Definition at line 401 of file HLTMuonMatchAndPlot.cc.

References funct::abs(), trigger::TriggerObject::eta(), hltProcessName_, crabWrapper::key, relativeConstraints::keys, moduleLabel_, triggerEtaMaxCut_, triggerEtaMinCut_, triggerMatchMonitor_cfi::triggerObjects, and HLTMuonOfflineAnalyzer_cfi::triggerSummary.

Referenced by analyze().

402  {
403  InputTag filterTag(moduleLabel_, "", hltProcessName_);
404  size_t filterIndex = triggerSummary.filterIndex(filterTag);
405 
406  TriggerObjectCollection selectedObjects;
407  if (filterIndex < triggerSummary.sizeFilters()) {
408  const Keys& keys = triggerSummary.filterKeys(filterIndex);
409  for (unsigned short key : keys) {
410  TriggerObject foundObject = triggerObjects[key];
411  if (abs(foundObject.eta()) < triggerEtaMaxCut_ && abs(foundObject.eta()) >= triggerEtaMinCut_)
412  selectedObjects.push_back(foundObject);
413  }
414  }
415 
416  return selectedObjects;
417 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 92 of file HLTMuonMatchAndPlot.h.

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

◆ cutMinPt_

unsigned int HLTMuonMatchAndPlot::cutMinPt_
private

Definition at line 99 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

◆ destination_

std::string HLTMuonMatchAndPlot::destination_
private

Definition at line 90 of file HLTMuonMatchAndPlot.h.

Referenced by beginRun().

◆ hists_

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

Definition at line 103 of file HLTMuonMatchAndPlot.h.

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

◆ hltPath_

std::string HLTMuonMatchAndPlot::hltPath_
private

Definition at line 100 of file HLTMuonMatchAndPlot.h.

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

◆ hltProcessName_

std::string HLTMuonMatchAndPlot::hltProcessName_
private

Definition at line 89 of file HLTMuonMatchAndPlot.h.

Referenced by selectedTriggerObjects().

◆ isLastFilter_

bool HLTMuonMatchAndPlot::isLastFilter_
private

Definition at line 102 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 93 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

◆ probeD0Cut_

double HLTMuonMatchAndPlot::probeD0Cut_
private

Definition at line 116 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ probeIsMuonGlb_

bool HLTMuonMatchAndPlot::probeIsMuonGlb_
private

Definition at line 114 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ probeMuonEtaMax_

double HLTMuonMatchAndPlot::probeMuonEtaMax_
private

Definition at line 112 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ probeMuonEtaMin_

double HLTMuonMatchAndPlot::probeMuonEtaMin_
private

Definition at line 113 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ probeParams_

edm::ParameterSet HLTMuonMatchAndPlot::probeParams_
private

Definition at line 95 of file HLTMuonMatchAndPlot.h.

◆ probeZ0Cut_

double HLTMuonMatchAndPlot::probeZ0Cut_
private

Definition at line 115 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ requiredTriggers_

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

Definition at line 91 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

◆ targetD0Cut_

double HLTMuonMatchAndPlot::targetD0Cut_
private

Definition at line 109 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ targetIsMuonGlb_

bool HLTMuonMatchAndPlot::targetIsMuonGlb_
private

Definition at line 107 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ targetMuonEtaMax_

double HLTMuonMatchAndPlot::targetMuonEtaMax_
private

Definition at line 105 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ targetMuonEtaMin_

double HLTMuonMatchAndPlot::targetMuonEtaMin_
private

Definition at line 106 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ targetParams_

edm::ParameterSet HLTMuonMatchAndPlot::targetParams_
private

Definition at line 94 of file HLTMuonMatchAndPlot.h.

◆ targetptCutJpsi_

double HLTMuonMatchAndPlot::targetptCutJpsi_
private

Definition at line 111 of file HLTMuonMatchAndPlot.h.

◆ targetptCutZ_

double HLTMuonMatchAndPlot::targetptCutZ_
private

Definition at line 110 of file HLTMuonMatchAndPlot.h.

◆ targetZ0Cut_

double HLTMuonMatchAndPlot::targetZ0Cut_
private

Definition at line 108 of file HLTMuonMatchAndPlot.h.

Referenced by selectedMuons().

◆ triggerEtaMaxCut_

double HLTMuonMatchAndPlot::triggerEtaMaxCut_
private

Definition at line 117 of file HLTMuonMatchAndPlot.h.

Referenced by selectedTriggerObjects().

◆ triggerEtaMinCut_

double HLTMuonMatchAndPlot::triggerEtaMinCut_
private

Definition at line 118 of file HLTMuonMatchAndPlot.h.

Referenced by selectedTriggerObjects().

◆ triggerLevel_

std::string HLTMuonMatchAndPlot::triggerLevel_
private

Definition at line 98 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().