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 // call pre-tracking action of derived class
45 PreTrackingAction(track);
47 // let sensitive detector process vertex step
48 // (this ensures compatibility with G3 that
49 // makes first step of zero length)
51 TG4StepManager* stepManager = TG4StepManager::Instance();
52 stepManager->SetStep((G4Track*)track, kVertex);
54 G4VPhysicalVolume* pv = stepManager->GetCurrentPhysicalVolume();
57 G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
58 text = text + " Cannot locate track vertex.";
59 TG4Globals::Exception(text);
62 G4VSensitiveDetector* sd
63 = pv->GetLogicalVolume()->GetSensitiveDetector();
66 TG4VSensitiveDetector* tsd = dynamic_cast<TG4VSensitiveDetector*>(sd);
68 tsd->UserProcessHits((G4Track*)track, 0);
70 G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
71 text = text + " Unknown sensitive detector type";
72 TG4Globals::Exception(text);
77 void TG4TrackingAction::PostUserTrackingAction(const G4Track* track)
79 // Called by G4 kernel after finishing tracking.
82 // call post-tracking action of derived class
83 PostTrackingAction(track);