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