]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: event | |
3 | // | |
4 | // See the class description in the header file. | |
5 | ||
6 | #include "AliSteppingAction.h" | |
7 | #include "AliSteppingActionMessenger.h" | |
8 | #include "AliGlobals.h" | |
9 | ||
10 | #include <G4Track.hh> | |
11 | #include <G4SteppingManager.hh> | |
12 | ||
c63f260d | 13 | const G4double AliSteppingAction::fgkTolerance = 1e-6*mm; |
676fb573 | 14 | |
15 | AliSteppingAction::AliSteppingAction() | |
16 | : fKeptStepPoint(G4ThreeVector()), | |
17 | fLoopVerboseLevel(1), | |
18 | fStandardVerboseLevel(0), | |
19 | fLoopStepCounter(0) | |
20 | { | |
21 | // | |
22 | fMessenger = new AliSteppingActionMessenger(this); | |
23 | } | |
24 | ||
25 | AliSteppingAction::AliSteppingAction(const AliSteppingAction& right) { | |
26 | // | |
27 | AliGlobals::Exception("AliSteppingAction is protected from copying."); | |
28 | } | |
29 | ||
30 | AliSteppingAction::~AliSteppingAction() { | |
31 | // | |
32 | delete fMessenger; | |
33 | } | |
34 | ||
35 | // operators | |
36 | ||
37 | AliSteppingAction& | |
38 | AliSteppingAction::operator=(const AliSteppingAction &right) | |
39 | { | |
40 | // check assignement to self | |
41 | if (this == &right) return *this; | |
42 | ||
43 | AliGlobals::Exception("AliSteppingAction is protected from assigning."); | |
44 | ||
45 | return *this; | |
46 | } | |
47 | ||
48 | // private methods | |
49 | ||
50 | void AliSteppingAction::PrintTrackInfo(const G4Track* track) const | |
51 | { | |
52 | // Prints the track info | |
53 | // - taken from private G4TrackingManager::Verbose() | |
54 | // and the standard header for verbose tracking | |
55 | // - taken from G4SteppingVerbose::TrackingStarted(). | |
56 | // --- | |
57 | ||
58 | // print track info | |
5f1d09c5 | 59 | G4cout << G4endl; |
676fb573 | 60 | G4cout << "*******************************************************" |
61 | << "**************************************************" | |
5f1d09c5 | 62 | << G4endl; |
676fb573 | 63 | G4cout << "* G4Track Information: " |
64 | << " Particle = " << track->GetDefinition()->GetParticleName() | |
65 | << "," | |
66 | << " Track ID = " << track->GetTrackID() | |
67 | << "," | |
68 | << " Parent ID = " << track->GetParentID() | |
5f1d09c5 | 69 | << G4endl; |
676fb573 | 70 | G4cout << "*******************************************************" |
71 | << "**************************************************" | |
5f1d09c5 | 72 | << G4endl; |
73 | G4cout << G4endl; | |
676fb573 | 74 | |
75 | // print header | |
76 | #ifdef G4_USE_G4BESTUNIT_FOR_VERBOSE | |
5f1d09c5 | 77 | G4cout << G4std::setw( 5) << "Step#" << " " |
78 | << G4std::setw( 8) << "X" << " " | |
79 | << G4std::setw( 8) << "Y" << " " | |
80 | << G4std::setw( 8) << "Z" << " " | |
81 | << G4std::setw( 9) << "KineE" << " " | |
82 | << G4std::setw( 8) << "dE" << " " | |
83 | << G4std::setw(12) << "StepLeng" << " " | |
84 | << G4std::setw(12) << "TrackLeng" << " " | |
85 | << G4std::setw(12) << "NextVolume" << " " | |
86 | << G4std::setw( 8) << "ProcName" << G4endl; | |
676fb573 | 87 | #else |
5f1d09c5 | 88 | G4cout << G4std::setw( 5) << "Step#" << " " |
89 | << G4std::setw( 8) << "X(mm)" << " " | |
90 | << G4std::setw( 8) << "Y(mm)" << " " | |
91 | << G4std::setw( 8) << "Z(mm)" << " " | |
92 | << G4std::setw( 9) << "KinE(MeV)" << " " | |
93 | << G4std::setw( 8) << "dE(MeV)" << " " | |
94 | << G4std::setw( 8) << "StepLeng" << " " | |
95 | << G4std::setw( 9) << "TrackLeng" << " " | |
96 | << G4std::setw(11) << "NextVolume" << " " | |
97 | << G4std::setw( 8) << "ProcName" << G4endl; | |
676fb573 | 98 | #endif |
99 | } | |
100 | ||
101 | // public methods | |
102 | ||
103 | void AliSteppingAction::UserSteppingAction(const G4Step* step) | |
104 | { | |
105 | // After processing the given number of steps (kCheckNofSteps) | |
106 | // the particle position is compared with the previus one | |
c63f260d | 107 | // - in case the distance is less than fgkTolerance value |
676fb573 | 108 | // the verbose mode is switched on, particle is let |
109 | // to process a small number of steps (kMaxNofLoopSteps) | |
110 | // and then stopped and killed. | |
111 | // --- | |
112 | ||
113 | G4Track* track = step->GetTrack(); | |
114 | ||
115 | // reset parameters at beginning of tracking | |
116 | G4int stepNumber = track->GetCurrentStepNumber(); | |
117 | if (stepNumber == 0) { | |
118 | fKeptStepPoint = G4ThreeVector(); | |
119 | fLoopStepCounter = 0; | |
120 | fStandardVerboseLevel = fpSteppingManager->GetverboseLevel(); | |
121 | return; | |
122 | } | |
123 | ||
124 | if (fLoopStepCounter) { | |
125 | // count steps after detecting looping track | |
126 | fLoopStepCounter++; | |
127 | if (fLoopStepCounter == kMaxNofLoopSteps) { | |
128 | ||
129 | // stop the looping track | |
130 | track->SetTrackStatus(fStopAndKill); | |
131 | ||
132 | // reset back parameters | |
133 | fpSteppingManager->SetVerboseLevel(fStandardVerboseLevel); | |
134 | fKeptStepPoint = G4ThreeVector(); | |
135 | fLoopStepCounter = 0; | |
136 | } | |
137 | } | |
138 | ||
139 | if (stepNumber % kCheckNofSteps == 0) { | |
140 | // detect looping track | |
141 | G4ThreeVector newStepPoint = step->GetPreStepPoint()->GetPosition(); | |
142 | G4double trajectory = (newStepPoint-fKeptStepPoint).mag(); | |
c63f260d | 143 | if (trajectory < fgkTolerance) { |
676fb573 | 144 | |
145 | // print looping info | |
146 | if (fLoopVerboseLevel > 0) { | |
5f1d09c5 | 147 | G4cout << "*** Particle is looping. ***" << G4endl; |
676fb573 | 148 | if (fStandardVerboseLevel == 0) PrintTrackInfo(track); |
149 | } | |
150 | // set loop verbose level | |
151 | fpSteppingManager->SetVerboseLevel(fLoopVerboseLevel); | |
152 | ||
153 | fLoopStepCounter++; | |
154 | } | |
155 | fKeptStepPoint = newStepPoint; | |
156 | } | |
157 | } |