CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
JetMatchingTools Class Reference

#include <JetMatchingTools.h>

Classes

struct  JetConstituent
 

Public Member Functions

int generatorId (unsigned fSimTrackId)
 Generator ID. More...
 
std::vector< const CaloTower * > getCaloTowers (int fGeneratorId)
 CaloTowers. More...
 
std::vector< JetConstituentgetConstituentHits (const CaloTower &fTower)
 get CaloRecHits contributing to the tower More...
 
std::vector< DetIdgetConstituentIds (const CaloTower &fTower)
 get cells contributing to the tower More...
 
std::vector< const CaloTower * > getConstituents (const reco::CaloJet &fJet)
 get towers contributing to CaloJet More...
 
const EBRecHitCollectiongetEBRecHitCollection ()
 
const edm::PCaloHitContainergetEBSimHitCollection ()
 
const EERecHitCollectiongetEERecHitCollection ()
 
const edm::PCaloHitContainergetEESimHitCollection ()
 
const reco::GenParticlegetGenParticle (int fGeneratorId)
 GenParticle. More...
 
std::vector< const
reco::GenParticle * > 
getGenParticles (const reco::CaloJet &fJet, bool fVerbose=true)
 GenParticles for CaloJet. More...
 
std::vector< const
reco::GenParticle * > 
getGenParticles (const reco::GenJet &fJet)
 GenParticles for GenJet. More...
 
const reco::CandidateCollectiongetGenParticlesCollection ()
 
const HBHERecHitCollectiongetHBHERecHitCollection ()
 
const edm::PCaloHitContainergetHcalSimHitCollection ()
 
const HFRecHitCollectiongetHFRecHitCollection ()
 
const HORecHitCollectiongetHORecHitCollection ()
 
std::vector< const PCaloHit * > getPCaloHits (DetId fId)
 get PCaloHits contributing to the detId More...
 
std::vector< const PCaloHit * > getPCaloHits (int fGeneratorId)
 CaloSimHits. More...
 
const edm::SimTrackContainergetSimTrackCollection ()
 
const edm::SimVertexContainergetSimVertexCollection ()
 
const SimTrackgetTrack (unsigned fSimTrackId)
 convert trackId to SimTrack More...
 
int getTrackId (const PCaloHit &fHit)
 GEANT track ID. More...
 
 JetMatchingTools (const edm::Event &fEvent, edm::ConsumesCollector &&iC)
 
double lostEnergyFraction (const reco::CaloJet &fJet)
 energy in broken links More...
 
double overlapEnergyFraction (const std::vector< const reco::GenParticle * > &fObject, const std::vector< const reco::GenParticle * > &fReference) const
 energy overlap More...
 
 ~JetMatchingTools ()
 

Private Attributes

edm::EDGetTokenT
< reco::CandidateCollection
input_cands_token_
 
edm::EDGetTokenT
< EBRecHitCollection
input_ebrechits_token_
 
edm::EDGetTokenT
< EERecHitCollection
input_eerechits_token_
 
edm::EDGetTokenT
< HBHERecHitCollection
input_hbherechits_token_
 
edm::EDGetTokenT
< HFRecHitCollection
input_hfrechits_token_
 
edm::EDGetTokenT
< HORecHitCollection
input_horechits_token_
 
edm::EDGetTokenT
< edm::PCaloHitContainer
input_pcalohits_ebcal_token_
 
edm::EDGetTokenT
< edm::PCaloHitContainer
input_pcalohits_eecal_token_
 
edm::EDGetTokenT
< edm::PCaloHitContainer
input_pcalohits_hcal_token_
 
edm::EDGetTokenT
< edm::SimTrackContainer
input_simtrack_token_
 
edm::EDGetTokenT
< edm::SimVertexContainer
input_simvertex_token_
 
const EBRecHitCollectionmEBRecHitCollection
 
const edm::PCaloHitContainermEBSimHitCollection
 
const EERecHitCollectionmEERecHitCollection
 
const edm::PCaloHitContainermEESimHitCollection
 
const edm::EventmEvent
 
const reco::CandidateCollectionmGenParticleCollection
 
const HBHERecHitCollectionmHBHERecHitCollection
 
const edm::PCaloHitContainermHcalSimHitCollection
 
const HFRecHitCollectionmHFRecHitCollection
 
