CMS 3D CMS Logo

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::MuonprobeMuonSelector_
 
edm::ParameterSet probeParams_
 
double probeZ0Cut_
 
std::vector< std::string > requiredTriggers_
 
double targetD0Cut_
 
StringCutObjectSelector< reco::MuontargetMuonSelector_
 
edm::ParameterSet targetParams_
 
double targetptCutJpsi_
 
double targetptCutZ_
 
double targetZ0Cut_
 
std::string triggerLevel_
 
StringCutObjectSelector< trigger::TriggerObjecttriggerSelector_
 

Detailed Description

Match reconstructed muons to HLT objects and plot efficiencies.

Note that this is not a true EDAnalyzer;

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

Author
J. Slaunwhite, Jeff Klukas

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

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

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

Author
C. Battilana

Definition at line 61 of file HLTMuonMatchAndPlot.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 35 of file HLTMuonMatchAndPlot.cc.

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

37  :
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")),
44  moduleLabel_(moduleLabel),
45  isLastFilter_(islastfilter),
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 {
59  // Create std::map<string, T> from ParameterSets.
60  fillMapFromPSet(binParams_, pset, "binParams");
61  fillMapFromPSet(plotCuts_, pset, "plotCuts");
62 
63  // Get the trigger level.
64  triggerLevel_ = "L3";
65  TPRegexp levelRegexp("L[1-3]");
66  // size_t nModules = moduleLabels_.size();
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  TObjString * ptCutString = (TObjString *)objArray->At(1);
79  cutMinPt_ = atoi(ptCutString->GetString());
80  cutMinPt_ = ceil(cutMinPt_ * plotCuts_["minPtFactor"]);
81  }
82  delete objArray;
83 
84 }
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 163 of file HLTMuonMatchAndPlot.cc.

References reco::LeafCandidate::charge(), cutMinPt_, allConversions_cfi::d0, deltaR(), reco::TrackBase::dxy(), reco::TrackBase::dz(), EFFICIENCY_SUFFIXES, stringResolutionProvider_cfi::eta, trigger::TriggerObject::eta(), reco::LeafCandidate::eta(), trigger::TriggerEvent::getObjects(), hasProbeRecoCuts, hasTargetRecoCuts, hasTriggerCuts_, hists_, i, reco::Muon::innerTrack(), isLastFilter_, reco::Muon::isStandAloneMuon(), reco::Muon::isTrackerMuon(), j, gen::k, ResonanceBuilder::mass, matchByDeltaR(), matches, reco::Muon::outerTrack(), reco::LeafCandidate::p4(), phi, trigger::TriggerObject::phi(), reco::LeafCandidate::phi(), plotCuts_, reco::BeamSpot::position(), probeD0Cut_, probeMuonSelector_, probeZ0Cut_, EnergyCorrector::pt, trigger::TriggerObject::pt(), reco::LeafCandidate::pt(), selectedMuons(), selectedTriggerObjects(), createPayload::suffix, targetD0Cut_, targetMuonSelector_, targetptCutJpsi_, targetptCutZ_, targetZ0Cut_, HiIsolationCommonParameters_cff::track, triggerLevel_, and triggerSelector_.

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

Definition at line 86 of file HLTMuonMatchAndPlot.cc.

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

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

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

Referenced by beginRun().

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

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

Referenced by beginRun().

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

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

Definition at line 364 of file HLTMuonMatchAndPlot.cc.

References i, and min().

Referenced by book1D(), and book2D().

366 {
367 
368  if (binning.size() < 3) {
369  LogWarning("HLTMuonVal") << "Invalid binning parameters!";
370  return;
371  }
372 
373  // Fixed-width binning.
374  if (binning.size() == 3) {
375  nBins = binning[0];
376  edges = new float[nBins + 1];
377  const double min = binning[1];
378  const double binwidth = (binning[2] - binning[1]) / nBins;
379  for (size_t i = 0; i <= nBins; i++) edges[i] = min + (binwidth * i);
380  }
381 
382  // Variable-width binning.
383  else {
384  nBins = binning.size() - 1;
385  edges = new float[nBins + 1];
386  for (size_t i = 0; i <= nBins; i++) edges[i] = binning[i];
387  }
388 
389 }
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 398 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.

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

References deltaR(), i, j, gen::k, electronMatch_cfi::maxDeltaR, NOMATCH, and mps_fire::result.

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

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

Referenced by analyze().

477 {
478 
479  // If there is no selector (recoCuts does not exists), return an empty collection.
480  if (!hasRecoCuts)
481  return MuonCollection();
482 
483  MuonCollection reducedMuons;
484  for (auto const& mu : allMuons){
485  const Track * track = 0;
486  if (mu.isTrackerMuon()) track = & * mu.innerTrack();
487  else if (mu.isStandAloneMuon()) track = & * mu.outerTrack();
488  if (track && selector(mu) &&
489  fabs(track->dxy(beamSpot.position())) < d0Cut &&
490  fabs(track->dz(beamSpot.position())) < z0Cut)
491  reducedMuons.push_back(mu);
492  }
493 
494  return reducedMuons;
495 
496 }
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
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 501 of file HLTMuonMatchAndPlot.cc.

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

Referenced by analyze().

506 {
507  if ( !hasTriggerCuts) return TriggerObjectCollection();
508 
509  InputTag filterTag(moduleLabel_, "", hltProcessName_);
510  size_t filterIndex = triggerSummary.filterIndex(filterTag);
511 
512  TriggerObjectCollection selectedObjects;
513 
514  if (filterIndex < triggerSummary.sizeFilters()) {
515  const Keys &keys = triggerSummary.filterKeys(filterIndex);
516  for (size_t j = 0; j < keys.size(); j++ ){
517  TriggerObject foundObject = triggerObjects[keys[j]];
518  if (triggerSelector(foundObject))
519  selectedObjects.push_back(foundObject);
520  }
521  }
522 
523  return selectedObjects;
524 
525 }
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
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().