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 AliSteppingAction::AliSteppingAction()
16 : fKeptStepPoint(G4ThreeVector())
19 fMessenger = new AliSteppingActionMessenger(this);
22 AliSteppingAction::AliSteppingAction(const AliSteppingAction& right) {
24 AliGlobals::Exception("AliSteppingAction is protected from copying.");
27 AliSteppingAction::~AliSteppingAction() {
35 AliSteppingAction::operator=(const AliSteppingAction &right)
37 // check assignement to self
38 if (this == &right) return *this;
40 AliGlobals::Exception("AliSteppingAction is protected from assigning.");
47 void AliSteppingAction::SteppingAction(const G4Step* step)
49 // After processing the given number of steps (kCheckNofSteps)
50 // the particle position is compared with the previus one
51 // - in case the distance is less than fgkTolerance value
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.
57 G4Track* track = step->GetTrack();
59 // reset parameters at beginning of tracking
60 G4int stepNumber = track->GetCurrentStepNumber();
61 if (stepNumber == 1) {
62 fKeptStepPoint = G4ThreeVector();
66 if (stepNumber % kCheckNofSteps == 0) {
67 // detect looping track
68 G4ThreeVector newStepPoint = step->GetPreStepPoint()->GetPosition();
69 G4double trajectory = (newStepPoint-fKeptStepPoint).mag();
71 if (trajectory < fgkTolerance) {
74 if (fLoopVerboseLevel > 0) {
75 G4cout << "*** Particle is looping. ***" << G4endl;
76 if (fStandardVerboseLevel == 0) PrintTrackInfo(track);
83 // set loop verbose level
84 fpSteppingManager->SetVerboseLevel(fLoopVerboseLevel);
88 fKeptStepPoint = newStepPoint;