CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
HitParentTest Class Reference
Inheritance diagram for HitParentTest:
edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 HitParentTest (const edm::ParameterSet &ps)
 
 ~HitParentTest () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::SharedResources >
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob () override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob () override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Private Member Functions

void analyzeAPDHits (const std::vector< PCaloHit > &, int depth)
 
void analyzeHits (const std::vector< PCaloHit > &, int type)
 
math::XYZTLorentzVectorD getOldestParentVertex (edm::SimTrackContainer::const_iterator track)
 
edm::SimTrackContainer::const_iterator parentSimTrack (edm::SimTrackContainer::const_iterator thisTrkItr)
 
bool simTrackPresent (int id)
 
bool validSimTrack (unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr)
 

Private Attributes

std::string detector [7]
 
std::string g4Label
 
bool histos
 
std::string hitLabEB
 
std::string hitLabEE
 
std::string hitLabES
 
std::string hitLabHC
 
TH1F * hitRho [7]
 
TH1F * hitType [7]
 
TH1F * hitZ [7]
 
unsigned int noGenParticle [7]
 
unsigned int noParent [7]
 
unsigned int noSimTrack [7]
 
unsigned int num_apd_hits_no_gen_particle [2]
 
unsigned int num_apd_hits_no_parent [2]
 
unsigned int num_apd_hits_no_simtrack [2]
 
std::map< int, unsigned > particle_type_count
 
edm::Handle< edm::SimTrackContainerSimTk
 
edm::Handle< edm::SimVertexContainerSimVtx
 
std::string sourceLabel
 
edm::EDGetTokenT< edm::PCaloHitContainertok_eb_
 
edm::EDGetTokenT< edm::PCaloHitContainertok_ee_
 
edm::EDGetTokenT< edm::PCaloHitContainertok_es_
 
edm::EDGetTokenT< edm::PCaloHitContainertok_hc_
 
edm::EDGetTokenT< edm::SimTrackContainertok_tk_
 
edm::EDGetTokenT< edm::SimVertexContainertok_vtx_
 
unsigned int total_num_apd_hits_seen [2]
 
unsigned int totalHits [7]
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Detailed Description

Definition at line 36 of file HitParentTest.cc.

Constructor & Destructor Documentation

◆ HitParentTest()

HitParentTest::HitParentTest ( const edm::ParameterSet ps)

Definition at line 93 of file HitParentTest.cc.

93  {
94  usesResource(TFileService::kSharedResource);
95 
96  sourceLabel = ps.getUntrackedParameter<std::string>("SourceLabel", "VtxSmeared");
97  g4Label = ps.getUntrackedParameter<std::string>("ModuleLabel", "g4SimHits");
98  hitLabEB = ps.getUntrackedParameter<std::string>("EBCollection", "EcalHitsEB");
99  hitLabEE = ps.getUntrackedParameter<std::string>("EECollection", "EcalHitsEE");
100  hitLabES = ps.getUntrackedParameter<std::string>("ESCollection", "EcalHitsES");
101  hitLabHC = ps.getUntrackedParameter<std::string>("HCCollection", "HcalHits");
102  edm::LogVerbatim("HitParentTest") << "Module Label: " << g4Label << " Hits: " << hitLabEB << ", " << hitLabEE
103  << ", " << hitLabES << ", " << hitLabHC;
104 
105  tok_eb_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label, hitLabEB));
106  tok_ee_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label, hitLabEE));
107  tok_es_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label, hitLabES));
108  tok_hc_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label, hitLabHC));
109  tok_tk_ = consumes<edm::SimTrackContainer>(edm::InputTag(g4Label));
110  tok_vtx_ = consumes<edm::SimVertexContainer>(edm::InputTag(g4Label));
111 
112  for (unsigned int i = 0; i < 2; ++i) {
117  }
118  std::string dets[7] = {"EB", "EE", "ES", "HB", "HE", "HO", "HF"};
119  for (unsigned int i = 0; i < 7; ++i) {
120  detector[i] = dets[i];
121  totalHits[i] = 0;
122  noParent[i] = 0;
123  noSimTrack[i] = 0;
124  noGenParticle[i] = 0;
125  }
126 }

