4 // See the class description in the header file.
6 #include "TG4TrackingAction.h"
7 #include "TG4StepManager.h"
8 #include "TG4VSensitiveDetector.h"
9 #include "TG4Globals.h"
11 TG4TrackingAction::TG4TrackingAction() {
15 TG4TrackingAction::TG4TrackingAction(const TG4TrackingAction& right) {
17 TG4Globals::Exception("TG4TrackingAction is protected from copying.");
20 TG4TrackingAction::~TG4TrackingAction() {
27 TG4TrackingAction::operator=(const TG4TrackingAction &right)
29 // check assignement to self
30 if (this == &right) return *this;
32 TG4Globals::Exception("TG4TrackingAction is protected from assigning.");
39 void TG4TrackingAction::PreUserTrackingAction(const G4Track* track)
41 // Called by G4 kernel before starting tracking.
44 // set step manager status
45 TG4StepManager* stepManager = TG4StepManager::Instance();
46 stepManager->SetStep((G4Track*)track, kVertex);
48 // call pre-tracking action of derived class
49 PreTrackingAction(track);
51 // let sensitive detector process vertex step
52 // (this ensures compatibility with G3 that
53 // makes first step of zero length)
55 G4VPhysicalVolume* pv = stepManager->GetCurrentPhysicalVolume();
58 G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
59 text = text + " Cannot locate track vertex.";
60 TG4Globals::Exception(text);
63 G4VSensitiveDetector* sd
64 = pv->GetLogicalVolume()->GetSensitiveDetector();
67 TG4VSensitiveDetector* tsd = dynamic_cast<TG4VSensitiveDetector*>(sd);
69 tsd->UserProcessHits((G4Track*)track, 0);
71 G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
72 text = text + " Unknown sensitive detector type";
73 TG4Globals::Exception(text);
78 void TG4TrackingAction::PostUserTrackingAction(const G4Track* track)
80 // Called by G4 kernel after finishing tracking.
83 // call post-tracking action of derived class
84 PostTrackingAction(track);