Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NeutronHPArbitaryTab Class Reference

#include <G4NeutronHPArbitaryTab.hh>

+ Inheritance diagram for G4NeutronHPArbitaryTab:

Public Member Functions

 G4NeutronHPArbitaryTab ()
 
 ~G4NeutronHPArbitaryTab ()
 
void Init (std::ifstream &theData)
 
G4double GetFractionalProbability (G4double anEnergy)
 
G4double Sample (G4double anEnergy)
 
- Public Member Functions inherited from G4VNeutronHPEDis
 G4VNeutronHPEDis ()
 
virtual ~G4VNeutronHPEDis ()
 
virtual void Init (std::ifstream &theData)=0
 
virtual G4double GetFractionalProbability (G4double anEnergy)=0
 
virtual G4double Sample (G4double anEnergy)=0
 

Detailed Description

Definition at line 44 of file G4NeutronHPArbitaryTab.hh.

Constructor & Destructor Documentation

◆ G4NeutronHPArbitaryTab()

G4NeutronHPArbitaryTab::G4NeutronHPArbitaryTab ( )
inline

Definition at line 47 of file G4NeutronHPArbitaryTab.hh.

48 {
49 theDistFunc = 0;
50 }

◆ ~G4NeutronHPArbitaryTab()

G4NeutronHPArbitaryTab::~G4NeutronHPArbitaryTab ( )
inline

Definition at line 51 of file G4NeutronHPArbitaryTab.hh.

52 {
53 if(theDistFunc!=0) delete [] theDistFunc;
54 }

Member Function Documentation

◆ GetFractionalProbability()

G4double G4NeutronHPArbitaryTab::GetFractionalProbability ( G4double  anEnergy)
inlinevirtual

Implements G4VNeutronHPEDis.

Definition at line 98 of file G4NeutronHPArbitaryTab.hh.

99 {
100 return theFractionalProb.GetY(anEnergy);
101 }
G4double GetY(G4double x)

◆ Init()

void G4NeutronHPArbitaryTab::Init ( std::ifstream &  theData)
inlinevirtual

Implements G4VNeutronHPEDis.

Definition at line 56 of file G4NeutronHPArbitaryTab.hh.

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

◆ Sample()

G4double G4NeutronHPArbitaryTab::Sample ( G4double  anEnergy)
virtual

Implements G4VNeutronHPEDis.

Definition at line 33 of file G4NeutronHPArbitaryTab.cc.

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

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