#include // for the funtion 'exp()' #include "FCALSteppingAction.hh" #include "FCALDetectorConstruction.hh" #include "FCALEventAction.hh" #include "G4ios.hh" #include "G4Step.hh" #include "G4ParticleDefinition.hh" #include "G4Navigator.hh" FCALSteppingAction::FCALSteppingAction(FCALEventAction* event_Act) : event_Action(event_Act) {} FCALSteppingAction::~FCALSteppingAction() {;} void FCALSteppingAction::UserSteppingAction(const G4Step* aStep) { // -------- 1. Extract information of energy deposited in LeadGlass blocks G4StepPoint* pre_Step = aStep->GetPreStepPoint(); G4StepPoint* post_Step = aStep->GetPostStepPoint(); G4TouchableHandle pre_TouchHandle = pre_Step->GetTouchableHandle(); G4VPhysicalVolume* pre_Volume = pre_TouchHandle->GetVolume(); G4TouchableHandle post_TouchHandle = post_Step->GetTouchableHandle(); G4VPhysicalVolume* post_Volume = post_TouchHandle->GetVolume(); if (pre_Volume != NULL && pre_Volume->GetName() == "LeadGlass") { G4double energy_Deposition = aStep->GetTotalEnergyDeposit(); // G4double z_PrePosition = (pre_Step->GetPosition()).z(); // G4double z_PostPosition = (post_Step->GetPosition()).z(); // G4double z_AvgPosition = (z_PrePosition + z_PostPosition) / 2.; // G4double energy_Attenuate = energy_Deposition * exp(-(143.8*mm + 50.*mm - z_AvgPosition) / 1600*mm); // G4double energy_Attenuate = energy_Deposition * exp(-(318.8*mm + 225.*mm - z_AvgPosition) / 1600*mm); // 318.8: the global z-position of the end of a leadglass // use local coordinate system to calculate attenuation G4ThreeVector worldPos1 = pre_Step->GetPosition(); G4ThreeVector localPos1 = pre_TouchHandle->GetHistory()->GetTopTransform().TransformPoint(worldPos1); G4ThreeVector worldPos2 = post_Step->GetPosition(); G4ThreeVector localPos2 = post_TouchHandle->GetHistory()->GetTopTransform().TransformPoint(worldPos2); G4double z_AvgPos = (localPos1.z()+localPos2.z())/2.; // GEANT4 uses millimeter internally // block_length - zposition : is wrong but is the same as in GlueX-geant siumulation // should be zposition-0.5*block_length G4double energy_Attenuate = energy_Deposition * exp((z_AvgPos-45.0*cm) / 1600*mm); if (energy_Deposition > 0) { G4int copy_Number = pre_TouchHandle->GetCopyNumber(2); event_Action->addEnergyDeposit(energy_Deposition, copy_Number); event_Action->addEnergyAttenuate(energy_Attenuate, copy_Number); } } // -------- 2. Extract associated infomation of optical photons hitting the photocathode if (post_Volume != NULL && post_Volume->GetName() == "PMTCathode") { G4String particle_Name = aStep->GetTrack()->GetDefinition()->GetParticleName(); if (particle_Name == "opticalphoton") ////////////////////////////////////////////////////////////////////////////////////////////////// // Actually, the above line might be meaningless. But if you generate, for example, muons, // // you can come across some occation when the associated detector counts them. // // Of course, when it comes to the comparative number, this must be meaningless // // since huge number of optical photons will be detected. This is just because of rigorousness. // ////////////////////////////////////////////////////////////////////////////////////////////////// { G4double photon_Energy = post_Step->GetTotalEnergy(); G4int copy_Number = post_TouchHandle->GetCopyNumber(2); event_Action->countHits(copy_Number); // count Hits event_Action->addEnergy(photon_Energy, copy_Number); // add energy } } }