]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliSteppingAction.cxx
README updated (R.Barbera)
[u/mrichter/AliRoot.git] / AliGeant4 / AliSteppingAction.cxx
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
13 const G4double AliSteppingAction::fgkTolerance = 1e-6*mm;
14
15 AliSteppingAction::AliSteppingAction()
16   : fKeptStepPoint(G4ThreeVector())
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
45 // public methods
46
47 void AliSteppingAction::SteppingAction(const G4Step* step)
48 {
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.
55 // ---
56
57   G4Track* track = step->GetTrack();  
58
59   // reset parameters at beginning of tracking
60   G4int stepNumber = track->GetCurrentStepNumber();
61   if (stepNumber == 1) {
62     fKeptStepPoint = G4ThreeVector();
63     return;
64   }  
65     
66   if (stepNumber % kCheckNofSteps == 0) {  
67     // detect looping track
68     G4ThreeVector newStepPoint = step->GetPreStepPoint()->GetPosition();
69     G4double trajectory = (newStepPoint-fKeptStepPoint).mag();
70     G4bool kill = false;
71     if (trajectory < fgkTolerance) {
72
73       // print looping info
74       if (fLoopVerboseLevel > 0) {
75         G4cout << "*** Particle is looping. ***" << G4endl;
76         if (fStandardVerboseLevel == 0) PrintTrackInfo(track);
77       } 
78       kill = true;
79     }
80     
81     if (kill) {
82
83       // set loop verbose level 
84       fpSteppingManager->SetVerboseLevel(fLoopVerboseLevel);
85       
86       fLoopStepCounter++;
87     }  
88     fKeptStepPoint = newStepPoint;
89   }  
90 }