LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
sim::EveIdCalculator Class Reference

#include "EveIdCalculator.h"

Inheritance diagram for sim::EveIdCalculator:
sim::EmEveIdCalculator

Public Member Functions

 EveIdCalculator ()
 Constructor and destructor. More...
 
virtual ~EveIdCalculator ()
 
void Init (const sim::ParticleList *list)
 Initialize this calculator for a particular ParticleList. More...
 
const sim::ParticleListParticleList () const
 
int CalculateEveId (const int trackID)
 

Protected Member Functions

virtual int DoCalculateEveId (const int trackID)
 

Protected Attributes

const sim::ParticleListm_particleList
 

Private Types

typedef std::map< int, int > m_previousList_t
 

The ParticleList associated with the eve ID calculation.

More...
 
typedef m_previousList_t::const_iterator m_previousList_ptr
 

Private Attributes

m_previousList_t m_previousList
 

Detailed Description

Definition at line 83 of file EveIdCalculator.h.

Member Typedef Documentation

typedef std::map< int, int > sim::EveIdCalculator::m_previousList_t
private

The ParticleList associated with the eve ID calculation.

Keep track of the previous eve IDs for the current ParticleList.

Definition at line 122 of file EveIdCalculator.h.

Constructor & Destructor Documentation

sim::EveIdCalculator::EveIdCalculator ( )

Constructor and destructor.

Definition at line 19 of file EveIdCalculator.cxx.

20  {
21  }
sim::EveIdCalculator::~EveIdCalculator ( )
virtual

Definition at line 25 of file EveIdCalculator.cxx.

26  {
27  }

Member Function Documentation

int sim::EveIdCalculator::CalculateEveId ( const int  trackID)

The main eve ID calculation method. This is the reason why we use the Template Method for this class: because no matter what the core eve ID calculation is, we want to perform the following an additional task: The eve ID calculation can be lengthy. If the user is going through a LArVoxelList and trying to figuring out the eve ID associated with each voxel, this routine may be called many times. To save on time, keep the results of previous eve ID calculations for the current particle list. Only do the complete eve ID calculation if we haven't done it already for a given track ID.

Definition at line 42 of file EveIdCalculator.cxx.

References DoCalculateEveId(), and m_previousList.

Referenced by ParticleList().

43  {
44  // Look to see if the eve ID has been previously calculated for
45  // this track.
46  m_previousList_ptr search = m_previousList.find( trackID );
47  if ( search == m_previousList.end() ){
48  // It hasn't been calculated before. Do the full eve ID
49  // calculation.
50  int eveID = DoCalculateEveId( trackID );
51 
52  // Save the result of the calculation.
53  m_previousList[ trackID ] = eveID;
54 
55  return eveID;
56  }
57 
58  // If we get here, we've calculated the eve ID for this track
59  // before. Return that result.
60  return (*search).second;
61  }
m_previousList_t::const_iterator m_previousList_ptr
virtual int DoCalculateEveId(const int trackID)
m_previousList_t m_previousList
int sim::EveIdCalculator::DoCalculateEveId ( const int  trackID)
protectedvirtual

This is the core method to calculate the eve ID. If another class is going to override the default calculation, this the method that must be implemented.

Reimplemented in sim::EmEveIdCalculator.

Definition at line 64 of file EveIdCalculator.cxx.

References m_particleList, and simb::MCParticle::TrackId().

Referenced by CalculateEveId(), and ParticleList().

65  {
66  // This is the default eve ID calculation method. It gets called
67  // if the user doesn't override it with their own method.
68 
69  // Almost any eve ID calculation will use this: Get the entire
70  // history of the particle and its ancestors in the simulated
71  // event.
72  ParticleHistory particleHistory( m_particleList, trackID );
73 
74  if ( particleHistory.empty() ){
75  // Something went wrong; most likely the track ID isn't
76  // present in the event.
77  return 0;
78  }
79 
80  // Return the primary particle from the event generator associated
81  // with this track ID.
82  const simb::MCParticle* particle = particleHistory[0];
83  return particle->TrackId();
84  }
const sim::ParticleList * m_particleList
int TrackId() const
Definition: MCParticle.h:211
void sim::EveIdCalculator::Init ( const sim::ParticleList list)

Initialize this calculator for a particular ParticleList.

Definition at line 31 of file EveIdCalculator.cxx.

References m_particleList, and m_previousList.

32  {
33  // Save the ParticleList associated with this simulated chain of
34  // particles.
35  m_particleList = list;
36 
37  // Reset the results of previous calculations.
38  m_previousList.clear();
39  }
const sim::ParticleList * m_particleList
m_previousList_t m_previousList
const sim::ParticleList* sim::EveIdCalculator::ParticleList ( ) const
inline

Accessor: For which ParticleList does this calculator generate results?

Definition at line 96 of file EveIdCalculator.h.

References CalculateEveId(), DoCalculateEveId(), and m_particleList.

96 { return m_particleList; }
const sim::ParticleList * m_particleList

Member Data Documentation

const sim::ParticleList* sim::EveIdCalculator::m_particleList
protected
m_previousList_t sim::EveIdCalculator::m_previousList
private

Definition at line 124 of file EveIdCalculator.h.

Referenced by CalculateEveId(), and Init().


The documentation for this class was generated from the following files: