Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 ////////////////////////////////////////////// << 26 ///////////////////////////////////////////////////////////////////////////////// 27 // Class: G4AdjointCSManager << 27 // Module: G4AdjointCSManager.hh 28 // Author: L. Desorgher << 28 // Author: L. Desorgher 29 // Organisation: SpaceIT GmbH << 29 // Date: 1st April 2007 >> 30 // Organisation: SpaceIT GmbH >> 31 // Customer: ESA/ESTEC >> 32 ///////////////////////////////////////////////////////////////////////////////// 30 // 33 // 31 // Class is responsible for the management of << 34 // CHANGE HISTORY 32 // matrices, and for the computation of the to << 35 // -------------- 33 // sections. Total adjoint and forward cross s << 36 // ChangeHistory: 34 // weight of a particle after a tracking step << 37 // 1st April 2007 creation by L. Desorgher 35 // reverse reaction. It is also used to sample << 38 // 36 // given adjoint cross section matrix. << 39 //------------------------------------------------------------- >> 40 // Documentation: >> 41 // Is responsible for the management of all adjoint cross sections matrices, and for the computation of the total forward and adjoint cross sections. >> 42 // Total adjoint and forward cross sections are needed to correct continuously the weight of a particle after a tracking step. >> 43 // It is also used to sample an adjoint secondary from a given adjoint cross section matrix. 37 // 44 // 38 ////////////////////////////////////////////// << 39 << 40 #ifndef G4AdjointCSManager_h 45 #ifndef G4AdjointCSManager_h 41 #define G4AdjointCSManager_h 1 46 #define G4AdjointCSManager_h 1 42 47 43 #include "globals.hh" << 48 #include"globals.hh" 44 #include "G4AdjointCSMatrix.hh" << 49 #include<vector> 45 #include "G4ThreadLocalSingleton.hh" << 50 #include"G4AdjointCSMatrix.hh" 46 51 47 #include <vector> << 48 52 49 class G4Element; << 53 class G4VEmAdjointModel; 50 class G4Material; << 51 class G4MaterialCutsCouple; 54 class G4MaterialCutsCouple; >> 55 class G4Material; 52 class G4ParticleDefinition; 56 class G4ParticleDefinition; 53 class G4PhysicsTable; << 57 class G4Element; 54 class G4VEmProcess; 58 class G4VEmProcess; 55 class G4VEmAdjointModel; << 56 class G4VEnergyLossProcess; 59 class G4VEnergyLossProcess; >> 60 class G4PhysicsTable; 57 61 >> 62 //////////////////////////////////////////////////////////////////////////////// >> 63 // 58 class G4AdjointCSManager 64 class G4AdjointCSManager 59 { 65 { 60 friend class G4ThreadLocalSingleton<G4Adjoin << 66 61 << 67 public: 62 public: << 68 ~G4AdjointCSManager(); 63 ~G4AdjointCSManager(); << 69 static G4AdjointCSManager* GetAdjointCSManager(); 64 static G4AdjointCSManager* GetAdjointCSManag << 70 65 << 71 public: 66 G4int GetNbProcesses(); << 72 G4int GetNbProcesses(); 67 << 73 68 // Registration of the different models and << 74 //Registration of the different models and processes 69 << 75 70 std::size_t RegisterEmAdjointModel(G4VEmAdjo << 76 void RegisterEmAdjointModel(G4VEmAdjointModel*); 71 << 77 72 void RegisterEmProcess(G4VEmProcess* aProces << 78 void RegisterEmProcess(G4VEmProcess* aProcess, G4ParticleDefinition* aPartDef); 73 G4ParticleDefinition* << 79 74 << 80 void RegisterEnergyLossProcess(G4VEnergyLossProcess* aProcess, G4ParticleDefinition* aPartDef); 75 void RegisterEnergyLossProcess(G4VEnergyLoss << 81 76 G4ParticleDef << 82 void RegisterAdjointParticle(G4ParticleDefinition* aPartDef); 77 << 83 78 void RegisterAdjointParticle(G4ParticleDefin << 84 //Building of thr CS Matrices and Total Forward and Adjoint LambdaTables 79 << 85 //---------------------------------------------------------------------- 80 // Building of the CS Matrices and Total For << 86 81 void BuildCrossSectionMatrices(); << 87 void BuildCrossSectionMatrices(); 82 << 88 void BuildTotalSigmaTables(); 83 void BuildTotalSigmaTables(); << 89 84 << 90 85 // Get TotalCrossSections form Total Lambda << 91 //Get TotalCrossSections form Total Lambda Tables 86 // correction and scaling of the << 92 //------------------------------------------------- 87 G4double GetTotalAdjointCS(G4ParticleDefinit << 93 G4double GetTotalAdjointCS(G4ParticleDefinition* aPartDef, G4double Ekin, 88 const G4MaterialC << 94 const G4MaterialCutsCouple* aCouple); 89 << 95 G4double GetTotalForwardCS(G4ParticleDefinition* aPartDef, G4double Ekin, 90 G4double GetTotalForwardCS(G4ParticleDefinit << 96 const G4MaterialCutsCouple* aCouple); 91 const G4MaterialC << 97 92 << 98 93 G4double GetAdjointSigma(G4double Ekin_nuc, << 99 94 G4bool is_scat_proj << 100 //Weight correction 95 const G4MaterialCut << 101 //------------------ 96 << 102 97 void GetEminForTotalCS(G4ParticleDefinition* << 103 G4double GetContinuousWeightCorrection(G4ParticleDefinition* aPartDef, G4double PreStepEkin,G4double AfterStepEkin, 98 const G4MaterialCutsC << 104 const G4MaterialCutsCouple* aCouple, G4double step_length); 99 G4double& emin_adj, G << 105 G4double GetPostStepWeightCorrection(G4ParticleDefinition* aPrimPartDef, G4ParticleDefinition* aSecondPartDef, 100 << 106 G4double EkinPrim,G4double EkinSecond, 101 void GetMaxFwdTotalCS(G4ParticleDefinition* << 107 const G4MaterialCutsCouple* aCouple); 102 const G4MaterialCutsCo << 108 103 G4double& e_sigma_max, << 109 104 << 110 double ComputeAdjointCS(G4Material* aMaterial, 105 void GetMaxAdjTotalCS(G4ParticleDefinition* << 111 G4VEmAdjointModel* aModel, 106 const G4MaterialCutsCo << 112 G4double PrimEnergy, 107 G4double& e_sigma_max, << 113 G4double Tcut, 108 << 114 G4bool IsScatProjToProjCase, 109 // CrossSection Correction 1 or FwdCS/AdjCS << 115 std::vector<double>& 110 // forward_CS_is_used and forward_CS_mode << 116 AdjointCS_for_each_element); 111 G4double GetCrossSectionCorrection(G4Particl << 117 112 G4double << 118 113 const G4M << 119 G4Element* SampleElementFromCSMatrices(G4Material* aMaterial, 114 G4bool& f << 120 G4VEmAdjointModel* aModel, 115 << 121 G4double PrimEnergy, 116 // Cross section mode << 122 G4double Tcut, 117 inline void SetFwdCrossSectionMode(G4bool aB << 123 G4bool IsScatProjToProjCase); 118 << 124 G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple* aMatCutCouple,G4ParticleDefinition* aPart,G4double PrimEnergy); 119 // Weight correction << 125 G4ParticleDefinition* GetAdjointParticleEquivalent(G4ParticleDefinition* theFwdPartDef); 120 G4double GetContinuousWeightCorrection(G4Par << 126 G4ParticleDefinition* GetForwardParticleEquivalent(G4ParticleDefinition* theAdjPartDef); 121 G4dou << 127 122 G4dou << 128 //inline 123 const << 129 inline void SetTmin(G4double aVal){Tmin=aVal;} 124 G4dou << 130 inline void SetTmax(G4double aVal){Tmax=aVal;} 125 << 131 inline void SetNbins(G4int aInt){nbins=aInt;} 126 G4double GetPostStepWeightCorrection(); << 132 127 << 133 128 // called by the adjoint model to get the CS << 134 129 G4double ComputeAdjointCS(G4Material* aMater << 135 //inline 130 G4double PrimEnerg << 136 inline void ConsiderContinuousWeightCorrection(G4bool aBool){consider_continuous_weight_correction=aBool;} 131 G4bool isScatProjT << 137 inline void ConsiderPoststepWeightCorrection(G4bool aBool){consider_poststep_weight_correction=aBool;} 132 std::vector<G4doub << 138 133 << 139 134 // called by the adjoint model to sample sec << 140 135 G4Element* SampleElementFromCSMatrices(G4Mat << 141 136 G4VEm << 142 private: 137 G4dou << 143 static G4AdjointCSManager* theInstance; 138 G4boo << 144 std::vector< std::vector<G4AdjointCSMatrix*> > theAdjointCSMatricesForScatProjToProj; //x dim is for G4VAdjointEM* while y dim is for elements 139 << 145 std::vector< std::vector<G4AdjointCSMatrix*> > theAdjointCSMatricesForProdToProj; 140 // Total Adjoint CS is computed at initialis << 146 std::vector< G4VEmAdjointModel*> listOfAdjointEMModel; 141 G4double ComputeTotalAdjointCS(const G4Mater << 147 142 G4ParticleDef << 148 std::vector<G4AdjointCSMatrix*> 143 G4double Prim << 149 BuildCrossSectionsMatricesForAGivenModelAndElement(G4VEmAdjointModel* aModel, 144 << 150 G4int Z, 145 G4ParticleDefinition* GetAdjointParticleEqui << 151 G4int A, 146 G4ParticleDefinition* theFwdPartDef); << 152 G4int nbin_pro_decade); 147 << 153 148 G4ParticleDefinition* GetForwardParticleEqui << 154 std::vector<G4AdjointCSMatrix*> 149 G4ParticleDefinition* theAdjPartDef); << 155 BuildCrossSectionsMatricesForAGivenModelAndMaterial(G4VEmAdjointModel* aModel, 150 << 156 G4Material* aMaterial, 151 // inline << 157 G4int nbin_pro_decade); 152 inline void SetIon(G4ParticleDefinition* adj << 158 153 { << 159 154 fAdjIon = adjIon; << 160 G4Material* lastMaterial; 155 fFwdIon = fwdIon; << 161 G4double lastPrimaryEnergy; 156 } << 162 G4double lastTcut; 157 << 163 std::vector< size_t> listOfIndexOfAdjointEMModelInAction; 158 private: << 164 std::vector< G4bool> listOfIsScatProjToProjCase; 159 G4AdjointCSManager(); << 165 std::vector< std::vector<double> > lastAdjointCSVsModelsAndElements; 160 << 166 G4bool CrossSectionMatrixesAreBuilt; 161 void DefineCurrentMaterial(const G4MaterialC << 167 162 << 168 //total adjoint and total forward cross section table in function of material and in function of adjoint particle type 163 void DefineCurrentParticle(const G4ParticleD << 169 //-------------------------------------------------------------------------------------------------------------------- 164 << 170 std::vector<G4PhysicsTable*> theTotalForwardSigmaTableVector; 165 G4double ComputeAdjointCS(G4double aPrimEner << 171 std::vector<G4PhysicsTable*> theTotalAdjointSigmaTableVector; 166 G4AdjointCSMatrix* << 172 167 G4double Tcut); << 173 //list of forward G4VEMLossProcess and of G4VEMProcess for the different adjoint particle 168 << 174 //-------------------------------------------------------------- 169 std::vector<G4AdjointCSMatrix*> BuildCrossSe << 175 std::vector< std::vector<G4VEmProcess*>* > listOfForwardEmProcess; 170 G4VEmAdjointModel* aModel, G4int Z, G4int << 176 std::vector< std::vector<G4VEnergyLossProcess*>* > listOfForwardEnergyLossProcess; 171 << 177 172 std::vector<G4AdjointCSMatrix*> BuildCrossSe << 178 //list of adjoint particles considered 173 G4VEmAdjointModel* aModel, G4Material* aMa << 179 174 << 180 std::vector< G4ParticleDefinition*> theListOfAdjointParticlesInAction; 175 static constexpr G4double fTmin = 0.1 * CLHE << 181 176 static constexpr G4double fTmax = 100. * CLH << 182 177 // fNbins chosen to avoid error << 183 G4double Tmin,Tmax; 178 // in the CS value close to CS jump. (For ex << 184 G4int nbins; 179 static constexpr G4int fNbins = 320; << 185 180 << 186 181 static G4ThreadLocal G4AdjointCSManager* fIn << 187 //Current material 182 << 188 //---------------- 183 // only one ion can be considered by simulat << 189 G4MaterialCutsCouple* currentCouple; 184 G4ParticleDefinition* fAdjIon = nullptr; << 190 G4Material* currentMaterial; 185 G4ParticleDefinition* fFwdIon = nullptr; << 191 size_t currentMatIndex; 186 << 192 187 G4MaterialCutsCouple* fCurrentCouple = nullp << 193 int verbose; 188 G4Material* fCurrentMaterial = nullp << 194 189 << 195 190 // x dim is for G4VAdjointEM*, y dim is for << 196 //Weight correction 191 std::vector<std::vector<G4AdjointCSMatrix*>> << 197 //------------------ 192 fAdjointCSMatricesForScatProjToProj; << 198 G4bool consider_continuous_weight_correction; 193 << 199 G4bool consider_poststep_weight_correction; 194 std::vector<std::vector<G4AdjointCSMatrix*>> << 200 195 << 201 private: 196 std::vector<G4VEmAdjointModel*> fAdjointMode << 202 G4AdjointCSManager(); 197 << 203 void DefineCurrentMaterial(const G4MaterialCutsCouple* couple); 198 std::vector<std::size_t> fIndexOfAdjointEMMo << 204 double ComputeAdjointCS(G4double aPrimEnergy, G4AdjointCSMatrix* anAdjointCSMatrix, G4double Tcut); 199 std::vector<G4bool> fIsScatProjToProj; << 200 std::vector<std::vector<G4double>> fLastAdjo << 201 << 202 // total adjoint and total forward cross sec << 203 // and in function of adjoint particle type << 204 std::vector<G4PhysicsTable*> fTotalFwdSigmaT << 205 std::vector<G4PhysicsTable*> fTotalAdjSigmaT << 206 << 207 // Sigma table for each G4VAdjointEMModel << 208 std::vector<G4PhysicsTable*> fSigmaTableForA << 209 std::vector<G4PhysicsTable*> fSigmaTableForA << 210 << 211 std::vector<std::vector<G4double>> fEminForF << 212 std::vector<std::vector<G4double>> fEminForA << 213 std::vector<std::vector<G4double>> fEkinofFw << 214 std::vector<std::vector<G4double>> fEkinofAd << 215 << 216 // list of forward G4VEmProcess and of G4VEn << 217 // adjoint particle << 218 std::vector<std::vector<G4VEmProcess*>*> fFo << 219 std::vector<std::vector<G4VEnergyLossProcess << 220 << 221 // list of adjoint particles considered << 222 std::vector<G4ParticleDefinition*> fAdjointP << 223 << 224 G4double fMassRatio = 1.; // i << 225 G4double fLastCSCorrectionFactor = 1.; << 226 << 227 G4ParticleDefinition* fCurrentParticleDef = << 228 std::size_t fCurrentParticleIndex = 0; << 229 std::size_t fCurrentMatIndex = 0; << 230 205 231 G4bool fCSMatricesBuilt = false; << 232 G4bool fSigmaTableBuilt = false; << 233 G4bool fForwardCSUsed = true; << 234 G4bool fForwardCSMode = true; << 235 // Two CS mode are possible: << 236 // 1) fForwardCSMode = false, the Adjoint CS << 237 // an AlongStep Weight Correction. << 238 // 2) fForwardCSMode = true, the Adjoint CS << 239 // adjoint CS equal to the fwd one implyi << 240 // For energies where the total Fwd CS or th << 241 // the scaling is not possible and fForwardC << 242 }; 206 }; 243 #endif 207 #endif 244 208