Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 ////////////////////////////////////////////// 27 // Class: G4AdjointCSManager 28 // Author: L. Desorgher 29 // Organisation: SpaceIT GmbH 30 // 31 // Class is responsible for the management of 32 // matrices, and for the computation of the to 33 // sections. Total adjoint and forward cross s 34 // weight of a particle after a tracking step 35 // reverse reaction. It is also used to sample 36 // given adjoint cross section matrix. 37 // 38 ////////////////////////////////////////////// 39 40 #ifndef G4AdjointCSManager_h 41 #define G4AdjointCSManager_h 1 42 43 #include "globals.hh" 44 #include "G4AdjointCSMatrix.hh" 45 #include "G4ThreadLocalSingleton.hh" 46 47 #include <vector> 48 49 class G4Element; 50 class G4Material; 51 class G4MaterialCutsCouple; 52 class G4ParticleDefinition; 53 class G4PhysicsTable; 54 class G4VEmProcess; 55 class G4VEmAdjointModel; 56 class G4VEnergyLossProcess; 57 58 class G4AdjointCSManager 59 { 60 friend class G4ThreadLocalSingleton<G4Adjoin 61 62 public: 63 ~G4AdjointCSManager(); 64 static G4AdjointCSManager* GetAdjointCSManag 65 66 G4int GetNbProcesses(); 67 68 // Registration of the different models and 69 70 std::size_t RegisterEmAdjointModel(G4VEmAdjo 71 72 void RegisterEmProcess(G4VEmProcess* aProces 73 G4ParticleDefinition* 74 75 void RegisterEnergyLossProcess(G4VEnergyLoss 76 G4ParticleDef 77 78 void RegisterAdjointParticle(G4ParticleDefin 79 80 // Building of the CS Matrices and Total For 81 void BuildCrossSectionMatrices(); 82 83 void BuildTotalSigmaTables(); 84 85 // Get TotalCrossSections form Total Lambda 86 // correction and scaling of the 87 G4double GetTotalAdjointCS(G4ParticleDefinit 88 const G4MaterialC 89 90 G4double GetTotalForwardCS(G4ParticleDefinit 91 const G4MaterialC 92 93 G4double GetAdjointSigma(G4double Ekin_nuc, 94 G4bool is_scat_proj 95 const G4MaterialCut 96 97 void GetEminForTotalCS(G4ParticleDefinition* 98 const G4MaterialCutsC 99 G4double& emin_adj, G 100 101 void GetMaxFwdTotalCS(G4ParticleDefinition* 102 const G4MaterialCutsCo 103 G4double& e_sigma_max, 104 105 void GetMaxAdjTotalCS(G4ParticleDefinition* 106 const G4MaterialCutsCo 107 G4double& e_sigma_max, 108 109 // CrossSection Correction 1 or FwdCS/AdjCS 110 // forward_CS_is_used and forward_CS_mode 111 G4double GetCrossSectionCorrection(G4Particl 112 G4double 113 const G4M 114 G4bool& f 115 116 // Cross section mode 117 inline void SetFwdCrossSectionMode(G4bool aB 118 119 // Weight correction 120 G4double GetContinuousWeightCorrection(G4Par 121 G4dou 122 G4dou 123 const 124 G4dou 125 126 G4double GetPostStepWeightCorrection(); 127 128 // called by the adjoint model to get the CS 129 G4double ComputeAdjointCS(G4Material* aMater 130 G4double PrimEnerg 131 G4bool isScatProjT 132 std::vector<G4doub 133 134 // called by the adjoint model to sample sec 135 G4Element* SampleElementFromCSMatrices(G4Mat 136 G4VEm 137 G4dou 138 G4boo 139 140 // Total Adjoint CS is computed at initialis 141 G4double ComputeTotalAdjointCS(const G4Mater 142 G4ParticleDef 143 G4double Prim 144 145 G4ParticleDefinition* GetAdjointParticleEqui 146 G4ParticleDefinition* theFwdPartDef); 147 148 G4ParticleDefinition* GetForwardParticleEqui 149 G4ParticleDefinition* theAdjPartDef); 150 151 // inline 152 inline void SetIon(G4ParticleDefinition* adj 153 { 154 fAdjIon = adjIon; 155 fFwdIon = fwdIon; 156 } 157 158 private: 159 G4AdjointCSManager(); 160 161 void DefineCurrentMaterial(const G4MaterialC 162 163 void DefineCurrentParticle(const G4ParticleD 164 165 G4double ComputeAdjointCS(G4double aPrimEner 166 G4AdjointCSMatrix* 167 G4double Tcut); 168 169 std::vector<G4AdjointCSMatrix*> BuildCrossSe 170 G4VEmAdjointModel* aModel, G4int Z, G4int 171 172 std::vector<G4AdjointCSMatrix*> BuildCrossSe 173 G4VEmAdjointModel* aModel, G4Material* aMa 174 175 static constexpr G4double fTmin = 0.1 * CLHE 176 static constexpr G4double fTmax = 100. * CLH 177 // fNbins chosen to avoid error 178 // in the CS value close to CS jump. (For ex 179 static constexpr G4int fNbins = 320; 180 181 static G4ThreadLocal G4AdjointCSManager* fIn 182 183 // only one ion can be considered by simulat 184 G4ParticleDefinition* fAdjIon = nullptr; 185 G4ParticleDefinition* fFwdIon = nullptr; 186 187 G4MaterialCutsCouple* fCurrentCouple = nullp 188 G4Material* fCurrentMaterial = nullp 189 190 // x dim is for G4VAdjointEM*, y dim is for 191 std::vector<std::vector<G4AdjointCSMatrix*>> 192 fAdjointCSMatricesForScatProjToProj; 193 194 std::vector<std::vector<G4AdjointCSMatrix*>> 195 196 std::vector<G4VEmAdjointModel*> fAdjointMode 197 198 std::vector<std::size_t> fIndexOfAdjointEMMo 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 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 }; 243 #endif 244