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 (auto const& pfCandPtr : pfCands.ptrs()) {
28  const reco::Candidate* pfCand = pfCandPtr.get();
29  float weight = (weights != nullptr) ? (*weights)[pfCandPtr] : 1.0;
30  if (!pfCand)
31  continue;
32  const double theta = pfCand->theta();
33  const double e = pfCand->energy() * weight;
34  const double et = e * sin(theta);
35  switch (abs(pfCand->pdgId())) {
36  case 211:
37  ChargedHadEt += et;
38  break;
39  case 11:
40  ChargedEMEt += et;
41  break;
42  case 13:
43  MuonEt += et;
44  break;
45  case 22:
46  NeutralEMEt += et;
47  break;
48  case 130:
49  NeutralHadEt += et;
50  break;
51  case 1:
52  type6Et += et;
53  break;
54  case 2:
55  type7Et += et;
56  break;
57  }
58  }
59 
60  const double Et_total = NeutralEMEt + NeutralHadEt + ChargedEMEt + ChargedHadEt + MuonEt + type6Et + type7Et;
62  if (Et_total != 0.0) {
63  specific.NeutralEMFraction = NeutralEMEt / Et_total;
64  specific.NeutralHadFraction = NeutralHadEt / Et_total;
65  specific.ChargedEMFraction = ChargedEMEt / Et_total;
66  specific.ChargedHadFraction = ChargedHadEt / Et_total;
67  specific.MuonFraction = MuonEt / Et_total;
68  specific.Type6Fraction = type6Et / Et_total;
69  specific.Type7Fraction = type7Et / Et_total;
70  }
71  return specific;
72 }
73 
74 //____________________________________________________________________________||
SpecificPFMETData run(const edm::View< reco::Candidate > &pfCands, edm::ValueMap< float > const *weights=nullptr)
virtual double energy() const =0
energy
std::vector< Ptr< value_type > > const & ptrs() const
bool empty() const
T get() const
get a component
Definition: Candidate.h:221
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Definition: weight.py:1
virtual double theta() const =0
momentum polar angle
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MET made from Particle Flow Candidates.
virtual int pdgId() const =0
PDG identifier.
Geom::Theta< T > theta() const