Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4PenelopeBremsstrahlungAngular Class Reference

#include <G4PenelopeBremsstrahlungAngular.hh>

Inheritance diagram for G4PenelopeBremsstrahlungAngular:
G4VEmAngularDistribution

Public Member Functions

 G4PenelopeBremsstrahlungAngular ()
 
 ~G4PenelopeBremsstrahlungAngular ()
 
G4double PolarAngle (const G4double initial_energy, const G4double final_energy, const G4int Z)
 
G4ThreeVectorSampleDirection (const G4DynamicParticle *dp, G4double out_energy, G4int Z, const G4Material *mat=0)
 Samples the direction of the outgoing photon (in global coordinates). More...
 
void SetVerbosityLevel (G4int vl)
 Set/Get Verbosity level. More...
 
G4int GetVerbosityLevel ()
 
void Initialize ()
 
void PrepareTables (const G4Material *material, G4bool isMaster)
 Reserved for Master Model. More...
 
- Public Member Functions inherited from G4VEmAngularDistribution
 G4VEmAngularDistribution (const G4String &name)
 
virtual ~G4VEmAngularDistribution ()
 
virtual G4ThreeVectorSampleDirectionForShell (const G4DynamicParticle *dp, G4double finalTotalEnergy, G4int Z, G4int shellID, const G4Material *)
 
const G4StringGetName () const
 

Additional Inherited Members

- Protected Attributes inherited from G4VEmAngularDistribution
G4ThreeVector fLocalDirection
 

Detailed Description

Definition at line 56 of file G4PenelopeBremsstrahlungAngular.hh.

Constructor & Destructor Documentation

G4PenelopeBremsstrahlungAngular::G4PenelopeBremsstrahlungAngular ( )

Definition at line 60 of file G4PenelopeBremsstrahlungAngular.cc.

60  :
61  G4VEmAngularDistribution("Penelope"), theEffectiveZSq(0),
62  theLorentzTables1(0),theLorentzTables2(0)
63 
64 {
65  dataRead = false;
66  verbosityLevel = 0;
67 }
G4VEmAngularDistribution(const G4String &name)
G4PenelopeBremsstrahlungAngular::~G4PenelopeBremsstrahlungAngular ( )

Definition at line 71 of file G4PenelopeBremsstrahlungAngular.cc.

72 {
73  ClearTables();
74 }

Member Function Documentation

G4int G4PenelopeBremsstrahlungAngular::GetVerbosityLevel ( )
inline

Definition at line 78 of file G4PenelopeBremsstrahlungAngular.hh.

78 {return verbosityLevel;};
void G4PenelopeBremsstrahlungAngular::Initialize ( )

Reserved for Master Model The Initialize() method forces the cleaning of tables

Definition at line 78 of file G4PenelopeBremsstrahlungAngular.cc.

Referenced by G4PenelopeBremsstrahlungModel::Initialise(), and G4PenelopeBremsstrahlungModel::InitialiseLocal().

79 {
80  ClearTables();
81 }
G4double G4PenelopeBremsstrahlungAngular::PolarAngle ( const G4double  initial_energy,
const G4double  final_energy,
const G4int  Z 
)

Old interface, backwards compatibility. Will not work in this case it will produce a G4Exception().

Definition at line 468 of file G4PenelopeBremsstrahlungAngular.cc.

References FatalException, G4cout, G4endl, and G4Exception().

471 {
472  G4cout << "WARNING: G4PenelopeBremsstrahlungAngular() does NOT support PolarAngle()" << G4endl;
473  G4cout << "Please use the alternative interface SampleDirection()" << G4endl;
474  G4Exception("G4PenelopeBremsstrahlungAngular::PolarAngle()",
475  "em0005",FatalException,"Unsupported interface");
476  return 0;
477 }
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
void G4PenelopeBremsstrahlungAngular::PrepareTables ( const G4Material material,
G4bool  isMaster 
)

Reserved for Master Model.

Definition at line 174 of file G4PenelopeBremsstrahlungAngular.cc.

References python.hepunit::electron_mass_c2, FatalException, G4endl, G4Exception(), python.hepunit::MeV, G4PhysicsTable::push_back(), G4PhysicsFreeVector::PutValue(), G4PhysicsVector::SetSpline(), and G4PhysicsVector::Value().

Referenced by G4PenelopeBremsstrahlungModel::Initialise(), and G4PenelopeBremsstrahlungModel::InitialiseLocal().

