ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SteppingAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SteppingAction.cc
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 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "SteppingAction.hh"
34 #include "DetectorConstruction.hh"
35 #include "TrackingAction.hh"
36 #include "HistoManager.hh"
37 #include "G4RunManager.hh"
38 #include "Run.hh"
39 
40 #include "G4SteppingManager.hh"
41 #include "G4Gamma.hh"
42 #include "G4UnitsTable.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47  TrackingAction* TrAct)
48 :fDetector(det), fTrackAction(TrAct),
49  fWall(0), fCavity(0)
50 {
51  first = true;
52  fTrackSegm = 0.;
53  fDirectionIn = G4ThreeVector(0.,0.,0.);
54 }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 { }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 {
65  //get fDetector pointers
66  if (first) {
67  fWall = fDetector->GetWall();
69  first = false;
70  }
71 
72 
73  Run* run = static_cast<Run*>(
75 
76  //histograms
78 
79  //get volume
80  //
81  G4StepPoint* point1 = step->GetPreStepPoint();
83 
84  // count processes
85  //
86  G4StepPoint* point2 = step->GetPostStepPoint();
87  const G4VProcess* process = point2->GetProcessDefinedStep();
88  if (process) run->CountProcesses(process->GetProcessName());
89 
90  //energy deposit in fCavity
91  //
92  if (volume == fCavity) {
94  if (edep > 0.) fTrackAction->AddEdepCavity(edep);
95  }
96 
97  //keep only charged particles
98  //
99  if (step->GetTrack()->GetDefinition() == G4Gamma::Gamma()) return;
100 
101  //step size of charged particles
102  //
103  G4int id;
104  G4double steplen = step->GetStepLength();
105  if (volume == fWall) {run->StepInWall (steplen); id = 9;}
106  else {run->StepInCavity(steplen); id = 10;}
107  analysisManager->FillH1(id,steplen);
108 
109  //last step before hitting the fCavity
110  //
111  if ((volume == fWall) && (point2->GetStepStatus() == fGeomBoundary)) {
113  }
114 
115  //keep only charged particles within fCavity
116  //
117  if (volume == fWall) return;
118 
119  G4double ekin1 = point1->GetKineticEnergy();
120  G4double ekin2 = point2->GetKineticEnergy();
121 
122  //first step in cavity
123  //
124  if (point1->GetStepStatus() == fGeomBoundary) {
125  fTrackSegm = 0.;
126  G4ThreeVector vertex = step->GetTrack()->GetVertexPosition();
127  analysisManager->FillH1(4,vertex.z());
128  run->FlowInCavity(0,ekin1);
129  analysisManager->FillH1(5,ekin1);
130  if (steplen>0.) {
131  G4ThreeVector directionOut =
132  (point2->GetPosition() - point1->GetPosition()).unit();
134  ->SurfaceNormal(point1->GetPosition());
135  analysisManager->FillH1(6,std::acos(-fDirectionIn*normal));
136  analysisManager->FillH1(7,std::acos(-directionOut*normal));
137  }
138  }
139 
140  //within cavity
141  //
142  if (step->GetTrack()->GetCurrentStepNumber() == 1) fTrackSegm = 0.;
143  fTrackSegm += steplen;
144  if (ekin2 <= 0.) {
146  analysisManager->FillH1(8,fTrackSegm);
147  }
148 
149  //exit cavity
150  //
151  if (point2->GetStepStatus() == fGeomBoundary) {
152  run->FlowInCavity(1,ekin2);
154  analysisManager->FillH1(8,fTrackSegm);
155  }
156 }
157 
158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159 
160