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, 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 (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

Author
J. Slaunwhite, Jeff Klukas

Definition at line 64 of file HLTMuonMatchAndPlot.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 41 of file HLTMuonMatchAndPlot.cc.

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

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

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

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

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

Definition at line 551 of file HLTMuonMatchAndPlot.cc.

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

Referenced by beginRun().

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

Definition at line 575 of file HLTMuonMatchAndPlot.cc.

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

Referenced by beginRun().

577 {
578 
579  /* Properly delete the arrays of floats that have been allocated on
580  * the heap by fillEdges. Avoid multiple copies and internal ROOT
581  * clones by simply creating the histograms directly in the DQMStore
582  * using the appropriate book2D method to handle the variable bins
583  * case. */
584 
585  size_t nBinsX;
586  float * edgesX = 0;
587  fillEdges(nBinsX, edgesX, binParams_[binningTypeX]);
588 
589  size_t nBinsY;
590  float * edgesY = 0;
591  fillEdges(nBinsY, edgesY, binParams_[binningTypeY]);
592 
593  hists_[name] = dbe_->book2D(name.c_str(), title.c_str(),
594  nBinsX, edgesX, nBinsY, edgesY);
595  if (hists_[name])
596  if (hists_[name]->getTH2F()->GetSumw2N())
597  hists_[name]->getTH2F()->Sumw2();
598 
599  if (edgesX)
600  delete [] edgesX;
601  if (edgesY)
602  delete [] edgesY;
603 }
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:1000
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 }
void HLTMuonMatchAndPlot::fillEdges ( size_t &  nBins,
float *&  edges,
const std::vector< double > &  binning 
)

Definition at line 382 of file HLTMuonMatchAndPlot.cc.

References i, and bookConverter::min.

Referenced by book1D(), and book2D().

383  {
384 
385  if (binning.size() < 3) {
386  LogWarning("HLTMuonVal") << "Invalid binning parameters!";
387  return;
388  }
389 
390  // Fixed-width binning.
391  if (binning.size() == 3) {
392  nBins = binning[0];
393  edges = new float[nBins + 1];
394  const double min = binning[1];
395  const double binwidth = (binning[2] - binning[1]) / nBins;
396  for (size_t i = 0; i <= nBins; i++) edges[i] = min + (binwidth * i);
397  }
398 
399  // Variable-width binning.
400  else {
401  nBins = binning.size() - 1;
402  edges = new float[nBins + 1];
403  for (size_t i = 0; i <= nBins; i++) edges[i] = binning[i];
404  }
405 
406 }
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 415 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.

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

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

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

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

Referenced by analyze().

492 {
493  // If there is no selector (recoCuts does not exists), return an empty collection.
494  if (!hasRecoCuts)
495  return MuonCollection();
496 
497  MuonCollection reducedMuons(allMuons);
498  MuonCollection::iterator iter = reducedMuons.begin();
499  while (iter != reducedMuons.end()) {
500  const Track * track = 0;
501  if (iter->isTrackerMuon()) track = & * iter->innerTrack();
502  else if (iter->isStandAloneMuon()) track = & * iter->outerTrack();
503  if (track && selector(* iter) &&
504  fabs(track->dxy(beamSpot.position())) < d0Cut &&
505  fabs(track->dz(beamSpot.position())) < z0Cut)
506  ++iter;
507  else reducedMuons.erase(iter);
508  }
509 
510  return reducedMuons;
511 
512 }
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 517 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().

521 {
522 
523  // If pset is empty, return an empty collection.
524  if (!pset.exists("hltCuts"))
525  return TriggerObjectCollection();
526 
528  (pset.getUntrackedParameter<string>("hltCuts"));
529 
530  InputTag filterTag(moduleLabels_[moduleLabels_.size() - 1], "",
532  size_t filterIndex = triggerSummary.filterIndex(filterTag);
533 
534  TriggerObjectCollection selectedObjects;
535 
536  if (filterIndex < triggerSummary.sizeFilters()) {
537  const Keys &keys = triggerSummary.filterKeys(filterIndex);
538  for (size_t j = 0; j < keys.size(); j++ ){
539  TriggerObject foundObject = triggerObjects[keys[j]];
540  if (selector(foundObject))
541  selectedObjects.push_back(foundObject);
542  }
543  }
544 
545  return selectedObjects;
546 
547 }
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 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().

DQMStore* HLTMuonMatchAndPlot::dbe_
private

Definition at line 116 of file HLTMuonMatchAndPlot.h.

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

std::string HLTMuonMatchAndPlot::destination_
private

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

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

Referenced by HLTMuonMatchAndPlot(), and selectedTriggerObjects().

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

Definition at line 105 of file HLTMuonMatchAndPlot.h.

Referenced by analyze(), and HLTMuonMatchAndPlot().

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

Definition at line 115 of file HLTMuonMatchAndPlot.h.

Referenced by HLTMuonMatchAndPlot(), and selectedTriggerObjects().

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

Referenced by analyze().

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

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

Referenced by analyze().

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

Definition at line 104 of file HLTMuonMatchAndPlot.h.

Referenced by analyze().

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.

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().