]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliSteppingAction.cxx
added comment lines separating methods
[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 //_____________________________________________________________________________
16 AliSteppingAction::AliSteppingAction()
17   : fKeptStepPoint(G4ThreeVector())
18 {
19 //
20   fMessenger = new AliSteppingActionMessenger(this);
21 }
22
23 //_____________________________________________________________________________
24 AliSteppingAction::AliSteppingAction(const AliSteppingAction& right) {
25 //
26   AliGlobals::Exception("AliSteppingAction is protected from copying.");
27 }
28
29 //_____________________________________________________________________________
30 AliSteppingAction::~AliSteppingAction() {
31 //
32   delete fMessenger;
33 }
34
35 // operators
36
37 //_____________________________________________________________________________
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
49 // public methods
50
51 //_____________________________________________________________________________
52 void AliSteppingAction::SteppingAction(const G4Step* step)
53 {
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.
60 // ---
61
62   G4Track* track = step->GetTrack();  
63
64   // reset parameters at beginning of tracking
65   G4int stepNumber = track->GetCurrentStepNumber();
66   if (stepNumber == 1) {
67     fKeptStepPoint = G4ThreeVector();
68     return;
69   }  
70     
71   if (stepNumber % kCheckNofSteps == 0) {  
72     // detect looping track
73     G4ThreeVector newStepPoint = step->GetPreStepPoint()->GetPosition();
74     G4double trajectory = (newStepPoint-fKeptStepPoint).mag();
75     G4bool kill = false;
76     if (trajectory < fgkTolerance) {
77
78       // print looping info
79       if (fLoopVerboseLevel > 0) {
80         G4cout << "*** Particle is looping. ***" << G4endl;
81         if (fStandardVerboseLevel == 0) PrintTrackInfo(track);
82       } 
83       kill = true;
84     }
85     
86     if (kill) {
87
88       // set loop verbose level 
89       fpSteppingManager->SetVerboseLevel(fLoopVerboseLevel);
90       
91       fLoopStepCounter++;
92     }  
93     fKeptStepPoint = newStepPoint;
94   }  
95 }