Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/basic/B3/B3a/src/RunAction.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file B3/B3a/src/RunAction.cc
0028 /// \brief Implementation of the B3a::RunAction class
0029 
0030 #include "RunAction.hh"
0031 
0032 #include "PrimaryGeneratorAction.hh"
0033 
0034 #include "G4AccumulableManager.hh"
0035 #include "G4ParticleGun.hh"
0036 #include "G4Run.hh"
0037 #include "G4RunManager.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4UnitsTable.hh"
0040 
0041 using namespace B3;
0042 
0043 namespace B3a
0044 {
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 RunAction::RunAction()
0049 {
0050   // add new units for dose
0051   //
0052   const G4double milligray = 1.e-3 * gray;
0053   const G4double microgray = 1.e-6 * gray;
0054   const G4double nanogray = 1.e-9 * gray;
0055   const G4double picogray = 1.e-12 * gray;
0056 
0057   new G4UnitDefinition("milligray", "milliGy", "Dose", milligray);
0058   new G4UnitDefinition("microgray", "microGy", "Dose", microgray);
0059   new G4UnitDefinition("nanogray", "nanoGy", "Dose", nanogray);
0060   new G4UnitDefinition("picogray", "picoGy", "Dose", picogray);
0061 
0062   // Register accumulable to the accumulable manager
0063   G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
0064   accumulableManager->Register(fGoodEvents);
0065   accumulableManager->Register(fSumDose);
0066 }
0067 
0068 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0069 
0070 void RunAction::BeginOfRunAction(const G4Run* run)
0071 {
0072   G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
0073 
0074   // reset accumulables to their initial values
0075   G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
0076   accumulableManager->Reset();
0077 
0078   // inform the runManager to save random number seed
0079   G4RunManager::GetRunManager()->SetRandomNumberStore(false);
0080 }
0081 
0082 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0083 
0084 void RunAction::EndOfRunAction(const G4Run* run)
0085 {
0086   G4int nofEvents = run->GetNumberOfEvent();
0087   if (nofEvents == 0) return;
0088 
0089   // Merge accumulables
0090   G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
0091   accumulableManager->Merge();
0092 
0093   // Run conditions
0094   //  note: There is no primary generator action object for "master"
0095   //        run manager for multi-threaded mode.
0096   const auto generatorAction = static_cast<const PrimaryGeneratorAction*>(
0097     G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
0098   G4String partName;
0099   if (generatorAction) {
0100     G4ParticleDefinition* particle = generatorAction->GetParticleGun()->GetParticleDefinition();
0101     partName = particle->GetParticleName();
0102   }
0103 
0104   // Print results
0105   //
0106   if (IsMaster()) {
0107     G4cout << G4endl << "--------------------End of Global Run-----------------------" << G4endl
0108            << "  The run was " << nofEvents << " events ";
0109   }
0110   else {
0111     G4cout << G4endl << "--------------------End of Local Run------------------------" << G4endl
0112            << "  The run was " << nofEvents << " " << partName;
0113   }
0114   G4cout << "; Nb of 'good' e+ annihilations: " << fGoodEvents.GetValue() << G4endl
0115          << " Total dose in patient : " << G4BestUnit(fSumDose.GetValue(), "Dose") << G4endl
0116          << "------------------------------------------------------------" << G4endl << G4endl;
0117 }
0118 
0119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0120 
0121 }  // namespace B3a