#include "mgSteppingAction.hh" #include "mgEventAction.hh" #include "mgDetectorConstruction.hh" #include "mgPrimaryGeneratorAction.hh" #include "G4Step.hh" #include "G4Event.hh" #include "G4RunManager.hh" #include "G4LogicalVolume.hh" #include "G4UnitsTable.hh" #include "G4SystemOfUnits.hh" mgSteppingAction::mgSteppingAction(mgEventAction* eventAction) : G4UserSteppingAction(), fEventAction(eventAction), fShellVolume(0) {} mgSteppingAction::~mgSteppingAction() {} void mgSteppingAction::UserSteppingAction(const G4Step* step) { // G4cout << "Step Made: part 1" << G4endl; if (!fShellVolume) { const mgDetectorConstruction* detectorConstruction = static_cast (G4RunManager::GetRunManager()->GetUserDetectorConstruction()); fShellVolume = detectorConstruction->GetShellVolume(); } // G4cout << "Step Made: part 2" << G4endl; G4String name = fShellVolume->GetName(); // G4cout << "Shell name: " << name << G4endl; G4LogicalVolume* volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume(); // G4cout << "Step Made: volume defined" << G4endl; G4String particlename = step->GetTrack()->GetParticleDefinition()->GetParticleName(); if (particlename != "neutron") { step->GetTrack()->SetTrackStatus(fStopAndKill); return; } if (volume != fShellVolume) return; // G4cout << "Step in shell" << G4endl; // G4String material = "Lead"; G4double kinEnergy = step->GetTrack()->GetKineticEnergy(); /*if (particlename != "neutron") { step->GetTrack()->SetTrackStatus(fStopAndKill); return; }*/ // std::ofstream energyFile("neutronenergy_through_"+material+".txt"); // energyFile << particlename << " " << kinEnergy/MeV << "\n"; G4cout << particlename << " " << kinEnergy/MeV << G4endl; }