Geant4  9.6.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$
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "SteppingAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "RunAction.hh"
37 #include "EventAction.hh"
38 #include "TrackingAction.hh"
39 #include "HistoManager.hh"
40 
41 #include "G4SteppingManager.hh"
42 #include "G4Gamma.hh"
43 #include "G4UnitsTable.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48  EventAction* EvAct,TrackingAction* TrAct,
49  HistoManager* histo)
50 :fDetector(det), fRunAction(RuAct), fEventAction(EvAct), fTrackAction(TrAct),
51  fHistoManager(histo), fWall(0), fCavity(0)
52 {
53  first = true;
54  fTrackSegm = 0.;
55  fDirectionIn = G4ThreeVector(0.,0.,0.);
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 { }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 {
67  //get fDetector pointers
68  if (first) {
69  fWall = fDetector->GetWall();
70  fCavity = fDetector->GetCavity();
71  first = false;
72  }
73 
74  //get volume
75  //
76  G4StepPoint* point1 = step->GetPreStepPoint();
77  G4VPhysicalVolume* volume = point1->GetTouchableHandle()->GetVolume();
78 
79  // count processes
80  //
81  G4StepPoint* point2 = step->GetPostStepPoint();
82  const G4VProcess* process = point2->GetProcessDefinedStep();
83  if (process) fRunAction->CountProcesses(process->GetProcessName());
84 
85  //energy deposit in fCavity
86  //
87  if (volume == fCavity) {
89  if (edep > 0.) fTrackAction->AddEdepCavity(edep);
90  }
91 
92  //keep only charged particles
93  //
94  if (step->GetTrack()->GetDefinition() == G4Gamma::Gamma()) return;
95 
96  //step size of charged particles
97  //
98  G4int id;
99  G4double steplen = step->GetStepLength();
100  if (volume == fWall) {fRunAction->StepInWall (steplen); id = 9;}
101  else {fRunAction->StepInCavity(steplen); id = 10;}
102  fHistoManager->FillHisto(id,steplen);
103 
104  //last step before hitting the fCavity
105  //
106  if ((volume == fWall) && (point2->GetStepStatus() == fGeomBoundary)) {
107  fDirectionIn = point1->GetMomentumDirection();
108  }
109 
110  //keep only charged particles within fCavity
111  //
112  if (volume == fWall) return;
113 
114  G4double ekin1 = point1->GetKineticEnergy();
115  G4double ekin2 = point2->GetKineticEnergy();
116 
117  //first step in cavity
118  //
119  if (point1->GetStepStatus() == fGeomBoundary) {
120  fTrackSegm = 0.;
121  G4ThreeVector vertex = step->GetTrack()->GetVertexPosition();
122  fHistoManager->FillHisto(4,vertex.z());
123  fRunAction->FlowInCavity(0,ekin1);
124  fHistoManager->FillHisto(5,ekin1);
125  if (steplen>0.) {
126  G4ThreeVector directionOut =
127  (point2->GetPosition() - point1->GetPosition()).unit();
128  G4ThreeVector normal = point1->GetTouchableHandle()->GetSolid()
129  ->SurfaceNormal(point1->GetPosition());
130  fHistoManager->FillHisto(6,std::acos(-fDirectionIn*normal));
131  fHistoManager->FillHisto(7,std::acos(-directionOut*normal));
132  }
133  }
134 
135  //within cavity
136  //
137  if (step->GetTrack()->GetCurrentStepNumber() == 1) fTrackSegm = 0.;
138  fTrackSegm += steplen;
139  if (ekin2 <= 0.) {
140  fRunAction->AddTrakCavity(fTrackSegm);
141  fHistoManager->FillHisto(8,fTrackSegm);
142  }
143 
144  //exit cavity
145  //
146  if (point2->GetStepStatus() == fGeomBoundary) {
147  fRunAction->FlowInCavity(1,ekin2);
148  fRunAction->AddTrakCavity(fTrackSegm);
149  fHistoManager->FillHisto(8,fTrackSegm);
150  }
151 }
152 
153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154 
155