Geant4-11
Public Member Functions | Private Attributes
G4ParticleHPArbitaryTab Class Reference

#include <G4ParticleHPArbitaryTab.hh>

Inheritance diagram for G4ParticleHPArbitaryTab:
G4VParticleHPEDis

Public Member Functions

 G4ParticleHPArbitaryTab ()
 
G4double GetFractionalProbability (G4double anEnergy)
 
void Init (std::istream &theData)
 
G4double Sample (G4double anEnergy)
 
 ~G4ParticleHPArbitaryTab ()
 

Private Attributes

G4int nDistFunc
 
G4ParticleHPVector theBuffer
 
G4ParticleHPVectortheDistFunc
 
G4ParticleHPVector theFractionalProb
 
G4double theHighThreshold [1000]
 
G4double theLowThreshold [1000]
 
G4InterpolationManager theManager
 

Detailed Description

Definition at line 45 of file G4ParticleHPArbitaryTab.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPArbitaryTab()

G4ParticleHPArbitaryTab::G4ParticleHPArbitaryTab ( )
inline

Definition at line 48 of file G4ParticleHPArbitaryTab.hh.

49 {
50 theDistFunc = 0;
51 nDistFunc = 0;
52 }
G4ParticleHPVector * theDistFunc

References nDistFunc, and theDistFunc.

◆ ~G4ParticleHPArbitaryTab()

G4ParticleHPArbitaryTab::~G4ParticleHPArbitaryTab ( )
inline

Definition at line 53 of file G4ParticleHPArbitaryTab.hh.

54 {
55 if(theDistFunc!=0) delete [] theDistFunc;
56 }

References theDistFunc.

Member Function Documentation

◆ GetFractionalProbability()

G4double G4ParticleHPArbitaryTab::GetFractionalProbability ( G4double  anEnergy)
inlinevirtual

Implements G4VParticleHPEDis.

Definition at line 101 of file G4ParticleHPArbitaryTab.hh.

102 {
103 return theFractionalProb.GetY(anEnergy);
104 }
G4ParticleHPVector theFractionalProb
G4double GetY(G4double x)

References G4ParticleHPVector::GetY(), and theFractionalProb.

◆ Init()

void G4ParticleHPArbitaryTab::Init ( std::istream &  theData)
inlinevirtual

Implements G4VParticleHPEDis.

Definition at line 58 of file G4ParticleHPArbitaryTab.hh.

59 {
60 G4int i;
62 theData >> nDistFunc; // = number of incoming n energy points
64 theManager.Init(theData);
65 G4double currentEnergy;
66 for(i=0; i<nDistFunc; i++)
67 {
68 theData >> currentEnergy;
69 theDistFunc[i].SetLabel(currentEnergy*CLHEP::eV);
70 theDistFunc[i].Init(theData, CLHEP::eV);
72 //************************************************************************
73 //EMendoza:
74 //ThinOut() assumes that the data is linear-linear, what is false:
75 //theDistFunc[i].ThinOut(0.02); // @@@ optimization to be finished.
76 //************************************************************************
77 }
78
79 //************************************************************************
80 //EMendoza:
81 //Here we calculate the thresholds for the 2D sampling:
82 for(i=0; i<nDistFunc; i++){
86 for(G4int j=0;j<np-1;j++){
87 if(theDistFunc[i].GetXsec(j+1)>1.e-20){
89 break;
90 }
91 }
92 for(G4int j=1;j<np;j++){
93 if(theDistFunc[i].GetXsec(j-1)>1.e-20){
95 }
96 }
97 }
98 //************************************************************************
99 }
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
void Init(G4int aScheme, G4int aRange)
G4InterpolationManager theManager
void SetLabel(G4double aLabel)
G4double GetEnergy(G4int i) const
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
G4int GetVectorLength() const
static constexpr double eV

References CLHEP::eV, G4ParticleHPVector::GetEnergy(), G4ParticleHPVector::GetVectorLength(), G4InterpolationManager::Init(), G4ParticleHPVector::Init(), G4ParticleHPVector::IntegrateAndNormalise(), nDistFunc, G4ParticleHPVector::SetLabel(), theDistFunc, theFractionalProb, theHighThreshold, theLowThreshold, and theManager.

◆ Sample()

