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 //_____________________________________________________________________________
12 TG4TrackingAction::TG4TrackingAction() {
16 //_____________________________________________________________________________
17 TG4TrackingAction::TG4TrackingAction(const TG4TrackingAction& right) {
19 TG4Globals::Exception("TG4TrackingAction is protected from copying.");
22 //_____________________________________________________________________________
23 TG4TrackingAction::~TG4TrackingAction() {
29 //_____________________________________________________________________________
31 TG4TrackingAction::operator=(const TG4TrackingAction &right)
33 // check assignement to self
34 if (this == &right) return *this;
36 TG4Globals::Exception("TG4TrackingAction is protected from assigning.");
43 //_____________________________________________________________________________
44 void TG4TrackingAction::PreUserTrackingAction(const G4Track* track)
46 // Called by G4 kernel before starting tracking.
49 // set step manager status
50 TG4StepManager* stepManager = TG4StepManager::Instance();
51 stepManager->SetStep((G4Track*)track, kVertex);
53 // call pre-tracking action of derived class
54 PreTrackingAction(track);
56 // let sensitive detector process vertex step
57 // (this ensures compatibility with G3 that
58 // makes first step of zero length)
60 G4VPhysicalVolume* pv = stepManager->GetCurrentPhysicalVolume();
63 G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
64 text = text + " Cannot locate track vertex.";
65 TG4Globals::Exception(text);
68 G4VSensitiveDetector* sd
69 = pv->GetLogicalVolume()->GetSensitiveDetector();
72 TG4VSensitiveDetector* tsd = dynamic_cast<TG4VSensitiveDetector*>(sd);
74 tsd->UserProcessHits((G4Track*)track, 0);
76 G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
77 text = text + " Unknown sensitive detector type";
78 TG4Globals::Exception(text);
83 //_____________________________________________________________________________
84 void TG4TrackingAction::PostUserTrackingAction(const G4Track* track)
86 // Called by G4 kernel after finishing tracking.
89 // call post-tracking action of derived class
90 PostTrackingAction(track);