Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SteppingAction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 // $Id: SteppingAction.cc 90829 2015-06-10 08:37:55Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "SteppingAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "TrackingAction.hh"
37 #include "HistoManager.hh"
38 #include "G4RunManager.hh"
39 #include "Run.hh"
40 
41 #include "G4SteppingManager.hh"
42 #include "G4Gamma.hh"
43 #include "G4UnitsTable.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48  TrackingAction* TrAct)
49 :fDetector(det), fTrackAction(TrAct),
50  fWall(0), fCavity(0)
51 {
52  first = true;
53  fTrackSegm = 0.;
54  fDirectionIn = G4ThreeVector(0.,0.,0.);
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 { }
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 {
66  //get fDetector pointers
67  if (first) {
68  fWall = fDetector->GetWall();
69  fCavity = fDetector->GetCavity();
70  first = false;
71  }
72 
73 
74  Run* run = static_cast<Run*>(
76 
77  //histograms
78  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
79 
80  //get volume
81  //
82  G4StepPoint* point1 = step->GetPreStepPoint();
83  G4VPhysicalVolume* volume = point1->GetTouchableHandle()->GetVolume();
84 
85  // count processes
86  //
87  G4StepPoint* point2 = step->GetPostStepPoint();
88  const G4VProcess* process = point2->GetProcessDefinedStep();
89  if (process) run->CountProcesses(process->GetProcessName());
90 
91  //energy deposit in fCavity
92  //
93  if (volume == fCavity) {
94  G4double edep = step->GetTotalEnergyDeposit();
95  if (edep > 0.) fTrackAction->AddEdepCavity(edep);
96  }
97 
98  //keep only charged particles
99  //
100  if (step->GetTrack()->GetDefinition() == G4Gamma::Gamma()) return;
101 
102  //step size of charged particles
103  //
104  G4int id;
105  G4double steplen = step->GetStepLength();
106  if (volume == fWall) {run->StepInWall (steplen); id = 9;}
107  else {run->StepInCavity(steplen); id = 10;}
108  analysisManager->FillH1(id,steplen);
109 
110  //last step before hitting the fCavity
111  //
112  if ((volume == fWall) && (point2->GetStepStatus() == fGeomBoundary)) {
113  fDirectionIn = point1->GetMomentumDirection();
114  }
115 
116  //keep only charged particles within fCavity
117  //
118  if (volume == fWall) return;
119 
120  G4double ekin1 = point1->GetKineticEnergy();
121  G4double ekin2 = point2->GetKineticEnergy();
122 
123  //first step in cavity
124  //
125  if (point1->GetStepStatus() == fGeomBoundary) {
126  fTrackSegm = 0.;
127  G4ThreeVector vertex = step->GetTrack()->GetVertexPosition();
128  analysisManager->FillH1(4,vertex.z());
129  run->FlowInCavity(0,ekin1);
130  analysisManager->FillH1(5,ekin1);
131  if (steplen>0.) {
132  G4ThreeVector directionOut =
133  (point2->GetPosition() - point1->GetPosition()).unit();
135  ->SurfaceNormal(point1->GetPosition());
136  analysisManager->FillH1(6,std::acos(-fDirectionIn*normal));
137  analysisManager->FillH1(7,std::acos(-directionOut*normal));
138  }
139  }
140 
141  //within cavity
142  //
143  if (step->GetTrack()->GetCurrentStepNumber() == 1) fTrackSegm = 0.;
144  fTrackSegm += steplen;
145  if (ekin2 <= 0.) {
146  run->AddTrakCavity(fTrackSegm);
147  analysisManager->FillH1(8,fTrackSegm);
148  }
149 
150  //exit cavity
151  //
152  if (point2->GetStepStatus() == fGeomBoundary) {
153  run->FlowInCavity(1,ekin2);
154  run->AddTrakCavity(fTrackSegm);
155  analysisManager->FillH1(8,fTrackSegm);
156  }
157 }
158 
159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
160 
161 
void AddTrakCavity(G4double dt)
Definition: Run.hh:70
G4ParticleDefinition * GetDefinition() const
G4VPhysicalVolume * GetWall()
void CountProcesses(G4String procName)
Definition: Run.cc:72
virtual G4VSolid * GetSolid(G4int depth=0) const
Definition: G4VTouchable.cc:51
CLHEP::Hep3Vector G4ThreeVector
void StepInCavity(G4double s)
Definition: Run.hh:74
G4double GetStepLength() const
G4StepStatus GetStepStatus() const
void UserSteppingAction(const G4Step *)
int G4int
Definition: G4Types.hh:78
double z() const
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
G4StepPoint * GetPreStepPoint() const
const G4ThreeVector & GetMomentumDirection() const
G4int GetCurrentStepNumber() const
const G4ThreeVector & GetPosition() const
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
Definition: G4Step.hh:76
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
const G4ThreeVector & GetVertexPosition() const
G4double GetTotalEnergyDeposit() const
G4VPhysicalVolume * GetCavity()
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
const G4VProcess * GetProcessDefinedStep() const
void StepInWall(G4double s)
Definition: Run.hh:72
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
void FlowInCavity(G4int k, G4double e)
Definition: Run.hh:65
G4StepPoint * GetPostStepPoint() const
Detector construction class to define materials and geometry.
void AddEdepCavity(G4double de)
G4double GetKineticEnergy() const
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4Track * GetTrack() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4Run * GetNonConstCurrentRun() const
const G4TouchableHandle & GetTouchableHandle() const