4 // Author: I.Hrivnacova
6 // Class TG4TrackingAction
7 // -----------------------
8 // See the class description in the header file.
10 #include "TG4TrackingAction.h"
11 #include "TG4StepManager.h"
12 #include "TG4VSensitiveDetector.h"
13 #include "TG4SDServices.h"
14 #include "TG4Globals.h"
16 //_____________________________________________________________________________
17 TG4TrackingAction::TG4TrackingAction() {
21 //_____________________________________________________________________________
22 TG4TrackingAction::TG4TrackingAction(const TG4TrackingAction& right) {
24 TG4Globals::Exception("TG4TrackingAction is protected from copying.");
27 //_____________________________________________________________________________
28 TG4TrackingAction::~TG4TrackingAction() {
34 //_____________________________________________________________________________
36 TG4TrackingAction::operator=(const TG4TrackingAction &right)
38 // check assignement to self
39 if (this == &right) return *this;
41 TG4Globals::Exception("TG4TrackingAction is protected from assigning.");
48 //_____________________________________________________________________________
49 void TG4TrackingAction::PreUserTrackingAction(const G4Track* track)
51 // Called by G4 kernel before starting tracking.
54 // set step manager status
55 TG4StepManager* stepManager = TG4StepManager::Instance();
56 stepManager->SetStep((G4Track*)track, kVertex);
58 // call pre-tracking action of derived class
59 PreTrackingAction(track);
61 // let sensitive detector process vertex step
62 // (this ensures compatibility with G3 that
63 // makes first step of zero length)
65 G4VPhysicalVolume* pv = stepManager->GetCurrentPhysicalVolume();
68 G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
69 text = text + " Cannot locate track vertex.";
70 TG4Globals::Exception(text);
74 TG4VSensitiveDetector* tsd
75 = TG4SDServices::Instance()
76 ->GetSensitiveDetector(
77 pv->GetLogicalVolume()->GetSensitiveDetector());
79 if (tsd) tsd->UserProcessHits((G4Track*)track, 0);
81 TG4VSensitiveDetector* tsd
82 = (TG4VSensitiveDetector*) pv->GetLogicalVolume()->GetSensitiveDetector();
84 if (tsd) tsd->UserProcessHits((G4Track*)track, 0);
88 //_____________________________________________________________________________
89 void TG4TrackingAction::PostUserTrackingAction(const G4Track* track)
91 // Called by G4 kernel after finishing tracking.
94 // call post-tracking action of derived class
95 PostTrackingAction(track);