References detector, g4Label, edm::ParameterSet::getUntrackedParameter(), hitLabEB, hitLabEE, hitLabES, hitLabHC, mps_fire::i, TFileService::kSharedResource, noGenParticle, noParent, noSimTrack, num_apd_hits_no_gen_particle, num_apd_hits_no_parent, num_apd_hits_no_simtrack, sourceLabel, AlCaHLTBitMon_QueryRunRegistry::string, tok_eb_, tok_ee_, tok_es_, tok_hc_, tok_tk_, tok_vtx_, total_num_apd_hits_seen, and totalHits.

◆ ~HitParentTest()

HitParentTest::~HitParentTest ( )
inlineoverride

Definition at line 39 of file HitParentTest.cc.

39 {}

Member Function Documentation

◆ analyze()

void HitParentTest::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotectedvirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 167 of file HitParentTest.cc.

167  {
168  edm::LogVerbatim("HitParentTest") << "HitParentTes::Run = " << e.id().run() << " Event = " << e.id().event();
169 
170  // get PCaloHits for ecal barrel
172  e.getByToken(tok_eb_, caloHitEB);
173 
174  // get PCaloHits for ecal endcap
176  e.getByToken(tok_ee_, caloHitEE);
177 
178  // get PCaloHits for preshower
180  e.getByToken(tok_es_, caloHitES);
181 
182  // get PCaloHits for hcal
184  e.getByToken(tok_hc_, caloHitHC);
185 
186  // get sim tracks
187  e.getByToken(tok_tk_, SimTk);
188 
189  // get sim vertices
190  e.getByToken(tok_vtx_, SimVtx);
191 
192  edm::LogVerbatim("HitParentTest") << "HitParentTest: hits valid[EB]: " << caloHitEB.isValid()
193  << " valid[EE]: " << caloHitEE.isValid() << " valid[ES]: " << caloHitES.isValid()
194  << " valid[HC]: " << caloHitHC.isValid();
195 
196  if (caloHitEB.isValid()) {
197  for (int depth = 1; depth <= 2; ++depth)
198  analyzeAPDHits(*caloHitEB, depth);
199  analyzeHits(*caloHitEB, 0);
200  }
201  if (caloHitEE.isValid())
202  analyzeHits(*caloHitEE, 1);
203  if (caloHitES.isValid())
204  analyzeHits(*caloHitES, 2);
205  if (caloHitHC.isValid())
206  analyzeHits(*caloHitHC, 3);
207 }

References analyzeAPDHits(), analyzeHits(), LEDCalibrationChannels::depth, MillePedeFileConverter_cfg::e, edm::HandleBase::isValid(), SimTk, SimVtx, tok_eb_, tok_ee_, tok_es_, tok_hc_, tok_tk_, and tok_vtx_.

◆ analyzeAPDHits()

void HitParentTest::analyzeAPDHits ( const std::vector< PCaloHit > &  hits,
int  depth 
)
private

Definition at line 334 of file HitParentTest.cc.

334  {
335  for (std::vector<PCaloHit>::const_iterator hit_it = hits.begin(); hit_it != hits.end(); ++hit_it) {
336  if (hit_it->depth() == depth) {
338 
339  // get the geant track id
340  int hit_geant_track_id = hit_it->geantTrackId();
341 
342  if (hit_geant_track_id <= 0) {
344  } else {
345  bool found = false;
346  // check whether this id is actually there in the list of simtracks
347  for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end() && !found;
348  ++simTrkItr) {
349  if (hit_geant_track_id == (int)(simTrkItr->trackId())) {
350  found = true;
351  bool match = validSimTrack(hit_geant_track_id, simTrkItr);
352 
353  edm::LogVerbatim("HitParentTest")
354  << "APDHIT Match = " << match << " hit_geant_track_id = " << hit_geant_track_id
355  << " particle id=" << simTrkItr->type();
356 
357  if (!match) {
358  edm::LogVerbatim("HitParentTest") << "NO MATCH FOUND !";
360  }
361 
362  int apd_pid = simTrkItr->type();
363  std::map<int, unsigned>::iterator count_it = particle_type_count.find(apd_pid);
364  if (count_it == particle_type_count.end())
365  // first occurence of this particle pid
366  particle_type_count[apd_pid] = 1;
367  else
368  ++count_it->second;
369 
370  //--------------------
371  // check where the oldest parent has its vertex. Should be close to the
372  // beam pipe...
373  math::XYZTLorentzVectorD oldest_parent_vertex = getOldestParentVertex(simTrkItr);
374 
375  edm::SimTrackContainer::const_iterator oldest_parent_track = parentSimTrack(simTrkItr);
376 
377  edm::LogVerbatim("HitParentTest")
378  << "APD hit pid = " << apd_pid << " APD hit track id = " << hit_geant_track_id
379  << " depth = " << hit_it->depth() << " OLDEST PARENT'S VERTEX: " << oldest_parent_vertex
380  << " rho = " << oldest_parent_vertex.Rho() << " OLDEST PARENT'S PID: " << oldest_parent_track->type()
381  << " OLDEST PARENT'S track id: " << oldest_parent_track->trackId() << "\n"
382  << "APD hit vertex index: " << simTrkItr->vertIndex() << " (tot #vertices: " << SimVtx->size() << ")"
383  << "\n"
384  << "APD hit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
385  << " present=" << simTrackPresent((*SimVtx)[simTrkItr->vertIndex()].parentIndex());
386 
387  } // a match was found
388  } // geant track id found in simtracks
389 
390  if (!found)
392  } // hits with a valid SimTrack Id
393  } // right depth index
394  } // loop over all calohits (of the given depth)
395 }

