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, const std::vector< std::string > &)
 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 &, const edm::ParameterSet &)
 

Private Attributes

std::map< std::string,
std::vector< double > > 
binParams_
 
unsigned int cutMinPt_
 
std::string destination_
 
bool hasProbeRecoCuts
 
bool hasTargetRecoCuts
 
std::map< std::string,
MonitorElement * > 
hists_
 
std::string hltPath_
 
std::string hltProcessName_
 
std::vector< std::string > moduleLabels_
 
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 targetZ0Cut_
 
std::string triggerLevel_
 

Detailed Description

Match reconstructed muons to HLT objects and plot efficiencies.

Note that this is not a true EDAnalyzer;

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

Author
J. Slaunwhite, Jeff Klukas

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

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

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

Author
C. Battilana

Definition at line 60 of file HLTMuonMatchAndPlot.h.

Constructor & Destructor Documentation

HLTMuonMatchAndPlot::HLTMuonMatchAndPlot ( const edm::ParameterSet ,
std::string  ,
const std::vector< std::string > &   
)

Constructor.

Definition at line 34 of file HLTMuonMatchAndPlot.cc.

References binParams_, cutMinPt_, fillMapFromPSet(), hltPath_, moduleLabels_, 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  moduleLabels_(moduleLabels),
49  probeMuonSelector_(probeParams_.getUntrackedParameter<string>("recoCuts", "")),
50  probeZ0Cut_(probeParams_.getUntrackedParameter<double>("z0Cut",0.)),
52 {
53 
54  // Create std::map<string, T> from ParameterSets.
55  fillMapFromPSet(binParams_, pset, "binParams");
56  fillMapFromPSet(plotCuts_, pset, "plotCuts");
57 
58  // Get the trigger level.
59  triggerLevel_ = "L3";
60  TPRegexp levelRegexp("L[1-3]");
61  size_t nModules = moduleLabels_.size();
62  TObjArray * levelArray = levelRegexp.MatchS(moduleLabels_[nModules - 1]);
63  if (levelArray->GetEntriesFast() > 0) {
64  triggerLevel_ = ((TObjString *)levelArray->At(0))->GetString();
65  }
66  delete levelArray;
67 
68  // Get the pT cut by parsing the name of the HLT path.
69  cutMinPt_ = 3;
70  TPRegexp ptRegexp("Mu([0-9]*)");
71  TObjArray * objArray = ptRegexp.MatchS(hltPath_);
72  if (objArray->GetEntriesFast() >= 2) {
73  TObjString * ptCutString = (TObjString *)objArray->At(1);
74  cutMinPt_ = atoi(ptCutString->GetString());
75  cutMinPt_ = ceil(cutMinPt_ * plotCuts_["minPtFactor"]);
76  }
77  delete objArray;
78 
79 }
T getUntrackedParameter(std::string const &, T const &) const
StringCutObjectSelector< reco::Muon > probeMuonSelector_
vector< string > vstring
Definition: ExoticaDQM.cc:75
edm::ParameterSet targetParams_
std::vector< std::string > moduleLabels_
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_
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 
)

Definition at line 147 of file HLTMuonMatchAndPlot.cc.

References reco::LeafCandidate::charge(), cutMinPt_, deltaR(), reco::TrackBase::dxy(), reco::TrackBase::dz(), EFFICIENCY_SUFFIXES, trigger::TriggerObject::eta(), eta(), reco::LeafCandidate::eta(), hasProbeRecoCuts, hasTargetRecoCuts, hists_, HLT_2013_cff::hltMuons, i, reco::Muon::innerTrack(), reco::Muon::isStandAloneMuon(), reco::Muon::isTrackerMuon(), j, gen::k, matchByDeltaR(), metsig::muon, reco::Muon::outerTrack(), reco::LeafCandidate::p4(), phi, trigger::TriggerObject::phi(), reco::LeafCandidate::phi(), plotCuts_, probeD0Cut_, probeMuonSelector_, probeZ0Cut_, RecoTauCleanerPlugins::pt, trigger::TriggerObject::pt(), reco::LeafCandidate::pt(), requiredTriggers_, selectedMuons(), selectedTriggerObjects(), findQualityFiles::size, createPayload::suffix, targetD0Cut_, targetMuonSelector_, targetParams_, targetZ0Cut_, and triggerLevel_.

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

Definition at line 81 of file HLTMuonMatchAndPlot.cc.

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

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

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

Referenced by beginRun().

