59 theLorentzTables1(0),theLorentzTables2(0)
82void G4PenelopeBremsstrahlungAngular::ClearTables()
84 std::map<G4double,G4PhysicsTable*>::iterator j;
86 if (theLorentzTables1)
88 for (j=theLorentzTables1->begin(); j != theLorentzTables1->end(); j++)
94 delete theLorentzTables1;
95 theLorentzTables1 = 0;
98 if (theLorentzTables2)
100 for (j=theLorentzTables2->begin(); j != theLorentzTables2->end(); j++)
106 delete theLorentzTables2;
107 theLorentzTables2 = 0;
111 delete theEffectiveZSq;
118void G4PenelopeBremsstrahlungAngular::ReadDataFile()
121 char* path = getenv(
"G4LEDATA");
125 "G4PenelopeBremsstrahlungAngular - G4LEDATA environment variable not set!";
126 G4Exception(
"G4PenelopeBremsstrahlungAngular::ReadDataFile()",
131 G4String pathFile = pathString +
"/penelope/bremsstrahlung/pdbrang.p08";
132 std::ifstream file(pathFile);
136 G4String excep =
"G4PenelopeBremsstrahlungAngular - data file " + pathFile +
" not found!";
137 G4Exception(
"G4PenelopeBremsstrahlungAngular::ReadDataFile()",
143 for (k=0;k<NumberofKPoints;k++)
144 for (i=0;i<NumberofZPoints;i++)
145 for (j=0;j<NumberofEPoints;j++)
150 file >> iz1 >> ie1 >> ik1 >> zr >> er >> kr >> a1 >> a2;
152 if ((iz1-1 == i) && (ik1-1 == k) && (ie1-1 == j))
160 ed <<
"Corrupted data file " << pathFile <<
"?" <<
G4endl;
161 G4Exception(
"G4PenelopeBremsstrahlungAngular::ReadDataFile()",
171void G4PenelopeBremsstrahlungAngular::PrepareInterpolationTables(
G4double Zmat)
178 G4Exception(
"G4PenelopeBremsstrahlungAngular::PrepareInterpolationTables()",
182 const G4int reducedEnergyGrid=21;
186 G4double Q1[NumberofEPoints][NumberofKPoints];
187 G4double Q2[NumberofEPoints][NumberofKPoints];
189 G4double Q1E[NumberofEPoints][reducedEnergyGrid];
190 G4double Q2E[NumberofEPoints][reducedEnergyGrid];
191 G4double pZ[NumberofZPoints] = {2.0,8.0,13.0,47.0,79.0,92.0};
195 for (i=0;i<NumberofEPoints;i++)
197 for (j=0;j<NumberofKPoints;j++)
205 for (k=0;k<NumberofZPoints;k++)
207 QQ1vector->
PutValue(k,pZ[k],std::log(QQ1[k][i][j]));
208 QQ2vector->
PutValue(k,pZ[k],QQ2[k][i][j]);
211 Q1[i][j]= std::exp(QQ1vector->
Value(Zmat));
212 Q2[i][j]=QQ2vector->
Value(Zmat);
217 G4double pE[NumberofEPoints] = {1.0e-03*MeV,5.0e-03*MeV,1.0e-02*MeV,5.0e-02*MeV,
218 1.0e-01*MeV,5.0e-01*MeV};
219 G4double pK[NumberofKPoints] = {0.0,0.6,0.8,0.95};
222 for(i=0;i<reducedEnergyGrid;i++)
226 for(i=0;i<NumberofEPoints;i++)
227 betas[i]=std::sqrt(pE[i]*(pE[i]+2*electron_mass_c2))/(pE[i]+electron_mass_c2);
230 for (i=0;i<NumberofEPoints;i++)
232 for (j=0;j<NumberofKPoints;j++)
233 Q1[i][j]=Q1[i][j]/Zmat;
237 for (i=0;i<NumberofEPoints;i++)
242 for (j=0;j<NumberofKPoints;j++)
244 Q1vector->
PutValue(j,pK[j],std::log(Q1[i][j]));
245 Q2vector->
PutValue(j,pK[j],Q2[i][j]);
248 for (j=0;j<reducedEnergyGrid;j++)
250 Q1E[i][j]=Q1vector->
Value(ppK[j]);
251 Q2E[i][j]=Q2vector->
Value(ppK[j]);
267 for (j=0;j<reducedEnergyGrid;j++)
277 for (j=0;j<reducedEnergyGrid;j++)
281 for (i=0;i<NumberofEPoints;i++)
283 thevec->
PutValue(i,betas[i],Q1E[i][j]);
284 thevec2->
PutValue(i,betas[i],Q2E[i][j]);
288 if (theLorentzTables1 && theLorentzTables2)
290 theLorentzTables1->insert(std::make_pair(Zmat,theTable1));
291 theLorentzTables2->insert(std::make_pair(Zmat,theTable2));
296 ed <<
"Unable to create tables of Lorentz coefficients for " <<
G4endl;
297 ed <<
"<Z>= " << Zmat <<
" in G4PenelopeBremsstrahlungAngular" <<
G4endl;
300 G4Exception(
"G4PenelopeBremsstrahlungAngular::PrepareInterpolationTables()",
316 G4Exception(
"G4PenelopeBremsstrahlungAngular::SampleDirection()",
321 G4double Zmat = GetEffectiveZ(material);
322 if (verbosityLevel > 0)
324 G4cout <<
"Effective <Z> for material : " << material->
GetName() <<
330 G4double beta = std::sqrt(ePrimary*(ePrimary+2*electron_mass_c2))/
331 (ePrimary+electron_mass_c2);
337 if (ePrimary > 500*keV)
343 cdt = -1.0*std::pow(-cdt,1./3.);
345 cdt = std::pow(cdt,1./3.);
347 cdt = (cdt+beta)/(1.0+beta*cdt);
349 sinTheta = std::sqrt(1. - cdt*cdt);
352 sinTheta* std::sin(phi),
361 if (!theLorentzTables1)
362 theLorentzTables1 =
new std::map<G4double,G4PhysicsTable*>;
363 if (!theLorentzTables2)
364 theLorentzTables2 =
new std::map<G4double,G4PhysicsTable*>;
367 if (!(theLorentzTables1->count(Zmat)))
368 PrepareInterpolationTables(Zmat);
370 if (!(theLorentzTables1->count(Zmat)) || !(theLorentzTables2->count(Zmat)))
373 ed <<
"Unable to retrieve Lorentz tables for Z= " << Zmat <<
G4endl;
374 G4Exception(
"G4PenelopeBremsstrahlungAngular::SampleDirection()",
379 G4PhysicsTable* theTable1 = theLorentzTables1->find(Zmat)->second;
380 G4PhysicsTable* theTable2 = theLorentzTables2->find(Zmat)->second;
391 P10 = v1->
Value(beta);
392 P11 = v2->
Value(beta);
393 P1=P10+(RK-(
G4double) ik)*(P11-P10);
400 P2=P20+(RK-(
G4double) ik)*(P21-P20);
403 P1=std::min(std::exp(P1)/beta,1.0);
404 G4double betap = std::min(std::max(beta*(1.0+P2/beta),0.0),0.9999);
422 cdt = (cdt+betap)/(1.0+betap*cdt);
425 sinTheta = std::sqrt(1. - cdt*cdt);
428 sinTheta* std::sin(phi),
443 G4cout <<
"WARNING: G4PenelopeBremsstrahlungAngular() does NOT support PolarAngle()" <<
G4endl;
444 G4cout <<
"Please use the alternative interface SampleDirection()" <<
G4endl;
445 G4Exception(
"G4PenelopeBremsstrahlungAngular::PolarAngle()",
454 if (!theEffectiveZSq)
455 theEffectiveZSq =
new std::map<const G4Material*,G4double>;
458 if (theEffectiveZSq->count(material))
459 return theEffectiveZSq->find(material)->second;
463 std::vector<G4double> *StechiometricFactors =
new std::vector<G4double>;
467 for (
G4int i=0;i<nElements;i++)
469 G4double fraction = fractionVector[i];
470 G4double atomicWeigth = (*elementVector)[i]->GetA()/(g/mole);
471 StechiometricFactors->push_back(fraction/atomicWeigth);
474 G4double MaxStechiometricFactor = 0.;
475 for (
G4int i=0;i<nElements;i++)
477 if ((*StechiometricFactors)[i] > MaxStechiometricFactor)
478 MaxStechiometricFactor = (*StechiometricFactors)[i];
481 for (
G4int i=0;i<nElements;i++)
482 (*StechiometricFactors)[i] /= MaxStechiometricFactor;
486 for (
G4int i=0;i<nElements;i++)
488 G4double Z = (*elementVector)[i]->GetZ();
489 sumz2 += (*StechiometricFactors)[i]*Z*Z;
490 sums += (*StechiometricFactors)[i];
492 delete StechiometricFactors;
494 G4double ZBR = std::sqrt(sumz2/sums);
495 theEffectiveZSq->insert(std::make_pair(material,ZBR));
std::vector< G4Element * > G4ElementVector
G4DLLIMPORT std::ostream G4cout
void set(double x, double y, double z)
Hep3Vector & rotateUz(const Hep3Vector &)
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
const G4ElementVector * GetElementVector() const
const G4double * GetFractionVector() const
size_t GetNumberOfElements() const
const G4String & GetName() const
~G4PenelopeBremsstrahlungAngular()
G4ThreeVector & SampleDirection(const G4DynamicParticle *dp, G4double out_energy, G4int Z, const G4Material *mat=0)
G4PenelopeBremsstrahlungAngular()
G4double PolarAngle(const G4double initial_energy, const G4double final_energy, const G4int Z)
void Initialize()
The Initialize() method forces the cleaning of tables.
void PutValue(size_t binNumber, G4double binValue, G4double dataValue)
void push_back(G4PhysicsVector *)
G4double Value(G4double theEnergy)
G4ThreeVector fLocalDirection
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostringstream G4ExceptionDescription