G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
Loading...
Searching...
No Matches
RunAction.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
28
29#include "RunAction.hh"
30
31#include <G4AccumulableManager.hh>
32#include <G4Run.hh>
33#include <G4RunManager.hh>
34#include <G4SystemOfUnits.hh>
35#include <G4UnitsTable.hh>
36#include <G4ios.hh>
37
38#include <cmath>
39
41 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
42 accumulableManager->Register(fEdep);
43 accumulableManager->Register(fEdep2);
44}
45
46void RunAction::BeginOfRunAction(const G4Run* /* run */) {
47 G4AccumulableManager::Instance()->Reset();
48}
49
50void RunAction::EndOfRunAction(const G4Run* run) {
51 G4int nEvents = run->GetNumberOfEvent();
52 if (nEvents == 0) {
53 return;
54 }
55
56 G4AccumulableManager::Instance()->Merge();
57
58 const G4double edep = fEdep.GetValue();
59 const G4double edep2 = fEdep2.GetValue();
60 const G4double rms = edep2 - edep * edep / nEvents;
61 const G4double rmsFinal = (rms > 0.0) ? std::sqrt(rms) : 0.0;
62
63 G4cout << "\n------------------------------------------------------------\n"
64 << " The run consists of " << nEvents << " events\n"
65 << " Cumulated dose in scoring volume (shape2):\n"
66 << " Total edep : " << G4BestUnit(edep, "Energy") << "\n"
67 << " RMS : " << G4BestUnit(rmsFinal, "Energy") << "\n"
68 << "------------------------------------------------------------\n"
69 << G4endl;
70}
71
72void RunAction::AddEdep(G4double edep) {
73 fEdep += edep;
74 fEdep2 += edep * edep;
75}
void BeginOfRunAction(const G4Run *run) override
Definition RunAction.cc:46
void EndOfRunAction(const G4Run *run) override
Definition RunAction.cc:50
void AddEdep(G4double edep)
Add edep to the accumulated energy deposit.
Definition RunAction.cc:72