G4NeutronHPArbitaryTab Class Reference

#include <G4NeutronHPArbitaryTab.hh>

Inheritance diagram for G4NeutronHPArbitaryTab:

G4VNeutronHPEDis

Public Member Functions

 G4NeutronHPArbitaryTab ()
 ~G4NeutronHPArbitaryTab ()
void Init (std::ifstream &theData)
G4double GetFractionalProbability (G4double anEnergy)
G4double Sample (G4double anEnergy)

Detailed Description

Definition at line 44 of file G4NeutronHPArbitaryTab.hh.


Constructor & Destructor Documentation

G4NeutronHPArbitaryTab::G4NeutronHPArbitaryTab (  )  [inline]

Definition at line 47 of file G4NeutronHPArbitaryTab.hh.

00048   {
00049    theDistFunc = 0;
00050   }

G4NeutronHPArbitaryTab::~G4NeutronHPArbitaryTab (  )  [inline]

Definition at line 51 of file G4NeutronHPArbitaryTab.hh.

00052   {
00053    if(theDistFunc!=0) delete [] theDistFunc;
00054   }


Member Function Documentation

G4double G4NeutronHPArbitaryTab::GetFractionalProbability ( G4double  anEnergy  )  [inline, virtual]

Implements G4VNeutronHPEDis.

Definition at line 98 of file G4NeutronHPArbitaryTab.hh.

References G4NeutronHPVector::GetY().

00099   {
00100     return theFractionalProb.GetY(anEnergy);
00101   }

void G4NeutronHPArbitaryTab::Init ( std::ifstream &  theData  )  [inline, virtual]

Implements G4VNeutronHPEDis.

Definition at line 56 of file G4NeutronHPArbitaryTab.hh.

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

00057   {
00058     G4int i;
00059     theFractionalProb.Init(theData, CLHEP::eV);
00060     theData >> nDistFunc; // = number of incoming n energy points
00061     theDistFunc = new G4NeutronHPVector [nDistFunc];
00062     theManager.Init(theData);
00063     G4double currentEnergy;
00064     for(i=0; i<nDistFunc; i++)
00065     {
00066       theData >> currentEnergy;
00067       theDistFunc[i].SetLabel(currentEnergy*CLHEP::eV);
00068       theDistFunc[i].Init(theData, CLHEP::eV);
00069       //************************************************************************
00070       //EMendoza:
00071       //ThinOut() assumes that the data is linear-linear, what is false:
00072       //theDistFunc[i].ThinOut(0.02); // @@@ optimization to be finished.
00073       //************************************************************************
00074     }
00075 
00076     //************************************************************************
00077     //EMendoza:
00078     //Here we calculate the thresholds for the 2D sampling:
00079     for(i=0; i<nDistFunc; i++){
00080       G4int np=theDistFunc[i].GetVectorLength();
00081       theLowThreshold[i]=theDistFunc[i].GetEnergy(0);
00082       theHighThreshold[i]=theDistFunc[i].GetEnergy(np-1);
00083       for(G4int j=0;j<np-1;j++){
00084         if(theDistFunc[i].GetXsec(j+1)>1.e-20){
00085           theLowThreshold[i]=theDistFunc[i].GetEnergy(j);
00086           break;
00087         }
00088       }
00089       for(G4int j=1;j<np;j++){
00090         if(theDistFunc[i].GetXsec(j-1)>1.e-20){
00091           theHighThreshold[i]=theDistFunc[i].GetEnergy(j);
00092         }
00093       }
00094     }
00095      //************************************************************************
00096   }

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().

00034   {
00035     G4int i;
00036     for(i=0;i<nDistFunc;i++)
00037     {
00038       if(anEnergy<theDistFunc[i].GetLabel()) break; // that is the energy we need
00039     }
00040     G4int low(0), high(0);
00041     if(i==nDistFunc) 
00042     {
00043       low = i-2;
00044       high = i-1;
00045     }
00046     else if(i==0)
00047     {
00048       if(nDistFunc==0)
00049       {
00050         G4cerr << "No distribution functions to sample "
00051              << "from in G4NeutronHPArbitaryTab::Sample"<<G4endl;
00052         throw G4HadronicException(__FILE__, __LINE__, "nDistFunc==0");
00053       } 
00054       else 
00055       {
00056         return theDistFunc[0].Sample();
00057       }
00058     }
00059     else
00060     {
00061       low = i-1;
00062       high = i;
00063     }
00064     //************************************************************************
00065     //EMendoza
00066     /*
00067       theBuffer.Merge(theManager.GetScheme(low), anEnergy, 
00068       theDistFunc+low, theDistFunc+high);
00069       return theBuffer.Sample();
00070     */
00071     //************************************************************************
00072     //New way to perform the 2D sampling:
00073     G4double elow=theDistFunc[low].GetLabel();
00074     G4double ehigh=theDistFunc[high].GetLabel();
00075     G4double rval=(anEnergy-elow)/(ehigh-elow);//rval is 0 for elow and 1 for ehigh
00076     G4double eoutlow=theLowThreshold[low]+rval*(theLowThreshold[high]-theLowThreshold[low]);
00077     G4double eouthigh=theHighThreshold[low]+rval*(theHighThreshold[high]-theHighThreshold[low]);
00078     G4double rand=G4UniformRand();
00079     G4double Eout_1=0,Eout_2=0;
00080     if(rval<rand){
00081       Eout_1=theDistFunc[low].Sample();
00082       Eout_2=eoutlow+(Eout_1-theLowThreshold[low])*(eouthigh-eoutlow)/(theHighThreshold[low]-theLowThreshold[low]);
00083     }
00084     else{
00085       Eout_1=theDistFunc[high].Sample();
00086       Eout_2=eoutlow+(Eout_1-theLowThreshold[high])*(eouthigh-eoutlow)/(theHighThreshold[high]-theLowThreshold[high]);
00087     }
00088     return Eout_2;
00089 
00090     //************************************************************************
00091   }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:36 2013 for Geant4 by  doxygen 1.4.7