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