Particle list in DetSim contains Monte Carlo particle information. More...
#include "nusimdata/SimulationBase/MCParticle.h"
#include <memory>
#include <ostream>
#include <map>
#include <cstdlib>
Go to the source code of this file.
Classes | |
class | truth::MCTruthParticleList |
struct | truth::MCTruthParticleList::archived_info_type |
Namespaces | |
truth | |
Monte Carlo Simulation. | |
Particle list in DetSim contains Monte Carlo particle information.
*** This class has been lifted from nutools and modified so that it *** does NOT take ownwership of the MCParticles that are added to it *** so we can avoid duplicating them
A container for particles generated during an event simulation. It acts like a map<int,Particle*> but with additional features:
Methods to access the list of primary particles in the event: truth::MCTruthParticleList MCTruthParticleList = // ...; int numberOfPrimaries = MCTruthParticleList->NumberOfPrimaries(); for ( int i = 0; i != numberOfPrimaries; ++i ) { simb::MCParticle* particle = MCTruthParticleList->Primary(i); ... } There's also a simple test: int trackID = // ...; if ( MCTruthParticleList->IsPrimary(trackID) ) {...}
(Aside: note that MCTruthParticleList[i] does NOT give you the "i-th" particle in the list; it gives you the particle whose trackID is "i".) Also this form becomes unacceptably inefficient when looping over all the particles in a crowded event: prefer to do a bit more of typing as: truth::MCTruthParticleList* MCTruthParticleList = // ...; for ( const auto& i: MCTruthParticleList) { int trackID = i.first; if (!MCTruthParticleList->IsPrimary(trackID)) continue; const simb::MCParticle primary = i.second; // ... }
Definition in file MCTruthParticleList.h.