Ignore:
Timestamp:
May 28, 2009, 4:26:57 PM (15 years ago)
Author:
garnier
Message:

maj sur la beta de geant 4.9.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/electromagnetic/lowenergy/src/G4LivermoreComptonModel.cc

    r1007 r1055  
    2424// ********************************************************************
    2525//
    26 // $Id: G4LivermoreComptonModel.cc,v 1.1 2008/10/30 14:17:46 sincerti Exp $
    27 // GEANT4 tag $Name: geant4-09-02 $
    28 //
     26// $Id: G4LivermoreComptonModel.cc,v 1.6 2009/04/18 18:29:34 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     28//
     29//
     30// Author: Sebastien Inserti
     31//         30 October 2008
     32//
     33// History:
     34// --------
     35// 18 Apr 2009   V Ivanchenko Cleanup initialisation and generation of secondaries:
     36//                  - apply internal high-energy limit only in constructor
     37//                  - do not apply low-energy limit (default is 0)
     38//                  - remove GetMeanFreePath method and table
     39//                  - added protection against numerical problem in energy sampling
     40//                  - use G4ElementSelector
    2941
    3042#include "G4LivermoreComptonModel.hh"
     
    3749
    3850G4LivermoreComptonModel::G4LivermoreComptonModel(const G4ParticleDefinition*,
    39                                              const G4String& nam)
    40 :G4VEmModel(nam),isInitialised(false)
     51                                                 const G4String& nam)
     52  :G4VEmModel(nam),isInitialised(false),meanFreePathTable(0),
     53   scatterFunctionData(0),crossSectionHandler(0)
    4154{
    42   lowEnergyLimit = 250 * eV; // SI - Could be 10 eV ?
     55  lowEnergyLimit = 250 * eV;
    4356  highEnergyLimit = 100 * GeV;
    44   SetLowEnergyLimit(lowEnergyLimit);
     57  //  SetLowEnergyLimit(lowEnergyLimit);
    4558  SetHighEnergyLimit(highEnergyLimit);
    4659
    47   verboseLevel= 0;
     60  verboseLevel=0 ;
    4861  // Verbosity scale:
    4962  // 0 = nothing
     
    5265  // 3 = calculation of cross sections, file openings, sampling of atoms
    5366  // 4 = entering in methods
    54  
    55   G4cout << "Livermore Compton model is constructed " << G4endl
    56          << "Energy range: "
    57          << lowEnergyLimit / keV << " keV - "
    58          << highEnergyLimit / GeV << " GeV"
    59          << G4endl;
    60  
     67
     68  if(  verboseLevel>0 ) {
     69    G4cout << "Livermore Compton model is constructed " << G4endl
     70           << "Energy range: "
     71           << lowEnergyLimit / eV << " eV - "
     72           << highEnergyLimit / GeV << " GeV"
     73           << G4endl;
     74  }
    6175}
    6276
     
    6579G4LivermoreComptonModel::~G4LivermoreComptonModel()
    6680
    67   delete meanFreePathTable;
    68   delete crossSectionHandler;
    69   delete scatterFunctionData;
     81  if (crossSectionHandler) delete crossSectionHandler;
     82  if (scatterFunctionData) delete scatterFunctionData;
    7083}
    7184
     
    7386
    7487void G4LivermoreComptonModel::Initialise(const G4ParticleDefinition* particle,
    75                                       const G4DataVector& cuts)
     88                                        const G4DataVector& cuts)
    7689{
    7790  if (verboseLevel > 3)
    7891    G4cout << "Calling G4LivermoreComptonModel::Initialise()" << G4endl;
    7992
    80   InitialiseElementSelectors(particle,cuts);
    81 
    82   // Energy limits
    83  
    84   if (LowEnergyLimit() < lowEnergyLimit)
    85     {
    86       G4cout << "G4LivermoreComptonModel: low energy limit increased from " <<
    87         LowEnergyLimit()/eV << " eV to " << lowEnergyLimit << " eV" << G4endl;
    88       SetLowEnergyLimit(lowEnergyLimit);
    89     }
    90 
    91   if (HighEnergyLimit() > highEnergyLimit)
    92     {
    93       G4cout << "G4LivermoreComptonModel: high energy limit decreased from " <<
    94         HighEnergyLimit()/GeV << " GeV to " << highEnergyLimit << " GeV" << G4endl;
    95       SetHighEnergyLimit(highEnergyLimit);
    96     }
    97 
     93  if (crossSectionHandler)
     94  {
     95    crossSectionHandler->Clear();
     96    delete crossSectionHandler;
     97  }
     98 
    9899  // Reading of data files - all materials are read
    99100 
     
    113114  shellData.LoadData(file);
    114115
    115   meanFreePathTable = 0;
    116   meanFreePathTable = crossSectionHandler->BuildMeanFreePathForMaterials();
    117  
    118116  if (verboseLevel > 2)
    119117    G4cout << "Loaded cross section files for Livermore Compton model" << G4endl;
    120118
    121   G4cout << "Livermore Compton model is initialized " << G4endl
    122          << "Energy range: "
    123          << LowEnergyLimit() / keV << " keV - "
    124          << HighEnergyLimit() / GeV << " GeV"
    125          << G4endl;
    126 
    127   //
    128  
     119  InitialiseElementSelectors(particle,cuts);
     120
     121  if(  verboseLevel>0 ) {
     122    G4cout << "Livermore Compton model is initialized " << G4endl
     123           << "Energy range: "
     124           << LowEnergyLimit() / eV << " eV - "
     125           << HighEnergyLimit() / GeV << " GeV"
     126           << G4endl;
     127  }
     128  // 
    129129  if(isInitialised) return;
    130 
    131   if(pParticleChange)
    132     fParticleChange = reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange);
    133   else
    134     fParticleChange = new G4ParticleChangeForGamma();
    135    
     130  fParticleChange = GetParticleChangeForGamma();
    136131  isInitialised = true;
    137132}
     
    148143    G4cout << "Calling ComputeCrossSectionPerAtom() of G4LivermoreComptonModel" << G4endl;
    149144
    150   G4double cs = crossSectionHandler->FindValue(G4int(Z), GammaEnergy);
     145  if (GammaEnergy < lowEnergyLimit || GammaEnergy > highEnergyLimit) return 0.0;
     146   
     147  G4double cs = crossSectionHandler->FindValue(G4int(Z), GammaEnergy); 
    151148  return cs;
    152149}
     
    155152
    156153void G4LivermoreComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>* fvect,
    157                                               const G4MaterialCutsCouple* couple,
    158                                               const G4DynamicParticle* aDynamicGamma,
    159                                               G4double,
    160                                               G4double)
     154                                                const G4MaterialCutsCouple* couple,
     155                                                const G4DynamicParticle* aDynamicGamma,
     156                                                G4double, G4double)
    161157{
     158
    162159  // The scattered gamma energy is sampled according to Klein - Nishina formula.
    163160  // then accepted or rejected depending on the Scattering Function multiplied
     
    174171  // (Nucl Phys 20(1960),15).
    175172
    176   if (verboseLevel > 3)
    177     G4cout << "Calling SampleSecondaries() of G4LivermoreComptonModel" << G4endl;
    178 
    179173  G4double photonEnergy0 = aDynamicGamma->GetKineticEnergy();
    180  
    181   if (photonEnergy0 <= lowEnergyLimit)
    182   {
     174
     175  if (verboseLevel > 3) {
     176    G4cout << "G4LivermoreComptonModel::SampleSecondaries() E(MeV)= "
     177           << photonEnergy0/MeV << " in " << couple->GetMaterial()->GetName()
     178           << G4endl;
     179  }
     180 
     181  // low-energy gamma is absorpted by this process
     182  if (photonEnergy0 <= lowEnergyLimit)
     183    {
    183184      fParticleChange->ProposeTrackStatus(fStopAndKill);
    184185      fParticleChange->SetProposedKineticEnergy(0.);
    185186      fParticleChange->ProposeLocalEnergyDeposit(photonEnergy0);
    186       // SI - IS THE FOLLOWING RETURN NECESSARY ?
    187187      return ;
    188   }
     188    }
    189189
    190190  G4double e0m = photonEnergy0 / electron_mass_c2 ;
     
    192192
    193193  // Select randomly one element in the current material
    194   G4int Z = crossSectionHandler->SelectRandomAtom(couple,photonEnergy0);
     194  //  G4int Z = crossSectionHandler->SelectRandomAtom(couple,photonEnergy0);
     195  const G4ParticleDefinition* particle =  aDynamicGamma->GetDefinition();
     196  const G4Element* elm = SelectRandomAtom(couple,particle,photonEnergy0);
     197  G4int Z = (G4int)elm->GetZ();
    195198
    196199  G4double epsilon0 = 1. / (1. + 2. * e0m);
     
    212215      if ( alpha1/(alpha1+alpha2) > G4UniformRand())
    213216      {
    214         epsilon = std::exp(-alpha1 * G4UniformRand());  // std::pow(epsilon0,G4UniformRand())
     217        // std::pow(epsilon0,G4UniformRand())
     218        epsilon = std::exp(-alpha1 * G4UniformRand()); 
    215219        epsilonSq = epsilon * epsilon;
    216220      }
     
    238242  // Doppler broadening -  Method based on:
    239243  // Y. Namito, S. Ban and H. Hirayama,
    240   // "Implementation of the Doppler Broadening of a Compton-Scattered Photon Into the EGS4 Code"
    241   // NIM A 349, pp. 489-494, 1994
     244  // "Implementation of the Doppler Broadening of a Compton-Scattered Photon
     245  // into the EGS4 Code", NIM A 349, pp. 489-494, 1994
    242246 
    243247  // Maximum number of sampling iterations
     
    257261      eMax = photonEnergy0 - bindingE;
    258262     
    259       // Randomly sample bound electron momentum (memento: the data set is in Atomic Units)
     263      // Randomly sample bound electron momentum
     264      // (memento: the data set is in Atomic Units)
    260265      G4double pSample = profileData.RandomSelectMomentum(Z,shell);
    261266      // Rescale from atomic units
     
    299304
    300305  if (photonEnergy1 > 0.)
    301   {
    302     fParticleChange->SetProposedKineticEnergy(photonEnergy1) ;
    303   }
     306    {
     307      fParticleChange->SetProposedKineticEnergy(photonEnergy1) ;
     308    }
    304309  else
    305   {
    306     fParticleChange->SetProposedKineticEnergy(0.) ;
    307     fParticleChange->ProposeTrackStatus(fStopAndKill);
    308   }
     310    {
     311      photonEnergy1 = 0.;
     312      fParticleChange->SetProposedKineticEnergy(0.) ;
     313      fParticleChange->ProposeTrackStatus(fStopAndKill);   
     314    }
    309315
    310316  // Kinematics of the scattered electron
    311317  G4double eKineticEnergy = photonEnergy0 - photonEnergy1 - bindingE;
     318
     319  // protection against negative final energy: no e- is created
     320  if(eKineticEnergy < 0.0) {
     321    fParticleChange->ProposeLocalEnergyDeposit(photonEnergy0 - photonEnergy1);
     322    return;
     323  }
    312324  G4double eTotalEnergy = eKineticEnergy + electron_mass_c2;
    313325
     
    329341  eDirection.rotateUz(photonDirection0);
    330342
    331 // SI - The range test has been removed wrt original G4LowEnergyCompton class
     343  // SI - The range test has been removed wrt original G4LowEnergyCompton class
    332344
    333345  fParticleChange->ProposeLocalEnergyDeposit(bindingE);
    334346 
    335   G4DynamicParticle* dp = new G4DynamicParticle (G4Electron::Electron(),eDirection,eKineticEnergy) ;
     347  G4DynamicParticle* dp = new G4DynamicParticle (G4Electron::Electron(),
     348                                                 eDirection,eKineticEnergy) ;
    336349  fvect->push_back(dp);
    337350}
    338351
    339 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    340 
    341 G4double G4LivermoreComptonModel::GetMeanFreePath(const G4Track& track,
    342                                              G4double, // previousStepSize
    343                                              G4ForceCondition*)
    344 {
    345   const G4DynamicParticle* photon = track.GetDynamicParticle();
    346   G4double energy = photon->GetKineticEnergy();
    347   const G4MaterialCutsCouple* couple = track.GetMaterialCutsCouple();
    348   size_t materialIndex = couple->GetIndex();
    349 
    350   G4double meanFreePath;
    351   if (energy > highEnergyLimit) meanFreePath = meanFreePathTable->FindValue(highEnergyLimit,materialIndex);
    352   else if (energy < lowEnergyLimit) meanFreePath = DBL_MAX;
    353   else meanFreePath = meanFreePathTable->FindValue(energy,materialIndex);
    354   return meanFreePath;
    355 }
    356 
Note: See TracChangeset for help on using the changeset viewer.