175 {
176  //Unused at the moment: the G4PenelopeBremsstrahlungAngular is thread-local, so each worker
177  //builds its own version of the tables.
178  /*
179  if (!isMaster)
180  //Should not be here!
181  G4Exception("G4PenelopeBremsstrahlungAngular::PrepareTables()",
182  "em0100",FatalException,"Worker thread in this method");
183  */
184 
185  //Check if data file has already been read
186  if (!dataRead)
187  {
188  ReadDataFile();
189  if (!dataRead)
190  G4Exception("G4PenelopeBremsstrahlungAngular::PrepareInterpolationTables()",
191  "em2001",FatalException,"Unable to build interpolation table");
192  }
193 
194  if (!theLorentzTables1)
195  theLorentzTables1 = new std::map<G4double,G4PhysicsTable*>;
196  if (!theLorentzTables2)
197  theLorentzTables2 = new std::map<G4double,G4PhysicsTable*>;
198 
199  G4double Zmat = CalculateEffectiveZ(material);
200 
201  const G4int reducedEnergyGrid=21;
202  //Support arrays.
203  G4double betas[NumberofEPoints]; //betas for interpolation
204  //tables for interpolation
205  G4double Q1[NumberofEPoints][NumberofKPoints];
206  G4double Q2[NumberofEPoints][NumberofKPoints];
207  //expanded tables for interpolation
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};
211 
212  G4int i=0,j=0,k=0; // i=index for Z, j=index for E, k=index for K
213  //Interpolation in Z
214  for (i=0;i<NumberofEPoints;i++)
215  {
216  for (j=0;j<NumberofKPoints;j++)
217  {
218  G4PhysicsFreeVector* QQ1vector = new G4PhysicsFreeVector(NumberofZPoints);
219  G4PhysicsFreeVector* QQ2vector = new G4PhysicsFreeVector(NumberofZPoints);
220 
221  //fill vectors
222  for (k=0;k<NumberofZPoints;k++)
223  {
224  QQ1vector->PutValue(k,pZ[k],std::log(QQ1[k][i][j]));
225  QQ2vector->PutValue(k,pZ[k],QQ2[k][i][j]);
226  }
227 
228  QQ1vector->SetSpline(true);
229  QQ2vector->SetSpline(true);
230 
231  Q1[i][j]= std::exp(QQ1vector->Value(Zmat));
232  Q2[i][j]=QQ2vector->Value(Zmat);
233  delete QQ1vector;
234  delete QQ2vector;
235  }
236  }
237  G4double pE[NumberofEPoints] = {1.0e-03*MeV,5.0e-03*MeV,1.0e-02*MeV,5.0e-02*MeV,
238  1.0e-01*MeV,5.0e-01*MeV};
239  G4double pK[NumberofKPoints] = {0.0,0.6,0.8,0.95};
240  G4double ppK[reducedEnergyGrid];
241 
242  for(i=0;i<reducedEnergyGrid;i++)
243  ppK[i]=((G4double) i) * 0.05;
244 
245 
246  for(i=0;i<NumberofEPoints;i++)
247  betas[i]=std::sqrt(pE[i]*(pE[i]+2*electron_mass_c2))/(pE[i]+electron_mass_c2);
248 
249 
250  for (i=0;i<NumberofEPoints;i++)
251  {
252  for (j=0;j<NumberofKPoints;j++)
253  Q1[i][j]=Q1[i][j]/Zmat;
254  }
255 
256  //Expanded table of distribution parameters
257  for (i=0;i<NumberofEPoints;i++)
258  {
259  G4PhysicsFreeVector* Q1vector = new G4PhysicsFreeVector(NumberofKPoints);
260  G4PhysicsFreeVector* Q2vector = new G4PhysicsFreeVector(NumberofKPoints);
261 
262  for (j=0;j<NumberofKPoints;j++)
263  {
264  Q1vector->PutValue(j,pK[j],std::log(Q1[i][j])); //logarithmic
265  Q2vector->PutValue(j,pK[j],Q2[i][j]);
266  }
267 
268  for (j=0;j<reducedEnergyGrid;j++)
269  {
270  Q1E[i][j]=Q1vector->Value(ppK[j]);
271  Q2E[i][j]=Q2vector->Value(ppK[j]);
272  }
273  delete Q1vector;
274  delete Q2vector;
275  }
276  //
277  //TABLES to be stored
278  //
279  G4PhysicsTable* theTable1 = new G4PhysicsTable();
280  G4PhysicsTable* theTable2 = new G4PhysicsTable();
281  // the table will contain reducedEnergyGrid G4PhysicsFreeVectors with different
282  // values of k,
283  // Each of the G4PhysicsFreeVectors has a profile of
284  // y vs. E
285  //
286  //reserve space of the vectors.
287  for (j=0;j<reducedEnergyGrid;j++)
288  {
289  G4PhysicsFreeVector* thevec = new G4PhysicsFreeVector(NumberofEPoints);
290  theTable1->push_back(thevec);
291  G4PhysicsFreeVector* thevec2 = new G4PhysicsFreeVector(NumberofEPoints);
292  theTable2->push_back(thevec2);
293  }
294 
295  for (j=0;j<reducedEnergyGrid;j++)
296  {
297  G4PhysicsFreeVector* thevec = (G4PhysicsFreeVector*) (*theTable1)[j];
298  G4PhysicsFreeVector* thevec2 = (G4PhysicsFreeVector*) (*theTable2)[j];
299  for (i=0;i<NumberofEPoints;i++)
300  {
301  thevec->PutValue(i,betas[i],Q1E[i][j]);
302  thevec2->PutValue(i,betas[i],Q2E[i][j]);
303  }
304  thevec->SetSpline(true);
305  thevec2->SetSpline(true);
306  }
307 
308  if (theLorentzTables1 && theLorentzTables2)
309  {
310  theLorentzTables1->insert(std::make_pair(Zmat,theTable1));
311  theLorentzTables2->insert(std::make_pair(Zmat,theTable2));
312  }
313  else
314  {
316  ed << "Unable to create tables of Lorentz coefficients for " << G4endl;
317  ed << "<Z>= " << Zmat << " in G4PenelopeBremsstrahlungAngular" << G4endl;
318  delete theTable1;
319  delete theTable2;
320  G4Exception("G4PenelopeBremsstrahlungAngular::PrepareInterpolationTables()",
321  "em2005",FatalException,ed);
322  }
323 
324  return;
325 }
void PutValue(size_t binNumber, G4double binValue, G4double dataValue)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void push_back(G4PhysicsVector *)
int G4int
Definition: G4Types.hh:78
void SetSpline(G4bool)
float electron_mass_c2
Definition: hepunit.py:274
G4double Value(G4double theEnergy, size_t &lastidx) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4ThreeVector & G4PenelopeBremsstrahlungAngular::SampleDirection ( const G4DynamicParticle dp,
G4double  out_energy,
G4int  Z,
const G4Material mat = 0 
)
virtual

