Created MedtechRunAction class

This commit is contained in:
Gitea 2018-04-02 23:19:27 +02:00
parent 4c5eee2b96
commit 124bd583e7
2 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,43 @@
//
// MedtechRunAction.hh
// medtech
//
// Created by Baranyai David on 2018. 04. 01..
//
#ifndef MedtechRunAction_hh
#define MedtechRunAction_hh
#include <stdio.h>
#include "G4UserRunAction.hh"
#include "G4Accumulable.hh"
#include "globals.hh"
#include "MedtechPrimaryGeneratorAction.hh"
#include "MedtechDetectorConstruction.hh"
#include "G4RunManager.hh"
#include "G4Run.hh"
#include "G4AccumulableManager.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4LogicalVolume.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "MedtechRun.hh"
class MedtechRunAction : public G4UserRunAction
{
public:
MedtechRunAction();
virtual ~MedtechRunAction();
virtual G4Run* GenerateRun();
virtual void BeginOfRunAction(const G4Run*);
virtual void EndOfRunAction(const G4Run*);
void AddEdep (G4double edep);
private:
G4Accumulable<G4double> fEdep;
G4Accumulable<G4double> fEdep2;
};
#endif /* MedtechRunAction_hh */

62
src/MedtechRunAction.cc Normal file
View File

@ -0,0 +1,62 @@
//
// MedtechRunAction.cc
// medtech
//
// Created by Baranyai David on 2018. 04. 01..
//
#include "MedtechRunAction.hh"
MedtechRunAction::MedtechRunAction() : G4UserRunAction(), fEdep(0.), fEdep2(0.)
{
}
MedtechRunAction::~MedtechRunAction()
{
}
void MedtechRunAction::BeginOfRunAction(const G4Run*)
{
}
void MedtechRunAction::EndOfRunAction(const G4Run* run)
{
G4int nofEvents = run->GetNumberOfEvent();
if (nofEvents == 0) return;
const MedtechRun* medRun = static_cast<const MedtechRun*>(run);
G4double edepInRuns = medRun->GetEdep();
// Print
//
if (IsMaster()) {
G4cout
<< G4endl
<< "--------------------End of Global Run-----------------------";
}
else {
G4cout
<< G4endl
<< "--------------------End of Local Run------------------------";
}
G4cout
<< G4endl
<< " The run consists of " << nofEvents << " edep: "<< edepInRuns/keV
<< G4endl;
}
G4Run* MedtechRunAction::GenerateRun()
{
return new MedtechRun;
}
void MedtechRunAction::AddEdep(G4double edep)
{
fEdep += edep;
fEdep2 += edep*edep;
}