slic/include
diff -u -r1.30 -r1.31
--- TrajectoryManager.hh 27 Apr 2007 01:54:33 -0000 1.30
+++ TrajectoryManager.hh 15 Oct 2009 00:07:49 -0000 1.31
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/TrajectoryManager.hh,v 1.30 2007/04/27 01:54:33 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/TrajectoryManager.hh,v 1.31 2009/10/15 00:07:49 jeremy Exp $
#ifndef SLIC_TRAJECTORYMANAGER_HH
#define SLIC_TRAJECTORYMANAGER_HH 1
@@ -24,235 +24,239 @@
namespace slic
{
- /**
- * @class TrajectoryManager
- *
- * @brief Provides runtime management of trajectories and track information,
- * mainly to provide enough data for correct settings of MCParticle
- * data in LcioMcpManager.
- *
- * @todo Add current track ID and G4Track instance variables to simplify
- * internal handling and function signatures.
- */
-
- class TrajectoryManager : public Module, public Singleton<TrajectoryManager>
- {
- public:
- typedef std::map<G4int, Trajectory*> TrackIDToTrajectoryMap;
-
- public:
- virtual ~TrajectoryManager();
- TrajectoryManager();
-
- public:
-
- // beginEvent action
- void beginEvent(const G4Event*)
- {
- clearTrackIDToTrajectoryMap();
- }
-
- // preTracking action
- void preTracking(const G4Track*);
-
- // postTracking action
- void postTracking(const G4Track*);
-
- // stepping action
- void stepping( const G4Step*);
-
- // find trajectory by track ID
- Trajectory* findTrajectory(G4int trkID);
-
- // find trajectory by const track
- Trajectory* findTrajectory(const G4Track* aTrack )
- {
- return findTrajectory( aTrack->GetTrackID() );
- }
-
- // find trajectory by track
- Trajectory* findTrajectory(G4Track* aTrack )
- {
- return findTrajectory( ( const_cast<const G4Track*> ( aTrack ) )->GetTrackID() );
- }
-
- void printTrackIDToTrajectoryMap()
- {
- log() << LOG::debug << "TrackIDToTrajectoryMap" << LOG::done;
- log() << LOG::debug << "trackID | trjPtr" << LOG::done;
- for ( TrackIDToTrajectoryMap::iterator iter = m_trackIDToTrajectory.begin();
- iter != m_trackIDToTrajectory.end();
- iter++) {
- log() << LOG::debug << iter->first << " " << iter->second << LOG::done;
- }
- }
-
- // set the TrackingManager
- inline void setTrackingManager(const G4TrackingManager* trkMgr)
- {
- m_trackingManager = const_cast<G4TrackingManager*>(trkMgr);
- }
-
- private:
-
- // handle a primary track
- void handlePrimaryTrack(const G4Track* aTrack);
-
- // setup primary track info
- void setPrimaryTrackInformation(const G4Track* aTrack);
-
- // handle a secondary track
- void handleSecondaryTrack(const G4Track* aTrack);
-
- // setup trajectory for a secondary track in handleSecondaryTrack()
- Trajectory* createSecondaryTrajectory(const G4Track* aTrack);
-
- // setup track info for secondary in tracking region
- void setupSecondaryTrackInformation(const G4Track* aTrack);
-
- // setup secondary track info
- void copySecondaryTrackInformationFromParent(const G4Track* aTrack);
-
- // check if this track requires manual trajectory setup
- bool needsManualTrajectorySetup(const G4Track* aTrack);
-
- // set final status of track in postTracking
- void setTrajectoryFinalStatus(const G4Track* aTrack);
-
- // count num secondaries at track's end
- G4int getNumberOfSecondariesAtEnd(const G4Track* aTrack);
-
- // does this track represent a primary particle, i.e. is parent trkID = 0?
- inline bool isPrimaryTrack(const G4Track* aTrack) const
- {
- return ( aTrack->GetParentID() == 0 );
- }
-
- // is edep less than region's threshold to create a trajectory?
- inline bool isBelowThreshold(const G4Track* aTrack) const
- {
- // less than region's kE cut or flag is set
- return ( (aTrack->GetKineticEnergy()
- < G4UserRegionInformation::getRegionInformation( aTrack )->getThreshold() ) ||
- ( TrackInformation::getTrackInformation(aTrack)->getBelowThreshold() == true ) );
- }
-
- /*
- Check if original tracking status is not in a tracking region,
- which works ok because this function is only relavent when track
- is currently in the tracking region.
- */
- inline bool isBackscatter(const G4Track* aTrack) const
- {
- return
- TrackInformation::getTrackInformation( aTrack )->getOriginalTrackingStatus() !=
- TrackInformation::eInTrackingRegion;
- }
-
- // is track status = alive?
- bool isAlive(const G4Step* aStep)
- {
- return aStep->GetTrack()->GetTrackStatus() == fAlive;
- }
-
- // get trajectory from tracking manager
- Trajectory* getCurrentTrajectory()
- {
- return static_cast<Trajectory*> ( m_trackingManager->GimmeTrajectory() );
- }
-
- void fillTrackIDToTrajectoryMap( const G4Event*, bool clearIt = true );
- void addTrackIDToTrajectoryLink( Trajectory* );
-
- void clearTrackIDToTrajectoryMap()
- {
- m_trackIDToTrajectory.clear();
- }
-
- // debug printers
- void printStatusFlags(const G4Track* trk);
- void printStatusFlags(TrackInformation* trkInfo);
- void printTrack(const G4Track* trk, bool isSecondary = false);
- void printTrajectory(const Trajectory* trj);
- void printSecondaries();
-
- void setTrackingFlagFromRegionInformation(TrackInformation* trk_info, G4UserRegionInformation* reg_info);
-
- void printPhysVolDbg(G4StepPoint* stepPnt);
-
- // use parent's endpoint and the seco track position to determine vertexIsNotEndpointOfParent flag
- bool vertexIsNotEndpointOfParent(const G4ThreeVector& parEndpoint, G4Track* secoTrack)
- {
- assert( secoTrack );
-
- bool r = false;
-
- if (!parEndpoint.isNear( secoTrack->GetPosition() ) ) {
- r = true;
- }
-
- return r;
- }
-
- // get trajectory point 3vect
- static G4ThreeVector getTrajectoryPointPosition(Trajectory* trj, G4int pos_idx = 0)
- {
- // check null trajectory
- if (!trj ) {
- G4Exception("TrajectoryManager::getTrajectoryPointPosition() - Trajectory argument is NULL!");
- }
-
- // get number of trajectories
- G4int numPnts = trj->GetPointEntries();
-
- // check idx argument against number of trajectories
- if ( ( pos_idx > ( numPnts - 1 ) ) || pos_idx < 0 ) {
- G4Exception("TrajectoryManager::getTrajectoryPointPosition() - Invalid trajectory position idx.");
- }
-
- // return point at idx
- return trj->GetPoint(pos_idx)->GetPosition();
- }
-
- // get a trajectory's vertex point
- static G4ThreeVector getTrajectoryVertex(Trajectory* trj)
- {
- return getTrajectoryPointPosition( trj, 0 );
- }
-
- // get a trajectory's endpoint
- static G4ThreeVector getTrajectoryEndpoint(Trajectory* trj)
- {
- return getTrajectoryPointPosition( trj, trj->GetPointEntries() - 1 );
- }
-
- // create a trajectory from track's data
- Trajectory* createTrajectoryFromTrack(const G4Track* aTrack );
-
- /* @return Trajectory that was created last */
- inline Trajectory* getCurrentTrajectory() const
- {
- return m_currentTrajectory;
- }
-
- inline const G4Track* getCurrentTrack() const
- {
- return m_currentTrack;
- }
-
- inline G4int getCurrentTrackID() const
- {
- return m_currentTrackID;
- }
-
- private:
-
- G4TrackingManager* m_trackingManager;
- TrackIDToTrajectoryMap m_trackIDToTrajectory;
- Trajectory* m_currentTrajectory;
- const G4Track* m_currentTrack;
- G4int m_currentTrackID;
- };
+ /**
+ * @class TrajectoryManager
+ *
+ * @brief Provides runtime management of trajectories and track information,
+ * mainly to provide enough data for correct settings of MCParticle
+ * data in LcioMcpManager.
+ *
+ * @todo Add current track ID and G4Track instance variables to simplify
+ * internal handling and function signatures.
+ */
+
+ class TrajectoryManager : public Module, public Singleton<TrajectoryManager>
+ {
+ public:
+ typedef std::map<G4int, Trajectory*> TrackIDToTrajectoryMap;
+
+ public:
+ virtual ~TrajectoryManager();
+ TrajectoryManager();
+
+ public:
+
+ // beginEvent action
+ void beginEvent(const G4Event*)
+ {
+ clearTrackIDToTrajectoryMap();
+ }
+
+ // preTracking action
+ void preTracking(const G4Track*);
+
+ // postTracking action
+ void postTracking(const G4Track*);
+
+ // stepping action
+ void stepping( const G4Step*);
+
+ // find trajectory by track ID
+ Trajectory* findTrajectory(G4int trkID);
+
+ // find trajectory by const track
+ Trajectory* findTrajectory(const G4Track* aTrack )
+ {
+ return findTrajectory( aTrack->GetTrackID() );
+ }
+
+ // find trajectory by track
+ Trajectory* findTrajectory(G4Track* aTrack )
+ {
+ return findTrajectory( ( const_cast<const G4Track*> ( aTrack ) )->GetTrackID() );
+ }
+
+ void printTrackIDToTrajectoryMap()
+ {
+ log() << LOG::debug << "TrackIDToTrajectoryMap" << LOG::done;
+ log() << LOG::debug << "trackID | trjPtr" << LOG::done;
+ for ( TrackIDToTrajectoryMap::iterator iter = m_trackIDToTrajectory.begin();
+ iter != m_trackIDToTrajectory.end();
+ iter++) {
+ log() << LOG::debug << iter->first << " " << iter->second << LOG::done;
+ }
+ }
+
+ // set the TrackingManager
+ inline void setTrackingManager(const G4TrackingManager* trkMgr)
+ {
+ m_trackingManager = const_cast<G4TrackingManager*>(trkMgr);
+ }
+
+ private:
+
+ // handle a primary track
+ void handlePrimaryTrack(const G4Track* aTrack);
+
+ // setup primary track info
+ void setPrimaryTrackInformation(const G4Track* aTrack);
+
+ // handle a secondary track
+ void handleSecondaryTrack(const G4Track* aTrack);
+
+ // setup trajectory for a secondary track in handleSecondaryTrack()
+ Trajectory* createSecondaryTrajectory(const G4Track* aTrack);
+
+ // setup track info for secondary in tracking region
+ void setupSecondaryTrackInformation(const G4Track* aTrack);
+
+ // setup secondary track info
+ void copySecondaryTrackInformationFromParent(const G4Track* aTrack);
+
+ // check if this track requires manual trajectory setup
+ bool needsManualTrajectorySetup(const G4Track* aTrack);
+
+ // set final status of track in postTracking
+ void setTrajectoryFinalStatus(const G4Track* aTrack);
+
+ // count num secondaries at track's end
+ G4int getNumberOfSecondariesAtEnd(const G4Track* aTrack);
+
+ // does this track represent a primary particle, i.e. is parent trkID = 0?
+ inline bool isPrimaryTrack(const G4Track* aTrack) const
+ {
+ return ( aTrack->GetParentID() == 0 );
+ }
+
+ /**
+ * Return true if energy is less than region's threshold to create a trajectory or if the
+ * flag has been set on the track info; False if not.
+ */
+ inline bool isBelowThreshold(const G4Track* aTrack) const
+ {
+ return ( (aTrack->GetKineticEnergy()
+ < G4UserRegionInformation::getRegionInformation( aTrack )->getThreshold() ) ||
+ ( TrackInformation::getTrackInformation(aTrack)->getBelowThreshold() == true ) );
+ }
+
+ /*
+ Check if original tracking status is not in a tracking region,
+ which works ok because this function is only relavent when track
+ is currently in the tracking region.
+ */
+ inline bool isBackscatter(const G4Track* aTrack) const
+ {
+ return
+ TrackInformation::getTrackInformation( aTrack )->getOriginalTrackingStatus() !=
+ TrackInformation::eInTrackingRegion;
+ }
+
+ // is track status = alive?
+ bool isAlive(const G4Step* aStep)
+ {
+ return aStep->GetTrack()->GetTrackStatus() == fAlive;
+ }
+
+ // get trajectory from tracking manager
+ Trajectory* getCurrentTrajectory()
+ {
+ return static_cast<Trajectory*> ( m_trackingManager->GimmeTrajectory() );
+ }
+
+ void fillTrackIDToTrajectoryMap( const G4Event*, bool clearIt = true );
+ void addTrackIDToTrajectoryLink( Trajectory* );
+
+ void clearTrackIDToTrajectoryMap()
+ {
+ m_trackIDToTrajectory.clear();
+ }
+
+ // debug printers
+ void printStatusFlags(const G4Track* trk);
+ void printStatusFlags(TrackInformation* trkInfo);
+ void printTrack(const G4Track* trk, bool isSecondary = false);
+ void printTrajectory(const Trajectory* trj);
+ void printSecondaries();
+
+ void setTrackingFlagFromRegionInformation(TrackInformation* trk_info, G4UserRegionInformation* reg_info);
+
+ void printPhysVolDbg(G4StepPoint* stepPnt);
+
+ // use parent's endpoint and the seco track position to determine vertexIsNotEndpointOfParent flag
+ bool vertexIsNotEndpointOfParent(const G4ThreeVector& parEndpoint, G4Track* secoTrack)
+ {
+ assert( secoTrack );
+
+ bool r = false;
+
+ if (!parEndpoint.isNear( secoTrack->GetPosition() ) ) {
+ r = true;
+ }
+
+ return r;
+ }
+
+ // get trajectory point 3vect
+ static G4ThreeVector getTrajectoryPointPosition(Trajectory* trj, G4int pos_idx = 0)
+ {
+ // check null trajectory
+ if (!trj ) {
+ G4Exception("TrajectoryManager::getTrajectoryPointPosition() - Trajectory argument is NULL!");
+ }
+
+ // get number of trajectories
+ G4int numPnts = trj->GetPointEntries();
+
+ // check idx argument against number of trajectories
+ if ( ( pos_idx > ( numPnts - 1 ) ) || pos_idx < 0 ) {
+ G4Exception("TrajectoryManager::getTrajectoryPointPosition() - Invalid trajectory position idx.");
+ }
+
+ // return point at idx
+ return trj->GetPoint(pos_idx)->GetPosition();
+ }
+
+ // get a trajectory's vertex point
+ static G4ThreeVector getTrajectoryVertex(Trajectory* trj)
+ {
+ return getTrajectoryPointPosition( trj, 0 );
+ }
+
+ // get a trajectory's endpoint
+ static G4ThreeVector getTrajectoryEndpoint(Trajectory* trj)
+ {
+ return getTrajectoryPointPosition( trj, trj->GetPointEntries() - 1 );
+ }
+
+ // create a trajectory from track's data
+ Trajectory* createTrajectoryFromTrack(const G4Track* aTrack );
+
+ /**
+ * @return Pointer to the current trajectory being processed.
+ */
+ inline Trajectory* getCurrentTrajectory() const
+ {
+ return m_currentTrajectory;
+ }
+
+ inline const G4Track* getCurrentTrack() const
+ {
+ return m_currentTrack;
+ }
+
+ inline G4int getCurrentTrackID() const
+ {
+ return m_currentTrackID;
+ }
+
+ private:
+
+ G4TrackingManager* m_trackingManager;
+ TrackIDToTrajectoryMap m_trackIDToTrajectory;
+ Trajectory* m_currentTrajectory;
+ const G4Track* m_currentTrack;
+ G4int m_currentTrackID;
+ };
}
#endif