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: G4VEMAdjointModel 27 // Class: G4VEMAdjointModel 28 // Author: L. Desorgher 28 // Author: L. Desorgher 29 // Organisation: SpaceIT GmbH 29 // Organisation: SpaceIT GmbH 30 // 30 // 31 // Base class for Adjoint EM model. It is bas 31 // Base class for Adjoint EM model. It is based on the use of direct 32 // G4VEmModel. 32 // G4VEmModel. 33 ////////////////////////////////////////////// 33 //////////////////////////////////////////////////////////////////////////////// 34 34 35 #ifndef G4VEmAdjointModel_h 35 #ifndef G4VEmAdjointModel_h 36 #define G4VEmAdjointModel_h 1 36 #define G4VEmAdjointModel_h 1 37 37 38 #include "globals.hh" 38 #include "globals.hh" 39 #include "G4ParticleDefinition.hh" 39 #include "G4ParticleDefinition.hh" 40 #include "G4VEmModel.hh" 40 #include "G4VEmModel.hh" 41 41 42 class G4AdjointCSMatrix; 42 class G4AdjointCSMatrix; 43 class G4AdjointCSManager; 43 class G4AdjointCSManager; 44 class G4Material; 44 class G4Material; 45 class G4MaterialCutsCouple; 45 class G4MaterialCutsCouple; 46 class G4ParticleChange; 46 class G4ParticleChange; 47 class G4Region; 47 class G4Region; 48 class G4Track; 48 class G4Track; 49 49 50 class G4VEmAdjointModel 50 class G4VEmAdjointModel 51 { 51 { 52 public: 52 public: 53 explicit G4VEmAdjointModel(const G4String& n 53 explicit G4VEmAdjointModel(const G4String& nam); 54 54 55 virtual ~G4VEmAdjointModel(); 55 virtual ~G4VEmAdjointModel(); 56 56 57 //------------------------------------------ 57 //------------------------------------------------------------------------ 58 // Virtual methods to be implemented for the 58 // Virtual methods to be implemented for the sample secondaries concrete model 59 //------------------------------------------ 59 //------------------------------------------------------------------------ 60 60 61 virtual void SampleSecondaries(const G4Track 61 virtual void SampleSecondaries(const G4Track& aTrack, G4bool isScatProjToProj, 62 G4ParticleCha 62 G4ParticleChange* fParticleChange) = 0; 63 63 64 //------------------------------------------ 64 //------------------------------------------------------------------------ 65 // Methods for adjoint processes 65 // Methods for adjoint processes 66 //------------------------------------------ 66 //------------------------------------------------------------------------ 67 67 68 virtual G4double AdjointCrossSection(const G 68 virtual G4double AdjointCrossSection(const G4MaterialCutsCouple* aCouple, 69 G4doubl 69 G4double primEnergy, 70 G4bool 70 G4bool isScatProjToProj); 71 71 72 // The implementation of the DiffCrossSectio 72 // The implementation of the DiffCrossSection... here are correct for 73 // energy loss process. For the photoelectri 73 // energy loss process. For the photoelectric and Compton scattering 74 // the method should be redefined 74 // the method should be redefined 75 virtual G4double DiffCrossSectionPerAtomPrim 75 virtual G4double DiffCrossSectionPerAtomPrimToSecond( 76 G4double kinEnergyProj, // kin energy of 76 G4double kinEnergyProj, // kin energy of primary before interaction 77 G4double kinEnergyProd, // kinetic energy 77 G4double kinEnergyProd, // kinetic energy of the secondary particle 78 G4double Z, G4double A = 0.); 78 G4double Z, G4double A = 0.); 79 79 80 virtual G4double DiffCrossSectionPerAtomPrim 80 virtual G4double DiffCrossSectionPerAtomPrimToScatPrim( 81 G4double kinEnergyProj, // kin energy 81 G4double kinEnergyProj, // kin energy of primary before interaction 82 G4double kinEnergyScatProj, // kin energy 82 G4double kinEnergyScatProj, // kin energy of primary after interaction 83 G4double Z, G4double A = 0.); 83 G4double Z, G4double A = 0.); 84 84 85 virtual G4double DiffCrossSectionPerVolumePr 85 virtual G4double DiffCrossSectionPerVolumePrimToSecond( 86 const G4Material* aMaterial, 86 const G4Material* aMaterial, 87 G4double kinEnergyProj, // kin energy of 87 G4double kinEnergyProj, // kin energy of primary before interaction 88 G4double kinEnergyProd // kinetic energy 88 G4double kinEnergyProd // kinetic energy of secondary particle 89 ); 89 ); 90 90 91 virtual G4double DiffCrossSectionPerVolumePr 91 virtual G4double DiffCrossSectionPerVolumePrimToScatPrim( 92 const G4Material* aMaterial, 92 const G4Material* aMaterial, 93 G4double kinEnergyProj, // kin energy 93 G4double kinEnergyProj, // kin energy of primary before interaction 94 G4double kinEnergyScatProj // kinetic ene 94 G4double kinEnergyScatProj // kinetic energy of primary after interaction 95 ); 95 ); 96 96 97 // Energy limits of adjoint secondary 97 // Energy limits of adjoint secondary 98 //------------------ 98 //------------------ 99 99 100 virtual G4double GetSecondAdjEnergyMaxForSca 100 virtual G4double GetSecondAdjEnergyMaxForScatProjToProj( 101 G4double primAdjEnergy); 101 G4double primAdjEnergy); 102 102 103 virtual G4double GetSecondAdjEnergyMinForSca 103 virtual G4double GetSecondAdjEnergyMinForScatProjToProj( 104 G4double primAdjEnergy, G4double tcut = 0. 104 G4double primAdjEnergy, G4double tcut = 0.); 105 105 106 virtual G4double GetSecondAdjEnergyMaxForPro 106 virtual G4double GetSecondAdjEnergyMaxForProdToProj(G4double primAdjEnergy); 107 107 108 virtual G4double GetSecondAdjEnergyMinForPro 108 virtual G4double GetSecondAdjEnergyMinForProdToProj(G4double primAdjEnergy); 109 109 110 // Other Methods 110 // Other Methods 111 //--------------- 111 //--------------- 112 112 113 void DefineCurrentMaterial(const G4MaterialC 113 void DefineCurrentMaterial(const G4MaterialCutsCouple* couple); 114 114 115 std::vector<std::vector<double>*> 115 std::vector<std::vector<double>*> 116 ComputeAdjointCrossSectionVectorPerAtomForSe 116 ComputeAdjointCrossSectionVectorPerAtomForSecond(G4double kinEnergyProd, 117 117 G4double Z, G4double A = 0., 118 118 G4int nbin_pro_decade = 10); 119 119 120 std::vector<std::vector<double>*> 120 std::vector<std::vector<double>*> 121 ComputeAdjointCrossSectionVectorPerAtomForSc 121 ComputeAdjointCrossSectionVectorPerAtomForScatProj( 122 G4double kinEnergyProd, G4double Z, G4doub 122 G4double kinEnergyProd, G4double Z, G4double A = 0., 123 G4int nbin_pro_decade = 10); 123 G4int nbin_pro_decade = 10); 124 124 125 std::vector<std::vector<double>*> 125 std::vector<std::vector<double>*> 126 ComputeAdjointCrossSectionVectorPerVolumeFor 126 ComputeAdjointCrossSectionVectorPerVolumeForSecond( 127 G4Material* aMaterial, G4double kinEnergyP 127 G4Material* aMaterial, G4double kinEnergyProd, G4int nbin_pro_decade = 10); 128 128 129 std::vector<std::vector<double>*> 129 std::vector<std::vector<double>*> 130 ComputeAdjointCrossSectionVectorPerVolumeFor 130 ComputeAdjointCrossSectionVectorPerVolumeForScatProj( 131 G4Material* aMaterial, G4double kinEnergyP 131 G4Material* aMaterial, G4double kinEnergyProd, G4int nbin_pro_decade = 10); 132 132 133 inline void SetCSMatrices(std::vector<G4Adjo 133 inline void SetCSMatrices(std::vector<G4AdjointCSMatrix*>* Vec1CSMatrix, 134 std::vector<G4Adjo 134 std::vector<G4AdjointCSMatrix*>* Vec2CSMatrix) 135 { 135 { 136 fCSMatrixProdToProjBackScat = Vec1CSMatrix 136 fCSMatrixProdToProjBackScat = Vec1CSMatrix; 137 fCSMatrixProjToProjBackScat = Vec2CSMatrix 137 fCSMatrixProjToProjBackScat = Vec2CSMatrix; 138 }; 138 }; 139 139 140 inline G4ParticleDefinition* 140 inline G4ParticleDefinition* 141 GetAdjointEquivalentOfDirectPrimaryParticleD << 141 GetAdjointEquivalentOfDirectPrimaryParticleDefinition() 142 { 142 { 143 return fAdjEquivDirectPrimPart; 143 return fAdjEquivDirectPrimPart; 144 } 144 } 145 145 146 inline G4ParticleDefinition* 146 inline G4ParticleDefinition* 147 GetAdjointEquivalentOfDirectSecondaryParticl << 147 GetAdjointEquivalentOfDirectSecondaryParticleDefinition() 148 { 148 { 149 return fAdjEquivDirectSecondPart; 149 return fAdjEquivDirectSecondPart; 150 } 150 } 151 151 152 inline G4double GetHighEnergyLimit() const { << 152 inline G4double GetHighEnergyLimit() { return fHighEnergyLimit; } 153 153 154 inline G4double GetLowEnergyLimit() const { << 154 inline G4double GetLowEnergyLimit() { return fLowEnergyLimit; } 155 155 156 void SetHighEnergyLimit(G4double aVal); 156 void SetHighEnergyLimit(G4double aVal); 157 157 158 void SetLowEnergyLimit(G4double aVal); 158 void SetLowEnergyLimit(G4double aVal); 159 159 160 inline void DefineDirectEMModel(G4VEmModel* 160 inline void DefineDirectEMModel(G4VEmModel* aModel) { fDirectModel = aModel; } 161 161 162 void SetAdjointEquivalentOfDirectPrimaryPart 162 void SetAdjointEquivalentOfDirectPrimaryParticleDefinition( 163 G4ParticleDefinition* aPart); 163 G4ParticleDefinition* aPart); 164 164 165 inline void SetAdjointEquivalentOfDirectSeco 165 inline void SetAdjointEquivalentOfDirectSecondaryParticleDefinition( 166 G4ParticleDefinition* aPart) 166 G4ParticleDefinition* aPart) 167 { 167 { 168 fAdjEquivDirectSecondPart = aPart; 168 fAdjEquivDirectSecondPart = aPart; 169 } 169 } 170 170 171 inline void SetSecondPartOfSameType(G4bool a 171 inline void SetSecondPartOfSameType(G4bool aBool) 172 { 172 { 173 fSecondPartSameType = aBool; 173 fSecondPartSameType = aBool; 174 } 174 } 175 175 176 inline G4bool GetSecondPartOfSameType() cons << 176 inline G4bool GetSecondPartOfSameType() { return fSecondPartSameType; } 177 177 178 inline void SetUseMatrix(G4bool aBool) { fUs 178 inline void SetUseMatrix(G4bool aBool) { fUseMatrix = aBool; } 179 179 180 inline void SetUseMatrixPerElement(G4bool aB 180 inline void SetUseMatrixPerElement(G4bool aBool) 181 { 181 { 182 fUseMatrixPerElement = aBool; 182 fUseMatrixPerElement = aBool; 183 } 183 } 184 184 185 inline void SetUseOnlyOneMatrixForAllElement 185 inline void SetUseOnlyOneMatrixForAllElements(G4bool aBool) 186 { 186 { 187 fOneMatrixForAllElements = aBool; 187 fOneMatrixForAllElements = aBool; 188 } 188 } 189 189 190 inline void SetApplyCutInRange(G4bool aBool) 190 inline void SetApplyCutInRange(G4bool aBool) { fApplyCutInRange = aBool; } 191 191 192 inline G4bool GetUseMatrix() const { return << 192 inline G4bool GetUseMatrix() { return fUseMatrix; } 193 193 194 inline G4bool GetUseMatrixPerElement() const << 194 inline G4bool GetUseMatrixPerElement() { return fUseMatrixPerElement; } 195 195 196 inline G4bool GetUseOnlyOneMatrixForAllEleme << 196 inline G4bool GetUseOnlyOneMatrixForAllElements() 197 { 197 { 198 return fOneMatrixForAllElements; 198 return fOneMatrixForAllElements; 199 } 199 } 200 200 201 inline G4bool GetApplyCutInRange() const { r << 201 inline G4bool GetApplyCutInRange() { return fApplyCutInRange; } 202 202 203 inline const G4String& GetName() const { ret << 203 inline G4String GetName() { return fName; } 204 204 205 inline virtual void SetCSBiasingFactor(G4dou 205 inline virtual void SetCSBiasingFactor(G4double aVal) 206 { 206 { 207 fCsBiasingFactor = aVal; 207 fCsBiasingFactor = aVal; 208 } 208 } 209 209 210 inline void SetCorrectWeightForPostStepInMod 210 inline void SetCorrectWeightForPostStepInModel(G4bool aBool) 211 { 211 { 212 fInModelWeightCorr = aBool; 212 fInModelWeightCorr = aBool; 213 } 213 } 214 214 215 inline void SetAdditionalWeightCorrectionFac 215 inline void SetAdditionalWeightCorrectionFactorForPostStepOutsideModel( 216 G4double factor) 216 G4double factor) 217 { 217 { 218 fOutsideWeightFactor = factor; 218 fOutsideWeightFactor = factor; 219 } 219 } 220 220 221 G4VEmAdjointModel(G4VEmAdjointModel&) = dele 221 G4VEmAdjointModel(G4VEmAdjointModel&) = delete; 222 G4VEmAdjointModel& operator=(const G4VEmAdjo 222 G4VEmAdjointModel& operator=(const G4VEmAdjointModel& right) = delete; 223 223 224 protected: 224 protected: 225 G4double DiffCrossSectionFunction1(G4double 225 G4double DiffCrossSectionFunction1(G4double kinEnergyProj); 226 226 227 G4double DiffCrossSectionFunction2(G4double 227 G4double DiffCrossSectionFunction2(G4double kinEnergyProj); 228 228 229 // General methods to sample secondary energ 229 // General methods to sample secondary energy 230 G4double SampleAdjSecEnergyFromCSMatrix(std: << 230 G4double SampleAdjSecEnergyFromCSMatrix(size_t MatrixIndex, 231 G4do 231 G4double prim_energy, 232 G4bo 232 G4bool isScatProjToProj); 233 233 234 G4double SampleAdjSecEnergyFromCSMatrix(G4do 234 G4double SampleAdjSecEnergyFromCSMatrix(G4double prim_energy, 235 G4bo 235 G4bool isScatProjToProj); 236 236 237 void SelectCSMatrix(G4bool isScatProjToProj) 237 void SelectCSMatrix(G4bool isScatProjToProj); 238 238 239 virtual G4double SampleAdjSecEnergyFromDiffC 239 virtual G4double SampleAdjSecEnergyFromDiffCrossSectionPerAtom( 240 G4double prim_energy, G4bool isScatProjToP 240 G4double prim_energy, G4bool isScatProjToProj); 241 241 242 // Post Step weight correction 242 // Post Step weight correction 243 virtual void CorrectPostStepWeight(G4Particl 243 virtual void CorrectPostStepWeight(G4ParticleChange* fParticleChange, 244 G4double 244 G4double old_weight, 245 G4double 245 G4double adjointPrimKinEnergy, 246 G4double 246 G4double projectileKinEnergy, 247 G4bool is 247 G4bool isScatProjToProj); 248 248 249 G4AdjointCSManager* fCSManager; 249 G4AdjointCSManager* fCSManager; 250 G4VEmModel* fDirectModel = nullptr; 250 G4VEmModel* fDirectModel = nullptr; 251 251 252 const G4String fName; 252 const G4String fName; 253 253 254 G4Material* fSelectedMaterial = nullp 254 G4Material* fSelectedMaterial = nullptr; 255 G4Material* fCurrentMaterial = nullp 255 G4Material* fCurrentMaterial = nullptr; 256 G4MaterialCutsCouple* fCurrentCouple = nullp 256 G4MaterialCutsCouple* fCurrentCouple = nullptr; 257 257 258 // particle definition 258 // particle definition 259 G4ParticleDefinition* fAdjEquivDirectPrimPar 259 G4ParticleDefinition* fAdjEquivDirectPrimPart = nullptr; 260 G4ParticleDefinition* fAdjEquivDirectSecondP 260 G4ParticleDefinition* fAdjEquivDirectSecondPart = nullptr; 261 G4ParticleDefinition* fDirectPrimaryPart 261 G4ParticleDefinition* fDirectPrimaryPart = nullptr; 262 262 263 // adjoint CS matrix for each element or mat 263 // adjoint CS matrix for each element or material 264 std::vector<G4AdjointCSMatrix*>* fCSMatrixPr 264 std::vector<G4AdjointCSMatrix*>* fCSMatrixProdToProjBackScat = nullptr; 265 std::vector<G4AdjointCSMatrix*>* fCSMatrixPr 265 std::vector<G4AdjointCSMatrix*>* fCSMatrixProjToProjBackScat = nullptr; 266 266 267 std::vector<G4double> fElementCSScatProjToPr 267 std::vector<G4double> fElementCSScatProjToProj; 268 std::vector<G4double> fElementCSProdToProj; 268 std::vector<G4double> fElementCSProdToProj; 269 269 270 G4double fKinEnergyProdForIntegration = 270 G4double fKinEnergyProdForIntegration = 0.; 271 G4double fKinEnergyScatProjForIntegration = 271 G4double fKinEnergyScatProjForIntegration = 0.; 272 272 273 G4double fLastCS = 0 273 G4double fLastCS = 0.; 274 G4double fLastAdjointCSForScatProjToProj = 0 274 G4double fLastAdjointCSForScatProjToProj = 0.; 275 G4double fLastAdjointCSForProdToProj = 0 275 G4double fLastAdjointCSForProdToProj = 0.; 276 276 277 G4double fPreStepEnergy = 0.; 277 G4double fPreStepEnergy = 0.; 278 278 279 G4double fTcutPrim = 0.; 279 G4double fTcutPrim = 0.; 280 G4double fTcutSecond = 0.; 280 G4double fTcutSecond = 0.; 281 281 282 // Energy limits 282 // Energy limits 283 G4double fHighEnergyLimit = 0.; 283 G4double fHighEnergyLimit = 0.; 284 G4double fLowEnergyLimit = 0.; 284 G4double fLowEnergyLimit = 0.; 285 285 286 // Cross Section biasing factor 286 // Cross Section biasing factor 287 G4double fCsBiasingFactor = 1.; 287 G4double fCsBiasingFactor = 1.; 288 288 289 // [1] This is needed for the forced interac 289 // [1] This is needed for the forced interaction where part of the weight 290 // correction is given outside the model whi 290 // correction is given outside the model while the secondary are created in 291 // the model. The weight should be fixed bef 291 // the model. The weight should be fixed before adding the secondary 292 G4double fOutsideWeightFactor = 1.; 292 G4double fOutsideWeightFactor = 1.; 293 293 294 // Needed for CS integration at the initiali 294 // Needed for CS integration at the initialisation phase 295 G4int fASelectedNucleus = 0; 295 G4int fASelectedNucleus = 0; 296 G4int fZSelectedNucleus = 0; 296 G4int fZSelectedNucleus = 0; 297 297 298 std::size_t fCSMatrixUsed = 0; // Index of << 298 size_t fCSMatrixUsed = 0; // Index of crosssection matrices used 299 299 300 G4bool fSecondPartSameType = false; 300 G4bool fSecondPartSameType = false; 301 G4bool fInModelWeightCorr = 301 G4bool fInModelWeightCorr = 302 false; // correct_weight_for_post_step_in 302 false; // correct_weight_for_post_step_in_model, see [1] 303 303 304 G4bool fApplyCutInRange = true; 304 G4bool fApplyCutInRange = true; 305 305 306 // Type of Model with Matrix or not 306 // Type of Model with Matrix or not 307 G4bool fUseMatrix = false; 307 G4bool fUseMatrix = false; 308 G4bool fUseMatrixPerElement = false; // 308 G4bool fUseMatrixPerElement = false; // other possibility is per Material 309 G4bool fOneMatrixForAllElements = false; 309 G4bool fOneMatrixForAllElements = false; 310 }; 310 }; 311 311 312 #endif 312 #endif 313 313