const HORecHitCollectionmHORecHitCollection
 
const edm::SimTrackContainermSimTrackCollection
 
const edm::SimVertexContainermSimVertexCollection
 

Detailed Description

Definition at line 28 of file JetMatchingTools.h.

Constructor & Destructor Documentation

JetMatchingTools::JetMatchingTools ( const edm::Event fEvent,
edm::ConsumesCollector &&  iC 
)

Definition at line 36 of file JetMatchingTools.cc.

References input_cands_token_, input_ebrechits_token_, input_eerechits_token_, input_hbherechits_token_, input_hfrechits_token_, input_horechits_token_, input_pcalohits_ebcal_token_, input_pcalohits_eecal_token_, input_pcalohits_hcal_token_, input_simtrack_token_, input_simvertex_token_, and HLT_25ns14e33_v1_cff::InputTag.

37  : mEvent (&fEvent),
49 {
50 
51  input_ebrechits_token_ = iC.mayConsume<EBRecHitCollection>(edm::InputTag ("ecalRecHit:EcalRecHitsEB"));
52  input_eerechits_token_ = iC.mayConsume<EERecHitCollection>(edm::InputTag ("ecalRecHit:EcalRecHitsEE"));
62 
63 }
const edm::PCaloHitContainer * mHcalSimHitCollection
std::vector< PCaloHit > PCaloHitContainer
const EBRecHitCollection * mEBRecHitCollection
edm::EDGetTokenT< edm::PCaloHitContainer > input_pcalohits_ebcal_token_
const edm::PCaloHitContainer * mEBSimHitCollection
edm::EDGetTokenT< edm::SimVertexContainer > input_simvertex_token_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
const reco::CandidateCollection * mGenParticleCollection
edm::EDGetTokenT< EERecHitCollection > input_eerechits_token_
const edm::PCaloHitContainer * mEESimHitCollection
edm::EDGetTokenT< reco::CandidateCollection > input_cands_token_
edm::EDGetTokenT< EBRecHitCollection > input_ebrechits_token_
const edm::SimTrackContainer * mSimTrackCollection
const EERecHitCollection * mEERecHitCollection
edm::EDGetTokenT< HFRecHitCollection > input_hfrechits_token_
edm::EDGetTokenT< HORecHitCollection > input_horechits_token_
const edm::SimVertexContainer * mSimVertexCollection
edm::EDGetTokenT< edm::PCaloHitContainer > input_pcalohits_eecal_token_
edm::EDGetTokenT< edm::SimTrackContainer > input_simtrack_token_
std::vector< SimVertex > SimVertexContainer
const edm::Event * mEvent
const HORecHitCollection * mHORecHitCollection
edm::EDGetTokenT< HBHERecHitCollection > input_hbherechits_token_
std::vector< SimTrack > SimTrackContainer
edm::EDGetTokenT< edm::PCaloHitContainer > input_pcalohits_hcal_token_
const HFRecHitCollection * mHFRecHitCollection
const HBHERecHitCollection * mHBHERecHitCollection
JetMatchingTools::~JetMatchingTools ( )

Definition at line 65 of file JetMatchingTools.cc.

65 {}

Member Function Documentation

int JetMatchingTools::generatorId ( unsigned  fSimTrackId)

Generator ID.

Definition at line 242 of file JetMatchingTools.cc.

References dtNoiseDBValidation_cfg::cerr, SimTrack::genpartIndex(), getSimVertexCollection(), getTrack(), SimTrack::noGenpart(), SimVertex::noParent(), SimTrack::noVertex(), SimVertex::parentIndex(), and SimTrack::vertIndex().

Referenced by getGenParticles(), and lostEnergyFraction().

