Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B1RunAction Class Reference

#include <B1RunAction.hh>

Inheritance diagram for B1RunAction:
Collaboration diagram for B1RunAction:

Public Member Functions

 B1RunAction ()
 
virtual ~B1RunAction ()
 
virtual void BeginOfRunAction (const G4Run *)
 
virtual void EndOfRunAction (const G4Run *)
 
void AddEdep (G4double edep)
 
 B1RunAction ()
 
virtual ~B1RunAction ()
 
virtual G4RunGenerateRun ()
 
virtual void BeginOfRunAction (const G4Run *)
 
virtual void EndOfRunAction (const G4Run *)
 
- Public Member Functions inherited from G4UserRunAction
 G4UserRunAction ()
 
virtual ~G4UserRunAction ()
 
virtual void SetMaster (G4bool val=true)
 
G4bool IsMaster () const
 

Additional Inherited Members

- Protected Attributes inherited from G4UserRunAction
G4bool isMaster
 

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 46 of file B1RunAction.hh.

Constructor & Destructor Documentation

B1RunAction::B1RunAction ( )

Definition at line 46 of file B1RunAction.cc.

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

Here is the call graph for this function:

B1RunAction::~B1RunAction ( )
virtual

Definition at line 71 of file B1RunAction.cc.

72 {}
B1RunAction::B1RunAction ( )
virtual B1RunAction::~B1RunAction ( )
virtual

Member Function Documentation

void B1RunAction::AddEdep ( G4double  edep)

Definition at line 156 of file B1RunAction.cc.

157 {
158  fEdep += edep;
159  fEdep2 += edep*edep;
160 }

Here is the caller graph for this function:

virtual void B1RunAction::BeginOfRunAction ( const G4Run )
virtual

Reimplemented from G4UserRunAction.

void B1RunAction::BeginOfRunAction ( const G4Run )
virtual

Reimplemented from G4UserRunAction.

Definition at line 76 of file B1RunAction.cc.

77 {
78  // inform the runManager to save random number seed
80 
81  // reset accumulables to their initial values
83  accumulableManager->Reset();
84 
85 }
void SetRandomNumberStore(G4bool flag)
static G4AccumulableManager * Instance()
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79

Here is the call graph for this function:

virtual void B1RunAction::EndOfRunAction ( const G4Run )
virtual

Reimplemented from G4UserRunAction.

void B1RunAction::EndOfRunAction ( const G4Run run)
virtual

Reimplemented from G4UserRunAction.

Definition at line 89 of file B1RunAction.cc.

90 {
91  G4int nofEvents = run->GetNumberOfEvent();
92  if (nofEvents == 0) return;
93 
94  // Merge accumulables
96  accumulableManager->Merge();
97 
98  // Compute dose = total energy deposit in a run and its variance
99  //
100  G4double edep = fEdep.GetValue();
101  G4double edep2 = fEdep2.GetValue();
102 
103  G4double rms = edep2 - edep*edep/nofEvents;
104  if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
105 
106  const B1DetectorConstruction* detectorConstruction
107  = static_cast<const B1DetectorConstruction*>
109  G4double mass = detectorConstruction->GetScoringVolume()->GetMass();
110  G4double dose = edep/mass;
111  G4double rmsDose = rms/mass;
112 
113  // Run conditions
114  // note: There is no primary generator action object for "master"
115  // run manager for multi-threaded mode.
116  const B1PrimaryGeneratorAction* generatorAction
117  = static_cast<const B1PrimaryGeneratorAction*>
119  G4String runCondition;
120  if (generatorAction)
121  {
122  const G4ParticleGun* particleGun = generatorAction->GetParticleGun();
123  runCondition += particleGun->GetParticleDefinition()->GetParticleName();
124  runCondition += " of ";
125  G4double particleEnergy = particleGun->GetParticleEnergy();
126  runCondition += G4BestUnit(particleEnergy,"Energy");
127  }
128 
129  // Print
130  //
131  if (IsMaster()) {
132  G4cout
133  << G4endl
134  << "--------------------End of Global Run-----------------------";
135  }
136  else {
137  G4cout
138  << G4endl
139  << "--------------------End of Local Run------------------------";
140  }
141 
142  G4cout
143  << G4endl
144  << " The run consists of " << nofEvents << " "<< runCondition
145  << G4endl
146  << " Cumulated dose per run, in scoring volume : "
147  << G4BestUnit(dose,"Dose") << " rms = " << G4BestUnit(rmsDose,"Dose")
148  << G4endl
149  << "------------------------------------------------------------"
150  << G4endl
151  << G4endl;
152 }
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
Detector construction class to define materials and geometry.
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
static G4AccumulableManager * Instance()
G4LogicalVolume * GetScoringVolume() const
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
G4bool IsMaster() const
T GetValue() const
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
const G4ParticleGun * GetParticleGun() const
G4ParticleDefinition * GetParticleDefinition() const
#define G4endl
Definition: G4ios.hh:61
G4double GetMass(G4bool forced=false, G4bool propagate=true, G4Material *parMaterial=0)
double G4double
Definition: G4Types.hh:76
G4double GetParticleEnergy() const

Here is the call graph for this function:

G4Run * B1RunAction::GenerateRun ( void  )
virtual

Reimplemented from G4UserRunAction.

Definition at line 67 of file B1RunAction.cc.

68 {
69  return new B1Run;
70 }
Definition: B1Run.hh:42

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