CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFSpecificAlgo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: METAlgorithms
4 // Class: PFSpecificAlgo
5 //
6 // Original Authors: R. Remington (UF), R. Cavanaugh (UIC/Fermilab)
7 // Created: October 27, 2008
8 // $Id: PFSpecificAlgo.cc,v 1.13 2012/06/10 16:37:16 sakuma Exp $
9 //
10 //
11 //____________________________________________________________________________||
15 
16 //____________________________________________________________________________||
17 using namespace reco;
18 
19 //____________________________________________________________________________||
21 {
22  SpecificPFMETData specific = mkSpecificPFMETData(PFCandidates);
23 
24  const LorentzVector p4(met.mex , met.mey, 0.0, met.met);
25  const Point vtx(0.0,0.0,0.0);
26  PFMET pfMET(specific, met.sumet, p4, vtx );
27 
28  if(doSignificance) pfMET.setSignificanceMatrix(mkSignifMatrix(PFCandidates));
29 
30  return pfMET;
31 }
32 
33 //____________________________________________________________________________||
35 {
36  doSignificance = true;
37  pfsignalgo_.setResolutions( &resolutions );
38  pfsignalgo_.addPFJets(jets);
39 }
40 
41 //____________________________________________________________________________||
43 {
44  specific.NeutralEMFraction = 0.0;
45  specific.NeutralHadFraction = 0.0;
46  specific.ChargedEMFraction = 0.0;
47  specific.ChargedHadFraction = 0.0;
48  specific.MuonFraction = 0.0;
49  specific.Type6Fraction = 0.0;
50  specific.Type7Fraction = 0.0;
51 }
52 
53 //____________________________________________________________________________||
55 {
56  if(!PFCandidates->size())
57  {
59  initializeSpecificPFMETData(specific);
60  return specific;
61  }
62 
63  double NeutralEMEt = 0.0;
64  double NeutralHadEt = 0.0;
65  double ChargedEMEt = 0.0;
66  double ChargedHadEt = 0.0;
67  double MuonEt = 0.0;
68  double type6Et = 0.0;
69  double type7Et = 0.0;
70 
71  for( edm::View<reco::Candidate>::const_iterator iParticle = (PFCandidates.product())->begin(); iParticle != (PFCandidates.product())->end(); ++iParticle )
72  {
73  const PFCandidate* pfCandidate = dynamic_cast<const PFCandidate*> (&(*iParticle));
74  if (!pfCandidate) continue;
75  const double theta = pfCandidate->theta();
76  const double e = pfCandidate->energy();
77  const double et = e*sin(theta);
78 
79  if (pfCandidate->particleId() == 1) ChargedHadEt += et;
80  if (pfCandidate->particleId() == 2) ChargedEMEt += et;
81  if (pfCandidate->particleId() == 3) MuonEt += et;
82  if (pfCandidate->particleId() == 4) NeutralEMEt += et;
83  if (pfCandidate->particleId() == 5) NeutralHadEt += et;
84  if (pfCandidate->particleId() == 6) type6Et += et;
85  if (pfCandidate->particleId() == 7) type7Et += et;
86 
87 
88  }
89 
90  const double Et_total = NeutralEMEt + NeutralHadEt + ChargedEMEt + ChargedHadEt + MuonEt + type6Et + type7Et;
92  initializeSpecificPFMETData(specific);
93  if (Et_total!=0.0)
94  {
95  specific.NeutralEMFraction = NeutralEMEt/Et_total;
96  specific.NeutralHadFraction = NeutralHadEt/Et_total;
97  specific.ChargedEMFraction = ChargedEMEt/Et_total;
98  specific.ChargedHadFraction = ChargedHadEt/Et_total;
99  specific.MuonFraction = MuonEt/Et_total;
100  specific.Type6Fraction = type6Et/Et_total;
101  specific.Type7Fraction = type7Et/Et_total;
102  }
103  return specific;
104 }
105 
106 //____________________________________________________________________________||
108 {
109  pfsignalgo_.useOriginalPtrs(PFCandidates.id());
110  for(edm::View<reco::Candidate>::const_iterator iParticle = (PFCandidates.product())->begin(); iParticle != (PFCandidates.product())->end(); ++iParticle )
111  {
112  const PFCandidate* pfCandidate = dynamic_cast<const PFCandidate*> (&(*iParticle));
113  if (!pfCandidate) continue;
114  reco::CandidatePtr dau(PFCandidates, iParticle - PFCandidates->begin());
115  if(dau.isNull()) continue;
116  if(!dau.isAvailable()) continue;
117  reco::PFCandidatePtr pf(dau.id(), pfCandidate, dau.key());
118  pfsignalgo_.addPFCandidate(pf);
119  }
120  return pfsignalgo_.getSignifMatrix();
121 }
122 
123 //____________________________________________________________________________||
virtual double energy() const GCC11_FINAL
energy
dictionary specific
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
void initializeSpecificPFMETData(SpecificPFMETData &specific)
math::XYZPoint Point
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
virtual double theta() const GCC11_FINAL
momentum polar angle
tuple pfMET
Definition: pfMET_cfi.py:7
double p4[4]
Definition: TauolaWrapper.h:92
vector< PseudoJet > jets
Structure containing data common to all types of MET.
Definition: CommonMETData.h:22
#define end
Definition: vmac.h:38
void setSignificanceMatrix(const TMatrixD &matrix)
Definition: MET.cc:185
math::XYZTLorentzVector LorentzVector
MET made from Particle Flow Candidates.
TMatrixD mkSignifMatrix(edm::Handle< edm::View< reco::Candidate > > &PFCandidates)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:35
#define begin
Definition: vmac.h:31
void runSignificance(metsig::SignAlgoResolutions &resolutions, edm::Handle< edm::View< reco::PFJet > > jets)
reco::PFMET addInfo(edm::Handle< edm::View< reco::Candidate > > PFCandidates, CommonMETData met)
SpecificPFMETData mkSpecificPFMETData(edm::Handle< edm::View< reco::Candidate > > &PFCandidates)
virtual ParticleType particleId() const
Definition: PFCandidate.h:347
tuple PFCandidates