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 "RunAction.hh"
36 #include "TrackingAction.hh"
37 #include "HistoManager.hh"
38 #include "Run.hh"
39 #include "G4RunManager.hh"
40 
41 #include "G4SteppingManager.hh"
42 #include "G4Gamma.hh"
43 #include "G4UnitsTable.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
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  //histograms
74 
75  //get volume
76  //
77  G4StepPoint* point1 = step->GetPreStepPoint();
79 
80  Run* run = static_cast<Run*>(
82  // count processes
83  //
84  G4StepPoint* point2 = step->GetPostStepPoint();
85  const G4VProcess* process = point2->GetProcessDefinedStep();
86  if (process) run->CountProcesses(process->GetProcessName());
87 
88  //energy deposit in cavity
89  //
90  if (volume == fCavity) {
92  if (edep > 0.) fTrackAction->AddEdepCavity(edep);
93  }
94 
95  //keep only charged particles
96  //
97  if (step->GetTrack()->GetDefinition() == G4Gamma::Gamma()) return;
98 
99  //step size of charged particles
100  //
101  G4int id;
102  G4double steplen = step->GetStepLength();
103  if (volume == fWall) {run->StepInWall (steplen); id = 9;}
104  else {run->StepInCavity(steplen); id = 10;}
105  analysisManager->FillH1(id,steplen);
106 
107  //last step before hitting the cavity
108  //
109  if ((volume == fWall) && (point2->GetStepStatus() == fGeomBoundary)) {
111  }
112 
113  //keep only charged particles within cavity
114  //
115  if (volume == fWall) return;
116 
117  G4double ekin1 = point1->GetKineticEnergy();
118  G4double ekin2 = point2->GetKineticEnergy();
119 
120  //first step in cavity
121  //
122  if (point1->GetStepStatus() == fGeomBoundary) {
123  fTrackSegm = 0.;
124  G4ThreeVector vertex = step->GetTrack()->GetVertexPosition();
125  analysisManager->FillH1(4,vertex.z());
126  run->FlowInCavity(0,ekin1);
127  analysisManager->FillH1(5,ekin1);
128  if (steplen>0.) {
129  G4ThreeVector directionOut =
130  (point2->GetPosition() - point1->GetPosition()).unit();
132  ->SurfaceNormal(point1->GetPosition());
133  analysisManager->FillH1(6,std::acos(-fDirectionIn*normal));
134  analysisManager->FillH1(7,std::acos(-directionOut*normal));
135  }
136  }
137 
138  //within cavity
139  //
140  if (step->GetTrack()->GetCurrentStepNumber() == 1) fTrackSegm = 0.;
141  fTrackSegm += steplen;
142  if (ekin2 <= 0.) {
144  analysisManager->FillH1(8,fTrackSegm);
145  }
146 
147  //exit cavity
148  //
149  if (point2->GetStepStatus() == fGeomBoundary) {
150  run->FlowInCavity(1,ekin2);
152  analysisManager->FillH1(8,fTrackSegm);
153  }
154 }
155 
156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
157