CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::Muon
probeMuonSelector_
 
edm::ParameterSet probeParams_
 
double probeZ0Cut_
 
std::vector< std::string > requiredTriggers_
 
double targetD0Cut_
 
StringCutObjectSelector
< reco::Muon
targetMuonSelector_
 
edm::ParameterSet targetParams_
 
double targetptCutJpsi_
 
double targetptCutZ_
 
double targetZ0Cut_
 
std::string triggerLevel_
 
StringCutObjectSelector
< trigger::TriggerObject
triggerSelector_
 

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

Definition at line 59 of file HLTMuonMatchAndPlot.h.

Definition at line 60 of file HLTMuonMatchAndPlot.h.

Constructor & Destructor Documentation

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_, 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")),
43  hltPath_(std::move(hltPath)),
44  moduleLabel_(std::move(moduleLabel)),
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)
T getUntrackedParameter(std::string const &, T const &) const
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_
void fillMapFromPSet(std::map< std::string, T > &, const edm::ParameterSet &, const std::string &)
def move
Definition: eostools.py:511
StringCutObjectSelector< reco::Muon > targetMuonSelector_
edm::ParameterSet probeParams_
StringCutObjectSelector< trigger::TriggerObject > triggerSelector_
std::map< std::string, double > plotCuts_

Member Function Documentation

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 reco::LeafCandidate::charge(), cutMinPt_, EFFICIENCY_SUFFIXES, reco::LeafCandidate::eta(), hasProbeRecoCuts, hasTargetRecoCuts, hasTriggerCuts_, hists_, hltPath_, mps_fire::i, reco::Muon::innerTrack(), isLastFilter_, reco::Muon::isStandAloneMuon(), reco::Muon::isTrackerMuon(), matchByDeltaR(), HLT_FULL_cff::muon, reco::Muon::outerTrack(), reco::LeafCandidate::phi(), plotCuts_, probeD0Cut_, probeMuonSelector_, probeZ0Cut_, reco::LeafCandidate::pt(), requiredTriggers_, selectedMuons(), selectedTriggerObjects(), edm::TriggerNames::size(), makePlotsFromDump::suffix, targetD0Cut_, targetMuonSelector_, targetZ0Cut_, HLT_FULL_cff::track, triggerLevel_, edm::TriggerNames::triggerName(), and triggerSelector_.

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();
178  TriggerObjectCollection hltMuons =
179  selectedTriggerObjects(allTriggerObjects, *triggerSummary, hasTriggerCuts_, triggerSelector_);
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.
std::size_t size() const
Definition: TriggerNames.cc:59
reco::MuonCollection selectedMuons(const reco::MuonCollection &, const reco::BeamSpot &, bool, const StringCutObjectSelector< reco::Muon > &, double, double)
StringCutObjectSelector< reco::Muon > probeMuonSelector_
double pt() const final
transverse momentum
const std::string EFFICIENCY_SUFFIXES[2]
virtual TrackRef innerTrack() const
Definition: Muon.h:45
std::map< std::string, MonitorElement * > hists_
bool isTrackerMuon() const override
Definition: Muon.h:302
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)
trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &, bool hasTriggerCuts, const StringCutObjectSelector< trigger::TriggerObject > &triggerSelector)
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:48
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
StringCutObjectSelector< reco::Muon > targetMuonSelector_
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:50
StringCutObjectSelector< trigger::TriggerObject > triggerSelector_
double phi() const final
momentum azimuthal angle
std::map< std::string, double > plotCuts_
int charge() const final
electric charge
bool isStandAloneMuon() const override
Definition: Muon.h:303
double eta() const final
momentum pseudorapidity
void HLTMuonMatchAndPlot::beginRun ( DQMStore::IBooker iBooker,
const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 85 of file HLTMuonMatchAndPlot.cc.

References 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)
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(), fillEdges(), hists_, and mergeVDriftHistosByStation::name.

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)
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_, and mergeVDriftHistosByStation::name.

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)
void HLTMuonMatchAndPlot::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 125 of file HLTMuonMatchAndPlot.cc.

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

