Geant4  10.00.p01
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 // $Id: RunAction.cc 67797 2013-03-08 09:52:18Z maire $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "RunAction.hh"
35 
36 #include "G4Run.hh"
37 #include "G4RunManager.hh"
38 #include "G4UnitsTable.hh"
39 #include "G4SystemOfUnits.hh"
40 
41 #include "Randomize.hh"
42 #include "HistoManager.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47  : G4UserRunAction(),
48  fHistoManager(0)
49 {
50  f_n_gam_sync = 0;
51  f_e_gam_sync = 0;
52  f_e_gam_sync2 = 0;
53  f_e_gam_sync_max = 0;
54  f_lam_gam_sync = 0;
55  fHistoManager = new HistoManager();
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  delete fHistoManager;
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
67 void RunAction::BeginOfRunAction(const G4Run* aRun)
68 {
69  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
70 
71  // save Rndm status
73  CLHEP::HepRandom::showEngineStatus();
74 
75  //histograms
76  //
77  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
78  if ( analysisManager->IsActive() ) {
79  analysisManager->OpenFile();
80  }
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
87  if (f_n_gam_sync > 0)
88  {
90  G4double E_rms = std::sqrt(f_e_gam_sync2/f_n_gam_sync - Emean*Emean);
91  G4cout
92  << "Summary for synchrotron radiation :" << '\n' << std::setprecision(4)
93  << " Number of photons = " << f_n_gam_sync << '\n'
94  << " Emean = " << Emean/keV << " +/- "
95  << E_rms/(keV * std::sqrt((G4double) f_n_gam_sync)) << " keV" << '\n'
96  << " E_rms = " << G4BestUnit(E_rms,"Energy") << '\n'
97  << " Energy Max / Mean = " << f_e_gam_sync_max / Emean << '\n'
98  << " MeanFreePath = " << G4BestUnit(f_lam_gam_sync/f_n_gam_sync,"Length")
99  << G4endl;
100  }
101 
102  // show Rndm status
103  CLHEP::HepRandom::showEngineStatus();
104 
105  //save histograms
106  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
107  if ( analysisManager->IsActive() ) {
108  analysisManager->Write();
109  analysisManager->CloseFile();
110  }
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void BeginOfRunAction(const G4Run *)
Definition: RunAction.cc:57
G4double f_e_gam_sync2
Definition: RunAction.hh:58
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4int f_n_gam_sync
Definition: RunAction.hh:57
HistoManager * fHistoManager
Definition: RunAction.hh:60
G4GLOB_DLL std::ostream G4cout
void EndOfRunAction(const G4Run *)
Definition: RunAction.cc:260
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:46
G4double f_e_gam_sync_max
Definition: RunAction.hh:59
~RunAction()
Definition: RunAction.cc:52
G4double f_e_gam_sync
Definition: RunAction.hh:58
#define G4endl
Definition: G4ios.hh:61
G4double f_lam_gam_sync
Definition: RunAction.hh:60
static const double keV
Definition: G4SIunits.hh:195
double G4double
Definition: G4Types.hh:76