References LEDCalibrationChannels::depth, newFWLiteAna::found, getOldestParentVertex(), hfClusterShapes_cfi::hits, match(), num_apd_hits_no_gen_particle, num_apd_hits_no_parent, num_apd_hits_no_simtrack, parentSimTrack(), particle_type_count, SimTk, simTrackPresent(), SimVtx, total_num_apd_hits_seen, and validSimTrack().

Referenced by analyze().

◆ analyzeHits()

void HitParentTest::analyzeHits ( const std::vector< PCaloHit > &  hits,
int  type 
)
private

performs some checks on hits

Definition at line 264 of file HitParentTest.cc.

264  {
265  for (std::vector<PCaloHit>::const_iterator hit_it = hits.begin(); hit_it != hits.end(); ++hit_it) {
266  int id(type), flag(0);
267  if (type == 3) {
268  HcalDetId id_ = HcalDetId(hit_it->id());
269  int subdet = id_.subdet();
270  if (subdet == static_cast<int>(HcalEndcap))
271  id = type + 1;
272  else if (subdet == static_cast<int>(HcalOuter))
273  id = type + 2;
274  else if (subdet == static_cast<int>(HcalForward))
275  id = type + 3;
276  }
277  ++totalHits[id];
278 
279  // get the geant track id
280  int hit_geant_track_id = hit_it->geantTrackId();
281 
282  if (hit_geant_track_id <= 0) {
283  ++noParent[id];
284  flag = 1;
285  } else {
286  bool found = false;
287  flag = 2;
288  // check whether this id is actually there in the list of simtracks
289  for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end() && !found;
290  ++simTrkItr) {
291  if (hit_geant_track_id == (int)(simTrkItr->trackId())) {
292  found = true;
293  flag = 3;
294  bool match = validSimTrack(hit_geant_track_id, simTrkItr);
295 
296  edm::LogVerbatim("HitParentTest")
297  << "[" << detector[type] << "] Match = " << match << " hit_geant_track_id=" << hit_geant_track_id
298  << " particle id=" << simTrkItr->type();
299 
300  if (!match) {
301  edm::LogVerbatim("HitParentTest") << "NO MATCH FOUND !";
302  ++noGenParticle[id];
303  }
304 
305  // beam pipe...
306  int pid = simTrkItr->type();
307  math::XYZTLorentzVectorD oldest_parent_vertex = getOldestParentVertex(simTrkItr);
308 
309  edm::SimTrackContainer::const_iterator oldest_parent_track = parentSimTrack(simTrkItr);
310 
311  edm::LogVerbatim("HitParentTest")
312  << "[" << detector[type] << "] Hit pid = " << pid << " hit track id = " << hit_geant_track_id
313  << " Oldest Parent's Vertex: " << oldest_parent_vertex << " rho = " << oldest_parent_vertex.Rho()
314  << " Oldest Parent's pid: " << oldest_parent_track->type()
315  << " Oldest Parent's track id: " << oldest_parent_track->trackId()
316  << "\nHit vertex index: " << simTrkItr->vertIndex() << " (tot #vertices: " << SimVtx->size() << ")"
317  << "\nHit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex()
318  << " present=" << simTrackPresent((*SimVtx)[simTrkItr->vertIndex()].parentIndex());
319  if (histos) {
320  hitRho[id]->Fill(oldest_parent_vertex.Rho());
321  hitZ[id]->Fill(oldest_parent_vertex.Z());
322  }
323  } // a match was found
324  } // geant track id found in simtracks
325 
326  if (!found)
327  ++noSimTrack[id];
328  } // hits with a valid SimTrack Id
329  if (histos)
330  hitType[id]->Fill((double)(flag));
331  } // loop over all calohits (of the given depth)
332 }

