LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
EveIdCalculator.cxx
Go to the documentation of this file.
1
9
#include "
nug4/ParticleNavigation/EveIdCalculator.h
"
10
#include "
nug4/ParticleNavigation/ParticleList.h
"
11
#include "
nug4/ParticleNavigation/ParticleHistory.h
"
12
#include "
nusimdata/SimulationBase/MCParticle.h
"
13
14
namespace
sim
{
15
16
//----------------------------------------------------------------------------
17
// Constructor. Keep this empty, since users who override with their
18
// class may forget to call this constructor.
19
EveIdCalculator::EveIdCalculator
()
20
{
21
}
22
23
//----------------------------------------------------------------------------
24
// Destructor.
25
EveIdCalculator::~EveIdCalculator
()
26
{
27
}
28
29
//----------------------------------------------------------------------------
30
// Initialization.
31
void
EveIdCalculator::Init
(
const
sim::ParticleList
* list )
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
}
40
41
//----------------------------------------------------------------------------
42
int
EveIdCalculator::CalculateEveId
(
const
int
trackID )
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
}
62
63
//----------------------------------------------------------------------------
64
int
EveIdCalculator::DoCalculateEveId
(
const
int
trackID )
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
}
85
86
}
sim::EveIdCalculator::m_particleList
const sim::ParticleList * m_particleList
Definition:
EveIdCalculator.h:118
sim::EveIdCalculator::m_previousList_ptr
m_previousList_t::const_iterator m_previousList_ptr
Definition:
EveIdCalculator.h:123
sim::EveIdCalculator::DoCalculateEveId
virtual int DoCalculateEveId(const int trackID)
Definition:
EveIdCalculator.cxx:64
simb::MCParticle
Definition:
MCParticle.h:24
MCParticle.h
Particle class.
sim::EveIdCalculator::m_previousList
m_previousList_t m_previousList
Definition:
EveIdCalculator.h:124
simb::MCParticle::TrackId
int TrackId() const
Definition:
MCParticle.h:211
sim::EveIdCalculator::CalculateEveId
int CalculateEveId(const int trackID)
Definition:
EveIdCalculator.cxx:42
sim
Monte Carlo Simulation.
Definition:
FlashHypothesisCreator.h:21
EveIdCalculator.h
Interface for calculating the "ultimate mother" of a particle in a simulated event.
sim::EveIdCalculator::Init
void Init(const sim::ParticleList *list)
Initialize this calculator for a particular ParticleList.
Definition:
EveIdCalculator.cxx:31
sim::EveIdCalculator::EveIdCalculator
EveIdCalculator()
Constructor and destructor.
Definition:
EveIdCalculator.cxx:19
sim::EveIdCalculator::~EveIdCalculator
virtual ~EveIdCalculator()
Definition:
EveIdCalculator.cxx:25
ParticleHistory.h
A "chain" of particles associated with production of a Particle in a ParticleList.
sim::ParticleHistory
Definition:
ParticleHistory.h:98
ParticleList.h
Particle list in DetSim contains Monte Carlo particle information.
sim::ParticleList
Definition:
ParticleList.h:122
nug4
ParticleNavigation
EveIdCalculator.cxx
Generated on Thu May 2 2024 20:59:53 for LArSoft by
1.8.11