#include "SteppingAction.hh" #include "EventAction.hh" #include "DetectorConstruction.hh" #include "G4Step.hh" #include "G4Event.hh" #include "G4RunManager.hh" #include "G4LogicalVolume.hh" //----------- // Checks if we are in the target volume and records // the deposited energy //----------- //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... SteppingAction::SteppingAction(EventAction* eventAction) : G4UserSteppingAction(), fEventAction(eventAction), fScoringVolume(0) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... SteppingAction::~SteppingAction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void SteppingAction::UserSteppingAction(const G4Step* step) { if (!fScoringVolume) { const DetectorConstruction* detectorConstruction = static_cast (G4RunManager::GetRunManager()->GetUserDetectorConstruction()); fScoringVolume = detectorConstruction->GetScoringVolume(); } // get volume of the current step G4LogicalVolume* volume = step->GetPreStepPoint()->GetTouchableHandle() ->GetVolume()->GetLogicalVolume(); // check if we are in scoring volume if (volume != fScoringVolume) return; // collect energy deposited in this step G4double edepStep = step->GetTotalEnergyDeposit(); fEventAction->AddEdep(edepStep); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......