References detector, RemoveAddSevLevel::flag, newFWLiteAna::found, getOldestParentVertex(), HcalEndcap, HcalForward, HcalOuter, histos, hitRho, hfClusterShapes_cfi::hits, hitType, hitZ, triggerObjects_cff::id, match(), noGenParticle, noParent, noSimTrack, parentSimTrack(), SimTk, simTrackPresent(), SimVtx, HcalDetId::subdet(), totalHits, and validSimTrack().

Referenced by analyze().

◆ beginJob()

void HitParentTest::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 139 of file HitParentTest.cc.

139  {
141  if (!tfile.isAvailable()) {
142  edm::LogVerbatim("HitParentTest") << "TFileService unavailable: no histograms";
143  histos = false;
144  } else {
145  char name[20], title[100];
146  histos = true;
147  for (unsigned int i = 0; i < 7; ++i) {
148  sprintf(name, "HitType%d", i);
149  sprintf(title, "Hit types for %s", detector[i].c_str());
150  hitType[i] = tfile->make<TH1F>(name, title, 10, 0., 10.);
151  hitType[i]->GetXaxis()->SetTitle(title);
152  hitType[i]->GetYaxis()->SetTitle("Hits");
153  sprintf(name, "RhoVertex%d", i);
154  sprintf(title, "#rho of the vertex for %s Hits", detector[i].c_str());
155  hitRho[i] = tfile->make<TH1F>(name, title, 10000, 0., 100.);
156  hitRho[i]->GetXaxis()->SetTitle(title);
157  hitRho[i]->GetYaxis()->SetTitle("Hits");
158  sprintf(name, "ZVertex%d", i);
159  sprintf(title, "z of the vertex for %s Hits", detector[i].c_str());
160  hitZ[i] = tfile->make<TH1F>(name, title, 2000, -100., 100.);
161  hitZ[i]->GetXaxis()->SetTitle(title);
162  hitZ[i]->GetYaxis()->SetTitle("Hits");
163  }
164  }
165 }

References detector, histos, hitRho, hitType, hitZ, mps_fire::i, Skims_PA_cff::name, compare::tfile, and overlapproblemtsosanalyzer_cfi::title.

◆ beginRun()

void HitParentTest::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprotected

Definition at line 44 of file HitParentTest.cc.

44 {}

◆ endJob()

void HitParentTest::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 221 of file HitParentTest.cc.

