CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
int i
Definition: DBlmapReader.cc:9
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:169
CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
virtual const Point & vertex() const
vertex position (overwritten by PF...)
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
Base class for all types of Jets.
Definition: Jet.h:20
virtual CaloTowerPtr getCaloConstituent(unsigned fIndex) const
Physics Eta (loop over constituents)
Definition: CaloJet.cc:69
bool isAvailable() const
Definition: Ptr.h:249
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
virtual CaloJet * clone() const
Polymorphic clone.
Definition: CaloJet.cc:100
daughters dau
collection of references to daughters
virtual size_t numberOfDaughters() const
number of daughters
virtual std::string print() const
Print object.
virtual bool overlap(const Candidate &) const
Polymorphic overlap.
Definition: CaloJet.cc:104
edm::Ptr< CaloTower > CaloTowerPtr
Definition: CaloTowerFwd.h:12
float emEnergyInEB() const
Definition: CaloJet.h:112
tuple result
Definition: query.py:137
math::XYZPoint Point
point in the space
Definition: Particle.h:25
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
tuple out
Definition: dbtoconf.py:99
virtual std::string print() const
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
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:164
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
float energyFractionHadronic() const
Definition: CaloJet.h:100
float hadEnergyInHB() const
Definition: CaloJet.h:104
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))
float hadEnergyInHF() const
Definition: CaloJet.h:110
float emEnergyFraction() const
Definition: CaloJet.h:102