ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LXeSteppingAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LXeSteppingAction.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 //
26 //
29 //
30 //
31 #include "LXeSteppingAction.hh"
32 #include "LXeEventAction.hh"
33 #include "LXeTrackingAction.hh"
34 #include "LXeTrajectory.hh"
35 #include "LXePMTSD.hh"
37 #include "LXeSteppingMessenger.hh"
38 
39 #include "G4SteppingManager.hh"
40 #include "G4SDManager.hh"
41 #include "G4EventManager.hh"
42 #include "G4ProcessManager.hh"
43 #include "G4Track.hh"
44 #include "G4Step.hh"
45 #include "G4Event.hh"
46 #include "G4StepPoint.hh"
47 #include "G4TrackStatus.hh"
48 #include "G4VPhysicalVolume.hh"
49 #include "G4ParticleDefinition.hh"
50 #include "G4ParticleTypes.hh"
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55  : fOneStepPrimaries(false),
56  fEventAction(ea)
57 {
59 
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
70 
71  G4Track* theTrack = theStep->GetTrack();
72 
73  if ( theTrack->GetCurrentStepNumber() == 1 ) fExpectedNextStatus = Undefined;
74 
75  LXeUserTrackInformation* trackInformation
77 
78  G4StepPoint* thePrePoint = theStep->GetPreStepPoint();
79  G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
80 
81  G4StepPoint* thePostPoint = theStep->GetPostStepPoint();
82  G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
83 
84  G4OpBoundaryProcessStatus boundaryStatus=Undefined;
85  static G4ThreadLocal G4OpBoundaryProcess* boundary = nullptr;
86 
87  //find the boundary process only once
88  if(!boundary){
90  = theStep->GetTrack()->GetDefinition()->GetProcessManager();
91  G4int nprocesses = pm->GetProcessListLength();
92  G4ProcessVector* pv = pm->GetProcessList();
93  G4int i;
94  for( i=0;i<nprocesses;i++){
95  if((*pv)[i]->GetProcessName()=="OpBoundary"){
96  boundary = (G4OpBoundaryProcess*)(*pv)[i];
97  break;
98  }
99  }
100  }
101 
102  if(theTrack->GetParentID()==0){
103  //This is a primary track
104 
109 
110  //If we havent already found the conversion position and there were
111  //secondaries generated, then search for it
112  if(!fEventAction->IsConvPosSet() && tN2ndariesTot>0 ){
113  for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
114  lp1<(*fSecondary).size(); lp1++){
115  const G4VProcess* creator=(*fSecondary)[lp1]->GetCreatorProcess();
116  if(creator){
117  G4String creatorName=creator->GetProcessName();
118  if(creatorName=="phot"||creatorName=="compt"||creatorName=="conv"){
119  //since this is happening before the secondary is being tracked
120  //the Vertex position has not been set yet(set in initial step)
121  fEventAction->SetConvPos((*fSecondary)[lp1]->GetPosition());
122  }
123  }
124  }
125  }
126 
127  if(fOneStepPrimaries&&thePrePV->GetName()=="scintillator")
128  theTrack->SetTrackStatus(fStopAndKill);
129  }
130 
131  if(!thePostPV){//out of world
133  return;
134  }
135 
136  G4ParticleDefinition* particleType = theTrack->GetDefinition();
137  if(particleType==G4OpticalPhoton::OpticalPhotonDefinition()){
138  //Optical photon only
139 
140  if(thePrePV->GetName()=="Slab")
141  //force drawing of photons in WLS slab
142  trackInformation->SetForceDrawTrajectory(true);
143  else if(thePostPV->GetName()=="expHall")
144  //Kill photons entering expHall from something other than Slab
145  theTrack->SetTrackStatus(fStopAndKill);
146 
147  //Was the photon absorbed by the absorption process
148  if(thePostPoint->GetProcessDefinedStep()->GetProcessName()
149  =="OpAbsorption"){
151  trackInformation->AddTrackStatusFlag(absorbed);
152  }
153 
154  boundaryStatus=boundary->GetStatus();
155 
156  //Check to see if the partcile was actually at a boundary
157  //Otherwise the boundary status may not be valid
158  //Prior to Geant4.6.0-p1 this would not have been enough to check
159  if(thePostPoint->GetStepStatus()==fGeomBoundary){
161  if(boundaryStatus!=StepTooSmall){
163  ed << "LXeSteppingAction::UserSteppingAction(): "
164  << "No reallocation step after reflection!"
165  << G4endl;
166  G4Exception("LXeSteppingAction::UserSteppingAction()", "LXeExpl01",
167  FatalException,ed,
168  "Something is wrong with the surface normal or geometry");
169  }
170  }
172  switch(boundaryStatus){
173  case Absorption:
174  trackInformation->AddTrackStatusFlag(boundaryAbsorbed);
176  break;
177  case Detection: //Note, this assumes that the volume causing detection
178  //is the photocathode because it is the only one with
179  //non-zero efficiency
180  {
181  //Triger sensitive detector manually since photon is
182  //absorbed but status was Detection
184  G4String sdName="/LXeDet/pmtSD";
185  LXePMTSD* pmtSD = (LXePMTSD*)SDman->FindSensitiveDetector(sdName);
186  if(pmtSD)pmtSD->ProcessHits_constStep(theStep, nullptr);
187  trackInformation->AddTrackStatusFlag(hitPMT);
188  break;
189  }
190  case FresnelReflection:
193  case LobeReflection:
194  case SpikeReflection:
195  case BackScattering:
196  trackInformation->IncReflections();
198  break;
199  default:
200  break;
201  }
202  if(thePostPV->GetName()=="sphere")
203  trackInformation->AddTrackStatusFlag(hitSphere);
204  }
205  }
206 }