#include "stepping.hh" #include "G4RunManager.hh" MySteppingAction::MySteppingAction(EventAction *eventAction) { fEventAction = eventAction; } MySteppingAction::~MySteppingAction() {} void MySteppingAction::UserSteppingAction(const G4Step *step) { G4LogicalVolume *volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume(); const DetectorConstruction *detectorConstruction = static_cast (G4RunManager::GetRunManager()->GetUserDetectorConstruction()); // G4cout << "volume is " << volume << G4endl; G4LogicalVolume *fScoringVolume = detectorConstruction->GetScoringVolume(); // G4cout << "fScoringVolume is " << fScoringVolume << G4endl; if(volume != fScoringVolume) // G4cout << "Sir, we have a problem here." << G4endl; return; G4double edep = step->GetTotalEnergyDeposit(); fEventAction->AddEdep(edep); }