All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Attributes | List of all members
truth::MCTruthEveIdCalculator Class Reference

#include <MCTruthEveIdCalculator.h>

Inheritance diagram for truth::MCTruthEveIdCalculator:
truth::MCTruthEmEveIdCalculator

Public Member Functions

 MCTruthEveIdCalculator ()
 Constructor and destructor. More...
 
virtual ~MCTruthEveIdCalculator ()
 
void Init (const MCTruthParticleList *list)
 Initialize this calculator for a particular ParticleList. More...
 
const MCTruthParticleListParticleList () const
 
int CalculateEveId (const int trackID)
 

Protected Member Functions

virtual int DoCalculateEveId (const int trackID)
 

Protected Attributes

const MCTruthParticleListm_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 89 of file MCTruthEveIdCalculator.h.

Member Typedef Documentation

typedef m_previousList_t::const_iterator truth::MCTruthEveIdCalculator::m_previousList_ptr
private

Definition at line 129 of file MCTruthEveIdCalculator.h.

typedef std::map< int, int > truth::MCTruthEveIdCalculator::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 128 of file MCTruthEveIdCalculator.h.

Constructor & Destructor Documentation

truth::MCTruthEveIdCalculator::MCTruthEveIdCalculator ( )

Constructor and destructor.

Definition at line 26 of file MCTruthEveIdCalculator.cxx.

27  {
28  }
truth::MCTruthEveIdCalculator::~MCTruthEveIdCalculator ( )
virtual

Definition at line 32 of file MCTruthEveIdCalculator.cxx.

33  {
34  }

Member Function Documentation

int truth::MCTruthEveIdCalculator::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 49 of file MCTruthEveIdCalculator.cxx.

50  {
51  // Look to see if the eve ID has been previously calculated for
52  // this track.
53  m_previousList_ptr search = m_previousList.find( trackID );
54  if ( search == m_previousList.end() ){
55  // It hasn't been calculated before. Do the full eve ID
56  // calculation.
57  int eveID = DoCalculateEveId( trackID );
58 
59  // Save the result of the calculation.
60  m_previousList[ trackID ] = eveID;
61 
62  return eveID;
63  }
64 
65  // If we get here, we've calculated the eve ID for this track
66  // before. Return that result.
67  return (*search).second;
68  }
virtual int DoCalculateEveId(const int trackID)
m_previousList_t::const_iterator m_previousList_ptr
int truth::MCTruthEveIdCalculator::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 truth::MCTruthEmEveIdCalculator.

Definition at line 71 of file MCTruthEveIdCalculator.cxx.

72  {
73  // This is the default eve ID calculation method. It gets called
74  // if the user doesn't override it with their own method.
75 
76  // Almost any eve ID calculation will use this: Get the entire
77  // history of the particle and its ancestors in the simulated
78  // event.
79  MCTruthParticleHistory particleHistory( m_particleList, trackID );
80 
81  if ( particleHistory.empty() ){
82  // Something went wrong; most likely the track ID isn't
83  // present in the event.
84  return 0;
85  }
86 
87  // Return the primary particle from the event generator associated
88  // with this track ID.
89  const simb::MCParticle* particle = particleHistory[0];
90  return particle->TrackId();
91  }
const MCTruthParticleList * m_particleList
void truth::MCTruthEveIdCalculator::Init ( const MCTruthParticleList list)

Initialize this calculator for a particular ParticleList.

Definition at line 38 of file MCTruthEveIdCalculator.cxx.

39  {
40  // Save the ParticleList associated with this simulated chain of
41  // particles.
43 
44  // Reset the results of previous calculations.
45  m_previousList.clear();
46  }
const MCTruthParticleList * m_particleList
list
Definition: file_to_url.sh:28
const MCTruthParticleList* truth::MCTruthEveIdCalculator::ParticleList ( ) const
inline

Accessor: For which ParticleList does this calculator generate results?

Definition at line 102 of file MCTruthEveIdCalculator.h.

102 { return m_particleList; }
const MCTruthParticleList * m_particleList

Member Data Documentation

const MCTruthParticleList* truth::MCTruthEveIdCalculator::m_particleList
protected

Definition at line 124 of file MCTruthEveIdCalculator.h.

m_previousList_t truth::MCTruthEveIdCalculator::m_previousList
private

Definition at line 130 of file MCTruthEveIdCalculator.h.


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