Samples the direction of the outgoing photon (in global coordinates).

Implements G4VEmAngularDistribution.

Definition at line 329 of file G4PenelopeBremsstrahlungAngular.cc.

References python.hepunit::electron_mass_c2, FatalException, G4VEmAngularDistribution::fLocalDirection, G4cout, G4endl, G4Exception(), G4UniformRand, G4DynamicParticle::GetKineticEnergy(), G4DynamicParticle::GetMomentumDirection(), G4Material::GetName(), python.hepunit::keV, G4INCL::Math::max(), G4INCL::Math::min(), CLHEP::Hep3Vector::rotateUz(), CLHEP::Hep3Vector::set(), python.hepunit::twopi, and G4PhysicsVector::Value().

Referenced by G4PenelopeBremsstrahlungModel::SampleSecondaries().

333 {
334  if (!material)
335  {
336  G4Exception("G4PenelopeBremsstrahlungAngular::SampleDirection()",
337  "em2040",FatalException,"The pointer to G4Material* is NULL");
338  return fLocalDirection;
339  }
340 
341  //Retrieve the effective Z
342  G4double Zmat = 0;
343 
344  if (!theEffectiveZSq)
345  {
346  G4Exception("G4PenelopeBremsstrahlungAngular::SampleDirection()",
347  "em2040",FatalException,"EffectiveZ table not available");
348  return fLocalDirection;
349  }
350 
351  //found in the table: return it
352  if (theEffectiveZSq->count(material))
353  Zmat = theEffectiveZSq->find(material)->second;
354  else
355  {
356  G4Exception("G4PenelopeBremsstrahlungAngular::SampleDirection()",
357  "em2040",FatalException,"Material not found in the effectiveZ table");
358  return fLocalDirection;
359  }
360 
361  if (verbosityLevel > 0)
362  {
363  G4cout << "Effective <Z> for material : " << material->GetName() <<
364  " = " << Zmat << G4endl;
365  }
366 
367  G4double ePrimary = dp->GetKineticEnergy();
368 
369  G4double beta = std::sqrt(ePrimary*(ePrimary+2*electron_mass_c2))/
370  (ePrimary+electron_mass_c2);
371  G4double cdt = 0;
372  G4double sinTheta = 0;
373  G4double phi = 0;
374 
375  //Use a pure dipole distribution for energy above 500 keV
376  if (ePrimary > 500*keV)
377  {
378  cdt = 2.0*G4UniformRand() - 1.0;
379  if (G4UniformRand() > 0.75)
380  {
381  if (cdt<0)
382  cdt = -1.0*std::pow(-cdt,1./3.);
383  else
384  cdt = std::pow(cdt,1./3.);
385  }
386  cdt = (cdt+beta)/(1.0+beta*cdt);
387  //Get primary kinematics
388  sinTheta = std::sqrt(1. - cdt*cdt);
389  phi = twopi * G4UniformRand();
390  fLocalDirection.set(sinTheta* std::cos(phi),
391  sinTheta* std::sin(phi),
392  cdt);
393  //rotate
395  //return
396  return fLocalDirection;
397  }
398 
399  if (!(theLorentzTables1->count(Zmat)) || !(theLorentzTables2->count(Zmat)))
400  {
402  ed << "Unable to retrieve Lorentz tables for Z= " << Zmat << G4endl;
403  G4Exception("G4PenelopeBremsstrahlungAngular::SampleDirection()",
404  "em2006",FatalException,ed);
405  }
406 
407  //retrieve actual tables
408  const G4PhysicsTable* theTable1 = theLorentzTables1->find(Zmat)->second;
409  const G4PhysicsTable* theTable2 = theLorentzTables2->find(Zmat)->second;
410 
411  G4double RK=20.0*eGamma/ePrimary;
412  G4int ik=std::min((G4int) RK,19);
413 
414  G4double P10=0,P11=0,P1=0;
415  G4double P20=0,P21=0,P2=0;
416 
417  //First coefficient
418  const G4PhysicsFreeVector* v1 = (G4PhysicsFreeVector*) (*theTable1)[ik];
419  const G4PhysicsFreeVector* v2 = (G4PhysicsFreeVector*) (*theTable1)[ik+1];
420  P10 = v1->Value(beta);
421  P11 = v2->Value(beta);
422  P1=P10+(RK-(G4double) ik)*(P11-P10);
423 
424  //Second coefficient
425  const G4PhysicsFreeVector* v3 = (G4PhysicsFreeVector*) (*theTable2)[ik];
426  const G4PhysicsFreeVector* v4 = (G4PhysicsFreeVector*) (*theTable2)[ik+1];
427  P20=v3->Value(beta);
428  P21=v4->Value(beta);
429  P2=P20+(RK-(G4double) ik)*(P21-P20);
430 
431  //Sampling from the Lorenz-trasformed dipole distributions
432  P1=std::min(std::exp(P1)/beta,1.0);
433  G4double betap = std::min(std::max(beta*(1.0+P2/beta),0.0),0.9999);
434 
435  G4double testf=0;
436 
437  if (G4UniformRand() < P1)
438  {
439  do{
440  cdt = 2.0*G4UniformRand()-1.0;
441  testf=2.0*G4UniformRand()-(1.0+cdt*cdt);
442  }while(testf>0);
443  }
444  else
445  {
446  do{
447  cdt = 2.0*G4UniformRand()-1.0;
448  testf=G4UniformRand()-(1.0-cdt*cdt);
449  }while(testf>0);
450  }
451  cdt = (cdt+betap)/(1.0+betap*cdt);
452 
453  //Get primary kinematics
454  sinTheta = std::sqrt(1. - cdt*cdt);
455  phi = twopi * G4UniformRand();
456  fLocalDirection.set(sinTheta* std::cos(phi),
457  sinTheta* std::sin(phi),
458  cdt);
459  //rotate
461  //return
462  return fLocalDirection;
463 
464 }
void set(double x, double y, double z)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetKineticEnergy() const
int G4int
Definition: G4Types.hh:78
string material
Definition: eplot.py:19
#define G4UniformRand()
Definition: Randomize.hh:87
G4GLOB_DLL std::ostream G4cout
const G4ThreeVector & GetMomentumDirection() const
Hep3Vector & rotateUz(const Hep3Vector &)
Definition: ThreeVector.cc:72
float electron_mass_c2
Definition: hepunit.py:274
G4double Value(G4double theEnergy, size_t &lastidx) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
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
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void G4PenelopeBremsstrahlungAngular::SetVerbosityLevel ( G4int  vl)
inline

Set/Get Verbosity level.

Definition at line 77 of file G4PenelopeBremsstrahlungAngular.hh.

77 {verbosityLevel = vl;};

The documentation for this class was generated from the following files: