CMS 3D CMS Logo

CaloJet.cc
Go to the documentation of this file.
1 // CaloJet.cc
2 // Fedor Ratnikov UMd
3 #include <sstream>
4 
7 
8 //Own header file
10 
11 using namespace reco;
12 
13  CaloJet::CaloJet (const LorentzVector& fP4, const Point& fVertex,
14  const Specific& fSpecific)
15  : Jet (fP4, fVertex),
16  m_specific (fSpecific)
17  {}
18 
19  CaloJet::CaloJet (const LorentzVector& fP4, const Point& fVertex,
20  const Specific& fSpecific,
21  const Jet::Constituents& fConstituents)
22  : Jet (fP4, fVertex, fConstituents),
23  m_specific (fSpecific)
24  {}
25 
27  const Specific& fSpecific,
28  const Jet::Constituents& fConstituents)
29  : Jet (fP4, Point(0,0,0), fConstituents),
30  m_specific (fSpecific)
31 {}
32 
33 
35 //float CaloJet::physicsEtaQuick (float fZVertex) const {
36 // return Jet::physicsEta (fZVertex, eta());
37 //}
38 
40 //float CaloJet::physicsEtaDetailed (float fZVertex) const {
41 // Jet::LorentzVector correctedMomentum;
42 // std::vector<const Candidate*> towers = getJetConstituentsQuick ();
43 // for (unsigned i = 0; i < towers.size(); ++i) {
44 // const Candidate* c = towers[i];
45 // double etaRef = Jet::physicsEta (fZVertex, c->eta());
46 // math::PtEtaPhiMLorentzVectorD p4 (c->p()/cosh(etaRef), etaRef, c->phi(), c->mass());
47 // correctedMomentum += p4;
48 // }
49 // return correctedMomentum.eta();
50 //}
51 
53 //deprecated, with 3d vertex correction not clear anymore!
54 //CaloJet::LorentzVector CaloJet::physicsP4 (float fZVertex) const {
55 // double physicsEta = Jet::physicsEta (fZVertex, eta());
56 // math::PtEtaPhiMLorentzVectorD p4 (p()/cosh(physicsEta), physicsEta, phi(), mass());
57 // return CaloJet::LorentzVector (p4);
58 //}
59 
61  return Jet::physicsP4(vertex,*this,this->vertex());
62 }
63 
65  return Jet::detectorP4(this->vertex(),*this);
66 }
67 
68 
69 CaloTowerPtr CaloJet::getCaloConstituent (unsigned fIndex) const {
70  Constituent dau = daughterPtr (fIndex);
71 
72  if ( dau.isNonnull() && dau.isAvailable() ) {
73 
74  const CaloTower* towerCandidate = dynamic_cast <const CaloTower*> (dau.get());
75 
76  if (towerCandidate) {
77 // return towerCandidate;
78 // 086 Ptr(ProductID const& productID, T const* item, key_type item_key) :
79  return edm::Ptr<CaloTower> (dau.id(), towerCandidate, dau.key() );
80  }
81  else {
82  throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTowere type";
83  }
84 
85  }
86 
87  else {
88  return CaloTowerPtr();
89  }
90 }
91 
92 
93 std::vector <CaloTowerPtr > CaloJet::getCaloConstituents () const {
94  std::vector <CaloTowerPtr> result;
95  for (unsigned i = 0; i < numberOfDaughters (); i++) result.push_back (getCaloConstituent (i));
96  return result;
97 }
98 
99 
101  return new CaloJet (*this);
102 }
103 
104 bool CaloJet::overlap( const Candidate & ) const {
105  return false;
106 }
107 
109  std::ostringstream out;
110  out << Jet::print () // generic jet info
111  << " CaloJet specific:" << std::endl
112  << " energy fractions em/had: " << emEnergyFraction () << '/' << energyFractionHadronic () << std::endl
113  << " em energy in EB/EE/HF: " << emEnergyInEB() << '/' << emEnergyInEE() << '/' << emEnergyInHF() << std::endl
114  << " had energy in HB/HO/HE/HF: " << hadEnergyInHB() << '/' << hadEnergyInHO() << '/' << hadEnergyInHE() << '/' << hadEnergyInHF() << std::endl
115  << " constituent towers area: " << towersArea() << std::endl;
116  out << " Towers:" << std::endl;
117  std::vector <CaloTowerPtr > towers = getCaloConstituents ();
118  for (unsigned i = 0; i < towers.size (); i++) {
119  if (towers[i].get ()) {
120  out << " #" << i << " " << *(towers[i]) << std::endl;
121  }
122  else {
123  out << " #" << i << " tower is not available in the event" << std::endl;
124  }
125  }
126  return out.str ();
127 }
128 
129 //----------------------------------------------------------
130 // here are methods extracting information from constituents
131 //----------------------------------------------------------
132 
133 std::vector<CaloTowerDetId> CaloJet::getTowerIndices() const {
134  std::vector<CaloTowerDetId> result;
135  std::vector <CaloTowerPtr> towers = getCaloConstituents ();
136  for (unsigned i = 0; i < towers.size(); ++i) {
137  result.push_back (towers[i]->id());
138  }
139  return result;
140 }
float hadEnergyInHE() const
Definition: CaloJet.h:108
float emEnergyInEE() const
Definition: CaloJet.h:114
Jets made from CaloTowers.
Definition: CaloJet.h:29
LorentzVector detectorP4() const
detector p4 for full 3d vertex correction.
Definition: CaloJet.cc:64
key_type key() const
Definition: Ptr.h:185
CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
virtual CaloTowerPtr getCaloConstituent(unsigned fIndex) const
Physics Eta (loop over constituents)
Definition: CaloJet.cc:69
bool isAvailable() const
Definition: Ptr.h:258
std::vector< Constituent > Constituents
Definition: Jet.h:23
float emEnergyInHF() const
Definition: CaloJet.h:116
virtual std::vector< CaloTowerPtr > getCaloConstituents() const
get all constituents
Definition: CaloJet.cc:93
float hadEnergyInHO() const
Definition: CaloJet.h:106
size_t numberOfDaughters() const override
number of daughters
daughters dau
collection of references to daughters
bool overlap(const Candidate &) const override
Polymorphic overlap.
Definition: CaloJet.cc:104
virtual std::string print() const
Print object.
Definition: Jet.py:1
float emEnergyInEB() const
Definition: CaloJet.h:112
const Point & vertex() const override
vertex position (overwritten by PF...)
math::XYZPoint Point
point in the space
Definition: Particle.h:25
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
std::string print() const override
Print object.
Definition: CaloJet.cc:108
LorentzVector physicsP4(const Particle::Point &vertex) const
Physics Eta (use jet Z and kinematics only)
Definition: CaloJet.cc:60
std::vector< CaloTowerDetId > getTowerIndices() const
CaloTowers indexes.
Definition: CaloJet.cc:133
static Candidate::LorentzVector detectorP4(const Candidate::Point &vertex, const Candidate &inParticle)
float towersArea() const
Definition: CaloJet.h:118
CaloJet * clone() const override
Polymorphic clone.
Definition: CaloJet.cc:100
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:180
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
fixed size matrix
float energyFractionHadronic() const
Definition: CaloJet.h:100
float hadEnergyInHB() const
Definition: CaloJet.h:104
edm::Ptr< CaloTower > CaloTowerPtr
Definition: CaloTowerDefs.h:14
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
static Candidate::LorentzVector physicsP4(const Candidate::Point &newVertex, const Candidate &inParticle, const Candidate::Point &oldVertex=Candidate::Point(0, 0, 0))
Specific m_specific
Definition: CaloJet.h:164
float hadEnergyInHF() const
Definition: CaloJet.h:110
float emEnergyFraction() const
Definition: CaloJet.h:102