Definition at line 286 of file HLTMuonMatchAndPlot.cc.

References mps_fire::i, and SiStripPI::min.

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 }
tuple binning
Definition: pileupCalc.py:163
Log< level::Warning, false > LogWarning
template<class T >
void HLTMuonMatchAndPlot::fillMapFromPSet ( std::map< std::string, T > &  ,
const edm::ParameterSet ,
const std::string &   
)

Referenced by HLTMuonMatchAndPlot().

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::getParameterSet(), edm::ParameterSet::getUntrackedParameter(), edm::ParameterSet::getUntrackedParameterSet(), and names.

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 getUntrackedParameter(std::string const &, T const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
const std::string names[nVars_]
std::vector< std::string > getParameterNames() const
ParameterSet const & getParameterSet(std::string const &) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
long double T
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().

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 HLT_FULL_cff::deltaR, mps_fire::i, dqmiolumiharvest::j, isotrackApplyRegressor::k, HLT_FULL_cff::maxDeltaR, HLT_FULL_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 }
tuple result
Definition: mps_fire.py:311
const double NOMATCH
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 reco::TrackBase::dxy(), reco::TrackBase::dz(), RPCpg::mu, reco::BeamSpot::position(), and HLT_FULL_cff::track.

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
tuple allMuons
Definition: allMuons_cfi.py:3
const int mu
Definition: Constants.h:22
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
const Point & position() const
position
Definition: BeamSpot.h:59
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:608
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 trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), hltProcessName_, submitPVResolutionJobs::key, relativeConstraints::keys, moduleLabel_, and trigger::TriggerEvent::sizeFilters().

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 }
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:146
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:132
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
tuple 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

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

Definition at line 103 of file HLTMuonMatchAndPlot.h.

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

unsigned int HLTMuonMatchAndPlot::cutMinPt_
private

Definition at line 110 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

std::string HLTMuonMatchAndPlot::destination_
private

Definition at line 101 of file HLTMuonMatchAndPlot.h.

Referenced by beginRun().

bool HLTMuonMatchAndPlot::hasProbeRecoCuts
private

Definition at line 118 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

bool HLTMuonMatchAndPlot::hasTargetRecoCuts
private

Definition at line 117 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

bool HLTMuonMatchAndPlot::hasTriggerCuts_
private

Definition at line 130 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 114 of file HLTMuonMatchAndPlot.h.

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

std::string HLTMuonMatchAndPlot::hltPath_
private

Definition at line 111 of file HLTMuonMatchAndPlot.h.

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

std::string HLTMuonMatchAndPlot::hltProcessName_
private

Definition at line 100 of file HLTMuonMatchAndPlot.h.

Referenced by selectedTriggerObjects().

bool HLTMuonMatchAndPlot::isLastFilter_
private

Definition at line 113 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and beginRun().

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

Definition at line 104 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

double HLTMuonMatchAndPlot::probeD0Cut_
private

Definition at line 127 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 125 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

edm::ParameterSet HLTMuonMatchAndPlot::probeParams_
private

Definition at line 106 of file HLTMuonMatchAndPlot.h.

double HLTMuonMatchAndPlot::probeZ0Cut_
private

Definition at line 126 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 102 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

double HLTMuonMatchAndPlot::targetD0Cut_
private

Definition at line 122 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 120 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

edm::ParameterSet HLTMuonMatchAndPlot::targetParams_
private

Definition at line 105 of file HLTMuonMatchAndPlot.h.

double HLTMuonMatchAndPlot::targetptCutJpsi_
private

Definition at line 124 of file HLTMuonMatchAndPlot.h.

double HLTMuonMatchAndPlot::targetptCutZ_
private

Definition at line 123 of file HLTMuonMatchAndPlot.h.

double HLTMuonMatchAndPlot::targetZ0Cut_
private

Definition at line 121 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

std::string HLTMuonMatchAndPlot::triggerLevel_
private

Definition at line 109 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

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

Definition at line 129 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().