From 2cf2d6c10a2a97c65aa71aad757b034955b0c996 Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 2 Apr 2018 23:19:47 +0200 Subject: [PATCH] Created SteppingAction class --- include/MedtechSteppingAction.hh | 28 ++++++++++++++++++++++ src/MedtechSteppingAction.cc | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 include/MedtechSteppingAction.hh create mode 100644 src/MedtechSteppingAction.cc 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); +}