CMS 3D CMS Logo

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::CandidateCollectioninput_cands_token_
 
edm::EDGetTokenT< EBRecHitCollectioninput_ebrechits_token_
 
edm::EDGetTokenT< EERecHitCollectioninput_eerechits_token_
 
edm::EDGetTokenT< HBHERecHitCollectioninput_hbherechits_token_
 
edm::EDGetTokenT< HFRecHitCollectioninput_hfrechits_token_
 
edm::EDGetTokenT< HORecHitCollectioninput_horechits_token_
 
edm::EDGetTokenT< edm::PCaloHitContainerinput_pcalohits_ebcal_token_
 
edm::EDGetTokenT< edm::PCaloHitContainerinput_pcalohits_eecal_token_
 
edm::EDGetTokenT< edm::PCaloHitContainerinput_pcalohits_hcal_token_
 
edm::EDGetTokenT< edm::SimTrackContainerinput_simtrack_token_
 
edm::EDGetTokenT< edm::SimVertexContainerinput_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 37 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_2018_cff::InputTag.

38  : mEvent(&fEvent),
39  mEBRecHitCollection(nullptr),
40  mEERecHitCollection(nullptr),
41  mHBHERecHitCollection(nullptr),
42  mHORecHitCollection(nullptr),
43  mHFRecHitCollection(nullptr),
44  mEBSimHitCollection(nullptr),
45  mEESimHitCollection(nullptr),
46  mHcalSimHitCollection(nullptr),
47  mSimTrackCollection(nullptr),
48  mSimVertexCollection(nullptr),
49  mGenParticleCollection(nullptr) {
50  input_ebrechits_token_ = iC.mayConsume<EBRecHitCollection>(edm::InputTag("ecalRecHit:EcalRecHitsEB"));
51  input_eerechits_token_ = iC.mayConsume<EERecHitCollection>(edm::InputTag("ecalRecHit:EcalRecHitsEE"));
61 }
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 63 of file JetMatchingTools.cc.

63 {}

Member Function Documentation

int JetMatchingTools::generatorId ( unsigned  fSimTrackId)

Generator ID.

Definition at line 240 of file JetMatchingTools.cc.

References beam_dqm_sourceclient-live_cfg::cerr, SimTrack::genpartIndex(), getSimVertexCollection(), getTrack(), SimTrack::noGenpart(), SimVertex::noParent(), SimTrack::noVertex(), SimVertex::parentIndex(), HLT_2018_cff::track, bphysicsOniaDQM_cfi::vertex, and SimTrack::vertIndex().

Referenced by getGenParticles(), and lostEnergyFraction().

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

References beam_dqm_sourceclient-live_cfg::cerr, CaloTower::constituent(), CaloTower::constituentsSize(), DetId::Ecal, EcalBarrel, EcalEndcap, getEBRecHitCollection(), getEERecHitCollection(), getHBHERecHitCollection(), getHFRecHitCollection(), getHORecHitCollection(), DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, mps_fire::i, and mps_fire::result.

Referenced by lostEnergyFraction().

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

get cells contributing to the tower

Definition at line 207 of file JetMatchingTools.cc.

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

Referenced by getGenParticles().

207  {
208  std::vector<DetId> result;
209  for (unsigned i = 0; i < fTower.constituentsSize(); ++i) {
210  DetId id = fTower.constituent(i);
211  result.push_back(id);
212  }
213  return result;
214 }
size_t constituentsSize() const
Definition: CaloTower.h:129
DetId constituent(size_t i) const
Definition: CaloTower.h:130
Definition: DetId.h:17
std::vector< const CaloTower * > JetMatchingTools::getConstituents ( const reco::CaloJet fJet)

get towers contributing to CaloJet

Definition at line 155 of file JetMatchingTools.cc.

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

Referenced by getGenParticles(), and lostEnergyFraction().

155  {
156  std::vector<const CaloTower*> result;
157  std::vector<CaloTowerPtr> constituents = fJet.getCaloConstituents();
158  for (unsigned i = 0; i < constituents.size(); ++i)
159  result.push_back(&*(constituents[i]));
160  return result;
161 }
virtual std::vector< CaloTowerPtr > getCaloConstituents() const
get all constituents
Definition: CaloJet.cc:78
const EBRecHitCollection * JetMatchingTools::getEBRecHitCollection ( )

Definition at line 65 of file JetMatchingTools.cc.

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

Referenced by getConstituentHits().

