source: trunk/source/processes/electromagnetic/lowenergy/src/G4hLowEnergyIonisation.cc @ 1228

Last change on this file since 1228 was 1228, checked in by garnier, 14 years ago

update geant4.9.3 tag

File size: 67.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//
27// -------------------------------------------------------------
28//      GEANT 4 class implementation file
29//
30//      History: based on object model of
31//      2nd December 1995, G.Cosmo
32//      ---------- G4hLowEnergyIonisation physics process -------
33//                by Vladimir Ivanchenko, 14 July 1999
34//                was made on the base of G4hIonisation class
35//                developed by Laszlo Urban
36// ************************************************************
37// It is the extention of the ionisation process for the slow
38// charged hadrons.
39// ************************************************************
40// 28 July   1999 V.Ivanchenko cleen up
41// 17 August 1999 G.Mancinelli added ICRU parametrisations for protons
42// 20 August 1999 G.Mancinelli added ICRU tables for alpha
43// 31 August 1999 V.Ivanchenko update and cleen up
44// 30 Sept.  1999 V.Ivanchenko minor upgrade
45// 12 Dec.   1999 S. Chauvie added Barkas correction
46// 19 Jan.   2000 V.Ivanchenko minor changing in Barkas corrections
47// 02 April  2000 S. Chauvie linearization of Barkas effect
48// 03 April  2000 V.Ivanchenko Nuclear Stopping power for antiprotons
49// 23 May    2000 MG Pia  Clean up for QAO model
50// 24 May    2000 MG Pia  Code properly indented to improve legibility
51// 17 July   2000 V.Ivanchenko Bug in scaling AlongStepDoIt method
52// 25 July   2000 V.Ivanchenko New design iteration
53// 17 August 2000 V.Ivanchenko Add ion fluctuation models
54// 18 August 2000 V.Ivanchenko Bug fixed in GetConstrain
55// 22 August 2000 V.Ivanchenko Insert paramStepLimit and
56//                reorganise access to Barkas and Bloch terms 
57// 04 Sept.  2000 V.Ivanchenko rename fluctuations
58// 05 Sept.  2000 V.Ivanchenko clean up
59// 03 Oct.   2000 V.Ivanchenko CodeWizard clean up
60// 03 Nov.   2000 V.Ivanchenko MinKineticEnergy=LowestKineticEnergy=10eV
61// 05 Nov.   2000 MG Pia - Removed const cast previously introduced to get
62//                the code compiled (const G4Material* now introduced in
63//                electromagnetic/utils utils-V02-00-03 tag)
64//                (this is going back and forth, to cope with Michel's
65//                utils tag not being accepted yet by system testing)
66// 21 Nov.  2000 V.Ivanchenko Fix a problem in fluctuations
67// 23 Nov.  2000 V.Ivanchenko Ion type fluctuations only for charge>0
68// 10 May   2001 V.Ivanchenko Clean up againist Linux compilation with -Wall
69// 23 May   2001 V.Ivanchenko Minor fix in PostStepDoIt
70// 07 June  2001 V.Ivanchenko Clean up AntiProtonDEDX + add print out
71// 18 June  2001 V.Ivanchenko Cleanup print out
72// 18 Oct.  2001 V.Ivanchenko Add fluorescence
73// 30 Oct.  2001 V.Ivanchenko Add minGammaEnergy and minElectronEnergy
74// 07 Dec   2001 V.Ivanchenko Add SetFluorescence method
75// 15 Feb   2002 V.Ivanchenko Fix problem of Generic Ions
76// 25 Mar   2002 V.Ivanchenko Fix problem of fluorescence below threshold
77// 28 Mar   2002 V.Ivanchenko Set fluorescence off by default
78// 09 Apr   2002 V.Ivanchenko Fix table problem of GenericIons
79// 28 May   2002 V.Ivanchenko Remove flag fStopAndKill
80// 31 May   2002 V.Ivanchenko Add path of Fluo + Auger cuts to
81//                            AtomicDeexcitation
82// 03 Jun   2002 MGP          Restore fStopAndKill
83// 10 Jun   2002 V.Ivanchenko Restore fStopButAlive
84// 12 Jun   2002 V.Ivanchenko Fix in fluctuations - if tmax<2*Ipot Gaussian
85//                            fluctuations enables
86// 20 Sept  2002 V.Ivanchenko Clean up energy ranges for models
87// 07 Oct   2002 V.Ivanchenko Clean up initialisation of fluorescence
88// 28 Oct   2002 V.Ivanchenko Optimal binning for dE/dx
89// 10 Dec   2002 V.Ivanchenko antiProtonLowEnergy -> 25 keV, QEG model below
90// 21 Jan   2003 V.Ivanchenko Cut per region
91// 10 Mar   2003 V.Ivanchenko Use SubTypes for ions
92// 12 Apr   2003 V.Ivanchenko Cut per region for fluo AlongStep
93// 18 Apr   2003 V.Ivanchenko finalRange redefinition
94// 26 Apr   2003 V.Ivanchenko fix for stepLimit
95// 30 Mar   2004 S.Saliceti add shellCS data member and expFlag variable,
96//                          atom total cross section for the Empiric Model
97// 28 May   2004 V.Ivanchenko fix for ionisation of antiprotons in complex materials
98// 30 Aug   2004 V.Ivanchenko use energy limit for parameterisation from model
99// 03 Oct   2005 V.Ivanchenko change logic of definition of high energy limit for
100//               parametrised proton model: min(user value, model limit)
101// 26 Jan   2005 S. Chauvie added PrintInfoDefinition() for antiproton
102
103
104// -----------------------------------------------------------------------
105
106//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
107//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
108
109#include "G4hLowEnergyIonisation.hh"
110#include "globals.hh"
111#include "G4ios.hh"
112#include "Randomize.hh"
113#include "G4Poisson.hh"
114#include "G4UnitsTable.hh"
115#include "G4EnergyLossTables.hh"
116#include "G4Material.hh"
117#include "G4DynamicParticle.hh"
118#include "G4ParticleDefinition.hh"
119#include "G4AtomicDeexcitation.hh"
120#include "G4AtomicTransitionManager.hh"
121#include "G4ShellVacancy.hh"
122#include "G4VhShellCrossSection.hh"
123#include "G4hShellCrossSection.hh"
124#include "G4hShellCrossSectionExp.hh"
125#include "G4hShellCrossSectionDoubleExp.hh"
126#include "G4VEMDataSet.hh"
127#include "G4EMDataSet.hh"
128#include "G4CompositeEMDataSet.hh"
129#include "G4Gamma.hh"
130#include "G4LogLogInterpolation.hh"
131#include "G4SemiLogInterpolation.hh"
132#include "G4ProcessManager.hh"
133#include "G4ProductionCutsTable.hh"
134
135//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
136
137G4hLowEnergyIonisation::G4hLowEnergyIonisation(const G4String& processName)
138  : G4hLowEnergyLoss(processName),
139    theBetheBlochModel(0),
140    theProtonModel(0),
141    theAntiProtonModel(0),
142    theIonEffChargeModel(0),
143    theNuclearStoppingModel(0),
144    theIonChuFluctuationModel(0),
145    theIonYangFluctuationModel(0),
146    theProtonTable("ICRU_R49p"),
147    theAntiProtonTable("ICRU_R49p"),
148    theNuclearTable("ICRU_R49"),
149    nStopping(true),
150    theBarkas(true),
151    theMeanFreePathTable(0),
152    paramStepLimit (0.005),
153    shellVacancy(0),
154    shellCS(0),
155    theFluo(false),
156    expFlag(false)
157{ 
158  InitializeMe();
159}
160
161//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
162
163void G4hLowEnergyIonisation::InitializeMe()
164{
165  LowestKineticEnergy  = 10.0*eV ;
166  HighestKineticEnergy = 100.0*GeV ;
167  MinKineticEnergy     = 10.0*eV ; 
168  TotBin               = 360 ;
169  protonLowEnergy      = 1.*keV ;
170  protonHighEnergy     = 100.*MeV ;
171  antiProtonLowEnergy  = 25.*keV ;
172  antiProtonHighEnergy = 2.*MeV ;
173  minGammaEnergy       = 25.*keV;
174  minElectronEnergy    = 25.*keV;
175  verboseLevel         = 0;
176
177//****************************************************************************
178// By default the method of cross section's calculation is swiched on an
179// 2nd implementation empirical model (G4hShellCrossSectionDoubleExp),
180// if you want to use Gryzinski's model (G4hShellCrossSection()) or the
181// 1st empiric one (G4hShellCrossSectionExp), you must change the
182// selection below and switching expFlag to FALSE
183//****************************************************************************
184
185  //shellCS = new G4hShellCrossSection();
186  //shellCS = new G4hShellCrossSectionExp();
187  shellCS = new G4hShellCrossSectionDoubleExp();
188  expFlag=true;
189}
190
191//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
192
193G4hLowEnergyIonisation::~G4hLowEnergyIonisation()
194{
195  if (theMeanFreePathTable) {
196    theMeanFreePathTable->clearAndDestroy();
197    delete theMeanFreePathTable;
198  }
199  if(theBetheBlochModel)delete theBetheBlochModel;
200  if(theProtonModel)delete theProtonModel;
201  if(theAntiProtonModel)delete theAntiProtonModel;
202  if(theNuclearStoppingModel)delete theNuclearStoppingModel;
203  if(theIonEffChargeModel)delete theIonEffChargeModel;
204  if(theIonChuFluctuationModel)delete theIonChuFluctuationModel;
205  if(theIonYangFluctuationModel)delete theIonYangFluctuationModel;
206  if(shellVacancy) delete shellVacancy;
207  if(shellCS) delete shellCS;
208  cutForDelta.clear();
209  G4int length = zFluoDataVector.size();
210  if(length) {
211    for(G4int i=0; i<length; i++) {
212      delete zFluoDataVector[i];
213    }
214    zFluoDataVector.clear();
215  }
216}
217
218//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
219
220void G4hLowEnergyIonisation::SetElectronicStoppingPowerModel(
221                             const G4ParticleDefinition* aParticle,
222                             const G4String& dedxTable)
223  // This method defines the ionisation parametrisation method via its name
224{
225  if(0 < aParticle->GetPDGCharge()) {
226    SetProtonElectronicStoppingPowerModel(dedxTable) ;
227  } else {
228    SetAntiProtonElectronicStoppingPowerModel(dedxTable) ;
229  }
230}
231
232//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
233
234void G4hLowEnergyIonisation::InitializeParametrisation() 
235
236{
237  // Define models for parametrisation of electronic energy losses
238  theBetheBlochModel = new G4hBetheBlochModel("Bethe-Bloch") ;
239  theProtonModel = new G4hParametrisedLossModel(theProtonTable) ;
240  protonHighEnergy = std::min(protonHighEnergy,theProtonModel->HighEnergyLimit(0, 0));
241  theAntiProtonModel = new G4QAOLowEnergyLoss(theAntiProtonTable) ;
242  theNuclearStoppingModel = new G4hNuclearStoppingModel(theNuclearTable) ;
243  theIonEffChargeModel = new G4hIonEffChargeSquare("Ziegler1988") ;
244  theIonChuFluctuationModel = new G4IonChuFluctuationModel("Chu") ;
245  theIonYangFluctuationModel = new G4IonYangFluctuationModel("Yang") ;
246}
247
248//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
249
250void G4hLowEnergyIonisation::BuildPhysicsTable(
251                       const G4ParticleDefinition& aParticleType)
252
253  //  just call BuildLossTable+BuildLambdaTable
254{
255  if(verboseLevel > 0) {
256    G4cout << "G4hLowEnergyIonisation::BuildPhysicsTable for "
257           << aParticleType.GetParticleName()
258           << " mass(MeV)= " << aParticleType.GetPDGMass()/MeV
259           << " charge= " << aParticleType.GetPDGCharge()/eplus
260           << " type= " << aParticleType.GetParticleType()
261           << G4endl;
262
263    if(verboseLevel > 1) {
264      G4ProcessVector* pv = aParticleType.GetProcessManager()->GetProcessList();
265
266      G4cout << " 0: " << (*pv)[0]->GetProcessName() << " " << (*pv)[0]
267             << " 1: " << (*pv)[1]->GetProcessName() << " " << (*pv)[1]
268        //        << " 2: " << (*pv)[2]->GetProcessName() << " " << (*pv)[2]
269             << G4endl;
270      G4cout << "ionModel= " << theIonEffChargeModel
271             << " MFPtable= " << theMeanFreePathTable
272             << " iniMass= " << initialMass
273             << G4endl;
274    }
275  }
276
277  if(aParticleType.GetParticleType() == "nucleus" &&
278     aParticleType.GetParticleName() != "GenericIon" &&
279     aParticleType.GetParticleSubType() == "generic")
280  {
281
282     G4EnergyLossTables::Register(&aParticleType,
283              theDEDXpTable,
284              theRangepTable,
285              theInverseRangepTable,
286              theLabTimepTable,
287              theProperTimepTable,
288              LowestKineticEnergy, HighestKineticEnergy,
289              proton_mass_c2/aParticleType.GetPDGMass(),
290              TotBin);
291
292     return;
293  }
294
295  if( !CutsWhereModified() && theLossTable) return;
296
297  InitializeParametrisation() ;
298  G4Proton* theProton = G4Proton::Proton();
299  G4AntiProton* theAntiProton = G4AntiProton::AntiProton();
300
301  charge = aParticleType.GetPDGCharge()/eplus;
302  chargeSquare = charge*charge ;
303
304  const G4ProductionCutsTable* theCoupleTable=
305        G4ProductionCutsTable::GetProductionCutsTable();
306  size_t numOfCouples = theCoupleTable->GetTableSize();
307
308  cutForDelta.clear();
309  cutForGamma.clear();
310
311  for (size_t j=0; j<numOfCouples; j++) {
312
313    // get material parameters needed for the energy loss calculation
314    const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(j);
315    const G4Material* material= couple->GetMaterial();
316
317    // the cut cannot be below lowest limit
318    G4double tCut = (*(theCoupleTable->GetEnergyCutsVector(1)))[j];
319    if(tCut > HighestKineticEnergy) tCut = HighestKineticEnergy;
320
321    G4double excEnergy = material->GetIonisation()->GetMeanExcitationEnergy();
322
323    tCut = std::max(tCut,excEnergy);
324    cutForDelta.push_back(tCut);
325
326    // the cut cannot be below lowest limit
327    tCut = (*(theCoupleTable->GetEnergyCutsVector(0)))[j];
328    if(tCut > HighestKineticEnergy) tCut = HighestKineticEnergy;
329    tCut = std::max(tCut,minGammaEnergy);
330    cutForGamma.push_back(tCut);
331  }
332
333  if(verboseLevel > 0) {
334    G4cout << "Cuts are defined " << G4endl;
335  }
336
337  if(0.0 < charge)
338    {
339      {
340        BuildLossTable(*theProton) ;
341
342//      The following vector has a fixed dimension (see src/G4hLowEnergyLoss.cc for more details)       
343//      It happended in the past that caused memory corruption errors. The problem is still pending, even if temporary solved
344//        G4cout << "[NOTE]: __LINE__=" << __LINE__ << ", aParticleType=" << aParticleType.GetParticleName() << ", theProton=" << theProton << ", theLossTable=" << theLossTable << ", CounterOfpProcess=" << CounterOfpProcess << G4endl;
345       
346        RecorderOfpProcess[CounterOfpProcess] = theLossTable ;
347        CounterOfpProcess++;
348      }
349  } else {
350      {
351        BuildLossTable(*theAntiProton) ;
352       
353//      The following vector has a fixed dimension (see src/G4hLowEnergyLoss.cc for more details)       
354//      It happended in the past that caused memory corruption errors. The problem is still pending, even if temporary solved
355//        G4cout << "[NOTE]: __LINE__=" << __LINE__ << ", aParticleType=" << aParticleType.GetParticleName() << ", theAntiProton=" << theAntiProton << ", theLossTable=" << theLossTable << ", CounterOfpbarProcess=" << CounterOfpbarProcess << G4endl;
356       
357        RecorderOfpbarProcess[CounterOfpbarProcess] = theLossTable ;
358        CounterOfpbarProcess++;
359      }
360  }
361
362  if(verboseLevel > 0) {
363    G4cout << "G4hLowEnergyIonisation::BuildPhysicsTable: "
364           << "Loss table is built "
365//         << theLossTable
366           << G4endl;
367  }
368
369  BuildLambdaTable(aParticleType) ;
370  BuildDataForFluorescence(aParticleType);
371
372  if(verboseLevel > 1) {
373    G4cout << (*theMeanFreePathTable) << G4endl;
374  }
375
376  if(verboseLevel > 0) {
377    G4cout << "G4hLowEnergyIonisation::BuildPhysicsTable: "
378           << "DEDX table will be built "
379//         << theDEDXpTable << " " << theDEDXpbarTable
380//         << " " << theRangepTable << " " << theRangepbarTable
381           << G4endl;
382  }
383
384  BuildDEDXTable(aParticleType) ;
385
386  if(verboseLevel > 1) {
387    G4cout << (*theDEDXpTable) << G4endl;
388  }
389
390  if((&aParticleType == theProton) ||  (&aParticleType == theAntiProton)) PrintInfoDefinition() ;
391
392  if(verboseLevel > 0) {
393    G4cout << "G4hLowEnergyIonisation::BuildPhysicsTable: end for "
394           << aParticleType.GetParticleName() << G4endl;
395  }
396}
397
398//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
399
400void G4hLowEnergyIonisation::BuildLossTable(
401                             const G4ParticleDefinition& aParticleType)
402{
403
404  // Initialisation
405  G4double lowEdgeEnergy , ionloss, ionlossBB, paramB ;
406  G4double lowEnergy, highEnergy;
407  G4Proton* theProton = G4Proton::Proton();
408
409  if(aParticleType == *theProton) {
410    lowEnergy = protonLowEnergy ;
411    highEnergy = protonHighEnergy ;
412    charge = 1.0 ;
413  } else {
414    lowEnergy = antiProtonLowEnergy ;
415    highEnergy = antiProtonHighEnergy ;
416    charge = -1.0 ;
417  }
418  chargeSquare = 1.0 ;
419
420  const G4ProductionCutsTable* theCoupleTable=
421        G4ProductionCutsTable::GetProductionCutsTable();
422  size_t numOfCouples = theCoupleTable->GetTableSize();
423
424  if ( theLossTable) {
425    theLossTable->clearAndDestroy();
426    delete theLossTable;
427  }
428
429  theLossTable = new G4PhysicsTable(numOfCouples);
430
431  //  loop for materials
432  for (size_t j=0; j<numOfCouples; j++) {
433
434    // create physics vector and fill it
435    G4PhysicsLogVector* aVector = new G4PhysicsLogVector(LowestKineticEnergy,
436                                                         HighestKineticEnergy,
437                                                         TotBin);
438
439    // get material parameters needed for the energy loss calculation
440    const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(j);
441    const G4Material* material= couple->GetMaterial();
442
443    if ( charge > 0.0 ) {
444      ionloss = ProtonParametrisedDEDX(couple,highEnergy) ;
445    } else {
446      ionloss = AntiProtonParametrisedDEDX(couple,highEnergy) ;
447    }
448
449    ionlossBB = theBetheBlochModel->TheValue(&aParticleType,material,highEnergy) ;
450    ionlossBB -= DeltaRaysEnergy(couple,highEnergy,proton_mass_c2) ;
451
452
453    paramB =  ionloss/ionlossBB - 1.0 ;
454
455    // now comes the loop for the kinetic energy values
456    for (G4int i = 0 ; i < TotBin ; i++) {
457      lowEdgeEnergy = aVector->GetLowEdgeEnergy(i) ;
458
459      // low energy part for this material, parametrised energy loss formulae
460      if ( lowEdgeEnergy < highEnergy ) {
461
462        if ( charge > 0.0 ) {
463          ionloss = ProtonParametrisedDEDX(couple,lowEdgeEnergy) ;
464        } else {
465          ionloss = AntiProtonParametrisedDEDX(couple,lowEdgeEnergy) ;
466        }
467
468      } else {
469
470        // high energy part for this material, Bethe-Bloch formula
471        ionloss = theBetheBlochModel->TheValue(theProton,material,
472                                               lowEdgeEnergy) ;
473
474        ionloss -= DeltaRaysEnergy(couple,lowEdgeEnergy,proton_mass_c2) ;
475
476        ionloss *= (1.0 + paramB*highEnergy/lowEdgeEnergy) ;
477      }
478
479      // now put the loss into the vector
480      if(verboseLevel > 1) {
481        G4cout << "E(MeV)= " << lowEdgeEnergy/MeV
482               << "  dE/dx(MeV/mm)= " << ionloss*mm/MeV
483               << " in " << material->GetName() << G4endl;
484      }
485      aVector->PutValue(i,ionloss) ;
486    }
487    // Insert vector for this material into the table
488    theLossTable->insert(aVector) ;
489  }
490}
491
492//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
493
494void G4hLowEnergyIonisation::BuildDataForFluorescence(
495                         const G4ParticleDefinition& aParticleType)
496{
497
498  if(verboseLevel > 1) {
499    G4cout << "G4hLowEnergyIonisation::BuildDataForFluorescence for "
500           << aParticleType.GetParticleName() << " is started" << G4endl;
501  }
502
503  // fill data for fluorescence
504
505  deexcitationManager.SetCutForSecondaryPhotons(minGammaEnergy);
506  deexcitationManager.SetCutForAugerElectrons(minElectronEnergy);
507
508  G4double mass = aParticleType.GetPDGMass();
509  const G4ProductionCutsTable* theCoupleTable=
510        G4ProductionCutsTable::GetProductionCutsTable();
511  size_t numOfCouples = theCoupleTable->GetTableSize();
512
513  if (shellVacancy != 0) delete shellVacancy;
514  shellVacancy = new G4ShellVacancy();
515  G4DataVector* ksi = 0;
516  G4DataVector* ksi1 = 0;
517  G4DataVector* energy = 0;
518  G4DataVector* energy1 = 0;
519  size_t binForFluo = TotBin/10;
520  G4int length = zFluoDataVector.size();
521  if(length > 0) {
522    for(G4int i=0; i<length; i++) {
523      G4VEMDataSet* x = zFluoDataVector[i];
524      delete x;
525    }
526    zFluoDataVector.clear();
527  }
528
529  G4PhysicsLogVector* bVector = new G4PhysicsLogVector(LowestKineticEnergy,
530                                                       HighestKineticEnergy,
531                                                       binForFluo);
532  const G4AtomicTransitionManager* transitionManager =
533                             G4AtomicTransitionManager::Instance();
534
535  G4double bindingEnergy;
536  //  G4double x;
537  //  G4double y;
538
539  //  loop for materials
540  for (size_t j=0; j<numOfCouples; j++) {
541
542    // get material parameters needed for the energy loss calculation
543    const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(j);
544    const G4Material* material= couple->GetMaterial();
545
546    const G4ElementVector* theElementVector = material->GetElementVector();
547    size_t NumberOfElements = material->GetNumberOfElements() ;
548    const G4double* theAtomicNumDensityVector =
549                    material->GetAtomicNumDensityVector();
550    G4VDataSetAlgorithm* interp = new G4SemiLogInterpolation();
551    G4VEMDataSet* xsis = new G4CompositeEMDataSet(interp, 1., 1.);
552    G4VDataSetAlgorithm* interp1 = new G4SemiLogInterpolation();
553    G4VEMDataSet* xsis1 = new G4CompositeEMDataSet(interp1, 1., 1.);
554
555    G4double tCut = cutForDelta[j];
556    G4double elDensity = 1.;
557
558    for (size_t iel=0; iel<NumberOfElements; iel++ ) {
559
560      G4int Z = (G4int)((*theElementVector)[iel]->GetZ());
561      G4int nShells = transitionManager->NumberOfShells(Z);
562      energy = new G4DataVector();
563      ksi    = new G4DataVector();
564      energy1= new G4DataVector();
565      ksi1   = new G4DataVector();
566      //if(NumberOfElements > 1)
567      elDensity = theAtomicNumDensityVector[iel]/((G4double)nShells);
568
569      for (size_t j = 0; j<binForFluo; j++) {
570
571        G4double tkin  = bVector->GetLowEdgeEnergy(j);
572        G4double gamma = tkin/mass + 1.;
573        G4double beta2 = 1.0 - 1.0/(gamma*gamma);
574        G4double r     = electron_mass_c2/mass;
575        G4double tmax  = 2.*electron_mass_c2*(gamma*gamma - 1.)/(1. + 2.*gamma*r + r*r);
576        G4double cross   = 0.;
577        G4double cross1  = 0.;
578        G4double eAverage= 0.;
579        G4double tmin = std::min(tCut,tmax);
580        G4double rel;
581
582        for (G4int n=0; n<nShells; n++) {
583
584          bindingEnergy = transitionManager->Shell(Z, n)->BindingEnergy();
585          if (tmin > bindingEnergy) {
586            rel = std::log(tmin/bindingEnergy);
587            eAverage   += rel - beta2*(tmin - bindingEnergy)/tmax;
588            cross      += 1.0/bindingEnergy - 1.0/tmin - beta2*rel/tmax;
589          }
590          if (tmax > tmin) {
591            cross1     += 1.0/tmin - 1.0/tmax - beta2*std::log(tmax/tmin)/tmax;
592          }
593        }
594
595        cross1 *= elDensity;
596        energy1->push_back(tkin);
597        ksi1->push_back(cross1);
598
599        if(eAverage > 0.) cross /= eAverage;
600        else              cross  = 0.;
601
602        energy->push_back(tkin);
603        ksi->push_back(cross);
604      }
605      G4VDataSetAlgorithm* algo = interp->Clone();
606      G4VEMDataSet* set = new G4EMDataSet(Z,energy,ksi,algo,1.,1.);
607      xsis->AddComponent(set);
608      G4VDataSetAlgorithm* algo1 = interp1->Clone();
609      G4VEMDataSet* set1 = new G4EMDataSet(Z,energy1,ksi1,algo1,1.,1.);
610      xsis1->AddComponent(set1);
611    }
612    if(verboseLevel > 1) {
613      G4cout << "### Shell inverse cross sections for "
614             << material->GetName() << G4endl;
615      xsis->PrintData();
616      G4cout << "### Atom cross sections for "
617             << material->GetName() << G4endl;
618      xsis1->PrintData();
619    }
620    shellVacancy->AddXsiTable(xsis);
621    zFluoDataVector.push_back(xsis1);
622  }
623  delete bVector;
624}
625
626//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
627
628void G4hLowEnergyIonisation::BuildLambdaTable(
629                       const G4ParticleDefinition& aParticleType)
630
631{
632  // Build mean free path tables for the delta ray production process
633  //     tables are built for MATERIALS
634
635  if(verboseLevel > 1) {
636    G4cout << "G4hLowEnergyIonisation::BuildLambdaTable for "
637           << aParticleType.GetParticleName() << " is started" << G4endl;
638  }
639
640
641  G4double lowEdgeEnergy, value;
642  charge = aParticleType.GetPDGCharge()/eplus ;
643  chargeSquare = charge*charge ;
644  initialMass = aParticleType.GetPDGMass();
645
646  const G4ProductionCutsTable* theCoupleTable=
647        G4ProductionCutsTable::GetProductionCutsTable();
648  size_t numOfCouples = theCoupleTable->GetTableSize();
649
650
651  if (theMeanFreePathTable) {
652    theMeanFreePathTable->clearAndDestroy();
653    delete theMeanFreePathTable;
654  }
655
656  theMeanFreePathTable = new G4PhysicsTable(numOfCouples);
657
658  // loop for materials
659
660  for (size_t J=0 ; J < numOfCouples; J++) {
661
662    //create physics vector then fill it ....
663    G4PhysicsLogVector* aVector = new G4PhysicsLogVector(LowestKineticEnergy,
664                                                         HighestKineticEnergy,
665                                                         TotBin);
666
667    // compute the (macroscopic) cross section first
668    const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(J);
669    const G4Material* material= couple->GetMaterial();
670
671    const G4ElementVector* theElementVector =
672                           material->GetElementVector() ;
673    const G4double* theAtomicNumDensityVector =
674                           material->GetAtomicNumDensityVector();
675    const G4int NumberOfElements = material->GetNumberOfElements() ;
676
677      // get the electron kinetic energy cut for the actual material,
678      //  it will be used in ComputeMicroscopicCrossSection
679      // ( it is the SAME for ALL the ELEMENTS in THIS MATERIAL )
680      //   ------------------------------------------------------
681
682    G4double deltaCut = cutForDelta[J];
683
684    for ( G4int i = 0 ; i < TotBin ; i++ ) {
685      lowEdgeEnergy = aVector->GetLowEdgeEnergy(i) ;
686      G4double sigma = 0.0 ;
687      G4int Z;
688     
689      for (G4int iel=0; iel<NumberOfElements; iel++ ) {
690        Z = (G4int) (*theElementVector)[iel]->GetZ();
691        totalCrossSectionMap [Z] = ComputeMicroscopicCrossSection(
692                                                                  aParticleType,
693                                                                  lowEdgeEnergy,
694                                                                  Z,
695                                                                  deltaCut ) ; 
696        sigma += theAtomicNumDensityVector[iel]*ComputeMicroscopicCrossSection(
697                                                                               aParticleType,
698                                                                               lowEdgeEnergy,
699                                                                               Z,
700                                                                               deltaCut ) ; 
701       
702      }
703
704      // mean free path = 1./macroscopic cross section
705
706      value = sigma<=0 ? DBL_MAX : 1./sigma ;
707
708      aVector->PutValue(i, value) ;
709    }
710
711    theMeanFreePathTable->insert(aVector);
712  }
713
714}
715
716
717//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
718
719G4double G4hLowEnergyIonisation::ComputeMicroscopicCrossSection(
720                           const G4ParticleDefinition& aParticleType,
721                                 G4double kineticEnergy,
722                                 G4double atomicNumber,
723                                 G4double deltaCutInEnergy) const
724{
725  //******************************************************************
726  // cross section formula is OK for spin=0, 1/2, 1 only !
727  // *****************************************************************
728
729  // calculates the microscopic cross section in GEANT4 internal units
730  //    ( it is called for elements , AtomicNumber = z )
731
732  G4double energy, gamma, beta2, tmax, var;
733  G4double totalCrossSection = 0.0 ;
734
735  G4double particleMass = initialMass;
736
737  // get particle data ...................................
738
739  energy = kineticEnergy + particleMass;
740
741  // some kinematics......................
742
743  gamma  = energy/particleMass;
744  beta2  = 1.0 - 1.0/(gamma*gamma);
745  var    = electron_mass_c2/particleMass;
746  tmax   = 2.*electron_mass_c2*(gamma*gamma - 1.)/(1. + 2.*gamma*var + var*var);
747
748  // now you can calculate the total cross section
749
750  if( tmax > deltaCutInEnergy ) {
751
752    var=deltaCutInEnergy/tmax;
753    totalCrossSection = (1.0 - var*(1.0 - beta2*std::log(var))) / deltaCutInEnergy ;
754    G4double spin = aParticleType.GetPDGSpin() ;
755
756    // +term for spin=1/2 particle
757    if( 0.5 == spin )
758      totalCrossSection +=  0.5 * (tmax - deltaCutInEnergy) / (energy*energy);
759
760    // +term for spin=1 particle
761    else if( 0.9 < spin )
762      totalCrossSection += -std::log(var)/(3.0*deltaCutInEnergy) +
763        (tmax - deltaCutInEnergy) * ( (5.0+ 1.0/var)*0.25 / (energy*energy) -
764         beta2 / (tmax * deltaCutInEnergy) ) / 3.0 ;
765
766    totalCrossSection *= twopi_mc2_rcl2 * atomicNumber / beta2 ;
767  }
768
769  return totalCrossSection ;
770}
771
772//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
773
774G4double G4hLowEnergyIonisation::GetMeanFreePath(const G4Track& trackData,
775                                                 G4double, // previousStepSize
776                                                 enum G4ForceCondition* condition)
777{
778   const G4DynamicParticle* aParticle = trackData.GetDynamicParticle();
779   const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
780   const G4Material* material = couple->GetMaterial();
781   G4double meanFreePath;
782   G4bool isOutRange ;
783
784   *condition = NotForced ;
785
786   G4double kineticEnergy = (aParticle->GetKineticEnergy())*initialMass/(aParticle->GetMass());
787   charge = aParticle->GetCharge()/eplus;
788   chargeSquare = theIonEffChargeModel->TheValue(aParticle, material);
789
790   if(kineticEnergy < LowestKineticEnergy) meanFreePath = DBL_MAX;
791
792   else {
793     if(kineticEnergy > HighestKineticEnergy)
794                    kineticEnergy = HighestKineticEnergy;
795     meanFreePath = (((*theMeanFreePathTable)(couple->GetIndex()))->
796                    GetValue(kineticEnergy,isOutRange))/chargeSquare;
797     }
798
799   return meanFreePath ;
800}
801
802//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
803
804G4double G4hLowEnergyIonisation::GetConstraints(
805                                 const G4DynamicParticle* particle,
806                                 const G4MaterialCutsCouple* couple)
807{
808  // returns the Step limit
809  // dEdx is calculated as well as the range
810  // based on Effective Charge Approach
811
812  const G4Material* material = couple->GetMaterial();
813  G4Proton* theProton = G4Proton::Proton();
814  G4AntiProton* theAntiProton = G4AntiProton::AntiProton();
815
816  G4double stepLimit = 0.0 ;
817  G4double dx, highEnergy;
818
819  G4double massRatio = proton_mass_c2/(particle->GetMass()) ;
820  G4double kineticEnergy = particle->GetKineticEnergy() ;
821
822  // Scale the kinetic energy
823
824  G4double tscaled = kineticEnergy*massRatio ;
825  fBarkas = 0.0;
826
827  if(charge > 0.0) {
828
829    highEnergy = protonHighEnergy ;
830
831    fRangeNow = G4EnergyLossTables::GetRange(theProton, tscaled, couple);
832    dx = G4EnergyLossTables::GetRange(theProton, highEnergy, couple);
833    fdEdx = G4EnergyLossTables::GetDEDX(theProton, tscaled, couple)
834          * chargeSquare ;
835
836        // Correction for positive ions
837    if(theBarkas && tscaled > highEnergy) { 
838        fBarkas = BarkasTerm(material,tscaled)*std::sqrt(chargeSquare)*chargeSquare
839                + BlochTerm(material,tscaled,chargeSquare);
840    }
841    // Antiprotons and negative hadrons
842  } else {
843
844    highEnergy = antiProtonHighEnergy ;
845    fRangeNow = G4EnergyLossTables::GetRange(theAntiProton, tscaled, couple);
846    dx = G4EnergyLossTables::GetRange(theAntiProton, highEnergy, couple);
847    fdEdx = G4EnergyLossTables::GetDEDX(theAntiProton, tscaled, couple)
848          * chargeSquare ;
849
850    if(theBarkas && tscaled > highEnergy) { 
851        fBarkas = -BarkasTerm(material,tscaled)*std::sqrt(chargeSquare)*chargeSquare
852                + BlochTerm(material,tscaled,chargeSquare);
853    }
854  }
855  /*
856  const G4Material* mat = couple->GetMaterial();
857  G4double fac = gram/(MeV*cm2*mat->GetDensity());
858  G4cout << particle->GetDefinition()->GetParticleName()
859         << " in " << mat->GetName()
860         << " E(MeV)= " << kineticEnergy/MeV
861         << " dedx(MeV*cm^2/g)= " << fdEdx*fac
862         << " barcas(MeV*cm^2/gram)= " << fBarkas*fac
863         << " Q^2= " << chargeSquare
864         << G4endl;
865  */
866  // scaling back
867  fRangeNow /= (chargeSquare*massRatio) ;
868  dx        /= (chargeSquare*massRatio) ;
869
870  stepLimit  = fRangeNow ;
871  G4double r = std::min(finalRange, couple->GetProductionCuts()
872                 ->GetProductionCut(idxG4ElectronCut));
873
874  if (fRangeNow > r) {
875    stepLimit = dRoverRange*fRangeNow + r*(1.0 - dRoverRange)*(2.0 - r/fRangeNow);
876    if (stepLimit > fRangeNow) stepLimit = fRangeNow;
877  }
878  // compute the (random) Step limit in standard energy range
879  if(tscaled > highEnergy ) {
880
881    // add Barkas correction directly to dedx
882    fdEdx  += fBarkas;
883 
884    if(stepLimit > fRangeNow - dx*0.9) stepLimit = fRangeNow - dx*0.9 ;
885
886  // Step limit in low energy range
887  } else {
888    G4double x = dx*paramStepLimit;
889    if (stepLimit > x) stepLimit = x;
890  }
891  return stepLimit ;
892}
893
894//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
895
896G4VParticleChange* G4hLowEnergyIonisation::AlongStepDoIt(
897                                           const G4Track& trackData,
898                                           const G4Step& stepData)
899{
900  // compute the energy loss after a step
901  G4Proton* theProton = G4Proton::Proton();
902  G4AntiProton* theAntiProton = G4AntiProton::AntiProton();
903  G4double finalT = 0.0 ;
904
905  aParticleChange.Initialize(trackData) ;
906
907  const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
908  const G4Material* material = couple->GetMaterial();
909
910  // get the actual (true) Step length from stepData
911  const G4double step = stepData.GetStepLength() ;
912
913  const G4DynamicParticle* particle = trackData.GetDynamicParticle() ;
914
915  G4double kineticEnergy = particle->GetKineticEnergy() ;
916  G4double massRatio = proton_mass_c2/(particle->GetMass()) ;
917  G4double tscaled= kineticEnergy*massRatio ;
918  G4double eloss = 0.0 ;
919  G4double nloss = 0.0 ;
920
921
922    // very small particle energy
923  if(kineticEnergy < MinKineticEnergy) {
924
925    eloss = kineticEnergy ;
926
927    // particle energy outside tabulated energy range
928  } else if( kineticEnergy > HighestKineticEnergy) {
929    eloss = step*fdEdx ;
930
931    // big step
932  } else if(step >= fRangeNow ) {
933    eloss = kineticEnergy ;
934
935    // tabulated range
936  } else {
937
938    // step longer than linear step limit
939    if(step > linLossLimit*fRangeNow) {
940
941      G4double rscaled= fRangeNow*massRatio*chargeSquare ;
942      G4double sscaled=   step   *massRatio*chargeSquare ;
943
944      if(charge > 0.0) {
945        eloss = G4EnergyLossTables::GetPreciseEnergyFromRange(
946                                    theProton,rscaled, couple) -
947                G4EnergyLossTables::GetPreciseEnergyFromRange(
948                                    theProton,rscaled-sscaled,couple) ;
949
950      } else {
951        eloss = G4EnergyLossTables::GetPreciseEnergyFromRange(
952                                    theAntiProton,rscaled,couple) -
953                G4EnergyLossTables::GetPreciseEnergyFromRange(
954                                    theAntiProton,rscaled-sscaled,couple) ;
955      }
956      eloss /= massRatio ;
957
958      // Barkas correction at big step     
959      eloss += fBarkas*step;
960
961    // step shorter than linear step limit
962    } else {
963      eloss = step*fdEdx ;
964    }
965    if(nStopping && tscaled < protonHighEnergy) {
966      nloss = (theNuclearStoppingModel->TheValue(particle, material))*step;
967    }
968  }
969
970  if(eloss < 0.0) eloss = 0.0;
971
972  finalT = kineticEnergy - eloss - nloss;
973
974  if( EnlossFlucFlag && 0.0 < eloss && finalT > MinKineticEnergy) {
975
976    //  now the electron loss with fluctuation
977    eloss = ElectronicLossFluctuation(particle, couple, eloss, step) ;
978    if(eloss < 0.0) eloss = 0.0;
979    finalT = kineticEnergy - eloss - nloss;
980  }
981
982  //  stop particle if the kinetic energy <= MinKineticEnergy
983  if (finalT*massRatio <= MinKineticEnergy ) {
984
985     finalT = 0.0;
986      if(!particle->GetDefinition()->GetProcessManager()->
987                     GetAtRestProcessVector()->size())
988        aParticleChange.ProposeTrackStatus(fStopAndKill);
989      else
990        aParticleChange.ProposeTrackStatus(fStopButAlive);
991  }
992
993  aParticleChange.ProposeEnergy( finalT );
994  eloss = kineticEnergy-finalT;
995
996  // Deexcitation only of ionised atoms
997  G4double hMass = particle->GetMass();
998  std::vector<G4DynamicParticle*>* newpart = 0;
999  G4DynamicParticle* part = 0;
1000
1001  if(theFluo) newpart = DeexciteAtom(couple, kineticEnergy, hMass, eloss);
1002
1003  if(newpart != 0) {
1004
1005    size_t nSecondaries = newpart->size();
1006    aParticleChange.SetNumberOfSecondaries(nSecondaries);
1007    G4Track* newtrack = 0;
1008    const G4StepPoint* preStep = stepData.GetPreStepPoint();
1009    const G4StepPoint* postStep = stepData.GetPostStepPoint();
1010    G4ThreeVector r = preStep->GetPosition();
1011    G4ThreeVector deltaR = postStep->GetPosition();
1012    deltaR -= r;
1013    G4double t = preStep->GetGlobalTime();
1014    G4double deltaT = postStep->GetGlobalTime();
1015    deltaT -= t;
1016    G4double time, q, e;
1017    G4ThreeVector position;
1018
1019    for(size_t i=0; i<nSecondaries; i++) {
1020
1021      part = (*newpart)[i];
1022      if(part) {
1023
1024        e = part->GetKineticEnergy();
1025        if(e <= eloss) {
1026
1027          eloss -= e;
1028          q = G4UniformRand();
1029          time = deltaT*q + t;
1030          position  = deltaR*q;
1031          position += r;
1032          newtrack = new G4Track(part, time, position);
1033          aParticleChange.AddSecondary(newtrack);
1034
1035        } else {
1036
1037          delete part;
1038
1039        }
1040      }
1041    }
1042    delete newpart;
1043  }
1044
1045  aParticleChange.ProposeLocalEnergyDeposit(eloss);
1046  return &aParticleChange ;
1047}
1048
1049//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1050
1051G4double G4hLowEnergyIonisation::ProtonParametrisedDEDX(
1052                                 const G4MaterialCutsCouple* couple,
1053                                       G4double kineticEnergy) const
1054{
1055  const G4Material* material = couple->GetMaterial();
1056  G4Proton* theProton = G4Proton::Proton();
1057  G4double eloss = 0.0;
1058
1059    // Free Electron Gas Model
1060  if(kineticEnergy < protonLowEnergy) {
1061    eloss = (theProtonModel->TheValue(theProton, material, protonLowEnergy))
1062          * std::sqrt(kineticEnergy/protonLowEnergy) ;
1063
1064    // Parametrisation
1065  } else {
1066    eloss = theProtonModel->TheValue(theProton, material, kineticEnergy) ;
1067  }
1068
1069  // Delta rays energy
1070  eloss -= DeltaRaysEnergy(couple,kineticEnergy,proton_mass_c2) ;
1071
1072  if(verboseLevel > 2) {
1073    G4cout << "p E(MeV)= " << kineticEnergy/MeV
1074           << " dE/dx(MeV/mm)= " << eloss*mm/MeV
1075           << " for " << material->GetName()
1076           << " model: " << theProtonModel << G4endl;
1077  }
1078
1079  if(eloss < 0.0) eloss = 0.0 ;
1080
1081  return eloss ;
1082}
1083
1084//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1085
1086G4double G4hLowEnergyIonisation::AntiProtonParametrisedDEDX(
1087                                 const G4MaterialCutsCouple* couple,
1088                                       G4double kineticEnergy) const
1089{
1090  const G4Material* material = couple->GetMaterial();
1091  G4AntiProton* theAntiProton = G4AntiProton::AntiProton();
1092  G4double eloss = 0.0 ;
1093
1094  // Antiproton model is used
1095  if(theAntiProtonModel->IsInCharge(theAntiProton,material)) {
1096    if(kineticEnergy < antiProtonLowEnergy) {
1097      eloss = theAntiProtonModel->TheValue(theAntiProton,material,antiProtonLowEnergy)
1098            * std::sqrt(kineticEnergy/antiProtonLowEnergy) ;
1099
1100    // Parametrisation
1101    } else {
1102      eloss = theAntiProtonModel->TheValue(theAntiProton,material,
1103                                           kineticEnergy);
1104    }
1105
1106  // The proton model is used + Barkas correction
1107  } else {
1108    if(kineticEnergy < protonLowEnergy) {
1109      eloss = theProtonModel->TheValue(G4Proton::Proton(),material,protonLowEnergy)
1110          * std::sqrt(kineticEnergy/protonLowEnergy) ;
1111
1112    // Parametrisation
1113    } else {
1114      eloss = theProtonModel->TheValue(G4Proton::Proton(),material,
1115                                       kineticEnergy);
1116    }
1117    //if(theBarkas) eloss -= 2.0*BarkasTerm(material, kineticEnergy);
1118  }
1119
1120  // Delta rays energy
1121  eloss -= DeltaRaysEnergy(couple,kineticEnergy,proton_mass_c2) ;
1122
1123  if(verboseLevel > 2) {
1124    G4cout << "pbar E(MeV)= " << kineticEnergy/MeV
1125           << " dE/dx(MeV/mm)= " << eloss*mm/MeV
1126           << " for " << material->GetName()
1127           << " model: " << theProtonModel << G4endl;
1128  }
1129
1130  if(eloss < 0.0) eloss = 0.0 ;
1131
1132  return eloss ;
1133}
1134
1135//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1136
1137G4double G4hLowEnergyIonisation::DeltaRaysEnergy(
1138                                 const G4MaterialCutsCouple* couple,
1139                                       G4double kineticEnergy,
1140                                       G4double particleMass) const
1141{
1142  G4double dloss = 0.0 ;
1143
1144  G4double deltaCutNow = cutForDelta[(couple->GetIndex())] ;
1145  const G4Material* material = couple->GetMaterial();
1146  G4double electronDensity = material->GetElectronDensity();
1147  G4double eexc = material->GetIonisation()->GetMeanExcitationEnergy();
1148
1149  G4double tau = kineticEnergy/particleMass ;
1150  G4double rateMass = electron_mass_c2/particleMass ;
1151
1152  // some local variables
1153
1154  G4double gamma,bg2,beta2,tmax,x ;
1155
1156  gamma = tau + 1.0 ;
1157  bg2 = tau*(tau+2.0) ;
1158  beta2 = bg2/(gamma*gamma) ;
1159  tmax = 2.*electron_mass_c2*bg2/(1.0+2.0*gamma*rateMass+rateMass*rateMass) ;
1160
1161  // Validity range for delta electron cross section
1162  G4double deltaCut = std::max(deltaCutNow, eexc);
1163
1164  if ( deltaCut < tmax) {
1165    x = deltaCut / tmax ;
1166    dloss = ( beta2 * (x - 1.0) - std::log(x) ) * twopi_mc2_rcl2
1167          * electronDensity / beta2 ;
1168  }
1169  return dloss ;
1170}
1171
1172//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1173
1174G4VParticleChange* G4hLowEnergyIonisation::PostStepDoIt(
1175                                           const G4Track& trackData,
1176                                           const G4Step& stepData)
1177{
1178  // Units are expressed in GEANT4 internal units.
1179
1180  G4double KineticEnergy,TotalEnergy,TotalMomentum,betasquare,
1181           DeltaKineticEnergy,DeltaTotalMomentum,costheta,sintheta,phi,
1182           dirx,diry,dirz,finalKineticEnergy,finalPx,finalPy,finalPz,
1183           x,xc,grej,Psquare,Esquare,rate,finalMomentum ;
1184
1185  aParticleChange.Initialize(trackData) ;
1186  const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
1187
1188  const G4DynamicParticle* aParticle = trackData.GetDynamicParticle() ;
1189
1190  // some kinematics
1191
1192  ParticleMass=aParticle->GetDefinition()->GetPDGMass();
1193  KineticEnergy=aParticle->GetKineticEnergy();
1194  TotalEnergy=KineticEnergy + ParticleMass ;
1195  Psquare=KineticEnergy*(TotalEnergy+ParticleMass) ;
1196  Esquare=TotalEnergy*TotalEnergy;
1197  betasquare=Psquare/Esquare;
1198  G4ThreeVector ParticleDirection = aParticle->GetMomentumDirection() ;
1199
1200  G4double gamma= KineticEnergy/ParticleMass + 1.;
1201  G4double r    = electron_mass_c2/ParticleMass;
1202  G4double tmax = 2.*electron_mass_c2*(gamma*gamma - 1.)/(1. + 2.*gamma*r + r*r);
1203
1204  // Validity range for delta electron cross section
1205  G4double DeltaCut = cutForDelta[couple->GetIndex()];
1206
1207  // This should not be a case
1208  if(DeltaCut >= tmax)
1209       return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
1210
1211  xc   = DeltaCut / tmax;
1212  rate = tmax / TotalEnergy;
1213  rate = rate*rate ;
1214  G4double spin = aParticle->GetDefinition()->GetPDGSpin() ;
1215
1216  // sampling follows ...
1217      do {
1218        x=xc/(1.-(1.-xc)*G4UniformRand());
1219
1220        if(0.0 == spin) {
1221          grej = 1.0 - betasquare * x ;
1222
1223        } else if (0.5 == spin) {
1224          grej = (1.0 - betasquare * x + 0.5*x*x*rate) / (1.0 + 0.5 * rate) ;
1225
1226        } else {
1227          grej = (1.0 - betasquare * x ) * (1.0 + x/ (3.0*xc)) +
1228            x * x * rate * (1.0 + 0.5 * x / xc) / 3.0 /
1229            (1.0 + 1.0/(3.0*xc) + rate *(1.0+ 0.5/xc) /3.0) ;
1230        }
1231
1232      } while( G4UniformRand() > grej );
1233
1234
1235  DeltaKineticEnergy = x * tmax;
1236
1237  DeltaTotalMomentum = std::sqrt(DeltaKineticEnergy * (DeltaKineticEnergy +
1238                                                  2. * electron_mass_c2 )) ;
1239  TotalMomentum = std::sqrt(Psquare) ;
1240  costheta = DeltaKineticEnergy * (TotalEnergy + electron_mass_c2)
1241    /(DeltaTotalMomentum * TotalMomentum) ;
1242
1243  //  protection against costheta > 1 or < -1   ---------------
1244  if ( costheta < -1. )
1245    costheta = -1. ;
1246  if ( costheta > +1. )
1247    costheta = +1. ;
1248
1249  //  direction of the delta electron  ........
1250  phi = twopi * G4UniformRand() ;
1251  sintheta = std::sqrt(1. - costheta*costheta);
1252  dirx = sintheta * std::cos(phi) ;
1253  diry = sintheta * std::sin(phi) ;
1254  dirz = costheta ;
1255
1256  G4ThreeVector DeltaDirection(dirx,diry,dirz) ;
1257  DeltaDirection.rotateUz(ParticleDirection) ;
1258
1259  // create G4DynamicParticle object for delta ray
1260  G4DynamicParticle *theDeltaRay = new G4DynamicParticle;
1261  theDeltaRay->SetKineticEnergy( DeltaKineticEnergy );
1262  theDeltaRay->SetMomentumDirection(DeltaDirection.x(),
1263                                    DeltaDirection.y(),
1264                                    DeltaDirection.z());
1265  theDeltaRay->SetDefinition(G4Electron::Electron());
1266
1267  // fill aParticleChange
1268  finalKineticEnergy = KineticEnergy - DeltaKineticEnergy ;
1269
1270  // Generation of Fluorescence and Auger
1271  size_t nSecondaries = 0;
1272  size_t totalNumber  = 1;
1273  std::vector<G4DynamicParticle*>* secondaryVector = 0;
1274  G4DynamicParticle* aSecondary = 0;
1275  G4ParticleDefinition* type = 0;
1276
1277  // Select atom and shell
1278  G4int Z = SelectRandomAtom(couple, KineticEnergy);
1279
1280  //   G4cout << "Fluorescence is switched :" << theFluo << G4endl;
1281
1282  if(theFluo && Z > 5) {
1283
1284
1285
1286    // Atom total cross section for the Empiric Model   
1287    if (expFlag) {   
1288    shellCS->SetTotalCS(totalCrossSectionMap[Z]);   
1289    }
1290    G4int shell = shellCS->SelectRandomShell(Z, KineticEnergy,ParticleMass,DeltaKineticEnergy);
1291
1292    if (expFlag && shell==1) {       
1293      aParticleChange.ProposeLocalEnergyDeposit (KineticEnergy);
1294      aParticleChange.ProposeEnergy(0);     
1295    }
1296
1297
1298    const G4AtomicShell* atomicShell =
1299                (G4AtomicTransitionManager::Instance())->Shell(Z, shell);
1300    G4double bindingEnergy = atomicShell->BindingEnergy();
1301
1302    if(verboseLevel > 1) {
1303      G4cout << "PostStep Z= " << Z << " shell= " << shell
1304             << " bindingE(keV)= " << bindingEnergy/keV
1305             << " finalE(keV)= " << finalKineticEnergy/keV
1306             << G4endl;
1307    }
1308
1309    // Fluorescence data start from element 6
1310
1311    if (finalKineticEnergy >= bindingEnergy
1312         && (bindingEnergy >= minGammaEnergy
1313         ||  bindingEnergy >= minElectronEnergy) ) {
1314
1315      G4int shellId = atomicShell->ShellId();
1316      secondaryVector = deexcitationManager.GenerateParticles(Z, shellId);
1317
1318      if (secondaryVector != 0) {
1319
1320        nSecondaries = secondaryVector->size();
1321        for (size_t i = 0; i<nSecondaries; i++) {
1322
1323          aSecondary = (*secondaryVector)[i];
1324          if (aSecondary) {
1325
1326            G4double e = aSecondary->GetKineticEnergy();
1327            type = aSecondary->GetDefinition();
1328            if (e < finalKineticEnergy &&
1329                 ((type == G4Gamma::Gamma() && e > minGammaEnergy ) ||
1330                  (type == G4Electron::Electron() && e > minElectronEnergy ))) {
1331
1332              finalKineticEnergy -= e;
1333              totalNumber++;
1334
1335            } else {
1336
1337              delete aSecondary;
1338              (*secondaryVector)[i] = 0;
1339            }
1340          }
1341        }
1342      }
1343    }
1344  }
1345
1346  // Save delta-electrons
1347
1348  G4double edep = 0.0;
1349
1350  if (finalKineticEnergy > MinKineticEnergy)
1351    {
1352      finalPx = TotalMomentum*ParticleDirection.x()
1353        - DeltaTotalMomentum*DeltaDirection.x();
1354      finalPy = TotalMomentum*ParticleDirection.y()
1355        - DeltaTotalMomentum*DeltaDirection.y();
1356      finalPz = TotalMomentum*ParticleDirection.z()
1357        - DeltaTotalMomentum*DeltaDirection.z();
1358      finalMomentum =
1359        std::sqrt(finalPx*finalPx+finalPy*finalPy+finalPz*finalPz) ;
1360      finalPx /= finalMomentum ;
1361      finalPy /= finalMomentum ;
1362      finalPz /= finalMomentum ;
1363
1364      aParticleChange.ProposeMomentumDirection( finalPx,finalPy,finalPz );
1365    }
1366  else
1367    {
1368      edep = finalKineticEnergy;
1369      finalKineticEnergy = 0.;
1370      aParticleChange.ProposeMomentumDirection(ParticleDirection.x(),
1371                      ParticleDirection.y(),ParticleDirection.z());
1372      if(!aParticle->GetDefinition()->GetProcessManager()->
1373                     GetAtRestProcessVector()->size())
1374        aParticleChange.ProposeTrackStatus(fStopAndKill);
1375      else
1376        aParticleChange.ProposeTrackStatus(fStopButAlive);
1377    }
1378
1379  aParticleChange.ProposeEnergy( finalKineticEnergy );
1380  aParticleChange.ProposeLocalEnergyDeposit (edep);
1381  aParticleChange.SetNumberOfSecondaries(totalNumber);
1382  aParticleChange.AddSecondary(theDeltaRay);
1383
1384  // Save Fluorescence and Auger
1385
1386  if (secondaryVector) {
1387
1388    for (size_t l = 0; l < nSecondaries; l++) {
1389
1390      aSecondary = (*secondaryVector)[l];
1391      if(aSecondary) {
1392        aParticleChange.AddSecondary(aSecondary);
1393      }
1394    }
1395    delete secondaryVector;
1396  }
1397
1398  return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
1399}
1400
1401//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1402
1403std::vector<G4DynamicParticle*>*
1404G4hLowEnergyIonisation::DeexciteAtom(const G4MaterialCutsCouple* couple,
1405                                           G4double incidentEnergy,
1406                                           G4double hMass,
1407                                           G4double eLoss)
1408{
1409
1410  if (verboseLevel > 1) {
1411        G4cout << "DeexciteAtom: cutForPhotons(keV)= " << minGammaEnergy/keV
1412               << "  cutForElectrons(keV)= " << minElectronEnergy/keV
1413               << "  eLoss(MeV)= " << eLoss
1414               << G4endl;
1415  }
1416
1417
1418
1419  if(eLoss < minGammaEnergy && eLoss < minElectronEnergy) return 0;
1420
1421  const G4Material* material = couple->GetMaterial();
1422  G4int index    = couple->GetIndex();
1423  //  G4double eexc  = material->GetIonisation()->GetMeanExcitationEnergy();
1424  G4double gamma = incidentEnergy/hMass + 1;
1425  G4double beta2 = 1.0 - 1.0/(gamma*gamma);
1426  G4double r     = electron_mass_c2/hMass;
1427  G4double tmax  = 2.*electron_mass_c2*(gamma*gamma - 1.)/(1. + 2.*gamma*r + r*r);
1428  G4double tcut  = std::min(tmax,cutForDelta[index]);
1429  const G4AtomicTransitionManager* transitionManager =
1430                             G4AtomicTransitionManager::Instance();
1431
1432  size_t nElements = material->GetNumberOfElements();
1433  const G4ElementVector* theElementVector = material->GetElementVector();
1434  G4bool stop = true;
1435
1436  for (size_t j=0; j<nElements; j++) {
1437
1438    G4int Z = (G4int)((*theElementVector)[j]->GetZ());
1439    G4double maxE = transitionManager->Shell(Z, 0)->BindingEnergy();
1440
1441    if (Z > 5 && maxE < tcut && (maxE > minGammaEnergy || maxE > minElectronEnergy) ) {
1442      stop = false;
1443      break;
1444    }
1445  }
1446
1447  if(stop) return 0;
1448
1449  // create vector of tracks of secondary particles
1450
1451  std::vector<G4DynamicParticle*>* partVector =
1452         new std::vector<G4DynamicParticle*>;
1453  std::vector<G4DynamicParticle*>* secVector = 0;
1454  G4DynamicParticle* aSecondary = 0;
1455  G4ParticleDefinition* type = 0;
1456  G4double e, tkin, grej;
1457  G4ThreeVector position;
1458  G4int shell, shellId;
1459
1460  // sample secondaries
1461
1462  G4double etot = 0.0;
1463  std::vector<G4int> n = shellVacancy->GenerateNumberOfIonisations(couple,
1464                                         incidentEnergy, eLoss);
1465
1466  for (size_t i=0; i<nElements; i++) {
1467
1468    size_t nVacancies = n[i];
1469    G4int Z = (G4int)((*theElementVector)[i]->GetZ());
1470    G4double maxE = transitionManager->Shell(Z, 0)->BindingEnergy();
1471
1472    if (nVacancies && Z  > 5 && maxE < tcut && (maxE > minGammaEnergy || maxE > minElectronEnergy)) {
1473      for(size_t j=0; j<nVacancies; j++) {
1474
1475        // sampling follows
1476        do {
1477          tkin = tcut/(1.0 + (tcut/maxE - 1.0)*G4UniformRand());
1478          grej = 1.0 - beta2 * tkin/tmax;
1479
1480        } while( G4UniformRand() > grej );
1481
1482        shell = shellCS->SelectRandomShell(Z,incidentEnergy,hMass,tkin);
1483
1484        shellId = transitionManager->Shell(Z, shell)->ShellId();
1485        G4double maxE = transitionManager->Shell(Z, shell)->BindingEnergy();
1486
1487        if (maxE>minGammaEnergy || maxE>minElectronEnergy ) {
1488          secVector = deexcitationManager.GenerateParticles(Z, shellId);
1489        } else {
1490          secVector = 0;
1491        }
1492
1493        if (secVector) {
1494
1495          for (size_t l = 0; l<secVector->size(); l++) {
1496
1497            aSecondary = (*secVector)[l];
1498            if(aSecondary) {
1499
1500              e = aSecondary->GetKineticEnergy();
1501              type = aSecondary->GetDefinition();
1502              if ( etot + e <= eLoss &&
1503                   ( (type == G4Gamma::Gamma() && e > minGammaEnergy ) ||
1504                   (type == G4Electron::Electron() && e > minElectronEnergy) ) ) {
1505
1506                     etot += e;
1507                     partVector->push_back(aSecondary);
1508
1509              } else {
1510                     delete aSecondary;
1511              }
1512            }
1513          }
1514          delete secVector;
1515        }
1516      }
1517    }
1518  }
1519
1520  if(partVector->empty()) {
1521    delete partVector;
1522    return 0;
1523  }
1524
1525  return partVector;
1526}
1527
1528//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1529
1530G4int G4hLowEnergyIonisation::SelectRandomAtom(const G4MaterialCutsCouple* couple,
1531                                                     G4double kineticEnergy) const
1532{
1533  const G4Material* material = couple->GetMaterial();
1534  G4int nElements = material->GetNumberOfElements();
1535  G4int Z = 0;
1536
1537  if(nElements == 1) {
1538    Z = (G4int)(material->GetZ());
1539    return Z;
1540  }
1541
1542  const G4ElementVector* theElementVector = material->GetElementVector();
1543  std::vector<G4double> p;
1544  G4int index = couple->GetIndex();
1545
1546  G4double norm = 0.0;
1547  for (G4int j=0; j<nElements; j++) {
1548
1549    const G4VEMDataSet* set = (zFluoDataVector[index])->GetComponent(j);
1550    G4double cross    = set->FindValue(kineticEnergy);
1551
1552    p.push_back(cross);
1553    norm += cross;
1554  }
1555
1556  if(norm == 0.0) return 0;
1557
1558  G4double q = norm*G4UniformRand();
1559
1560  for (G4int i=0; i<nElements; i++) {
1561
1562    if(p[i] > q) {
1563       Z = (G4int)((*theElementVector)[i]->GetZ());
1564       break;
1565    }
1566    q -= p[i];
1567  }
1568
1569  return Z;
1570}
1571
1572//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1573
1574G4double G4hLowEnergyIonisation::ComputeDEDX(
1575                                 const G4ParticleDefinition* aParticle,
1576                                 const G4MaterialCutsCouple* couple,
1577                                 G4double kineticEnergy)
1578{
1579  const G4Material* material = couple->GetMaterial();
1580  G4Proton* theProton = G4Proton::Proton();
1581  G4AntiProton* theAntiProton = G4AntiProton::AntiProton();
1582  G4double dedx = 0.0 ;
1583
1584  G4double tscaled = kineticEnergy*proton_mass_c2/(aParticle->GetPDGMass()) ;
1585  charge  = aParticle->GetPDGCharge() ;
1586
1587  if(charge>0.0) {
1588    if(tscaled > protonHighEnergy) {
1589      dedx=G4EnergyLossTables::GetDEDX(theProton,tscaled,couple) ;
1590
1591    } else {
1592      dedx=ProtonParametrisedDEDX(couple,tscaled) ;
1593    }
1594
1595  } else {
1596    if(tscaled > antiProtonHighEnergy) {
1597      dedx=G4EnergyLossTables::GetDEDX(theAntiProton,tscaled,couple);
1598
1599    } else {
1600      dedx=AntiProtonParametrisedDEDX(couple,tscaled) ;
1601    }
1602  }
1603  dedx *= theIonEffChargeModel->TheValue(aParticle, material, kineticEnergy) ;
1604
1605  return dedx ;
1606}
1607
1608//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1609
1610G4double G4hLowEnergyIonisation::BarkasTerm(const G4Material* material,
1611                                                  G4double kineticEnergy) const
1612//Function to compute the Barkas term for protons:
1613//
1614//Ref. Z_1^3 effect in the stopping power of matter for charged particles
1615//     J.C Ashley and R.H.Ritchie
1616//     Physical review B Vol.5 No.7 1 April 1972 pagg. 2393-2397
1617//
1618{
1619  static double FTable[47][2] = {
1620   { 0.02, 21.5},
1621   { 0.03, 20.0},
1622   { 0.04, 18.0},
1623   { 0.05, 15.6},
1624   { 0.06, 15.0},
1625   { 0.07, 14.0},
1626   { 0.08, 13.5},
1627   { 0.09, 13.},
1628   { 0.1,  12.2},
1629   { 0.2,  9.25},
1630   { 0.3,  7.0},
1631   { 0.4,  6.0},
1632   { 0.5,  4.5},
1633   { 0.6,  3.5},
1634   { 0.7,  3.0},
1635   { 0.8,  2.5},
1636   { 0.9,  2.0},
1637   { 1.0,  1.7},
1638   { 1.2,  1.2},
1639   { 1.3,  1.0},
1640   { 1.4,  0.86},
1641   { 1.5,  0.7},
1642   { 1.6,  0.61},
1643   { 1.7,  0.52},
1644   { 1.8,  0.5},
1645   { 1.9,  0.43},
1646   { 2.0,  0.42},
1647   { 2.1,  0.3},
1648   { 2.4,  0.2},
1649   { 3.0,  0.13},
1650   { 3.08, 0.1},
1651   { 3.1,  0.09},
1652   { 3.3,  0.08},
1653   { 3.5,  0.07},
1654   { 3.8,  0.06},
1655   { 4.0,  0.051},
1656   { 4.1,  0.04},
1657   { 4.8,  0.03},
1658   { 5.0,  0.024},
1659   { 5.1,  0.02},
1660   { 6.0,  0.013},
1661   { 6.5,  0.01},
1662   { 7.0,  0.009},
1663   { 7.1,  0.008},
1664   { 8.0,  0.006},
1665   { 9.0,  0.0032},
1666   { 10.0, 0.0025} };
1667
1668  // Information on particle and material
1669  G4double kinE  = kineticEnergy ;
1670  if(0.5*MeV > kinE) kinE = 0.5*MeV ;
1671  G4double gamma = 1.0 + kinE / proton_mass_c2 ;
1672  G4double beta2 = 1.0 - 1.0/(gamma*gamma) ;
1673  if(0.0 >= beta2) return 0.0;
1674
1675  G4double BarkasTerm = 0.0;
1676  G4double AMaterial = 0.0;
1677  G4double ZMaterial = 0.0;
1678  const G4ElementVector* theElementVector = material->GetElementVector();
1679  G4int numberOfElements = material->GetNumberOfElements();
1680
1681  for (G4int i = 0; i<numberOfElements; i++) {
1682
1683    AMaterial = (*theElementVector)[i]->GetA()*mole/g;
1684    ZMaterial = (*theElementVector)[i]->GetZ();
1685
1686    G4double X = 137.0 * 137.0 * beta2 / ZMaterial;
1687
1688    // Variables to compute L_1
1689    G4double Eta0Chi = 0.8;
1690    G4double EtaChi = Eta0Chi * ( 1.0 + 6.02*std::pow( ZMaterial,-1.19 ) );
1691    G4double W = ( EtaChi * std::pow( ZMaterial,1.0/6.0 ) ) / std::sqrt(X);
1692    G4double FunctionOfW = FTable[46][1]*FTable[46][0]/W ;
1693
1694    for(G4int j=0; j<47; j++) {
1695
1696      if( W < FTable[j][0] ) {
1697
1698        if(0 == j) {
1699          FunctionOfW = FTable[0][1] ;
1700
1701        } else {
1702          FunctionOfW = (FTable[j][1] - FTable[j-1][1]) * (W - FTable[j-1][0])
1703                      / (FTable[j][0] - FTable[j-1][0])
1704                      +  FTable[j-1][1] ;
1705        }
1706
1707        break;
1708      }
1709
1710    }
1711
1712    BarkasTerm += FunctionOfW /( std::sqrt(ZMaterial * X) * X);
1713  }
1714
1715  BarkasTerm *= twopi_mc2_rcl2 * (material->GetElectronDensity()) / beta2 ;
1716
1717  return BarkasTerm;
1718}
1719
1720//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1721
1722G4double G4hLowEnergyIonisation::BlochTerm(const G4Material* material,
1723                                                 G4double kineticEnergy,
1724                                                 G4double cSquare) const
1725//Function to compute the Bloch term for protons:
1726//
1727//Ref. Z_1^3 effect in the stopping power of matter for charged particles
1728//     J.C Ashley and R.H.Ritchie
1729//     Physical review B Vol.5 No.7 1 April 1972 pagg. 2393-2397
1730//
1731{
1732  G4double eloss = 0.0 ;
1733  G4double gamma = 1.0 + kineticEnergy / proton_mass_c2 ;
1734  G4double beta2 = 1.0 - 1.0/(gamma*gamma) ;
1735  G4double y = cSquare / (137.0*137.0*beta2) ;
1736
1737  if(y < 0.05) {
1738    eloss = 1.202 ;
1739
1740  } else {
1741    eloss = 1.0 / (1.0 + y) ;
1742    G4double de = eloss ;
1743
1744    for(G4int i=2; de>eloss*0.01; i++) {
1745      de = 1.0/( i * (i*i + y)) ;
1746      eloss += de ;
1747    }
1748  }
1749  eloss *= -1.0 * y * cSquare * twopi_mc2_rcl2 *
1750            (material->GetElectronDensity()) / beta2 ;
1751
1752  return eloss;
1753}
1754
1755//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1756
1757G4double G4hLowEnergyIonisation::ElectronicLossFluctuation(
1758                                 const G4DynamicParticle* particle,
1759                                 const G4MaterialCutsCouple* couple,
1760                                       G4double meanLoss,
1761                                       G4double step) const
1762//  calculate actual loss from the mean loss
1763//  The model used to get the fluctuation is essentially the same
1764// as in Glandz in Geant3.
1765{
1766  // data members to speed up the fluctuation calculation
1767  //  G4int imat ;
1768  //  G4double f1Fluct,f2Fluct,e1Fluct,e2Fluct,rateFluct,ipotFluct;
1769  //  G4double e1LogFluct,e2LogFluct,ipotLogFluct;
1770
1771  static const G4double minLoss = 1.*eV ;
1772  static const G4double kappa = 10. ;
1773  static const G4double theBohrBeta2 = 50.0 * keV/proton_mass_c2 ;
1774
1775  const G4Material* material = couple->GetMaterial();
1776  G4int    imaterial   = couple->GetIndex() ;
1777  G4double ipotFluct   = material->GetIonisation()->GetMeanExcitationEnergy() ;
1778  G4double electronDensity = material->GetElectronDensity() ;
1779  G4double zeff = electronDensity/(material->GetTotNbOfAtomsPerVolume()) ;
1780
1781  // get particle data
1782  G4double tkin   = particle->GetKineticEnergy();
1783  G4double particleMass = particle->GetMass() ;
1784  G4double deltaCutInKineticEnergyNow = cutForDelta[imaterial];
1785
1786  // shortcut for very very small loss
1787  if(meanLoss < minLoss) return meanLoss ;
1788
1789  // Validity range for delta electron cross section
1790  G4double threshold = std::max(deltaCutInKineticEnergyNow,ipotFluct);
1791  G4double loss, siga;
1792
1793  G4double rmass = electron_mass_c2/particleMass;
1794  G4double tau   = tkin/particleMass;
1795  G4double tau1 = tau+1.0;
1796  G4double tau2 = tau*(tau+2.);
1797  G4double tmax    = 2.*electron_mass_c2*tau2/(1.+2.*tau1*rmass+rmass*rmass);
1798
1799
1800  if(tmax > threshold) tmax = threshold;
1801  G4double beta2 = tau2/(tau1*tau1);
1802
1803  // Gaussian fluctuation
1804  if(meanLoss > kappa*tmax || tmax < kappa*ipotFluct )
1805  {
1806    siga = tmax * (1.0-0.5*beta2) * step * twopi_mc2_rcl2
1807         * electronDensity / beta2 ;
1808
1809    // High velocity or negatively charged particle
1810    if( beta2 > 3.0*theBohrBeta2*zeff || charge < 0.0) {
1811      siga = std::sqrt( siga * chargeSquare ) ;
1812
1813    // Low velocity - additional ion charge fluctuations according to
1814    // Q.Yang et al., NIM B61(1991)149-155.
1815    } else {
1816      G4double chu = theIonChuFluctuationModel->TheValue(particle, material);
1817      G4double yang = theIonYangFluctuationModel->TheValue(particle, material);
1818      siga = std::sqrt( siga * (chargeSquare * chu + yang)) ;
1819    }
1820
1821    do {
1822        loss = G4RandGauss::shoot(meanLoss,siga);
1823    } while (loss < 0. || loss > 2.0*meanLoss);
1824    return loss;
1825  }
1826
1827  // Non Gaussian fluctuation
1828  static const G4double probLim = 0.01 ;
1829  static const G4double sumaLim = -std::log(probLim) ;
1830  static const G4double alim = 10.;
1831
1832  G4double suma,w1,w2,C,e0,lossc,w;
1833  G4double a1,a2,a3;
1834  G4int p1,p2,p3;
1835  G4int nb;
1836  G4double corrfac, na,alfa,rfac,namean,sa,alfa1,ea,sea;
1837  G4double dp3;
1838
1839  G4double f1Fluct     = material->GetIonisation()->GetF1fluct();
1840  G4double f2Fluct     = material->GetIonisation()->GetF2fluct();
1841  G4double e1Fluct     = material->GetIonisation()->GetEnergy1fluct();
1842  G4double e2Fluct     = material->GetIonisation()->GetEnergy2fluct();
1843  G4double e1LogFluct  = material->GetIonisation()->GetLogEnergy1fluct();
1844  G4double e2LogFluct  = material->GetIonisation()->GetLogEnergy2fluct();
1845  G4double rateFluct   = material->GetIonisation()->GetRateionexcfluct();
1846  G4double ipotLogFluct= material->GetIonisation()->GetLogMeanExcEnergy();
1847
1848  w1 = tmax/ipotFluct;
1849  w2 = std::log(2.*electron_mass_c2*tau2);
1850
1851  C = meanLoss*(1.-rateFluct)/(w2-ipotLogFluct-beta2);
1852
1853  a1 = C*f1Fluct*(w2-e1LogFluct-beta2)/e1Fluct;
1854  a2 = C*f2Fluct*(w2-e2LogFluct-beta2)/e2Fluct;
1855  a3 = rateFluct*meanLoss*(tmax-ipotFluct)/(ipotFluct*tmax*std::log(w1));
1856  if(a1 < 0.0) a1 = 0.0;
1857  if(a2 < 0.0) a2 = 0.0;
1858  if(a3 < 0.0) a3 = 0.0;
1859
1860  suma = a1+a2+a3;
1861
1862  loss = 0.;
1863
1864
1865  if(suma < sumaLim)             // very small Step
1866    {
1867      e0 = material->GetIonisation()->GetEnergy0fluct();
1868
1869      if(tmax == ipotFluct)
1870      {
1871        a3 = meanLoss/e0;
1872
1873        if(a3>alim)
1874        {
1875          siga=std::sqrt(a3) ;
1876          p3 = std::max(0,G4int(G4RandGauss::shoot(a3,siga)+0.5));
1877        }
1878        else
1879          p3 = G4Poisson(a3);
1880
1881        loss = p3*e0 ;
1882
1883        if(p3 > 0)
1884          loss += (1.-2.*G4UniformRand())*e0 ;
1885
1886      }
1887      else
1888      {
1889        tmax = tmax-ipotFluct+e0 ;
1890        a3 = meanLoss*(tmax-e0)/(tmax*e0*std::log(tmax/e0));
1891
1892        if(a3>alim)
1893        {
1894          siga=std::sqrt(a3) ;
1895          p3 = std::max(0,int(G4RandGauss::shoot(a3,siga)+0.5));
1896        }
1897        else
1898          p3 = G4Poisson(a3);
1899
1900        if(p3 > 0)
1901        {
1902          w = (tmax-e0)/tmax ;
1903          if(p3 > nmaxCont2)
1904          {
1905            dp3 = G4float(p3) ;
1906            corrfac = dp3/G4float(nmaxCont2) ;
1907            p3 = nmaxCont2 ;
1908          }
1909          else
1910            corrfac = 1. ;
1911
1912          for(G4int i=0; i<p3; i++) loss += 1./(1.-w*G4UniformRand()) ;
1913          loss *= e0*corrfac ;
1914        }
1915      }
1916    }
1917
1918  else                              // not so small Step
1919    {
1920      // excitation type 1
1921      if(a1>alim)
1922      {
1923        siga=std::sqrt(a1) ;
1924        p1 = std::max(0,G4int(G4RandGauss::shoot(a1,siga)+0.5));
1925      }
1926      else
1927       p1 = G4Poisson(a1);
1928
1929      // excitation type 2
1930      if(a2>alim)
1931      {
1932        siga=std::sqrt(a2) ;
1933        p2 = std::max(0,G4int(G4RandGauss::shoot(a2,siga)+0.5));
1934      }
1935      else
1936        p2 = G4Poisson(a2);
1937
1938      loss = p1*e1Fluct+p2*e2Fluct;
1939
1940      // smearing to avoid unphysical peaks
1941      if(p2 > 0)
1942        loss += (1.-2.*G4UniformRand())*e2Fluct;
1943      else if (loss>0.)
1944        loss += (1.-2.*G4UniformRand())*e1Fluct;
1945
1946      // ionisation .......................................
1947     if(a3 > 0.)
1948     {
1949      if(a3>alim)
1950      {
1951        siga=std::sqrt(a3) ;
1952        p3 = std::max(0,G4int(G4RandGauss::shoot(a3,siga)+0.5));
1953      }
1954      else
1955        p3 = G4Poisson(a3);
1956
1957      lossc = 0.;
1958      if(p3 > 0)
1959      {
1960        na = 0.;
1961        alfa = 1.;
1962        if (p3 > nmaxCont2)
1963        {
1964          dp3        = G4float(p3);
1965          rfac       = dp3/(G4float(nmaxCont2)+dp3);
1966          namean     = G4float(p3)*rfac;
1967          sa         = G4float(nmaxCont1)*rfac;
1968          na         = G4RandGauss::shoot(namean,sa);
1969          if (na > 0.)
1970          {
1971            alfa   = w1*G4float(nmaxCont2+p3)/
1972                    (w1*G4float(nmaxCont2)+G4float(p3));
1973            alfa1  = alfa*std::log(alfa)/(alfa-1.);
1974            ea     = na*ipotFluct*alfa1;
1975            sea    = ipotFluct*std::sqrt(na*(alfa-alfa1*alfa1));
1976            lossc += G4RandGauss::shoot(ea,sea);
1977          }
1978        }
1979
1980        nb = G4int(G4float(p3)-na);
1981        if (nb > 0)
1982        {
1983          w2 = alfa*ipotFluct;
1984          w  = (tmax-w2)/tmax;
1985          for (G4int k=0; k<nb; k++) lossc += w2/(1.-w*G4UniformRand());
1986        }
1987      }
1988      loss += lossc;
1989     }
1990    }
1991
1992  return loss ;
1993}
1994
1995//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1996
1997void G4hLowEnergyIonisation::SetCutForSecondaryPhotons(G4double cut)
1998{
1999  minGammaEnergy = cut;
2000}
2001
2002//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
2003
2004void G4hLowEnergyIonisation::SetCutForAugerElectrons(G4double cut)
2005{
2006  minElectronEnergy = cut;
2007}
2008
2009//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
2010
2011void G4hLowEnergyIonisation::ActivateAugerElectronProduction(G4bool val)
2012{
2013  deexcitationManager.ActivateAugerElectronProduction(val);
2014}
2015
2016//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
2017
2018void G4hLowEnergyIonisation::PrintInfoDefinition() const
2019{
2020  G4String comments = "  Knock-on electron cross sections . ";
2021  comments += "\n        Good description above the mean excitation energy.\n";
2022  comments += "        Delta ray energy sampled from  differential Xsection.";
2023
2024  G4cout << G4endl << GetProcessName() << ":  " << comments
2025         << "\n        PhysicsTables from " << LowestKineticEnergy / eV << " eV "
2026         << " to " << HighestKineticEnergy / TeV << " TeV "
2027         << " in " << TotBin << " bins."
2028 << "\n        Electronic stopping power model is  "
2029 << theProtonTable
2030         << "\n        from " << protonLowEnergy / keV << " keV "
2031         << " to " << protonHighEnergy / MeV << " MeV " << "." << G4endl ;
2032  G4cout << "\n        Parametrisation model for antiprotons is  "
2033         << theAntiProtonTable
2034         << "\n        from " << antiProtonLowEnergy / keV << " keV "
2035         << " to " << antiProtonHighEnergy / MeV << " MeV " << "." << G4endl ;
2036  if(theBarkas){
2037  G4cout << "        Parametrization of the Barkas effect is switched on."
2038         << G4endl ;
2039  }
2040  if(nStopping) {
2041  G4cout << "        Nuclear stopping power model is " << theNuclearTable
2042         << G4endl ;
2043  }
2044
2045  G4bool printHead = true;
2046
2047  const G4ProductionCutsTable* theCoupleTable=
2048        G4ProductionCutsTable::GetProductionCutsTable();
2049  size_t numOfCouples = theCoupleTable->GetTableSize();
2050
2051  // loop for materials
2052
2053  for (size_t j=0 ; j < numOfCouples; j++) {
2054
2055    const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(j);
2056    const G4Material* material= couple->GetMaterial();
2057    G4double deltaCutNow = cutForDelta[(couple->GetIndex())] ;
2058    G4double eexc = material->GetIonisation()->GetMeanExcitationEnergy();
2059
2060    if(eexc > deltaCutNow) {
2061      if(printHead) {
2062        printHead = false ;
2063
2064        G4cout << "           material       min.delta energy(keV) " << G4endl;
2065        G4cout << G4endl;
2066      }
2067
2068      G4cout << std::setw(20) << material->GetName()
2069             << std::setw(15) << eexc/keV << G4endl;
2070    }
2071  }
2072}
Note: See TracBrowser for help on using the repository browser.