221  {
222  edm::LogVerbatim("HitParentTest") << "HitParentTest::Total number of APD hits seen: "
224  for (unsigned int depth = 0; depth < 2; ++depth) {
225  edm::LogVerbatim("HitParentTest") << "APD Hits in depth = " << depth + 1
226  << " Total = " << total_num_apd_hits_seen[depth];
227  edm::LogVerbatim("HitParentTest") << "summary of errors:\n"
228  << " number of APD hits with zero geant track id: "
229  << num_apd_hits_no_parent[depth] << "\n"
230  << "number of APD hits for which the parent simtrack was not found "
231  << "in the simtrack collection: " << num_apd_hits_no_simtrack[depth] << "\n"
232  << "number of APD hits for which no generator particle was "
233  << "found: " << num_apd_hits_no_gen_particle[depth] << "\n";
234  }
235 
236  for (unsigned int det = 0; det < 7; ++det) {
237  edm::LogVerbatim("HitParentTest") << "Total number of hits seen in " << detector[det] << ": " << totalHits[det];
238  edm::LogVerbatim("HitParentTest") << "summary of errors:\n"
239  << "number of hits with zero geant track id: " << noParent[det] << "\n"
240  << "number of hits for which the parent simtrack was not found in "
241  << "the simtrack collection: " << noSimTrack[det] << "\n"
242  << "number of hits for which no generator particle was found: "
243  << noGenParticle[det] << "\n";
244  }
245 
246  // sort in decreasing order of occurence
247  std::vector<int> sorted_pids;
248  for (std::map<int, unsigned>::const_iterator it = particle_type_count.begin(); it != particle_type_count.end(); ++it)
249  sorted_pids.push_back(it->first);
250 
251  // now sort the pids
252 
253  std::sort(sorted_pids.begin(), sorted_pids.end(), HitParentTestComparison(particle_type_count));
254 
255  edm::LogVerbatim("HitParentTest") << "HitParentTest::Frequency particle types through the APD "
256  << "(pid/frequency):";
257  for (unsigned i = 0; i < sorted_pids.size(); ++i) {
258  int pid = sorted_pids[i];
259  edm::LogVerbatim("HitParentTest") << " pid " << boost::format("%6d") % pid << ": count "
260  << boost::format("%6d") % particle_type_count[pid];
261  }
262 }

References LEDCalibrationChannels::depth, detector, dqm-mbProfile::format, mps_fire::i, noGenParticle, noParent, noSimTrack, num_apd_hits_no_gen_particle, num_apd_hits_no_parent, num_apd_hits_no_simtrack, particle_type_count, total_num_apd_hits_seen, and totalHits.

◆ endRun()

void HitParentTest::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprotected

Definition at line 46 of file HitParentTest.cc.

46 {}

◆ fillDescriptions()

void HitParentTest::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 128 of file HitParentTest.cc.

128  {
130  desc.addUntracked<std::string>("SourceLabel", "generatorSmeared");
131  desc.addUntracked<std::string>("ModuleLabel", "g4SimHits");
132  desc.addUntracked<std::string>("EBCollection", "EcalHitsEB");
133  desc.addUntracked<std::string>("EECollection", "EcalHitsEE");
134  desc.addUntracked<std::string>("ESCollection", "EcalHitsES");
135  desc.addUntracked<std::string>("HCCollection", "HcalHits");
136  descriptions.add("HitParentTest", desc);
137 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ getOldestParentVertex()

math::XYZTLorentzVectorD HitParentTest::getOldestParentVertex ( edm::SimTrackContainer::const_iterator  track)
private

Definition at line 405 of file HitParentTest.cc.

405  {
406  static const math::XYZTLorentzVectorD invalid_vertex(
407  10000, 10000, 10000, 10000); // default value if no valid vertex found
408 
409  edm::SimTrackContainer::const_iterator oldest_parent_track = parentSimTrack(track);
410 
411  int vertex_index = oldest_parent_track->vertIndex();
412 
413  // sanity checks
414  if (vertex_index < 0 || vertex_index >= (int)(SimVtx->size()))
415  return invalid_vertex;
416 
417  return (*SimVtx)[vertex_index].position();
418 }

References parentSimTrack(), SimVtx, and HLT_2018_cff::track.

Referenced by analyzeAPDHits(), and analyzeHits().

◆ parentSimTrack()

edm::SimTrackContainer::const_iterator HitParentTest::parentSimTrack ( edm::SimTrackContainer::const_iterator  thisTrkItr)
private

Definition at line 420 of file HitParentTest.cc.

420  {
421  edm::SimTrackContainer::const_iterator itr = SimTk->end();
422 
423  int vertIndex = thisTrkItr->vertIndex();
424  int type = thisTrkItr->type();
425  int charge = (int)thisTrkItr->charge();
426  edm::LogVerbatim("HitParentTest") << "SimTrackParent:: " << thisTrkItr->trackId() << " Vertex " << vertIndex
427  << " Type " << type << " Charge " << charge;
428 
429  if (vertIndex == -1)
430  return thisTrkItr;
431  else if (vertIndex >= (int)SimVtx->size())
432  return itr;
433 
434  edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
435  for (int iv = 0; iv < vertIndex; iv++)
436  simVtxItr++;
437  int parent = simVtxItr->parentIndex();
438 
439  if (parent < 0 && simVtxItr != SimVtx->begin()) {
440  const math::XYZTLorentzVectorD pos1 = simVtxItr->position();
441  for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) {
442  if (simVtxItr->parentIndex() > 0) {
443  const math::XYZTLorentzVectorD pos2 = pos1 - simVtxItr->position();
444  double dist = pos2.P();
445  if (dist < 0.001) {
446  parent = simVtxItr->parentIndex();
447  break;
448  }
449  }
450  }
451  }
452  for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
453  if ((int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr)
454  return parentSimTrack(simTrkItr);
455  }
456 
457  return thisTrkItr;
458 }

