CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
MuonPFAnalyzer Class Reference

#include <MuonPFAnalyzer.h>

Inheritance diagram for MuonPFAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Types

typedef std::vector< RecoGenPairRecoGenCollection
 
typedef std::pair< const
reco::Muon *, const
reco::GenParticle * > 
RecoGenPair
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 Perform the PF - TUNEP muon analysis. More...
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 Initialize an book plots. More...
 
 MuonPFAnalyzer (const edm::ParameterSet &)
 Constructor. More...
 
 ~MuonPFAnalyzer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

void bookHistos (const std::string &group)
 
float combRelIso (const reco::Muon *muon)
 
float fDeltaPhi (float phi1, float phi2)
 
void fillInRange (MonitorElement *plot, int nAxis, double x, double y=0)
 
MonitorElementgetPlot (const std::string &group, const std::string &type)
 
const reco::Vertex getPrimaryVertex (edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
 
int muonTrackType (const reco::Muon *muon, bool usePF)
 
void recoToGenMatch (edm::Handle< reco::MuonCollection > &reco, edm::Handle< reco::GenParticleCollection > &gen)
 
void setCodeLabels (MonitorElement *plot, int nAxis)
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpottheBeamSpotLabel_
 
DQMStoretheDbe
 
std::string theFolder
 
edm::EDGetTokenT
< reco::GenParticleCollection
theGenLabel_
 
double theHighPtTh
 
double theIsoCut
 
std::vector< std::string > theMuonKinds
 
std::map< std::string,
std::map< std::string,
MonitorElement * > > 
thePlots
 
RecoGenCollection theRecoGen
 
double theRecoGenR
 
edm::EDGetTokenT
< reco::MuonCollection
theRecoLabel_
 
bool theRunOnMC
 
edm::EDGetTokenT
< reco::VertexCollection
theVertexLabel_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 34 of file MuonPFAnalyzer.h.

Member Typedef Documentation

Definition at line 39 of file MuonPFAnalyzer.h.

typedef std::pair<const reco::Muon*, const reco::GenParticle*> MuonPFAnalyzer::RecoGenPair

Definition at line 38 of file MuonPFAnalyzer.h.

Constructor & Destructor Documentation

MuonPFAnalyzer::MuonPFAnalyzer ( const edm::ParameterSet pSet)
explicit

Constructor.

Definition at line 43 of file MuonPFAnalyzer.cc.

References edm::ParameterSet::getParameter(), and LogTrace.

43  {
44 
45  LogTrace("MuonPFAnalyzer") << "[MuonPFAnalyzer] Initializing configuration from parameterset.\n";
46 
47  theGenLabel_ = consumes<GenParticleCollection>(pSet.getParameter<InputTag>("inputTagGenParticles"));
48  theRecoLabel_ = consumes<MuonCollection> (pSet.getParameter<InputTag>("inputTagMuonReco"));
49  theVertexLabel_ = consumes<VertexCollection> (pSet.getParameter<InputTag>("inputTagVertex"));
50  theBeamSpotLabel_ = consumes<BeamSpot> (pSet.getParameter<InputTag>("inputTagBeamSpot"));
51 
52  theHighPtTh = pSet.getParameter<double>("highPtThreshold");
53  theRecoGenR = pSet.getParameter<double>("recoGenDeltaR");
54  theIsoCut = pSet.getParameter<double>("relCombIsoCut");
55  theRunOnMC = pSet.getParameter<bool>("runOnMC");
56 
57  theFolder = pSet.getParameter<string>("folder");
58 
59  theMuonKinds.push_back(""); // all TUNEP/PF muons
60  theMuonKinds.push_back("Tight"); // tight TUNEP/PF muons
61  theMuonKinds.push_back("TightIso"); // tight/iso TUNEP/PF muons
62 
63 
64 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > theVertexLabel_
edm::EDGetTokenT< reco::MuonCollection > theRecoLabel_
edm::EDGetTokenT< reco::GenParticleCollection > theGenLabel_
std::vector< std::string > theMuonKinds
#define LogTrace(id)
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotLabel_
std::string theFolder
MuonPFAnalyzer::~MuonPFAnalyzer ( )

Destructor.

Definition at line 67 of file MuonPFAnalyzer.cc.

References LogTrace.

68 {
69 
70  LogTrace("MuonPFAnalyzer") <<
71  "[MuonPFAnalyzer] Destructor called.\n";
72 
73 }
#define LogTrace(id)

Member Function Documentation

void MuonPFAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup context 
)
virtual

Perform the PF - TUNEP muon analysis.

Implements edm::EDAnalyzer.

Definition at line 106 of file MuonPFAnalyzer.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, reco::CompositeRefCandidateT< D >::begin(), eta(), dataDML::fillInRange(), reco::Muon::innerTrack(), edm::Ref< C, T, F >::isNull(), reco::Muon::isPFMuon(), muon::isTightMuon(), metsig::muon, patZpeak::muons, reco::LeafCandidate::p4(), phi, RecoTauCleanerPlugins::pt, reco::LeafCandidate::pt(), and reco::Muon::tunePMuonBestTrack().

108 {
109 
111  event.getByToken(theRecoLabel_, muons);
112 
114  event.getByToken(theGenLabel_, genMuons);
115 
117  event.getByToken(theBeamSpotLabel_, beamSpot);
118 
120  event.getByToken(theVertexLabel_, vertex);
121 
122  const Vertex primaryVertex = getPrimaryVertex(vertex, beamSpot);
123 
124  recoToGenMatch(muons, genMuons);
125 
126  RecoGenCollection::const_iterator recoGenIt = theRecoGen.begin();
127  RecoGenCollection::const_iterator recoGenEnd = theRecoGen.end();
128 
129  for (;recoGenIt!=recoGenEnd;++recoGenIt)
130  {
131 
132  const Muon *muon = recoGenIt->first;
133  TrackRef tunePTrack = muon->tunePMuonBestTrack();
134 
135  const GenParticle *genMuon = recoGenIt->second;
136 
137  vector<string>::const_iterator kindIt = theMuonKinds.begin();
138  vector<string>::const_iterator kindEnd = theMuonKinds.end();
139 
140  for (;kindIt!=kindEnd;++kindIt)
141  {
142 
143  const string & kind = (*kindIt);
144 
145  if (kind.find("Tight") != string::npos &&
146  !muon::isTightMuon((*muon), primaryVertex)) continue;
147 
148  if (kind.find("Iso") != string::npos &&
149  combRelIso(muon) > theIsoCut) continue;
150 
151  if (theRunOnMC && genMuon && !muon->innerTrack().isNull() ) // has matched gen muon
152  {
153 
154  if (!tunePTrack.isNull())
155  {
156 
157  string group = "TUNEP" + kind;
158 
159  float pt = tunePTrack->pt();
160  float phi = tunePTrack->phi();
161  float eta = tunePTrack->eta();
162 
163  float genPt = genMuon->pt();
164  float genPhi = genMuon->p4().phi();
165  float genEta = genMuon->p4().eta();
166 
167  float dPtOverPt = (pt / genPt) - 1;
168 
169  if (pt < theHighPtTh)
170  {
171 
172  fillInRange(getPlot(group,"code"),1,muonTrackType(muon, false));
173  fillInRange(getPlot(group,"deltaPtOverPt"),1,dPtOverPt);
174  }
175  else
176  {
177  fillInRange(getPlot(group,"codeHighPt"),1,muonTrackType(muon, false));
178  fillInRange(getPlot(group,"deltaPtOverPtHighPt"),1,dPtOverPt);
179  }
180 
181  fillInRange(getPlot(group,"deltaPt"),1,(pt - genPt));
182  fillInRange(getPlot(group,"deltaPhi"),1,fDeltaPhi(genPhi,phi));
183  fillInRange(getPlot(group,"deltaEta"),1,genEta - eta);
184 
185  }
186 
187  if (muon->isPFMuon())
188  {
189 
190  string group = "PF" + kind;
191 
192  // Assumes that default in muon is PF
193  float pt = muon->pt();
194  float phi = muon->p4().phi();
195  float eta = muon->p4().eta();
196 
197  float genPt = genMuon->pt();
198  float genPhi = genMuon->p4().phi();
199  float genEta = genMuon->p4().eta();
200 
201  float dPtOverPt = (pt / genPt) - 1;
202 
203  if (pt < theHighPtTh)
204  {
205  fillInRange(getPlot(group,"code"),1,muonTrackType(muon, true));
206  fillInRange(getPlot(group,"deltaPtOverPt"),1,dPtOverPt);
207  }
208  else
209  {
210  fillInRange(getPlot(group,"codeHighPt"),1,muonTrackType(muon, true));
211  fillInRange(getPlot(group,"deltaPtOverPtHighPt"),1,dPtOverPt);
212  }
213 
214 
215  fillInRange(getPlot(group,"deltaPt"),1,pt - genPt);
216  fillInRange(getPlot(group,"deltaPhi"),1,fDeltaPhi(genPhi,phi));
217  fillInRange(getPlot(group,"deltaEta"),1,genEta - eta);
218 
219  }
220 
221  }
222 
223 
224 
225  if (muon->isPFMuon() && !tunePTrack.isNull() &&
226  !muon->innerTrack().isNull()) // Compare PF with TuneP + Tracker
227  { // No gen matching needed
228 
229  string group = "PFvsTUNEP" + kind;
230 
231  float pt = tunePTrack->pt();
232  float phi = tunePTrack->phi();
233  float eta = tunePTrack->eta();
234 
235  // Assumes that default in muon is PF
236  float pfPt = muon->pt();
237  float pfPhi = muon->p4().phi();
238  float pfEta = muon->p4().eta();
239  float dPtOverPt = (pfPt / pt) - 1; // TUNEP vs PF pt used as denum.
240 
241 
242  if (pt < theHighPtTh)
243  {
244  fillInRange(getPlot(group,"code"),2,
245  muonTrackType(muon, false),muonTrackType(muon, true));
246  fillInRange(getPlot(group,"deltaPtOverPt"),1,dPtOverPt);
247  }
248  else
249  {
250  fillInRange(getPlot(group,"codeHighPt"),
251  2,muonTrackType(muon, false),muonTrackType(muon, true));
252  fillInRange(getPlot(group,"deltaPtOverPtHighPt"),1,dPtOverPt);
253  }
254 
255  fillInRange(getPlot(group,"deltaPt"),1,pfPt - pt);
256  fillInRange(getPlot(group,"deltaPhi"),1,fDeltaPhi(pfPhi,phi));
257  fillInRange(getPlot(group,"deltaEta"),1,pfEta - eta);
258 
259 
260  if (theRunOnMC && genMuon) // has a matched gen muon
261 
262  {
263 
264  float genPt = genMuon->pt();
265  float dPtOverPtGen = (pt / genPt) - 1;
266  float dPtOverPtGenPF = (pfPt / genPt) - 1;
267 
268  if (pt < theHighPtTh)
269  {
270  fillInRange(getPlot(group,"deltaPtOverPtPFvsTUNEP"),
271  2,dPtOverPtGen,dPtOverPtGenPF);
272  }
273  else
274  {
275  fillInRange(getPlot(group,"deltaPtOverPtHighPtPFvsTUNEP"),
276  2,dPtOverPtGen,dPtOverPtGenPF);
277  }
278  }
279 
280  }
281 
282  }
283 
284  }
285 
286 }
int muonTrackType(const reco::Muon *muon, bool usePF)
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
edm::EDGetTokenT< reco::VertexCollection > theVertexLabel_
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
virtual TrackRef innerTrack() const
Definition: Muon.h:48
edm::EDGetTokenT< reco::MuonCollection > theRecoLabel_
T eta() const
RecoGenCollection theRecoGen
edm::EDGetTokenT< reco::GenParticleCollection > theGenLabel_
MonitorElement * getPlot(const std::string &group, const std::string &type)
std::vector< std::string > theMuonKinds
bool isNull() const
Checks for null.
Definition: Ref.h:247
void fillInRange(MonitorElement *plot, int nAxis, double x, double y=0)
float combRelIso(const reco::Muon *muon)
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotLabel_
float fDeltaPhi(float phi1, float phi2)
tuple muons
Definition: patZpeak.py:38
void recoToGenMatch(edm::Handle< reco::MuonCollection > &reco, edm::Handle< reco::GenParticleCollection > &gen)
bool isPFMuon() const
Definition: Muon.h:222
virtual TrackRef tunePMuonBestTrack() const
Definition: Muon.h:65
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
virtual float pt() const GCC11_FINAL
transverse momentum
Definition: DDAxes.h:10
void MuonPFAnalyzer::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
virtual

Initialize an book plots.

Reimplemented from edm::EDAnalyzer.

Definition at line 79 of file MuonPFAnalyzer.cc.

References bookHistos(), LogTrace, and cppFunctionSkipper::operator.

79  {
80 
81  LogTrace("MuonPFAnalyzer") <<
82  "[MuonPFAnalyzer] Booking histograms.\n";
83 
84  //Set up DAQ
85  theDbe = 0;
87  theDbe->cd();
88 
89  if(theRunOnMC)
90  {
91  bookHistos("PF");
92  bookHistos("PFTight");
93  bookHistos("PFTightIso");
94  bookHistos("TUNEP");
95  bookHistos("TUNEPTight");
96  bookHistos("TUNEPTightIso");
97  }
98 
99  bookHistos("PFvsTUNEP");
100  bookHistos("PFvsTUNEPTight");
101  bookHistos("PFvsTUNEPTightIso");
102 
103 
104 }
DQMStore * theDbe
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:562
void bookHistos(const std::string &group)
#define LogTrace(id)
void MuonPFAnalyzer::bookHistos ( const std::string &  group)
private

Definition at line 291 of file MuonPFAnalyzer.cc.

References LogTrace, and plotResiduals::plot().

291  {
292 
293 
294 
295  LogTrace("MuonPFAnalyzer") << "[MuonPFAnalyzer] Booking histos for group :"
296  << group << "\n";
297 
298  theDbe->setCurrentFolder(string(theFolder) + group);
299 
300 
301  bool isPFvsTUNEP = group.find("PFvsTUNEP") != string::npos;
302 
303  string hName;
304 
305 
306  hName = "deltaPtOverPt" + group;
307  thePlots[group]["deltaPtOverPt"] = theDbe->book1D(hName.c_str(),hName.c_str(),101,-1.01,1.01);
308 
309  hName = "deltaPtOverPtHighPt" + group;
310  thePlots[group]["deltaPtOverPtHighPt"] = theDbe->book1D(hName.c_str(),hName.c_str(),101,-1.01,1.01);
311 
312  hName = "deltaPt" + group;
313  thePlots[group]["deltaPt"] = theDbe->book1D(hName.c_str(),hName.c_str(),201.,-10.25,10.25);
314 
315  hName = "deltaPhi"+group;
316  thePlots[group]["deltaPhi"] = theDbe->book1D(hName.c_str(),hName.c_str(),51.,0,.0102);
317 
318  hName = "deltaEta"+group;
319  thePlots[group]["deltaEta"] = theDbe->book1D(hName.c_str(),hName.c_str(),101.,-.00505,.00505);
320 
321 
322 
323  if (isPFvsTUNEP) {
324 
325 
326  hName = "code"+group;
327  MonitorElement * plot = theDbe->book2D(hName.c_str(),hName.c_str(),7,-.5,6.5,7,-.5,6.5);
328  thePlots[group]["code"] = plot;
329  setCodeLabels(plot,1);
330  setCodeLabels(plot,2);
331 
332  hName = "codeHighPt"+group;
333  plot = theDbe->book2D(hName.c_str(),hName.c_str(),7,-.5,6.5,7,-.5,6.5);
334  thePlots[group]["codeHighPt"] = plot;
335  setCodeLabels(plot,1);
336  setCodeLabels(plot,2);
337 
338 
339  if (theRunOnMC)
340  {
341  hName = "deltaPtOverPtPFvsTUNEP" + group;
342  thePlots[group]["deltaPtOverPtPFvsTUNEP"] =
343  theDbe->book2D(hName.c_str(),hName.c_str(),
344  101,-1.01,1.01,101,-1.01,1.01);
345 
346  hName = "deltaPtOverPtHighPtPFvsTUNEP" + group;
347  thePlots[group]["deltaPtOverPtHighPtPFvsTUNEP"] =
348  theDbe->book2D(hName.c_str(),hName.c_str(),
349  101,-1.01,1.01,101,-1.01,1.01);
350  }
351  } else {
352  hName = "code"+group;
353  MonitorElement * plot = theDbe->book1D(hName.c_str(),hName.c_str(),7,-.5,6.5);
354  thePlots[group]["code"] = plot;
355  setCodeLabels(plot,1);
356 
357  hName = "codeHighPt"+group;
358  plot = theDbe->book1D(hName.c_str(),hName.c_str(),7,-.5,6.5);
359  thePlots[group]["codeHighPt"] = plot;
360  setCodeLabels(plot,1);
361  }
362 
363 }
DQMStore * theDbe
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:873
void setCodeLabels(MonitorElement *plot, int nAxis)
#define LogTrace(id)
std::map< std::string, std::map< std::string, MonitorElement * > > thePlots
std::string theFolder
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:1001
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
float MuonPFAnalyzer::combRelIso ( const reco::Muon muon)
inlineprivate

Definition at line 389 of file MuonPFAnalyzer.cc.

References reco::MuonIsolation::emEt, reco::MuonIsolation::hadEt, reco::Muon::isolationR03(), reco::LeafCandidate::pt(), and reco::MuonIsolation::sumPt.

390 {
391 
392  MuonIsolation iso = muon->isolationR03();
393  float combRelIso = (iso.emEt + iso.hadEt + iso.sumPt) / muon->pt();
394 
395  return combRelIso;
396 
397 }
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:9
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:7
float combRelIso(const reco::Muon *muon)
float emEt
ecal sum-Et
Definition: MuonIsolation.h:8
virtual float pt() const GCC11_FINAL
transverse momentum
const MuonIsolation & isolationR03() const
Definition: Muon.h:158
float MuonPFAnalyzer::fDeltaPhi ( float  phi1,
float  phi2 
)
inlineprivate

Definition at line 400 of file MuonPFAnalyzer.cc.

References funct::cos().

400  {
401 
402  float fPhiDiff = fabs(acos(cos(phi1-phi2)));
403  return fPhiDiff;
404 
405 }
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void MuonPFAnalyzer::fillInRange ( MonitorElement plot,
int  nAxis,
double  x,
double  y = 0 
)
private

Definition at line 434 of file MuonPFAnalyzer.cc.

References MonitorElement::Fill(), MonitorElement::getTH1(), timingPdfMaker::histo, i, edm::max(), edm::min(), relativeConstraints::value, x, and detailsBasic3DVector::y.

435 {
436 
437  TH1 * histo = plot->getTH1();
438 
439  TAxis *axis[2] = {0, 0};
440  axis[0] = histo->GetXaxis();
441  if (nAxis == 2)
442  axis[1] = histo->GetYaxis();
443 
444  double value[2] = {0, 0};
445  value[0] = x;
446  value[1] = y;
447 
448  for (int i = 0;i<nAxis;++i)
449  {
450  double min = axis[i]->GetXmin();
451  double max = axis[i]->GetXmax();
452 
453  if (value[i] <= min)
454  value[i] = axis[i]->GetBinCenter(1);
455 
456  if (value[i] >= max)
457  value[i] = axis[i]->GetBinCenter(axis[i]->GetNbins());
458  }
459 
460  if (nAxis == 2)
461  plot->Fill(value[0],value[1]);
462  else
463  plot->Fill(value[0]);
464 
465 }
int i
Definition: DBlmapReader.cc:9
void Fill(long long x)
const T & max(const T &a, const T &b)
TH1 * getTH1(void) const
Definition: DDAxes.h:10
MonitorElement * MuonPFAnalyzer::getPlot ( const std::string &  group,
const std::string &  type 
)
private

Definition at line 366 of file MuonPFAnalyzer.cc.

References LogTrace.

367  {
368 
369  map<string,map<string,MonitorElement *> >::iterator groupIt = thePlots.find(group);
370  if (groupIt == thePlots.end()) {
371  LogTrace("MuonPFAnalyzer") << "[MuonPFAnalyzer] GROUP : " << group
372  << " is not a valid plot group. Returning 0.\n";
373  return 0;
374  }
375 
376  map<string,MonitorElement *>::iterator typeIt = groupIt->second.find(type);
377  if (typeIt == groupIt->second.end()) {
378  LogTrace("MuonPFAnalyzer") << "[MuonPFAnalyzer] TYPE : " << type
379  << " is not a valid type for GROUP : " << group
380  << ". Returning 0.\n";
381  return 0;
382  }
383 
384  return typeIt->second;
385 
386 }
type
Definition: HCALResponse.h:21
#define LogTrace(id)
std::map< std::string, std::map< std::string, MonitorElement * > > thePlots
const reco::Vertex MuonPFAnalyzer::getPrimaryVertex ( edm::Handle< reco::VertexCollection > &  vertex,
edm::Handle< reco::BeamSpot > &  beamSpot 
)
private

Definition at line 549 of file MuonPFAnalyzer.cc.

References edm::HandleBase::isValid().

551 {
552 
553  Vertex::Point posVtx;
554  Vertex::Error errVtx;
555 
556  bool hasPrimaryVertex = false;
557 
558  if (vertex.isValid())
559  {
560 
561  vector<Vertex>::const_iterator vertexIt = vertex->begin();
562  vector<Vertex>::const_iterator vertexEnd = vertex->end();
563 
564  for (;vertexIt!=vertexEnd;++vertexIt)
565  {
566  if (vertexIt->isValid() &&
567  !vertexIt->isFake())
568  {
569  posVtx = vertexIt->position();
570  errVtx = vertexIt->error();
571  hasPrimaryVertex = true;
572  break;
573  }
574  }
575  }
576 
577  if ( !hasPrimaryVertex ) {
578 
579  LogInfo("MuonPFAnalyzer") <<
580  "[MuonPFAnalyzer] PrimaryVertex not found, use BeamSpot position instead.\n";
581 
582  posVtx = beamSpot->position();
583  errVtx(0,0) = beamSpot->BeamWidthX();
584  errVtx(1,1) = beamSpot->BeamWidthY();
585  errVtx(2,2) = beamSpot->sigmaZ();
586 
587  }
588 
589  const Vertex primaryVertex(posVtx,errVtx);
590 
591  return primaryVertex;
592 
593 }
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
bool isValid() const
Definition: HandleBase.h:76
int MuonPFAnalyzer::muonTrackType ( const reco::Muon muon,
bool  usePF 
)
private

Definition at line 468 of file MuonPFAnalyzer.cc.

References reco::Muon::muonBestTrackType(), and reco::Muon::tunePMuonBestTrackType().

468  {
469 
470  switch ( usePF ? muon->muonBestTrackType() : muon->tunePMuonBestTrackType() ) {
471  case Muon::InnerTrack :
472  return 0;
473  case Muon::OuterTrack :
474  return 1;
475  case Muon::CombinedTrack :
476  return 2;
477  case Muon::TPFMS :
478  return 3;
479  case Muon::Picky :
480  return 4;
481  case Muon::DYT :
482  return 5;
483  case Muon::None :
484  return 6;
485  }
486 
487  return 6;
488 
489 }
virtual MuonTrackType muonBestTrackType() const
Definition: Muon.h:64
virtual MuonTrackType tunePMuonBestTrackType() const
Definition: Muon.h:66
void MuonPFAnalyzer::recoToGenMatch ( edm::Handle< reco::MuonCollection > &  reco,
edm::Handle< reco::GenParticleCollection > &  gen 
)
private

Definition at line 492 of file MuonPFAnalyzer.cc.

References funct::abs(), deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, edm::HandleBase::isValid(), PatBasicFWLiteAnalyzer::muonEta, and PatBasicFWLiteAnalyzer::muonPhi.

494 {
495 
496  theRecoGen.clear();
497 
498  if (muons.isValid())
499  {
500 
501  MuonCollection::const_iterator muonIt = muons->begin();
502  MuonCollection::const_iterator muonEnd = muons->end();
503 
504  for(; muonIt!=muonEnd; ++muonIt)
505  {
506 
507  float bestDR = 999.;
508  const GenParticle *bestGen = 0;
509 
510  if (theRunOnMC && gens.isValid())
511  {
512 
513  GenParticleCollection::const_iterator genIt = gens->begin();
514  GenParticleCollection::const_iterator genEnd = gens->end();
515 
516  for(; genIt!=genEnd; ++genIt)
517  {
518 
519  if (abs(genIt->pdgId()) == 13 )
520  {
521 
522  float muonPhi = muonIt->phi();
523  float muonEta = muonIt->eta();
524 
525  float genPhi = genIt->phi();
526  float genEta = genIt->eta();
527 
528  float dR = deltaR(muonEta,muonPhi,
529  genEta,genPhi);
530 
531  if (dR < theRecoGenR && dR < bestDR)
532  {
533  bestDR = dR;
534  bestGen = &(*genIt);
535  }
536 
537  }
538 
539  }
540  }
541 
542  theRecoGen.push_back(RecoGenPair(&(*muonIt), bestGen));
543 
544  }
545  }
546 
547 }
RecoGenCollection theRecoGen
virtual const_iterator end() const =0
last daughter const_iterator
virtual const_iterator begin() const
first daughter const_iterator
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
tuple muons
Definition: patZpeak.py:38
std::pair< const reco::Muon *, const reco::GenParticle * > RecoGenPair
void MuonPFAnalyzer::setCodeLabels ( MonitorElement plot,
int  nAxis 
)
private

Definition at line 408 of file MuonPFAnalyzer.cc.

References MonitorElement::getTH1(), and timingPdfMaker::histo.

409 {
410 
411  TAxis *axis = 0;
412 
413  TH1 * histo = plot->getTH1();
414  if(!histo) return;
415 
416  if (nAxis==1)
417  axis =histo->GetXaxis();
418  else if (nAxis == 2)
419  axis =histo->GetYaxis();
420 
421  if(!axis) return;
422 
423  axis->SetBinLabel(1,"Inner Track");
424  axis->SetBinLabel(2,"Outer Track");
425  axis->SetBinLabel(3,"Combined");
426  axis->SetBinLabel(4,"TPFMS");
427  axis->SetBinLabel(5,"Picky");
428  axis->SetBinLabel(6,"DYT");
429  axis->SetBinLabel(7,"None");
430 
431 }
TH1 * getTH1(void) const

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> MuonPFAnalyzer::theBeamSpotLabel_
private

Definition at line 88 of file MuonPFAnalyzer.h.

DQMStore* MuonPFAnalyzer::theDbe
private

Definition at line 92 of file MuonPFAnalyzer.h.

std::string MuonPFAnalyzer::theFolder
private

Definition at line 103 of file MuonPFAnalyzer.h.

edm::EDGetTokenT<reco::GenParticleCollection> MuonPFAnalyzer::theGenLabel_
private

Definition at line 85 of file MuonPFAnalyzer.h.

double MuonPFAnalyzer::theHighPtTh
private

Definition at line 97 of file MuonPFAnalyzer.h.

double MuonPFAnalyzer::theIsoCut
private

Definition at line 99 of file MuonPFAnalyzer.h.

std::vector<std::string> MuonPFAnalyzer::theMuonKinds
private

Definition at line 90 of file MuonPFAnalyzer.h.

std::map<std::string,std::map<std::string,MonitorElement*> > MuonPFAnalyzer::thePlots
private

Definition at line 94 of file MuonPFAnalyzer.h.

RecoGenCollection MuonPFAnalyzer::theRecoGen
private

Definition at line 95 of file MuonPFAnalyzer.h.

double MuonPFAnalyzer::theRecoGenR
private

Definition at line 98 of file MuonPFAnalyzer.h.

edm::EDGetTokenT<reco::MuonCollection> MuonPFAnalyzer::theRecoLabel_
private

Definition at line 86 of file MuonPFAnalyzer.h.

bool MuonPFAnalyzer::theRunOnMC
private

Definition at line 101 of file MuonPFAnalyzer.h.

edm::EDGetTokenT<reco::VertexCollection> MuonPFAnalyzer::theVertexLabel_
private

Definition at line 87 of file MuonPFAnalyzer.h.