Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4NeutronHPArbitaryTab Class Reference

#include <G4NeutronHPArbitaryTab.hh>

Inheritance diagram for G4NeutronHPArbitaryTab:
G4VNeutronHPEDis

Public Member Functions

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

Detailed Description

Definition at line 43 of file G4NeutronHPArbitaryTab.hh.

Constructor & Destructor Documentation

G4NeutronHPArbitaryTab::G4NeutronHPArbitaryTab ( )
inline

Definition at line 46 of file G4NeutronHPArbitaryTab.hh.

47  {
48  theDistFunc = 0;
49  }
G4NeutronHPArbitaryTab::~G4NeutronHPArbitaryTab ( )
inline

Definition at line 50 of file G4NeutronHPArbitaryTab.hh.

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

Member Function Documentation

G4double G4NeutronHPArbitaryTab::GetFractionalProbability ( G4double  anEnergy)
inlinevirtual

Implements G4VNeutronHPEDis.

Definition at line 97 of file G4NeutronHPArbitaryTab.hh.

References G4NeutronHPVector::GetY().

98  {
99  return theFractionalProb.GetY(anEnergy);
100  }
G4double GetY(G4double x)
void G4NeutronHPArbitaryTab::Init ( std::istream &  theData)
inlinevirtual

Implements G4VNeutronHPEDis.

Definition at line 55 of file G4NeutronHPArbitaryTab.hh.

References G4NeutronHPVector::GetEnergy(), G4NeutronHPVector::GetVectorLength(), G4InterpolationManager::Init(), G4NeutronHPVector::Init(), and G4NeutronHPVector::SetLabel().

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

Implements G4VNeutronHPEDis.

Definition at line 33 of file G4NeutronHPArbitaryTab.cc.

References G4cerr, G4endl, G4UniformRand, G4NeutronHPVector::GetLabel(), and G4NeutronHPVector::Sample().

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]);
78  G4double rand=G4UniformRand();
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  }
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:87
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4GLOB_DLL std::ostream G4cerr

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