511 {
512 
513  /* Properly delete the array of floats that has been allocated on
514  * the heap by fillEdges. Avoid multiple copies and internal ROOT
515  * clones by simply creating the histograms directly in the DQMStore
516  * using the appropriate book1D method to handle the variable bins
517  * case. */
518 
519  size_t nBins;
520  float * edges = 0;
521  fillEdges(nBins, edges, binParams_[binningType]);
522 
523  hists_[name] = iBooker.book1D(name, title, nBins, edges);
524  if (hists_[name])
525  if (hists_[name]->getTH1F()->GetSumw2N())
526  hists_[name]->getTH1F()->Sumw2();
527 
528  if (edges)
529  delete [] edges;
530 
531 }
std::map< std::string, std::vector< double > > binParams_
std::map< std::string, MonitorElement * > hists_
dictionary edges
TH1F * getTH1F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
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 536 of file HLTMuonMatchAndPlot.cc.

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

Referenced by beginRun().

539 {
540 
541  /* Properly delete the arrays of floats that have been allocated on
542  * the heap by fillEdges. Avoid multiple copies and internal ROOT
543  * clones by simply creating the histograms directly in the DQMStore
544  * using the appropriate book2D method to handle the variable bins
545  * case. */
546 
547  size_t nBinsX;
548  float * edgesX = 0;
549  fillEdges(nBinsX, edgesX, binParams_[binningTypeX]);
550 
551  size_t nBinsY;
552  float * edgesY = 0;
553  fillEdges(nBinsY, edgesY, binParams_[binningTypeY]);
554 
555  hists_[name] = iBooker.book2D(name.c_str(), title.c_str(),
556  nBinsX, edgesX, nBinsY, edgesY);
557  if (hists_[name])
558  if (hists_[name]->getTH2F()->GetSumw2N())
559  hists_[name]->getTH2F()->Sumw2();
560 
561  if (edgesX)
562  delete [] edgesX;
563  if (edgesY)
564  delete [] edgesY;
565 
566 }
std::map< std::string, std::vector< double > > binParams_
std::map< std::string, MonitorElement * > hists_
TH2F * getTH2F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
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 139 of file HLTMuonMatchAndPlot.cc.

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

Definition at line 336 of file HLTMuonMatchAndPlot.cc.

References i, and bookConverter::min.

Referenced by book1D(), and book2D().

338 {
339 
340  if (binning.size() < 3) {
341  LogWarning("HLTMuonVal") << "Invalid binning parameters!";
342  return;
343  }
344 
345  // Fixed-width binning.
346  if (binning.size() == 3) {
347  nBins = binning[0];
348  edges = new float[nBins + 1];
349  const double min = binning[1];
350  const double binwidth = (binning[2] - binning[1]) / nBins;
351  for (size_t i = 0; i <= nBins; i++) edges[i] = min + (binwidth * i);
352  }
353 
354  // Variable-width binning.
355  else {
356  nBins = binning.size() - 1;
357  edges = new float[nBins + 1];
358  for (size_t i = 0; i <= nBins; i++) edges[i] = binning[i];
359  }
360 
361 }
int i
Definition: DBlmapReader.cc:9
dictionary edges
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 370 of file HLTMuonMatchAndPlot.cc.

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

372 {
373 
374  // Get the ParameterSet with name 'target' from 'pset'
375  ParameterSet targetPset;
376  if (pset.existsAs<ParameterSet>(target, true)) // target is tracked
377  targetPset = pset.getParameterSet(target);
378  else if (pset.existsAs<ParameterSet>(target, false)) // target is untracked
379  targetPset = pset.getUntrackedParameterSet(target);
380 
381  // Get the parameter names from targetPset
382  vector<string> names = targetPset.getParameterNames();
383  vector<string>::const_iterator iter;
384 
385  for (iter = names.begin(); iter != names.end(); ++iter) {
386  if (targetPset.existsAs<T>(* iter, true)) // target is tracked
387  m[* iter] = targetPset.getParameter<T>(* iter);
388  else if (targetPset.existsAs<T>(* iter, false)) // target is untracked
389  m[* iter] = targetPset.getUntrackedParameter<T>(* iter);
390  }
391 
392 }
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:184
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 399 of file HLTMuonMatchAndPlot.cc.

References deltaR(), i, j, gen::k, NOMATCH, and query::result.

