Geant4  9.6.p02
 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$
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 //
49 //-------------------------------------------------------------
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
54 #ifndef RMC01AnalysisManager_HH
55 #define RMC01AnalysisManager_HH
56 
57 #include"G4ios.hh"
58 #include"G4strstreambuf.hh"
59 #include <vector>
60 #include"globals.hh"
61 #include <fstream>
62 #include"G4ThreeVector.hh"
63 #include"G4Event.hh"
64 #include"G4Run.hh"
65 
66 class Histo1DVar;
67 class Histo2DVar;
68 class G4Timer;
70 
72 
73 class G4Step;
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79 public:
80 
83 
84  public:
85 
86  void BeginOfRun(const G4Run*);
87  void EndOfRun(const G4Run*);
88  void BeginOfEvent(const G4Event*);
89  void EndOfEvent(const G4Event*);
90 
92  const G4String& particle_name, G4double fluence,
93  G4double E0, G4double Emin,G4double Emax);
95  const G4String& particle_name,G4double fluence,
96  G4double alpha, G4double Emin,G4double Emax);
97  //precision of the simulation results is given in % by the user
98  inline void SetPrecision(G4double precision){
99  fPrecision_to_reach =precision/100.;};
100 
101 private:
102 
103  static RMC01AnalysisManager* fInstance;
104 
105 private:
106 
108 private:
109 
110  void EndOfEventForForwardSimulation(const G4Event* anEvent);
111  void EndOfEventForAdjointSimulation(const G4Event* anEvent);
112  G4double PrimDiffAndDirFluxForAdjointSim(G4double prim_energy);
113  void WriteHisto(Histo1DVar* anHisto, G4double scaling_factor,
114  G4String fileName, G4String header_lines);
115  void WriteHisto(Histo2DVar* anHisto, G4double scaling_factor,
116  G4String fileName, G4String header_lines);
117  void ResetHistograms();
118  void ComputeMeanEdepAndError(const G4Event* anEvent,
119  G4double& mean,G4double& error);
120 
121 private:
122 
124 
125  //Histos for fwd simulation
126  //--------------
127  Histo1DVar* fEdep_vs_prim_ekin;
128  Histo1DVar* fElectron_current;
129  Histo1DVar* fProton_current;
130  Histo1DVar* fGamma_current;
131 
132  //Fluence
133  //------------
134  G4double fOmni_fluence_for_fwd_sim;
135 
136  //Variable to check the convergence of the energy deposited
137  // for forward and adjoint simulations
138  //---------------------------------------------------------
139  G4double fAccumulated_edep;
140  G4double fAccumulated_edep2;
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 adjoint simulation
151  //-----------------------------
152  Histo1DVar* fEdep_rmatrix_vs_electron_prim_energy;
153  Histo2DVar* fElectron_current_rmatrix_vs_electron_prim_energy;
154  Histo2DVar* fGamma_current_rmatrix_vs_electron_prim_energy;
155 
156  Histo1DVar* fEdep_rmatrix_vs_gamma_prim_energy;
157  Histo2DVar* fElectron_current_rmatrix_vs_gamma_prim_energy;
158  Histo2DVar* fGamma_current_rmatrix_vs_gamma_prim_energy;
159 
160  Histo1DVar* fEdep_rmatrix_vs_proton_prim_energy;
161  Histo2DVar* fElectron_current_rmatrix_vs_proton_prim_energy;
162  Histo2DVar* fProton_current_rmatrix_vs_proton_prim_energy;
163  Histo2DVar* fGamma_current_rmatrix_vs_proton_prim_energy;
164 
165 
166  //Prim spectrum to which the adjoint simulation will be normalised
167  //Answer matrices will be also registered for post processing normalisation
168  //--------------------------------------------------------
169  PRIM_SPECTRUM_TYPE fPrimSpectrumType;
170  G4int fPrimPDG_ID;
171  G4double fAlpha_or_E0;
172  G4double fAmplitude_prim_spectrum;
173  G4double fEmin_prim_spectrum;
174  G4double fEmax_prim_spectrum;
175  G4bool fAdjoint_sim_mode;
176  G4int fNb_evt_per_adj_evt;
177 
178  //Timer
179  //------
180  G4Timer* fTimer;
181  std::fstream fConvergenceFileOutput;
182 
183 };
184 
185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
186 
187 #endif