242  {
243  const SimTrack* track = getTrack (fSimTrackId);
244  if (!track) return -1;
245  while (track->noGenpart ()) {
246  if (track->noVertex ()) {
247  std::cerr << "JetMatchingTools::generatorId-> No vertex for track " << *track << std::endl;
248  return -1;
249  }
250  const SimVertex* vertex = &((*getSimVertexCollection ())[track->vertIndex ()]);
251  if (vertex->noParent()) {
252  std::cerr << "JetMatchingTools::generatorId-> No track for vertex " << *vertex << std::endl;
253  return -1;
254  }
255  track = getTrack (vertex->parentIndex ());
256  }
257  return track->genpartIndex ();
258 }
const edm::SimVertexContainer * getSimVertexCollection()
bool noGenpart() const
Definition: SimTrack.h:34
int parentIndex() const
Definition: SimVertex.h:33
int genpartIndex() const
index of the corresponding Generator particle in the Event container (-1 if no Genpart) ...
Definition: SimTrack.h:33
bool noVertex() const
Definition: SimTrack.h:30
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
Definition: SimTrack.h:29
const SimTrack * getTrack(unsigned fSimTrackId)
convert trackId to SimTrack
bool noParent() const
Definition: SimVertex.h:34
std::vector<const CaloTower*> JetMatchingTools::getCaloTowers ( int  fGeneratorId)

CaloTowers.

std::vector< JetMatchingTools::JetConstituent > JetMatchingTools::getConstituentHits ( const CaloTower fTower)

get CaloRecHits contributing to the tower

Definition at line 165 of file JetMatchingTools.cc.

References assert(), dtNoiseDBValidation_cfg::cerr, CaloTower::constituent(), CaloTower::constituentsSize(), DetId::Ecal, EcalBarrel, EcalEndcap, getEBRecHitCollection(), getEERecHitCollection(), getHBHERecHitCollection(), getHFRecHitCollection(), getHORecHitCollection(), DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, i, NULL, and query::result.

Referenced by lostEnergyFraction().

165  {
166  std::vector<JetConstituent> result;
167 
168  for (unsigned i = 0; i < fTower.constituentsSize(); ++i) {
169  DetId id = fTower.constituent (i);
170 
171  if (id.det () == DetId::Ecal) {
172  const EcalRecHit *hit = NULL;
173 
174  if ((EcalSubdetector) id.subdetId () == EcalBarrel) {
175  hit = getHit (*getEBRecHitCollection (), id);
176  }
177  else if ((EcalSubdetector) id.subdetId () == EcalEndcap) {
178  hit = getHit (*getEERecHitCollection (), id);
179  }
180 
181  assert(hit != NULL);
182  if (hit) result.push_back(JetConstituent(*hit));
183  else std::cerr << "Can not find rechit for id " << id.rawId () << std::endl;
184  } else if (id.det () == DetId::Hcal) {
185  const CaloRecHit* hit = NULL;
186 
187  if ((HcalSubdetector) id.subdetId () == HcalBarrel || (HcalSubdetector) id.subdetId () == HcalEndcap) {
188  hit = getHit (*getHBHERecHitCollection (), id);
189  }
190  else if ((HcalSubdetector) id.subdetId () == HcalOuter) {
191  hit = getHit (*getHORecHitCollection (), id);
192  }
193  if ((HcalSubdetector) id.subdetId () == HcalForward) {
194  hit = getHit (*getHFRecHitCollection (), id);
195  }
196 
197  if (hit) result.push_back(JetConstituent(*hit));
198  else std::cerr << "Can not find rechit for id " << id.rawId () << std::endl;
199  }
200  }
201 
202  return result;
203 }
int i
Definition: DBlmapReader.cc:9
size_t constituentsSize() const
Definition: CaloTower.h:89
const HFRecHitCollection * getHFRecHitCollection()
DetId constituent(size_t i) const
Definition: CaloTower.h:90
assert(m_qm.get())
#define NULL
Definition: scimark2.h:8
tuple result
Definition: query.py:137
const EBRecHitCollection * getEBRecHitCollection()
HcalSubdetector
Definition: HcalAssistant.h:31
const EERecHitCollection * getEERecHitCollection()
const HORecHitCollection * getHORecHitCollection()
const HBHERecHitCollection * getHBHERecHitCollection()
Definition: DetId.h:18
EcalSubdetector
std::vector< DetId > JetMatchingTools::getConstituentIds ( const CaloTower fTower)

get cells contributing to the tower

Definition at line 206 of file JetMatchingTools.cc.

References CaloTower::constituent(), CaloTower::constituentsSize(), i, and query::result.

Referenced by getGenParticles().

