// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // /// \file RunAction.cc /// \brief Implementation of the B1::RunAction class #include "RunAction.hh" #include "PrimaryGeneratorAction.hh" #include "DetectorConstruction.hh" // #include "Run.hh" #include "G4RunManager.hh" #include "G4Run.hh" #include "G4AccumulableManager.hh" #include "G4LogicalVolumeStore.hh" #include "G4LogicalVolume.hh" #include "G4UnitsTable.hh" #include "G4SystemOfUnits.hh" namespace B1 { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... RunAction::RunAction() { // add new units for dose // const G4double milligray = 1.e-3*gray; const G4double microgray = 1.e-6*gray; const G4double nanogray = 1.e-9*gray; const G4double picogray = 1.e-12*gray; new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray); new G4UnitDefinition("microgray", "microGy" , "Dose", microgray); new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray); new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray); // Register accumulable to the accumulable manager G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance(); accumulableManager->RegisterAccumulable(fEdep); accumulableManager->RegisterAccumulable(fEdep2); accumulableManager->RegisterAccumulable(fEdep1); accumulableManager->RegisterAccumulable(fEdep22); accumulableManager->RegisterAccumulable(fEdep3); accumulableManager->RegisterAccumulable(fEdep33); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... RunAction::~RunAction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void RunAction::BeginOfRunAction(const G4Run*) { // inform the runManager to save random number seed G4RunManager::GetRunManager()->SetRandomNumberStore(false); // reset accumulables to their initial values G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance(); accumulableManager->Reset(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void RunAction::EndOfRunAction(const G4Run* run) { G4int nofEvents = run->GetNumberOfEvent(); if (nofEvents == 0) return; // Merge accumulables G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance(); accumulableManager->Merge(); // Compute dose = total energy deposit in a run and its variance // G4double edep = fEdep.GetValue(); G4double edep1 = fEdep1.GetValue(); G4double edep3 = fEdep3.GetValue(); // G4double edep2 = fEdep2.GetValue(); G4double edep22 = fEdep22.GetValue(); G4double edep33 = fEdep33.GetValue(); // G4double rms = edep2 - (edep*edep)/nofEvents; G4double rms1 = edep22 - edep1*edep1/nofEvents; G4double rms2 = edep33 - edep3*edep3/nofEvents; // if (rms > 0.) rms = std::sqrt(rms); else rms = 0.; if (rms1 > 0.) rms1 = std::sqrt(rms1); else rms1 = 0.; if (rms2 > 0.) rms2 = std::sqrt(rms2); else rms2 = 0.; const DetectorConstruction* detConstruction = static_cast (G4RunManager::GetRunManager()->GetUserDetectorConstruction()); G4double mass = detConstruction->GetScoringVolume()->GetMass(); G4double dose = edep/mass; G4double rmsDose = rms/mass; G4double mass1 = detConstruction->GetScoringVolume1()->GetMass(); G4double dose1= edep1/mass1; G4double rmsDose1 = rms1/mass1; G4double mass2 = detConstruction->GetScoringVolume2()->GetMass(); G4double dose2= edep3/mass2; G4double rmsDose2 = rms2/mass2; // Run conditions // note: There is no primary generator action object for "master" // run manager for multi-threaded mode. // Print // if (IsMaster()) { G4cout << G4endl << "--------------------End of Global Run-----------------------"; } else { G4cout << G4endl << "--------------------End of Local Run------------------------"; } G4cout << G4endl << " The run consists of " << nofEvents << G4endl << " Cumulated dose per run, in D1 Disc: " << G4BestUnit(dose2,"Dose") << " rms = " << G4BestUnit(rmsDose2,"Dose") << G4endl << " Cumulated dose per run, in D2 Disc: " << G4BestUnit(dose,"Dose") << " rms = " << G4BestUnit(rmsDose,"Dose") << G4endl << " Cumulated dose per run, in D3 Disc: " << G4BestUnit(dose1,"Dose") << " rms = " << G4BestUnit(rmsDose1,"Dose") << G4endl << "------------------------------------------------------------" << G4endl << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void RunAction::AddEdep(G4double edep) { fEdep += edep; fEdep2 += edep*edep; } void RunAction::AddEdep1(G4double edep1) { fEdep1 += edep1; fEdep22 += edep1*edep1; } void RunAction::AddEdep3(G4double edep3) { fEdep3 += edep3; fEdep33 += edep3*edep3; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... }