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

Run action class. More...

#include <RunAction.hh>

Inheritance diagram for B1Con::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.
 
VectorAccumulable< G4double > fEdepPerEvent
 
G4ConvergenceTesterfDoseTally = nullptr
 

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 53 of file RunAction.hh.

Constructor & Destructor Documentation

◆ RunAction()

B1Con::RunAction::RunAction ( )

Definition at line 47 of file RunAction.cc.

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

◆ ~RunAction()

B1Con::RunAction::~RunAction ( )
overridedefault

Member Function Documentation

◆ BeginOfRunAction()

void B1Con::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 if (IsMaster()) {
80 fDoseTally = new G4ConvergenceTester("DOSE_TALLY");
81 //fDoseTally = new G4ConvergenceTester();
82 }
83}
G4ConvergenceTester * fDoseTally
Definition RunAction.hh:68

◆ EndOfRunAction()

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

Definition at line 87 of file RunAction.cc.

88{
89 G4int nofEvents = run->GetNumberOfEvent();
90 if (nofEvents == 0) return;
91
92 // Merge accumulables
93 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
94 accumulableManager->Merge();
95
96 // Compute dose = total energy deposit in a run and its variance
97 //
98 G4double edep = fEdep.GetValue();
99 G4double edep2 = fEdep2.GetValue();
100
101 G4double rms = edep2 - edep*edep/nofEvents;
102 if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
103
104 const auto detConstruction = static_cast<const B1::DetectorConstruction*>(
105 G4RunManager::GetRunManager()->GetUserDetectorConstruction());
106 G4double mass = detConstruction->GetScoringVolume()->GetMass();
107 G4double dose = edep/mass;
108 G4double rmsDose = rms/mass;
109
110 // Run conditions
111 // note: There is no primary generator action object for "master"
112 // run manager for multi-threaded mode.
113 const auto generatorAction = static_cast<const B1::PrimaryGeneratorAction*>(
114 G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
115 G4String runCondition;
116 if (generatorAction)
117 {
118 const G4ParticleGun* particleGun = generatorAction->GetParticleGun();
119 runCondition += particleGun->GetParticleDefinition()->GetParticleName();
120 runCondition += " of ";
121 G4double particleEnergy = particleGun->GetParticleEnergy();
122 runCondition += G4BestUnit(particleEnergy,"Energy");
123 }
124
125 // Print
126 //
127 if (IsMaster()) {
128 for (auto edepPerEvent : fEdepPerEvent.GetVector()) {
129 G4double dosePerEvent = edepPerEvent/mass/gray;
130 fDoseTally->AddScore(dosePerEvent);
131 }
132
133 fDoseTally->ShowResult();
134 fDoseTally->ShowHistory();
135 delete fDoseTally;
136 fDoseTally = nullptr;
137
138 G4cout
139 << G4endl
140 << "--------------------End of Global Run-----------------------";
141 }
142 else {
143 G4cout
144 << G4endl
145 << "--------------------End of Local Run------------------------";
146 }
147
148 G4cout
149 << G4endl
150 << " The run consists of " << nofEvents << " "<< runCondition
151 << G4endl
152 << " Cumulated dose per run, in scoring volume : "
153 << G4BestUnit(dose,"Dose") << " rms = " << G4BestUnit(rmsDose,"Dose")
154 << G4endl
155 << "------------------------------------------------------------"
156 << G4endl
157 << G4endl;
158}
Detector construction class to define materials and geometry.
G4LogicalVolume * GetScoringVolume() const
The primary generator action class with particle gun.

◆ AddEdep()

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

Definition at line 162 of file RunAction.cc.

163{
164 fEdep += edep;
165 fEdep2 += edep*edep;
167}

Member Data Documentation

◆ fEdep

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

Definition at line 65 of file RunAction.hh.

◆ fEdep2

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

Definition at line 66 of file RunAction.hh.

◆ fEdepPerEvent

VectorAccumulable<G4double> B1Con::RunAction::fEdepPerEvent
private

Definition at line 67 of file RunAction.hh.

◆ fDoseTally

G4ConvergenceTester* B1Con::RunAction::fDoseTally = nullptr
private

Definition at line 68 of file RunAction.hh.


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

Applications | User Support | Publications | Collaboration