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