EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EGS_ParticleTrackContainer Class Reference

A class that stores all the tracks in a simulation. More...

#include <egs_particle_track.h>

Public Member Functions

 EGS_ParticleTrackContainer ()
 Basic Constructor. Initializes all variables.
 
 EGS_ParticleTrackContainer (const char *fname, int buf_size)
 Constructor. More...
 
 ~EGS_ParticleTrackContainer ()
 The Destructor. Deallocate all allocated memory.
 
void setEvents (int e)
 Save the number of events (for example, decays) tracked so far.
 
int getEvents ()
 Get the number of events tracked so far.
 
int getCurrentNumVertices ()
 Get the number of vertices in the track currently being scorred.
 
void addVertex (EGS_ParticleTrack::Vertex *x)
 Add a vertex to the track currently being scorred.
 
void addVertex (int stackIndex, EGS_ParticleTrack::Vertex *x)
 Add a vertex to the track mapped by the internal stack. More...
 
EGS_ParticleTrack::VertexgetTrackVertex (int tr, int v)
 Get the v vertex from the tr track. More...
 
bool isScoringParticle ()
 Are we still scoring the current particle?
 
bool isScoringParticle (int stackIndex)
 Are we still scoring the particle mapped by the stack?
 
void stopScoringParticle ()
 Stop scoring the current particle.
 
void stopScoringParticle (int stackIndex)
 Stop scoring the particle mapped by the stack.
 
void startNewTrack ()
 Start scoring a new track.
 
void startNewTrack (int stackIndex)
 Start scoring a new track and map it on the stack. More...
 
void startNewTrack (EGS_ParticleTrack::ParticleInfo *p)
 Start scoring a new track from a particle of type p .
 
void setParticleInfo (int stackIndex, EGS_ParticleTrack::ParticleInfo *p)
 Set the type of mapped particle to p .
 
void setCurrentParticleInfo (EGS_ParticleTrack::ParticleInfo *p)
 Set the type of the currently tracked particle to p .
 
int readDataFile (const char *filename)
 Load particle data from the file called filename .
 
void reportResults (bool with_header=true)
 Report results from the track scoring process so far. More...
 

Protected Member Functions

void flushBuffer ()
 Write all track data to the file. More...
 
void updateHeader ()
 Update the output file's header. More...
 

Protected Attributes

int m_nEvents
 number of events scored
 
int m_nTracks
 number of tracks currently in memory
 
int m_totalTracks
 total number of tracks registered
 
int * m_stackMap
 
bool * m_isScoring
 
int m_bufferSize
 max number of tracks in memory
 
EGS_ParticleTrack ** m_buffer
 the tracks array
 
ofstream * m_trspFile
 the file to which data is output
 
string m_trspFilename
 filename of output file
 

Detailed Description

A class that stores all the tracks in a simulation.

The EGS_ParticleTrackContainer class represents the place where the user should store everything related to particle tracks (i.e. number of events scored, type of the tracked particles, trajectories, etc.). This information can be saved in a separate file and later used for visualization of the simulated particles.

Definition at line 168 of file egs_particle_track.h.

Constructor & Destructor Documentation

EGS_ParticleTrackContainer::EGS_ParticleTrackContainer ( const char *  fname,
int  buf_size 
)

Constructor.

Prepares data to be written in a 'track space file' file called fname . Sets the m_bufferSize property of the class equal to buf_size which defines how many tracks the container will store before flushing them to the output file.

Definition at line 184 of file egs_particle_track.h.

Member Function Documentation

void EGS_ParticleTrackContainer::addVertex ( int  stackIndex,
EGS_ParticleTrack::Vertex x 
)

Add a vertex to the track mapped by the internal stack.

The stackIndex tells the position of the desired track in the stack. This way, by passing different stackIndex arguments, multiple tracks could be tracked at once.

Definition at line 189 of file egs_particle_track.cpp.

References EGS_ParticleTrack::addVertex(), m_buffer, m_isScoring, and m_stackMap.

EGS_ParticleTrack::Vertex * EGS_ParticleTrackContainer::getTrackVertex ( int  tr,
int  v 
)

Get the v vertex from the tr track.

Todo:
Have to test this method.

Definition at line 175 of file egs_particle_track.cpp.

References m_buffer, and m_nTracks.

void EGS_ParticleTrackContainer::startNewTrack ( int  stackIndex)

Start scoring a new track and map it on the stack.

This method allows mapping different particles with different integers. This way, the track being mapped to stackIndex can be further referenced by the same integer stackIndex , which would allow the tracking of multiple tracks at once.

Definition at line 115 of file egs_particle_track.cpp.

References flushBuffer(), m_bufferSize, m_isScoring, m_nTracks, and m_stackMap.

void EGS_ParticleTrackContainer::reportResults ( bool  with_header = true)

Report results from the track scoring process so far.

Todo:
Maybe this method should be virtual ?

Definition at line 237 of file egs_particle_track.cpp.

References egsInformation, egsWarning, flushBuffer(), m_bufferSize, m_isScoring, m_nEvents, m_totalTracks, and m_trspFilename.

void EGS_ParticleTrackContainer::flushBuffer ( )
protected

Write all track data to the file.

If no file is open for writing, tracks are just discarded. Only tracks that are not being scored any more are discarded! Others remain in memory for further scoring.

Definition at line 135 of file egs_particle_track.cpp.

References EGS_ParticleTrack::clearTrack(), m_buffer, m_bufferSize, m_isScoring, m_nTracks, m_stackMap, m_totalTracks, m_trspFile, and updateHeader().

Referenced by reportResults(), and startNewTrack().

void EGS_ParticleTrackContainer::updateHeader ( )
protected

Update the output file's header.

Usually called at the end to update the number of events scored, etc.

Definition at line 166 of file egs_particle_track.cpp.

References m_totalTracks, and m_trspFile.

Referenced by flushBuffer().

Member Data Documentation

int* EGS_ParticleTrackContainer::m_stackMap
protected

the internal stack used for mapping the tracks in the tracks array with integers

Definition at line 348 of file egs_particle_track.h.

Referenced by addVertex(), flushBuffer(), readDataFile(), and startNewTrack().

bool* EGS_ParticleTrackContainer::m_isScoring
protected

which of the tracks in the array are still being scored

Definition at line 351 of file egs_particle_track.h.

Referenced by addVertex(), flushBuffer(), readDataFile(), reportResults(), and startNewTrack().


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