File indexing completed on 2025-01-18 09:58:51
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 #ifndef G4ParticleHPContAngularPar_h
0034 #define G4ParticleHPContAngularPar_h 1
0035
0036 #include "G4Cache.hh"
0037 #include "G4InterpolationManager.hh"
0038 #include "G4ParticleHPInterpolator.hh"
0039 #include "G4ParticleHPList.hh"
0040 #include "G4ReactionProduct.hh"
0041 #include "G4ios.hh"
0042 #include "globals.hh"
0043
0044 #include <fstream>
0045 #include <set>
0046
0047 class G4ParticleDefinition;
0048
0049 class G4ParticleHPContAngularPar
0050 {
0051 struct toBeCached
0052 {
0053 G4bool fresh{true};
0054 G4double currentMeanEnergy{-2.0};
0055 G4double remaining_energy{0.0};
0056 G4double theTargetCode{-1.0};
0057 G4ReactionProduct* theTarget{nullptr};
0058 G4ReactionProduct* thePrimary{nullptr};
0059 toBeCached() = default;
0060 };
0061
0062 public:
0063 G4ParticleHPContAngularPar(const G4ParticleDefinition* p = nullptr);
0064 G4ParticleHPContAngularPar(G4ParticleHPContAngularPar&);
0065
0066 ~G4ParticleHPContAngularPar();
0067
0068 void Init(std::istream& aDataFile, const G4ParticleDefinition* projectile);
0069
0070 G4ReactionProduct* Sample(G4double anEnergy, G4double massCode,
0071 G4double mass, G4int angularRep, G4int interpol);
0072
0073 G4double GetEnergy() const { return theEnergy; }
0074
0075 void SetPrimary(G4ReactionProduct* aPrimary) { fCache.Get().thePrimary = aPrimary; }
0076
0077 void SetTarget(G4ReactionProduct* aTarget) { fCache.Get().theTarget = aTarget; }
0078
0079 void SetTargetCode(G4double aTargetCode) { fCache.Get().theTargetCode = aTargetCode; }
0080
0081 void SetInterpolation(G4int theInterpolation)
0082 {
0083 theManager.Init(theInterpolation, nEnergies);
0084 }
0085
0086 void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme,
0087 G4ParticleHPContAngularPar& store1,
0088 G4ParticleHPContAngularPar& store2);
0089
0090
0091 void PrepareTableInterpolation();
0092
0093 G4double MeanEnergyOfThisInteraction()
0094 {
0095 G4double result = std::max(fCache.Get().currentMeanEnergy, 0.0);
0096 fCache.Get().currentMeanEnergy = -2.0;
0097 return result;
0098 }
0099
0100 G4int GetNEnergies() const { return nEnergies; }
0101 G4int GetNDiscreteEnergies() const { return nDiscreteEnergies; }
0102 std::set<G4double> GetEnergiesTransformed() const { return theEnergiesTransformed; }
0103 G4int GetNEnergiesTransformed() const { return (G4int)theEnergiesTransformed.size(); }
0104 G4double GetMinEner() const { return theMinEner; }
0105 G4double GetMaxEner() const { return theMaxEner; }
0106 std::map<G4double, G4int> GetDiscreteEnergiesOwn() const { return theDiscreteEnergiesOwn; }
0107 G4ParticleHPList* GetAngDataList() const { return theAngular; }
0108
0109 void ClearHistories()
0110 {
0111 fCache.Get().fresh = true;
0112 fCache.Get().currentMeanEnergy = -2.0;
0113 fCache.Get().remaining_energy = 0.0;
0114 fCache.Get().theTargetCode = -1.0;
0115 fCache.Get().theTarget = nullptr;
0116 fCache.Get().thePrimary = nullptr;
0117 }
0118
0119 void Dump() const;
0120
0121 G4ParticleHPContAngularPar& operator=(const G4ParticleHPContAngularPar &right) = delete;
0122
0123 private:
0124
0125 G4double theEnergy{0.0};
0126 G4double theMinEner{DBL_MAX};
0127 G4double theMaxEner{-DBL_MAX};
0128
0129 G4int nEnergies{0};
0130
0131 G4int nDiscreteEnergies{0};
0132
0133 G4int nAngularParameters{0};
0134
0135 const G4ParticleDefinition* theProjectile{nullptr};
0136
0137 G4ParticleHPList* theAngular{nullptr};
0138
0139
0140 G4InterpolationManager theManager;
0141
0142 G4ParticleHPInterpolator theInt;
0143
0144 G4Cache<toBeCached> fCache;
0145
0146 G4bool adjustResult{true};
0147
0148
0149
0150 std::set<G4double> theEnergiesTransformed;
0151 std::set<G4double> theDiscreteEnergies;
0152 std::map<G4double, G4int> theDiscreteEnergiesOwn;
0153 };
0154
0155 #endif