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 //____________________________________________________________________________||
reco::Candidate::energy
virtual double energy() const =0
energy
HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
edm::View::empty
bool empty() const
PFCandidate.h
SpecificPFMETData
MET made from Particle Flow Candidates.
Definition: SpecificPFMETData.h:12
mps_merge.weight
weight
Definition: mps_merge.py:88
edm::View::ptrs
std::vector< Ptr< value_type > > const & ptrs() const
PFSpecificAlgo::run
SpecificPFMETData run(const edm::View< reco::Candidate > &pfCands, edm::ValueMap< float > const *weights=nullptr)
Definition: PFSpecificAlgo.cc:15
reco::Candidate::get
T get() const
get a component
Definition: Candidate.h:221
reco::Candidate::theta
virtual double theta() const =0
momentum polar angle
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
timingPdfMaker.specific
specific
Definition: timingPdfMaker.py:78
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
edm::View
Definition: CaloClusterFwd.h:14
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
reco::Candidate
Definition: Candidate.h:27
PFSpecificAlgo.h
edm::ValueMap< float >
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
weight
Definition: weight.py:1
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37