CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProtoJet.cc
Go to the documentation of this file.
1 // ProtJet2.cc
2 // Revision History: R. Harris 10/19/05 Modified to work with real CaloTowers from Jeremy Mans
3 //
4 // #include <stdio.h>
5 // #include "stl_algobase.h"
6 // #include "stl_algo.h"
7 
11 
12 #include <vector>
13 #include <algorithm> // include STL algorithm implementations
14 #include <numeric> // For the use of numeric
15 
16 
17 namespace {
18  class ERecombination {
19  public: inline double weight (const reco::Candidate& c) {return c.energy();}
20  };
21  class EtRecombination {
22  public: inline double weight (const reco::Candidate& c) {return c.et();}
23  };
24  class PRecombination {
25  public: inline double weight (const reco::Candidate& c) {return c.p();}
26  };
27  class PtRecombination {
28  public: inline double weight (const reco::Candidate& c) {return c.pt();}
29  };
30 
31  template <class T>
32  inline ProtoJet::LorentzVector calculateLorentzVectorRecombination(const ProtoJet::Constituents& fConstituents) {
33  T weightMaker;
35  double weights = 0;
36  for(ProtoJet::Constituents::const_iterator i = fConstituents.begin(); i != fConstituents.end(); ++i) {
37  const ProtoJet::Constituent c = *i;
38  double weight = weightMaker.weight (*c);
39  result += c->p4() * weight;
40  weights += weight;
41  } //end of loop over the jet constituents
42  result = result / weights;
43  return result;
44  }
45 
46 }
47 
49  : mOrdered (false),
50  mJetArea (0),
51  mPileupEnergy (0),
52  mPassNumber (0)
53 {}
54 
55 ProtoJet::ProtoJet(const Constituents& fConstituents)
56  : mConstituents (fConstituents),
57  mOrdered (false),
58  mJetArea (0),
59  mPileupEnergy (0),
60  mPassNumber (0)
61 {
63 }
64 
65 ProtoJet::ProtoJet(const LorentzVector& fP4, const Constituents& fConstituents)
66  : mP4 (fP4),
67  mConstituents (fConstituents),
68  mOrdered (false),
69  mJetArea (0),
70  mPileupEnergy (0),
71  mPassNumber (0)
72 
73 {}
74 
75 void ProtoJet::setJetArea (float fArea) {mJetArea = fArea;}
76 float ProtoJet::jetArea () const {return mJetArea;}
77 void ProtoJet::setPileup (float fEnergy) {mPileupEnergy = fEnergy;}
78 float ProtoJet::pileup () const {return mPileupEnergy;}
79 void ProtoJet::setNPasses (int fPasses) {mPassNumber = fPasses;}
80 int ProtoJet::nPasses () const {return mPassNumber;}
81 
83  reorderTowers ();
84  return mConstituents;
85 }
86 
88  if (mOrdered) return mConstituents;
90  sortByEtRef (&result);
91  return result;
92 }
93 
95  if (!mOrdered) std::cerr << "ProtoJet::getPresortedTowerList-> ERROR: constituents are not sorted." << std::endl;
96  return mConstituents;
97 }
98 
99 void ProtoJet::putTowers(const Constituents& towers) {
100  mConstituents = towers;
101  mOrdered = false;
103 }
104 
106  if (!mOrdered) {
107  sortByEtRef (&mConstituents);
108  mOrdered = true;
109  }
110 }
111 
113  mP4 = LorentzVector (0,0,0,0);
114  for(Constituents::const_iterator i = mConstituents.begin(); i != mConstituents.end(); ++i) {
115  const Constituent c = *i;
116  mP4 += c->p4();
117  } //end of loop over the jet constituents
118 }
119 
121  mP4 = calculateLorentzVectorRecombination <EtRecombination> (mConstituents);
122 }
123 
124 
int i
Definition: DBlmapReader.cc:9
virtual double energy() const =0
energy
JetReco::InputCollection Constituents
Definition: ProtoJet.h:28
void reorderTowers()
Definition: ProtoJet.cc:105
virtual double et() const =0
transverse energy
void setPileup(float fEnergy)
Set pileup energy contribution as calculated by algorithm.
Definition: ProtoJet.cc:77
float mPileupEnergy
Definition: ProtoJet.h:123
bool mOrdered
Definition: ProtoJet.h:120
const Constituents & getTowerList()
Definition: ProtoJet.cc:82
void setJetArea(float fArea)
Set Jet area as calculated by algorithm.
Definition: ProtoJet.cc:75
int mPassNumber
Definition: ProtoJet.h:124
Constituents mConstituents
Definition: ProtoJet.h:119
float mJetArea
Parameters returning from algorithms.
Definition: ProtoJet.h:122
virtual double p() const =0
magnitude of momentum vector
virtual float pt() const =0
transverse momentum
tuple result
Definition: query.py:137
float jetArea() const
Jet area as calculated by algorithm.
Definition: ProtoJet.cc:76
LorentzVector mP4
Definition: ProtoJet.h:117
void calculateLorentzVectorEtRecombination()
Definition: ProtoJet.cc:120
ProtoJet()
Definition: ProtoJet.cc:48
math::XYZTLorentzVector LorentzVector
Definition: ProtoJet.h:30
void setNPasses(int fPasses)
Set number of passes taken by algorithm.
Definition: ProtoJet.cc:79
const Constituents & getPresortedTowerList() const
Definition: ProtoJet.cc:94
float pileup() const
pileup energy contribution as calculated by algorithm
Definition: ProtoJet.cc:78
void calculateLorentzVectorERecombination()
Definition: ProtoJet.cc:112
void calculateLorentzVector()
Definition: ProtoJet.h:108
int nPasses() const
number of passes taken by algorithm
Definition: ProtoJet.cc:80
int weight
Definition: histoStyle.py:50
long double T
void putTowers(const Constituents &towers)
Definition: ProtoJet.cc:99
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector