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 &)
 
bool 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:7
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 132 of file HLTMuonMatchAndPlot.cc.

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

137  {
138  /*
139  if(gen != 0) {
140  for(g_part = gen->begin(); g_part != gen->end(); g_part++){
141  if( abs(g_part->pdgId()) == 13) {
142  if(!( g_part->status() ==1 || (g_part->status() ==2 && abs(g_part->pdgId())==5))) continue;
143  bool GenMomExists (true);
144  bool GenGrMomExists(true);
145  if( g_part->pt() < 10.0 ) continue;
146  if( fabs(g_part->eta()) > 2.4 ) continue;
147  int gen_id= g_part->pdgId();
148  const GenParticle* gen_lept = &(*g_part);
149  // get mother of gen_lept
150  const GenParticle* gen_mom = static_cast<const GenParticle*> (gen_lept->mother());
151  if(gen_mom==NULL) GenMomExists=false;
152  int m_id=-999;
153  if(GenMomExists) m_id = gen_mom->pdgId();
154  if(m_id != gen_id || !GenMomExists);
155  else{
156  int id= m_id;
157  while(id == gen_id && GenMomExists){
158  gen_mom = static_cast<const GenParticle*> (gen_mom->mother());
159  if(gen_mom==NULL){
160  GenMomExists=false;
161  }
162  if(GenMomExists) id=gen_mom->pdgId();
163  }
164  }
165  if(GenMomExists) m_id = gen_mom->pdgId();
166  gen_leptsp.push_back(gen_lept);
167  gen_momsp.push_back(gen_mom);
168  }
169  }
170  }
171  std::vector<GenParticle> gen_lepts;
172  for(size_t i = 0; i < gen_leptsp.size(); i++) {
173  gen_lepts.push_back(*gen_leptsp[i]);
174  }
175  */
176 
177  // Select objects based on the configuration.
178  MuonCollection targetMuons = selectedMuons(*allMuons, *beamSpot, true);
179  MuonCollection probeMuons = selectedMuons(*allMuons, *beamSpot, false);
180  TriggerObjectCollection allTriggerObjects = triggerSummary->getObjects();
182  // Fill plots for HLT muons.
183 
184  // Find the best trigger object matches for the targetMuons.
185  vector<size_t> matches = matchByDeltaR(targetMuons, hltMuons, plotCuts_[triggerLevel_ + "DeltaR"]);
186 
187  // Fill plots for matched muons.
188  for (size_t i = 0; i < targetMuons.size(); i++) {
189  Muon& muon = targetMuons[i];
190 
191  // Fill numerators and denominators for efficiency plots.
192  for (const auto& suffix : EFFICIENCY_SUFFIXES) {
193  // If no match was found, then the numerator plots don't get filled.
194  if (suffix == "numer" && matches[i] >= targetMuons.size())
195  continue;
196 
197  if (muon.pt() > cutMinPt_) {
198  hists_["efficiencyEta_" + suffix]->Fill(muon.eta());
199  }
200 
201  if (fabs(muon.eta()) < plotCuts_["maxEta"]) {
202  hists_["efficiencyTurnOn_" + suffix]->Fill(muon.pt());
203  }
204 
205  if (muon.pt() > cutMinPt_ && fabs(muon.eta()) < plotCuts_["maxEta"]) {
206  const Track* track = nullptr;
207  if (muon.isTrackerMuon())
208  track = &*muon.innerTrack();
209  else if (muon.isStandAloneMuon())
210  track = &*muon.outerTrack();
211  if (track) {
212  hists_["efficiencyNVertex_" + suffix]->Fill(vertices->size());
213  hists_["efficiencyPhi_" + suffix]->Fill(muon.phi());
214 
215  if (isLastFilter_) {
216  hists_["efficiencyZ0_" + suffix]->Fill(track->dz(beamSpot->position()));
217  hists_["efficiencyCharge_" + suffix]->Fill(muon.charge());
218  }
219  }
220  }
221  } // finish loop numerator / denominator...
222 
223  if (!isLastFilter_)
224  continue;
225  // Fill plots for tag and probe
226  // Muon cannot be a tag because doesn't match an hlt muon
227  if (matches[i] >= targetMuons.size())
228  continue;
229  } // End loop over targetMuons.
230 
231  // fill eff histograms for reference trigger method
232  // Denominator: events passing reference trigger and two target muons
233  // Numerator: events in the denominator with two target muons
234  // matched to hlt muons
235  if (!isLastFilter_)
236  return;
237  unsigned int numTriggers = trigNames.size();
238 
239  int nMatched = 0;
240  for (unsigned long matche : matches) {
241  if (matche < targetMuons.size())
242  nMatched++;
243  }
244 
245  string nonDZPath = hltPath_;
246  bool dzPath = false;
247  if (nonDZPath.rfind("_DZ") < nonDZPath.length()) {
248  dzPath = true;
249  nonDZPath = boost::replace_all_copy<string>(nonDZPath, "_DZ", "");
250  nonDZPath = nonDZPath.substr(0, nonDZPath.rfind("_v") + 2);
251  }
252  bool passTriggerDZ = false;
253 
254  if (dzPath) {
255  for (unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
256  passTriggerDZ = passTriggerDZ || (trigNames.triggerName(hltIndex).find(nonDZPath) != std::string::npos &&
257  triggerResults->wasrun(hltIndex) && triggerResults->accept(hltIndex));
258  }
259  }
260  if (dzPath && targetMuons.size() > 1 && passTriggerDZ) {
261  const Track* track0 = nullptr;
262  const Track* track1 = nullptr;
263  if (targetMuons.at(0).isTrackerMuon())
264  track0 = &*targetMuons.at(0).innerTrack();
265  else if (targetMuons.at(0).isStandAloneMuon())
266  track0 = &*targetMuons.at(0).outerTrack();
267  if (targetMuons.at(1).isTrackerMuon())
268  track1 = &*targetMuons.at(1).innerTrack();
269  else if (targetMuons.at(1).isStandAloneMuon())
270  track1 = &*targetMuons.at(1).outerTrack();
271 
272  if (track0 && track1) {
273  hists_["efficiency_DZ_Mu_denom"]->Fill(track0->dz(beamSpot->position()) - track1->dz(beamSpot->position()));
274  if (nMatched > 1) {
275  hists_["efficiency_DZ_Mu_numer"]->Fill(track0->dz(beamSpot->position()) - track1->dz(beamSpot->position()));
276  }
277  }
278  }
279 
280 } // 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
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:622
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:47
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  book1D(iBooker, "efficiencyNVertex_" + suffix, "NVertex", ";NVertex;");
115 
116  if (isLastFilter_)
117  iBooker.setCurrentFolder(baseDir + pathSansSuffix);
118  else
119  iBooker.setCurrentFolder(baseDir + pathSansSuffix + "/" + moduleLabel_);
120 
121  if (!isLastFilter_)
122  continue; //this will be plotted only for the last filter
123 
124  book1D(iBooker, "efficiencyCharge_" + suffix, "charge", ";charge;");
125  book1D(iBooker, "efficiencyZ0_" + suffix, "z0", ";z0;");
126  book1D(iBooker, "efficiency_DZ_Mu_" + suffix, "z0", ";z0;");
127  }
128 }
const std::string EFFICIENCY_SUFFIXES[2]
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
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 418 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().

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

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

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

