Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00007 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00008 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
00009 #include "DataFormats/RecoCandidate/interface/RecoCaloTowerCandidate.h"
00010 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00011 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00012 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00013 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00014 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00015
00016 #include "RecoParticleFlow/PFRootEvent/interface/JetMaker.h"
00017
00018 using namespace std;
00019 using namespace reco;
00020
00021 bool JetMaker::makeSpecific (const JetReco::InputCollection& fTowers,
00022 const CaloSubdetectorGeometry& fTowerGeometry,
00023 CaloJet::Specific* fJetSpecific) {
00024 if (!fJetSpecific) return false;
00025
00026
00027
00028
00029 vector<double> eECal_i;
00030 vector<double> eHCal_i;
00031 double eInHad = 0.;
00032 double eInEm = 0.;
00033 double eInHO = 0.;
00034 double eInHB = 0.;
00035 double eInHE = 0.;
00036 double eHadInHF = 0.;
00037 double eEmInHF = 0.;
00038 double eInEB = 0.;
00039 double eInEE = 0.;
00040 double jetArea = 0.;
00041
00042 for (JetReco::InputCollection::const_iterator towerCand = fTowers.begin(); towerCand != fTowers.end(); ++towerCand) {
00043 const Candidate* candidate = towerCand->get ();
00044 if (candidate) {
00045 const CaloTower* tower = dynamic_cast<const CaloTower*> (candidate);
00046 if (tower) {
00047
00048 eECal_i.push_back(tower->emEnergy());
00049 eInEm += tower->emEnergy();
00050
00051 eHCal_i.push_back(tower->hadEnergy());
00052 eInHad += tower->hadEnergy();
00053
00054
00055 switch (JetMaker::hcalSubdetector (tower->id().ieta())) {
00056 case HcalBarrel:
00057 eInHB += tower->hadEnergy();
00058 eInHO += tower->outerEnergy();
00059 eInEB += tower->emEnergy();
00060 break;
00061 case HcalEndcap:
00062 eInHE += tower->hadEnergy();
00063 eInEE += tower->emEnergy();
00064 break;
00065 case HcalForward:
00066 eHadInHF += tower->hadEnergy();
00067 eEmInHF += tower->emEnergy();
00068 break;
00069 default:
00070 break;
00071 }
00072
00073 if ( tower->energy() > 0 ) {
00074 const CaloCellGeometry* geometry = fTowerGeometry.getGeometry(tower->id());
00075 if (geometry) {
00076 float dEta = fabs (geometry->getCorners() [0].eta() - geometry->getCorners() [2].eta());
00077 float dPhi = fabs (geometry->getCorners() [0].phi() - geometry->getCorners() [2].phi());
00078 jetArea += dEta * dPhi;
00079 }
00080 }
00081 else {
00082 std::cerr << "JetMaker::makeSpecific (CaloJet)-> Geometry for cell " << tower->id() << " can not be found. Ignoring cell" << std::endl;
00083 }
00084 }
00085 else {
00086 std::cerr << "JetMaker::makeSpecific (CaloJet)-> Constituent is not of CaloTower type" << std::endl;
00087 }
00088 }
00089 else {
00090 std::cerr << "JetMaker::makeSpecific (CaloJet)-> Referred constituent is not available in the event" << std::endl;
00091 }
00092 }
00093 double towerEnergy = eInHad + eInEm;
00094 fJetSpecific->mHadEnergyInHO = eInHO;
00095 fJetSpecific->mHadEnergyInHB = eInHB;
00096 fJetSpecific->mHadEnergyInHE = eInHE;
00097 fJetSpecific->mHadEnergyInHF = eHadInHF;
00098 fJetSpecific->mEmEnergyInHF = eEmInHF;
00099 fJetSpecific->mEmEnergyInEB = eInEB;
00100 fJetSpecific->mEmEnergyInEE = eInEE;
00101 if (towerEnergy > 0) {
00102 fJetSpecific->mEnergyFractionHadronic = eInHad / towerEnergy;
00103 fJetSpecific->mEnergyFractionEm = eInEm / towerEnergy;
00104 }
00105 else {
00106 fJetSpecific->mEnergyFractionHadronic = 1.;
00107 fJetSpecific->mEnergyFractionEm = 0.;
00108 }
00109 fJetSpecific->mTowersArea = jetArea;
00110 fJetSpecific->mMaxEInEmTowers = 0;
00111 fJetSpecific->mMaxEInHadTowers = 0;
00112
00113
00114 sort(eECal_i.begin(), eECal_i.end(), greater<double>());
00115 sort(eHCal_i.begin(), eHCal_i.end(), greater<double>());
00116
00117 if (!fTowers.empty ()) {
00118
00119 fJetSpecific->mMaxEInEmTowers = eECal_i.front();
00120 fJetSpecific->mMaxEInHadTowers = eHCal_i.front();
00121
00122 }
00123 return true;
00124 }
00125
00127 bool JetMaker::makeSpecific (const JetReco::InputCollection& fPFCandidates,
00128 PFJet::Specific* fJetSpecific) {
00129 if (!fJetSpecific) return false;
00130
00131
00132
00133
00134
00135 float chargedHadronEnergy=0.;
00136 float neutralHadronEnergy=0.;
00137 float chargedEmEnergy=0.;
00138 float neutralEmEnergy=0.;
00139 float chargedMuEnergy=0.;
00140 int chargedMultiplicity=0;
00141 int neutralMultiplicity=0;
00142 int muonMultiplicity=0;
00143
00144 JetReco::InputCollection::const_iterator constituent = fPFCandidates.begin();
00145 for (; constituent != fPFCandidates.end(); ++constituent) {
00146 const Candidate* candidate = constituent->get ();
00147 if (candidate) {
00148 const PFCandidate* pfCand = dynamic_cast<const PFCandidate*> (candidate);
00149 if (pfCand) {
00150 switch ( PFCandidate::ParticleType (pfCand->particleId())) {
00151 case PFCandidate::h:
00152 chargedHadronEnergy += pfCand->energy();
00153 chargedMultiplicity++;
00154 break;
00155
00156 case PFCandidate::e:
00157 chargedEmEnergy += pfCand->energy();
00158 chargedMultiplicity++;
00159 break;
00160
00161 case PFCandidate::mu:
00162 chargedMuEnergy += pfCand->energy();
00163 chargedMultiplicity++;
00164 muonMultiplicity++;
00165 break;
00166
00167 case PFCandidate::gamma:
00168 case PFCandidate::egamma_HF :
00169 neutralEmEnergy += pfCand->energy();
00170 neutralMultiplicity++;
00171 break;
00172
00173 case PFCandidate::h0 :
00174 case PFCandidate::h_HF :
00175 neutralHadronEnergy += pfCand->energy();
00176 neutralMultiplicity++;
00177 break;
00178
00179 default:
00180 std::cerr << "JetMaker::makeSpecific (PFJetJet)-> Unknown PFCandidate::ParticleType: " << pfCand->particleId() << " is ignored" << std::endl;
00181 break;
00182 }
00183 }
00184 else {
00185 std::cerr << "JetMaker::makeSpecific (PFJetJet)-> Referred constituent is not PFCandidate" << std::endl;
00186 }
00187 }
00188 else {
00189 std::cerr << "JetMaker::makeSpecific (PFJetJet)-> Referred constituent is not available in the event" << std::endl;
00190 }
00191 }
00192 fJetSpecific->mChargedHadronEnergy=chargedHadronEnergy;
00193 fJetSpecific->mNeutralHadronEnergy= neutralHadronEnergy;
00194 fJetSpecific->mChargedEmEnergy=chargedEmEnergy;
00195 fJetSpecific->mChargedMuEnergy=chargedMuEnergy;
00196 fJetSpecific->mNeutralEmEnergy=neutralEmEnergy;
00197 fJetSpecific->mChargedMultiplicity=chargedMultiplicity;
00198 fJetSpecific->mNeutralMultiplicity=neutralMultiplicity;
00199 fJetSpecific->mMuonMultiplicity=muonMultiplicity;
00200 return true;
00201 }
00202
00203
00204 bool JetMaker::makeSpecific (const JetReco::InputCollection& fMcParticles,
00205 GenJet::Specific* fJetSpecific) {
00206 for (JetReco::InputCollection::const_iterator genCand = fMcParticles.begin(); genCand != fMcParticles.end(); ++genCand) {
00207 const Candidate* candidate = genCand->get ();
00208 if (candidate->hasMasterClone ()) candidate = candidate->masterClone().get ();
00209 if (candidate) {
00210 const GenParticle* genParticle = GenJet::genParticle (candidate);
00211 if (genParticle) {
00212 double e = genParticle->energy();
00213 switch (std::abs (genParticle->pdgId ())) {
00214 case 22:
00215 case 11:
00216 fJetSpecific->m_EmEnergy += e;
00217 break;
00218 case 211:
00219 case 321:
00220 case 130:
00221 case 2212:
00222 case 2112:
00223 fJetSpecific->m_HadEnergy += e;
00224 break;
00225 case 13:
00226 case 12:
00227 case 14:
00228 case 16:
00229
00230 fJetSpecific->m_InvisibleEnergy += e;
00231 break;
00232 default:
00233 fJetSpecific->m_AuxiliaryEnergy += e;
00234 }
00235 }
00236 else {
00237 std::cerr << "JetMaker::makeSpecific (GenJet)-> Referred GenParticleCandidate is not available in the event" << std::endl;
00238 }
00239 }
00240 else {
00241 std::cerr << "JetMaker::makeSpecific (GenJet)-> Referred constituent is not available in the event" << std::endl;
00242 }
00243 }
00244 return true;
00245 }
00246
00247 HcalSubdetector JetMaker::hcalSubdetector (int fEta) {
00248 static const HcalTopology topology;
00249 int eta = std::abs (fEta);
00250 if (eta <= topology.lastHBRing()) return HcalBarrel;
00251 else if (eta <= topology.lastHERing()) return HcalEndcap;
00252 else if (eta <= topology.lastHFRing()) return HcalForward;
00253 return HcalEmpty;
00254 }
00255