62 theLorentzTables1(0),theLorentzTables2(0)
85 void G4PenelopeBremsstrahlungAngular::ClearTables()
87 std::map<G4double,G4PhysicsTable*>::iterator j;
89 if (theLorentzTables1)
91 for (j=theLorentzTables1->begin(); j != theLorentzTables1->end(); j++)
97 delete theLorentzTables1;
98 theLorentzTables1 = 0;
101 if (theLorentzTables2)
103 for (j=theLorentzTables2->begin(); j != theLorentzTables2->end(); j++)
109 delete theLorentzTables2;
110 theLorentzTables2 = 0;
114 delete theEffectiveZSq;
121 void G4PenelopeBremsstrahlungAngular::ReadDataFile()
124 char* path = getenv(
"G4LEDATA");
128 "G4PenelopeBremsstrahlungAngular - G4LEDATA environment variable not set!";
129 G4Exception(
"G4PenelopeBremsstrahlungAngular::ReadDataFile()",
134 G4String pathFile = pathString +
"/penelope/bremsstrahlung/pdbrang.p08";
135 std::ifstream
file(pathFile);
139 G4String excep =
"G4PenelopeBremsstrahlungAngular - data file " + pathFile +
" not found!";
140 G4Exception(
"G4PenelopeBremsstrahlungAngular::ReadDataFile()",
146 for (k=0;k<NumberofKPoints;k++)
147 for (i=0;i<NumberofZPoints;i++)
148 for (j=0;j<NumberofEPoints;j++)
153 file >> iz1 >> ie1 >> ik1 >> zr >> er >> kr >> a1 >> a2;
155 if ((iz1-1 == i) && (ik1-1 == k) && (ie1-1 == j))
163 ed <<
"Corrupted data file " << pathFile <<
"?" <<
G4endl;
164 G4Exception(
"G4PenelopeBremsstrahlungAngular::ReadDataFile()",
190 G4Exception(
"G4PenelopeBremsstrahlungAngular::PrepareInterpolationTables()",
194 if (!theLorentzTables1)
195 theLorentzTables1 =
new std::map<G4double,G4PhysicsTable*>;
196 if (!theLorentzTables2)
197 theLorentzTables2 =
new std::map<G4double,G4PhysicsTable*>;
199 G4double Zmat = CalculateEffectiveZ(material);
201 const G4int reducedEnergyGrid=21;
205 G4double Q1[NumberofEPoints][NumberofKPoints];
206 G4double Q2[NumberofEPoints][NumberofKPoints];
208 G4double Q1E[NumberofEPoints][reducedEnergyGrid];
209 G4double Q2E[NumberofEPoints][reducedEnergyGrid];
210 G4double pZ[NumberofZPoints] = {2.0,8.0,13.0,47.0,79.0,92.0};
214 for (i=0;i<NumberofEPoints;i++)
216 for (j=0;j<NumberofKPoints;j++)
222 for (k=0;k<NumberofZPoints;k++)
224 QQ1vector->
PutValue(k,pZ[k],std::log(QQ1[k][i][j]));
225 QQ2vector->
PutValue(k,pZ[k],QQ2[k][i][j]);
231 Q1[i][j]= std::exp(QQ1vector->
Value(Zmat));
232 Q2[i][j]=QQ2vector->
Value(Zmat);
239 G4double pK[NumberofKPoints] = {0.0,0.6,0.8,0.95};
242 for(i=0;i<reducedEnergyGrid;i++)
246 for(i=0;i<NumberofEPoints;i++)
250 for (i=0;i<NumberofEPoints;i++)
252 for (j=0;j<NumberofKPoints;j++)
253 Q1[i][j]=Q1[i][j]/Zmat;
257 for (i=0;i<NumberofEPoints;i++)
262 for (j=0;j<NumberofKPoints;j++)
264 Q1vector->
PutValue(j,pK[j],std::log(Q1[i][j]));
265 Q2vector->
PutValue(j,pK[j],Q2[i][j]);
268 for (j=0;j<reducedEnergyGrid;j++)
270 Q1E[i][j]=Q1vector->
Value(ppK[j]);
271 Q2E[i][j]=Q2vector->
Value(ppK[j]);
287 for (j=0;j<reducedEnergyGrid;j++)
295 for (j=0;j<reducedEnergyGrid;j++)
299 for (i=0;i<NumberofEPoints;i++)
301 thevec->
PutValue(i,betas[i],Q1E[i][j]);
302 thevec2->
PutValue(i,betas[i],Q2E[i][j]);
308 if (theLorentzTables1 && theLorentzTables2)
310 theLorentzTables1->insert(std::make_pair(Zmat,theTable1));
311 theLorentzTables2->insert(std::make_pair(Zmat,theTable2));
316 ed <<
"Unable to create tables of Lorentz coefficients for " <<
G4endl;
317 ed <<
"<Z>= " << Zmat <<
" in G4PenelopeBremsstrahlungAngular" <<
G4endl;
320 G4Exception(
"G4PenelopeBremsstrahlungAngular::PrepareInterpolationTables()",
336 G4Exception(
"G4PenelopeBremsstrahlungAngular::SampleDirection()",
344 if (!theEffectiveZSq)
346 G4Exception(
"G4PenelopeBremsstrahlungAngular::SampleDirection()",
352 if (theEffectiveZSq->count(material))
353 Zmat = theEffectiveZSq->find(material)->second;
356 G4Exception(
"G4PenelopeBremsstrahlungAngular::SampleDirection()",
357 "em2040",
FatalException,
"Material not found in the effectiveZ table");
361 if (verbosityLevel > 0)
363 G4cout <<
"Effective <Z> for material : " << material->
GetName() <<
376 if (ePrimary > 500*
keV)
382 cdt = -1.0*std::pow(-cdt,1./3.);
384 cdt = std::pow(cdt,1./3.);
386 cdt = (cdt+beta)/(1.0+beta*cdt);
388 sinTheta = std::sqrt(1. - cdt*cdt);
391 sinTheta* std::sin(phi),
399 if (!(theLorentzTables1->count(Zmat)) || !(theLorentzTables2->count(Zmat)))
402 ed <<
"Unable to retrieve Lorentz tables for Z= " << Zmat <<
G4endl;
403 G4Exception(
"G4PenelopeBremsstrahlungAngular::SampleDirection()",
408 const G4PhysicsTable* theTable1 = theLorentzTables1->find(Zmat)->second;
409 const G4PhysicsTable* theTable2 = theLorentzTables2->find(Zmat)->second;
420 P10 = v1->
Value(beta);
421 P11 = v2->
Value(beta);
422 P1=P10+(RK-(
G4double) ik)*(P11-P10);
429 P2=P20+(RK-(
G4double) ik)*(P21-P20);
451 cdt = (cdt+betap)/(1.0+betap*cdt);
454 sinTheta = std::sqrt(1. - cdt*cdt);
457 sinTheta* std::sin(phi),
472 G4cout <<
"WARNING: G4PenelopeBremsstrahlungAngular() does NOT support PolarAngle()" <<
G4endl;
473 G4cout <<
"Please use the alternative interface SampleDirection()" <<
G4endl;
474 G4Exception(
"G4PenelopeBremsstrahlungAngular::PolarAngle()",
483 if (!theEffectiveZSq)
484 theEffectiveZSq =
new std::map<const G4Material*,G4double>;
487 if (theEffectiveZSq->count(material))
488 return theEffectiveZSq->find(material)->second;
491 std::vector<G4double> *StechiometricFactors =
new std::vector<G4double>;
495 for (
G4int i=0;i<nElements;i++)
497 G4double fraction = fractionVector[i];
498 G4double atomicWeigth = (*elementVector)[i]->GetA()/(
g/
mole);
499 StechiometricFactors->push_back(fraction/atomicWeigth);
502 G4double MaxStechiometricFactor = 0.;
503 for (
G4int i=0;i<nElements;i++)
505 if ((*StechiometricFactors)[i] > MaxStechiometricFactor)
506 MaxStechiometricFactor = (*StechiometricFactors)[i];
509 for (
G4int i=0;i<nElements;i++)
510 (*StechiometricFactors)[i] /= MaxStechiometricFactor;
514 for (
G4int i=0;i<nElements;i++)
516 G4double Z = (*elementVector)[i]->GetZ();
517 sumz2 += (*StechiometricFactors)[i]*Z*
Z;
518 sums += (*StechiometricFactors)[i];
520 delete StechiometricFactors;
522 G4double ZBR = std::sqrt(sumz2/sums);
523 theEffectiveZSq->insert(std::make_pair(material,ZBR));
void set(double x, double y, double z)
std::vector< G4Element * > G4ElementVector
void PutValue(size_t binNumber, G4double binValue, G4double dataValue)
std::ostringstream G4ExceptionDescription
G4double GetKineticEnergy() const
const G4String & GetName() const
void push_back(G4PhysicsVector *)
void PrepareTables(const G4Material *material, G4bool isMaster)
Reserved for Master Model.
G4ThreeVector & SampleDirection(const G4DynamicParticle *dp, G4double out_energy, G4int Z, const G4Material *mat=0)
Samples the direction of the outgoing photon (in global coordinates).
const G4ElementVector * GetElementVector() const
G4GLOB_DLL std::ostream G4cout
std::ostream & tab(std::ostream &)
const G4ThreeVector & GetMomentumDirection() const
Hep3Vector & rotateUz(const Hep3Vector &)
G4double Value(G4double theEnergy, size_t &lastidx) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4PenelopeBremsstrahlungAngular()
size_t GetNumberOfElements() const
G4ThreeVector fLocalDirection
G4double PolarAngle(const G4double initial_energy, const G4double final_energy, const G4int Z)
const G4double * GetFractionVector() const
~G4PenelopeBremsstrahlungAngular()