Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
B1::RunAction Class Reference

Run action class. More...

#include <Doxymodules_basic.h>

Inheritance diagram for B1::RunAction:
G4UserRunAction

Public Member Functions

 RunAction ()
 
 ~RunAction () override=default
 
void BeginOfRunAction (const G4Run *) override
 
void EndOfRunAction (const G4Run *) override
 
void AddEdep (G4double edep)
 

Private Attributes

G4Accumulable< G4double > fEdep = 0.
 
G4Accumulable< G4double > fEdep2 = 0.
 

Detailed Description

Run action class.

In EndOfRunAction(), it calculates the dose in the selected volume from the energy deposit accumulated via stepping and event actions. The computed dose is then printed on the screen.

Definition at line 24 of file Doxymodules_basic.h.

Constructor & Destructor Documentation

◆ RunAction()

B1::RunAction::RunAction ( )

Definition at line 48 of file RunAction.cc.

49{
50 // add new units for dose
51 //
52 const G4double milligray = 1.e-3*gray;
53 const G4double microgray = 1.e-6*gray;
54 const G4double nanogray = 1.e-9*gray;
55 const G4double picogray = 1.e-12*gray;
56
57 new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray);
58 new G4UnitDefinition("microgray", "microGy" , "Dose", microgray);
59 new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray);
60 new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
61
62 // Register accumulable to the accumulable manager
63 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
64 accumulableManager->RegisterAccumulable(fEdep);
65 accumulableManager->RegisterAccumulable(fEdep2);
66}
G4Accumulable< G4double > fEdep2
Definition RunAction.hh:61
G4Accumulable< G4double > fEdep
Definition RunAction.hh:60

◆ ~RunAction()

B1::RunAction::~RunAction ( )
overridedefault

Member Function Documentation

◆ BeginOfRunAction()

void B1::RunAction::BeginOfRunAction ( const G4Run )
override

Definition at line 70 of file RunAction.cc.

71{
72 // inform the runManager to save random number seed
73 G4RunManager::GetRunManager()->SetRandomNumberStore(false);
74
75 // reset accumulables to their initial values
76 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
77 accumulableManager->Reset();
78
79}

◆ EndOfRunAction()

void B1::RunAction::EndOfRunAction ( const G4Run run)
override

Definition at line 83 of file RunAction.cc.

84{
85 G4int nofEvents = run->GetNumberOfEvent();
86 if (nofEvents == 0) return;
87
88 // Merge accumulables
89 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
90 accumulableManager->Merge();
91
92 // Compute dose = total energy deposit in a run and its variance
93 //
94 G4double edep = fEdep.GetValue();
95 G4double edep2 = fEdep2.GetValue();
96
97 G4double rms = edep2 - edep*edep/nofEvents;
98 if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
99
100 const auto detConstruction = static_cast<const DetectorConstruction*>(
101 G4RunManager::GetRunManager()->GetUserDetectorConstruction());
102 G4double mass = detConstruction->GetScoringVolume()->GetMass();
103 G4double dose = edep/mass;
104 G4double rmsDose = rms/mass;
105
106 // Run conditions
107 // note: There is no primary generator action object for "master"
108 // run manager for multi-threaded mode.
109 const auto generatorAction = static_cast<const PrimaryGeneratorAction*>(
110 G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
111 G4String runCondition;
112 if (generatorAction)
113 {
114 const G4ParticleGun* particleGun = generatorAction->GetParticleGun();
115 runCondition += particleGun->GetParticleDefinition()->GetParticleName();
116 runCondition += " of ";
117 G4double particleEnergy = particleGun->GetParticleEnergy();
118 runCondition += G4BestUnit(particleEnergy,"Energy");
119 }
120
121 // Print
122 //
123 if (IsMaster()) {
124 G4cout
125 << G4endl
126 << "--------------------End of Global Run-----------------------";
127 }
128 else {
129 G4cout
130 << G4endl
131 << "--------------------End of Local Run------------------------";
132 }
133
134 G4cout
135 << G4endl
136 << " The run consists of " << nofEvents << " "<< runCondition
137 << G4endl
138 << " Cumulated dose per run, in scoring volume : "
139 << G4BestUnit(dose,"Dose") << " rms = " << G4BestUnit(rmsDose,"Dose")
140 << G4endl
141 << "------------------------------------------------------------"
142 << G4endl
143 << G4endl;
144}

◆ AddEdep()

void B1::RunAction::AddEdep ( G4double  edep)

Definition at line 148 of file RunAction.cc.

149{
150 fEdep += edep;
151 fEdep2 += edep*edep;
152}

Member Data Documentation

◆ fEdep

G4Accumulable<G4double> B1::RunAction::fEdep = 0.
private

Definition at line 60 of file RunAction.hh.

◆ fEdep2

G4Accumulable<G4double> B1::RunAction::fEdep2 = 0.
private

Definition at line 61 of file RunAction.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration