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/23 13:07:46
Revision:
1.17
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 42 of file HLTMuonMatchAndPlot.cc.

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

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

Member Function Documentation

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

Definition at line 159 of file HLTMuonMatchAndPlot.cc.

References allMuons_cfi::allMuons, reco::LeafCandidate::charge(), cutMinPt_, debug_cff::d0, deltaR(), reco::TrackBase::dxy(), reco::TrackBase::dz(), EFFICIENCY_SUFFIXES, trigger::TriggerObject::eta(), reco::LeafCandidate::eta(), edm::Event::getByLabel(), hasProbeRecoCuts, hasTargetRecoCuts, hists_, 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(), 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_, and triggerLevel_.

162 {
163 
164  // Get objects from the event.
166  iEvent.getByLabel(inputTags_["recoMuon"], allMuons);
167  Handle<BeamSpot> beamSpot;
168  iEvent.getByLabel(inputTags_["beamSpot"], beamSpot);
169  Handle<TriggerEvent> triggerSummary;
170  iEvent.getByLabel(inputTags_["triggerSummary"], triggerSummary);
171  Handle<TriggerResults> triggerResults;
172  if(!triggerSummary.isValid())
173  {
174  edm::LogError("HLTMuonMatchAndPlot")<<"Missing triggerSummary with label " << inputTags_["triggerSummary"] <<std::endl;
175  return;
176  }
177  iEvent.getByLabel(inputTags_["triggerResults"], triggerResults);
178  if(!triggerResults.isValid())
179  {
180  edm::LogError("HLTMuonMatchAndPlot")<<"Missing triggerResults with label " << inputTags_["triggerResults"] <<std::endl;
181  return;
182  }
183  // Throw out this event if it doesn't pass the required triggers.
184  for (size_t i = 0; i < requiredTriggers_.size(); i++) {
185  unsigned int triggerIndex = triggerResults->find(requiredTriggers_[i]);
186  if (triggerIndex < triggerResults->size() ||
187  !triggerResults->accept(triggerIndex))
188  return;
189  }
190 
191  // Select objects based on the configuration.
194  TriggerObjectCollection allTriggerObjects = triggerSummary->getObjects();
195  TriggerObjectCollection hltMuons =
196  selectedTriggerObjects(allTriggerObjects, * triggerSummary, targetParams_);
197 
198  // Find the best trigger object matches for the targetMuons.
199  vector<size_t> matches = matchByDeltaR(targetMuons, hltMuons,
200  plotCuts_[triggerLevel_ + "DeltaR"]);
201 
202  // Fill plots for matched muons.
203  for (size_t i = 0; i < targetMuons.size(); i++) {
204 
205  Muon & muon = targetMuons[i];
206 
207  // Fill plots which are not efficiencies.
208  if (matches[i] < targetMuons.size()) {
209  TriggerObject & hltMuon = hltMuons[matches[i]];
210  double ptRes = (muon.pt() - hltMuon.pt()) / muon.pt();
211  double etaRes = (muon.eta() - hltMuon.eta()) / fabs(muon.eta());
212  double phiRes = (muon.phi() - hltMuon.phi()) / fabs(muon.phi());
213  hists_["resolutionEta"]->Fill(etaRes);
214  hists_["resolutionPhi"]->Fill(phiRes);
215  hists_["resolutionPt"]->Fill(ptRes);
216  hists_["deltaR"]->Fill(deltaR(muon, hltMuon));
217  }
218 
219  // Fill numerators and denominators for efficiency plots.
220  for (size_t j = 0; j < 2; j++) {
221 
222  string suffix = EFFICIENCY_SUFFIXES[j];
223 
224  // If no match was found, then the numerator plots don't get filled.
225  if (suffix == "numer" && matches[i] >= targetMuons.size()) continue;
226 
227  if (muon.pt() > cutMinPt_) {
228  hists_["efficiencyEta_" + suffix]->Fill(muon.eta());
229  hists_["efficiencyPhiVsEta_" + suffix]->Fill(muon.eta(), muon.phi());
230  }
231 
232  if (fabs(muon.eta()) < plotCuts_["maxEta"]) {
233  hists_["efficiencyTurnOn_" + suffix]->Fill(muon.pt());
234  }
235 
236  if (muon.pt() > cutMinPt_ && fabs(muon.eta()) < plotCuts_["maxEta"]) {
237  const Track * track = 0;
238  if (muon.isTrackerMuon()) track = & * muon.innerTrack();
239  else if (muon.isStandAloneMuon()) track = & * muon.outerTrack();
240  if (track) {
241  double d0 = track->dxy(beamSpot->position());
242  double z0 = track->dz(beamSpot->position());
243  hists_["efficiencyPhi_" + suffix]->Fill(muon.phi());
244  hists_["efficiencyD0_" + suffix]->Fill(d0);
245  hists_["efficiencyZ0_" + suffix]->Fill(z0);
246  hists_["efficiencyCharge_" + suffix]->Fill(muon.charge());
247  }
248  }
249 
250  // Fill plots for tag and probe
251  for (size_t k = 0; k < probeMuons.size(); k++) {
252  Muon & probe = targetMuons[k];
253  if (muon.charge() != probe.charge()) {
254  double mass = (muon.p4() + probe.p4()).M();
255  hists_["massVsEta_" + suffix]->Fill(mass, muon.eta());
256  }
257  }
258 
259  } // End loop over denominator and numerator.
260 
261  } // End loop over targetMuons.
262 
263  // Plot fake rates (efficiency for HLT objects to not get matched to RECO).
264  vector<size_t> hltMatches = matchByDeltaR(hltMuons, targetMuons,
265  plotCuts_[triggerLevel_ + "DeltaR"]);
266  for (size_t i = 0; i < hltMuons.size(); i++) {
267  TriggerObject & hltMuon = hltMuons[i];
268  bool isFake = hltMatches[i] > hltMuons.size();
269  for (size_t j = 0; j < 2; j++) {
270  string suffix = EFFICIENCY_SUFFIXES[j];
271  // If match is found, then numerator plots should not get filled
272  if (suffix == "numer" && ! isFake) continue;
273  hists_["fakerateEta_" + suffix]->Fill(hltMuon.eta());
274  hists_["fakeratePhi_" + suffix]->Fill(hltMuon.phi());
275  hists_["fakerateTurnOn_" + suffix]->Fill(hltMuon.pt());
276  } // End loop over numerator and denominator.
277  } // End loop over hltMuons.
278 
279 
280 } // 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]
tuple d0
Definition: debug_cff.py:3
virtual TrackRef innerTrack() const
Definition: Muon.h:38
float phi() const
Definition: TriggerObject.h:60
edm::ParameterSet targetParams_
bool isTrackerMuon() const
Definition: Muon.h:149
std::map< std::string, MonitorElement * > hists_
float eta() const
Definition: TriggerObject.h:59
bool isStandAloneMuon() const
Definition: Muon.h:150
virtual double eta() const
momentum pseudorapidity
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
std::vector< size_t > matchByDeltaR(const std::vector< T1 > &, const std::vector< T2 > &, const double maxDeltaR=NOMATCH)
virtual int charge() const
electric charge
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:355
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:41
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 double pt() const
transverse momentum
std::map< std::string, edm::InputTag > inputTags_
trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &, const edm::ParameterSet &)
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
virtual double phi() const
momentum azimuthal angle
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
std::map< std::string, double > plotCuts_
tuple size
Write out results.
void HLTMuonMatchAndPlot::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 99 of file HLTMuonMatchAndPlot.cc.

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

