CMS 3D CMS Logo

List of all members | Public Member Functions
PFSpecificAlgo Class Reference

#include <RecoMET/METAlgorithms/interface/PFSpecificAlgo.h>

Public Member Functions

 PFSpecificAlgo ()
 
SpecificPFMETData run (const edm::View< reco::Candidate > &pfCands, edm::ValueMap< float > const *weights=nullptr)
 

Detailed Description

Description: Adds Particle Flow specific information to MET

Implementation: [Notes on implementation]

Definition at line 28 of file PFSpecificAlgo.h.

Constructor & Destructor Documentation

◆ PFSpecificAlgo()

PFSpecificAlgo::PFSpecificAlgo ( )
inline

Definition at line 30 of file PFSpecificAlgo.h.

30 {}

Member Function Documentation

◆ run()

SpecificPFMETData PFSpecificAlgo::run ( const edm::View< reco::Candidate > &  pfCands,
edm::ValueMap< float > const *  weights = nullptr 
)

Definition at line 15 of file PFSpecificAlgo.cc.

References funct::abs(), MillePedeFileConverter_cfg::e, edm::View< T >::empty(), reco::Candidate::energy(), l1tnanotables_cff::et, reco::Candidate::get(), reco::Candidate::pdgId(), edm::View< T >::ptrs(), funct::sin(), timingPdfMaker::specific, reco::Candidate::theta(), theta(), mps_merge::weight, and hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights.

Referenced by reco::PFMETProducerMVA::produce().

15  {
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 }
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