G4PenelopeBremsstrahlungAngular Class Reference

#include <G4PenelopeBremsstrahlungAngular.hh>

Inheritance diagram for G4PenelopeBremsstrahlungAngular:

G4VEmAngularDistribution

Public Member Functions

 G4PenelopeBremsstrahlungAngular ()
 ~G4PenelopeBremsstrahlungAngular ()
void Initialize ()
 The Initialize() method forces the cleaning of tables.
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)
void SetVerbosityLevel (G4int vl)
 Set/Get Verbosity level.
G4int GetVerbosityLevel ()

Detailed Description

Definition at line 55 of file G4PenelopeBremsstrahlungAngular.hh.


Constructor & Destructor Documentation

G4PenelopeBremsstrahlungAngular::G4PenelopeBremsstrahlungAngular (  ) 

Definition at line 57 of file G4PenelopeBremsstrahlungAngular.cc.

00057                                                                  : 
00058   G4VEmAngularDistribution("Penelope"), theEffectiveZSq(0),
00059   theLorentzTables1(0),theLorentzTables2(0)
00060   
00061 {
00062   dataRead = false;
00063   verbosityLevel = 0;
00064 }

G4PenelopeBremsstrahlungAngular::~G4PenelopeBremsstrahlungAngular (  ) 

Definition at line 68 of file G4PenelopeBremsstrahlungAngular.cc.

00069 {
00070   ClearTables();
00071 }


Member Function Documentation

G4int G4PenelopeBremsstrahlungAngular::GetVerbosityLevel (  )  [inline]

Definition at line 80 of file G4PenelopeBremsstrahlungAngular.hh.

00080 {return verbosityLevel;};

void G4PenelopeBremsstrahlungAngular::Initialize (  ) 

The Initialize() method forces the cleaning of tables.

Definition at line 75 of file G4PenelopeBremsstrahlungAngular.cc.

Referenced by G4PenelopeBremsstrahlungModel::Initialise().

00076 {
00077   ClearTables();
00078 }

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 439 of file G4PenelopeBremsstrahlungAngular.cc.

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

00442 {
00443   G4cout << "WARNING: G4PenelopeBremsstrahlungAngular() does NOT support PolarAngle()" << G4endl;
00444   G4cout << "Please use the alternative interface SampleDirection()" << G4endl;
00445   G4Exception("G4PenelopeBremsstrahlungAngular::PolarAngle()",
00446               "em0005",FatalException,"Unsupported interface");  
00447   return 0;
00448 }

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). Forces the calculation of tables, if they are not available

Implements G4VEmAngularDistribution.

Definition at line 309 of file G4PenelopeBremsstrahlungAngular.cc.

References FatalException, G4VEmAngularDistribution::fLocalDirection, G4cout, G4endl, G4Exception(), G4UniformRand, G4DynamicParticle::GetKineticEnergy(), G4DynamicParticle::GetMomentumDirection(), G4Material::GetName(), and G4PhysicsVector::Value().

Referenced by G4PenelopeBremsstrahlungModel::SampleSecondaries().