101 {
102 
103  TPRegexp suffixPtCut("Mu[0-9]+$");
104 
105  string baseDir = destination_;
106  if (baseDir[baseDir.size() - 1] != '/') baseDir += '/';
107  string pathSansSuffix = hltPath_;
108  if (hltPath_.rfind("_v") < hltPath_.length())
109  pathSansSuffix = hltPath_.substr(0, hltPath_.rfind("_v"));
110  dbe_->setCurrentFolder(baseDir + pathSansSuffix);
111 
112  // Form is book1D(name, binningType, title) where 'binningType' is used
113  // to fetch the bin settings from binParams_.
114  book1D("deltaR", "deltaR", ";#Deltar(reco, HLT);");
115  book1D("resolutionEta", "resolution",
116  ";(#eta^{reco}-#eta^{HLT})/|#eta^{reco}|;");
117  book1D("resolutionPhi", "resolution",
118  ";(#phi^{reco}-#phi^{HLT})/|#phi^{reco}|;");
119  book1D("resolutionPt", "resolution",
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  book2D("efficiencyPhiVsEta_" + suffix, "etaCoarse", "phiCoarse",
133  ";#eta;#phi");
134 
135  book1D("fakerateEta_" + suffix, "eta", ";#eta;");
136  book1D("fakeratePhi_" + suffix, "phi", ";#phi;");
137  book1D("fakerateTurnOn_" + suffix, "pt", ";p_{T};");
138 
139  // Charge Flip?
140 
141  // Book histograms for tag and probe
142  if (probeParams_.exists("recoCuts")) {
143  book2D("massVsEta_" + suffix, "zMass", "etaCoarse", ";m_{#mu#mu};#eta");
144  }
145 
146  }
147 
148 }
int i
Definition: DBlmapReader.cc:9
const std::string EFFICIENCY_SUFFIXES[2]
bool exists(std::string const &parameterName) const
checks if a parameter exists
void book1D(std::string, std::string, std::string)
void book2D(std::string, std::string, std::string, std::string)
edm::ParameterSet probeParams_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void HLTMuonMatchAndPlot::book1D ( std::string  ,
std::string  ,
std::string   
)
private

Definition at line 456 of file HLTMuonMatchAndPlot.cc.

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

Referenced by beginRun().

456  {
457 
458  size_t nBins;
459  float * edges;
460  fillEdges(nBins, edges, binParams_[binningType]);
461 
462  TH1F * h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
463  h->Sumw2();
464  hists_[name] = dbe_->book1D(name, h);
465  delete h;
466 
467 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void HLTMuonMatchAndPlot::book2D ( std::string  ,
std::string  ,
std::string  ,
std::string   
)
private

Definition at line 472 of file HLTMuonMatchAndPlot.cc.

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

Referenced by beginRun().

473  {
474 
475  size_t nBinsX;
476  float * edgesX;
477  fillEdges(nBinsX, edgesX, binParams_[binningTypeX]);
478 
479  size_t nBinsY;
480  float * edgesY;
481  fillEdges(nBinsY, edgesY, binParams_[binningTypeY]);
482 
483  TH2F * h = new TH2F(name.c_str(), title.c_str(),
484  nBinsX, edgesX, nBinsY, edgesY);
485  h->Sumw2();
486  hists_[name] = dbe_->book2D(name, h);
487  delete h;
488 
489 }
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_
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:642
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void HLTMuonMatchAndPlot::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 152 of file HLTMuonMatchAndPlot.cc.

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

Definition at line 286 of file HLTMuonMatchAndPlot.cc.

References i, and min.

Referenced by book1D(), and book2D().

287  {
288 
289  if (binning.size() < 3) {
290  LogWarning("HLTMuonVal") << "Invalid binning parameters!";
291  return;
292  }
293 
294  // Fixed-width binning.
295  if (binning.size() == 3) {
296  nBins = binning[0];
297  edges = new float[nBins + 1];
298  const double min = binning[1];
299  const double binwidth = (binning[2] - binning[1]) / nBins;
300  for (size_t i = 0; i <= nBins; i++) edges[i] = min + (binwidth * i);
301  }
302 
303  // Variable-width binning.
304  else {
305  nBins = binning.size() - 1;
306  edges = new float[nBins + 1];
307  for (size_t i = 0; i <= nBins; i++) edges[i] = binning[i];
308  }
309 
310 }
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 319 of file HLTMuonMatchAndPlot.cc.

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

320  {
321 
322  // Get the ParameterSet with name 'target' from 'pset'
323  ParameterSet targetPset;
324  if (pset.existsAs<ParameterSet>(target, true)) // target is tracked
325  targetPset = pset.getParameterSet(target);
326  else if (pset.existsAs<ParameterSet>(target, false)) // target is untracked
327  targetPset = pset.getUntrackedParameterSet(target);
328 
329  // Get the parameter names from targetPset
330  vector<string> names = targetPset.getParameterNames();
331  vector<string>::const_iterator iter;
332 
333  for (iter = names.begin(); iter != names.end(); ++iter) {
334  if (targetPset.existsAs<T>(* iter, true)) // target is tracked
335  m[* iter] = targetPset.getParameter<T>(* iter);
336  else if (targetPset.existsAs<T>(* iter, false)) // target is untracked
337  m[* iter] = targetPset.getUntrackedParameter<T>(* iter);
338  }
339 
340 }
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:181
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
static const HistoName names[]
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 347 of file HLTMuonMatchAndPlot.cc.

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

349  {
350 
351  const size_t n1 = collection1.size();
352  const size_t n2 = collection2.size();
353 
354  vector<size_t> result(n1, -1);
355  vector<vector<double> > deltaRMatrix(n1, vector<double>(n2, NOMATCH));
356 
357  for (size_t i = 0; i < n1; i++)
358  for (size_t j = 0; j < n2; j++) {
359  deltaRMatrix[i][j] = deltaR(collection1[i], collection2[j]);
360  }
361 
362  // Run through the matrix n1 times to make sure we've found all matches.
363  for (size_t k = 0; k < n1; k++) {
364  size_t i_min = -1;
365  size_t j_min = -1;
366  double minDeltaR = maxDeltaR;
367  // find the smallest deltaR
368  for (size_t i = 0; i < n1; i++)
369  for (size_t j = 0; j < n2; j++)
370  if (deltaRMatrix[i][j] < minDeltaR) {
371  i_min = i;
372  j_min = j;
373  minDeltaR = deltaRMatrix[i][j];
374  }
375  // If a match has been made, save it and make those candidates unavailable.
376  if (minDeltaR < maxDeltaR) {
377  result[i_min] = j_min;
378  deltaRMatrix[i_min] = vector<double>(n2, NOMATCH);
379  for (size_t i = 0; i < n1; i++)
380  deltaRMatrix[i][j_min] = NOMATCH;
381  }
382  }
383 
384  return result;
385 
386 }
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 391 of file HLTMuonMatchAndPlot.cc.

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

Referenced by analyze().

396 {
397  // If there is no selector (recoCuts does not exists), return an empty collection.
398  if (!hasRecoCuts)
399  return MuonCollection();
400 
401  MuonCollection reducedMuons(allMuons);
402  MuonCollection::iterator iter = reducedMuons.begin();
403  while (iter != reducedMuons.end()) {
404  const Track * track = 0;
405  if (iter->isTrackerMuon()) track = & * iter->innerTrack();
406  else if (iter->isStandAloneMuon()) track = & * iter->outerTrack();
407  if (track && selector(* iter) &&
408  fabs(track->dxy(beamSpot.position())) < d0Cut &&
409  fabs(track->dz(beamSpot.position())) < z0Cut)
410  ++iter;
411  else reducedMuons.erase(iter);
412  }
413 
414  return reducedMuons;
415 
416 }
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 421 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().

425 {
426 
427  // If pset is empty, return an empty collection.
428  if (!pset.exists("hltCuts"))
429  return TriggerObjectCollection();
430 
432  (pset.getUntrackedParameter<string>("hltCuts"));
433 
434  InputTag filterTag(moduleLabels_[moduleLabels_.size() - 1], "",
436  size_t filterIndex = triggerSummary.filterIndex(filterTag);
437 
438  TriggerObjectCollection selectedObjects;
439 
440  if (filterIndex < triggerSummary.sizeFilters()) {
441  const Keys &keys = triggerSummary.filterKeys(filterIndex);
442  for (size_t j = 0; j < keys.size(); j++ ){
443  TriggerObject foundObject = triggerObjects[keys[j]];
444  if (selector(foundObject))
445  selectedObjects.push_back(foundObject);
446  }
447  }
448 
449  return selectedObjects;
450 
451 }
T getUntrackedParameter(std::string const &, T const &) const
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:130
std::vector< std::string > moduleLabels_
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:106
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:118
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.

Referenced by beginRun().

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