Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
EDepSim::TrajectoryMap Class Reference

#include <EDepSimTrajectoryMap.hh>

Public Member Functions

 ~TrajectoryMap ()
 

Static Public Member Functions

static G4VTrajectory * Get (int trackId)
 Provide a map between the track id and the trajectory object. More...
 
static void Add (G4VTrajectory *traj)
 Add a trajectory to the map. More...
 
static void Clear ()
 
static int FindPrimaryId (int trackId)
 

Private Member Functions

 TrajectoryMap ()
 

Static Private Attributes

static std::map< int, G4VTrajectory * > fMap
 

Detailed Description

Definition at line 15 of file EDepSimTrajectoryMap.hh.

Constructor & Destructor Documentation

EDepSim::TrajectoryMap::~TrajectoryMap ( )
inline

Definition at line 17 of file EDepSimTrajectoryMap.hh.

17 {}
EDepSim::TrajectoryMap::TrajectoryMap ( )
inlineprivate

The constructor is private so that it can only be created using the static get method.

Definition at line 42 of file EDepSimTrajectoryMap.hh.

42 {}

Member Function Documentation

void EDepSim::TrajectoryMap::Add ( G4VTrajectory *  traj)
static

Add a trajectory to the map.

Definition at line 17 of file EDepSimTrajectoryMap.cc.

17  {
18  int trackId = traj->GetTrackID();
19  fMap[trackId] = traj;
20 }
static std::map< int, G4VTrajectory * > fMap
void EDepSim::TrajectoryMap::Clear ( )
static

Clear the trajectory map. This must be done in the EDepSim::UserEventAction::BeginOfEventAction() method.

Definition at line 13 of file EDepSimTrajectoryMap.cc.

13  {
14  fMap.clear();
15 }
static std::map< int, G4VTrajectory * > fMap
int EDepSim::TrajectoryMap::FindPrimaryId ( int  trackId)
static

Find the primary track ID for the current track. This is the primary that is the ultimate parent of the current track.

Definition at line 22 of file EDepSimTrajectoryMap.cc.

22  {
23  int currentId = trackId;
24  int parentId = trackId;
25  int loopCount=0;
26  for (loopCount=0;loopCount<10000;++loopCount) {
27  G4VTrajectory* t = Get(currentId);
28  if (!t) break;
29  parentId = t->GetParentID();
30  // Check to see the search loop should terminate.
31  G4VTrajectory* p = Get(parentId);
32  // There is no parent so break so this is a primary trajectory.
33  if (!p) break;
34  // Decay products are primary trajectories since they should be
35  // independently reconstructed
36  EDepSim::Trajectory * edepTraj = dynamic_cast<EDepSim::Trajectory*>(t);
37  if (!edepTraj) EDepSimThrow("Invalid Trajectory");
38  if (edepTraj->GetProcessName() == "Decay") break;
39  // A parent ID of zero means that this particle is a primary particle,
40  // so that makes it a primary trajectory too.
41  if (parentId == 0) break;
42  currentId = parentId;
43  }
44  if (loopCount>9999) {
45  EDepSimLog("Infinite Loop in EDepSim::TrajectoryMap::FindPrimaryId(): "
46  << "Track Id: " << trackId);
47  }
48 
49  return currentId;
50 }
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
G4String GetProcessName() const
Get the interaction process that created the trajectory.
p
Definition: test.py:223
static G4VTrajectory * Get(int trackId)
Provide a map between the track id and the trajectory object.
G4VTrajectory * EDepSim::TrajectoryMap::Get ( int  trackId)
static

Provide a map between the track id and the trajectory object.

Definition at line 52 of file EDepSimTrajectoryMap.cc.

52  {
54  if (t == fMap.end()) {
55  return NULL;
56  }
57  return t->second;
58 }
intermediate_table::iterator iterator
static std::map< int, G4VTrajectory * > fMap

Member Data Documentation

std::map< int, G4VTrajectory * > EDepSim::TrajectoryMap::fMap
staticprivate

A map to the trajectories information indexed the the track id. Be careful since the trajectory information is owned by the event, so if you try to use this after a trajectory has been deleted... bad things will happen.

Definition at line 38 of file EDepSimTrajectoryMap.hh.


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