G4double G4ParticleHPArbitaryTab::Sample ( G4double  anEnergy)
virtual

Implements G4VParticleHPEDis.

Definition at line 35 of file G4ParticleHPArbitaryTab.cc.

36 {
37 G4int i;
38 for(i=0;i<nDistFunc;i++)
39 {
40 if(anEnergy<theDistFunc[i].GetLabel()) break; // that is the energy we need
41 }
42 G4int low(0), high(0);
43 if(i==nDistFunc)
44 {
45 low = i-2;
46 high = i-1;
47 }
48 else if(i==0)
49 {
50 if(nDistFunc==0)
51 {
52 G4cerr << "No distribution functions to sample "
53 << "from in G4ParticleHPArbitaryTab::Sample"<<G4endl;
54 throw G4HadronicException(__FILE__, __LINE__, "nDistFunc==0");
55 }
56 else
57 {
58 return theDistFunc[0].Sample();
59 }
60 }
61 else
62 {
63 low = i-1;
64 high = i;
65 }
66 //************************************************************************
67 //EMendoza
68 /*
69 theBuffer.Merge(theManager.GetScheme(low), anEnergy,
70 theDistFunc+low, theDistFunc+high);
71 return theBuffer.Sample();
72 */
73 //************************************************************************
74 //New way to perform the 2D sampling:
75 G4double elow=theDistFunc[low].GetLabel();
76 G4double ehigh=theDistFunc[high].GetLabel();
77 G4double rval=(anEnergy-elow)/(ehigh-elow);//rval is 0 for elow and 1 for ehigh
78 G4double eoutlow=theLowThreshold[low]+rval*(theLowThreshold[high]-theLowThreshold[low]);
79 G4double eouthigh=theHighThreshold[low]+rval*(theHighThreshold[high]-theHighThreshold[low]);
81 G4double Eout_1=0,Eout_2=0;
82 if(rval<rand){
83 Eout_1=theDistFunc[low].Sample();
84 Eout_2=eoutlow+(Eout_1-theLowThreshold[low])*(eouthigh-eoutlow)/(theHighThreshold[low]-theLowThreshold[low]);
85 }
86 else{
87 Eout_1=theDistFunc[high].Sample();
88 Eout_2=eoutlow+(Eout_1-theLowThreshold[high])*(eouthigh-eoutlow)/(theHighThreshold[high]-theLowThreshold[high]);
89 }
90 return Eout_2;
91
92 //************************************************************************
93 }
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
#define G4UniformRand()
Definition: Randomize.hh:52

References G4cerr, G4endl, G4UniformRand, G4ParticleHPVector::GetLabel(), nDistFunc, G4ParticleHPVector::Sample(), theDistFunc, theHighThreshold, and theLowThreshold.

Field Documentation

◆ nDistFunc

G4int G4ParticleHPArbitaryTab::nDistFunc
private

Definition at line 111 of file G4ParticleHPArbitaryTab.hh.

Referenced by G4ParticleHPArbitaryTab(), Init(), and Sample().

◆ theBuffer

G4ParticleHPVector G4ParticleHPArbitaryTab::theBuffer
private

Definition at line 114 of file G4ParticleHPArbitaryTab.hh.

◆ theDistFunc

G4ParticleHPVector* G4ParticleHPArbitaryTab::theDistFunc
private

◆ theFractionalProb

G4ParticleHPVector G4ParticleHPArbitaryTab::theFractionalProb
private

Definition at line 110 of file G4ParticleHPArbitaryTab.hh.

Referenced by GetFractionalProbability(), and Init().

◆ theHighThreshold

G4double G4ParticleHPArbitaryTab::theHighThreshold[1000]
private

Definition at line 118 of file G4ParticleHPArbitaryTab.hh.

Referenced by Init(), and Sample().

◆ theLowThreshold

G4double G4ParticleHPArbitaryTab::theLowThreshold[1000]
private

Definition at line 117 of file G4ParticleHPArbitaryTab.hh.

Referenced by Init(), and Sample().

◆ theManager

G4InterpolationManager G4ParticleHPArbitaryTab::theManager
private

Definition at line 112 of file G4ParticleHPArbitaryTab.hh.

Referenced by Init().


The documentation for this class was generated from the following files: