]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4TrackingAction.cxx
Changes by Massimo Masera to allow Recpoints and Clusters to be written
[u/mrichter/AliRoot.git] / TGeant4 / TG4TrackingAction.cxx
1 // $Id$
2 // Category: event
3 //
4 // Author: I.Hrivnacova
5 //
6 // Class TG4TrackingAction
7 // -----------------------
8 // See the class description in the header file.
9
10 #include "TG4TrackingAction.h"
11 #include "TG4StepManager.h"
12 #include "TG4VSensitiveDetector.h"
13 #include "TG4SDServices.h"
14 #include "TG4Globals.h"
15
16 //_____________________________________________________________________________
17 TG4TrackingAction::TG4TrackingAction() {
18 //
19 }
20
21 //_____________________________________________________________________________
22 TG4TrackingAction::TG4TrackingAction(const TG4TrackingAction& right) {
23 //
24   TG4Globals::Exception("TG4TrackingAction is protected from copying.");
25 }
26
27 //_____________________________________________________________________________
28 TG4TrackingAction::~TG4TrackingAction() {
29 //
30 }
31
32 // operators
33
34 //_____________________________________________________________________________
35 TG4TrackingAction& 
36 TG4TrackingAction::operator=(const TG4TrackingAction &right)
37 {
38   // check assignement to self
39   if (this == &right) return *this;
40   
41   TG4Globals::Exception("TG4TrackingAction is protected from assigning.");
42
43   return *this;
44 }
45
46 // public methods
47
48 //_____________________________________________________________________________
49 void TG4TrackingAction::PreUserTrackingAction(const G4Track* track)
50 {
51 // Called by G4 kernel before starting tracking.
52 // ---
53
54   // set step manager status
55   TG4StepManager* stepManager = TG4StepManager::Instance();
56   stepManager->SetStep((G4Track*)track, kVertex);
57   
58   // call pre-tracking action of derived class
59   PreTrackingAction(track);
60
61   // let sensitive detector process vertex step
62   // (this ensures compatibility with G3 that
63   // makes first step of zero length)
64    
65   G4VPhysicalVolume* pv = stepManager->GetCurrentPhysicalVolume();
66   
67   if (!pv) {
68     G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
69     text = text + "   Cannot locate track vertex."; 
70     TG4Globals::Exception(text);
71   }  
72   
73 #ifdef TGEANT4_DEBUG
74   TG4VSensitiveDetector* tsd
75     = TG4SDServices::Instance()
76          ->GetSensitiveDetector(
77               pv->GetLogicalVolume()->GetSensitiveDetector());
78
79   if (tsd) tsd->UserProcessHits((G4Track*)track, 0);
80 #else
81   TG4VSensitiveDetector* tsd
82     = (TG4VSensitiveDetector*) pv->GetLogicalVolume()->GetSensitiveDetector();
83
84   if (tsd) tsd->UserProcessHits((G4Track*)track, 0);
85 #endif  
86 }
87
88 //_____________________________________________________________________________
89 void TG4TrackingAction::PostUserTrackingAction(const G4Track* track)
90 {
91 // Called by G4 kernel after finishing tracking.
92 // ---
93
94   // call post-tracking action of derived class
95   PostTrackingAction(track);
96 }
97