Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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$
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 {
48  n_gam_sync = 0;
49  e_gam_sync = 0;
50  e_gam_sync2 = 0;
51  e_gam_sync_max =0;
52  lam_gam_sync = 0;
53  fHistoManager = new HistoManager();
54 }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 {
60  delete fHistoManager;
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
65 void RunAction::BeginOfRunAction(const G4Run* aRun)
66 {
67  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
68 
69  // save Rndm status
72 
73  //histograms
74  //
75  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
76  if ( analysisManager->IsActive() ) {
77  analysisManager->OpenFile();
78  }
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85  if(n_gam_sync>0)
86  {
88  G4double E_rms = std::sqrt(e_gam_sync2/n_gam_sync - Emean*Emean);
89  G4cout
90  << "Summary for synchrotron radiation :" << '\n' << std::setprecision(4)
91  << " Number of photons = " << n_gam_sync << '\n'
92  << " Emean = " << Emean/keV << " +/- "
93  << E_rms/(keV * std::sqrt((G4double) n_gam_sync)) << " keV" << '\n'
94  << " E_rms = " << G4BestUnit(E_rms,"Energy") << '\n'
95  << " Energy Max / Mean = " << e_gam_sync_max / Emean << '\n'
96  << " MeanFreePath = " << G4BestUnit(lam_gam_sync/n_gam_sync,"Length")
97  << G4endl;
98  }
99 
100  // show Rndm status
102 
103  //save histograms
104  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
105  if ( analysisManager->IsActive() ) {
106  analysisManager->Write();
107  analysisManager->CloseFile();
108  }
109 }
110 
111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......