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