File indexing completed on 2024-04-06 12:04:24
0001
0002
0003 #include <sstream>
0004
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 #include "DataFormats/RecoCandidate/interface/RecoCaloTowerCandidate.h"
0007
0008
0009 #include "DataFormats/JetReco/interface/CaloJet.h"
0010
0011 using namespace reco;
0012
0013 CaloJet::CaloJet(const LorentzVector& fP4, const Point& fVertex, const Specific& fSpecific)
0014 : Jet(fP4, fVertex), m_specific(fSpecific) {}
0015
0016 CaloJet::CaloJet(const LorentzVector& fP4,
0017 const Point& fVertex,
0018 const Specific& fSpecific,
0019 const Jet::Constituents& fConstituents)
0020 : Jet(fP4, fVertex, fConstituents), m_specific(fSpecific) {}
0021
0022 CaloJet::CaloJet(const LorentzVector& fP4, const Specific& fSpecific, const Jet::Constituents& fConstituents)
0023 : Jet(fP4, Point(0, 0, 0), fConstituents), m_specific(fSpecific) {}
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 CaloJet::LorentzVector CaloJet::physicsP4(const Particle::Point& vertex) const {
0052 return Jet::physicsP4(vertex, *this, this->vertex());
0053 }
0054
0055 CaloJet::LorentzVector CaloJet::detectorP4() const { return Jet::detectorP4(this->vertex(), *this); }
0056
0057 CaloTowerPtr CaloJet::getCaloConstituent(unsigned fIndex) const {
0058 Constituent dau = daughterPtr(fIndex);
0059
0060 if (dau.isNonnull() && dau.isAvailable()) {
0061 const CaloTower* towerCandidate = dynamic_cast<const CaloTower*>(dau.get());
0062
0063 if (towerCandidate) {
0064
0065
0066 return edm::Ptr<CaloTower>(dau.id(), towerCandidate, dau.key());
0067 } else {
0068 throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTowere type";
0069 }
0070
0071 }
0072
0073 else {
0074 return CaloTowerPtr();
0075 }
0076 }
0077
0078 std::vector<CaloTowerPtr> CaloJet::getCaloConstituents() const {
0079 std::vector<CaloTowerPtr> result;
0080 for (unsigned i = 0; i < numberOfDaughters(); i++)
0081 result.push_back(getCaloConstituent(i));
0082 return result;
0083 }
0084
0085 CaloJet* CaloJet::clone() const { return new CaloJet(*this); }
0086
0087 bool CaloJet::overlap(const Candidate&) const { return false; }
0088
0089 std::string CaloJet::print() const {
0090 std::ostringstream out;
0091 out << Jet::print()
0092 << " CaloJet specific:" << std::endl
0093 << " energy fractions em/had: " << emEnergyFraction() << '/' << energyFractionHadronic() << std::endl
0094 << " em energy in EB/EE/HF: " << emEnergyInEB() << '/' << emEnergyInEE() << '/' << emEnergyInHF()
0095 << std::endl
0096 << " had energy in HB/HO/HE/HF: " << hadEnergyInHB() << '/' << hadEnergyInHO() << '/' << hadEnergyInHE()
0097 << '/' << hadEnergyInHF() << std::endl
0098 << " constituent towers area: " << towersArea() << std::endl;
0099 out << " Towers:" << std::endl;
0100 std::vector<CaloTowerPtr> towers = getCaloConstituents();
0101 for (unsigned i = 0; i < towers.size(); i++) {
0102 if (towers[i].get()) {
0103 out << " #" << i << " " << *(towers[i]) << std::endl;
0104 } else {
0105 out << " #" << i << " tower is not available in the event" << std::endl;
0106 }
0107 }
0108 return out.str();
0109 }
0110
0111
0112
0113
0114
0115 std::vector<CaloTowerDetId> CaloJet::getTowerIndices() const {
0116 std::vector<CaloTowerDetId> result;
0117 std::vector<CaloTowerPtr> towers = getCaloConstituents();
0118 for (unsigned i = 0; i < towers.size(); ++i) {
0119 result.push_back(towers[i]->id());
0120 }
0121 return result;
0122 }