References begin, ALCARECOTkAlJpsiMuMu_cff::charge, createfilelist::int, class-composition::parent, SimTk, and SimVtx.

Referenced by analyzeAPDHits(), analyzeHits(), and getOldestParentVertex().

◆ simTrackPresent()

bool HitParentTest::simTrackPresent ( int  id)
private

Definition at line 397 of file HitParentTest.cc.

397  {
398  for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); ++simTrkItr) {
399  if ((int)(simTrkItr->trackId()) == id)
400  return true;
401  }
402  return false;
403 }

References SimTk.

Referenced by analyzeAPDHits(), and analyzeHits().

◆ validSimTrack()

bool HitParentTest::validSimTrack ( unsigned int  simTkId,
edm::SimTrackContainer::const_iterator  thisTrkItr 
)
private

Definition at line 460 of file HitParentTest.cc.

460  {
461  edm::LogVerbatim("HitParentTest") << "Inside validSimTrack: trackId " << thisTrkItr->trackId() << " vtxIndex "
462  << thisTrkItr->vertIndex() << " to be matched to " << simTkId;
463 
464  //This track originates from simTkId
465  if (thisTrkItr->trackId() == simTkId)
466  return true;
467 
468  //Otherwise trace back the history using SimTracks and SimVertices
469  int vertIndex = thisTrkItr->vertIndex();
470  if (vertIndex == -1 || vertIndex >= (int)SimVtx->size())
471  return false;
472  edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
473  for (int iv = 0; iv < vertIndex; iv++)
474  simVtxItr++;
475  int parent = simVtxItr->parentIndex();
476  edm::LogVerbatim("HitParentTest") << "validSimTrack:: parent index " << parent << " ";
477  if (parent < 0 && simVtxItr != SimVtx->begin()) {
478  const math::XYZTLorentzVectorD pos1 = simVtxItr->position();
479  for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) {
480  if (simVtxItr->parentIndex() > 0) {
481  const math::XYZTLorentzVectorD pos2 = pos1 - simVtxItr->position();
482  double dist = pos2.P();
483  if (dist < 0.001) {
484  parent = simVtxItr->parentIndex();
485  break;
486  }
487  }
488  }
489  }
490  edm::LogVerbatim("HitParentTest") << "HitParentTes::final index " << parent;
491  for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
492  if ((int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr)
493  return validSimTrack(simTkId, simTrkItr);
494  }
495 
496  return false;
497 }

References begin, class-composition::parent, SimTk, and SimVtx.

Referenced by analyzeAPDHits(), and analyzeHits().

Member Data Documentation

◆ detector

std::string HitParentTest::detector[7]
private

Definition at line 86 of file HitParentTest.cc.

Referenced by analyzeHits(), beginJob(), endJob(), and HitParentTest().

◆ g4Label

std::string HitParentTest::g4Label
private

Definition at line 60 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ histos

bool HitParentTest::histos
private

Definition at line 87 of file HitParentTest.cc.

Referenced by analyzeHits(), and beginJob().

◆ hitLabEB

std::string HitParentTest::hitLabEB
private

Definition at line 60 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ hitLabEE

std::string HitParentTest::hitLabEE
private

Definition at line 60 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ hitLabES

std::string HitParentTest::hitLabES
private

Definition at line 60 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ hitLabHC

std::string HitParentTest::hitLabHC
private

Definition at line 60 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ hitRho

TH1F * HitParentTest::hitRho[7]
private

Definition at line 90 of file HitParentTest.cc.

Referenced by analyzeHits(), and beginJob().

◆ hitType

TH1F* HitParentTest::hitType[7]
private

Definition at line 90 of file HitParentTest.cc.

