Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
srcs
icarusalg
icarusalg
gallery
MCTruthBase
MCTruthEveIdCalculator.cxx
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
///
3
/// ********************************************************************
4
/// *** This class has been lifted from nutools and modified so that it
5
/// *** does NOT take ownwership of the MCParticles that are added to it
6
/// *** so we can avoid duplicating them
7
/// ********************************************************************
8
///
9
/// \file MCTruthEveIdCalculator.cxx
10
/// \brief Interface for calculating the "ultimate mother" of a particle in a simulated event.
11
///
12
/// \version $Id: MCTruthEveIdCalculator.cxx,v 1.1 2010/05/13 16:12:20 seligman Exp $
13
/// \author seligman@nevis.columbia.edu
14
////////////////////////////////////////////////////////////////////////
15
16
#include "
icarusalg/gallery/MCTruthBase/MCTruthEveIdCalculator.h
"
17
#include "
icarusalg/gallery/MCTruthBase/MCTruthParticleList.h
"
18
#include "
icarusalg/gallery/MCTruthBase/MCTruthParticleHistory.h
"
19
#include "nusimdata/SimulationBase/MCParticle.h"
20
21
namespace
truth {
22
23
//----------------------------------------------------------------------------
24
// Constructor. Keep this empty, since users who override with their
25
// class may forget to call this constructor.
26
MCTruthEveIdCalculator::MCTruthEveIdCalculator
()
27
{
28
}
29
30
//----------------------------------------------------------------------------
31
// Destructor.
32
MCTruthEveIdCalculator::~MCTruthEveIdCalculator
()
33
{
34
}
35
36
//----------------------------------------------------------------------------
37
// Initialization.
38
void
MCTruthEveIdCalculator::Init
(
const
MCTruthParticleList
*
list
)
39
{
40
// Save the ParticleList associated with this simulated chain of
41
// particles.
42
m_particleList
=
list
;
43
44
// Reset the results of previous calculations.
45
m_previousList
.clear();
46
}
47
48
//----------------------------------------------------------------------------
49
int
MCTruthEveIdCalculator::CalculateEveId
(
const
int
trackID )
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
}
69
70
//----------------------------------------------------------------------------
71
int
MCTruthEveIdCalculator::DoCalculateEveId
(
const
int
trackID )
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
}
92
93
}
truth::MCTruthEveIdCalculator::~MCTruthEveIdCalculator
virtual ~MCTruthEveIdCalculator()
Definition:
MCTruthEveIdCalculator.cxx:32
MCTruthParticleList.h
Particle list in DetSim contains Monte Carlo particle information.
truth::MCTruthEveIdCalculator::DoCalculateEveId
virtual int DoCalculateEveId(const int trackID)
Definition:
MCTruthEveIdCalculator.cxx:71
truth::MCTruthEveIdCalculator::MCTruthEveIdCalculator
MCTruthEveIdCalculator()
Constructor and destructor.
Definition:
MCTruthEveIdCalculator.cxx:26
MCTruthEveIdCalculator.h
Interface for calculating the "ultimate mother" of a particle in a simulated event.
truth::MCTruthEveIdCalculator::Init
void Init(const MCTruthParticleList *list)
Initialize this calculator for a particular ParticleList.
Definition:
MCTruthEveIdCalculator.cxx:38
truth::MCTruthParticleHistory
Definition:
MCTruthParticleHistory.h:97
MCTruthParticleHistory.h
A "chain" of particles associated with production of a Particle in a ParticleList.
truth::MCTruthEveIdCalculator::CalculateEveId
int CalculateEveId(const int trackID)
Definition:
MCTruthEveIdCalculator.cxx:49
truth::MCTruthEveIdCalculator::m_previousList_ptr
m_previousList_t::const_iterator m_previousList_ptr
Definition:
MCTruthEveIdCalculator.h:129
truth::MCTruthParticleList
Definition:
MCTruthParticleList.h:128
truth::MCTruthEveIdCalculator::m_particleList
const MCTruthParticleList * m_particleList
Definition:
MCTruthEveIdCalculator.h:124
truth::MCTruthEveIdCalculator::m_previousList
m_previousList_t m_previousList
Definition:
MCTruthEveIdCalculator.h:130
list
list
Definition:
file_to_url.sh:28
Generated by
1.8.5