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 (const edm::Event &, const edm::EventSetup &)
 
void beginRun (const edm::Run &, const edm::EventSetup &)
 
void endRun (const edm::Run &, const edm::EventSetup &)
 
void fillEdges (size_t &nBins, float *&edges, std::vector< double > binning)
 
template<class T >
void fillMapFromPSet (std::map< std::string, T > &, edm::ParameterSet, std::string)
 
template<class T >
void fillMapFromPSet (map< string, T > &m, ParameterSet pset, string target)
 
 HLTMuonMatchAndPlot (const edm::ParameterSet &, std::string, 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 (std::string, std::string, std::string)
 
void book2D (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_
 
DQMStoredbe_
 
std::string destination_
 
bool hasProbeRecoCuts
 
bool hasTargetRecoCuts
 
std::map< std::string,
MonitorElement * > 
hists_
 
std::string hltPath_
 
std::string hltProcessName_
 
std::map< std::string,
edm::InputTag
inputTags_
 
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; rather, the intent is that one EDAnalyzer would call a separate instantiation of HLTMuonMatchAndPlot for each HLT path under consideration.

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

Date:
2011/05/27 13:38:18
Revision:
1.18
Author
J. Slaunwhite, Jeff Klukas

Definition at line 66 of file HLTMuonMatchAndPlot.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 44 of file HLTMuonMatchAndPlot.cc.

References binParams_, cutMinPt_, dbe_, fillMapFromPSet(), hltPath_, hltProcessName_, inputTags_, edm::InputTag::instance(), edm::InputTag::label(), moduleLabels_, cppFunctionSkipper::operator, plotCuts_, and triggerLevel_.

46  :
47  hltProcessName_(pset.getParameter<string>("hltProcessName")),
48  destination_(pset.getUntrackedParameter<string>("destination")),
49  requiredTriggers_(pset.getUntrackedParameter<vstring>("requiredTriggers")),
50  targetParams_(pset.getParameterSet("targetParams")),
51  probeParams_(pset.getParameterSet("probeParams")),
52  hltPath_(hltPath),
53  moduleLabels_(moduleLabels),
59  probeMuonSelector_(probeParams_.getUntrackedParameter<string>("recoCuts", "")),
60  probeZ0Cut_(probeParams_.getUntrackedParameter<double>("z0Cut",0.)),
62 {
63 
64  // Create std::map<string, T> from ParameterSets.
65  fillMapFromPSet(inputTags_, pset, "inputTags");
66  fillMapFromPSet(binParams_, pset, "binParams");
67  fillMapFromPSet(plotCuts_, pset, "plotCuts");
68 
69  // Set HLT process name for TriggerResults and TriggerSummary.
70  InputTag & resTag = inputTags_["triggerResults"];
71  resTag = InputTag(resTag.label(), resTag.instance(), hltProcessName_);
72  InputTag & sumTag = inputTags_["triggerSummary"];
73  sumTag = InputTag(sumTag.label(), sumTag.instance(), hltProcessName_);
74 
75  // Prepare the DQMStore object.
77  dbe_->setVerbose(0);
78 
79  // Get the trigger level.
80  triggerLevel_ = "L3";
81  TPRegexp levelRegexp("L[1-3]");
82  size_t nModules = moduleLabels_.size();
83  TObjArray * levelArray = levelRegexp.MatchS(moduleLabels_[nModules - 1]);
84  if (levelArray->GetEntriesFast() > 0) {
85  triggerLevel_ = ((TObjString *)levelArray->At(0))->GetString();
86  }
87  delete levelArray;
88 
89  // Get the pT cut by parsing the name of the HLT path.
90  cutMinPt_ = 3;
91  TPRegexp ptRegexp("Mu([0-9]*)");
92  TObjArray * objArray = ptRegexp.MatchS(hltPath_);
93  if (objArray->GetEntriesFast() >= 2) {
94  TObjString * ptCutString = (TObjString *)objArray->At(1);
95  cutMinPt_ = atoi(ptCutString->GetString());
96  cutMinPt_ = ceil(cutMinPt_ * plotCuts_["minPtFactor"]);
97  }
98  delete objArray;
99 }
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 setVerbose(unsigned level)
Definition: DQMStore.cc:398
StringCutObjectSelector< reco::Muon > targetMuonSelector_
std::map< std::string, edm::InputTag > inputTags_
std::string const & label() const
Definition: InputTag.h:42
edm::ParameterSet probeParams_
void fillMapFromPSet(std::map< std::string, T > &, edm::ParameterSet, std::string)
std::map< std::string, double > plotCuts_
std::string const & instance() const
Definition: InputTag.h:43

Member Function Documentation

void HLTMuonMatchAndPlot::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 165 of file HLTMuonMatchAndPlot.cc.

References allMuons_cfi::allMuons, SiPixelRawToDigiRegional_cfi::beamSpot, reco::LeafCandidate::charge(), cutMinPt_, deltaR(), reco::TrackBase::dxy(), reco::TrackBase::dz(), EFFICIENCY_SUFFIXES, trigger::TriggerObject::eta(), reco::LeafCandidate::eta(), eta(), edm::Event::getByLabel(), hasProbeRecoCuts, hasTargetRecoCuts, hists_, HLT_8E33v2_cff::hltMuons, i, reco::Muon::innerTrack(), inputTags_, reco::Muon::isStandAloneMuon(), reco::Muon::isTrackerMuon(), edm::HandleBase::isValid(), j, gen::k, matchByDeltaR(), metsig::muon, reco::Muon::outerTrack(), reco::LeafCandidate::p4(), phi, trigger::TriggerObject::phi(), reco::LeafCandidate::phi(), plotCuts_, probeD0Cut_, probeMuonSelector_, probeZ0Cut_, trigger::TriggerObject::pt(), reco::LeafCandidate::pt(), requiredTriggers_, selectedMuons(), selectedTriggerObjects(), findQualityFiles::size, createPayload::suffix, targetD0Cut_, targetMuonSelector_, targetParams_, targetZ0Cut_, triggerLevel_, and patRefSel_triggerSelection_cff::triggerResults.

168 {
169 
170  // Get objects from the event.
172  iEvent.getByLabel(inputTags_["recoMuon"], allMuons);
173 
175  iEvent.getByLabel(inputTags_["beamSpot"], beamSpot);
176 
177  Handle<TriggerEvent> triggerSummary;
178  iEvent.getByLabel(inputTags_["triggerSummary"], triggerSummary);
180 
182  iEvent.getByLabel("offlinePrimaryVertices", vertices);
183 
184  //edm::Handle<GenParticleCollection> gen;
185  //iEvent.getByLabel("genParticles", gen);
186  //GenParticleCollection::const_iterator g_part;
187  //std::vector<const GenParticle *> gen_leptsp;
188  //std::vector<const GenParticle *> gen_momsp;
189 
190 
191  if(!triggerSummary.isValid())
192  {
193  edm::LogError("HLTMuonMatchAndPlot")<<"Missing triggerSummary with label " << inputTags_["triggerSummary"] <<std::endl;
194  return;
195  }
196  iEvent.getByLabel(inputTags_["triggerResults"], triggerResults);
197  if(!triggerResults.isValid())
198  {
199  edm::LogError("HLTMuonMatchAndPlot")<<"Missing triggerResults with label " << inputTags_["triggerResults"] <<std::endl;
200  return;
201  }
202 
203  /*
204  if(gen != 0) {
205  for(g_part = gen->begin(); g_part != gen->end(); g_part++){
206  if( abs(g_part->pdgId()) == 13) {
207  if(!( g_part->status() ==1 || (g_part->status() ==2 && abs(g_part->pdgId())==5))) continue;
208  bool GenMomExists (true);
209  bool GenGrMomExists(true);
210  if( g_part->pt() < 10.0 ) continue;
211  if( fabs(g_part->eta()) > 2.4 ) continue;
212  int gen_id= g_part->pdgId();
213  const GenParticle* gen_lept = &(*g_part);
214  // get mother of gen_lept
215  const GenParticle* gen_mom = static_cast<const GenParticle*> (gen_lept->mother());
216  if(gen_mom==NULL) GenMomExists=false;
217  int m_id=-999;
218  if(GenMomExists) m_id = gen_mom->pdgId();
219  if(m_id != gen_id || !GenMomExists);
220  else{
221  int id= m_id;
222  while(id == gen_id && GenMomExists){
223  gen_mom = static_cast<const GenParticle*> (gen_mom->mother());
224  if(gen_mom==NULL){
225  GenMomExists=false;
226  }
227  if(GenMomExists) id=gen_mom->pdgId();
228  }
229  }
230  if(GenMomExists) m_id = gen_mom->pdgId();
231  gen_leptsp.push_back(gen_lept);
232  gen_momsp.push_back(gen_mom);
233  }
234  }
235  }
236 
237 
238  std::vector<GenParticle> gen_lepts;
239  for(size_t i = 0; i < gen_leptsp.size(); i++) {
240  gen_lepts.push_back(*gen_leptsp[i]);
241  }
242 
243 
244  */
245 
246 
247 
248  // Throw out this event if it doesn't pass the required triggers.
249  for (size_t i = 0; i < requiredTriggers_.size(); i++) {
250  unsigned int triggerIndex = triggerResults->find(requiredTriggers_[i]);
251  if (triggerIndex < triggerResults->size() ||
252  !triggerResults->accept(triggerIndex))
253  return;
254  }
255 
256  // Select objects based on the configuration.
259  TriggerObjectCollection allTriggerObjects = triggerSummary->getObjects();
261  selectedTriggerObjects(allTriggerObjects, * triggerSummary, targetParams_);
262 
263  // Fill plots for HLT muons.
264  for (size_t i = 0; i < hltMuons.size(); i++) {
265  hists_["hltPt"]->Fill(hltMuons[i].pt());
266  hists_["hltEta"]->Fill(hltMuons[i].eta());
267  hists_["hltPhi"]->Fill(hltMuons[i].phi());
268  }
269 
270  // Find the best trigger object matches for the targetMuons.
271  vector<size_t> matches = matchByDeltaR(targetMuons, hltMuons,
272  plotCuts_[triggerLevel_ + "DeltaR"]);
273 
274 
275  // Fill plots for matched muons.
276  bool pairalreadyconsidered = false;
277  for (size_t i = 0; i < targetMuons.size(); i++) {
278 
279  Muon & muon = targetMuons[i];
280 
281  // Fill plots which are not efficiencies.
282  if (matches[i] < targetMuons.size()) {
283  TriggerObject & hltMuon = hltMuons[matches[i]];
284  double ptRes = (muon.pt() - hltMuon.pt()) / muon.pt();
285  double etaRes = muon.eta() - hltMuon.eta();
286  double phiRes = muon.phi() - hltMuon.phi();
287  hists_["resolutionEta"]->Fill(etaRes);
288  hists_["resolutionPhi"]->Fill(phiRes);
289  hists_["resolutionPt"]->Fill(ptRes);
290  hists_["deltaR"]->Fill(deltaR(muon, hltMuon));
291  }
292 
293  // Fill numerators and denominators for efficiency plots.
294  for (size_t j = 0; j < 2; j++) {
295 
296  string suffix = EFFICIENCY_SUFFIXES[j];
297 
298  // If no match was found, then the numerator plots don't get filled.
299  if (suffix == "numer" && matches[i] >= targetMuons.size()) continue;
300 
301  if (muon.pt() > cutMinPt_) {
302  hists_["efficiencyEta_" + suffix]->Fill(muon.eta());
303  hists_["efficiencyPhiVsEta_" + suffix]->Fill(muon.eta(), muon.phi());
304  }
305 
306  if (fabs(muon.eta()) < plotCuts_["maxEta"]) {
307  hists_["efficiencyTurnOn_" + suffix]->Fill(muon.pt());
308  }
309 
310  if (muon.pt() > cutMinPt_ && fabs(muon.eta()) < plotCuts_["maxEta"]) {
311  const Track * track = 0;
312  if (muon.isTrackerMuon()) track = & * muon.innerTrack();
313  else if (muon.isStandAloneMuon()) track = & * muon.outerTrack();
314  if (track) {
315  double d0 = track->dxy(beamSpot->position());
316  double z0 = track->dz(beamSpot->position());
317  hists_["efficiencyVertex_" + suffix]->Fill(vertices->size());
318  hists_["efficiencyPhi_" + suffix]->Fill(muon.phi());
319  hists_["efficiencyD0_" + suffix]->Fill(d0);
320  hists_["efficiencyZ0_" + suffix]->Fill(z0);
321  hists_["efficiencyCharge_" + suffix]->Fill(muon.charge());
322  }
323  }
324  }
325 
326  // Fill plots for tag and probe
327  // Muon cannot be a tag because doesn't match an hlt muon
328  if(matches[i] >= targetMuons.size()) continue;
329  for (size_t k = 0; k < targetMuons.size(); k++) {
330  if(k == i) continue;
331  if(muon.pt() < 20.0) continue;
332  Muon & theProbe = targetMuons[k];
333  if (muon.charge() != theProbe.charge() && !pairalreadyconsidered) {
334  double mass = (muon.p4() + theProbe.p4()).M();
335  if(mass > 60 && mass < 120) {
336  hists_["massVsEtaZ_denom"]->Fill(theProbe.eta());
337  hists_["massVsPtZ_denom"]->Fill(theProbe.pt());
338  hists_["massVsVertexZ_denom"]->Fill(vertices->size());
339  if(matches[k] < targetMuons.size()) {
340  hists_["massVsEtaZ_numer"]->Fill(theProbe.eta());
341  hists_["massVsPtZ_numer"]->Fill(theProbe.pt());
342  hists_["massVsVertexZ_numer"]->Fill(vertices->size());
343  }
344  pairalreadyconsidered = true;
345  }
346  if(mass > 1 && mass < 4) {
347  hists_["massVsEtaJpsi_denom"]->Fill(theProbe.eta());
348  hists_["massVsPtJpsi_denom"]->Fill(theProbe.pt());
349  hists_["massVsVertexJpsi_denom"]->Fill(vertices->size());
350  if(matches[k] < targetMuons.size()) {
351  hists_["massVsEtaJpsi_numer"]->Fill(theProbe.eta());
352  hists_["massVsPtJpsi_numer"]->Fill(theProbe.pt());
353  hists_["massVsVertexJpsi_numer"]->Fill(vertices->size());
354  }
355  pairalreadyconsidered = true;
356  }
357  }
358  } // End loop over denominator and numerator.
359  } // End loop over targetMuons.
360 
361  // Plot fake rates (efficiency for HLT objects to not get matched to RECO).
362  vector<size_t> hltMatches = matchByDeltaR(hltMuons, targetMuons,
363  plotCuts_[triggerLevel_ + "DeltaR"]);
364  for (size_t i = 0; i < hltMuons.size(); i++) {
365  TriggerObject & hltMuon = hltMuons[i];
366  bool isFake = hltMatches[i] > hltMuons.size();
367  for (size_t j = 0; j < 2; j++) {
368  string suffix = EFFICIENCY_SUFFIXES[j];
369  // If match is found, then numerator plots should not get filled
370  if (suffix == "numer" && ! isFake) continue;
371  hists_["fakerateVertex_" + suffix]->Fill(vertices->size());
372  hists_["fakerateEta_" + suffix]->Fill(hltMuon.eta());
373  hists_["fakeratePhi_" + suffix]->Fill(hltMuon.phi());
374  hists_["fakerateTurnOn_" + suffix]->Fill(hltMuon.pt());
375  } // End loop over numerator and denominator.
376  } // End loop over hltMuons.
377 
378 
379 } // 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:49
float phi() const
Definition: TriggerObject.h:60
edm::ParameterSet targetParams_
bool isTrackerMuon() const
Definition: Muon.h:220
std::map< std::string, MonitorElement * > hists_
float eta() const
Definition: TriggerObject.h:59
T eta() const
bool isStandAloneMuon() const
Definition: Muon.h:221
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:24
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
tuple allMuons
Definition: allMuons_cfi.py:3
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:52
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:127
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:83
StringCutObjectSelector< reco::Muon > targetMuonSelector_
virtual int charge() const GCC11_FINAL
electric charge
std::map< std::string, edm::InputTag > inputTags_
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:121
std::map< std::string, double > plotCuts_
tuple size
Write out results.
Definition: DDAxes.h:10
void HLTMuonMatchAndPlot::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 101 of file HLTMuonMatchAndPlot.cc.

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

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

Definition at line 554 of file HLTMuonMatchAndPlot.cc.

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

Referenced by beginRun().

555 {
556  /* Properly delete the array of floats that has been allocated on
557  * the heap by fillEdges. Avoid multiple copies and internal ROOT
558  * clones by simply creating the histograms directly in the DQMStore
559  * using the appropriate book1D method to handle the variable bins
560  * case. */
561 
562  size_t nBins;
563  float * edges = 0;
564  fillEdges(nBins, edges, binParams_[binningType]);
565 
566  hists_[name] = dbe_->book1D(name, title, nBins, edges);
567  if (hists_[name])
568  if (hists_[name]->getTH1F()->GetSumw2N())
569  hists_[name]->getTH1F()->Sumw2();
570 
571  if (edges)
572  delete [] edges;
573 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
void fillEdges(size_t &nBins, float *&edges, std::vector< double > binning)
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 HLTMuonMatchAndPlot::book2D ( std::string  ,
std::string  ,
std::string  ,
std::string   
)
private

Definition at line 578 of file HLTMuonMatchAndPlot.cc.

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

Referenced by beginRun().

580 {
581 
582  /* Properly delete the arrays of floats that have been allocated on
583  * the heap by fillEdges. Avoid multiple copies and internal ROOT
584  * clones by simply creating the histograms directly in the DQMStore
585  * using the appropriate book2D method to handle the variable bins
586  * case. */
587 
588  size_t nBinsX;
589  float * edgesX = 0;
590  fillEdges(nBinsX, edgesX, binParams_[binningTypeX]);
591 
592  size_t nBinsY;
593  float * edgesY = 0;
594  fillEdges(nBinsY, edgesY, binParams_[binningTypeY]);
595 
596  hists_[name] = dbe_->book2D(name.c_str(), title.c_str(),
597  nBinsX, edgesX, nBinsY, edgesY);
598  if (hists_[name])
599  if (hists_[name]->getTH2F()->GetSumw2N())
600  hists_[name]->getTH2F()->Sumw2();
601 
602  if (edgesX)
603  delete [] edgesX;
604  if (edgesY)
605  delete [] edgesY;
606 }
void fillEdges(size_t &nBins, float *&edges, std::vector< double > binning)
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)
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:850
void HLTMuonMatchAndPlot::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 158 of file HLTMuonMatchAndPlot.cc.

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

Definition at line 385 of file HLTMuonMatchAndPlot.cc.

References i, and min.

Referenced by book1D(), and book2D().

386  {
387 
388  if (binning.size() < 3) {
389  LogWarning("HLTMuonVal") << "Invalid binning parameters!";
390  return;
391  }
392 
393  // Fixed-width binning.
394  if (binning.size() == 3) {
395  nBins = binning[0];
396  edges = new float[nBins + 1];
397  const double min = binning[1];
398  const double binwidth = (binning[2] - binning[1]) / nBins;
399  for (size_t i = 0; i <= nBins; i++) edges[i] = min + (binwidth * i);
400  }
401 
402  // Variable-width binning.
403  else {
404  nBins = binning.size() - 1;
405  edges = new float[nBins + 1];
406  for (size_t i = 0; i <= nBins; i++) edges[i] = binning[i];
407  }
408 
409 }
int i
Definition: DBlmapReader.cc:9
#define min(a, b)
Definition: mlp_lapack.h:161
dictionary edges
template<class T >
void HLTMuonMatchAndPlot::fillMapFromPSet ( std::map< std::string, T > &  ,
edm::ParameterSet  ,
std::string   
)

Referenced by HLTMuonMatchAndPlot().

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

Definition at line 418 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.

419  {
420 
421  // Get the ParameterSet with name 'target' from 'pset'
422  ParameterSet targetPset;
423  if (pset.existsAs<ParameterSet>(target, true)) // target is tracked
424  targetPset = pset.getParameterSet(target);
425  else if (pset.existsAs<ParameterSet>(target, false)) // target is untracked
426  targetPset = pset.getUntrackedParameterSet(target);
427 
428  // Get the parameter names from targetPset
429  vector<string> names = targetPset.getParameterNames();
430  vector<string>::const_iterator iter;
431 
432  for (iter = names.begin(); iter != names.end(); ++iter) {
433  if (targetPset.existsAs<T>(* iter, true)) // target is tracked
434  m[* iter] = targetPset.getParameter<T>(* iter);
435  else if (targetPset.existsAs<T>(* iter, false)) // target is untracked
436  m[* iter] = targetPset.getUntrackedParameter<T>(* iter);
437  }
438 
439 }
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:187
static const HistoName names[]
ParameterSet const & 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 446 of file HLTMuonMatchAndPlot.cc.

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

448  {
449 
450  const size_t n1 = collection1.size();
451  const size_t n2 = collection2.size();
452 
453  vector<size_t> result(n1, -1);
454  vector<vector<double> > deltaRMatrix(n1, vector<double>(n2, NOMATCH));
455 
456  for (size_t i = 0; i < n1; i++)
457  for (size_t j = 0; j < n2; j++) {
458  deltaRMatrix[i][j] = deltaR(collection1[i], collection2[j]);
459  }
460 
461  // Run through the matrix n1 times to make sure we've found all matches.
462  for (size_t k = 0; k < n1; k++) {
463  size_t i_min = -1;
464  size_t j_min = -1;
465  double minDeltaR = maxDeltaR;
466  // find the smallest deltaR
467  for (size_t i = 0; i < n1; i++)
468  for (size_t j = 0; j < n2; j++)
469  if (deltaRMatrix[i][j] < minDeltaR) {
470  i_min = i;
471  j_min = j;
472  minDeltaR = deltaRMatrix[i][j];
473  }
474  // If a match has been made, save it and make those candidates unavailable.
475  if (minDeltaR < maxDeltaR) {
476  result[i_min] = j_min;
477  deltaRMatrix[i_min] = vector<double>(n2, NOMATCH);
478  for (size_t i = 0; i < n1; i++)
479  deltaRMatrix[i][j_min] = NOMATCH;
480  }
481  }
482 
483  return result;
484 
485 }
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 490 of file HLTMuonMatchAndPlot.cc.

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

Referenced by analyze().

495 {
496  // If there is no selector (recoCuts does not exists), return an empty collection.
497  if (!hasRecoCuts)
498  return MuonCollection();
499 
500  MuonCollection reducedMuons(allMuons);
501  MuonCollection::iterator iter = reducedMuons.begin();
502  while (iter != reducedMuons.end()) {
503  const Track * track = 0;
504  if (iter->isTrackerMuon()) track = & * iter->innerTrack();
505  else if (iter->isStandAloneMuon()) track = & * iter->outerTrack();
506  if (track && selector(* iter) &&
507  fabs(track->dxy(beamSpot.position())) < d0Cut &&
508  fabs(track->dz(beamSpot.position())) < z0Cut)
509  ++iter;
510  else reducedMuons.erase(iter);
511  }
512 
513  return reducedMuons;
514 
515 }
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:127
const Point & position() const
position
Definition: BeamSpot.h:63
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:121
TriggerObjectCollection HLTMuonMatchAndPlot::selectedTriggerObjects ( const trigger::TriggerObjectCollection triggerObjects,
const trigger::TriggerEvent triggerSummary,
const edm::ParameterSet pset 
)
private

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

524 {
525 
526  // If pset is empty, return an empty collection.
527  if (!pset.exists("hltCuts"))
528  return TriggerObjectCollection();
529 
531  (pset.getUntrackedParameter<string>("hltCuts"));
532 
533  InputTag filterTag(moduleLabels_[moduleLabels_.size() - 1], "",
535  size_t filterIndex = triggerSummary.filterIndex(filterTag);
536 
537  TriggerObjectCollection selectedObjects;
538 
539  if (filterIndex < triggerSummary.sizeFilters()) {
540  const Keys &keys = triggerSummary.filterKeys(filterIndex);
541  for (size_t j = 0; j < keys.size(); j++ ){
542  TriggerObject foundObject = triggerObjects[keys[j]];
543  if (selector(foundObject))
544  selectedObjects.push_back(foundObject);
545  }
546  }
547 
548  return selectedObjects;
549 
550 }
T getUntrackedParameter(std::string const &, T const &) const
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:137
std::vector< std::string > moduleLabels_
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:113
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:125
bool exists(std::string const &parameterName) const
checks if a parameter exists
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:24
int j
Definition: DBlmapReader.cc:9
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:83
std::vector< size_type > Keys

Member Data Documentation

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

Definition at line 108 of file HLTMuonMatchAndPlot.h.

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

unsigned int HLTMuonMatchAndPlot::cutMinPt_
private

Definition at line 115 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

DQMStore* HLTMuonMatchAndPlot::dbe_
private

Definition at line 118 of file HLTMuonMatchAndPlot.h.

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

std::string HLTMuonMatchAndPlot::destination_
private

Definition at line 105 of file HLTMuonMatchAndPlot.h.

Referenced by beginRun().

bool HLTMuonMatchAndPlot::hasProbeRecoCuts
private

Definition at line 123 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

bool HLTMuonMatchAndPlot::hasTargetRecoCuts
private

Definition at line 122 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 119 of file HLTMuonMatchAndPlot.h.

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

std::string HLTMuonMatchAndPlot::hltPath_
private

Definition at line 116 of file HLTMuonMatchAndPlot.h.

Referenced by beginRun(), and HLTMuonMatchAndPlot().

std::string HLTMuonMatchAndPlot::hltProcessName_
private

Definition at line 104 of file HLTMuonMatchAndPlot.h.

Referenced by HLTMuonMatchAndPlot(), and selectedTriggerObjects().

std::map<std::string, edm::InputTag> HLTMuonMatchAndPlot::inputTags_
private

Definition at line 107 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

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

Definition at line 117 of file HLTMuonMatchAndPlot.h.

Referenced by HLTMuonMatchAndPlot(), and selectedTriggerObjects().

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

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

Referenced by analyze().

double HLTMuonMatchAndPlot::targetD0Cut_
private

Definition at line 127 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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

Definition at line 125 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

edm::ParameterSet HLTMuonMatchAndPlot::targetParams_
private

Definition at line 110 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

double HLTMuonMatchAndPlot::targetZ0Cut_
private

Definition at line 126 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

std::string HLTMuonMatchAndPlot::triggerLevel_
private

Definition at line 114 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().