Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 ()
 

Detailed Description

Definition at line 45 of file G4ParticleHPArbitaryTab.hh.

Constructor & Destructor Documentation

G4ParticleHPArbitaryTab::G4ParticleHPArbitaryTab ( )
inline

Definition at line 48 of file G4ParticleHPArbitaryTab.hh.

49  {
50  theDistFunc = 0;
51  nDistFunc = 0;
52  }
G4ParticleHPArbitaryTab::~G4ParticleHPArbitaryTab ( )
inline

Definition at line 53 of file G4ParticleHPArbitaryTab.hh.

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

Member Function Documentation

G4double G4ParticleHPArbitaryTab::GetFractionalProbability ( G4double  anEnergy)
inlinevirtual

Implements G4VParticleHPEDis.

Definition at line 101 of file G4ParticleHPArbitaryTab.hh.

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

Here is the call graph for this function:

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

Implements G4VParticleHPEDis.

Definition at line 58 of file G4ParticleHPArbitaryTab.hh.

59  {
60  G4int i;
61  theFractionalProb.Init(theData, CLHEP::eV);
62  theData >> nDistFunc; // = number of incoming n energy points
63  theDistFunc = new G4ParticleHPVector [nDistFunc];
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);
71  theDistFunc[i].IntegrateAndNormalise();
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++){
83  G4int np=theDistFunc[i].GetVectorLength();
84  theLowThreshold[i]=theDistFunc[i].GetEnergy(0);
85  theHighThreshold[i]=theDistFunc[i].GetEnergy(np-1);
86  for(G4int j=0;j<np-1;j++){
87  if(theDistFunc[i].GetXsec(j+1)>1.e-20){
88  theLowThreshold[i]=theDistFunc[i].GetEnergy(j);
89  break;
90  }
91  }
92  for(G4int j=1;j<np;j++){
93  if(theDistFunc[i].GetXsec(j-1)>1.e-20){
94  theHighThreshold[i]=theDistFunc[i].GetEnergy(j);
95  }
96  }
97  }
98  //************************************************************************
99  }
G4double GetEnergy(G4int i) const
G4int GetVectorLength() const
void Init(G4int aScheme, G4int aRange)
int G4int
Definition: G4Types.hh:78
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
static constexpr double eV
double G4double
Definition: G4Types.hh:76
void SetLabel(G4double aLabel)

Here is the call graph for this function:

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
#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:


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