4 // See the class description in the header file.
6 #include "AliSteppingAction.h"
7 #include "AliSteppingActionMessenger.h"
8 #include "AliGlobals.h"
11 #include <G4SteppingManager.hh>
13 const G4double AliSteppingAction::fgkTolerance = 1e-6*mm;
15 //_____________________________________________________________________________
16 AliSteppingAction::AliSteppingAction()
17 : fKeptStepPoint(G4ThreeVector())
20 fMessenger = new AliSteppingActionMessenger(this);
23 //_____________________________________________________________________________
24 AliSteppingAction::AliSteppingAction(const AliSteppingAction& right) {
26 AliGlobals::Exception("AliSteppingAction is protected from copying.");
29 //_____________________________________________________________________________
30 AliSteppingAction::~AliSteppingAction() {
37 //_____________________________________________________________________________
39 AliSteppingAction::operator=(const AliSteppingAction &right)
41 // check assignement to self
42 if (this == &right) return *this;
44 AliGlobals::Exception("AliSteppingAction is protected from assigning.");
51 //_____________________________________________________________________________
52 void AliSteppingAction::SteppingAction(const G4Step* step)
54 // After processing the given number of steps (kCheckNofSteps)
55 // the particle position is compared with the previus one
56 // - in case the distance is less than fgkTolerance value
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.
62 G4Track* track = step->GetTrack();
64 // reset parameters at beginning of tracking
65 G4int stepNumber = track->GetCurrentStepNumber();
66 if (stepNumber == 1) {
67 fKeptStepPoint = G4ThreeVector();
71 if (stepNumber % kCheckNofSteps == 0) {
72 // detect looping track
73 G4ThreeVector newStepPoint = step->GetPreStepPoint()->GetPosition();
74 G4double trajectory = (newStepPoint-fKeptStepPoint).mag();
76 if (trajectory < fgkTolerance) {
79 if (fLoopVerboseLevel > 0) {
80 G4cout << "*** Particle is looping. ***" << G4endl;
81 if (fStandardVerboseLevel == 0) PrintTrackInfo(track);
88 // set loop verbose level
89 fpSteppingManager->SetVerboseLevel(fLoopVerboseLevel);
93 fKeptStepPoint = newStepPoint;