LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
sim::EmEveIdCalculator Class Reference

#include "EmEveIdCalculator.h"

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

Public Member Functions

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

Protected Attributes

const sim::ParticleListm_particleList
 

Private Member Functions

virtual int DoCalculateEveId (const int trackID)
 

Detailed Description

Definition at line 63 of file EmEveIdCalculator.h.

Constructor & Destructor Documentation

sim::EmEveIdCalculator::EmEveIdCalculator ( )
inline

Definition at line 67 of file EmEveIdCalculator.h.

68  : EveIdCalculator() // Make sure the parent class constructor is called
69  {}
EveIdCalculator()
Constructor and destructor.
virtual sim::EmEveIdCalculator::~EmEveIdCalculator ( )
inlinevirtual

Definition at line 70 of file EmEveIdCalculator.h.

References DoCalculateEveId().

70 {}

Member Function Documentation

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

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 sim::EveIdCalculator::DoCalculateEveId(), and sim::EveIdCalculator::m_previousList.

Referenced by sim::EveIdCalculator::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::EmEveIdCalculator::DoCalculateEveId ( const int  trackID)
privatevirtual

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 from sim::EveIdCalculator.

Definition at line 22 of file EmEveIdCalculator.cxx.

References sim::EveIdCalculator::m_particleList.

Referenced by ~EmEveIdCalculator().

23  {
24  // Almost any eve ID calculation will use this: Get the entire
25  // history of the particle and its ancestors in the simulated
26  // event. (m_particleList is defined in EveIdCalculator.h)
27  const sim::ParticleHistory particleHistory( m_particleList, trackID );
28 
29  // You can treat particleHistory like an array, and do something
30  // like:
31 
32  // for ( int i = particleHistory.size(); i >= 0; --i )
33  // { const simb::MCParticle* particle = particleHistory[i]; ... }
34 
35  // But we know how to use the Standard Template Library (Yes, you
36  // do! Don't doubt yourself!) so let's treat particleHistory in
37  // the most efficient manner, as an STL container. We want to scan
38  // the container from its last element to its first, from the base
39  // of the particle production chain towards the primary particle.
40 
41  for(auto i = particleHistory.rbegin(); i != particleHistory.rend(); ++i){
42  // Get the text string that describes the process that created
43  // the particle.
44  std::string process = (*i)->Process();
45 
46  // Skip it if it was created by pair production, compton
47  // scattering, photoelectric effect, bremstrahlung,
48  // annihilation, or any ionization. (The ultimate source of
49  // the process names are the physics lists used in Geant4.)
50 
51  if ( process.find("conv") != std::string::npos ||
52  process.find("LowEnConversion") != std::string::npos ||
53  process.find("Pair") != std::string::npos ||
54  process.find("compt") != std::string::npos ||
55  process.find("Compt") != std::string::npos ||
56  process.find("Brem") != std::string::npos ||
57  process.find("phot") != std::string::npos ||
58  process.find("Photo") != std::string::npos ||
59  process.find("Ion") != std::string::npos ||
60  process.find("annihil") != std::string::npos) continue;
61 
62  // If we get here, the particle wasn't created by any of the
63  // above processes. Return its ID.
64  return (*i)->TrackId();
65  }
66 
67  // If we get here, we've skipped every particle in the
68  // chain. Perhaps it was empty.
69  return 0;
70  }
const sim::ParticleList * m_particleList
void sim::EveIdCalculator::Init ( const sim::ParticleList list)
inherited

Initialize this calculator for a particular ParticleList.

Definition at line 31 of file EveIdCalculator.cxx.

References sim::EveIdCalculator::m_particleList, and sim::EveIdCalculator::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
inlineinherited

Accessor: For which ParticleList does this calculator generate results?

Definition at line 96 of file EveIdCalculator.h.

References sim::EveIdCalculator::CalculateEveId(), sim::EveIdCalculator::DoCalculateEveId(), and sim::EveIdCalculator::m_particleList.

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

Member Data Documentation

const sim::ParticleList* sim::EveIdCalculator::m_particleList
protectedinherited

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