File indexing completed on 2025-01-18 09:58:53
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 #ifndef G4ParticleHPPartial_h
0032 #define G4ParticleHPPartial_h 1
0033
0034 #include "G4InterpolationManager.hh"
0035 #include "G4ParticleHPInterpolator.hh"
0036 #include "G4ParticleHPVector.hh"
0037 #include "globals.hh"
0038
0039 #include <CLHEP/Units/SystemOfUnits.h>
0040
0041 class G4ParticleHPPartial
0042 {
0043 public:
0044 G4ParticleHPPartial(G4int n)
0045 {
0046 X = new G4double[n];
0047 data = new G4ParticleHPVector[n];
0048 nData = n;
0049 T = nullptr;
0050 }
0051
0052 G4ParticleHPPartial(G4int n1, G4int n2)
0053 {
0054 T = new G4double[n2];
0055 X = new G4double[n1];
0056 data = new G4ParticleHPVector[n1];
0057 nData = std::max(n1, n2);
0058 }
0059
0060 void InitInterpolation(G4int i, std::istream& aDataFile)
0061 {
0062 data[i].InitInterpolation(aDataFile);
0063 }
0064
0065 void InitInterpolation(std::istream& aDataFile) { theManager.Init(aDataFile); }
0066
0067 void Init(std::istream& aDataFile)
0068 {
0069 G4int i;
0070 G4double e;
0071 for (i = 0; i < nData; i++) {
0072 aDataFile >> e;
0073 e *= CLHEP::eV;
0074 SetX(i, e);
0075 InitData(i, aDataFile, CLHEP::eV);
0076 }
0077 }
0078
0079 void InitData(G4int i, std::istream& aDataFile, G4double unit = 1.)
0080 {
0081 G4int ii;
0082 G4double eg, pg;
0083 G4int neg;
0084 aDataFile >> neg;
0085 data[i].InitInterpolation(aDataFile);
0086 for (ii = 0; ii < neg; ii++) {
0087 aDataFile >> eg >> pg;
0088 eg *= unit;
0089 SetX(i, ii, eg);
0090 SetY(i, ii, pg);
0091 }
0092 data[i].Hash();
0093 }
0094
0095 ~G4ParticleHPPartial()
0096 {
0097 delete[] X;
0098 delete[] T;
0099 delete[] data;
0100 }
0101 inline G4int GetNumberOfEnergies() { return nData; }
0102
0103 inline void SetX(G4int i, G4double x) { X[i] = x; }
0104 inline void SetT(G4int i, G4double x) { T[i] = x; }
0105 inline void SetX(G4int i, G4int j, G4double x) { data[i].SetX(j, x); }
0106 inline void SetY(G4int i, G4int j, G4double y) { data[i].SetY(j, y); }
0107 void DoneSetXY(G4int i) { data[i].Hash(); }
0108
0109 inline G4double GetX(G4int i) { return X[i]; }
0110 inline G4double GetT(G4int i) { return T[i]; }
0111 inline G4double GetX(G4int i, G4int j) { return data[i].GetX(j); }
0112 inline G4double GetY(G4int i, G4int j) { return data[i].GetY(j); }
0113 inline G4double GetY(G4int i, G4double e) { return data[i].GetY(e); }
0114 inline G4int GetNEntries(G4int i) { return data[i].GetVectorLength(); }
0115 G4ParticleHPVector* GetY(G4double e1);
0116 G4double Sample(G4double x);
0117
0118 private:
0119 G4double* X;
0120 G4double* T;
0121 G4ParticleHPVector* data;
0122
0123
0124 G4int nData;
0125 G4InterpolationManager theManager;
0126 G4ParticleHPInterpolator theInt;
0127 };
0128
0129 #endif