52   theReducedXSTable(0),theEffectiveZSq(0),theSamplingTable(0),
 
   53   thePBcut(0),fVerbosity(verbosity)
 
   57     {1.0e-12,0.025e0,0.05e0,0.075e0,0.1e0,0.15e0,0.2e0,0.25e0,
 
   58     0.3e0,0.35e0,0.4e0,0.45e0,0.5e0,0.55e0,0.6e0,0.65e0,0.7e0,
 
   59     0.75e0,0.8e0,0.85e0,0.9e0,0.925e0,0.95e0,0.97e0,0.99e0,
 
   60     0.995e0,0.999e0,0.9995e0,0.9999e0,0.99995e0,0.99999e0,1.0e0};
 
   62   for (
size_t ix=0;ix<nBinsX;ix++)
 
   63     theXGrid[ix] = tempvector[ix];
 
   65   for (
size_t i=0;i<nBinsE;i++)
 
   68   theElementData = 
new std::map<G4int,G4DataVector*>; 
 
   83       std::map<G4int,G4DataVector*>::iterator i;
 
   84       for (i=theElementData->begin(); i != theElementData->end(); i++)        
 
   86       delete theElementData;
 
   99     G4Exception(
"G4PenelopeBremsstrahlungFS::ClearTables()",
 
  102   std::map< std::pair<const G4Material*,G4double> ,
G4PhysicsTable*>::iterator j;
 
  104   if (theReducedXSTable)
 
  106       for (j=theReducedXSTable->begin(); j != theReducedXSTable->end(); j++)
 
  112       delete theReducedXSTable;
 
  113       theReducedXSTable = 0;
 
  116   if (theSamplingTable)
 
  118       for (j=theSamplingTable->begin(); j != theSamplingTable->end(); j++)
 
  124       delete theSamplingTable;
 
  125       theSamplingTable = 0;
 
  141       delete theEffectiveZSq;
 
  152   if (!theEffectiveZSq)
 
  155       ed << 
"The container for the <Z^2> values is not initialized" << 
G4endl;
 
  156       G4Exception(
"G4PenelopeBremsstrahlungFS::GetEffectiveZSquared()",
 
  161   if (theEffectiveZSq->count(material))
 
  162     return theEffectiveZSq->find(material)->second;    
 
  166       ed << 
"The value of  <Z^2> is not properly set for material " << 
 
  169       G4Exception(
"G4PenelopeBremsstrahlungFS::GetEffectiveZSquared()",
 
  189     G4Exception(
"G4PenelopeBremsstrahlungFS::BuildScaledXSTable()",
 
  194       G4cout << 
"Entering in G4PenelopeBremsstrahlungFS::BuildScaledXSTable for " << 
 
  196       G4cout << 
"Threshold = " << cut/
keV << 
" keV, isMaster= " << isMaster << 
 
  201   if (!theSamplingTable)    
 
  203       new std::map< std::pair<const G4Material*,G4double> , 
G4PhysicsTable*>;
 
  209   if (!theReducedXSTable)
 
  210     theReducedXSTable = 
new std::map< std::pair<const G4Material*,G4double> ,
 
  212   if (!theEffectiveZSq)
 
  213     theEffectiveZSq = 
new std::map<const G4Material*,G4double>;
 
  220   std::vector<G4double> *StechiometricFactors = 
new std::vector<G4double>;
 
  224   for (
G4int i=0;i<nElements;i++)
 
  226       G4double fraction = fractionVector[i];
 
  227       G4double atomicWeigth = (*elementVector)[i]->GetA()/(
g/
mole);
 
  228       StechiometricFactors->push_back(fraction/atomicWeigth);
 
  231   G4double MaxStechiometricFactor = 0.;
 
  232   for (
G4int i=0;i<nElements;i++)
 
  234       if ((*StechiometricFactors)[i] > MaxStechiometricFactor)
 
  235         MaxStechiometricFactor = (*StechiometricFactors)[i];
 
  238   for (
G4int i=0;i<nElements;i++)
 
  239     (*StechiometricFactors)[i] /=  MaxStechiometricFactor;
 
  243   for (
G4int i=0;i<nElements;i++)
 
  245       G4double Z = (*elementVector)[i]->GetZ();
 
  246       sumz2 += (*StechiometricFactors)[i]*Z*
Z;
 
  247       sums  += (*StechiometricFactors)[i];
 
  251   theEffectiveZSq->insert(std::make_pair(material,ZBR2));
 
  260   for (
G4int iel=0;iel<nElements;iel++)
 
  262       G4double Z = (*elementVector)[iel]->GetZ();
 
  264       G4double wgt = (*StechiometricFactors)[iel]*Z*Z/ZBR2;
 
  268       if (!theElementData->count(iZ))
 
  271       if (!theElementData->count(iZ))
 
  274           ed << 
"Error in G4PenelopeBremsstrahlungFS::BuildScaledXSTable" << 
G4endl;
 
  275           ed << 
"Unable to retrieve data for element " << iZ << 
G4endl;
 
  276           G4Exception(
"G4PenelopeBremsstrahlungFS::BuildScaledXSTable()",
 
  281       G4DataVector* atomData = theElementData->find(iZ)->second;
 
  283       for (
size_t ie=0;ie<nBinsE;ie++)
 
  285       (*tempData)[ie] += wgt*(*atomData)[ie*(nBinsX+1)+nBinsX]; 
 
  286       for (
size_t ix=0;ix<nBinsX;ix++)
 
  287         (*tempMatrix)[ie*nBinsX+ix] += wgt*(*atomData)[ie*(nBinsX+1)+ix];    
 
  295   for (
size_t ie=0;ie<nBinsE;ie++)
 
  299       for (
size_t ix=0;ix<nBinsX;ix++)  
 
  300     tempData2[ix] = (*tempMatrix)[ie*nBinsX+ix]; 
 
  305       G4double fnorm = (*tempData)[ie]/(rsum*fact);
 
  306       G4double TST = 100.*std::fabs(fnorm-1.0);
 
  310       ed << 
"G4PenelopeBremsstrahlungFS. Corrupted data files?" << 
G4endl;
 
  311       G4cout << 
"TST= " << TST << 
"; fnorm = " << fnorm << 
G4endl;
 
  315       G4Exception(
"G4PenelopeBremsstrahlungFS::BuildScaledXSTable()",
 
  318       for (
size_t ix=0;ix<nBinsX;ix++)
 
  319     (*tempMatrix)[ie*nBinsX+ix] *= fnorm;                    
 
  325   G4PhysicsTable* thePhysicsTable = 
new G4PhysicsTable();
 
  333   for (
size_t i=0;i<nBinsX;i++)
 
  334     thePhysicsTable->
push_back(
new G4PhysicsFreeVector(nBinsE+1));
 
  336   for (
size_t ix=0;ix<nBinsX;ix++)
 
  338       G4PhysicsFreeVector* theVec = 
 
  339     (G4PhysicsFreeVector*) ((*thePhysicsTable)[ix]);      
 
  340       for (
size_t ie=0;ie<nBinsE;ie++)
 
  342       G4double logene = std::log(theEGrid[ie]);
 
  343       G4double aValue = (*tempMatrix)[ie*nBinsX+ix];
 
  346       theVec->
PutValue(ie+1,logene,std::log(aValue));
 
  352       G4double val1eV = (*theVec)[1]+derivative*(log1eV-theVec->
Energy(1));
 
  356   std::pair<const G4Material*,G4double> theKey = std::make_pair(material,cut);
 
  357   theReducedXSTable->insert(std::make_pair(theKey,thePhysicsTable));
 
  359   delete StechiometricFactors;
 
  364   if (!(theSamplingTable->count(theKey)))    
 
  365     InitializeEnergySampling(material,cut);
 
  372 void G4PenelopeBremsstrahlungFS::ReadDataFile(
G4int Z)
 
  375   char* path = getenv(
"G4LEDATA");
 
  378       G4String excep = 
"G4PenelopeBremsstrahlungFS - G4LEDATA environment variable not set!";
 
  379       G4Exception(
"G4PenelopeBremsstrahlungFS::ReadDataFile()",
 
  386   std::ostringstream ost;
 
  388     ost << path << 
"/penelope/bremsstrahlung/pdebr" << Z << 
".p08";
 
  390     ost << path << 
"/penelope/bremsstrahlung/pdebr0" << Z << 
".p08";
 
  391   std::ifstream 
file(ost.str().c_str());
 
  394       G4String excep = 
"G4PenelopeBremsstrahlungFS - data file " + 
 
  395     G4String(ost.str()) + 
" not found!";
 
  396       G4Exception(
"G4PenelopeBremsstrahlungFS::ReadDataFile()",
 
  408       ed << 
"Corrupted data file for Z=" << Z << 
G4endl;
 
  409       G4Exception(
"G4PenelopeBremsstrahlungFS::ReadDataFile()",
 
  416   for (
size_t ie=0;ie<nBinsE;ie++)
 
  421     theEGrid[ie] = myDouble*
eV;
 
  423       for (
size_t ix=0;ix<nBinsX;ix++)
 
  426       (*theMatrix)[ie*(nBinsX+1)+ix] = myDouble*
millibarn;
 
  429       (*theMatrix)[ie*(nBinsX+1)+nBinsX] = myDouble*
millibarn;
 
  433     theElementData->insert(std::make_pair(Z,theMatrix));
 
  450   size_t size = nBinsX;
 
  454   if (momOrder<-1 || size<2 || theXGrid[0]<0)
 
  456       G4Exception(
"G4PenelopeBremsstrahlungFS::GetMomentumIntegral()",
 
  460   for (
size_t i=1;i<size;i++)
 
  462       if (theXGrid[i]<0 || theXGrid[i]<theXGrid[i-1])
 
  465       ed << 
"Invalid call for bin " << i << 
G4endl;
 
  466       G4Exception(
"G4PenelopeBremsstrahlungFS::GetMomentumIntegral()",
 
  473   if (xup < theXGrid[0])
 
  475   bool loopAgain = 
true;
 
  478   for (
size_t i=0;i<size-1;i++)
 
  494       if (std::fabs(dx)>1e-14*std::fabs(dy))
 
  499         ds = a*std::log(xtc/x1)+b*(xtc-
x1);
 
  500       else if (momOrder == 0) 
 
  501         ds = a*(xtc-
x1) + 0.5*b*(xtc*xtc-x1*x1);
 
  503         ds = a*(std::pow(xtc,momOrder+1)-std::pow(x1,momOrder+1))/((
G4double) (momOrder + 1))
 
  504           + b*(std::pow(xtc,momOrder+2)-std::pow(x1,momOrder+2))/((
G4double) (momOrder + 2));       
 
  507     ds = 0.5*(y1+
y2)*(xtc-x1)*std::pow(xtc,momOrder);
 
  521   std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
 
  523   if (!(theReducedXSTable->count(theKey)))
 
  525       G4Exception(
"G4PenelopeBremsstrahlungFS::GetScaledXSTable()",
 
  526           "em2013",
FatalException,
"Unable to retrieve the cross section table");
 
  529   return theReducedXSTable->find(theKey)->second;
 
  538     G4cout << 
"Entering in G4PenelopeBremsstrahlungFS::InitializeEnergySampling() for " << 
 
  542   std::pair<const G4Material*,G4double> theKey = std::make_pair(material,cut);
 
  550   for (
size_t i=0;i<nBinsE;i++)
 
  555   if (!(theReducedXSTable->count(theKey)))    
 
  556     G4Exception(
"G4PenelopeBremsstrahlungFS::InitializeEnergySampling()",
 
  557         "em2013",
FatalException,
"Unable to retrieve the cross section table");
 
  558   G4PhysicsTable* theTableReduced = theReducedXSTable->find(theKey)->second;
 
  560   for (
size_t ie=0;ie<nBinsE;ie++)
 
  566       theVec->
PutValue(0,theXGrid[0],value);
 
  567       for (
size_t ix=1;ix<nBinsX;ix++)
 
  584       theVec->
PutValue(ix,theXGrid[ix],value);
 
  591       for (
size_t ix=0;ix<nBinsX;ix++)  
 
  594       tempData[ix] = std::exp((*vv)[ie+1]);
 
  599       thePBvec->
PutValue(ie,theEGrid[ie],pbval);
 
  603   theSamplingTable->insert(std::make_pair(theKey,thePhysicsTable));
 
  604   thePBcut->insert(std::make_pair(theKey,thePBvec));
 
  613   std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
 
  614   if (!(theSamplingTable->count(theKey)) || !(thePBcut->count(theKey)))
 
  617       ed << 
"Unable to retrieve the SamplingTable: " << 
 
  618     theSamplingTable->count(theKey) << 
" " << 
 
  619     thePBcut->count(theKey) << 
G4endl;
 
  620       G4Exception(
"G4PenelopeBremsstrahlungFS::SampleGammaEnergy()",
 
  625   const G4PhysicsTable* theTableInte = theSamplingTable->find(theKey)->second;
 
  626   const G4PhysicsTable* theTableRed = theReducedXSTable->find(theKey)->second;
 
  630   G4bool firstOrLastBin = 
false;
 
  632   if (energy < theEGrid[0]) 
 
  635       firstOrLastBin = 
true;
 
  637   else if (energy > theEGrid[nBinsE-1]) 
 
  640       firstOrLastBin = 
true;
 
  649       if (energy > theEGrid[k])
 
  671       fCache.
Put(theTempVec);
 
  673     G4cout << 
"Creating new instance of G4PhysicsFreeVector() on the worker" << 
G4endl;
 
  681       for (
size_t iloop=0;iloop<nBinsX;iloop++)
 
  683       G4double val = (*theVec1)[iloop]+(((*theVec2)[iloop]-(*theVec1)[iloop]))*
 
  684         (energy-theEGrid[eBin])/(theEGrid[eBin+1]-theEGrid[eBin]);
 
  685       theTempVec->
PutValue(iloop,theXGrid[iloop],val);
 
  690       for (
size_t iloop=0;iloop<nBinsX;iloop++) 
 
  691     theTempVec->
PutValue(iloop,theXGrid[iloop],(*theVec1)[iloop]);  
 
  695   G4double pbcut = (*(thePBcut->find(theKey)->second))[eBin];
 
  699       pbcut = (*(thePBcut->find(theKey)->second))[eBin] + 
 
  700     ((*(thePBcut->find(theKey)->second))[eBin+1]-(*(thePBcut->find(theKey)->second))[eBin])*
 
  701     (energy-theEGrid[eBin])/(theEGrid[eBin+1]-theEGrid[eBin]);
 
  704   G4double pCumulative = (*theTempVec)[nBinsX-1]; 
 
  713       if (pt < (*theTempVec)[0])
 
  715       else if (pt > (*theTempVec)[nBinsX-1])
 
  719       G4double delta = pt-(*theTempVec)[nBinsX-1];
 
  720       if (delta < pt*1e-10) 
 
  724           ed << 
"Found that (pt > (*theTempVec)[nBinsX-1]) with pt = " << pt << 
 
  725         " , (*theTempVec)[nBinsX-1] = " << (*theTempVec)[nBinsX-1] << 
" and delta = " << 
 
  726         (pt-(*theTempVec)[nBinsX-1]) << 
G4endl;
 
  727           ed << 
"Possible symptom of problem with numerical precision" << 
G4endl;
 
  728           G4Exception(
"G4PenelopeBremsstrahlungFS::SampleGammaEnergy()",
 
  734           ed << 
"Crash at (pt > (*theTempVec)[nBinsX-1]) with pt = " << pt << 
 
  735         " , (*theTempVec)[nBinsX-1]=" << (*theTempVec)[nBinsX-1] << 
" and nBinsX = " << 
 
  737           ed << 
"Material: " << mat->
GetName() << 
", energy = " << energy/
keV << 
" keV" << 
 
  739           G4Exception(
"G4PenelopeBremsstrahlungFS::SampleGammaEnergy()",
 
  750           if (pt > (*theTempVec)[k])
 
  765       G4double pdf1 = std::exp((*v1)[eBin+1]);
 
  766       G4double pdf2 = std::exp((*v2)[eBin+1]);    
 
  775     wbcut  = (cut < theEGrid[eBin]) ? cut/theEGrid[eBin] : 1.0;
 
  788           ed << 
"Warning in G4PenelopeBremsstrahlungFS::SampleX()" << 
G4endl;
 
  789           ed << 
"Conflicting end-point values: w1=" << w1 << 
"; w2 = " << w2 << 
G4endl;
 
  790           ed << 
"wbcut = " << wbcut << 
" energy= " << energy/
keV << 
" keV" << 
G4endl;
 
  791           ed << 
"cut = " << cut/
keV << 
" keV" << 
G4endl;
 
  792           G4Exception(
"G4PenelopeBremsstrahlungFS::SampleGammaEnergy()",
"em2015",
 
  808     }
while(eGamma < cut); 
 
G4double GetEffectiveZSquared(const G4Material *mat) const 
 
G4double GetMomentumIntegral(G4double *y, G4double up, G4int momOrder) const 
 
std::vector< G4Element * > G4ElementVector
 
void PutValue(size_t binNumber, G4double binValue, G4double dataValue)
 
std::ostringstream G4ExceptionDescription
 
const G4String & GetName() const 
 
void push_back(G4PhysicsVector *)
 
G4double SampleGammaEnergy(G4double energy, const G4Material *, const G4double cut) const 
 
G4double G4NeutronHPJENDLHEData::G4double result
 
const G4ElementVector * GetElementVector() const 
 
G4GLOB_DLL std::ostream G4cout
 
void BuildScaledXSTable(const G4Material *material, G4double cut, G4bool isMaster)
 
void ClearTables(G4bool isMaster=true)
Reserved for the master model: they build and handle tables. 
 
std::ostream & tab(std::ostream &)
 
G4double Energy(size_t index) const 
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
~G4PenelopeBremsstrahlungFS()
 
T max(const T t1, const T t2)
brief Return the largest of the two arguments 
 
G4PenelopeBremsstrahlungFS(G4int verbosity=0)
Only master models are supposed to create instances. 
 
T min(const T t1, const T t2)
brief Return the smallest of the two arguments 
 
const XML_Char int const XML_Char * value
 
size_t GetNumberOfElements() const 
 
const G4double * GetFractionVector() const 
 
const G4PhysicsTable * GetScaledXSTable(const G4Material *, const G4double cut) const 
 
void Put(const value_type &val) const