Referenced by ntupleDataFormat._RecoHitAdaptor::_hits(), analyzeHits(), and beginJob().

◆ hitZ

TH1F * HitParentTest::hitZ[7]
private

Definition at line 90 of file HitParentTest.cc.

Referenced by analyzeHits(), and beginJob().

◆ noGenParticle

unsigned int HitParentTest::noGenParticle[7]
private

Definition at line 89 of file HitParentTest.cc.

Referenced by analyzeHits(), endJob(), and HitParentTest().

◆ noParent

unsigned int HitParentTest::noParent[7]
private

Definition at line 88 of file HitParentTest.cc.

Referenced by analyzeHits(), endJob(), and HitParentTest().

◆ noSimTrack

unsigned int HitParentTest::noSimTrack[7]
private

Definition at line 89 of file HitParentTest.cc.

Referenced by analyzeHits(), endJob(), and HitParentTest().

◆ num_apd_hits_no_gen_particle

unsigned int HitParentTest::num_apd_hits_no_gen_particle[2]
private

number of APD hits for which no generator particle was found

Definition at line 77 of file HitParentTest.cc.

Referenced by analyzeAPDHits(), endJob(), and HitParentTest().

◆ num_apd_hits_no_parent

unsigned int HitParentTest::num_apd_hits_no_parent[2]
private

Definition at line 70 of file HitParentTest.cc.

Referenced by analyzeAPDHits(), endJob(), and HitParentTest().

◆ num_apd_hits_no_simtrack

unsigned int HitParentTest::num_apd_hits_no_simtrack[2]
private

number of apd hits for which the parent sim track id was not found in the simtrack collection.

Definition at line 74 of file HitParentTest.cc.

Referenced by analyzeAPDHits(), endJob(), and HitParentTest().

◆ particle_type_count

std::map<int, unsigned> HitParentTest::particle_type_count
private

'histogram' of types of particles going through the APD. Maps from numeric particle code to the number of occurences.

Definition at line 84 of file HitParentTest.cc.

Referenced by analyzeAPDHits(), and endJob().

◆ SimTk

edm::Handle<edm::SimTrackContainer> HitParentTest::SimTk
private

◆ SimVtx

edm::Handle<edm::SimVertexContainer> HitParentTest::SimVtx
private

◆ sourceLabel

std::string HitParentTest::sourceLabel
private

Definition at line 60 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ tok_eb_

edm::EDGetTokenT<edm::PCaloHitContainer> HitParentTest::tok_eb_
private

Definition at line 61 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_ee_

edm::EDGetTokenT<edm::PCaloHitContainer> HitParentTest::tok_ee_
private

Definition at line 62 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_es_

edm::EDGetTokenT<edm::PCaloHitContainer> HitParentTest::tok_es_
private

Definition at line 63 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_hc_

edm::EDGetTokenT<edm::PCaloHitContainer> HitParentTest::tok_hc_
private

Definition at line 64 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_tk_

edm::EDGetTokenT<edm::SimTrackContainer> HitParentTest::tok_tk_
private

Definition at line 65 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_vtx_

edm::EDGetTokenT<edm::SimVertexContainer> HitParentTest::tok_vtx_
private

Definition at line 66 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ total_num_apd_hits_seen

unsigned int HitParentTest::total_num_apd_hits_seen[2]
private

error and other counters

Definition at line 69 of file HitParentTest.cc.

Referenced by analyzeAPDHits(), endJob(), and HitParentTest().

◆ totalHits

unsigned int HitParentTest::totalHits[7]
private

Definition at line 88 of file HitParentTest.cc.

Referenced by analyzeHits(), endJob(), and HitParentTest().