206  {
207  std::vector <DetId> result;
208  for (unsigned i = 0; i < fTower.constituentsSize(); ++i) {
209  DetId id = fTower.constituent (i);
210  result.push_back (id);
211  }
212  return result;
213 }
int i
Definition: DBlmapReader.cc:9
size_t constituentsSize() const
Definition: CaloTower.h:89
DetId constituent(size_t i) const
Definition: CaloTower.h:90
tuple result
Definition: query.py:137
Definition: DetId.h:18
std::vector< const CaloTower * > JetMatchingTools::getConstituents ( const reco::CaloJet fJet)

get towers contributing to CaloJet

Definition at line 157 of file JetMatchingTools.cc.

References reco::CaloJet::getCaloConstituents(), i, and query::result.

Referenced by getGenParticles(), and lostEnergyFraction().

157  {
158  std::vector <const CaloTower*> result;
159  std::vector<CaloTowerPtr> constituents = fJet.getCaloConstituents ();
160  for (unsigned i = 0; i < constituents.size(); ++i) result.push_back (&*(constituents[i]));
161  return result;
162 }
int i
Definition: DBlmapReader.cc:9
virtual std::vector< CaloTowerPtr > getCaloConstituents() const
get all constituents
Definition: CaloJet.cc:93
tuple result
Definition: query.py:137
const EBRecHitCollection * JetMatchingTools::getEBRecHitCollection ( )

Definition at line 67 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_ebrechits_token_, mEBRecHitCollection, mEvent, and HLT_50nsGRun_cff::recHits.

Referenced by getConstituentHits().

67  {
68  if (!mEBRecHitCollection) {
72  }
73  return mEBRecHitCollection;
74 }
const EBRecHitCollection * mEBRecHitCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
edm::EDGetTokenT< EBRecHitCollection > input_ebrechits_token_
const edm::Event * mEvent
const PCaloHitContainer * JetMatchingTools::getEBSimHitCollection ( )

Definition at line 107 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_pcalohits_ebcal_token_, mEBSimHitCollection, mEvent, and trackerHits::simHits.

Referenced by getPCaloHits().

107  {
108  if (!mEBSimHitCollection) {
112  }
113  return mEBSimHitCollection;
114 }
edm::EDGetTokenT< edm::PCaloHitContainer > input_pcalohits_ebcal_token_
const edm::PCaloHitContainer * mEBSimHitCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
tuple simHits
Definition: trackerHits.py:16
const edm::Event * mEvent
const EERecHitCollection * JetMatchingTools::getEERecHitCollection ( )

Definition at line 75 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_eerechits_token_, mEERecHitCollection, mEvent, and HLT_50nsGRun_cff::recHits.

Referenced by getConstituentHits().

