]>
Commit | Line | Data |
---|---|---|
6fc5df41 | 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 | ||
d94b6f87 | 44 | // set step manager status |
45 | TG4StepManager* stepManager = TG4StepManager::Instance(); | |
46 | stepManager->SetStep((G4Track*)track, kVertex); | |
47 | ||
6fc5df41 | 48 | // call pre-tracking action of derived class |
49 | PreTrackingAction(track); | |
50 | ||
51 | // let sensitive detector process vertex step | |
52 | // (this ensures compatibility with G3 that | |
53 | // makes first step of zero length) | |
54 | ||
6fc5df41 | 55 | G4VPhysicalVolume* pv = stepManager->GetCurrentPhysicalVolume(); |
56 | ||
57 | if (!pv) { | |
58 | G4String text = "TG4TrackingAction::PreUserTrackingAction: \n"; | |
59 | text = text + " Cannot locate track vertex."; | |
60 | TG4Globals::Exception(text); | |
61 | } | |
62 | ||
63 | G4VSensitiveDetector* sd | |
64 | = pv->GetLogicalVolume()->GetSensitiveDetector(); | |
65 | ||
66 | if (sd) { | |
67 | TG4VSensitiveDetector* tsd = dynamic_cast<TG4VSensitiveDetector*>(sd); | |
68 | if (tsd) | |
69 | tsd->UserProcessHits((G4Track*)track, 0); | |
70 | else { | |
71 | G4String text = "TG4TrackingAction::PreUserTrackingAction: \n"; | |
72 | text = text + " Unknown sensitive detector type"; | |
73 | TG4Globals::Exception(text); | |
74 | } | |
75 | } | |
76 | } | |
77 | ||
78 | void TG4TrackingAction::PostUserTrackingAction(const G4Track* track) | |
79 | { | |
80 | // Called by G4 kernel after finishing tracking. | |
81 | // --- | |
82 | ||
83 | // call post-tracking action of derived class | |
84 | PostTrackingAction(track); | |
85 | } | |
86 |