// // ******************************************************************** // * 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. * // ******************************************************************** // // // $Id: ExN03RunAction.cc,v 1.18 2006/06/29 17:49:11 gunter Exp $ // GEANT4 tag $Name: geant4-09-01-patch-02 $ // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... #include "ExN03RunAction.hh" #include "G4Run.hh" #include "G4RunManager.hh" #include "G4UnitsTable.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... ExN03RunAction::ExN03RunAction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... ExN03RunAction::~ExN03RunAction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void ExN03RunAction::BeginOfRunAction(const G4Run* aRun) { G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; //inform the runManager to save random number seed G4RunManager::GetRunManager()->SetRandomNumberStore(true); //initialize cumulative quantities // sumEAbs = sum2EAbs =sumEGap = sum2EGap = 0.; sumLAbs = sum2LAbs =sumLGap = sum2LGap = 0.; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void ExN03RunAction::fillPerEvent(G4double EAbs, G4double EGap, G4double LAbs, G4double LGap) { //accumulate statistic // sumEAbs += EAbs; sum2EAbs += EAbs*EAbs; sumEGap += EGap; sum2EGap += EGap*EGap; sumLAbs += LAbs; sum2LAbs += LAbs*LAbs; sumLGap += LGap; sum2LGap += LGap*LGap; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void ExN03RunAction::EndOfRunAction(const G4Run* aRun) { G4int NbOfEvents = aRun->GetNumberOfEvent(); if (NbOfEvents == 0) return; //compute statistics: mean and rms // sumEAbs /= NbOfEvents; sum2EAbs /= NbOfEvents; G4double rmsEAbs = sum2EAbs - sumEAbs*sumEAbs; if (rmsEAbs >0.) rmsEAbs = std::sqrt(rmsEAbs); else rmsEAbs = 0.; sumEGap /= NbOfEvents; sum2EGap /= NbOfEvents; G4double rmsEGap = sum2EGap - sumEGap*sumEGap; if (rmsEGap >0.) rmsEGap = std::sqrt(rmsEGap); else rmsEGap = 0.; sumLAbs /= NbOfEvents; sum2LAbs /= NbOfEvents; G4double rmsLAbs = sum2LAbs - sumLAbs*sumLAbs; if (rmsLAbs >0.) rmsLAbs = std::sqrt(rmsLAbs); else rmsLAbs = 0.; sumLGap /= NbOfEvents; sum2LGap /= NbOfEvents; G4double rmsLGap = sum2LGap - sumLGap*sumLGap; if (rmsLGap >0.) rmsLGap = std::sqrt(rmsLGap); else rmsLGap = 0.; //print // G4cout << "\n--------------------End of Run------------------------------\n" << "\n mean Energy in Absorber : " << G4BestUnit(sumEAbs,"Energy") << " +- " << G4BestUnit(rmsEAbs,"Energy") << "\n mean Energy in Gap : " << G4BestUnit(sumEGap,"Energy") << " +- " << G4BestUnit(rmsEGap,"Energy") << G4endl; G4cout << "\n mean trackLength in Absorber : " << G4BestUnit(sumLAbs,"Length") << " +- " << G4BestUnit(rmsLAbs,"Length") << "\n mean trackLength in Gap : " << G4BestUnit(sumLGap,"Length") << " +- " << G4BestUnit(rmsLGap,"Length") << "\n------------------------------------------------------------\n" << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......