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
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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 31 of file HitParentTest.cc.

Constructor & Destructor Documentation

◆ HitParentTest()

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

Definition at line 88 of file HitParentTest.cc.

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

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 34 of file HitParentTest.cc.

34 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 162 of file HitParentTest.cc.

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

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 329 of file HitParentTest.cc.

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

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 259 of file HitParentTest.cc.

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

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 134 of file HitParentTest.cc.

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

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

◆ beginRun()

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

Definition at line 39 of file HitParentTest.cc.

39 {}

◆ endJob()

void HitParentTest::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 216 of file HitParentTest.cc.

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

References LEDCalibrationChannels::depth, detector, 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, jetUpdater_cfi::sort, total_num_apd_hits_seen, and totalHits.

◆ endRun()

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

Definition at line 41 of file HitParentTest.cc.

41 {}

◆ fillDescriptions()

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

Definition at line 123 of file HitParentTest.cc.

123  {
125  desc.addUntracked<std::string>("SourceLabel", "generatorSmeared");
126  desc.addUntracked<std::string>("ModuleLabel", "g4SimHits");
127  desc.addUntracked<std::string>("EBCollection", "EcalHitsEB");
128  desc.addUntracked<std::string>("EECollection", "EcalHitsEE");
129  desc.addUntracked<std::string>("ESCollection", "EcalHitsES");
130  desc.addUntracked<std::string>("HCCollection", "HcalHits");
131  descriptions.add("HitParentTest", desc);
132 }

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ getOldestParentVertex()

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

Definition at line 400 of file HitParentTest.cc.

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

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

Referenced by analyzeAPDHits(), and analyzeHits().

◆ parentSimTrack()

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

Definition at line 415 of file HitParentTest.cc.

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

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

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

◆ simTrackPresent()

bool HitParentTest::simTrackPresent ( int  id)
private

Definition at line 392 of file HitParentTest.cc.

392  {
393  for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); ++simTrkItr) {
394  if ((int)(simTrkItr->trackId()) == id)
395  return true;
396  }
397  return false;
398 }

References SimTk.

Referenced by analyzeAPDHits(), and analyzeHits().

◆ validSimTrack()

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

Definition at line 455 of file HitParentTest.cc.

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

References gpuVertexFinder::iv, class-composition::parent, SimTk, and SimVtx.

Referenced by analyzeAPDHits(), and analyzeHits().

Member Data Documentation

◆ detector

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

Definition at line 81 of file HitParentTest.cc.

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

◆ g4Label

std::string HitParentTest::g4Label
private

Definition at line 55 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ histos

bool HitParentTest::histos
private

Definition at line 82 of file HitParentTest.cc.

Referenced by analyzeHits(), and beginJob().

◆ hitLabEB

std::string HitParentTest::hitLabEB
private

Definition at line 55 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ hitLabEE

std::string HitParentTest::hitLabEE
private

Definition at line 55 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ hitLabES

std::string HitParentTest::hitLabES
private

Definition at line 55 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ hitLabHC

std::string HitParentTest::hitLabHC
private

Definition at line 55 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ hitRho

TH1F * HitParentTest::hitRho[7]
private

Definition at line 85 of file HitParentTest.cc.

Referenced by analyzeHits(), and beginJob().

◆ hitType

TH1F* HitParentTest::hitType[7]
private

Definition at line 85 of file HitParentTest.cc.

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

◆ hitZ

TH1F * HitParentTest::hitZ[7]
private

Definition at line 85 of file HitParentTest.cc.

Referenced by analyzeHits(), and beginJob().

◆ noGenParticle

unsigned int HitParentTest::noGenParticle[7]
private

Definition at line 84 of file HitParentTest.cc.

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

◆ noParent

unsigned int HitParentTest::noParent[7]
private

Definition at line 83 of file HitParentTest.cc.

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

◆ noSimTrack

unsigned int HitParentTest::noSimTrack[7]
private

Definition at line 84 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 72 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 65 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 69 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 79 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 55 of file HitParentTest.cc.

Referenced by HitParentTest().

◆ tok_eb_

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

Definition at line 56 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_ee_

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

Definition at line 57 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_es_

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

Definition at line 58 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_hc_

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

Definition at line 59 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_tk_

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

