Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/extended/biasing/ReverseMC01/include/RMC01AnalysisManager.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file RMC01AnalysisManager.hh
0027 /// \brief Definition of the RMC01AnalysisManager class
0028 
0029 //  Class Name:            RMC01AnalysisManager
0030 //        Author:               L. Desorgher
0031 //        Organisation:         SpaceIT GmbH
0032 //        Contract:        ESA contract 21435/08/NL/AT
0033 //        Customer:             ESA/ESTEC
0034 //////////////////////////////////////////////////////////////
0035 // CHANGE HISTORY
0036 //--------------
0037 //      ChangeHistory:
0038 //        17-11-2009 creation by L. Desorgher
0039 //        24-11-2009 L.Desorgher,
0040 //           -registering in  Conv* ASCII files every 5000 events the computed
0041 //                edep with  precision.
0042 //           -Correction of the adjoint computed current and answer matrices
0043 //           by a factor n_asked/n_processed for the case where a run is aborted
0044 //          because the user expected precision on e_dep has been reached.
0045 //        7-11-2013 L. Desorgher, migrate to the use of G4Histo
0046 //
0047 //-------------------------------------------------------------
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 #ifndef RMC01AnalysisManager_HH
0053 #define RMC01AnalysisManager_HH
0054 
0055 #include "G4ios.hh"
0056 //#include "G4strstreambuf.hh"
0057 #include <vector>
0058 #include "globals.hh"
0059 #include <fstream>
0060 #include "G4ThreeVector.hh"
0061 #include "G4Accumulable.hh"
0062 #include "G4ThreadLocalSingleton.hh"
0063 #include "G4Event.hh"
0064 #include "G4Run.hh"
0065 #include"G4AnalysisManager.hh"
0066 #include "RMC01Analysis.hh"
0067 
0068 
0069 class G4Timer;
0070 class RMC01AnalysisManagerMessenger;
0071 
0072 enum PRIM_SPECTRUM_TYPE{EXPO,POWER,USER};
0073 
0074 class G4Step;
0075 
0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0077 using G4AnaH1 = tools::histo::h1d; // keep for backward compatibility
0078 using G4AnaH2 = tools::histo::h2d; // keep for backward compatibility
0079 //
0080 
0081 class RMC01AnalysisManager
0082 {
0083   friend class G4ThreadLocalSingleton <RMC01AnalysisManager>;
0084 
0085   public:
0086   
0087     ~RMC01AnalysisManager();
0088     static RMC01AnalysisManager* GetInstance();
0089 
0090     void BeginOfRun(const G4Run*); 
0091     void EndOfRun(const G4Run*); 
0092     void BeginOfEvent(const G4Event*); 
0093     void EndOfEvent(const G4Event*); 
0094    
0095     void SetPrimaryExpSpectrumForAdjointSim(const G4String& particle_name,
0096                                             G4double fluence, G4double E0,
0097                                             G4double Emin, G4double Emax);
0098     void SetPrimaryPowerLawSpectrumForAdjointSim(
0099                                             const G4String& particle_name,
0100                                             G4double fluence, G4double alpha,
0101                                             G4double Emin, G4double Emax);
0102 
0103 
0104 
0105     void SetUserDefinedSpectrumPointForAdjointSim(
0106                                             const G4String& particle_name,
0107                                             G4double fluence,
0108                                             G4bool is_arbitrary_point_wise=true);
0109 
0110     // Precision of the simulation results is given in % by the user
0111     //
0112     inline void SetPrecision(G4double precision)
0113     {
0114       fPrecision_to_reach =precision/100.;
0115     }
0116 
0117     inline void SetEventWeightFactor(G4double factor)
0118     {
0119       fevent_weight_factor=factor;
0120     }
0121 
0122     // Booking and saving of histograms
0123     //
0124     void Book();
0125     void Save(G4double scaling_factor);
0126 
0127   private:
0128 
0129     RMC01AnalysisManager(); 
0130   
0131     void EndOfEventForForwardSimulation(const G4Event* anEvent);
0132     void EndOfEventForAdjointSimulation(const G4Event* anEvent);
0133     G4double PrimDiffAndDirFluxForAdjointSim(G4double prim_energy);
0134 
0135     void ComputeMeanEdepAndError(G4double& mean, G4double& error,
0136                                  G4int nb_of_global_evt);
0137   
0138     RMC01AnalysisManagerMessenger* fMsg;
0139   
0140     // Histos for fwd simulation
0141     //--------------
0142     G4AnaH1* fEdep_vs_prim_ekin;
0143     G4AnaH1* fElectron_current;
0144     G4AnaH1* fProton_current;
0145     G4AnaH1* fGamma_current;
0146   
0147     // Fluence
0148     //------------
0149     //G4double fOmni_fluence_for_fwd_sim;
0150   
0151     // Variable to check the convergence of the energy deposited
0152     //             for forward and adjoint simulations
0153     //---------------------------------------------------------
0154     G4Accumulable<G4double> fAccumulated_edep;
0155     G4Accumulable<G4double> fAccumulated_edep2;
0156     G4double fMean_edep;
0157     G4double fError_mean_edep;
0158     G4double fRelative_error;
0159     G4double fElapsed_time;
0160     G4double fPrecision_to_reach;
0161     G4bool fStop_run_if_precision_reached;
0162     G4int fNb_evt_modulo_for_convergence_test;
0163 
0164     // Histos for forward and adjoint simulation
0165     //-----------------------------
0166     G4AnaH1* fEdep_rmatrix_vs_electron_prim_energy;
0167     G4AnaH2* fElectron_current_rmatrix_vs_electron_prim_energy;
0168     G4AnaH2* fGamma_current_rmatrix_vs_electron_prim_energy;
0169   
0170     G4AnaH1* fEdep_rmatrix_vs_gamma_prim_energy;
0171     G4AnaH2* fElectron_current_rmatrix_vs_gamma_prim_energy;
0172     G4AnaH2* fGamma_current_rmatrix_vs_gamma_prim_energy;
0173   
0174     G4AnaH1* fEdep_rmatrix_vs_proton_prim_energy;
0175     G4AnaH2* fElectron_current_rmatrix_vs_proton_prim_energy;
0176     G4AnaH2* fProton_current_rmatrix_vs_proton_prim_energy;
0177     G4AnaH2* fGamma_current_rmatrix_vs_proton_prim_energy;
0178 
0179     G4String fFileName[2];
0180     G4bool fFactoryOn;
0181 
0182     // Prim spectrum to which the adjoint simulation will be normalised
0183     // Answer matrices will be also registered for post processing
0184     // normalisation
0185     //--------------------------------------------------------
0186     PRIM_SPECTRUM_TYPE fPrimSpectrumType;
0187     G4int fPrimPDG_ID;
0188     G4double fAlpha_or_E0;
0189     G4double fAmplitude_prim_spectrum;
0190     G4double fEmin_prim_spectrum;
0191     G4double fEmax_prim_spectrum;
0192     G4bool fAdjoint_sim_mode;
0193     G4int fNb_evt_per_adj_evt;
0194     std::vector<G4double> f_energy_vec; //User spectrum
0195     std::vector<G4double> f_flux_vec; //User spectrum
0196     G4double fevent_weight_factor;
0197 
0198     // Timer
0199     //------
0200     G4bool fIsEndOfRun;
0201 };
0202 
0203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0204 
0205 #endif