Geant4 Cross Reference |
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 // 26 /// \file biasing/ReverseMC01/include/RMC01AnalysisManager.hh 27 /// \brief Definition of the RMC01AnalysisManager class 28 // 29 // 30 ////////////////////////////////////////////////////////////// 31 // Class Name: RMC01AnalysisManager 32 // Author: L. Desorgher 33 // Organisation: SpaceIT GmbH 34 // Contract: ESA contract 21435/08/NL/AT 35 // Customer: ESA/ESTEC 36 ////////////////////////////////////////////////////////////// 37 // CHANGE HISTORY 38 //-------------- 39 // ChangeHistory: 40 // 17-11-2009 creation by L. Desorgher 41 // 24-11-2009 L.Desorgher, 42 // -registering in Conv* ASCII files every 5000 events the computed 43 // edep with precision. 44 // -Correction of the adjoint computed current and answer matrices 45 // by a factor n_asked/n_processed for the case where a run is aborted 46 // because the user expected precision on e_dep has been reached. 47 // 7-11-2013 L. Desorgher, migrate to the use of G4Histo 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 "G4AnalysisManager.hh" 58 #include "G4Event.hh" 59 #include "G4Run.hh" 60 #include "G4ThreeVector.hh" 61 #include "G4ios.hh" 62 #include "g4hntools_defs.hh" 63 #include "globals.hh" 64 65 #include <fstream> 66 #include <vector> 67 68 class G4Timer; 69 class RMC01AnalysisManagerMessenger; 70 71 enum PRIM_SPECTRUM_TYPE 72 { 73 EXPO, 74 POWER 75 }; 76 77 class G4Step; 78 79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 80 81 class RMC01AnalysisManager 82 { 83 public: 84 ~RMC01AnalysisManager(); 85 static RMC01AnalysisManager* GetInstance(); 86 87 void BeginOfRun(const G4Run*); 88 void EndOfRun(const G4Run*); 89 void BeginOfEvent(const G4Event*); 90 void EndOfEvent(const G4Event*); 91 92 void SetPrimaryExpSpectrumForAdjointSim(const G4String& particle_name, G4double fluence, 93 G4double E0, G4double Emin, G4double Emax); 94 void SetPrimaryPowerLawSpectrumForAdjointSim(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) { fPrecision_to_reach = precision / 100.; }; 98 99 // Booking and saving of histograms 100 void Book(); 101 void Save(G4double scaling_factor); 102 103 private: 104 static RMC01AnalysisManager* fInstance; 105 106 RMC01AnalysisManager(); 107 108 void EndOfEventForForwardSimulation(const G4Event* anEvent); 109 void EndOfEventForAdjointSimulation(const G4Event* anEvent); 110 G4double PrimDiffAndDirFluxForAdjointSim(G4double prim_energy); 111 /* 112 void WriteHisto(G4H1* anHisto, G4double scaling_factor, 113 G4String fileName, G4String header_lines); 114 void WriteHisto(G4H2* anHisto, G4double scaling_factor, 115 G4String fileName, G4String header_lines); 116 */ 117 void ComputeMeanEdepAndError(const G4Event* anEvent, G4double& mean, G4double& error); 118 119 RMC01AnalysisManagerMessenger* fMsg; 120 121 // Histos for fwd simulation 122 //-------------- 123 G4H1* fEdep_vs_prim_ekin; 124 G4H1* fElectron_current; 125 G4H1* fProton_current; 126 G4H1* fGamma_current; 127 128 // Fluence 129 //------------ 130 // G4double fOmni_fluence_for_fwd_sim; 131 132 // Variable to check the convergence of the energy deposited 133 // for forward and adjoint simulations 134 //--------------------------------------------------------- 135 G4double fAccumulated_edep; 136 G4double fAccumulated_edep2; 137 G4double fNentry; 138 G4double fMean_edep; 139 G4double fError_mean_edep; 140 G4double fRelative_error; 141 G4double fElapsed_time; 142 G4double fPrecision_to_reach; 143 G4bool fStop_run_if_precision_reached; 144 G4int fNb_evt_modulo_for_convergence_test; 145 146 // Histos for forward and adjoint simulation 147 //----------------------------- 148 G4H1* fEdep_rmatrix_vs_electron_prim_energy; 149 G4H2* fElectron_current_rmatrix_vs_electron_prim_energy; 150 G4H2* fGamma_current_rmatrix_vs_electron_prim_energy; 151 152 G4H1* fEdep_rmatrix_vs_gamma_prim_energy; 153 G4H2* fElectron_current_rmatrix_vs_gamma_prim_energy; 154 G4H2* fGamma_current_rmatrix_vs_gamma_prim_energy; 155 156 G4H1* fEdep_rmatrix_vs_proton_prim_energy; 157 G4H2* fElectron_current_rmatrix_vs_proton_prim_energy; 158 G4H2* fProton_current_rmatrix_vs_proton_prim_energy; 159 G4H2* fGamma_current_rmatrix_vs_proton_prim_energy; 160 161 G4String fFileName[2]; 162 G4bool fFactoryOn; 163 164 // Prim spectrum to which the adjoint simulation will be normalised 165 // Answer matrices will be also registered for post processing 166 // normalisation 167 //-------------------------------------------------------- 168 PRIM_SPECTRUM_TYPE fPrimSpectrumType; 169 G4int fPrimPDG_ID; 170 G4double fAlpha_or_E0; 171 G4double fAmplitude_prim_spectrum; 172 G4double fEmin_prim_spectrum; 173 G4double fEmax_prim_spectrum; 174 G4bool fAdjoint_sim_mode; 175 G4int fNb_evt_per_adj_evt; 176 177 // Timer 178 //------ 179 G4Timer* fTimer; 180 std::fstream fConvergenceFileOutput; 181 }; 182 183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 184 185 #endif 186