CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HLTMuonMatchAndPlot Class Reference

#include <HLTMuonMatchAndPlot.h>

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 > &)
 
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 &, std::string)
 
template<class T >
void fillMapFromPSet (map< string, T > &m, const ParameterSet &pset, 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, std::string, std::string)
 
void book2D (DQMStore::IBooker &, std::string, std::string, std::string, 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 61 of file HLTMuonMatchAndPlot.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 34 of file HLTMuonMatchAndPlot.cc.

References binParams_, cutMinPt_, fillMapFromPSet(), hltPath_, moduleLabel_, plotCuts_, and triggerLevel_.

36  :
37  hltProcessName_(pset.getParameter<string>("hltProcessName")),
38  destination_(pset.getUntrackedParameter<string>("destination")),
39  requiredTriggers_(pset.getUntrackedParameter<vstring>("requiredTriggers")),
40  targetParams_(pset.getParameterSet("targetParams")),
41  probeParams_(pset.getParameterSet("probeParams")),
42  hltPath_(hltPath),
43  moduleLabel_(moduleLabel),
44  isLastFilter_(islastfilter),
50  targetptCutZ_(targetParams_.getUntrackedParameter<double>("ptCut_Z",20.)),
51  targetptCutJpsi_(targetParams_.getUntrackedParameter<double>("ptCut_Jpsi",20.)),
52  probeMuonSelector_(probeParams_.getUntrackedParameter<string>("recoCuts", "")),
53  probeZ0Cut_(probeParams_.getUntrackedParameter<double>("z0Cut",0.)),
54  probeD0Cut_(probeParams_.getUntrackedParameter<double>("d0Cut",0.)),
57 {
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  TObjArray * levelArray = levelRegexp.MatchS(moduleLabel_);
67  if (levelArray->GetEntriesFast() > 0) {
68  triggerLevel_ = ((TObjString *)levelArray->At(0))->GetString();
69  }
70  delete levelArray;
71 
72  // Get the pT cut by parsing the name of the HLT path.
73  cutMinPt_ = 3;
74  TPRegexp ptRegexp("Mu([0-9]*)");
75  TObjArray * objArray = ptRegexp.MatchS(hltPath_);
76  if (objArray->GetEntriesFast() >= 2) {
77  TObjString * ptCutString = (TObjString *)objArray->At(1);
78  cutMinPt_ = atoi(ptCutString->GetString());
79  cutMinPt_ = ceil(cutMinPt_ * plotCuts_["minPtFactor"]);
80  }
81  delete objArray;
82 
83 }
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 &, std::string)
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 
)

for (size_t i = 0; i < requiredTriggers_.size(); i++) { unsigned int triggerIndex = triggerResults->find(requiredTriggers_[i]); if (triggerIndex < triggerResults->size() || !triggerResults->accept(triggerIndex)) return; }

Definition at line 162 of file HLTMuonMatchAndPlot.cc.

References reco::LeafCandidate::charge(), cutMinPt_, deltaR(), reco::TrackBase::dxy(), reco::TrackBase::dz(), EFFICIENCY_SUFFIXES, eta, trigger::TriggerObject::eta(), reco::LeafCandidate::eta(), hasProbeRecoCuts, hasTargetRecoCuts, hasTriggerCuts_, hists_, HLT_FULL_cff::hltMuons, i, reco::Muon::innerTrack(), isLastFilter_, reco::Muon::isStandAloneMuon(), reco::Muon::isTrackerMuon(), j, relval_2017::k, ResonanceBuilder::mass, matchByDeltaR(), matches, metsig::muon, reco::Muon::outerTrack(), reco::LeafCandidate::p4(), phi, trigger::TriggerObject::phi(), reco::LeafCandidate::phi(), plotCuts_, probeD0Cut_, probeMuonSelector_, probeZ0Cut_, EnergyCorrector::pt, trigger::TriggerObject::pt(), reco::LeafCandidate::pt(), selectedMuons(), selectedTriggerObjects(), createPayload::suffix, targetD0Cut_, targetMuonSelector_, targetptCutJpsi_, targetptCutZ_, targetZ0Cut_, triggerLevel_, and triggerSelector_.

