source: trunk/source/processes/electromagnetic/standard/src/G4ComptonScattering52.cc @ 825

Last change on this file since 825 was 819, checked in by garnier, 16 years ago

import all except CVS

File size: 18.0 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// $Id: G4ComptonScattering52.cc,v 1.5 2007/05/16 14:00:56 vnivanch Exp $
27// GEANT4 tag $Name: geant4-09-01-patch-02 $
28//
29//
30//------------ G4ComptonScattering52 physics process -----------------------------
31//                   by Michel Maire, April 1996
32//
33// 28-05-96, DoIt() small change in ElecDirection, by M.Maire
34// 10-06-96, simplification in ComputeMicroscopicCrossSection(), by M.Maire
35// 21-06-96, SetCuts implementation, M.Maire
36// 13-09-96, small changes in DoIt for better efficiency. Thanks to P.Urban
37// 06-01-97, crossection table + meanfreepath table, M.Maire
38// 05-03-97, new Physics scheme, M.Maire
39// 28-03-97, protection in BuildPhysicsTable, M.Maire
40// 07-04-98, remove 'tracking cut' of the scattered gamma, MMa
41// 04-06-98, in DoIt, secondary production condition:
42//                                     range>std::min(threshold,safety)
43// 13-08-98, new methods SetBining()  PrintInfo()
44// 15-12-98, cross section=0 below 10 keV
45// 28-05-01, V.Ivanchenko minor changes to provide ANSI -wall compilation
46// 13-07-01, DoIt: suppression of production cut for the electron (mma)
47// 03-08-01, new methods Store/Retrieve PhysicsTable (mma)
48// 06-08-01, BuildThePhysicsTable() called from constructor (mma)
49// 17-09-01, migration of Materials to pure STL (mma)
50// 20-09-01, DoIt: fminimalEnergy = 1*eV (mma)
51// 01-10-01, come back to BuildPhysicsTable(const G4ParticleDefinition&)
52// 17-04-02, LowestEnergyLimit = 1*keV     
53// 26-05-04, cross section parametrization improved for low energy :
54//           Egamma <~ 15 keV (Laszlo)
55// 08-11-04, Remove Store/Retrieve tables (V.Ivanchenko)
56// 04-05-05, Add 52 to class name (V.Ivanchenko)
57// -----------------------------------------------------------------------------
58
59#include "G4ComptonScattering52.hh"
60#include "G4UnitsTable.hh"
61#include "G4PhysicsTableHelper.hh"
62
63//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64
65using namespace std;
66
67G4ComptonScattering52::G4ComptonScattering52(const G4String& processName,
68    G4ProcessType type):G4VDiscreteProcess (processName, type),
69    theCrossSectionTable(NULL),
70    theMeanFreePathTable(NULL),
71    LowestEnergyLimit (  1*keV),
72    HighestEnergyLimit(100*GeV),
73    NumbBinTable(80),
74    fminimalEnergy(1*eV)
75{}
76
77//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
79// destructor
80 
81G4ComptonScattering52::~G4ComptonScattering52()
82{
83   if (theCrossSectionTable) {
84      theCrossSectionTable->clearAndDestroy();
85      delete theCrossSectionTable;
86   }
87
88   if (theMeanFreePathTable) {
89      theMeanFreePathTable->clearAndDestroy();
90      delete theMeanFreePathTable;
91   }
92}
93
94//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
95
96G4bool G4ComptonScattering52::IsApplicable( const G4ParticleDefinition& particle)
97{
98   return ( &particle == G4Gamma::Gamma() ); 
99}
100 
101//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102
103void G4ComptonScattering52::SetPhysicsTableBining(
104                                   G4double lowE, G4double highE, G4int nBins)
105{
106  LowestEnergyLimit = lowE; HighestEnergyLimit = highE; NumbBinTable = nBins;
107} 
108
109//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
110 
111void G4ComptonScattering52::BuildPhysicsTable(const G4ParticleDefinition&)
112// Build cross section and mean free path tables
113{
114   G4double LowEdgeEnergy, Value;
115   G4PhysicsLogVector* ptrVector;
116
117// Build cross section per atom tables for the Compton Scattering process
118
119   if (theCrossSectionTable) {
120       theCrossSectionTable->clearAndDestroy(); delete theCrossSectionTable;}
121
122   theCrossSectionTable = new G4PhysicsTable(G4Element::GetNumberOfElements());
123   const G4ElementTable* theElementTable = G4Element::GetElementTable();
124   G4double AtomicNumber;
125   size_t J;
126
127   for ( J=0 ; J < G4Element::GetNumberOfElements(); J++ )
128       {
129        //create physics vector then fill it ....
130        ptrVector = new G4PhysicsLogVector(LowestEnergyLimit,HighestEnergyLimit,
131                                           NumbBinTable );
132        AtomicNumber = (*theElementTable)[J]->GetZ();
133
134        for ( G4int i = 0 ; i < NumbBinTable ; i++ )
135           {
136             LowEdgeEnergy = ptrVector->GetLowEdgeEnergy(i);
137             Value = ComputeCrossSectionPerAtom(LowEdgeEnergy, AtomicNumber);
138             ptrVector->PutValue(i,Value);
139           }
140
141        theCrossSectionTable->insertAt( J , ptrVector ) ;
142
143      }
144
145// Build mean free path table for the Compton Scattering process
146
147   if (theMeanFreePathTable) {
148       theMeanFreePathTable->clearAndDestroy(); delete theMeanFreePathTable;}
149 
150   theMeanFreePathTable= new G4PhysicsTable(G4Material::GetNumberOfMaterials());
151   const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
152   G4Material* material;
153
154   for ( J=0 ; J < G4Material::GetNumberOfMaterials(); J++ ) 
155       { 
156        //create physics vector then fill it ....
157        ptrVector = new G4PhysicsLogVector(LowestEnergyLimit,HighestEnergyLimit,
158                                           NumbBinTable ) ;
159        material = (*theMaterialTable)[J];
160
161        for ( G4int i = 0 ; i < NumbBinTable ; i++ )     
162           {
163             LowEdgeEnergy = ptrVector->GetLowEdgeEnergy( i ) ;
164             Value = ComputeMeanFreePath( LowEdgeEnergy, material); 
165             ptrVector->PutValue( i , Value ) ;
166           }
167
168        theMeanFreePathTable->insertAt( J , ptrVector ) ;
169      }
170
171    PrintInfoDefinition(); 
172
173}
174
175//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176
177G4double G4ComptonScattering52::ComputeCrossSectionPerAtom
178                              (G4double GammaEnergy, G4double Z)
179 
180// Calculates the cross section per atom in GEANT4 internal units.
181// A parametrized formula from L. Urban is used to estimate
182// the total cross section.
183// It gives a good description of the data from 10 keV to 100/Z GeV.
184// lower limit 1 keV now with a correction for low energy
185 
186{
187 G4double CrossSection = 0.0 ;
188 if ( Z < 1. )                     return CrossSection;
189 if ( GammaEnergy < 1.*keV       ) return CrossSection;
190 if ( GammaEnergy > (100.*GeV/Z) ) return CrossSection;
191
192 static const G4double a = 20.0 , b = 230.0 , c = 440.0;
193 
194 static const G4double
195 d1= 2.7965e-1*barn, d2=-1.8300e-1*barn, d3= 6.7527   *barn, d4=-1.9798e+1*barn,
196 e1= 1.9756e-5*barn, e2=-1.0205e-2*barn, e3=-7.3913e-2*barn, e4= 2.7079e-2*barn,
197 f1=-3.9178e-7*barn, f2= 6.8241e-5*barn, f3= 6.0480e-5*barn, f4= 3.0274e-4*barn;
198     
199 G4double p1Z = Z*(d1 + e1*Z + f1*Z*Z), p2Z = Z*(d2 + e2*Z + f2*Z*Z),
200          p3Z = Z*(d3 + e3*Z + f3*Z*Z), p4Z = Z*(d4 + e4*Z + f4*Z*Z);
201
202 G4double T0 = 15*keV; if (Z == 1.) T0 = 40*keV; 
203
204 G4double X = max(GammaEnergy, T0) / electron_mass_c2;
205 CrossSection = p1Z*log(1.+2*X)/X
206                + (p2Z + p3Z*X + p4Z*X*X)/(1. + a*X + b*X*X + c*X*X*X);
207               
208 //  modification for low energy. (special case for Hydrogen)
209 if (GammaEnergy < T0) {
210   G4double dT0 = 1.*keV;
211   X = (T0+dT0) / electron_mass_c2 ;
212   G4double sigma = p1Z*log(1.+2*X)/X
213                    + (p2Z + p3Z*X + p4Z*X*X)/(1. + a*X + b*X*X + c*X*X*X);
214   G4double c1 = -T0*(sigma-CrossSection)/(CrossSection*dT0);             
215   G4double c2 = 0.150; if (Z > 1.) c2 = 0.375-0.0556*log(Z);
216   G4double  y = log(GammaEnergy/T0);
217   CrossSection *= exp(-y*(c1+c2*y));         
218   }
219
220 return CrossSection;
221}
222
223//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
224
225G4double G4ComptonScattering52::ComputeMeanFreePath(G4double GammaEnergy,
226                                                         G4Material* aMaterial)
227
228// returns the gamma mean free path in GEANT4 internal units
229
230{
231  const G4ElementVector* theElementVector = aMaterial->GetElementVector() ;
232  const G4double* NbOfAtomsPerVolume = aMaterial->GetVecNbOfAtomsPerVolume();
233
234  G4double SIGMA = 0.;
235
236  for ( size_t elm=0 ; elm < aMaterial->GetNumberOfElements() ; elm++ )
237      {
238        SIGMA += NbOfAtomsPerVolume[elm] * 
239                 ComputeCrossSectionPerAtom(GammaEnergy,
240                                            (*theElementVector)[elm]->GetZ());
241      }       
242  return SIGMA > DBL_MIN ? 1./SIGMA : DBL_MAX;
243}
244
245 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
246
247G4double G4ComptonScattering52::GetCrossSectionPerAtom(
248                                 G4DynamicParticle* aDynamicGamma,
249                                 G4Element*         anElement)
250 
251// gives the microscopic total cross section in GEANT4 internal units
252
253{
254   G4double crossSection;
255   G4double GammaEnergy = aDynamicGamma->GetKineticEnergy();
256   G4bool isOutRange ;
257   if (GammaEnergy < LowestEnergyLimit || GammaEnergy > HighestEnergyLimit)
258      crossSection = 0.;
259   else
260      crossSection = (*theCrossSectionTable)(anElement->GetIndex())->
261                                       GetValue(GammaEnergy, isOutRange);
262
263   return crossSection;
264}
265
266//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
267
268
269G4double G4ComptonScattering52::GetMeanFreePath(const G4Track& aTrack,
270                                              G4double,
271                                              G4ForceCondition*)
272
273// returns the gamma mean free path in GEANT4 internal units
274
275{
276   const G4DynamicParticle* aDynamicGamma = aTrack.GetDynamicParticle();
277   G4double GammaEnergy = aDynamicGamma->GetKineticEnergy();
278   G4Material* aMaterial = aTrack.GetMaterial();
279
280   G4double MeanFreePath;
281   G4bool isOutRange;
282
283   if (GammaEnergy > HighestEnergyLimit || GammaEnergy < LowestEnergyLimit)
284     MeanFreePath = DBL_MAX;
285   else
286     MeanFreePath = (*theMeanFreePathTable)(aMaterial->GetIndex())->
287                                       GetValue(GammaEnergy, isOutRange);
288   return MeanFreePath;
289}
290
291//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
292
293G4VParticleChange* G4ComptonScattering52::PostStepDoIt(const G4Track& aTrack,
294                                                     const G4Step&  aStep)
295//
296// The scattered gamma energy is sampled according to Klein - Nishina formula.
297// The random number techniques of Butcher & Messel are used
298// (Nuc Phys 20(1960),15).
299// GEANT4 internal units
300//
301// Note : Effects due to binding of atomic electrons are negliged.
302 
303{
304   aParticleChange.Initialize(aTrack);
305
306   const G4DynamicParticle* aDynamicGamma = aTrack.GetDynamicParticle();
307   G4double GammaEnergy0 = aDynamicGamma->GetKineticEnergy();
308   G4double E0_m = GammaEnergy0 / electron_mass_c2 ;
309
310   G4ParticleMomentum GammaDirection0 = aDynamicGamma->GetMomentumDirection();
311
312   //
313   // sample the energy rate of the scattered gamma
314   //
315
316   G4double epsilon, epsilonsq, onecost, sint2, greject ;
317
318   G4double epsilon0 = 1./(1. + 2*E0_m) , epsilon0sq = epsilon0*epsilon0;
319   G4double alpha1   = - log(epsilon0)  , alpha2 = 0.5*(1.- epsilon0sq);
320
321   do {
322       if ( alpha1/(alpha1+alpha2) > G4UniformRand() )
323            { epsilon   = exp(-alpha1*G4UniformRand());   // epsilon0**r
324              epsilonsq = epsilon*epsilon; }
325       else {
326             epsilonsq = epsilon0sq + (1.- epsilon0sq)*G4UniformRand();
327             epsilon   = sqrt(epsilonsq);
328       };
329       onecost = (1.- epsilon)/(epsilon*E0_m);
330       sint2   = onecost*(2.-onecost);
331       greject = 1. - epsilon*sint2/(1.+ epsilonsq);
332   } while (greject < G4UniformRand());
333 
334   //
335   // scattered gamma angles. ( Z - axis along the parent gamma)
336   //
337
338   G4double cosTeta = 1. - onecost , sinTeta = sqrt (sint2);
339   G4double Phi     = twopi * G4UniformRand();
340   G4double dirx = sinTeta*cos(Phi), diry = sinTeta*sin(Phi), dirz = cosTeta;
341
342   //
343   // update G4VParticleChange for the scattered gamma
344   //
345   
346   G4ThreeVector GammaDirection1 ( dirx,diry,dirz );
347   GammaDirection1.rotateUz(GammaDirection0);
348   aParticleChange.ProposeMomentumDirection( GammaDirection1 );
349   G4double GammaEnergy1 = epsilon*GammaEnergy0;
350   G4double localEnergyDeposit = 0.;
351   
352   if (GammaEnergy1 > fminimalEnergy)
353     {
354       aParticleChange.ProposeEnergy( GammaEnergy1 );
355     }
356   else
357     {
358       localEnergyDeposit += GammaEnergy1;   
359       aParticleChange.ProposeEnergy(0.) ;
360       aParticleChange.ProposeTrackStatus(fStopAndKill);
361     }
362       
363   //
364   // kinematic of the scattered electron
365   //
366
367   G4double ElecKineEnergy = GammaEnergy0 - GammaEnergy1;
368
369    if (ElecKineEnergy > fminimalEnergy)       
370      {
371        G4double ElecMomentum = sqrt(ElecKineEnergy*
372                                    (ElecKineEnergy+2.*electron_mass_c2));
373        G4ThreeVector ElecDirection (
374        (GammaEnergy0*GammaDirection0 - GammaEnergy1*GammaDirection1)
375        *(1./ElecMomentum) );
376
377        // create G4DynamicParticle object for the electron.
378        G4DynamicParticle* aElectron= new G4DynamicParticle(
379                           G4Electron::Electron(),ElecDirection,ElecKineEnergy);
380
381        aParticleChange.SetNumberOfSecondaries(1);
382        aParticleChange.AddSecondary( aElectron );
383      }
384    else
385      {
386        aParticleChange.SetNumberOfSecondaries(0);
387        localEnergyDeposit += ElecKineEnergy;
388      }
389    aParticleChange.ProposeLocalEnergyDeposit (localEnergyDeposit);
390
391   //  Reset NbOfInteractionLengthLeft and return aParticleChange
392   return G4VDiscreteProcess::PostStepDoIt( aTrack, aStep);
393}
394
395//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
396
397G4bool G4ComptonScattering52::StorePhysicsTable(const G4ParticleDefinition* particle,
398                                              const G4String& directory,
399                                                    G4bool          ascii)
400{
401  G4String filename;
402
403  // store cross section table
404  filename = GetPhysicsTableFileName(particle,directory,"CrossSection",ascii);
405  if ( !theCrossSectionTable->StorePhysicsTable(filename, ascii) ){
406    G4cout << " FAIL theCrossSectionTable->StorePhysicsTable in " << filename
407           << G4endl;
408    return false;
409  }
410
411  // store mean free path table
412  filename = GetPhysicsTableFileName(particle,directory,"MeanFreePath",ascii);
413  if ( !theMeanFreePathTable->StorePhysicsTable(filename, ascii) ){
414    G4cout << " FAIL theMeanFreePathTable->StorePhysicsTable in " << filename
415           << G4endl;
416    return false;
417  }
418
419  G4cout << GetProcessName() << " for " << particle->GetParticleName()
420         << ": Success to store the PhysicsTables in "
421         << directory << G4endl;
422  return true;
423}
424
425//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
426/*
427G4bool G4ComptonScattering52::RetrievePhysicsTable(const G4ParticleDefinition* particle,
428                                                 const G4String& directory,
429                                                 G4bool          ascii)
430{
431  // delete theCrossSectionTable and theMeanFreePathTable
432  if (theCrossSectionTable != 0) {
433    theCrossSectionTable->clearAndDestroy();
434    delete theCrossSectionTable;
435  }
436  if (theMeanFreePathTable != 0) {
437    theMeanFreePathTable->clearAndDestroy();
438    delete theMeanFreePathTable;
439  }
440
441  G4String filename;
442
443  // retreive cross section table
444  filename = GetPhysicsTableFileName(particle,directory,"CrossSection",ascii);
445  theCrossSectionTable = new G4PhysicsTable(G4Element::GetNumberOfElements());
446  if ( !G4PhysicsTableHelper::RetrievePhysicsTable(filename, ascii) ){
447    G4cout << " FAIL theCrossSectionTable->RetrievePhysicsTable in " << filename
448           << G4endl;
449    return false;
450  }
451
452  // retreive mean free path table
453  filename = GetPhysicsTableFileName(particle,directory,"MeanFreePath",ascii);
454  theMeanFreePathTable = new G4PhysicsTable(G4Material::GetNumberOfMaterials());
455  if ( !G4PhysicsTableHelper::RetrievePhysicsTable(filename, ascii) ){
456    G4cout << " FAIL theMeanFreePathTable->RetrievePhysicsTable in " << filename
457           << G4endl;
458    return false;
459  }
460
461  G4cout << GetProcessName() << " for " << particle->GetParticleName()
462         << ": Success to retrieve the PhysicsTables from "
463         << directory << G4endl;
464  return true;
465}
466*/
467//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
468
469void G4ComptonScattering52::PrintInfoDefinition()
470{
471  G4String comments = "Total cross sections from a parametrisation. ";
472           comments += "Good description from 10 KeV to (100/Z) GeV. \n";
473           comments += "       Scattered gamma energy according Klein-Nishina.";
474                     
475  G4cout << G4endl << GetProcessName() << ":  " << comments
476         << "\n        PhysicsTables from "
477                   << G4BestUnit(LowestEnergyLimit,"Energy")
478         << " to " << G4BestUnit(HighestEnergyLimit,"Energy") 
479         << " in " << NumbBinTable << " bins. \n";
480  G4cout << "        WARNING: This process is obsolete and will be soon removed" 
481         << G4endl;
482}         
483
484//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.