Definition at line 60 of file HitParentTest.cc.

Referenced by analyze(), and HitParentTest().

◆ tok_vtx_

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

Definition at line 61 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 64 of file HitParentTest.cc.

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

◆ totalHits

unsigned int HitParentTest::totalHits[7]
private

Definition at line 83 of file HitParentTest.cc.

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

HitParentTest::detector
std::string detector[7]
Definition: HitParentTest.cc:81
HitParentTest::analyzeHits
void analyzeHits(const std::vector< PCaloHit > &, int type)
Definition: HitParentTest.cc:259
HitParentTest::hitZ
TH1F * hitZ[7]
Definition: HitParentTest.cc:85
HitParentTest::simTrackPresent
bool simTrackPresent(int id)
Definition: HitParentTest.cc:392
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
HitParentTest::SimVtx
edm::Handle< edm::SimVertexContainer > SimVtx
Definition: HitParentTest.cc:75
HitParentTest::tok_tk_
edm::EDGetTokenT< edm::SimTrackContainer > tok_tk_
Definition: HitParentTest.cc:60
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:65
gpuVertexFinder::iv
int32_t *__restrict__ iv
Definition: gpuClusterTracksDBSCAN.h:42
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:415
HitParentTest::noGenParticle
unsigned int noGenParticle[7]
Definition: HitParentTest.cc:84
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
HitParentTest::tok_hc_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hc_
Definition: HitParentTest.cc:59
HitParentTest::total_num_apd_hits_seen
unsigned int total_num_apd_hits_seen[2]
Definition: HitParentTest.cc:64
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:61
HitParentTest::hitLabEB
std::string hitLabEB
Definition: HitParentTest.cc:55
HitParentTest::getOldestParentVertex
math::XYZTLorentzVectorD getOldestParentVertex(edm::SimTrackContainer::const_iterator track)
Definition: HitParentTest.cc:400
HitParentTest::hitRho
TH1F * hitRho[7]
Definition: HitParentTest.cc:85
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HitParentTest::hitType
TH1F * hitType[7]
Definition: HitParentTest.cc:85
HitParentTest::tok_ee_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_ee_
Definition: HitParentTest.cc:57
HitParentTest::hitLabEE
std::string hitLabEE
Definition: HitParentTest.cc:55
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:72
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
HitParentTest::histos
bool histos
Definition: HitParentTest.cc:82
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
HitParentTest::particle_type_count
std::map< int, unsigned > particle_type_count
Definition: HitParentTest.cc:79
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
HitParentTest::SimTk
edm::Handle< edm::SimTrackContainer > SimTk
Definition: HitParentTest.cc:74
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:55
HitParentTest::analyzeAPDHits
void analyzeAPDHits(const std::vector< PCaloHit > &, int depth)
Definition: HitParentTest.cc:329
HitParentTest::tok_es_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_es_
Definition: HitParentTest.cc:58
HitParentTestComparison
Definition: HitParentTest.cc:205
HitParentTest::hitLabES
std::string hitLabES
Definition: HitParentTest.cc:55
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HitParentTest::num_apd_hits_no_simtrack
unsigned int num_apd_hits_no_simtrack[2]
Definition: HitParentTest.cc:69
compare.tfile
tfile
Definition: compare.py:324
HitParentTest::noSimTrack
unsigned int noSimTrack[7]
Definition: HitParentTest.cc:84
HcalForward
Definition: HcalAssistant.h:36
HitParentTest::totalHits
unsigned int totalHits[7]
Definition: HitParentTest.cc:83
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
HcalEndcap
Definition: HcalAssistant.h:34
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
HitParentTest::hitLabHC
std::string hitLabHC
Definition: HitParentTest.cc:55
HitParentTest::validSimTrack
bool validSimTrack(unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr)
Definition: HitParentTest.cc:455
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HitParentTest::tok_eb_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_eb_
Definition: HitParentTest.cc:56
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
HitParentTest::sourceLabel
std::string sourceLabel
Definition: HitParentTest.cc:55
HitParentTest::noParent
unsigned int noParent[7]
Definition: HitParentTest.cc:83
class-composition.parent
parent
Definition: class-composition.py:98
edm::InputTag
Definition: InputTag.h:15
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37