167 {
168  /*
169  if(gen != 0) {
170  for(g_part = gen->begin(); g_part != gen->end(); g_part++){
171  if( abs(g_part->pdgId()) == 13) {
172  if(!( g_part->status() ==1 || (g_part->status() ==2 && abs(g_part->pdgId())==5))) continue;
173  bool GenMomExists (true);
174  bool GenGrMomExists(true);
175  if( g_part->pt() < 10.0 ) continue;
176  if( fabs(g_part->eta()) > 2.4 ) continue;
177  int gen_id= g_part->pdgId();
178  const GenParticle* gen_lept = &(*g_part);
179  // get mother of gen_lept
180  const GenParticle* gen_mom = static_cast<const GenParticle*> (gen_lept->mother());
181  if(gen_mom==NULL) GenMomExists=false;
182  int m_id=-999;
183  if(GenMomExists) m_id = gen_mom->pdgId();
184  if(m_id != gen_id || !GenMomExists);
185  else{
186  int id= m_id;
187  while(id == gen_id && GenMomExists){
188  gen_mom = static_cast<const GenParticle*> (gen_mom->mother());
189  if(gen_mom==NULL){
190  GenMomExists=false;
191  }
192  if(GenMomExists) id=gen_mom->pdgId();
193  }
194  }
195  if(GenMomExists) m_id = gen_mom->pdgId();
196  gen_leptsp.push_back(gen_lept);
197  gen_momsp.push_back(gen_mom);
198  }
199  }
200  }
201 
202 
203  std::vector<GenParticle> gen_lepts;
204  for(size_t i = 0; i < gen_leptsp.size(); i++) {
205  gen_lepts.push_back(*gen_leptsp[i]);
206  }
207 
208 
209  */
210 
211 
212 
213  // Throw out this event if it doesn't pass the required triggers.
214  // this is not needed anymore rejecting if there is no filter...
221 
222 
223  // Select objects based on the configuration.
226  TriggerObjectCollection allTriggerObjects = triggerSummary->getObjects();
228  selectedTriggerObjects(allTriggerObjects, * triggerSummary, hasTriggerCuts_,triggerSelector_);
229 
230  // Fill plots for HLT muons.
231  if (isLastFilter_){
232  for (size_t i = 0; i < hltMuons.size(); i++) {
233  hists_["hltPt"]->Fill(hltMuons[i].pt());
234  hists_["hltEta"]->Fill(hltMuons[i].eta());
235  hists_["hltPhi"]->Fill(hltMuons[i].phi());
236  }
237  }
238  // Find the best trigger object matches for the targetMuons.
239  vector<size_t> matches = matchByDeltaR(targetMuons, hltMuons,
240  plotCuts_[triggerLevel_ + "DeltaR"]);
241 
242 
243  // Fill plots for matched muons.
244  bool pairalreadyconsidered = false;
245  for (size_t i = 0; i < targetMuons.size(); i++) {
246 
247  Muon & muon = targetMuons[i];
248 
249  // Fill plots which are not efficiencies.
250  if (matches[i] < targetMuons.size()) {
251  TriggerObject & hltMuon = hltMuons[matches[i]];
252  double ptRes = (muon.pt() - hltMuon.pt()) / muon.pt();
253  hists_["resolutionPt"]->Fill(ptRes);
254  hists_["deltaR"]->Fill(deltaR(muon, hltMuon));
255 
256  if (isLastFilter_){
257  double etaRes = muon.eta() - hltMuon.eta();
258  double phiRes = muon.phi() - hltMuon.phi();
259  hists_["resolutionEta"]->Fill(etaRes);
260  hists_["resolutionPhi"]->Fill(phiRes);
261  }
262  }
263 
264  // Fill numerators and denominators for efficiency plots.
265  for (size_t j = 0; j < 2; j++) {
266 
267  string suffix = EFFICIENCY_SUFFIXES[j];
268 
269  // If no match was found, then the numerator plots don't get filled.
270  if (suffix == "numer" && matches[i] >= targetMuons.size()) continue;
271 
272  if (muon.pt() > cutMinPt_) {
273  hists_["efficiencyEta_" + suffix]->Fill(muon.eta());
274  hists_["efficiencyPhiVsEta_" + suffix]->Fill(muon.eta(), muon.phi());
275  }
276 
277  if (fabs(muon.eta()) < plotCuts_["maxEta"]) {
278  hists_["efficiencyTurnOn_" + suffix]->Fill(muon.pt());
279  }
280 
281 
282  if (muon.pt() > cutMinPt_ && fabs(muon.eta()) < plotCuts_["maxEta"]) {
283  const Track * track = 0;
284  if (muon.isTrackerMuon()) track = & * muon.innerTrack();
285  else if (muon.isStandAloneMuon()) track = & * muon.outerTrack();
286  if (track) {
287  hists_["efficiencyVertex_" + suffix]->Fill(vertices->size());
288  hists_["efficiencyPhi_" + suffix]->Fill(muon.phi());
289 
290  if (isLastFilter_){
291  double d0 = track->dxy(beamSpot->position());
292  double z0 = track->dz(beamSpot->position());
293  hists_["efficiencyD0_" + suffix]->Fill(d0);
294  hists_["efficiencyZ0_" + suffix]->Fill(z0);
295  hists_["efficiencyCharge_" + suffix]->Fill(muon.charge());
296  }
297  }
298  }
299  } // finish loop numerator / denominator...
300 
301  if (!isLastFilter_) continue;
302  // Fill plots for tag and probe
303  // Muon cannot be a tag because doesn't match an hlt muon
304  if(matches[i] >= targetMuons.size()) continue;
305  for (size_t k = 0; k < targetMuons.size(); k++) {
306  if(k == i) continue;
307  Muon & theProbe = targetMuons[k];
308  if (muon.charge() != theProbe.charge() && !pairalreadyconsidered) {
309  double mass = (muon.p4() + theProbe.p4()).M();
310  if(mass > 60 && mass < 120) {
311  if(muon.pt() < targetptCutZ_) continue;
312  hists_["massVsEtaZ_denom"]->Fill(theProbe.eta());
313  hists_["massVsPtZ_denom"]->Fill(theProbe.pt());
314  hists_["massVsVertexZ_denom"]->Fill(vertices->size());
315  if(matches[k] < targetMuons.size()) {
316  hists_["massVsEtaZ_numer"]->Fill(theProbe.eta());
317  hists_["massVsPtZ_numer"]->Fill(theProbe.pt());
318  hists_["massVsVertexZ_numer"]->Fill(vertices->size());
319  }
320  pairalreadyconsidered = true;
321  }
322  if(mass > 1 && mass < 4) {
323  if(muon.pt() < targetptCutJpsi_) continue;
324  hists_["massVsEtaJpsi_denom"]->Fill(theProbe.eta());
325  hists_["massVsPtJpsi_denom"]->Fill(theProbe.pt());
326  hists_["massVsVertexJpsi_denom"]->Fill(vertices->size());
327  if(matches[k] < targetMuons.size()) {
328  hists_["massVsEtaJpsi_numer"]->Fill(theProbe.eta());
329  hists_["massVsPtJpsi_numer"]->Fill(theProbe.pt());
330  hists_["massVsVertexJpsi_numer"]->Fill(vertices->size());
331  }
332  pairalreadyconsidered = true;
333  }
334  }
335  } // End loop over denominator and numerator.
336  } // End loop over targetMuons.
337 
338  if (!isLastFilter_) return;
339  // Plot fake rates (efficiency for HLT objects to not get matched to RECO).
340  vector<size_t> hltMatches = matchByDeltaR(hltMuons, targetMuons,
341  plotCuts_[triggerLevel_ + "DeltaR"]);
342  for (size_t i = 0; i < hltMuons.size(); i++) {
343  TriggerObject & hltMuon = hltMuons[i];
344  bool isFake = hltMatches[i] > hltMuons.size();
345  for (size_t j = 0; j < 2; j++) {
346  string suffix = EFFICIENCY_SUFFIXES[j];
347  // If match is found, then numerator plots should not get filled
348  if (suffix == "numer" && ! isFake) continue;
349  hists_["fakerateVertex_" + suffix]->Fill(vertices->size());
350  hists_["fakerateEta_" + suffix]->Fill(hltMuon.eta());
351  hists_["fakeratePhi_" + suffix]->Fill(hltMuon.phi());
352  hists_["fakerateTurnOn_" + suffix]->Fill(hltMuon.pt());
353  } // End loop over numerator and denominator.
354  } // End loop over hltMuons.
355 
356 
357 } // End analyze() method.
int i
Definition: DBlmapReader.cc:9
reco::MuonCollection selectedMuons(const reco::MuonCollection &, const reco::BeamSpot &, bool, const StringCutObjectSelector< reco::Muon > &, double, double)
StringCutObjectSelector< reco::Muon > probeMuonSelector_
const std::string EFFICIENCY_SUFFIXES[2]
virtual TrackRef innerTrack() const
Definition: Muon.h:48
float phi() const
Definition: TriggerObject.h:58
bool isTrackerMuon() const
Definition: Muon.h:226
virtual double phi() const final
momentum azimuthal angle
std::map< std::string, MonitorElement * > hists_
float eta() const
Definition: TriggerObject.h:57
bool isStandAloneMuon() const
Definition: Muon.h:227
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &, bool hasTriggerCuts, const StringCutObjectSelector< trigger::TriggerObject > triggerSelector)
std::vector< size_t > matchByDeltaR(const std::vector< T1 > &, const std::vector< T2 > &, const double maxDeltaR=NOMATCH)
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
int j
Definition: DBlmapReader.cc:9
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
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:604
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
StringCutObjectSelector< reco::Muon > targetMuonSelector_
StringCutObjectSelector< trigger::TriggerObject > triggerSelector_
virtual double eta() const final
momentum pseudorapidity
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:586
std::map< std::string, double > plotCuts_
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
virtual double pt() const final
transverse momentum
void HLTMuonMatchAndPlot::beginRun ( DQMStore::IBooker iBooker,
const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 85 of file HLTMuonMatchAndPlot.cc.

References book1D(), book2D(), destination_, EFFICIENCY_SUFFIXES, hltPath_, i, isLastFilter_, moduleLabel_, DQMStore::IBooker::setCurrentFolder(), and createPayload::suffix.

88 {
89 
90  TPRegexp suffixPtCut("Mu[0-9]+$");
91 
92  string baseDir = destination_;
93  if (baseDir[baseDir.size() - 1] != '/') baseDir += '/';
94  string pathSansSuffix = hltPath_;
95  if (hltPath_.rfind("_v") < hltPath_.length())
96  pathSansSuffix = hltPath_.substr(0, hltPath_.rfind("_v"));
97 
98  if (isLastFilter_)
99  iBooker.setCurrentFolder(baseDir + pathSansSuffix);
100  else
101  iBooker.setCurrentFolder(baseDir + pathSansSuffix + "/" + moduleLabel_);
102 
103  // Form is book1D(name, binningType, title) where 'binningType' is used
104  // to fetch the bin settings from binParams_.
105  if (isLastFilter_){
106  book1D(iBooker, "hltPt", "pt", ";p_{T} of HLT object");
107  book1D(iBooker, "hltEta", "eta", ";#eta of HLT object");
108  book1D(iBooker, "hltPhi", "phi", ";#phi of HLT object");
109  book1D(iBooker, "resolutionEta", "resolutionEta", ";#eta^{reco}-#eta^{HLT};");
110  book1D(iBooker, "resolutionPhi", "resolutionPhi", ";#phi^{reco}-#phi^{HLT};");
111  }
112  book1D(iBooker, "deltaR", "deltaR", ";#Deltar(reco, HLT);");
113 
114  book1D(iBooker, "resolutionPt", "resolutionRel",
115  ";(p_{T}^{reco}-p_{T}^{HLT})/|p_{T}^{reco}|;");
116 
117  for (size_t i = 0; i < 2; i++) {
118 
119  string suffix = EFFICIENCY_SUFFIXES[i];
120 
121  book1D(iBooker, "efficiencyEta_" + suffix, "eta", ";#eta;");
122  book1D(iBooker, "efficiencyPhi_" + suffix, "phi", ";#phi;");
123  book1D(iBooker, "efficiencyTurnOn_" + suffix, "pt", ";p_{T};");
124  book1D(iBooker, "efficiencyVertex_" + suffix, "NVertex", ";NVertex;");
125 
126 
127  book2D(iBooker, "efficiencyPhiVsEta_" + suffix, "etaCoarse",
128  "phiCoarse", ";#eta;#phi");
129 
130  if (!isLastFilter_) continue; //this will be plotted only for the last filter
131 
132  book1D(iBooker, "efficiencyD0_" + suffix, "d0", ";d0;");
133  book1D(iBooker, "efficiencyZ0_" + suffix, "z0", ";z0;");
134  book1D(iBooker, "efficiencyCharge_" + suffix, "charge", ";charge;");
135 
136  book1D(iBooker, "fakerateEta_" + suffix, "eta", ";#eta;");
137  book1D(iBooker, "fakerateVertex_" + suffix, "NVertex", ";NVertex;");
138  book1D(iBooker, "fakeratePhi_" + suffix, "phi", ";#phi;");
139  book1D(iBooker, "fakerateTurnOn_" + suffix, "pt", ";p_{T};");
140 
141  book1D(iBooker, "massVsEtaZ_" + suffix, "etaCoarse", ";#eta");
142  book1D(iBooker, "massVsEtaJpsi_" + suffix, "etaCoarse", ";#eta");
143  book1D(iBooker, "massVsPtZ_" + suffix, "ptCoarse", ";p_{T}");
144  book1D(iBooker, "massVsPtJpsi_" + suffix, "ptCoarse", ";p_{T}");
145  book1D(iBooker, "massVsVertexZ_" + suffix, "NVertex", ";NVertex");
146  book1D(iBooker, "massVsVertexJpsi_" + suffix, "NVertex", ";NVertex");
147 
148  }
149 
150 }
int i
Definition: DBlmapReader.cc:9
const std::string EFFICIENCY_SUFFIXES[2]
void book2D(DQMStore::IBooker &, std::string, std::string, std::string, std::string)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
void book1D(DQMStore::IBooker &, std::string, std::string, std::string)
void HLTMuonMatchAndPlot::book1D ( DQMStore::IBooker ,
std::string  ,
std::string  ,
std::string   
)
private

Definition at line 528 of file HLTMuonMatchAndPlot.cc.

References binParams_, DQMStore::IBooker::book1D(), fillEdges(), hists_, and mergeVDriftHistosByStation::name.

Referenced by beginRun().

530 {
531 
532  /* Properly delete the array of floats that has been allocated on
533  * the heap by fillEdges. Avoid multiple copies and internal ROOT
534  * clones by simply creating the histograms directly in the DQMStore
535  * using the appropriate book1D method to handle the variable bins
536  * case. */
537 
538  size_t nBins;
539  float * edges = 0;
540  fillEdges(nBins, edges, binParams_[binningType]);
541 
542  hists_[name] = iBooker.book1D(name, title, nBins, edges);
543  if (hists_[name])
544  if (hists_[name]->getTH1F()->GetSumw2N())
545  hists_[name]->getTH1F()->Sumw2();
546 
547  if (edges)
548  delete [] edges;
549 
550 }
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 ,
std::string  ,
std::string  ,
std::string  ,
std::string   
)
private

