Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RMC01AnalysisManager.hh
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: RMC01AnalysisManager.hh 98774 2016-08-09 14:28:06Z gcosmo $
30 //
32 // Class Name: RMC01AnalysisManager
33 // Author: L. Desorgher
34 // Organisation: SpaceIT GmbH
35 // Contract: ESA contract 21435/08/NL/AT
36 // Customer: ESA/ESTEC
38 // CHANGE HISTORY
39 //--------------
40 // ChangeHistory:
41 // 17-11-2009 creation by L. Desorgher
42 // 24-11-2009 L.Desorgher,
43 // -registering in Conv* ASCII files every 5000 events the computed
44 // edep with precision.
45 // -Correction of the adjoint computed current and answer matrices
46 // by a factor n_asked/n_processed for the case where a run is aborted
47 // because the user expected precision on e_dep has been reached.
48 // 7-11-2013 L. Desorgher, migrate to the use of G4Histo
49 //
50 //-------------------------------------------------------------
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
55 #ifndef RMC01AnalysisManager_HH
56 #define RMC01AnalysisManager_HH
57 
58 #include"G4ios.hh"
59 #include"G4strstreambuf.hh"
60 #include <vector>
61 #include"globals.hh"
62 #include <fstream>
63 #include"G4ThreeVector.hh"
64 #include"G4Event.hh"
65 #include"G4Run.hh"
66 #include "g4root.hh"
67 
68 class G4Timer;
70 
72 
73 class G4Step;
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79 public:
80 
83 
84  void BeginOfRun(const G4Run*);
85  void EndOfRun(const G4Run*);
86  void BeginOfEvent(const G4Event*);
87  void EndOfEvent(const G4Event*);
88 
90  const G4String& particle_name,
91  G4double fluence,
94  const G4String& particle_name,G4double fluence,
95  G4double alpha, G4double Emin,G4double Emax);
96  //precision of the simulation results is given in % by the user
97  inline void SetPrecision(G4double precision){
98  fPrecision_to_reach =precision/100.;};
99 
100  //Booking and saving of histograms
101  void Book();
102  void Save(G4double scaling_factor);
103 
104 private:
105 
106  static RMC01AnalysisManager* fInstance;
107 
109 
110  void EndOfEventForForwardSimulation(const G4Event* anEvent);
111  void EndOfEventForAdjointSimulation(const G4Event* anEvent);
112  G4double PrimDiffAndDirFluxForAdjointSim(G4double prim_energy);
113  /*
114  void WriteHisto(G4AnaH1* anHisto, G4double scaling_factor,
115  G4String fileName, G4String header_lines);
116  void WriteHisto(G4AnaH2* anHisto, G4double scaling_factor,
117  G4String fileName, G4String header_lines);
118  */
119  void ComputeMeanEdepAndError(const G4Event* anEvent,
120  G4double& mean,G4double& error);
121 
123 
124  //Histos for fwd simulation
125  //--------------
126  G4AnaH1* fEdep_vs_prim_ekin;
127  G4AnaH1* fElectron_current;
128  G4AnaH1* fProton_current;
129  G4AnaH1* fGamma_current;
130 
131  //Fluence
132  //------------
133  //G4double fOmni_fluence_for_fwd_sim;
134 
135  //Variable to check the convergence of the energy deposited
136  // for forward and adjoint simulations
137  //---------------------------------------------------------
138  G4double fAccumulated_edep;
139  G4double fAccumulated_edep2;
140  G4double fNentry;
141  G4double fMean_edep;
142  G4double fError_mean_edep;
143  G4double fRelative_error;
144  G4double fElapsed_time;
145  G4double fPrecision_to_reach;
146  G4bool fStop_run_if_precision_reached;
147  G4int fNb_evt_modulo_for_convergence_test;
148 
149 
150  //Histos for forward and adjoint simulation
151  //-----------------------------
152  G4AnaH1* fEdep_rmatrix_vs_electron_prim_energy;
153  G4AnaH2* fElectron_current_rmatrix_vs_electron_prim_energy;
154  G4AnaH2* fGamma_current_rmatrix_vs_electron_prim_energy;
155 
156  G4AnaH1* fEdep_rmatrix_vs_gamma_prim_energy;
157  G4AnaH2* fElectron_current_rmatrix_vs_gamma_prim_energy;
158  G4AnaH2* fGamma_current_rmatrix_vs_gamma_prim_energy;
159 
160  G4AnaH1* fEdep_rmatrix_vs_proton_prim_energy;
161  G4AnaH2* fElectron_current_rmatrix_vs_proton_prim_energy;
162  G4AnaH2* fProton_current_rmatrix_vs_proton_prim_energy;
163  G4AnaH2* fGamma_current_rmatrix_vs_proton_prim_energy;
164 
165  G4String fFileName[2];
166  G4bool fFactoryOn;
167 
168 
169  //Prim spectrum to which the adjoint simulation will be normalised
170  //Answer matrices will be also registered for post processing
171  //normalisation
172  //--------------------------------------------------------
173  PRIM_SPECTRUM_TYPE fPrimSpectrumType;
174  G4int fPrimPDG_ID;
175  G4double fAlpha_or_E0;
176  G4double fAmplitude_prim_spectrum;
177  G4double fEmin_prim_spectrum;
178  G4double fEmax_prim_spectrum;
179  G4bool fAdjoint_sim_mode;
180  G4int fNb_evt_per_adj_evt;
181 
182  //Timer
183  //------
184  G4Timer* fTimer;
185  std::fstream fConvergenceFileOutput;
186 };
187 
188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
189 
190 #endif
void SetPrimaryPowerLawSpectrumForAdjointSim(const G4String &particle_name, G4double fluence, G4double alpha, G4double Emin, G4double Emax)
void SetPrimaryExpSpectrumForAdjointSim(const G4String &particle_name, G4double fluence, G4double E0, G4double Emin, G4double Emax)
void BeginOfEvent(const G4Event *)
int G4int
Definition: G4Types.hh:78
PRIM_SPECTRUM_TYPE
void SetPrecision(G4double precision)
bool G4bool
Definition: G4Types.hh:79
Definition: G4Run.hh:46
void EndOfRun(const G4Run *)
Definition: G4Step.hh:76
void Save(G4double scaling_factor)
static RMC01AnalysisManager * GetInstance()
void EndOfEvent(const G4Event *)
void BeginOfRun(const G4Run *)
static const G4double Emin
static const G4double Emax
tools::histo::h1d G4AnaH1
Definition: g4root_defs.hh:46
static PROLOG_HANDLER error
Definition: xmlrole.cc:112
tools::histo::h2d G4AnaH2
Definition: g4root_defs.hh:52
double G4double
Definition: G4Types.hh:76
static const G4double alpha