]>
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() | |
41e0e5cc | 16 | : fKeptStepPoint(G4ThreeVector()) |
676fb573 | 17 | { |
18 | // | |
19 | fMessenger = new AliSteppingActionMessenger(this); | |
20 | } | |
21 | ||
22 | AliSteppingAction::AliSteppingAction(const AliSteppingAction& right) { | |
23 | // | |
24 | AliGlobals::Exception("AliSteppingAction is protected from copying."); | |
25 | } | |
26 | ||
27 | AliSteppingAction::~AliSteppingAction() { | |
28 | // | |
29 | delete fMessenger; | |
30 | } | |
31 | ||
32 | // operators | |
33 | ||
34 | AliSteppingAction& | |
35 | AliSteppingAction::operator=(const AliSteppingAction &right) | |
36 | { | |
37 | // check assignement to self | |
38 | if (this == &right) return *this; | |
39 | ||
40 | AliGlobals::Exception("AliSteppingAction is protected from assigning."); | |
41 | ||
42 | return *this; | |
43 | } | |
44 | ||
676fb573 | 45 | // public methods |
46 | ||
9bcb6317 | 47 | void AliSteppingAction::SteppingAction(const G4Step* step) |
676fb573 | 48 | { |
49 | // After processing the given number of steps (kCheckNofSteps) | |
50 | // the particle position is compared with the previus one | |
c63f260d | 51 | // - in case the distance is less than fgkTolerance value |
676fb573 | 52 | // the verbose mode is switched on, particle is let |
53 | // to process a small number of steps (kMaxNofLoopSteps) | |
54 | // and then stopped and killed. | |
55 | // --- | |
56 | ||
57 | G4Track* track = step->GetTrack(); | |
58 | ||
59 | // reset parameters at beginning of tracking | |
60 | G4int stepNumber = track->GetCurrentStepNumber(); | |
41e0e5cc | 61 | if (stepNumber == 1) { |
676fb573 | 62 | fKeptStepPoint = G4ThreeVector(); |
676fb573 | 63 | return; |
64 | } | |
65 | ||
676fb573 | 66 | if (stepNumber % kCheckNofSteps == 0) { |
67 | // detect looping track | |
68 | G4ThreeVector newStepPoint = step->GetPreStepPoint()->GetPosition(); | |
69 | G4double trajectory = (newStepPoint-fKeptStepPoint).mag(); | |
b7af6ca0 | 70 | G4bool kill = false; |
c63f260d | 71 | if (trajectory < fgkTolerance) { |
676fb573 | 72 | |
73 | // print looping info | |
74 | if (fLoopVerboseLevel > 0) { | |
5f1d09c5 | 75 | G4cout << "*** Particle is looping. ***" << G4endl; |
676fb573 | 76 | if (fStandardVerboseLevel == 0) PrintTrackInfo(track); |
77 | } | |
b7af6ca0 | 78 | kill = true; |
79 | } | |
80 | ||
b7af6ca0 | 81 | if (kill) { |
82 | ||
676fb573 | 83 | // set loop verbose level |
84 | fpSteppingManager->SetVerboseLevel(fLoopVerboseLevel); | |
85 | ||
86 | fLoopStepCounter++; | |
87 | } | |
88 | fKeptStepPoint = newStepPoint; | |
89 | } | |
90 | } |