File indexing completed on 2025-01-18 09:57:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 #ifndef G4AdjointCSManager_h
0041 #define G4AdjointCSManager_h 1
0042
0043 #include "globals.hh"
0044 #include "G4AdjointCSMatrix.hh"
0045 #include "G4ThreadLocalSingleton.hh"
0046
0047 #include <vector>
0048
0049 class G4Element;
0050 class G4Material;
0051 class G4MaterialCutsCouple;
0052 class G4ParticleDefinition;
0053 class G4PhysicsTable;
0054 class G4VEmProcess;
0055 class G4VEmAdjointModel;
0056 class G4VEnergyLossProcess;
0057
0058 class G4AdjointCSManager
0059 {
0060 friend class G4ThreadLocalSingleton<G4AdjointCSManager>;
0061
0062 public:
0063 ~G4AdjointCSManager();
0064 static G4AdjointCSManager* GetAdjointCSManager();
0065
0066 G4int GetNbProcesses();
0067
0068
0069
0070 std::size_t RegisterEmAdjointModel(G4VEmAdjointModel*);
0071
0072 void RegisterEmProcess(G4VEmProcess* aProcess,
0073 G4ParticleDefinition* aPartDef);
0074
0075 void RegisterEnergyLossProcess(G4VEnergyLossProcess* aProcess,
0076 G4ParticleDefinition* aPartDef);
0077
0078 void RegisterAdjointParticle(G4ParticleDefinition* aPartDef);
0079
0080
0081 void BuildCrossSectionMatrices();
0082
0083 void BuildTotalSigmaTables();
0084
0085
0086
0087 G4double GetTotalAdjointCS(G4ParticleDefinition* aPartDef, G4double Ekin,
0088 const G4MaterialCutsCouple* aCouple);
0089
0090 G4double GetTotalForwardCS(G4ParticleDefinition* aPartDef, G4double Ekin,
0091 const G4MaterialCutsCouple* aCouple);
0092
0093 G4double GetAdjointSigma(G4double Ekin_nuc, std::size_t index_model,
0094 G4bool is_scat_proj_to_proj,
0095 const G4MaterialCutsCouple* aCouple);
0096
0097 void GetEminForTotalCS(G4ParticleDefinition* aPartDef,
0098 const G4MaterialCutsCouple* aCouple,
0099 G4double& emin_adj, G4double& emin_fwd);
0100
0101 void GetMaxFwdTotalCS(G4ParticleDefinition* aPartDef,
0102 const G4MaterialCutsCouple* aCouple,
0103 G4double& e_sigma_max, G4double& sigma_max);
0104
0105 void GetMaxAdjTotalCS(G4ParticleDefinition* aPartDef,
0106 const G4MaterialCutsCouple* aCouple,
0107 G4double& e_sigma_max, G4double& sigma_max);
0108
0109
0110
0111 G4double GetCrossSectionCorrection(G4ParticleDefinition* aPartDef,
0112 G4double PreStepEkin,
0113 const G4MaterialCutsCouple* aCouple,
0114 G4bool& fwd_is_used);
0115
0116
0117 inline void SetFwdCrossSectionMode(G4bool aBool) { fForwardCSMode = aBool; }
0118
0119
0120 G4double GetContinuousWeightCorrection(G4ParticleDefinition* aPartDef,
0121 G4double PreStepEkin,
0122 G4double AfterStepEkin,
0123 const G4MaterialCutsCouple* aCouple,
0124 G4double step_length);
0125
0126 G4double GetPostStepWeightCorrection();
0127
0128
0129 G4double ComputeAdjointCS(G4Material* aMaterial, G4VEmAdjointModel* aModel,
0130 G4double PrimEnergy, G4double Tcut,
0131 G4bool isScatProjToProj,
0132 std::vector<G4double>& AdjointCS_for_each_element);
0133
0134
0135 G4Element* SampleElementFromCSMatrices(G4Material* aMaterial,
0136 G4VEmAdjointModel* aModel,
0137 G4double PrimEnergy, G4double Tcut,
0138 G4bool isScatProjToProj);
0139
0140
0141 G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple* aMatCutCouple,
0142 G4ParticleDefinition* aPart,
0143 G4double PrimEnergy);
0144
0145 G4ParticleDefinition* GetAdjointParticleEquivalent(
0146 G4ParticleDefinition* theFwdPartDef);
0147
0148 G4ParticleDefinition* GetForwardParticleEquivalent(
0149 G4ParticleDefinition* theAdjPartDef);
0150
0151
0152 inline void SetIon(G4ParticleDefinition* adjIon, G4ParticleDefinition* fwdIon)
0153 {
0154 fAdjIon = adjIon;
0155 fFwdIon = fwdIon;
0156 }
0157
0158 private:
0159 G4AdjointCSManager();
0160
0161 void DefineCurrentMaterial(const G4MaterialCutsCouple* couple);
0162
0163 void DefineCurrentParticle(const G4ParticleDefinition* aPartDef);
0164
0165 G4double ComputeAdjointCS(G4double aPrimEnergy,
0166 G4AdjointCSMatrix* anAdjointCSMatrix,
0167 G4double Tcut);
0168
0169 std::vector<G4AdjointCSMatrix*> BuildCrossSectionsModelAndElement(
0170 G4VEmAdjointModel* aModel, G4int Z, G4int A, G4int nbin_pro_decade);
0171
0172 std::vector<G4AdjointCSMatrix*> BuildCrossSectionsModelAndMaterial(
0173 G4VEmAdjointModel* aModel, G4Material* aMaterial, G4int nbin_pro_decade);
0174
0175 static constexpr G4double fTmin = 0.1 * CLHEP::keV;
0176 static constexpr G4double fTmax = 100. * CLHEP::TeV;
0177
0178
0179 static constexpr G4int fNbins = 320;
0180
0181 static G4ThreadLocal G4AdjointCSManager* fInstance;
0182
0183
0184 G4ParticleDefinition* fAdjIon = nullptr;
0185 G4ParticleDefinition* fFwdIon = nullptr;
0186
0187 G4MaterialCutsCouple* fCurrentCouple = nullptr;
0188 G4Material* fCurrentMaterial = nullptr;
0189
0190
0191 std::vector<std::vector<G4AdjointCSMatrix*>>
0192 fAdjointCSMatricesForScatProjToProj;
0193
0194 std::vector<std::vector<G4AdjointCSMatrix*>> fAdjointCSMatricesForProdToProj;
0195
0196 std::vector<G4VEmAdjointModel*> fAdjointModels;
0197
0198 std::vector<std::size_t> fIndexOfAdjointEMModelInAction;
0199 std::vector<G4bool> fIsScatProjToProj;
0200 std::vector<std::vector<G4double>> fLastAdjointCSVsModelsAndElements;
0201
0202
0203
0204 std::vector<G4PhysicsTable*> fTotalFwdSigmaTable;
0205 std::vector<G4PhysicsTable*> fTotalAdjSigmaTable;
0206
0207
0208 std::vector<G4PhysicsTable*> fSigmaTableForAdjointModelScatProjToProj;
0209 std::vector<G4PhysicsTable*> fSigmaTableForAdjointModelProdToProj;
0210
0211 std::vector<std::vector<G4double>> fEminForFwdSigmaTables;
0212 std::vector<std::vector<G4double>> fEminForAdjSigmaTables;
0213 std::vector<std::vector<G4double>> fEkinofFwdSigmaMax;
0214 std::vector<std::vector<G4double>> fEkinofAdjSigmaMax;
0215
0216
0217
0218 std::vector<std::vector<G4VEmProcess*>*> fForwardProcesses;
0219 std::vector<std::vector<G4VEnergyLossProcess*>*> fForwardLossProcesses;
0220
0221
0222 std::vector<G4ParticleDefinition*> fAdjointParticlesInAction;
0223
0224 G4double fMassRatio = 1.;
0225 G4double fLastCSCorrectionFactor = 1.;
0226
0227 std::size_t fCurrentParticleIndex = 0;
0228 std::size_t fCurrentMatIndex = 0;
0229
0230 G4bool fCSMatricesBuilt = false;
0231 G4bool fSigmaTableBuilt = false;
0232 G4bool fForwardCSUsed = true;
0233 G4bool fForwardCSMode = true;
0234
0235
0236
0237
0238
0239
0240
0241 };
0242 #endif