Definition at line 555 of file HLTMuonMatchAndPlot.cc.

References binParams_, DQMStore::IBooker::book2D(), fillEdges(), hists_, and mergeVDriftHistosByStation::name.

Referenced by beginRun().

558 {
559 
560  /* Properly delete the arrays of floats that have been allocated on
561  * the heap by fillEdges. Avoid multiple copies and internal ROOT
562  * clones by simply creating the histograms directly in the DQMStore
563  * using the appropriate book2D method to handle the variable bins
564  * case. */
565 
566  size_t nBinsX;
567  float * edgesX = 0;
568  fillEdges(nBinsX, edgesX, binParams_[binningTypeX]);
569 
570  size_t nBinsY;
571  float * edgesY = 0;
572  fillEdges(nBinsY, edgesY, binParams_[binningTypeY]);
573 
574  hists_[name] = iBooker.book2D(name.c_str(), title.c_str(),
575  nBinsX, edgesX, nBinsY, edgesY);
576  if (hists_[name])
577  if (hists_[name]->getTH2F()->GetSumw2N())
578  hists_[name]->getTH2F()->Sumw2();
579 
580  if (edgesX)
581  delete [] edgesX;
582  if (edgesY)
583  delete [] edgesY;
584 
585 }
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 154 of file HLTMuonMatchAndPlot.cc.

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