HitParentTest::detector
std::string detector[7]
Definition: HitParentTest.cc:86
HitParentTest::analyzeHits
void analyzeHits(const std::vector< PCaloHit > &, int type)
Definition: HitParentTest.cc:264
HitParentTest::hitZ
TH1F * hitZ[7]
Definition: HitParentTest.cc:90
HitParentTest::simTrackPresent
bool simTrackPresent(int id)
Definition: HitParentTest.cc:397
mps_fire.i
i
Definition: mps_fire.py:355
HitParentTest::SimVtx
edm::Handle< edm::SimVertexContainer > SimVtx
Definition: HitParentTest.cc:80
HitParentTest::tok_tk_
edm::EDGetTokenT< edm::SimTrackContainer > tok_tk_
Definition: HitParentTest.cc:65
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
HitParentTest::num_apd_hits_no_parent
unsigned int num_apd_hits_no_parent[2]
Definition: HitParentTest.cc:70
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HitParentTest::parentSimTrack
edm::SimTrackContainer::const_iterator parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr)
Definition: HitParentTest.cc:420
HitParentTest::noGenParticle
unsigned int noGenParticle[7]
Definition: HitParentTest.cc:89
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
HitParentTest::tok_hc_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hc_
Definition: HitParentTest.cc:64
HitParentTest::total_num_apd_hits_seen
unsigned int total_num_apd_hits_seen[2]
Definition: HitParentTest.cc:69
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
HitParentTest::tok_vtx_
edm::EDGetTokenT< edm::SimVertexContainer > tok_vtx_
Definition: HitParentTest.cc:66
HitParentTest::hitLabEB
std::string hitLabEB
Definition: HitParentTest.cc:60
HitParentTest::getOldestParentVertex
math::XYZTLorentzVectorD getOldestParentVertex(edm::SimTrackContainer::const_iterator track)
Definition: HitParentTest.cc:405
HitParentTest::hitRho
TH1F * hitRho[7]
Definition: HitParentTest.cc:90
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HitParentTest::hitType
TH1F * hitType[7]
Definition: HitParentTest.cc:90
HitParentTest::tok_ee_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_ee_
Definition: HitParentTest.cc:62
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
HitParentTest::hitLabEE
std::string hitLabEE
Definition: HitParentTest.cc:60
tfile
Definition: tfile.py:1
HcalOuter
Definition: HcalAssistant.h:35
HitParentTest::num_apd_hits_no_gen_particle
unsigned int num_apd_hits_no_gen_particle[2]
Definition: HitParentTest.cc:77
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
HitParentTest::histos
bool histos
Definition: HitParentTest.cc:87
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
HitParentTest::particle_type_count
std::map< int, unsigned > particle_type_count
Definition: HitParentTest.cc:84
HitParentTest::SimTk
edm::Handle< edm::SimTrackContainer > SimTk
Definition: HitParentTest.cc:79
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
HcalDetId::subdet
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
HcalDetId
Definition: HcalDetId.h:12
edm::Service< TFileService >
createfilelist.int
int
Definition: createfilelist.py:10
HitParentTest::g4Label
std::string g4Label
Definition: HitParentTest.cc:60
HitParentTest::analyzeAPDHits
void analyzeAPDHits(const std::vector< PCaloHit > &, int depth)
Definition: HitParentTest.cc:334
HitParentTest::tok_es_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_es_
Definition: HitParentTest.cc:63
edm::LogVerbatim
Definition: MessageLogger.h:297
HitParentTestComparison
Definition: HitParentTest.cc:210
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
HitParentTest::hitLabES
std::string hitLabES
Definition: HitParentTest.cc:60
HitParentTest::num_apd_hits_no_simtrack
unsigned int num_apd_hits_no_simtrack[2]
Definition: HitParentTest.cc:74
compare.tfile
tfile
Definition: compare.py:325
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
HitParentTest::noSimTrack
unsigned int noSimTrack[7]
Definition: HitParentTest.cc:89
HcalForward
Definition: HcalAssistant.h:36
HitParentTest::totalHits
unsigned int totalHits[7]
Definition: HitParentTest.cc:88
type
type
Definition: HCALResponse.h:21
HcalEndcap
Definition: HcalAssistant.h:34
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
HitParentTest::hitLabHC
std::string hitLabHC
Definition: HitParentTest.cc:60
HitParentTest::validSimTrack
bool validSimTrack(unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr)
Definition: HitParentTest.cc:460
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
HitParentTest::tok_eb_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_eb_
Definition: HitParentTest.cc:61
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
HitParentTest::sourceLabel
std::string sourceLabel
Definition: HitParentTest.cc:60
HitParentTest::noParent
unsigned int noParent[7]
Definition: HitParentTest.cc:88
class-composition.parent
parent
Definition: class-composition.py:88
edm::InputTag
Definition: InputTag.h:15
begin
#define begin
Definition: vmac.h:32
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37