CMS 3D CMS Logo

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 //
9 //
10 //____________________________________________________________________________||
13 
14 //____________________________________________________________________________||
16  if (pfCands.empty())
17  return SpecificPFMETData();
18 
19  double NeutralEMEt = 0.0;
20  double NeutralHadEt = 0.0;
21  double ChargedEMEt = 0.0;
22  double ChargedHadEt = 0.0;
23  double MuonEt = 0.0;
24  double type6Et = 0.0;
25  double type7Et = 0.0;
26 
27  for (edm::View<reco::Candidate>::const_iterator iPfCand = pfCands.begin(); iPfCand != pfCands.end(); ++iPfCand) {
28  const reco::Candidate* pfCand = dynamic_cast<const reco::Candidate*>(&(*iPfCand));
29  if (!pfCand)
30  continue;
31  const double theta = pfCand->theta();
32  const double e = pfCand->energy();
33  const double et = e * sin(theta);
34  switch (abs(pfCand->pdgId())) {
35  case 211:
36  ChargedHadEt += et;
37  break;
38  case 11:
39  ChargedEMEt += et;
40  break;
41  case 13:
42  MuonEt += et;
43  break;
44  case 22:
45  NeutralEMEt += et;
46  break;
47  case 130:
48  NeutralHadEt += et;
49  break;
50  case 1:
51  type6Et += et;
52  break;
53  case 2:
54  type7Et += et;
55  break;
56  }
57  }
58 
59  const double Et_total = NeutralEMEt + NeutralHadEt + ChargedEMEt + ChargedHadEt + MuonEt + type6Et + type7Et;
61  if (Et_total != 0.0) {
62  specific.NeutralEMFraction = NeutralEMEt / Et_total;
63  specific.NeutralHadFraction = NeutralHadEt / Et_total;
64  specific.ChargedEMFraction = ChargedEMEt / Et_total;
65  specific.ChargedHadFraction = ChargedHadEt / Et_total;
66  specific.MuonFraction = MuonEt / Et_total;
67  specific.Type6Fraction = type6Et / Et_total;
68  specific.Type7Fraction = type7Et / Et_total;
69  }
70  return specific;
71 }
72 
73 //____________________________________________________________________________||
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
virtual double energy() const =0
energy
const_iterator begin() const
virtual int pdgId() const =0
PDG identifier.
bool empty() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MET made from Particle Flow Candidates.
SpecificPFMETData run(const edm::View< reco::Candidate > &pfCands)
virtual double theta() const =0
momentum polar angle
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
const_iterator end() const