Definition at line 363 of file HLTMuonMatchAndPlot.cc.

References i, and min().

Referenced by book1D(), and book2D().

365 {
366 
367  if (binning.size() < 3) {
368  LogWarning("HLTMuonVal") << "Invalid binning parameters!";
369  return;
370  }
371 
372  // Fixed-width binning.
373  if (binning.size() == 3) {
374  nBins = binning[0];
375  edges = new float[nBins + 1];
376  const double min = binning[1];
377  const double binwidth = (binning[2] - binning[1]) / nBins;
378  for (size_t i = 0; i <= nBins; i++) edges[i] = min + (binwidth * i);
379  }
380 
381  // Variable-width binning.
382  else {
383  nBins = binning.size() - 1;
384  edges = new float[nBins + 1];
385  for (size_t i = 0; i <= nBins; i++) edges[i] = binning[i];
386  }
387 
388 }
int i
Definition: DBlmapReader.cc:9
T min(T a, T b)
Definition: MathUtil.h:58
template<class T >
void HLTMuonMatchAndPlot::fillMapFromPSet ( std::map< std::string, T > &  ,
const edm::ParameterSet ,
std::string   
)

Referenced by HLTMuonMatchAndPlot().

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

Definition at line 397 of file HLTMuonMatchAndPlot.cc.

References edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::ParameterSet::getParameterSet(), edm::ParameterSet::getUntrackedParameter(), edm::ParameterSet::getUntrackedParameterSet(), and cscdqm::h::names.

399 {
400 
401  // Get the ParameterSet with name 'target' from 'pset'
402  ParameterSet targetPset;
403  if (pset.existsAs<ParameterSet>(target, true)) // target is tracked
404  targetPset = pset.getParameterSet(target);
405  else if (pset.existsAs<ParameterSet>(target, false)) // target is untracked
406  targetPset = pset.getUntrackedParameterSet(target);
407 
408  // Get the parameter names from targetPset
409  vector<string> names = targetPset.getParameterNames();
410  vector<string>::const_iterator iter;
411 
412  for (iter = names.begin(); iter != names.end(); ++iter) {
413  if (targetPset.existsAs<T>(* iter, true)) // target is tracked
414  m[* iter] = targetPset.getParameter<T>(* iter);
415  else if (targetPset.existsAs<T>(* iter, false)) // target is untracked
416  m[* iter] = targetPset.getUntrackedParameter<T>(* iter);
417  }
418 
419 }
T getParameter(std::string const &) const
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:186
static const HistoName names[]
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
std::vector< std::string > getParameterNames() const
ParameterSet const & getParameterSet(std::string const &) const
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 426 of file HLTMuonMatchAndPlot.cc.

