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

#include <B1ConRunAction.hh>

Inheritance diagram for B1ConRunAction:
Collaboration diagram for B1ConRunAction:

Public Member Functions

 B1ConRunAction ()
 
virtual ~B1ConRunAction ()
 
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 47 of file B1ConRunAction.hh.

Constructor & Destructor Documentation

B1ConRunAction::B1ConRunAction ( )

Definition at line 44 of file B1ConRunAction.cc.

46 {
47  // add new units for dose
48  //
49  const G4double milligray = 1.e-3*gray;
50  const G4double microgray = 1.e-6*gray;
51  const G4double nanogray = 1.e-9*gray;
52  const G4double picogray = 1.e-12*gray;
53 
54  new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray);
55  new G4UnitDefinition("microgray", "microGy" , "Dose", microgray);
56  new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray);
57  new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
58 
59 }
static constexpr double microgray
Definition: G4SIunits.hh:312
static constexpr double gray
Definition: G4SIunits.hh:309
static constexpr double milligray
Definition: G4SIunits.hh:311
double G4double
Definition: G4Types.hh:76
B1ConRunAction::~B1ConRunAction ( )
virtual

Definition at line 63 of file B1ConRunAction.cc.

64 {}

Member Function Documentation

void B1ConRunAction::BeginOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 75 of file B1ConRunAction.cc.

76 {
77  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
78 
79  //inform the runManager to save random number seed
81 
82  if (IsMaster()) {
83  fdose_tally = new G4ConvergenceTester("DOSE_TALLY");
84  //fdose_tally = new G4ConvergenceTester();
85  }
86 
87 }
void SetRandomNumberStore(G4bool flag)
G4GLOB_DLL std::ostream G4cout
G4bool IsMaster() const
G4int GetRunID() const
Definition: G4Run.hh:76
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void B1ConRunAction::EndOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 91 of file B1ConRunAction.cc.

92 {
93  G4int nofEvents = aRun->GetNumberOfEvent();
94  if (nofEvents == 0) return;
95 
96  const B1ConRun* b1ConRun = static_cast<const B1ConRun*>(aRun);
97 
98  // Compute dose
99  //
100  G4double edep = b1ConRun->GetEdep();
101  G4double edep2 = b1ConRun->GetEdep2();
102  G4double rms = edep2 - edep*edep/nofEvents;
103  if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
104 
105  const B1DetectorConstruction* detectorConstruction
106  = static_cast<const B1DetectorConstruction*>
108  G4double mass = detectorConstruction->GetScoringVolume()->GetMass();
109  G4double dose = edep/mass;
110  G4double rmsDose = rms/mass;
111 
112  // Run conditions
113  // note: There is no primary generator action object for "master"
114  // run manager for multi-threaded mode.
115  const B1PrimaryGeneratorAction* generatorAction
116  = static_cast<const B1PrimaryGeneratorAction*>
118  G4String runCondition;
119  if (generatorAction)
120  {
121  const G4ParticleGun* particleGun = generatorAction->GetParticleGun();
122  runCondition += particleGun->GetParticleDefinition()->GetParticleName();
123  runCondition += " of ";
124  G4double particleEnergy = particleGun->GetParticleEnergy();
125  runCondition += G4BestUnit(particleEnergy,"Energy");
126  }
127 
128  // Print
129  //
130  if (IsMaster())
131  {
132 
133  for ( G4int i = 0 ; i != b1ConRun->GetNumberOfEvent(); i++ ) {
134  G4double aDose = b1ConRun->GetEdepPerEvent(i)/mass/gray;
135  fdose_tally->AddScore( aDose );
136  }
137 
138  fdose_tally->ShowResult();
139  fdose_tally->ShowHistory();
140  delete fdose_tally;
141 
142  G4cout
143  << "\n--------------------End of Global Run-----------------------";
144  }
145  else
146  {
147  G4cout
148  << "\n--------------------End of Local Run------------------------";
149  }
150  G4cout
151  << "\n The run consists of " << nofEvents << " "<< runCondition
152  << "\n Dose in scoring volume : "
153  << G4BestUnit(dose,"Dose") << " +- " << G4BestUnit(rmsDose,"Dose")
154  << "\n------------------------------------------------------------\n"
155  << G4endl;
156 
157 }
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
G4int GetNumberOfEvent() const
Definition: B1ConRun.hh:53
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
G4double GetEdepPerEvent(G4int i) const
Definition: B1ConRun.hh:54
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
G4LogicalVolume * GetScoringVolume() const
G4double GetEdep() const
Definition: B1Run.hh:54
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
static constexpr double gray
Definition: G4SIunits.hh:309
G4bool IsMaster() const
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void ShowHistory(std::ostream &out=G4cout)
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
void ShowResult(std::ostream &out=G4cout)
G4double GetParticleEnergy() const
G4double GetEdep2() const
Definition: B1Run.hh:55

Here is the call graph for this function:

G4Run * B1ConRunAction::GenerateRun ( void  )
virtual

Reimplemented from G4UserRunAction.

Definition at line 68 of file B1ConRunAction.cc.

69 {
70  return new B1ConRun;
71 }

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