G4AdjointCSManager.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id: G4AdjointCSManager.hh 69844 2013-05-16 09:19:33Z gcosmo $
00027 //
00029 //      Class:          G4AdjointCSManager
00030 //      Author:         L. Desorgher
00031 //      Organisation:   SpaceIT GmbH
00032 //      Contract:       ESA contract 21435/08/NL/AT
00033 //      Customer:       ESA/ESTEC
00035 //
00036 // CHANGE HISTORY
00037 // --------------
00038 //      ChangeHistory: 
00039 //              1st April 2007 creation by L. Desorgher                 
00040 //              
00041 //              September-October 2009. Implementation of the mode where the adjoint cross sections are scaled such that the total used adjoint cross sections is in 
00042 //              most of the cases equal to the total forward cross section. L.Desorgher
00043 //
00044 //-------------------------------------------------------------
00045 //      Documentation:
00046 //              Is responsible for the management of all adjoint cross sections matrices, and for the computation of the total forward and adjoint cross sections.
00047 //              Total adjoint and forward cross sections are needed to correct the weight of a particle after a tracking step or after the occurence of a reverse reaction. 
00048 //              It is also used to sample an adjoint secondary from a given adjoint cross section matrix.
00049 //
00050 #ifndef G4AdjointCSManager_h
00051 #define G4AdjointCSManager_h 1
00052 
00053 #include"globals.hh"
00054 #include<vector>
00055 #include"G4AdjointCSMatrix.hh"
00056 
00057 
00058 class G4VEmAdjointModel;
00059 class G4MaterialCutsCouple;
00060 class G4Material;
00061 class G4ParticleDefinition;
00062 class G4Element;
00063 class G4VEmProcess;
00064 class G4VEnergyLossProcess;
00065 class G4PhysicsTable;
00066 
00068 //
00069 class G4AdjointCSManager
00070 {
00071         
00072   public:
00073         ~G4AdjointCSManager();
00074         static G4AdjointCSManager* GetAdjointCSManager();
00075 
00076   public:
00077         G4int GetNbProcesses();
00078         
00079         //Registration of the different models and processes
00080         
00081         size_t RegisterEmAdjointModel(G4VEmAdjointModel*);
00082         
00083         void RegisterEmProcess(G4VEmProcess* aProcess, G4ParticleDefinition* aPartDef);
00084         
00085         void RegisterEnergyLossProcess(G4VEnergyLossProcess* aProcess, G4ParticleDefinition* aPartDef);
00086         
00087         void RegisterAdjointParticle(G4ParticleDefinition* aPartDef);
00088         
00089         //Building of the CS Matrices and Total Forward and Adjoint LambdaTables
00090         //----------------------------------------------------------------------
00091         
00092         void BuildCrossSectionMatrices();
00093         void BuildTotalSigmaTables();
00094         
00095         
00096         //Get TotalCrossSections form Total Lambda Tables, Needed for Weight correction and scaling of the 
00097         //-------------------------------------------------
00098         G4double GetTotalAdjointCS(G4ParticleDefinition* aPartDef, G4double Ekin,
00099                                      const G4MaterialCutsCouple* aCouple);
00100         G4double GetTotalForwardCS(G4ParticleDefinition* aPartDef, G4double Ekin,
00101                                      const G4MaterialCutsCouple* aCouple);
00102         
00103         G4double GetAdjointSigma(G4double Ekin_nuc, size_t index_model,G4bool is_scat_proj_to_proj,
00104                                      const G4MaterialCutsCouple* aCouple);
00105         
00106         void GetEminForTotalCS(G4ParticleDefinition* aPartDef,
00107                                      const G4MaterialCutsCouple* aCouple, G4double& emin_adj, G4double& emin_fwd);
00108         void GetMaxFwdTotalCS(G4ParticleDefinition* aPartDef,
00109                                      const G4MaterialCutsCouple* aCouple, G4double& e_sigma_max, G4double& sigma_max);
00110         void GetMaxAdjTotalCS(G4ParticleDefinition* aPartDef,
00111                                      const G4MaterialCutsCouple* aCouple, G4double& e_sigma_max, G4double& sigma_max);
00112                                      
00113                                                                                      
00114         
00115         //CrossSection Correction  1 or FwdCS/AdjCS following the G4boolean value of forward_CS_is_used and forward_CS_mode
00116         //-------------------------------------------------
00117         G4double GetCrossSectionCorrection(G4ParticleDefinition* aPartDef,G4double PreStepEkin,const G4MaterialCutsCouple* aCouple, G4bool& fwd_is_used, G4double& fwd_TotCS);
00118         
00119         
00120         //Cross section mode
00121         //------------------
00122         inline void SetFwdCrossSectionMode(G4bool aBool){forward_CS_mode=aBool;}
00123         
00124         
00125         //Weight correction 
00126         //------------------
00127         
00128         G4double GetContinuousWeightCorrection(G4ParticleDefinition* aPartDef, G4double PreStepEkin,G4double AfterStepEkin,
00129                                      const G4MaterialCutsCouple* aCouple, G4double step_length);
00130         G4double GetPostStepWeightCorrection();
00131                                      
00132         
00133         
00134         
00135         //Method Called by the adjoint model to get there CS, if not precised otherwise
00136         //-------------------------------
00137         
00138         G4double ComputeAdjointCS(G4Material* aMaterial,
00139                                             G4VEmAdjointModel* aModel, 
00140                                             G4double PrimEnergy,
00141                                             G4double Tcut,
00142                                             G4bool IsScatProjToProjCase,
00143                                             std::vector<G4double>& 
00144                                                  AdjointCS_for_each_element);
00145                                          
00146         //Method Called by the adjoint model to sample the secondary energy form the CS matrix
00147         //--------------------------------------------------------------------------------
00148         G4Element*  SampleElementFromCSMatrices(G4Material* aMaterial,
00149                                                        G4VEmAdjointModel* aModel,
00150                                                        G4double PrimEnergy,
00151                                                         G4double Tcut,
00152                                                        G4bool IsScatProjToProjCase);
00153                                                        
00154                                                        
00155         //Total Adjoint CS  is computed at initialisation phase 
00156         //-----------------------------------------------------                                        
00157         G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple* aMatCutCouple,G4ParticleDefinition* aPart,G4double PrimEnergy);
00158         
00159         
00160         
00161                                                                 
00162         G4ParticleDefinition* GetAdjointParticleEquivalent(G4ParticleDefinition* theFwdPartDef);
00163         G4ParticleDefinition* GetForwardParticleEquivalent(G4ParticleDefinition* theAdjPartDef);
00164         
00165         //inline
00166         inline void SetTmin(G4double aVal){Tmin=aVal;}
00167         inline void SetTmax(G4double aVal){Tmax=aVal;}
00168         inline void SetNbins(G4int aInt){nbins=aInt;}
00169         inline void SetIon(G4ParticleDefinition* adjIon,
00170                            G4ParticleDefinition* fwdIon) {theAdjIon=adjIon; theFwdIon =fwdIon;}
00171         
00172         
00173   private:
00174         static  G4AdjointCSManager* theInstance;
00175         std::vector< std::vector<G4AdjointCSMatrix*> > theAdjointCSMatricesForScatProjToProj; //x dim is for G4VAdjointEM* while y dim is for elements
00176         std::vector< std::vector<G4AdjointCSMatrix*> > theAdjointCSMatricesForProdToProj;
00177         std::vector< G4VEmAdjointModel*> listOfAdjointEMModel;
00178                 
00179         std::vector<G4AdjointCSMatrix*> 
00180                                 BuildCrossSectionsMatricesForAGivenModelAndElement(G4VEmAdjointModel* aModel,
00181                                                                                    G4int Z,
00182                                                                                    G4int A,
00183                                                                                    G4int nbin_pro_decade);
00184         
00185         std::vector<G4AdjointCSMatrix*> 
00186                                 BuildCrossSectionsMatricesForAGivenModelAndMaterial(G4VEmAdjointModel* aModel,
00187                                                                                    G4Material* aMaterial,
00188                                                                                    G4int nbin_pro_decade);
00189         
00190         
00191         G4Material* lastMaterial;
00192         G4double    lastPrimaryEnergy;
00193         G4double    lastTcut;   
00194         std::vector< size_t> listOfIndexOfAdjointEMModelInAction;
00195         std::vector< G4bool> listOfIsScatProjToProjCase;
00196         std::vector< std::vector<G4double> > lastAdjointCSVsModelsAndElements;
00197         G4bool CrossSectionMatrixesAreBuilt;
00198         size_t  currentParticleIndex;
00199         G4ParticleDefinition* currentParticleDef;
00200         
00201         //total adjoint and total forward cross section table in function of material and in function of adjoint particle type
00202         //--------------------------------------------------------------------------------------------------------------------
00203         std::vector<G4PhysicsTable*>        theTotalForwardSigmaTableVector;
00204         std::vector<G4PhysicsTable*>        theTotalAdjointSigmaTableVector;
00205         std::vector< std::vector<G4double> >    EminForFwdSigmaTables;  
00206         std::vector< std::vector<G4double> >    EminForAdjSigmaTables;  
00207         std::vector< std::vector<G4double> >    EkinofFwdSigmaMax;      
00208         std::vector< std::vector<G4double> >    EkinofAdjSigmaMax;
00209         G4bool TotalSigmaTableAreBuilt;
00210         
00211         //Sigma tavle for each G4VAdjointEMModel 
00212         std::vector<G4PhysicsTable*>        listSigmaTableForAdjointModelScatProjToProj;
00213         std::vector<G4PhysicsTable*>        listSigmaTableForAdjointModelProdToProj;
00214         
00215 
00216         
00217          
00218         //list of forward G4VEMLossProcess and of G4VEMProcess for the different adjoint particle
00219         //--------------------------------------------------------------
00220         std::vector< std::vector<G4VEmProcess*>* >              listOfForwardEmProcess;
00221         std::vector< std::vector<G4VEnergyLossProcess*>* >      listOfForwardEnergyLossProcess;
00222         
00223         //list of adjoint particles considered
00224         //--------------------------------------------------------------
00225         std::vector< G4ParticleDefinition*> theListOfAdjointParticlesInAction;
00226         
00227         
00228         G4double Tmin,Tmax;
00229         G4int nbins;
00230         
00231         
00232         //Current material
00233         //----------------
00234         G4MaterialCutsCouple* currentCouple;  
00235         G4Material* currentMaterial;
00236         size_t  currentMatIndex;
00237         
00238         G4int verbose;
00239         
00240         
00241         
00242         
00243         //Two CS mode are possible :forward_CS_mode = false the Adjoint CS are used as it is implying a AlongStep Weight Correction.
00244         //                         :forward_CS_mode = true the Adjoint CS are scaled to have the total adjoint CS eual to the fwd one implying a PostStep Weight Correction.
00245         //                                           For energy range  where the total FwdCS or the total adjoint CS are null, the scaling is not possble and
00246         //                                           forward_CS_is_used is set to false         
00247         //--------------------------------------------
00248         G4bool forward_CS_is_used;
00249         G4bool forward_CS_mode;
00250         
00251         //Adj and Fwd CS values for re-use 
00252         //------------------------
00253         
00254         G4double PreadjCS,PostadjCS;
00255         G4double PrefwdCS,PostfwdCS;
00256         G4double LastEkinForCS;
00257         G4double LastCSCorrectionFactor;
00258         G4ParticleDefinition* lastPartDefForCS;
00259         
00260         //Ion
00261         //----------------
00262         G4ParticleDefinition* theAdjIon; //at the moment Only one ion can be considered by simulation
00263         G4ParticleDefinition* theFwdIon;
00264         G4double massRatio;
00265         
00266         
00267         
00268 
00269   private:
00270         G4AdjointCSManager();  
00271         void DefineCurrentMaterial(const G4MaterialCutsCouple* couple);
00272         void DefineCurrentParticle(const G4ParticleDefinition* aPartDef);
00273         G4double ComputeAdjointCS(G4double aPrimEnergy, G4AdjointCSMatrix* anAdjointCSMatrix, G4double Tcut);
00274         size_t eindex;
00275 
00276 };
00277 #endif

Generated on Mon May 27 17:47:37 2013 for Geant4 by  doxygen 1.4.7