130 {}

◆ fillEdges()

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

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

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

313  {
314  // Get the ParameterSet with name 'target' from 'pset'
315  ParameterSet targetPset;
316  if (pset.existsAs<ParameterSet>(target, true)) // target is tracked
317  targetPset = pset.getParameterSet(target);
318  else if (pset.existsAs<ParameterSet>(target, false)) // target is untracked
319  targetPset = pset.getUntrackedParameterSet(target);
320 
321  // Get the parameter names from targetPset
322  vector<string> names = targetPset.getParameterNames();
323  vector<string>::const_iterator iter;
324 
325  for (iter = names.begin(); iter != names.end(); ++iter) {
326  if (targetPset.existsAs<T>(*iter, true)) // target is tracked
327  m[*iter] = targetPset.getParameter<T>(*iter);
328  else if (targetPset.existsAs<T>(*iter, false)) // target is untracked
329  m[*iter] = targetPset.getUntrackedParameter<T>(*iter);
330  }
331 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:172
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 335 of file HLTMuonMatchAndPlot.cc.

References l1tGTMenu_hadr_metSeeds_cff::collection1, l1tGTMenu_hadr_metSeeds_cff::collection2, PbPb_ZMuSkimMuonDPG_cff::deltaR, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, ewkMuLumiMonitorDQM_cfi::maxDeltaR, HLT_2024v14_cff::minDeltaR, NOMATCH, and mps_fire::result.

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

◆ selectedMuons()

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

Definition at line 374 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_2024v14_cff::track, and HLTMuonOfflineAnalyzer_cff::z0Cut.

Referenced by analyze().

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

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

Referenced by analyze().

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

◆ 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().