CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PFMETAlgo.cc
Go to the documentation of this file.
2 
4 
8 
10 
11 using namespace std;
12 using namespace edm;
13 using namespace reco;
14 using namespace math;
15 using namespace pf2pat;
16 
17 PFMETAlgo::PFMETAlgo(const edm::ParameterSet& iConfig) {
18  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
19 
20  hfCalibFactor_ = iConfig.getParameter<double>("hfCalibFactor");
21 }
22 
23 PFMETAlgo::~PFMETAlgo() {}
24 
26  double sumEx = 0;
27  double sumEy = 0;
28  double sumEt = 0;
29 
30  for (unsigned i = 0; i < pfCandidates.size(); i++) {
31  const reco::PFCandidate& cand = pfCandidates[i];
32 
33  double E = cand.energy();
34 
36  if (cand.particleId() == PFCandidate::h_HF || cand.particleId() == PFCandidate::egamma_HF)
37  E *= hfCalibFactor_;
38 
39  double phi = cand.phi();
40  double cosphi = cos(phi);
41  double sinphi = sin(phi);
42 
43  double theta = cand.theta();
44  double sintheta = sin(theta);
45 
46  double et = E * sintheta;
47  double ex = et * cosphi;
48  double ey = et * sinphi;
49 
50  sumEx += ex;
51  sumEy += ey;
52  sumEt += et;
53  }
54 
55  double Et = sqrt(sumEx * sumEx + sumEy * sumEy);
56  XYZTLorentzVector missingEt(-sumEx, -sumEy, 0, Et);
57 
58  if (verbose_) {
59  cout << "PFMETAlgo: mEx, mEy, mEt = " << missingEt.X() << ", " << missingEt.Y() << ", " << missingEt.T() << endl;
60  }
61 
62  XYZPoint vertex; // dummy vertex
63  return MET(sumEt, missingEt, vertex);
64 }
T getUntrackedParameter(std::string const &, T const &) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
double theta() const final
momentum polar angle
Definition: MET.h:41
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
tuple cout
Definition: gather_cfg.py:144
virtual ParticleType particleId() const
Definition: PFCandidate.h:392
double phi() const final
momentum azimuthal angle
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:25
double energy() const final
energy