References deltaR(), i, j, relval_2017::k, HLT_FULL_cff::minDeltaR, NOMATCH, and mps_fire::result.

429 {
430 
431  const size_t n1 = collection1.size();
432  const size_t n2 = collection2.size();
433 
434  vector<size_t> result(n1, -1);
435  vector<vector<double> > deltaRMatrix(n1, vector<double>(n2, NOMATCH));
436 
437  for (size_t i = 0; i < n1; i++)
438  for (size_t j = 0; j < n2; j++) {
439  deltaRMatrix[i][j] = deltaR(collection1[i], collection2[j]);
440  }
441 
442  // Run through the matrix n1 times to make sure we've found all matches.
443  for (size_t k = 0; k < n1; k++) {
444  size_t i_min = -1;
445  size_t j_min = -1;
446  double minDeltaR = maxDeltaR;
447  // find the smallest deltaR
448  for (size_t i = 0; i < n1; i++)
449  for (size_t j = 0; j < n2; j++)
450  if (deltaRMatrix[i][j] < minDeltaR) {
451  i_min = i;
452  j_min = j;
453  minDeltaR = deltaRMatrix[i][j];
454  }
455  // If a match has been made, save it and make those candidates unavailable.
456  if (minDeltaR < maxDeltaR) {
457  result[i_min] = j_min;
458  deltaRMatrix[i_min] = vector<double>(n2, NOMATCH);
459  for (size_t i = 0; i < n1; i++)
460  deltaRMatrix[i][j_min] = NOMATCH;
461  }
462  }
463 
464  return result;
465 
466 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: mps_fire.py:84
const double NOMATCH
int j
Definition: DBlmapReader.cc:9
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
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 471 of file HLTMuonMatchAndPlot.cc.

References reco::TrackBase::dxy(), reco::TrackBase::dz(), RPCpg::mu, and reco::BeamSpot::position().

Referenced by analyze().

476 {
477 
478  // If there is no selector (recoCuts does not exists), return an empty collection.
479  if (!hasRecoCuts)
480  return MuonCollection();
481 
482  MuonCollection reducedMuons;
483  for (auto const& mu : allMuons){
484  const Track * track = 0;
485  if (mu.isTrackerMuon()) track = & * mu.innerTrack();
486  else if (mu.isStandAloneMuon()) track = & * mu.outerTrack();
487  if (track && selector(mu) &&
488  fabs(track->dxy(beamSpot.position())) < d0Cut &&
489  fabs(track->dz(beamSpot.position())) < z0Cut)
490  reducedMuons.push_back(mu);
491  }
492 
493  return reducedMuons;
494 
495 }
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:604
const Point & position() const
position
Definition: BeamSpot.h:62
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:586
TriggerObjectCollection HLTMuonMatchAndPlot::selectedTriggerObjects ( const trigger::TriggerObjectCollection triggerObjects,
const trigger::TriggerEvent triggerSummary,
bool  hasTriggerCuts,
const StringCutObjectSelector< trigger::TriggerObject triggerSelector 
)
private

Definition at line 500 of file HLTMuonMatchAndPlot.cc.

References trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), hltProcessName_, j, relativeConstraints::keys, moduleLabel_, and trigger::TriggerEvent::sizeFilters().

