File indexing completed on 2025-07-12 08:37:01
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 #ifndef G4ParticleHPArbitaryTab_h
0031 #define G4ParticleHPArbitaryTab_h 1
0032
0033 #include "G4InterpolationManager.hh"
0034 #include "G4ParticleHPVector.hh"
0035 #include "G4VParticleHPEDis.hh"
0036 #include "G4ios.hh"
0037 #include "Randomize.hh"
0038 #include "globals.hh"
0039
0040 #include <CLHEP/Units/SystemOfUnits.h>
0041
0042 #include <fstream>
0043
0044
0045
0046 class G4ParticleHPArbitaryTab : public G4VParticleHPEDis
0047 {
0048 public:
0049 G4ParticleHPArbitaryTab()
0050 {
0051 theDistFunc = nullptr;
0052 nDistFunc = 0;
0053 }
0054 ~G4ParticleHPArbitaryTab() override { delete[] theDistFunc; }
0055
0056 inline void Init(std::istream& theData) override
0057 {
0058 std::size_t i;
0059 theFractionalProb.Init(theData, CLHEP::eV);
0060 theData >> nDistFunc;
0061 const std::size_t dsize = nDistFunc > 0 ? nDistFunc : 1;
0062 theDistFunc = new G4ParticleHPVector[dsize];
0063 theManager.Init(theData);
0064 G4double currentEnergy;
0065 for (i = 0; i < dsize; ++i) {
0066 theData >> currentEnergy;
0067 theDistFunc[i].SetLabel(currentEnergy * CLHEP::eV);
0068 theDistFunc[i].Init(theData, CLHEP::eV);
0069 theDistFunc[i].IntegrateAndNormalise();
0070
0071
0072
0073
0074
0075 }
0076
0077
0078
0079
0080 for (i = 0; i < dsize; ++i) {
0081 G4int np = theDistFunc[i].GetVectorLength();
0082 theLowThreshold[i] = theDistFunc[i].GetEnergy(0);
0083 theHighThreshold[i] = theDistFunc[i].GetEnergy(np - 1);
0084 for (G4int j = 0; j < np - 1; ++j) {
0085 if (theDistFunc[i].GetXsec(j + 1) > 1.e-20) {
0086 theLowThreshold[i] = theDistFunc[i].GetEnergy(j);
0087 break;
0088 }
0089 }
0090 for (G4int j = 1; j < np; ++j) {
0091 if (theDistFunc[i].GetXsec(j - 1) > 1.e-20) {
0092 theHighThreshold[i] = theDistFunc[i].GetEnergy(j);
0093 }
0094 }
0095 }
0096
0097 }
0098
0099 inline G4double GetFractionalProbability(G4double anEnergy) override
0100 {
0101 return theFractionalProb.GetY(anEnergy);
0102 }
0103
0104 G4double Sample(G4double anEnergy) override;
0105
0106 private:
0107 G4ParticleHPVector theFractionalProb;
0108 G4int nDistFunc;
0109 G4InterpolationManager theManager;
0110 G4ParticleHPVector* theDistFunc;
0111 G4ParticleHPVector theBuffer;
0112
0113
0114 G4double theLowThreshold[1000];
0115 G4double theHighThreshold[1000];
0116
0117 };
0118
0119 #endif