Created SteppingAction class

This commit is contained in:
Gitea 2018-04-02 23:19:47 +02:00
parent 124bd583e7
commit 2cf2d6c10a
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,28 @@
//
// MedtechSteppingAction.hh
// medtech
//
// Created by Baranyai David on 2018. 04. 01..
//
#ifndef MedtechSteppingAction_hh
#define MedtechSteppingAction_hh
#include <stdio.h>
#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 */

View File

@ -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<const MedtechDetectorConstruction*>
(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);
}