Referenced by analyze().

505 {
506  if ( !hasTriggerCuts) return TriggerObjectCollection();
507 
508  InputTag filterTag(moduleLabel_, "", hltProcessName_);
509  size_t filterIndex = triggerSummary.filterIndex(filterTag);
510 
511  TriggerObjectCollection selectedObjects;
512 
513  if (filterIndex < triggerSummary.sizeFilters()) {
514  const Keys &keys = triggerSummary.filterKeys(filterIndex);
515  for (size_t j = 0; j < keys.size(); j++ ){
516  TriggerObject foundObject = triggerObjects[keys[j]];
517  if (triggerSelector(foundObject))
518  selectedObjects.push_back(foundObject);
519  }
520  }
521 
522  return selectedObjects;
523 
524 }
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
int j
Definition: DBlmapReader.cc:9
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
std::vector< size_type > Keys

Member Data Documentation

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

Definition at line 106 of file HLTMuonMatchAndPlot.h.

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

unsigned int HLTMuonMatchAndPlot::cutMinPt_
private

Definition at line 113 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

std::string HLTMuonMatchAndPlot::destination_
private

Definition at line 104 of file HLTMuonMatchAndPlot.h.

Referenced by beginRun().

bool HLTMuonMatchAndPlot::hasProbeRecoCuts
private

Definition at line 121 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

bool HLTMuonMatchAndPlot::hasTargetRecoCuts
private

Definition at line 120 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

bool HLTMuonMatchAndPlot::hasTriggerCuts_
private

Definition at line 133 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 117 of file HLTMuonMatchAndPlot.h.

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

std::string HLTMuonMatchAndPlot::hltPath_
private

Definition at line 114 of file HLTMuonMatchAndPlot.h.

Referenced by beginRun(), and HLTMuonMatchAndPlot().

std::string HLTMuonMatchAndPlot::hltProcessName_
private

Definition at line 103 of file HLTMuonMatchAndPlot.h.

Referenced by selectedTriggerObjects().

bool HLTMuonMatchAndPlot::isLastFilter_
private

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

Referenced by analyze(), and HLTMuonMatchAndPlot().

double HLTMuonMatchAndPlot::probeD0Cut_
private

Definition at line 130 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 128 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

edm::ParameterSet HLTMuonMatchAndPlot::probeParams_
private

Definition at line 109 of file HLTMuonMatchAndPlot.h.

double HLTMuonMatchAndPlot::probeZ0Cut_
private

Definition at line 129 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 105 of file HLTMuonMatchAndPlot.h.

double HLTMuonMatchAndPlot::targetD0Cut_
private

Definition at line 125 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 123 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

edm::ParameterSet HLTMuonMatchAndPlot::targetParams_
private

Definition at line 108 of file HLTMuonMatchAndPlot.h.

double HLTMuonMatchAndPlot::targetptCutJpsi_
private

Definition at line 127 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

double HLTMuonMatchAndPlot::targetptCutZ_
private

Definition at line 126 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

double HLTMuonMatchAndPlot::targetZ0Cut_
private

Definition at line 124 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

std::string HLTMuonMatchAndPlot::triggerLevel_
private

Definition at line 112 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

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

Definition at line 132 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().