#include <JetMatchingTools.h>
Definition at line 25 of file JetMatchingTools.h.
JetMatchingTools::JetMatchingTools | ( | const edm::Event & | fEvent | ) |
Definition at line 40 of file JetMatchingTools.cc.
: mEvent (&fEvent), mEBRecHitCollection (0), mEERecHitCollection (0), mHBHERecHitCollection (0), mHORecHitCollection (0), mHFRecHitCollection (0), mEBSimHitCollection (0), mEESimHitCollection (0), mHcalSimHitCollection (0), mSimTrackCollection (0), mSimVertexCollection (0), mGenParticleCollection (0) {}
JetMatchingTools::~JetMatchingTools | ( | ) |
Definition at line 55 of file JetMatchingTools.cc.
{}
int JetMatchingTools::generatorId | ( | unsigned | fSimTrackId | ) |
Generator ID.
Definition at line 221 of file JetMatchingTools.cc.
References ExpressReco_HICollisions_FallBack::cerr, SimTrack::genpartIndex(), getSimVertexCollection(), getTrack(), SimTrack::noGenpart(), SimVertex::noParent(), SimTrack::noVertex(), SimVertex::parentIndex(), ExpressReco_HICollisions_FallBack::track, and SimTrack::vertIndex().
Referenced by getGenParticles(), and lostEnergyFraction().
{ const SimTrack* track = getTrack (fSimTrackId); if (!track) return -1; while (track->noGenpart ()) { if (track->noVertex ()) { std::cerr << "JetMatchingTools::generatorId-> No vertex for track " << *track << std::endl; return -1; } const SimVertex* vertex = &((*getSimVertexCollection ())[track->vertIndex ()]); if (vertex->noParent()) { std::cerr << "JetMatchingTools::generatorId-> No track for vertex " << *vertex << std::endl; return -1; } track = getTrack (vertex->parentIndex ()); } return track->genpartIndex (); }
std::vector<const CaloRecHit*> JetMatchingTools::getCaloRecHits | ( | int | fGeneratorId | ) |
CaloRecHits.
std::vector<const CaloTower*> JetMatchingTools::getCaloTowers | ( | int | fGeneratorId | ) |
CaloTowers.
get cells contributing to the tower
Definition at line 185 of file JetMatchingTools.cc.
References CaloTower::constituent(), CaloTower::constituentsSize(), i, and query::result.
Referenced by getGenParticles().
{ std::vector <DetId> result; for (unsigned i = 0; i < fTower.constituentsSize(); ++i) { DetId id = fTower.constituent (i); result.push_back (id); } return result; }
std::vector< const CaloRecHit * > JetMatchingTools::getConstituents | ( | const CaloTower & | fTower | ) |
get CaloRecHits contributing to the tower
Definition at line 154 of file JetMatchingTools.cc.
References ExpressReco_HICollisions_FallBack::cerr, CaloTower::constituent(), CaloTower::constituentsSize(), DetId::Ecal, EcalBarrel, EcalEndcap, getEBRecHitCollection(), getEERecHitCollection(), getHBHERecHitCollection(), getHFRecHitCollection(), getHORecHitCollection(), DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, i, and query::result.
{ std::vector <const CaloRecHit*> result; for (unsigned i = 0; i < fTower.constituentsSize(); ++i) { DetId id = fTower.constituent (i); const CaloRecHit* hit = 0; if (id.det () == DetId::Ecal) { if ((EcalSubdetector) id.subdetId () == EcalBarrel) { hit = getHit (*getEBRecHitCollection (), id); } else if ((EcalSubdetector) id.subdetId () == EcalEndcap) { hit = getHit (*getEERecHitCollection (), id); } } else if (id.det () == DetId::Hcal) { if ((HcalSubdetector) id.subdetId () == HcalBarrel || (HcalSubdetector) id.subdetId () == HcalEndcap) { hit = getHit (*getHBHERecHitCollection (), id); } else if ((HcalSubdetector) id.subdetId () == HcalOuter) { hit = getHit (*getHORecHitCollection (), id); } if ((HcalSubdetector) id.subdetId () == HcalForward) { hit = getHit (*getHFRecHitCollection (), id); } } if (hit) result.push_back (hit); else std::cerr << "Can not find rechit for id " << id.rawId () << std::endl; } return result; }
std::vector< const CaloTower * > JetMatchingTools::getConstituents | ( | const reco::CaloJet & | fJet | ) |
get towers contributing to CaloJet
Definition at line 147 of file JetMatchingTools.cc.
References reco::CaloJet::getCaloConstituents(), i, and query::result.
Referenced by getGenParticles(), and lostEnergyFraction().
const EBRecHitCollection * JetMatchingTools::getEBRecHitCollection | ( | ) |
Definition at line 57 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEBRecHitCollection, and mEvent.
Referenced by getConstituents().
{ if (!mEBRecHitCollection) { edm::Handle<EBRecHitCollection> recHits; mEvent->getByLabel (edm::InputTag ("ecalRecHit:EcalRecHitsEB"), recHits); mEBRecHitCollection = &*recHits; } return mEBRecHitCollection; }
const PCaloHitContainer * JetMatchingTools::getEBSimHitCollection | ( | ) |
Definition at line 97 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEBSimHitCollection, mEvent, and trackerHits::simHits.
Referenced by getPCaloHits().
{ if (!mEBSimHitCollection) { edm::Handle<PCaloHitContainer> simHits; mEvent->getByLabel (edm::InputTag ("g4SimHits:EcalHitsEB"), simHits); mEBSimHitCollection = &*simHits; } return mEBSimHitCollection; }
const EERecHitCollection * JetMatchingTools::getEERecHitCollection | ( | ) |
Definition at line 65 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEERecHitCollection, and mEvent.
Referenced by getConstituents().
{ if (!mEERecHitCollection) { edm::Handle<EERecHitCollection> recHits; mEvent->getByLabel (edm::InputTag ("ecalRecHit:EcalRecHitsEE"), recHits); mEERecHitCollection = &*recHits; } return mEERecHitCollection; }
const PCaloHitContainer * JetMatchingTools::getEESimHitCollection | ( | ) |
Definition at line 105 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEESimHitCollection, mEvent, and trackerHits::simHits.
Referenced by getPCaloHits().
{ if (!mEESimHitCollection) { edm::Handle<PCaloHitContainer> simHits; mEvent->getByLabel (edm::InputTag ("g4SimHits:EcalHitsEE"), simHits); mEESimHitCollection = &*simHits; } return mEESimHitCollection; }
const reco::GenParticle * JetMatchingTools::getGenParticle | ( | int | fGeneratorId | ) |
GenParticle.
Definition at line 240 of file JetMatchingTools.cc.
References ExpressReco_HICollisions_FallBack::cerr, reco::GenJet::genParticle(), getGenParticlesCollection(), findQualityFiles::size, and edm::OwnVector< T, P >::size().
Referenced by getGenParticles().
{ if (fGeneratorId > int (getGenParticlesCollection ()->size())) { std::cerr << "JetMatchingTools::getGenParticle-> requested index " << fGeneratorId << " is grater then container size " << getGenParticlesCollection ()->size() << std::endl; return 0; } return reco::GenJet::genParticle ( &(*getGenParticlesCollection ())[fGeneratorId-1]); // knowhow: index is shifted by 1 }
std::vector< const reco::GenParticle * > JetMatchingTools::getGenParticles | ( | const reco::CaloJet & | fJet, |
bool | fVerbose = true |
||
) |
GenParticles for CaloJet.
Definition at line 249 of file JetMatchingTools.cc.
References ExpressReco_HICollisions_FallBack::cerr, generatorId(), getConstituentIds(), getConstituents(), getGenParticle(), getPCaloHits(), getTrackId(), and query::result.
Referenced by CaloJetTester::analyze().
{ std::set <const reco::GenParticle*> result; // follow the chain std::vector <const CaloTower*> towers = getConstituents (fJet) ; for (unsigned itower = 0; itower < towers.size (); ++itower) { std::vector <DetId> detids = getConstituentIds (*(towers[itower])) ; for (unsigned iid = 0; iid < detids.size(); ++iid) { std::vector <const PCaloHit*> phits = getPCaloHits (detids[iid]); for (unsigned iphit = 0; iphit < phits.size(); ++iphit) { int trackId = getTrackId (*(phits[iphit])); if (trackId >= 0) { int genId = generatorId (trackId); if (genId >= 0) { const reco::GenParticle* genPart = getGenParticle (genId); if (genPart) { result.insert (genPart); } else if (fVerbose) { std::cerr << "JetMatchingTools::getGenParticles-> Can not convert genId " << genId << " to GenParticle" << std::endl; } } else if (fVerbose) { std::cerr << "JetMatchingTools::getGenParticles-> Can not convert trackId " << trackId << " to genId" << std::endl; } } else if (fVerbose) { std::cerr << "JetMatchingTools::getGenParticles-> Unknown trackId for PCaloHit " << *(phits[iphit]) << std::endl; } } } } return std::vector <const reco::GenParticle*> (result.begin (), result.end()); }
std::vector< const reco::GenParticle * > JetMatchingTools::getGenParticles | ( | const reco::GenJet & | fJet | ) |
GenParticles for GenJet.
Definition at line 284 of file JetMatchingTools.cc.
References reco::GenJet::getGenConstituents().
{ return fJet.getGenConstituents (); }
const reco::CandidateCollection * JetMatchingTools::getGenParticlesCollection | ( | ) |
Definition at line 137 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), patZpeak::handle, mEvent, and mGenParticleCollection.
Referenced by getGenParticle().
{ if (!mGenParticleCollection) { edm::Handle<reco::CandidateCollection> handle; mEvent->getByLabel (edm::InputTag ("genParticleCandidates"), handle); mGenParticleCollection = &*handle; } return mGenParticleCollection; }
const HBHERecHitCollection * JetMatchingTools::getHBHERecHitCollection | ( | ) |
Definition at line 73 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEvent, and mHBHERecHitCollection.
Referenced by getConstituents().
{ if (!mHBHERecHitCollection) { edm::Handle<HBHERecHitCollection> recHits; mEvent->getByLabel (edm::InputTag ("hbhereco"), recHits); mHBHERecHitCollection = &*recHits; } return mHBHERecHitCollection; }
const PCaloHitContainer * JetMatchingTools::getHcalSimHitCollection | ( | ) |
Definition at line 113 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEvent, mHcalSimHitCollection, and trackerHits::simHits.
Referenced by getPCaloHits().
{ if (!mHcalSimHitCollection) { edm::Handle<PCaloHitContainer> simHits; mEvent->getByLabel (edm::InputTag ("g4SimHits:HcalHits"), simHits); mHcalSimHitCollection = &*simHits; } return mHcalSimHitCollection; }
const HFRecHitCollection * JetMatchingTools::getHFRecHitCollection | ( | ) |
Definition at line 89 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEvent, and mHFRecHitCollection.
Referenced by getConstituents().
{ if (!mHFRecHitCollection) { edm::Handle<HFRecHitCollection> recHits; mEvent->getByLabel (edm::InputTag ("hfreco"), recHits); mHFRecHitCollection = &*recHits; } return mHFRecHitCollection; }
const HORecHitCollection * JetMatchingTools::getHORecHitCollection | ( | ) |
Definition at line 81 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEvent, and mHORecHitCollection.
Referenced by getConstituents().
{ if (!mHORecHitCollection) { edm::Handle<HORecHitCollection> recHits; mEvent->getByLabel (edm::InputTag ("horeco"), recHits); mHORecHitCollection = &*recHits; } return mHORecHitCollection; }
get PCaloHits contributing to the detId
Definition at line 194 of file JetMatchingTools.cc.
References DetId::det(), DetId::Ecal, EcalBarrel, EcalEndcap, getEBSimHitCollection(), getEESimHitCollection(), getHcalSimHitCollection(), DetId::Hcal, query::result, and DetId::subdetId().
Referenced by getGenParticles(), and lostEnergyFraction().
{ std::vector <const PCaloHit*> result; if (fId.det () == DetId::Ecal) { if ((EcalSubdetector) fId.subdetId () == EcalBarrel) { result = getSimHits (*getEBSimHitCollection (), fId); } else if ((EcalSubdetector) fId.subdetId () == EcalEndcap) { result = getSimHits (*getEESimHitCollection (), fId); } } else if (fId.det () == DetId::Hcal) { result = getSimHits (*getHcalSimHitCollection (), fId); } return result; }
std::vector<const PCaloHit*> JetMatchingTools::getPCaloHits | ( | int | fGeneratorId | ) |
CaloSimHits.
const SimTrackContainer * JetMatchingTools::getSimTrackCollection | ( | ) |
Definition at line 121 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEvent, mSimTrackCollection, and trackerHits::simHits.
Referenced by getTrack().
{ if (!mSimTrackCollection) { edm::Handle<SimTrackContainer> simHits; mEvent->getByLabel (edm::InputTag ("g4SimHits"), simHits); mSimTrackCollection = &*simHits; } return mSimTrackCollection; }
const SimVertexContainer * JetMatchingTools::getSimVertexCollection | ( | ) |
Definition at line 129 of file JetMatchingTools.cc.
References edm::Event::getByLabel(), mEvent, mSimVertexCollection, and trackerHits::simHits.
Referenced by generatorId().
{ if (!mSimVertexCollection) { edm::Handle<SimVertexContainer> simHits; mEvent->getByLabel (edm::InputTag ("g4SimHits"), simHits); mSimVertexCollection = &*simHits; } return mSimVertexCollection; }
const SimTrack * JetMatchingTools::getTrack | ( | unsigned | fSimTrackId | ) |
convert trackId to SimTrack
Definition at line 214 of file JetMatchingTools.cc.
References getSimTrackCollection(), and i.
Referenced by generatorId().
{ for (unsigned i = 0; i < getSimTrackCollection ()->size (); ++i) { if ((*getSimTrackCollection ())[i].trackId() == fSimTrackId) return &(*getSimTrackCollection ())[i]; } return 0; }
int JetMatchingTools::getTrackId | ( | const PCaloHit & | fHit | ) |
GEANT track ID.
Definition at line 210 of file JetMatchingTools.cc.
References PCaloHit::geantTrackId().
Referenced by getGenParticles(), and lostEnergyFraction().
{ return fHit.geantTrackId (); }
double JetMatchingTools::lostEnergyFraction | ( | const reco::CaloJet & | fJet | ) |
energy in broken links
Definition at line 289 of file JetMatchingTools.cc.
References cond::rpcobgas::detid, generatorId(), getConstituents(), getPCaloHits(), and getTrackId().
{ double totalEnergy = 0; double lostEnergy = 0; // follow the chain std::vector <const CaloTower*> towers = getConstituents (fJet) ; for (unsigned itower = 0; itower < towers.size (); ++itower) { std::vector <const CaloRecHit*> recHits = getConstituents (*(towers[itower])); for (unsigned ihit = 0; ihit < recHits.size(); ++ihit) { double foundSimEnergy = 0; double lostSimEnergy = 0; std::vector <const PCaloHit*> phits = getPCaloHits (recHits[ihit]->detid()); for (unsigned iphit = 0; iphit < phits.size(); ++iphit) { double simEnergy = phits[iphit]->energy (); int trackId = getTrackId (*(phits[iphit])); if (trackId < 0 || generatorId (trackId) < 0) lostSimEnergy += simEnergy; else foundSimEnergy += simEnergy; } if (foundSimEnergy > 0 || lostSimEnergy > 0) { totalEnergy += recHits[ihit]->energy (); lostEnergy += recHits[ihit]->energy () * lostSimEnergy / (foundSimEnergy + lostSimEnergy); } } } return lostEnergy / totalEnergy; }
double JetMatchingTools::overlapEnergyFraction | ( | const std::vector< const reco::GenParticle * > & | fObject, |
const std::vector< const reco::GenParticle * > & | fReference | ||
) | const |
energy overlap
Definition at line 316 of file JetMatchingTools.cc.
References relval_parameters_module::energy, spr::find(), and i.
Referenced by CaloJetTester::analyze().
{ if (fObject.empty()) return 0; double totalEnergy = 0; double overlapEnergy = 0; for (unsigned i = 0; i < fObject.size(); ++i) { totalEnergy += fObject [i]->energy(); if (find (fReference.begin(), fReference.end(), fObject [i]) != fReference.end ()) overlapEnergy += fObject [i]->energy(); } return overlapEnergy / totalEnergy; }
const EBRecHitCollection* JetMatchingTools::mEBRecHitCollection [private] |
Definition at line 83 of file JetMatchingTools.h.
Referenced by getEBRecHitCollection().
const edm::PCaloHitContainer* JetMatchingTools::mEBSimHitCollection [private] |
Definition at line 88 of file JetMatchingTools.h.
Referenced by getEBSimHitCollection().
const EERecHitCollection* JetMatchingTools::mEERecHitCollection [private] |
Definition at line 84 of file JetMatchingTools.h.
Referenced by getEERecHitCollection().
const edm::PCaloHitContainer* JetMatchingTools::mEESimHitCollection [private] |
Definition at line 89 of file JetMatchingTools.h.
Referenced by getEESimHitCollection().
const edm::Event* JetMatchingTools::mEvent [private] |
Definition at line 82 of file JetMatchingTools.h.
Referenced by getEBRecHitCollection(), getEBSimHitCollection(), getEERecHitCollection(), getEESimHitCollection(), getGenParticlesCollection(), getHBHERecHitCollection(), getHcalSimHitCollection(), getHFRecHitCollection(), getHORecHitCollection(), getSimTrackCollection(), and getSimVertexCollection().
const reco::CandidateCollection* JetMatchingTools::mGenParticleCollection [private] |
Definition at line 93 of file JetMatchingTools.h.
Referenced by getGenParticlesCollection().
const HBHERecHitCollection* JetMatchingTools::mHBHERecHitCollection [private] |
Definition at line 85 of file JetMatchingTools.h.
Referenced by getHBHERecHitCollection().
const edm::PCaloHitContainer* JetMatchingTools::mHcalSimHitCollection [private] |
Definition at line 90 of file JetMatchingTools.h.
Referenced by getHcalSimHitCollection().
const HFRecHitCollection* JetMatchingTools::mHFRecHitCollection [private] |
Definition at line 87 of file JetMatchingTools.h.
Referenced by getHFRecHitCollection().
const HORecHitCollection* JetMatchingTools::mHORecHitCollection [private] |
Definition at line 86 of file JetMatchingTools.h.
Referenced by getHORecHitCollection().
const edm::SimTrackContainer* JetMatchingTools::mSimTrackCollection [private] |
Definition at line 91 of file JetMatchingTools.h.
Referenced by getSimTrackCollection().
const edm::SimVertexContainer* JetMatchingTools::mSimVertexCollection [private] |
Definition at line 92 of file JetMatchingTools.h.
Referenced by getSimVertexCollection().