14 std::ifstream fileWithTables (filename);
16 if (not fileWithTables.is_open())
badFile (filename, 1);
23 while (fileWithTables.get() ==
'#' and ++lineCounter)
24 getline (fileWithTables, tempLine);
26 while (getline (fileWithTables, tempLine) and ++lineCounter)
28 badFile (filename, error, lineCounter);
47int INukeOsetTable :: processLine (
const std::string &line)
49 std::istringstream splitLine (line);
52 double currentDensityValue, currentEnergyValue;
55 splitLine >> currentDensityValue >> currentEnergyValue;
57 if (
int exitCode =
checkIntegrity (currentDensityValue, currentEnergyValue))
63 double xsecQel, xsecCex;
64 splitLine >> xsecQel >> xsecCex;
72 splitLine >> absorption;
80int INukeOsetTable :: checkIntegrity (
const double &densityValue,
const double &energyValue)
82 static unsigned int energyBinCounter = 0;
85 energyBinCounter = -1;
107 energyBinCounter = 0;
141void INukeOsetTable :: badFile (
const char* file,
const int &errorCode,
const int &line)
const
143 std::cerr <<
"\nERROR: " << file <<
" is corrupted (";
147 case 1: std::cerr <<
"could not be opened).\n"; exit(errorCode);
148 case 2: std::cerr <<
"wrong density";
break;
149 case 3: std::cerr <<
"different number of energy bins per density";
break;
150 case 4: std::cerr <<
"wrong energy";
break;
151 default: std::cerr <<
"undefined error";
154 std::cerr <<
" in line " << line <<
").\n";
159double INukeOsetTable :: interpolate (
const std::vector<double> &data)
const
173 double highDensityValue = lowValue;
174 double highEnergyValue = lowValue;
175 double highValue = lowValue;
200 return (lowValue + highDensityValue + highEnergyValue + highValue) /
205void INukeOsetTable :: PointHandler :: update (
const double &newValue)
229void INukeOsetTable :: setupOset (
const double &density,
const double &pionTk,
const int &pionPDG,
230 const double &protonFraction)
243void INukeOsetTable :: setCrossSections ()
unsigned int fNDensityBins
number of denisty bins
void badFile(const char *file, const int &errorCode, const int &line=0) const
stop program and through an error if input file is corrupted (method fixed for Oset tables)
int processLine(const std::string &line)
process single line from table file, push values to proper vector (method fixed for Oset tables)
double interpolate(const std::vector< double > &data) const
interpolate cross section (method fixed for Oset tables)
unsigned int fNEnergyBins
number of energy bins
void setCrossSections()
calculalte cross sections for each channel
double fDensityBinWidth
density step (must be fixed)
PointHandler fEnergyHandler
pion kinetic energy handler
double fEnergyBinWidth
energy step (must be fixed)
std::vector< double > fQelCrossSectionTable[fNChannels]
quasi-elastic piN cross section
std::vector< double > fAbsorptionCrossSectionTable
pi absorption cross section
int checkIntegrity(const double &densityValue, const double &energyValue)
check if data in file is consistent (method fixed for Oset tables)
std::vector< double > fCexCrossSectionTable[fNChannels]
charge-exchange piN cross section
PointHandler fDensityHandler
nuclear density handler
double fCexCrossSections[fNChannels]
cex cross section for each channel
double fQelCrossSections[fNChannels]
total qel (el+cex) cross section for each channel
double fAbsorptionCrossSection
absorption cross section (averaged over proton / neutron fraction)
double fNuclearDensity
nuclear density in fm-3
virtual void setCrossSections()=0
calculalte cross sections for each channel
static const unsigned int fNChannels
number of possible channels: pi+n, pi+p, pi0
double fPionKineticEnergy
pion kinetic energy in MeV
bool isEqual(const double &x, const double &y, const double &epsilon)
double binWidth
bin width used to calculate distances
int nBins
nBins to check isEdge
bool isEdge
true if value is on edge of table (should never happen)
double value
exact value as read from table
double lowWeight
distance from high boundary
double highWeight
distance from low boundary
int index
point index = index of low boundary