402 {
403 
404  const size_t n1 = collection1.size();
405  const size_t n2 = collection2.size();
406 
407  vector<size_t> result(n1, -1);
408  vector<vector<double> > deltaRMatrix(n1, vector<double>(n2, NOMATCH));
409 
410  for (size_t i = 0; i < n1; i++)
411  for (size_t j = 0; j < n2; j++) {
412  deltaRMatrix[i][j] = deltaR(collection1[i], collection2[j]);
413  }
414 
415  // Run through the matrix n1 times to make sure we've found all matches.
416  for (size_t k = 0; k < n1; k++) {
417  size_t i_min = -1;
418  size_t j_min = -1;
419  double minDeltaR = maxDeltaR;
420  // find the smallest deltaR
421  for (size_t i = 0; i < n1; i++)
422  for (size_t j = 0; j < n2; j++)
423  if (deltaRMatrix[i][j] < minDeltaR) {
424  i_min = i;
425  j_min = j;
426  minDeltaR = deltaRMatrix[i][j];
427  }
428  // If a match has been made, save it and make those candidates unavailable.
429  if (minDeltaR < maxDeltaR) {
430  result[i_min] = j_min;
431  deltaRMatrix[i_min] = vector<double>(n2, NOMATCH);
432  for (size_t i = 0; i < n1; i++)
433  deltaRMatrix[i][j_min] = NOMATCH;
434  }
435  }
436 
437  return result;
438 
439 }
int i
Definition: DBlmapReader.cc:9
const double NOMATCH
tuple result
Definition: query.py:137
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 444 of file HLTMuonMatchAndPlot.cc.

References reco::TrackBase::dxy(), reco::TrackBase::dz(), getDQMSummary::iter, and reco::BeamSpot::position().

Referenced by analyze().

449 {
450 
451  // If there is no selector (recoCuts does not exists), return an empty collection.
452  if (!hasRecoCuts)
453  return MuonCollection();
454 
455  MuonCollection reducedMuons(allMuons);
456  MuonCollection::iterator iter = reducedMuons.begin();
457  while (iter != reducedMuons.end()) {
458  const Track * track = 0;
459  if (iter->isTrackerMuon()) track = & * iter->innerTrack();
460  else if (iter->isStandAloneMuon()) track = & * iter->outerTrack();
461  if (track && selector(* iter) &&
462  fabs(track->dxy(beamSpot.position())) < d0Cut &&
463  fabs(track->dz(beamSpot.position())) < z0Cut)
464  ++iter;
465  else reducedMuons.erase(iter);
466  }
467 
468  return reducedMuons;
469 
470 }
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
tuple allMuons
Definition: allMuons_cfi.py:3
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:125
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:119
TriggerObjectCollection HLTMuonMatchAndPlot::selectedTriggerObjects ( const trigger::TriggerObjectCollection triggerObjects,
const trigger::TriggerEvent triggerSummary,
const edm::ParameterSet pset 
)
private

Definition at line 475 of file HLTMuonMatchAndPlot.cc.

References edm::ParameterSet::exists(), trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), edm::ParameterSet::getUntrackedParameter(), hltProcessName_, j, relativeConstraints::keys, moduleLabels_, and trigger::TriggerEvent::sizeFilters().

Referenced by analyze().

479 {
480 
481  // If pset is empty, return an empty collection.
482  if (!pset.exists("hltCuts"))
483  return TriggerObjectCollection();
484 
486  (pset.getUntrackedParameter<string>("hltCuts"));
487 
488  InputTag filterTag(moduleLabels_[moduleLabels_.size() - 1], "",
490  size_t filterIndex = triggerSummary.filterIndex(filterTag);
491 
492  TriggerObjectCollection selectedObjects;
493 
494  if (filterIndex < triggerSummary.sizeFilters()) {
495  const Keys &keys = triggerSummary.filterKeys(filterIndex);
496  for (size_t j = 0; j < keys.size(); j++ ){
497  TriggerObject foundObject = triggerObjects[keys[j]];
498  if (selector(foundObject))
499  selectedObjects.push_back(foundObject);
500  }
501  }
502 
503  return selectedObjects;
504 
505 }
T getUntrackedParameter(std::string const &, T const &) const
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
std::vector< std::string > moduleLabels_
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
bool exists(std::string const &parameterName) const
checks if a parameter exists
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 104 of file HLTMuonMatchAndPlot.h.

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

unsigned int HLTMuonMatchAndPlot::cutMinPt_
private

Definition at line 111 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

std::string HLTMuonMatchAndPlot::destination_
private

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

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

Referenced by beginRun(), and HLTMuonMatchAndPlot().

std::string HLTMuonMatchAndPlot::hltProcessName_
private

Definition at line 101 of file HLTMuonMatchAndPlot.h.

Referenced by selectedTriggerObjects().

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

Definition at line 113 of file HLTMuonMatchAndPlot.h.

Referenced by HLTMuonMatchAndPlot(), and selectedTriggerObjects().

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

Definition at line 105 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

double HLTMuonMatchAndPlot::probeD0Cut_
private

Definition at line 125 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 123 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

edm::ParameterSet HLTMuonMatchAndPlot::probeParams_
private

Definition at line 107 of file HLTMuonMatchAndPlot.h.

double HLTMuonMatchAndPlot::probeZ0Cut_
private

Definition at line 124 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

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

Referenced by analyze().

double HLTMuonMatchAndPlot::targetZ0Cut_
private

Definition at line 121 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

std::string HLTMuonMatchAndPlot::triggerLevel_
private

Definition at line 110 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().