Go to the documentation of this file.00001
00002
00003
00004 #include <sstream>
00005
00006 #include "FWCore/Utilities/interface/Exception.h"
00007 #include "DataFormats/RecoCandidate/interface/RecoCaloTowerCandidate.h"
00008
00009
00010 #include "DataFormats/JetReco/interface/CaloJet.h"
00011
00012 using namespace reco;
00013
00014 CaloJet::CaloJet (const LorentzVector& fP4, const Point& fVertex,
00015 const Specific& fSpecific)
00016 : Jet (fP4, fVertex),
00017 m_specific (fSpecific)
00018 {}
00019
00020 CaloJet::CaloJet (const LorentzVector& fP4, const Point& fVertex,
00021 const Specific& fSpecific,
00022 const Jet::Constituents& fConstituents)
00023 : Jet (fP4, fVertex, fConstituents),
00024 m_specific (fSpecific)
00025 {}
00026
00027 CaloJet::CaloJet (const LorentzVector& fP4,
00028 const Specific& fSpecific,
00029 const Jet::Constituents& fConstituents)
00030 : Jet (fP4, Point(0,0,0), fConstituents),
00031 m_specific (fSpecific)
00032 {}
00033
00034
00036
00037
00038
00039
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00054
00055
00056
00057
00058
00059
00060
00061 CaloJet::LorentzVector CaloJet::physicsP4 (const Particle::Point &vertex) const {
00062 return Jet::physicsP4(vertex,*this,this->vertex());
00063 }
00064
00065 CaloJet::LorentzVector CaloJet::detectorP4 () const {
00066 return Jet::detectorP4(this->vertex(),*this);
00067 }
00068
00069
00070 CaloTowerPtr CaloJet::getCaloConstituent (unsigned fIndex) const {
00071 Constituent dau = daughterPtr (fIndex);
00072
00073 if ( dau.isNonnull() && dau.isAvailable() ) {
00074
00075 const CaloTower* towerCandidate = dynamic_cast <const CaloTower*> (dau.get());
00076
00077 if (towerCandidate) {
00078
00079
00080 return edm::Ptr<CaloTower> (dau.id(), towerCandidate, dau.key() );
00081 }
00082 else {
00083 throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTowere type";
00084 }
00085
00086 }
00087
00088 else {
00089 return CaloTowerPtr();
00090 }
00091 }
00092
00093
00094 std::vector <CaloTowerPtr > CaloJet::getCaloConstituents () const {
00095 std::vector <CaloTowerPtr> result;
00096 for (unsigned i = 0; i < numberOfDaughters (); i++) result.push_back (getCaloConstituent (i));
00097 return result;
00098 }
00099
00100
00101 CaloJet* CaloJet::clone () const {
00102 return new CaloJet (*this);
00103 }
00104
00105 bool CaloJet::overlap( const Candidate & ) const {
00106 return false;
00107 }
00108
00109 std::string CaloJet::print () const {
00110 std::ostringstream out;
00111 out << Jet::print ()
00112 << " CaloJet specific:" << std::endl
00113 << " energy fractions em/had: " << emEnergyFraction () << '/' << energyFractionHadronic () << std::endl
00114 << " em energy in EB/EE/HF: " << emEnergyInEB() << '/' << emEnergyInEE() << '/' << emEnergyInHF() << std::endl
00115 << " had energy in HB/HO/HE/HF: " << hadEnergyInHB() << '/' << hadEnergyInHO() << '/' << hadEnergyInHE() << '/' << hadEnergyInHF() << std::endl
00116 << " constituent towers area: " << towersArea() << std::endl;
00117 out << " Towers:" << std::endl;
00118 std::vector <CaloTowerPtr > towers = getCaloConstituents ();
00119 for (unsigned i = 0; i < towers.size (); i++) {
00120 if (towers[i].get ()) {
00121 out << " #" << i << " " << *(towers[i]) << std::endl;
00122 }
00123 else {
00124 out << " #" << i << " tower is not available in the event" << std::endl;
00125 }
00126 }
00127 return out.str ();
00128 }
00129
00130
00131
00132
00133
00134 std::vector<CaloTowerDetId> CaloJet::getTowerIndices() const {
00135 std::vector<CaloTowerDetId> result;
00136 std::vector <CaloTowerPtr> towers = getCaloConstituents ();
00137 for (unsigned i = 0; i < towers.size(); ++i) {
00138 result.push_back (towers[i]->id());
00139 }
00140 return result;
00141 }