65  {
66  if (!mEBRecHitCollection) {
70  }
71  return mEBRecHitCollection;
72 }
const EBRecHitCollection * mEBRecHitCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< EBRecHitCollection > input_ebrechits_token_
const edm::Event * mEvent
const PCaloHitContainer * JetMatchingTools::getEBSimHitCollection ( )

Definition at line 105 of file JetMatchingTools.cc.

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

Referenced by getPCaloHits().

105  {
106  if (!mEBSimHitCollection) {
110  }
111  return mEBSimHitCollection;
112 }
edm::EDGetTokenT< edm::PCaloHitContainer > input_pcalohits_ebcal_token_
const edm::PCaloHitContainer * mEBSimHitCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const edm::Event * mEvent
const EERecHitCollection * JetMatchingTools::getEERecHitCollection ( )

Definition at line 73 of file JetMatchingTools.cc.

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

Referenced by getConstituentHits().

73  {
74  if (!mEERecHitCollection) {
78  }
79  return mEERecHitCollection;
80 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< EERecHitCollection > input_eerechits_token_
const EERecHitCollection * mEERecHitCollection
const edm::Event * mEvent
const PCaloHitContainer * JetMatchingTools::getEESimHitCollection ( )

Definition at line 113 of file JetMatchingTools.cc.

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

Referenced by getPCaloHits().

113  {
114  if (!mEESimHitCollection) {
118  }
119  return mEESimHitCollection;
120 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const edm::PCaloHitContainer * mEESimHitCollection
edm::EDGetTokenT< edm::PCaloHitContainer > input_pcalohits_eecal_token_
const edm::Event * mEvent
const reco::GenParticle * JetMatchingTools::getGenParticle ( int  fGeneratorId)

GenParticle.

Definition at line 260 of file JetMatchingTools.cc.

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

Referenced by getGenParticles().

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

GenParticles for CaloJet.

Definition at line 271 of file JetMatchingTools.cc.

References beam_dqm_sourceclient-live_cfg::cerr, generatorId(), getConstituentIds(), getConstituents(), getGenParticle(), getPCaloHits(), getTrackId(), mps_fire::result, and HLT_2018_cff::towers.

Referenced by IsolatedParticlesGeneratedJets::analyze().

271  {
272  std::set<const reco::GenParticle*> result;
273  // follow the chain
274  std::vector<const CaloTower*> towers = getConstituents(fJet);
275  for (unsigned itower = 0; itower < towers.size(); ++itower) {
276  std::vector<DetId> detids = getConstituentIds(*(towers[itower]));
277  for (unsigned iid = 0; iid < detids.size(); ++iid) {
278  std::vector<const PCaloHit*> phits = getPCaloHits(detids[iid]);
279  for (unsigned iphit = 0; iphit < phits.size(); ++iphit) {
280  int trackId = getTrackId(*(phits[iphit]));
281  if (trackId >= 0) {
282  int genId = generatorId(trackId);
283  if (genId >= 0) {
284  const reco::GenParticle* genPart = getGenParticle(genId);
285  if (genPart) {
286  result.insert(genPart);
287  } else if (fVerbose) {
288  std::cerr << "JetMatchingTools::getGenParticles-> Can not convert genId " << genId << " to GenParticle"
289  << std::endl;
290  }
291  } else if (fVerbose) {
292  std::cerr << "JetMatchingTools::getGenParticles-> Can not convert trackId " << trackId << " to genId"
293  << std::endl;
294  }
295  } else if (fVerbose) {
296  std::cerr << "JetMatchingTools::getGenParticles-> Unknown trackId for PCaloHit " << *(phits[iphit])
297  << std::endl;
298  }
299  }
300  }
301  }
302  return std::vector<const reco::GenParticle*>(result.begin(), result.end());
303 }
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.
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 306 of file JetMatchingTools.cc.

References reco::GenJet::getGenConstituents().

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

Definition at line 145 of file JetMatchingTools.cc.

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

Referenced by getGenParticle().

145  {
146  if (!mGenParticleCollection) {
150  }
151  return mGenParticleCollection;
152 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const reco::CandidateCollection * mGenParticleCollection
edm::EDGetTokenT< reco::CandidateCollection > input_cands_token_
const edm::Event * mEvent
const HBHERecHitCollection * JetMatchingTools::getHBHERecHitCollection ( )

Definition at line 81 of file JetMatchingTools.cc.

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

Referenced by getConstituentHits().

81  {
82  if (!mHBHERecHitCollection) {
86  }
87  return mHBHERecHitCollection;
88 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const edm::Event * mEvent
edm::EDGetTokenT< HBHERecHitCollection > input_hbherechits_token_
const HBHERecHitCollection * mHBHERecHitCollection
const PCaloHitContainer * JetMatchingTools::getHcalSimHitCollection ( )

Definition at line 121 of file JetMatchingTools.cc.

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

Referenced by getPCaloHits().

121  {
122  if (!mHcalSimHitCollection) {
126  }
127  return mHcalSimHitCollection;
128 }
const edm::PCaloHitContainer * mHcalSimHitCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const edm::Event * mEvent
edm::EDGetTokenT< edm::PCaloHitContainer > input_pcalohits_hcal_token_
const HFRecHitCollection * JetMatchingTools::getHFRecHitCollection ( )

Definition at line 97 of file JetMatchingTools.cc.

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

Referenced by getConstituentHits().

97  {
98  if (!mHFRecHitCollection) {
102  }
103  return mHFRecHitCollection;
104 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< HFRecHitCollection > input_hfrechits_token_
const edm::Event * mEvent
const HFRecHitCollection * mHFRecHitCollection
const HORecHitCollection * JetMatchingTools::getHORecHitCollection ( )

Definition at line 89 of file JetMatchingTools.cc.

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

Referenced by getConstituentHits().

89  {
90  if (!mHORecHitCollection) {
94  }
95  return mHORecHitCollection;
96 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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 216 of file JetMatchingTools.cc.

References DetId::det(), DetId::Ecal, EcalBarrel, EcalEndcap, getEBSimHitCollection(), getEESimHitCollection(), getHcalSimHitCollection(), DetId::Hcal, mps_fire::result, and DetId::subdetId().

Referenced by getGenParticles(), and lostEnergyFraction().

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

CaloSimHits.

const SimTrackContainer * JetMatchingTools::getSimTrackCollection ( )

Definition at line 129 of file JetMatchingTools.cc.

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

Referenced by getTrack().

129  {
130  if (!mSimTrackCollection) {
134  }
135  return mSimTrackCollection;
136 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const edm::SimTrackContainer * mSimTrackCollection
edm::EDGetTokenT< edm::SimTrackContainer > input_simtrack_token_
const edm::Event * mEvent
const SimVertexContainer * JetMatchingTools::getSimVertexCollection ( )

Definition at line 137 of file JetMatchingTools.cc.

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

Referenced by generatorId().

137  {
138  if (!mSimVertexCollection) {
142  }
143  return mSimVertexCollection;
144 }
edm::EDGetTokenT< edm::SimVertexContainer > input_simvertex_token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const edm::SimVertexContainer * mSimVertexCollection
const edm::Event * mEvent
const SimTrack * JetMatchingTools::getTrack ( unsigned  fSimTrackId)

convert trackId to SimTrack

Definition at line 232 of file JetMatchingTools.cc.

References getSimTrackCollection(), and mps_fire::i.

Referenced by generatorId().

232  {
233  for (unsigned i = 0; i < getSimTrackCollection()->size(); ++i) {
234  if ((*getSimTrackCollection())[i].trackId() == fSimTrackId)
235  return &(*getSimTrackCollection())[i];
236  }
237  return nullptr;
238 }
const edm::SimTrackContainer * getSimTrackCollection()
int JetMatchingTools::getTrackId ( const PCaloHit fHit)

GEANT track ID.

Definition at line 230 of file JetMatchingTools.cc.

References PCaloHit::geantTrackId().

Referenced by getGenParticles(), and lostEnergyFraction().

230 { return fHit.geantTrackId(); }
int geantTrackId() const
Definition: PCaloHit.h:33
double JetMatchingTools::lostEnergyFraction ( const reco::CaloJet fJet)

energy in broken links

Definition at line 311 of file JetMatchingTools.cc.

References generatorId(), getConstituentHits(), getConstituents(), getPCaloHits(), getTrackId(), FastTrackerRecHitMaskProducer_cfi::recHits, and HLT_2018_cff::towers.

311  {
312  double totalEnergy = 0;
313  double lostEnergy = 0;
314  // follow the chain
315  std::vector<const CaloTower*> towers = getConstituents(fJet);
316  for (unsigned itower = 0; itower < towers.size(); ++itower) {
317  std::vector<JetConstituent> recHits = getConstituentHits(*(towers[itower]));
318  for (unsigned ihit = 0; ihit < recHits.size(); ++ihit) {
319  double foundSimEnergy = 0;
320  double lostSimEnergy = 0;
321  std::vector<const PCaloHit*> phits = getPCaloHits(recHits[ihit].id);
322  for (unsigned iphit = 0; iphit < phits.size(); ++iphit) {
323  double simEnergy = phits[iphit]->energy();
324  int trackId = getTrackId(*(phits[iphit]));
325  if (trackId < 0 || generatorId(trackId) < 0)
326  lostSimEnergy += simEnergy;
327  else
328  foundSimEnergy += simEnergy;
329  }
330  if (foundSimEnergy > 0 || lostSimEnergy > 0) {
331  totalEnergy += recHits[ihit].energy;
332  lostEnergy += recHits[ihit].energy * lostSimEnergy / (foundSimEnergy + lostSimEnergy);
333  }
334  }
335  }
336  return lostEnergy / totalEnergy;
337 }
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 340 of file JetMatchingTools.cc.

References HCALHighEnergyHPDFilter_cfi::energy, spr::find(), and mps_fire::i.

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

Member Data Documentation

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

Definition at line 114 of file JetMatchingTools.h.

Referenced by getGenParticlesCollection(), and JetMatchingTools().

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

Definition at line 104 of file JetMatchingTools.h.

Referenced by getEBRecHitCollection(), and JetMatchingTools().

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

Definition at line 105 of file JetMatchingTools.h.

Referenced by getEERecHitCollection(), and JetMatchingTools().

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

Definition at line 106 of file JetMatchingTools.h.

Referenced by getHBHERecHitCollection(), and JetMatchingTools().

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

Definition at line 108 of file JetMatchingTools.h.

Referenced by getHFRecHitCollection(), and JetMatchingTools().

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

Definition at line 107 of file JetMatchingTools.h.

Referenced by getHORecHitCollection(), and JetMatchingTools().

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

Definition at line 110 of file JetMatchingTools.h.

Referenced by getEBSimHitCollection(), and JetMatchingTools().

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

Definition at line 109 of file JetMatchingTools.h.

Referenced by getEESimHitCollection(), and JetMatchingTools().

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

Definition at line 111 of file JetMatchingTools.h.

Referenced by getHcalSimHitCollection(), and JetMatchingTools().

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

Definition at line 112 of file JetMatchingTools.h.

Referenced by getSimTrackCollection(), and JetMatchingTools().

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

Definition at line 113 of file JetMatchingTools.h.

Referenced by getSimVertexCollection(), and JetMatchingTools().

const EBRecHitCollection* JetMatchingTools::mEBRecHitCollection
private

Definition at line 92 of file JetMatchingTools.h.

Referenced by getEBRecHitCollection().

const edm::PCaloHitContainer* JetMatchingTools::mEBSimHitCollection
private

Definition at line 97 of file JetMatchingTools.h.

Referenced by getEBSimHitCollection().

const EERecHitCollection* JetMatchingTools::mEERecHitCollection
private

Definition at line 93 of file JetMatchingTools.h.

Referenced by getEERecHitCollection().

const edm::PCaloHitContainer* JetMatchingTools::mEESimHitCollection
private

Definition at line 98 of file JetMatchingTools.h.

Referenced by getEESimHitCollection().

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

Definition at line 102 of file JetMatchingTools.h.

Referenced by getGenParticlesCollection().

const HBHERecHitCollection* JetMatchingTools::mHBHERecHitCollection
private

Definition at line 94 of file JetMatchingTools.h.

Referenced by getHBHERecHitCollection().

const edm::PCaloHitContainer* JetMatchingTools::mHcalSimHitCollection
private

Definition at line 99 of file JetMatchingTools.h.

Referenced by getHcalSimHitCollection().

const HFRecHitCollection* JetMatchingTools::mHFRecHitCollection
private

Definition at line 96 of file JetMatchingTools.h.

Referenced by getHFRecHitCollection().

const HORecHitCollection* JetMatchingTools::mHORecHitCollection
private

Definition at line 95 of file JetMatchingTools.h.

Referenced by getHORecHitCollection().

const edm::SimTrackContainer* JetMatchingTools::mSimTrackCollection
private

Definition at line 100 of file JetMatchingTools.h.

Referenced by getSimTrackCollection().

const edm::SimVertexContainer* JetMatchingTools::mSimVertexCollection
private

Definition at line 101 of file JetMatchingTools.h.

Referenced by getSimVertexCollection().