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