75  {
76  if (!mEERecHitCollection) {
80  }
81  return mEERecHitCollection;
82 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
edm::EDGetTokenT< EERecHitCollection > input_eerechits_token_
const EERecHitCollection * mEERecHitCollection
const edm::Event * mEvent
const PCaloHitContainer * JetMatchingTools::getEESimHitCollection ( )

Definition at line 115 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_pcalohits_eecal_token_, mEESimHitCollection, mEvent, and trackerHits::simHits.

Referenced by getPCaloHits().

115  {
116  if (!mEESimHitCollection) {
120  }
121  return mEESimHitCollection;
122 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
const edm::PCaloHitContainer * mEESimHitCollection
edm::EDGetTokenT< edm::PCaloHitContainer > input_pcalohits_eecal_token_
tuple simHits
Definition: trackerHits.py:16
const edm::Event * mEvent
const reco::GenParticle * JetMatchingTools::getGenParticle ( int  fGeneratorId)

GenParticle.

Definition at line 261 of file JetMatchingTools.cc.

References dtNoiseDBValidation_cfg::cerr, reco::GenJet::genParticle(), getGenParticlesCollection(), edm::OwnVector< T, P >::size(), and findQualityFiles::size.

Referenced by getGenParticles().

261  {
262  if (fGeneratorId > int (getGenParticlesCollection ()->size())) {
263  std::cerr << "JetMatchingTools::getGenParticle-> requested index " << fGeneratorId << " is grater then container size " << getGenParticlesCollection ()->size() << std::endl;
264  return 0;
265  }
266  return reco::GenJet::genParticle ( &(*getGenParticlesCollection ())[fGeneratorId-1]); // knowhow: index is shifted by 1
267 }
const reco::CandidateCollection * getGenParticlesCollection()
size_type size() const
Definition: OwnVector.h:254
static const GenParticle * genParticle(const reco::Candidate *fConstituent)
convert generic constituent to specific type
Definition: GenJet.cc:38
tuple size
Write out results.
std::vector< const reco::GenParticle * > JetMatchingTools::getGenParticles ( const reco::CaloJet fJet,
bool  fVerbose = true 
)

GenParticles for CaloJet.

Definition at line 270 of file JetMatchingTools.cc.

References dtNoiseDBValidation_cfg::cerr, generatorId(), getConstituentIds(), getConstituents(), getGenParticle(), getPCaloHits(), getTrackId(), query::result, and HLT_25ns14e33_v1_cff::towers.

Referenced by IsolatedParticlesGeneratedJets::analyze().

270  {
271  std::set <const reco::GenParticle*> result;
272  // follow the chain
273  std::vector <const CaloTower*> towers = getConstituents (fJet) ;
274  for (unsigned itower = 0; itower < towers.size (); ++itower) {
275  std::vector <DetId> detids = getConstituentIds (*(towers[itower])) ;
276  for (unsigned iid = 0; iid < detids.size(); ++iid) {
277  std::vector <const PCaloHit*> phits = getPCaloHits (detids[iid]);
278  for (unsigned iphit = 0; iphit < phits.size(); ++iphit) {
279  int trackId = getTrackId (*(phits[iphit]));
280  if (trackId >= 0) {
281  int genId = generatorId (trackId);
282  if (genId >= 0) {
283  const reco::GenParticle* genPart = getGenParticle (genId);
284  if (genPart) {
285  result.insert (genPart);
286  }
287  else if (fVerbose) {
288  std::cerr << "JetMatchingTools::getGenParticles-> Can not convert genId " << genId << " to GenParticle" << std::endl;
289  }
290  }
291  else if (fVerbose) {
292  std::cerr << "JetMatchingTools::getGenParticles-> Can not convert trackId " << trackId << " to genId" << std::endl;
293  }
294  }
295  else if (fVerbose) {
296  std::cerr << "JetMatchingTools::getGenParticles-> Unknown trackId for PCaloHit " << *(phits[iphit]) << std::endl;
297  }
298  }
299  }
300  }
301  return std::vector <const reco::GenParticle*> (result.begin (), result.end());
302 }
std::vector< const PCaloHit * > getPCaloHits(DetId fId)
get PCaloHits contributing to the detId
int generatorId(unsigned fSimTrackId)
Generator ID.
std::vector< DetId > getConstituentIds(const CaloTower &fTower)
get cells contributing to the tower
const reco::GenParticle * getGenParticle(int fGeneratorId)
GenParticle.
tuple result
Definition: query.py:137
std::vector< const CaloTower * > getConstituents(const reco::CaloJet &fJet)
get towers contributing to CaloJet
int getTrackId(const PCaloHit &fHit)
GEANT track ID.
std::vector< const reco::GenParticle * > JetMatchingTools::getGenParticles ( const reco::GenJet fJet)

GenParticles for GenJet.

Definition at line 305 of file JetMatchingTools.cc.

References reco::GenJet::getGenConstituents().

305  {
306  return fJet.getGenConstituents ();
307 }
virtual std::vector< const GenParticle * > getGenConstituents() const
get all constituents
Definition: GenJet.cc:58
const reco::CandidateCollection * JetMatchingTools::getGenParticlesCollection ( )

Definition at line 147 of file JetMatchingTools.cc.

References edm::Event::getByToken(), patZpeak::handle, input_cands_token_, mEvent, and mGenParticleCollection.

Referenced by getGenParticle().

147  {
148  if (!mGenParticleCollection) {
152  }
153  return mGenParticleCollection;
154 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
const reco::CandidateCollection * mGenParticleCollection
edm::EDGetTokenT< reco::CandidateCollection > input_cands_token_
tuple handle
Definition: patZpeak.py:22
const edm::Event * mEvent
const HBHERecHitCollection * JetMatchingTools::getHBHERecHitCollection ( )

Definition at line 83 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_hbherechits_token_, mEvent, mHBHERecHitCollection, and HLT_50nsGRun_cff::recHits.

Referenced by getConstituentHits().

83  {
84  if (!mHBHERecHitCollection) {
88  }
89  return mHBHERecHitCollection;
90 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
const edm::Event * mEvent
edm::EDGetTokenT< HBHERecHitCollection > input_hbherechits_token_
const HBHERecHitCollection * mHBHERecHitCollection
const PCaloHitContainer * JetMatchingTools::getHcalSimHitCollection ( )

Definition at line 123 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_pcalohits_hcal_token_, mEvent, mHcalSimHitCollection, and trackerHits::simHits.

Referenced by getPCaloHits().

123  {
124  if (!mHcalSimHitCollection) {
128  }
129  return mHcalSimHitCollection;
130 }
const edm::PCaloHitContainer * mHcalSimHitCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
tuple simHits
Definition: trackerHits.py:16
const edm::Event * mEvent
edm::EDGetTokenT< edm::PCaloHitContainer > input_pcalohits_hcal_token_
const HFRecHitCollection * JetMatchingTools::getHFRecHitCollection ( )

Definition at line 99 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_hfrechits_token_, mEvent, mHFRecHitCollection, and HLT_50nsGRun_cff::recHits.

Referenced by getConstituentHits().

99  {
100  if (!mHFRecHitCollection) {
104  }
105  return mHFRecHitCollection;
106 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
edm::EDGetTokenT< HFRecHitCollection > input_hfrechits_token_
const edm::Event * mEvent
const HFRecHitCollection * mHFRecHitCollection
const HORecHitCollection * JetMatchingTools::getHORecHitCollection ( )

Definition at line 91 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_horechits_token_, mEvent, mHORecHitCollection, and HLT_50nsGRun_cff::recHits.

Referenced by getConstituentHits().

91  {
92  if (!mHORecHitCollection) {
96  }
97  return mHORecHitCollection;
98 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
edm::EDGetTokenT< HORecHitCollection > input_horechits_token_
const edm::Event * mEvent
const HORecHitCollection * mHORecHitCollection
std::vector< const PCaloHit * > JetMatchingTools::getPCaloHits ( DetId  fId)

get PCaloHits contributing to the detId

Definition at line 215 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().

215  {
216  std::vector <const PCaloHit*> result;
217  if (fId.det () == DetId::Ecal) {
218  if ((EcalSubdetector) fId.subdetId () == EcalBarrel) {
219  result = getSimHits (*getEBSimHitCollection (), fId);
220  }
221  else if ((EcalSubdetector) fId.subdetId () == EcalEndcap) {
222  result = getSimHits (*getEESimHitCollection (), fId);
223  }
224  }
225  else if (fId.det () == DetId::Hcal) {
226  result = getSimHits (*getHcalSimHitCollection (), fId);
227  }
228  return result;
229 }
const edm::PCaloHitContainer * getEESimHitCollection()
const edm::PCaloHitContainer * getEBSimHitCollection()
tuple result
Definition: query.py:137
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
const edm::PCaloHitContainer * getHcalSimHitCollection()
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
EcalSubdetector
std::vector<const PCaloHit*> JetMatchingTools::getPCaloHits ( int  fGeneratorId)

CaloSimHits.

const SimTrackContainer * JetMatchingTools::getSimTrackCollection ( )

Definition at line 131 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_simtrack_token_, mEvent, mSimTrackCollection, and trackerHits::simHits.

Referenced by getTrack().

131  {
132  if (!mSimTrackCollection) {
136  }
137  return mSimTrackCollection;
138 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
const edm::SimTrackContainer * mSimTrackCollection
edm::EDGetTokenT< edm::SimTrackContainer > input_simtrack_token_
tuple simHits
Definition: trackerHits.py:16
const edm::Event * mEvent
const SimVertexContainer * JetMatchingTools::getSimVertexCollection ( )

Definition at line 139 of file JetMatchingTools.cc.

References edm::Event::getByToken(), input_simvertex_token_, mEvent, mSimVertexCollection, and trackerHits::simHits.

Referenced by generatorId().

139  {
140  if (!mSimVertexCollection) {
144  }
145  return mSimVertexCollection;
146 }
edm::EDGetTokenT< edm::SimVertexContainer > input_simvertex_token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
const edm::SimVertexContainer * mSimVertexCollection
tuple simHits
Definition: trackerHits.py:16
const edm::Event * mEvent
const SimTrack * JetMatchingTools::getTrack ( unsigned  fSimTrackId)

convert trackId to SimTrack

Definition at line 235 of file JetMatchingTools.cc.

References getSimTrackCollection(), and i.

Referenced by generatorId().

235  {
236  for (unsigned i = 0; i < getSimTrackCollection ()->size (); ++i) {
237  if ((*getSimTrackCollection ())[i].trackId() == fSimTrackId) return &(*getSimTrackCollection ())[i];
238  }
239  return 0;
240 }
int i
Definition: DBlmapReader.cc:9
const edm::SimTrackContainer * getSimTrackCollection()
int JetMatchingTools::getTrackId ( const PCaloHit fHit)

GEANT track ID.

Definition at line 231 of file JetMatchingTools.cc.

References PCaloHit::geantTrackId().

Referenced by getGenParticles(), and lostEnergyFraction().

231  {
232  return fHit.geantTrackId ();
233 }
int geantTrackId() const
Definition: PCaloHit.h:39
double JetMatchingTools::lostEnergyFraction ( const reco::CaloJet fJet)

energy in broken links

Definition at line 310 of file JetMatchingTools.cc.

References generatorId(), getConstituentHits(), getConstituents(), getPCaloHits(), getTrackId(), HLT_50nsGRun_cff::recHits, and HLT_25ns14e33_v1_cff::towers.

310  {
311  double totalEnergy = 0;
312  double lostEnergy = 0;
313  // follow the chain
314  std::vector <const CaloTower*> towers = getConstituents (fJet) ;
315  for (unsigned itower = 0; itower < towers.size (); ++itower) {
316  std::vector<JetConstituent> recHits = getConstituentHits(*(towers[itower]));
317  for (unsigned ihit = 0; ihit < recHits.size(); ++ihit) {
318  double foundSimEnergy = 0;
319  double lostSimEnergy = 0;
320  std::vector <const PCaloHit*> phits = getPCaloHits (recHits[ihit].id);
321  for (unsigned iphit = 0; iphit < phits.size(); ++iphit) {
322  double simEnergy = phits[iphit]->energy ();
323  int trackId = getTrackId (*(phits[iphit]));
324  if (trackId < 0 || generatorId (trackId) < 0) lostSimEnergy += simEnergy;
325  else foundSimEnergy += simEnergy;
326  }
327  if (foundSimEnergy > 0 || lostSimEnergy > 0) {
328  totalEnergy += recHits[ihit].energy;
329  lostEnergy += recHits[ihit].energy * lostSimEnergy / (foundSimEnergy + lostSimEnergy);
330  }
331  }
332  }
333  return lostEnergy / totalEnergy;
334 }
std::vector< const PCaloHit * > getPCaloHits(DetId fId)
get PCaloHits contributing to the detId
int generatorId(unsigned fSimTrackId)
Generator ID.
std::vector< JetConstituent > getConstituentHits(const CaloTower &fTower)
get CaloRecHits contributing to the tower
std::vector< const CaloTower * > getConstituents(const reco::CaloJet &fJet)
get towers contributing to CaloJet
int getTrackId(const PCaloHit &fHit)
GEANT track ID.
double JetMatchingTools::overlapEnergyFraction ( const std::vector< const reco::GenParticle * > &  fObject,
const std::vector< const reco::GenParticle * > &  fReference 
) const

energy overlap

Definition at line 337 of file JetMatchingTools.cc.

References relval_parameters_module::energy, spr::find(), and i.

338  {
339  if (fObject.empty()) return 0;
340  double totalEnergy = 0;
341  double overlapEnergy = 0;
342  for (unsigned i = 0; i < fObject.size(); ++i) {
343  totalEnergy += fObject [i]->energy();
344  if (find (fReference.begin(), fReference.end(), fObject [i]) != fReference.end ()) overlapEnergy += fObject [i]->energy();
345  }
346  return overlapEnergy / totalEnergy;
347 }
int i
Definition: DBlmapReader.cc:9
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7

Member Data Documentation

edm::EDGetTokenT<reco::CandidateCollection> JetMatchingTools::input_cands_token_
private

Definition at line 117 of file JetMatchingTools.h.

Referenced by getGenParticlesCollection(), and JetMatchingTools().

edm::EDGetTokenT<EBRecHitCollection> JetMatchingTools::input_ebrechits_token_
private

Definition at line 107 of file JetMatchingTools.h.

Referenced by getEBRecHitCollection(), and JetMatchingTools().

edm::EDGetTokenT<EERecHitCollection> JetMatchingTools::input_eerechits_token_
private

Definition at line 108 of file JetMatchingTools.h.

Referenced by getEERecHitCollection(), and JetMatchingTools().

edm::EDGetTokenT<HBHERecHitCollection> JetMatchingTools::input_hbherechits_token_
private

Definition at line 109 of file JetMatchingTools.h.

Referenced by getHBHERecHitCollection(), and JetMatchingTools().

edm::EDGetTokenT<HFRecHitCollection> JetMatchingTools::input_hfrechits_token_
private

Definition at line 111 of file JetMatchingTools.h.

Referenced by getHFRecHitCollection(), and JetMatchingTools().

edm::EDGetTokenT<HORecHitCollection> JetMatchingTools::input_horechits_token_
private

Definition at line 110 of file JetMatchingTools.h.

Referenced by getHORecHitCollection(), and JetMatchingTools().

edm::EDGetTokenT<edm::PCaloHitContainer> JetMatchingTools::input_pcalohits_ebcal_token_
private

Definition at line 113 of file JetMatchingTools.h.

Referenced by getEBSimHitCollection(), and JetMatchingTools().

edm::EDGetTokenT<edm::PCaloHitContainer> JetMatchingTools::input_pcalohits_eecal_token_
private

Definition at line 112 of file JetMatchingTools.h.

Referenced by getEESimHitCollection(), and JetMatchingTools().

edm::EDGetTokenT<edm::PCaloHitContainer> JetMatchingTools::input_pcalohits_hcal_token_
private

Definition at line 114 of file JetMatchingTools.h.

Referenced by getHcalSimHitCollection(), and JetMatchingTools().

edm::EDGetTokenT<edm::SimTrackContainer> JetMatchingTools::input_simtrack_token_
private

Definition at line 115 of file JetMatchingTools.h.

Referenced by getSimTrackCollection(), and JetMatchingTools().

edm::EDGetTokenT<edm::SimVertexContainer> JetMatchingTools::input_simvertex_token_
private

Definition at line 116 of file JetMatchingTools.h.

Referenced by getSimVertexCollection(), and JetMatchingTools().

const EBRecHitCollection* JetMatchingTools::mEBRecHitCollection
private

Definition at line 95 of file JetMatchingTools.h.

Referenced by getEBRecHitCollection().

const edm::PCaloHitContainer* JetMatchingTools::mEBSimHitCollection
private

Definition at line 100 of file JetMatchingTools.h.

Referenced by getEBSimHitCollection().

const EERecHitCollection* JetMatchingTools::mEERecHitCollection
private

Definition at line 96 of file JetMatchingTools.h.

Referenced by getEERecHitCollection().

const edm::PCaloHitContainer* JetMatchingTools::mEESimHitCollection
private

Definition at line 101 of file JetMatchingTools.h.

Referenced by getEESimHitCollection().

const edm::Event* JetMatchingTools::mEvent
private
const reco::CandidateCollection* JetMatchingTools::mGenParticleCollection
private

Definition at line 105 of file JetMatchingTools.h.

Referenced by getGenParticlesCollection().

const HBHERecHitCollection* JetMatchingTools::mHBHERecHitCollection
private

Definition at line 97 of file JetMatchingTools.h.

Referenced by getHBHERecHitCollection().

const edm::PCaloHitContainer* JetMatchingTools::mHcalSimHitCollection
private

Definition at line 102 of file JetMatchingTools.h.

Referenced by getHcalSimHitCollection().

const HFRecHitCollection* JetMatchingTools::mHFRecHitCollection
private

Definition at line 99 of file JetMatchingTools.h.

Referenced by getHFRecHitCollection().

const HORecHitCollection* JetMatchingTools::mHORecHitCollection
private

Definition at line 98 of file JetMatchingTools.h.

Referenced by getHORecHitCollection().

const edm::SimTrackContainer* JetMatchingTools::mSimTrackCollection
private

Definition at line 103 of file JetMatchingTools.h.

Referenced by getSimTrackCollection().

const edm::SimVertexContainer* JetMatchingTools::mSimVertexCollection
private

Definition at line 104 of file JetMatchingTools.h.

Referenced by getSimVertexCollection().