Geant4  10.02.p03
G4ParticleHPArbitaryTab Class Reference

#include <G4ParticleHPArbitaryTab.hh>

Inheritance diagram for G4ParticleHPArbitaryTab:
Collaboration diagram for G4ParticleHPArbitaryTab:

Public Member Functions

 G4ParticleHPArbitaryTab ()
 
 ~G4ParticleHPArbitaryTab ()
 
void Init (std::istream &theData)
 
G4double GetFractionalProbability (G4double anEnergy)
 
G4double Sample (G4double anEnergy)
 
- Public Member Functions inherited from G4VParticleHPEDis
 G4VParticleHPEDis ()
 
virtual ~G4VParticleHPEDis ()
 

Private Attributes

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

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  }
G4ParticleHPVector * theDistFunc

◆ ~G4ParticleHPArbitaryTab()

G4ParticleHPArbitaryTab::~G4ParticleHPArbitaryTab ( )
inline

Definition at line 52 of file G4ParticleHPArbitaryTab.hh.

53  {
54  if(theDistFunc!=0) delete [] theDistFunc;
55  }
G4ParticleHPVector * theDistFunc

Member Function Documentation

◆ GetFractionalProbability()

G4double G4ParticleHPArbitaryTab::GetFractionalProbability ( G4double  anEnergy)
inlinevirtual

Implements G4VParticleHPEDis.

Definition at line 100 of file G4ParticleHPArbitaryTab.hh.

101  {
102  return theFractionalProb.GetY(anEnergy);
103  }
G4ParticleHPVector theFractionalProb
G4double GetY(G4double x)
Here is the call graph for this function:

◆ Init()

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

Implements G4VParticleHPEDis.

Definition at line 57 of file G4ParticleHPArbitaryTab.hh.

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

◆ 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]);
80  G4double rand=G4UniformRand();
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  }
int G4int
Definition: G4Types.hh:78
G4ParticleHPVector * theDistFunc
#define G4UniformRand()
Definition: Randomize.hh:97
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ nDistFunc

G4int G4ParticleHPArbitaryTab::nDistFunc
private

Definition at line 110 of file G4ParticleHPArbitaryTab.hh.

◆ theBuffer

G4ParticleHPVector G4ParticleHPArbitaryTab::theBuffer
private

Definition at line 113 of file G4ParticleHPArbitaryTab.hh.

◆ theDistFunc

G4ParticleHPVector* G4ParticleHPArbitaryTab::theDistFunc
private

Definition at line 112 of file G4ParticleHPArbitaryTab.hh.

◆ theFractionalProb

G4ParticleHPVector G4ParticleHPArbitaryTab::theFractionalProb
private

Definition at line 109 of file G4ParticleHPArbitaryTab.hh.

◆ theHighThreshold

G4double G4ParticleHPArbitaryTab::theHighThreshold[1000]
private

Definition at line 117 of file G4ParticleHPArbitaryTab.hh.

◆ theLowThreshold

G4double G4ParticleHPArbitaryTab::theLowThreshold[1000]
private

Definition at line 116 of file G4ParticleHPArbitaryTab.hh.

◆ theManager

G4InterpolationManager G4ParticleHPArbitaryTab::theManager
private

Definition at line 111 of file G4ParticleHPArbitaryTab.hh.


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