#include "ELYSE/SteppingAction.hh" //GEANT 4 #include "G4SteppingManager.hh" #include "G4SDManager.hh" #include "G4EventManager.hh" #include "G4ProcessManager.hh" #include "G4Track.hh" #include "G4Step.hh" #include "G4Event.hh" #include "G4StepPoint.hh" #include "G4TrackStatus.hh" #include "G4VPhysicalVolume.hh" #include "G4ParticleDefinition.hh" #include "G4ParticleTypes.hh" #include "G4OpBoundaryProcess.hh" //ELYSE #include "ELYSE/EventAction.hh" #include "ELYSE/TrackingAction.hh" #include "ELYSE/Trajectory.hh" #include "ELYSE/TrappingVolume.hh" #include "ELYSE/TrackInformation.hh" ELYSE::SteppingAction::SteppingAction() { }//Ctor //--------------------------------------------------------------------------------------------------- ELYSE::SteppingAction::~SteppingAction() { }//Dtor //--------------------------------------------------------------------------------------------------- void ELYSE::SteppingAction::UserSteppingAction(const G4Step * theStep){ G4Track* theTrack = theStep->GetTrack(); G4StepPoint* thePostPoint = theStep->GetPostStepPoint(); G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume(); G4OpBoundaryProcessStatus boundaryStatus=Undefined; static G4OpBoundaryProcess* boundary=NULL; if(!thePostPV){//out of world return;} G4ParticleDefinition* particleType = theTrack->GetDefinition(); G4String particleName = particleType->GetParticleName(); //-----------only optical photons if(particleName == "opticalphoton") { //------------find the boundary process only once if( !boundary ) { G4ProcessManager* pm = theStep->GetTrack()->GetDefinition()->GetProcessManager(); G4int nprocesses = pm->GetProcessListLength(); G4ProcessVector* pv = pm->GetProcessList(); G4int i; for( i=0;iGetProcessName()=="OpBoundary"){ boundary = (G4OpBoundaryProcess*)(*pv)[i]; break; } } }//set boundary once //if the OpticalBoundary process is not registered for Optical Photon => FATAL error if(!boundary) { G4cout << "(JEC) UserSteppingAction: FATAL: NO OpBoundary FOUND" << G4endl; exit(0); } //------------Kill photons entering expHall if(thePostPV->GetName()=="expHall") { theTrack->SetTrackStatus(fStopAndKill);} //----------- boundaryStatus = boundary->GetStatus(); // Check to see if the particle was actually at a boundary // Otherwise the boundary status may not be valid // Prior to Geant4.6.0-p1 this would not have been enough to check if(thePostPoint->GetStepStatus()==fGeomBoundary) { //possible G4OpBoundaryProcessStatus { Undefined, // FresnelRefraction, FresnelReflection, // TotalInternalReflection, // LambertianReflection, LobeReflection, // SpikeReflection, BackScattering, // Absorption, Detection, NotAtBoundary, // SameMaterial, StepTooSmall, NoRINDEX} switch(boundaryStatus){ case FresnelRefraction: G4cout << "(JEC) Status of PostPoint: FresnelRefraction" << G4endl; break; case FresnelReflection: G4cout << "(JEC) Status of PostPoint: FresnelReflection" << G4endl; break; case TotalInternalReflection: G4cout << "(JEC) Status of PostPoint: TotalInternalReflection" << G4endl; break; case LambertianReflection: G4cout << "(JEC) Status of PostPoint: LambertianReflection" << G4endl; break; case LobeReflection: G4cout << "(JEC) Status of PostPoint: LobeReflection" << G4endl; break; case SpikeReflection: G4cout << "(JEC) Status of PostPoint: SpikeReflection" << G4endl; break; case Absorption: G4cout << "(JEC) Status of PostPoint: Absorption" << G4endl; break; case Detection: // Note, this assumes that the volume causing detection // is the interface between Tyvek and Air because it is the only one with // 100% efficiency { // Triger sensitive detector manually since photon is // absorbed but status was Detection G4SDManager* SDman = G4SDManager::GetSDMpointer(); //see DetectorConstruction::Construct for the PATH of the Sensitive Volume TrappingVolume* trapVol = 0; if(SDman) trapVol = (TrappingVolume*)SDman->FindSensitiveDetector("/ELYSE/TrappingVolume"); if(trapVol) { trapVol->ProcessHits_constStep(theStep,0); //------------Save the hit into the track info TrackInformation* aInfo = (TrackInformation*)theTrack->GetUserInformation(); G4cout << "(JEC) SteppingAction::opticalphoton detection = " << " " << theTrack << " " << aInfo << G4endl; if(aInfo)aInfo->AddTrackStatusFlag(hitProduced); } else { G4cout << "(JEC) UserSteppingAction: FATAL: NO Sensitive Det. FOUND" << G4endl; exit(0); } break; }//case Detection case NotAtBoundary: G4cout << "(JEC) Status of PostPoint: NotAtBoundary" << G4endl; break; case SameMaterial: G4cout << "(JEC) Status of PostPoint: SameMaterial" << G4endl; break; case StepTooSmall: G4cout << "(JEC) Status of PostPoint: StepTooSmall" << G4endl; break; case NoRINDEX: G4cout << "(JEC) Status of PostPoint: NoRINDEX" << G4endl; break; default: break; }//eo switch on boundary values }//test on GeomBoundary }//Optical photon }//UserSteppingAction