diff --git a/include/MedtechSteppingAction.hh b/include/MedtechSteppingAction.hh new file mode 100644 index 0000000..5450ed3 --- /dev/null +++ b/include/MedtechSteppingAction.hh @@ -0,0 +1,28 @@ +// +// MedtechSteppingAction.hh +// medtech +// +// Created by Baranyai David on 2018. 04. 01.. +// + +#ifndef MedtechSteppingAction_hh +#define MedtechSteppingAction_hh + +#include +#include "G4UserSteppingAction.hh" +#include "MedtechEventAction.hh" + +class MedtechSteppingAction : public G4UserSteppingAction +{ +public: + MedtechSteppingAction(MedtechEventAction *eventAction); + virtual ~MedtechSteppingAction(); + + virtual void UserSteppingAction(const G4Step*); + +private: + MedtechEventAction* fEventAction; + G4LogicalVolume* fScoringVolume; +}; + +#endif /* MedtechSteppingAction_hh */ diff --git a/src/MedtechSteppingAction.cc b/src/MedtechSteppingAction.cc new file mode 100644 index 0000000..675ea4b --- /dev/null +++ b/src/MedtechSteppingAction.cc @@ -0,0 +1,40 @@ +// +// MedtechSteppingAction.cc +// medtech +// +// Created by Baranyai David on 2018. 04. 01.. +// + +#include "MedtechSteppingAction.hh" + +MedtechSteppingAction::MedtechSteppingAction(MedtechEventAction* eventAction) : G4UserSteppingAction(), fEventAction(eventAction), fScoringVolume(0) +{ + +} + +MedtechSteppingAction::~MedtechSteppingAction() +{ + +} + +void MedtechSteppingAction::UserSteppingAction(const G4Step* step) +{ + if (!fScoringVolume) { + const MedtechDetectorConstruction* 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); +}