00313 {
00314   if (!material)
00315     {
00316       G4Exception("G4PenelopeBremsstrahlungAngular::SampleDirection()",
00317                   "em2040",FatalException,"The pointer to G4Material* is NULL");
00318       return fLocalDirection;
00319     }
00320   
00321   G4double Zmat = GetEffectiveZ(material);
00322   if (verbosityLevel > 0)
00323     {
00324       G4cout << "Effective <Z> for material : " << material->GetName() << 
00325         " = " << Zmat << G4endl;
00326     }
00327 
00328   G4double ePrimary = dp->GetKineticEnergy();
00329 
00330   G4double beta = std::sqrt(ePrimary*(ePrimary+2*electron_mass_c2))/
00331     (ePrimary+electron_mass_c2);
00332   G4double cdt = 0;
00333   G4double sinTheta = 0;
00334   G4double phi = 0;
00335 
00336   //Use a pure dipole distribution for energy above 500 keV
00337   if (ePrimary > 500*keV)
00338     {
00339       cdt = 2.0*G4UniformRand() - 1.0;
00340       if (G4UniformRand() > 0.75)
00341         {
00342           if (cdt<0)
00343             cdt = -1.0*std::pow(-cdt,1./3.);
00344           else
00345             cdt = std::pow(cdt,1./3.);
00346         }
00347       cdt = (cdt+beta)/(1.0+beta*cdt);
00348       //Get primary kinematics
00349       sinTheta = std::sqrt(1. - cdt*cdt);
00350       phi  = twopi * G4UniformRand(); 
00351       fLocalDirection.set(sinTheta* std::cos(phi),
00352                       sinTheta* std::sin(phi),
00353                       cdt);
00354       //rotate
00355       fLocalDirection.rotateUz(dp->GetMomentumDirection());
00356       //return
00357       return fLocalDirection;
00358     }
00359   
00360   //Else, retrieve tables and go through the full thing
00361   if (!theLorentzTables1)
00362       theLorentzTables1 = new std::map<G4double,G4PhysicsTable*>;
00363   if (!theLorentzTables2)
00364     theLorentzTables2 = new std::map<G4double,G4PhysicsTable*>;
00365 
00366   //Check if tables exist for the given Zmat
00367   if (!(theLorentzTables1->count(Zmat)))
00368     PrepareInterpolationTables(Zmat);
00369 
00370   if (!(theLorentzTables1->count(Zmat)) || !(theLorentzTables2->count(Zmat)))
00371     {
00372       G4ExceptionDescription ed;
00373       ed << "Unable to retrieve Lorentz tables for Z= " << Zmat << G4endl;
00374       G4Exception("G4PenelopeBremsstrahlungAngular::SampleDirection()",
00375                   "em2006",FatalException,ed);
00376     }
00377     
00378   //retrieve actual tables
00379   G4PhysicsTable* theTable1 = theLorentzTables1->find(Zmat)->second;
00380   G4PhysicsTable* theTable2 = theLorentzTables2->find(Zmat)->second;
00381       
00382   G4double RK=20.0*eGamma/ePrimary;
00383   G4int ik=std::min((G4int) RK,19);
00384   
00385   G4double P10=0,P11=0,P1=0;
00386   G4double P20=0,P21=0,P2=0;
00387 
00388   //First coefficient
00389   G4PhysicsFreeVector* v1 = (G4PhysicsFreeVector*) (*theTable1)[ik];
00390   G4PhysicsFreeVector* v2 = (G4PhysicsFreeVector*) (*theTable1)[ik+1];
00391   P10 = v1->Value(beta);
00392   P11 = v2->Value(beta);
00393   P1=P10+(RK-(G4double) ik)*(P11-P10);
00394   
00395   //Second coefficient
00396   G4PhysicsFreeVector* v3 = (G4PhysicsFreeVector*) (*theTable2)[ik];
00397   G4PhysicsFreeVector* v4 = (G4PhysicsFreeVector*) (*theTable2)[ik+1];
00398   P20=v3->Value(beta); 
00399   P21=v4->Value(beta);
00400   P2=P20+(RK-(G4double) ik)*(P21-P20);
00401   
00402   //Sampling from the Lorenz-trasformed dipole distributions
00403   P1=std::min(std::exp(P1)/beta,1.0);
00404   G4double betap = std::min(std::max(beta*(1.0+P2/beta),0.0),0.9999);
00405   
00406   G4double testf=0;
00407   
00408   if (G4UniformRand() < P1)
00409     {
00410       do{
00411         cdt = 2.0*G4UniformRand()-1.0;
00412         testf=2.0*G4UniformRand()-(1.0+cdt*cdt);
00413       }while(testf>0);
00414     }
00415   else
00416     {
00417       do{
00418         cdt = 2.0*G4UniformRand()-1.0;
00419         testf=G4UniformRand()-(1.0-cdt*cdt);
00420       }while(testf>0);
00421     }
00422   cdt = (cdt+betap)/(1.0+betap*cdt);
00423 
00424   //Get primary kinematics
00425   sinTheta = std::sqrt(1. - cdt*cdt);
00426   phi  = twopi * G4UniformRand(); 
00427   fLocalDirection.set(sinTheta* std::cos(phi),
00428                       sinTheta* std::sin(phi),
00429                       cdt);
00430   //rotate
00431   fLocalDirection.rotateUz(dp->GetMomentumDirection());
00432   //return
00433   return fLocalDirection;
00434   
00435 }

void G4PenelopeBremsstrahlungAngular::SetVerbosityLevel ( G4int  vl  )  [inline]

Set/Get Verbosity level.

Definition at line 79 of file G4PenelopeBremsstrahlungAngular.hh.

00079 {verbosityLevel = vl;};


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:52 2013 for Geant4 by  doxygen 1.4.7