Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/lowenergy/src/G4UAtomicDeexcitation.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/lowenergy/src/G4UAtomicDeexcitation.cc (Version 11.3.0) and /processes/electromagnetic/lowenergy/src/G4UAtomicDeexcitation.cc (Version 10.1.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                            *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: G4UAtomicDeexcitation.cc,v 1.11 
 26 //                                                 27 //
 27 // -------------------------------------------     28 // -------------------------------------------------------------------
 28 //                                                 29 //
 29 // Geant4 Class file                               30 // Geant4 Class file
 30 //                                                 31 //  
 31 // Authors: Alfonso Mantero (Alfonso.Mantero@g     32 // Authors: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
 32 //                                                 33 //
 33 // Created 22 April 2010 from old G4UAtomicDee     34 // Created 22 April 2010 from old G4UAtomicDeexcitation class 
 34 //                                                 35 //
 35 // Modified:                                       36 // Modified:
 36 // ---------                                       37 // ---------
 37 // 20 Oct 2011  Alf  modified to take into acc     38 // 20 Oct 2011  Alf  modified to take into account ECPSSR form Form Factor
 38 // 03 Nov 2011  Alf  Extended Empirical and Fo     39 // 03 Nov 2011  Alf  Extended Empirical and Form Factor ionisation XS models
 39 //                   out thei ranges with Anal     40 //                   out thei ranges with Analytical one.
 40 // 07 Nov 2011  Alf  Restored original ioniati     41 // 07 Nov 2011  Alf  Restored original ioniation XS for alphas, 
 41 //                   letting scaled ones for o     42 //                   letting scaled ones for other ions.   
 42 // 20 Mar 2012  LP   Register G4PenelopeIonisa     43 // 20 Mar 2012  LP   Register G4PenelopeIonisationCrossSection
 43 //                                                 44 //
 44 // -------------------------------------------     45 // -------------------------------------------------------------------
 45 //                                                 46 //
 46 // Class description:                              47 // Class description:
 47 // Implementation of atomic deexcitation           48 // Implementation of atomic deexcitation 
 48 //                                                 49 //
 49 // -------------------------------------------     50 // -------------------------------------------------------------------
 50                                                    51 
 51 #include "G4UAtomicDeexcitation.hh"                52 #include "G4UAtomicDeexcitation.hh"
 52 #include "G4PhysicalConstants.hh"                  53 #include "G4PhysicalConstants.hh"
 53 #include "G4SystemOfUnits.hh"                      54 #include "G4SystemOfUnits.hh"
 54 #include "Randomize.hh"                            55 #include "Randomize.hh"
 55 #include "G4Gamma.hh"                              56 #include "G4Gamma.hh"
 56 #include "G4AtomicTransitionManager.hh"            57 #include "G4AtomicTransitionManager.hh"
 57 #include "G4FluoTransition.hh"                     58 #include "G4FluoTransition.hh"
 58 #include "G4Electron.hh"                           59 #include "G4Electron.hh"
 59 #include "G4Positron.hh"                           60 #include "G4Positron.hh"
 60 #include "G4Proton.hh"                             61 #include "G4Proton.hh"
 61 #include "G4Alpha.hh"                              62 #include "G4Alpha.hh"
 62                                                    63 
 63 #include "G4teoCrossSection.hh"                    64 #include "G4teoCrossSection.hh"
 64 #include "G4empCrossSection.hh"                    65 #include "G4empCrossSection.hh"
 65 #include "G4PenelopeIonisationCrossSection.hh"     66 #include "G4PenelopeIonisationCrossSection.hh"
 66 #include "G4LivermoreIonisationCrossSection.hh     67 #include "G4LivermoreIonisationCrossSection.hh"
 67 #include "G4EmCorrections.hh"                      68 #include "G4EmCorrections.hh"
 68 #include "G4LossTableManager.hh"                   69 #include "G4LossTableManager.hh"
 69 #include "G4EmParameters.hh"                   << 
 70 #include "G4Material.hh"                           70 #include "G4Material.hh"
 71 #include "G4AtomicShells.hh"                       71 #include "G4AtomicShells.hh"
 72                                                    72 
 73 using namespace std;                               73 using namespace std;
 74                                                    74 
 75 //....oooOO0OOooo........oooOO0OOooo........oo << 
 76                                                << 
 77 G4UAtomicDeexcitation::G4UAtomicDeexcitation()     75 G4UAtomicDeexcitation::G4UAtomicDeexcitation():
 78   G4VAtomDeexcitation("UAtomDeexcitation"),        76   G4VAtomDeexcitation("UAtomDeexcitation"),
 79   minGammaEnergy(DBL_MAX),                         77   minGammaEnergy(DBL_MAX), 
 80   minElectronEnergy(DBL_MAX),                      78   minElectronEnergy(DBL_MAX),
 81   newShellId(-1)                               <<  79   emcorr(0)
 82 {                                                  80 {
 83   anaPIXEshellCS = nullptr;                    <<  81   PIXEshellCS    = 0;
 84   PIXEshellCS    = nullptr;                    <<  82   ePIXEshellCS   = 0;
 85   ePIXEshellCS   = nullptr;                    << 
 86   emcorr = G4LossTableManager::Instance()->EmC     83   emcorr = G4LossTableManager::Instance()->EmCorrections();
 87   theElectron = G4Electron::Electron();            84   theElectron = G4Electron::Electron();
 88   thePositron = G4Positron::Positron();            85   thePositron = G4Positron::Positron();
 89   transitionManager = G4AtomicTransitionManage     86   transitionManager = G4AtomicTransitionManager::Instance();
                                                   >>  87   anaPIXEshellCS = 0;
 90 }                                                  88 }
 91                                                    89 
 92 //....oooOO0OOooo........oooOO0OOooo........oo << 
 93                                                << 
 94 G4UAtomicDeexcitation::~G4UAtomicDeexcitation(     90 G4UAtomicDeexcitation::~G4UAtomicDeexcitation()
 95 {                                                  91 {
 96   delete anaPIXEshellCS;                       << 
 97   delete PIXEshellCS;                              92   delete PIXEshellCS;
                                                   >>  93   delete anaPIXEshellCS;
 98   delete ePIXEshellCS;                             94   delete ePIXEshellCS;
 99 }                                                  95 }
100                                                    96 
101 //....oooOO0OOooo........oooOO0OOooo........oo << 
102                                                << 
103 void G4UAtomicDeexcitation::InitialiseForNewRu     97 void G4UAtomicDeexcitation::InitialiseForNewRun()
104 {                                                  98 {
105   if(!IsFluoActive()) { return; }                  99   if(!IsFluoActive()) { return; }
106   transitionManager->Initialise();                100   transitionManager->Initialise();
107   if(!IsPIXEActive()) { return; }              << 101   if(IsPIXEActive()) {
108                                                << 102     G4cout << G4endl;
109   if(!anaPIXEshellCS) {                        << 103     G4cout << "### === G4UAtomicDeexcitation::InitialiseForNewRun()" << G4endl;
110     anaPIXEshellCS = new G4teoCrossSection("EC << 104     anaPIXEshellCS = new G4teoCrossSection("Analytical");
                                                   >> 105  
111   }                                               106   }
112   G4cout << G4endl;                            << 107   else  {return;}
113   G4cout << "### === G4UAtomicDeexcitation::In << 108   // initializing PIXE x-section name
114                                                << 109   // 
115   G4EmParameters* param = G4EmParameters::Inst << 110   if (PIXECrossSectionModel() == "" ||
116   G4String namePIXExsModel = param->PIXECrossS << 111       PIXECrossSectionModel() == "Empirical" ||
117   G4String namePIXExsElectronModel = param->PI << 112       PIXECrossSectionModel() == "empirical") 
118                                                << 113     {
119   // Check if old cross section for p/ion shou << 114       SetPIXECrossSectionModel("Empirical");
120   if(PIXEshellCS && namePIXExsModel != PIXEshe << 115     }
                                                   >> 116   else if (PIXECrossSectionModel() == "ECPSSR_Analytical" ||
                                                   >> 117      PIXECrossSectionModel() == "Analytical" || 
                                                   >> 118      PIXECrossSectionModel() == "analytical") 
                                                   >> 119     {
                                                   >> 120       SetPIXECrossSectionModel("Analytical");
                                                   >> 121     }
                                                   >> 122   else if (PIXECrossSectionModel() == "ECPSSR_FormFactor" ||
                                                   >> 123      PIXECrossSectionModel() == "ECPSSR_Tabulated" ||
                                                   >> 124      PIXECrossSectionModel() == "Analytical_Tabulated") 
121     {                                             125     {
122       delete PIXEshellCS;                      << 126       SetPIXECrossSectionModel("ECPSSR_FormFactor");
123       PIXEshellCS = nullptr;                   << 127     }
                                                   >> 128   else 
                                                   >> 129     {
                                                   >> 130       G4cout << "### G4UAtomicDeexcitation::InitialiseForNewRun WARNING "
                                                   >> 131        << G4endl;
                                                   >> 132       G4cout << "    PIXE cross section name " << PIXECrossSectionModel()
                                                   >> 133        << " is unknown, Analytical cross section will be used" << G4endl; 
                                                   >> 134       SetPIXECrossSectionModel("Analytical");
                                                   >> 135     }
                                                   >> 136     
                                                   >> 137   // Check if old model should be deleted 
                                                   >> 138   if(PIXEshellCS) 
                                                   >> 139     {
                                                   >> 140       if(PIXECrossSectionModel() != PIXEshellCS->GetName()) 
                                                   >> 141   {
                                                   >> 142     delete PIXEshellCS;
                                                   >> 143           PIXEshellCS = 0;
                                                   >> 144   }
124     }                                             145     }
125                                                   146 
126   // Instantiate new proton/ion cross section  << 147   // Instantiate empirical model
127   if(!PIXEshellCS) {                              148   if(!PIXEshellCS) {
128     if (namePIXExsModel == "ECPSSR_FormFactor" << 149     if (PIXECrossSectionModel() == "Empirical")
129       {                                           150       {
130   PIXEshellCS = new G4teoCrossSection(namePIXE << 151   PIXEshellCS = new G4empCrossSection("Empirical");
131       }                                           152       }
132     else if(namePIXExsModel == "ECPSSR_ANSTO") << 153 
133       {                                        << 154     if (PIXECrossSectionModel() == "ECPSSR_FormFactor")
134   PIXEshellCS = new G4teoCrossSection(namePIXE << 
135       }                                        << 
136     else if(namePIXExsModel == "Empirical")    << 
137       {                                           155       {
138   PIXEshellCS = new G4empCrossSection(namePIXE << 156   PIXEshellCS = new G4teoCrossSection("ECPSSR_FormFactor");
139       }                                           157       }
140   }                                               158   }
141                                                   159 
142   // Check if old cross section for e+- should << 160   // Electron cross section
143   if(ePIXEshellCS && namePIXExsElectronModel ! << 161   // initializing PIXE x-section name
                                                   >> 162   // 
                                                   >> 163   if (PIXEElectronCrossSectionModel() == "" ||
                                                   >> 164       PIXEElectronCrossSectionModel() == "Livermore")
144     {                                             165     {
145       delete ePIXEshellCS;                     << 166       SetPIXEElectronCrossSectionModel("Livermore");
146       ePIXEshellCS = nullptr;                  << 167     }
147     }                                          << 168   else if (PIXEElectronCrossSectionModel() == "ProtonAnalytical" ||
                                                   >> 169      PIXEElectronCrossSectionModel() == "Analytical" || 
                                                   >> 170      PIXEElectronCrossSectionModel() == "analytical") 
                                                   >> 171     {
                                                   >> 172       SetPIXEElectronCrossSectionModel("ProtonAnalytical");
                                                   >> 173     }
                                                   >> 174   else if (PIXEElectronCrossSectionModel() == "ProtonEmpirical" ||
                                                   >> 175      PIXEElectronCrossSectionModel() == "Empirical" || 
                                                   >> 176      PIXEElectronCrossSectionModel() == "empirical") 
                                                   >> 177     {
                                                   >> 178       SetPIXEElectronCrossSectionModel("ProtonEmpirical");
                                                   >> 179     }
                                                   >> 180   else if (PIXEElectronCrossSectionModel() == "Penelope")
                                                   >> 181     SetPIXEElectronCrossSectionModel("Penelope");
                                                   >> 182   else 
                                                   >> 183     {
                                                   >> 184       G4cout << "### G4UAtomicDeexcitation::InitialiseForNewRun WARNING "
                                                   >> 185        << G4endl;
                                                   >> 186       G4cout << "    PIXE e- cross section name " << PIXEElectronCrossSectionModel()
                                                   >> 187        << " is unknown, PIXE is disabled" << G4endl; 
                                                   >> 188       SetPIXEElectronCrossSectionModel("Livermore");
                                                   >> 189     }
                                                   >> 190     
                                                   >> 191   // Check if old model should be deleted 
                                                   >> 192   if(ePIXEshellCS) 
                                                   >> 193     {
                                                   >> 194       if(PIXEElectronCrossSectionModel() != ePIXEshellCS->GetName()) 
                                                   >> 195   {
                                                   >> 196     delete ePIXEshellCS;
                                                   >> 197           ePIXEshellCS = 0;
                                                   >> 198   }
                                                   >> 199     }
148                                                   200 
149   // Instantiate new e+- cross section         << 201   // Instantiate empirical model
150   if(nullptr == ePIXEshellCS)                  << 202   if(!ePIXEshellCS) 
151     {                                             203     {
152       if(namePIXExsElectronModel == "Empirical << 204       if(PIXEElectronCrossSectionModel() == "Empirical")
153   {                                               205   {
154     ePIXEshellCS = new G4empCrossSection("Empi    206     ePIXEshellCS = new G4empCrossSection("Empirical");
155   }                                               207   }
156       else if(namePIXExsElectronModel == "ECPS << 208 
                                                   >> 209       else if(PIXEElectronCrossSectionModel() == "Analytical") 
157   {                                               210   {
158     ePIXEshellCS = new G4teoCrossSection("ECPS << 211     ePIXEshellCS = new G4teoCrossSection("Analytical");
159   }                                               212   }
160       else if (namePIXExsElectronModel == "Pen << 213 
                                                   >> 214       else if(PIXEElectronCrossSectionModel() == "Livermore")
161   {                                               215   {
162     ePIXEshellCS = new G4PenelopeIonisationCro << 216     ePIXEshellCS = new G4LivermoreIonisationCrossSection();
163   }                                               217   }
164       else                                     << 218       else if (PIXEElectronCrossSectionModel() == "Penelope")
165   {                                               219   {
166     ePIXEshellCS = new G4LivermoreIonisationCr << 220     ePIXEshellCS = new G4PenelopeIonisationCrossSection();
167   }                                               221   }
168     }                                             222     } 
169 }                                                 223 }
170                                                   224 
171 //....oooOO0OOooo........oooOO0OOooo........oo << 225 void G4UAtomicDeexcitation::InitialiseForExtraAtom(G4int /*Z*/)
172                                                << 
173 void G4UAtomicDeexcitation::InitialiseForExtra << 
174 {}                                                226 {}
175                                                   227 
176 //....oooOO0OOooo........oooOO0OOooo........oo << 
177                                                << 
178 const G4AtomicShell*                              228 const G4AtomicShell* 
179 G4UAtomicDeexcitation::GetAtomicShell(G4int Z,    229 G4UAtomicDeexcitation::GetAtomicShell(G4int Z, G4AtomicShellEnumerator shell)
180 {                                                 230 {
181   return transitionManager->Shell(Z, (std::siz << 231   return transitionManager->Shell(Z, size_t(shell));
182 }                                                 232 }
183                                                   233 
184 //....oooOO0OOooo........oooOO0OOooo........oo << 
185                                                << 
186 void G4UAtomicDeexcitation::GenerateParticles(    234 void G4UAtomicDeexcitation::GenerateParticles(
187                 std::vector<G4DynamicParticle* << 235           std::vector<G4DynamicParticle*>* vectorOfParticles,  
188           const G4AtomicShell* atomicShell,    << 236           const G4AtomicShell* atomicShell, 
189           G4int Z,                             << 237           G4int Z,
190           G4double gammaCut,                   << 238           G4double gammaCut,
191           G4double eCut)                       << 239           G4double eCut)
192 {                                                 240 {
                                                   >> 241 
193   // Defined initial conditions                   242   // Defined initial conditions
194   G4int givenShellId = atomicShell->ShellId();    243   G4int givenShellId = atomicShell->ShellId();
                                                   >> 244   //G4cout << "generating particles for vacancy in shellId: " 
                                                   >> 245   // << givenShellId << G4endl; // debug
195   minGammaEnergy = gammaCut;                      246   minGammaEnergy = gammaCut;
196   minElectronEnergy = eCut;                       247   minElectronEnergy = eCut;
197   vacancyArray.clear();                        << 248 
198                                                << 249   // V.I. short-cut
                                                   >> 250   //  if(!IsAugerActive()) {  minElectronEnergy = DBL_MAX; }
                                                   >> 251 
199   // generation secondaries                       252   // generation secondaries
200   G4DynamicParticle* aParticle=0;                 253   G4DynamicParticle* aParticle=0;
201   G4int provShellId = 0;                          254   G4int provShellId = 0;
                                                   >> 255   G4int counter = 0;
202                                                   256   
203   //ORIGINAL METHOD BY ALFONSO MANTERO         << 257   // let's check that 5<Z<100
204   if (!IsAugerCascadeActive())                 << 258 
205     {                                          << 259   if (Z>5 && Z<100) {
206       //----------------------------           << 
207       G4int counter = 0;                       << 
208                                                << 
209       // limits of the EPDL data               << 
210       if (Z>5 && Z<105) {                      << 
211                                                   260 
212   // The aim of this loop is to generate more  << 261   // The aim of this loop is to generate more than one fluorecence photon 
213   // from the same ionizing event              << 262   // from the same ionizing event 
214   do                                           << 263     do
                                                   >> 264       {
                                                   >> 265   if (counter == 0) 
                                                   >> 266     // First call to GenerateParticles(...):
                                                   >> 267     // givenShellId is given by the process
215     {                                             268     {
216       if (counter == 0)                        << 269       provShellId = SelectTypeOfTransition(Z, givenShellId);
217         // First call to GenerateParticles(... << 270 
218         // givenShellId is given by the proces << 271       if  ( provShellId >0) 
219         {                                         272         {
220     provShellId = SelectTypeOfTransition(Z, gi << 273     aParticle = GenerateFluorescence(Z,givenShellId,provShellId);
221                                                << 274     //if (aParticle != 0) { 
222     if (provShellId >0)                        << 275     // G4cout << "****FLUO!_1**** " 
223       {                                        << 276                 // << aParticle->GetParticleDefinition()->GetParticleType() 
224         aParticle =                            << 277                 // << " " << aParticle->GetKineticEnergy()/keV << G4endl ;}
225           GenerateFluorescence(Z, givenShellId << 
226       }                                        << 
227     else if (provShellId == -1)                << 
228       {                                        << 
229         aParticle = GenerateAuger(Z, givenShel << 
230       }                                        << 
231         }                                         278         }
232       else                                     << 279       else if ( provShellId == -1)
233         // Following calls to GenerateParticle << 
234         // newShellId is given by GenerateFluo << 
235         {                                         280         {
236     provShellId = SelectTypeOfTransition(Z,new << 281     // G4cout << "Try to generate Auger 1" << G4endl; 
237     if (provShellId >0)                        << 282     aParticle = GenerateAuger(Z, givenShellId);
238       {                                        << 283     // if (aParticle != 0) { G4cout << "****AUGER!****" << G4endl;} 
239         aParticle = GenerateFluorescence(Z,new << 
240       }                                        << 
241     else if ( provShellId == -1)               << 
242       {                                        << 
243         aParticle = GenerateAuger(Z, newShellI << 
244       }                                        << 
245         }                                         284         }
246       ++counter;                               << 285       else
247       if (aParticle != 0)                      << 
248         {                                         286         {
249     vectorOfParticles->push_back(aParticle);   << 287     G4Exception("G4UAtomicDeexcitation::GenerateParticles()",
                                                   >> 288           "de0002",JustWarning, "Energy deposited locally");
250         }                                         289         }
251       else {provShellId = -2;}                 << 290     }
252     }                                          << 291   else 
253   while (provShellId > -2);                    << 292     // Following calls to GenerateParticles(...):
254       }                                        << 293     // newShellId is given by GenerateFluorescence(...)
255     } // Auger cascade is not active           << 294     {
256                                                << 295       provShellId = SelectTypeOfTransition(Z,newShellId);
257   //END OF ORIGINAL METHOD BY ALFONSO MANTERO  << 296       if  (provShellId >0)
258   //----------------------                     << 297         {
259                                                << 298     aParticle = GenerateFluorescence(Z,newShellId,provShellId);
260   // NEW METHOD                                << 299     //if (aParticle != 0) { G4cout << "****FLUO!_2****" << aParticle->GetParticleDefinition()->GetParticleType() << " " << aParticle->GetKineticEnergy()/keV << G4endl;} //debug
261   // Auger cascade by Burkhant Suerfu on March << 300         }
262   if (IsAugerCascadeActive())                  << 301       else if ( provShellId == -1)
                                                   >> 302         {
                                                   >> 303     //    G4cout << "Try to generate Auger 2" << G4endl; //debug
                                                   >> 304     aParticle = GenerateAuger(Z, newShellId);
                                                   >> 305     //    if (aParticle != 0) { G4cout << "****AUGER!****" << G4endl;} //debug
                                                   >> 306         }
                                                   >> 307       else
                                                   >> 308         {
                                                   >> 309     G4Exception("G4UAtomicDeexcitation::GenerateParticles()","de0002",JustWarning, "Energy deposited locally");
                                                   >> 310         }
                                                   >> 311     }
                                                   >> 312   counter++;
                                                   >> 313   if (aParticle != 0) 
                                                   >> 314     {
                                                   >> 315       vectorOfParticles->push_back(aParticle);
                                                   >> 316       //G4cout << "Deexcitation Occurred!" << G4endl; //debug
                                                   >> 317     }
                                                   >> 318   else {provShellId = -2;}
                                                   >> 319       }  
                                                   >> 320     while (provShellId > -2); 
                                                   >> 321   }
                                                   >> 322   else
263     {                                             323     {
264       //----------------------                 << 324       G4Exception("G4UAtomicDeexcitation::GenerateParticles()","de0001",JustWarning, "Energy deposited locally");
265       vacancyArray.push_back(givenShellId);    << 325     }
266                                                << 326   
267       // let's check that 5<Z<100              << 327   //G4cout << "---------FATTO!---------" << G4endl; //debug 
268       if (Z<6 || Z>104){                       << 
269   return;                                      << 
270       }                                        << 
271                                                << 
272       // as long as there is vacancy to be fil << 
273       while(!vacancyArray.empty()){            << 
274   //  prepare to process the last element, and << 
275   givenShellId = vacancyArray[0];              << 
276   provShellId = SelectTypeOfTransition(Z,given << 
277                                                << 
278   //G4cout<<"\n------ Atom Transition with Z:  << 
279   //    <<givenShellId<<" & target:"<<provShel << 
280   if(provShellId>0){                           << 
281     aParticle = GenerateFluorescence(Z,givenSh << 
282   }                                            << 
283   else if(provShellId == -1){                  << 
284     aParticle = GenerateAuger(Z, givenShellId) << 
285   }                                            << 
286   //  if a particle is created, put it in the  << 
287   if(aParticle!=0)                             << 
288     vectorOfParticles->push_back(aParticle);   << 
289                                                << 
290   //  one vacancy has been processed. Erase it << 
291   vacancyArray.erase(vacancyArray.begin());    << 
292       }                                        << 
293       //----------------------                 << 
294       //End of Auger cascade by Burkhant Suerf << 
295                                                   328 
296     } // Auger cascade is active               << 
297 }                                                 329 }
298                                                   330 
299 //....oooOO0OOooo........oooOO0OOooo........oo << 
300                                                << 
301 G4double                                          331 G4double 
302 G4UAtomicDeexcitation::GetShellIonisationCross    332 G4UAtomicDeexcitation::GetShellIonisationCrossSectionPerAtom(
303            const G4ParticleDefinition* pdef,   << 333              const G4ParticleDefinition* pdef, 
304            G4int Z,                            << 334              G4int Z, 
305            G4AtomicShellEnumerator shellEnum,  << 335              G4AtomicShellEnumerator shellEnum,
306            G4double kineticEnergy,             << 336              G4double kineticEnergy,
307            const G4Material* mat)              << 337              const G4Material* mat)
308 {                                                 338 {
                                                   >> 339 
309   // we must put a control on the shell that a    340   // we must put a control on the shell that are passed: 
310   // some shells should not pass (line "0" or     341   // some shells should not pass (line "0" or "2")
311                                                   342 
312   // check atomic number                          343   // check atomic number
313   G4double xsec = 0.0;                            344   G4double xsec = 0.0;
314   if(Z > 93 || Z < 6 ) { return xsec; } //corr    345   if(Z > 93 || Z < 6 ) { return xsec; } //corrected by alf - Z<6 missing
315   G4int idx = G4int(shellEnum);                   346   G4int idx = G4int(shellEnum);
316   if(idx >= G4AtomicShells::GetNumberOfShells(    347   if(idx >= G4AtomicShells::GetNumberOfShells(Z)) { return xsec; }
317                                                   348 
                                                   >> 349   // 
318   if(pdef == theElectron || pdef == thePositro    350   if(pdef == theElectron || pdef == thePositron) {
319     xsec = ePIXEshellCS->CrossSection(Z,shellE    351     xsec = ePIXEshellCS->CrossSection(Z,shellEnum,kineticEnergy,0.0,mat);
320     return xsec;                                  352     return xsec;
321   }                                               353   }
322                                                   354 
323   G4double mass = pdef->GetPDGMass();             355   G4double mass = pdef->GetPDGMass();
324   G4double escaled = kineticEnergy;               356   G4double escaled = kineticEnergy;
325   G4double q2 = 0.0;                              357   G4double q2 = 0.0;
326                                                   358 
327   // scaling to protons for all particles excl << 359   // scaling to protons
328   G4int pdg = pdef->GetPDGEncoding();          << 360   if ((pdef->GetParticleName() != "proton" && pdef->GetParticleName() != "alpha" ) )
329   if (pdg != 2212 && pdg != 1000020040)        << 361   {
330     {                                          << 362     mass = proton_mass_c2;
331       mass = proton_mass_c2;                   << 363     escaled = kineticEnergy*mass/(pdef->GetPDGMass());
332       escaled = kineticEnergy*mass/(pdef->GetP << 364 
333                                                << 365     if(mat) {
334       if(mat) {                                << 366       q2 = emcorr->EffectiveChargeSquareRatio(pdef,mat,kineticEnergy);
335   q2 = emcorr->EffectiveChargeSquareRatio(pdef << 367     } else {
336       } else {                                 << 368       G4double q = pdef->GetPDGCharge()/eplus;
337   G4double q = pdef->GetPDGCharge()/eplus;     << 369       q2 = q*q;
338   q2 = q*q;                                    << 
339       }                                        << 
340     }                                             370     }
341                                                << 
342   if(PIXEshellCS) {                            << 
343     xsec = PIXEshellCS->CrossSection(Z,shellEn << 
344   }                                               371   }
345   if(xsec < 1e-100) {                          << 372   
                                                   >> 373   if(PIXEshellCS) { xsec = PIXEshellCS->CrossSection(Z,shellEnum,escaled,mass,mat); }
                                                   >> 374   if(xsec < 1e-100) { 
                                                   >> 375     
346     xsec = anaPIXEshellCS->CrossSection(Z,shel    376     xsec = anaPIXEshellCS->CrossSection(Z,shellEnum,escaled,mass,mat); 
                                                   >> 377     
347   }                                               378   }
348                                                   379 
349   if (q2)  {xsec *= q2;}                          380   if (q2)  {xsec *= q2;}
350                                                   381 
351   return xsec;                                    382   return xsec;
352 }                                                 383 }
353                                                   384 
354 //....oooOO0OOooo........oooOO0OOooo........oo << 
355                                                << 
356 void G4UAtomicDeexcitation::SetCutForSecondary    385 void G4UAtomicDeexcitation::SetCutForSecondaryPhotons(G4double cut)
357 {                                                 386 {
358   minGammaEnergy = cut;                           387   minGammaEnergy = cut;
359 }                                                 388 }
360                                                   389 
361 //....oooOO0OOooo........oooOO0OOooo........oo << 
362                                                << 
363 void G4UAtomicDeexcitation::SetCutForAugerElec    390 void G4UAtomicDeexcitation::SetCutForAugerElectrons(G4double cut)
364 {                                                 391 {
365   minElectronEnergy = cut;                        392   minElectronEnergy = cut;
366 }                                                 393 }
367                                                   394 
368 //....oooOO0OOooo........oooOO0OOooo........oo << 395 G4double 
369                                                << 396 G4UAtomicDeexcitation::ComputeShellIonisationCrossSectionPerAtom(
370 G4double G4UAtomicDeexcitation::ComputeShellIo << 397                                const G4ParticleDefinition* p, 
371         const G4ParticleDefinition* p,         << 398              G4int Z, 
372         G4int Z,                               << 399              G4AtomicShellEnumerator shell,
373         G4AtomicShellEnumerator shell,         << 400              G4double kinE,
374         G4double kinE,                         << 401              const G4Material* mat)
375         const G4Material* mat)                 << 
376 {                                                 402 {
377   return GetShellIonisationCrossSectionPerAtom    403   return GetShellIonisationCrossSectionPerAtom(p,Z,shell,kinE,mat);
378 }                                                 404 }
379                                                   405 
380 //....oooOO0OOooo........oooOO0OOooo........oo << 
381                                                << 
382 G4int G4UAtomicDeexcitation::SelectTypeOfTrans    406 G4int G4UAtomicDeexcitation::SelectTypeOfTransition(G4int Z, G4int shellId)
383 {                                                 407 {
384   if (shellId <=0 ) {                             408   if (shellId <=0 ) {
                                                   >> 409     G4Exception("G4UAtomicDeexcitation::SelecttypeOfTransition()","de0002",JustWarning, "Energy deposited locally");
385     return 0;                                     410     return 0;
386   }                                               411   }
                                                   >> 412   //G4bool fluoTransitionFoundFlag = false;
387                                                   413   
388   G4int provShellId = -1;                         414   G4int provShellId = -1;
389   G4int shellNum = 0;                             415   G4int shellNum = 0;
390   G4int maxNumOfShells = transitionManager->Nu    416   G4int maxNumOfShells = transitionManager->NumberOfReachableShells(Z);  
391                                                   417   
392   const G4FluoTransition* refShell =           << 418   const G4FluoTransition* refShell = transitionManager->ReachableShell(Z,maxNumOfShells-1);
393     transitionManager->ReachableShell(Z,maxNum << 
394                                                   419 
395   // This loop gives shellNum the value of the    420   // This loop gives shellNum the value of the index of shellId
396   // in the vector storing the list of the she    421   // in the vector storing the list of the shells reachable through
397   // a radiative transition                       422   // a radiative transition
398   if ( shellId <= refShell->FinalShellId())       423   if ( shellId <= refShell->FinalShellId())
399     {                                             424     {
400       while (shellId != transitionManager->Rea    425       while (shellId != transitionManager->ReachableShell(Z,shellNum)->FinalShellId())
401   {                                               426   {
402     if(shellNum ==maxNumOfShells-1)               427     if(shellNum ==maxNumOfShells-1)
403       {                                           428       {
404         break;                                    429         break;
405       }                                           430       }
406     shellNum++;                                   431     shellNum++;
407   }                                               432   }
408       G4int transProb = 0; //AM change 29/6/07    433       G4int transProb = 0; //AM change 29/6/07 was 1
409                                                   434    
410       G4double partialProb = G4UniformRand();     435       G4double partialProb = G4UniformRand();      
411       G4double partSum = 0;                       436       G4double partSum = 0;
412       const G4FluoTransition* aShell = transit << 437       const G4FluoTransition* aShell = transitionManager->ReachableShell(Z,shellNum);      
413       G4int trSize =  (G4int)(aShell->Transiti << 438       G4int trSize =  (aShell->TransitionProbabilities()).size();
414                                                   439     
415       // Loop over the shells wich can provide    440       // Loop over the shells wich can provide an electron for a 
416       // radiative transition towards shellId:    441       // radiative transition towards shellId:
417       // in every loop the partial sum of the     442       // in every loop the partial sum of the first transProb shells
418       // is calculated and compared with a ran    443       // is calculated and compared with a random number [0,1].
419       // If the partial sum is greater, the sh    444       // If the partial sum is greater, the shell whose index is transProb
420       // is chosen as the starting shell for a    445       // is chosen as the starting shell for a radiative transition
421       // and its identity is returned             446       // and its identity is returned
422       // Else, terminateded the loop, -1 is re    447       // Else, terminateded the loop, -1 is returned
423       while(transProb < trSize){                  448       while(transProb < trSize){
424   partSum += aShell->TransitionProbability(tra << 449   
                                                   >> 450    partSum += aShell->TransitionProbability(transProb);
425                                                   451 
426   if(partialProb <= partSum)                   << 452    if(partialProb <= partSum)
427     {                                          << 453      {
428       provShellId = aShell->OriginatingShellId << 454        provShellId = aShell->OriginatingShellId(transProb);
429       break;                                   << 455        //fluoTransitionFoundFlag = true;
430     }                                          << 456 
431   ++transProb;                                 << 457        break;
                                                   >> 458      }
                                                   >> 459    transProb++;
432       }                                           460       }
                                                   >> 461 
433       // here provShellId is the right one or     462       // here provShellId is the right one or is -1.
434       // if -1, the control is passed to the A    463       // if -1, the control is passed to the Auger generation part of the package 
435     }                                             464     }
436   else                                            465   else 
437     {                                             466     {
438       provShellId = -1;                           467       provShellId = -1;
439     }                                             468     }
                                                   >> 469   //G4cout << "FlagTransition= " << provShellId << " ecut(MeV)= " << minElectronEnergy
                                                   >> 470   //   << "  gcut(MeV)= " << minGammaEnergy << G4endl;
440   return provShellId;                             471   return provShellId;
441 }                                                 472 }
442                                                   473 
443 //....oooOO0OOooo........oooOO0OOooo........oo << 
444                                                << 
445 G4DynamicParticle*                                474 G4DynamicParticle* 
446 G4UAtomicDeexcitation::GenerateFluorescence(G4    475 G4UAtomicDeexcitation::GenerateFluorescence(G4int Z, G4int shellId,
447               G4int provShellId )                 476               G4int provShellId )
448 {                                                 477 { 
                                                   >> 478 
                                                   >> 479   //if(!IsDeexActive()) { return 0; }
                                                   >> 480 
449   if (shellId <=0 )                               481   if (shellId <=0 )
                                                   >> 482 
450     {                                             483     {
451       return nullptr;                          << 484       G4Exception("G4UAtomicDeexcitation::GenerateFluorescence()","de0002",JustWarning, "Energy deposited locally");
                                                   >> 485       return 0;
452     }                                             486     }
                                                   >> 487   
453                                                   488 
454   //isotropic angular distribution for the out    489   //isotropic angular distribution for the outcoming photon
455   G4double newcosTh = 1.-2.*G4UniformRand();      490   G4double newcosTh = 1.-2.*G4UniformRand();
456   G4double newsinTh = std::sqrt((1.-newcosTh)*    491   G4double newsinTh = std::sqrt((1.-newcosTh)*(1. + newcosTh));
457   G4double newPhi = twopi*G4UniformRand();        492   G4double newPhi = twopi*G4UniformRand();
458                                                   493   
459   G4double xDir = newsinTh*std::sin(newPhi);      494   G4double xDir = newsinTh*std::sin(newPhi);
460   G4double yDir = newsinTh*std::cos(newPhi);      495   G4double yDir = newsinTh*std::cos(newPhi);
461   G4double zDir = newcosTh;                       496   G4double zDir = newcosTh;
462                                                   497   
463   G4ThreeVector newGammaDirection(xDir,yDir,zD    498   G4ThreeVector newGammaDirection(xDir,yDir,zDir);
464                                                   499   
465   G4int shellNum = 0;                             500   G4int shellNum = 0;
466   G4int maxNumOfShells = transitionManager->Nu    501   G4int maxNumOfShells = transitionManager->NumberOfReachableShells(Z);
467                                                   502   
468   // find the index of the shell named shellId    503   // find the index of the shell named shellId
469   while (shellId != transitionManager->           504   while (shellId != transitionManager->
470    ReachableShell(Z,shellNum)->FinalShellId())    505    ReachableShell(Z,shellNum)->FinalShellId())
471     {                                             506     {
472       if(shellNum == maxNumOfShells-1)            507       if(shellNum == maxNumOfShells-1)
473   {                                               508   {
474     break;                                        509     break;
475   }                                               510   }
476       ++shellNum;                              << 511       shellNum++;
477     }                                             512     }
478   // number of shell from wich an electron can    513   // number of shell from wich an electron can reach shellId
479   G4int transitionSize = (G4int)transitionMana << 514   size_t transitionSize = transitionManager->
480     ReachableShell(Z,shellNum)->OriginatingShe    515     ReachableShell(Z,shellNum)->OriginatingShellIds().size();
481                                                   516   
482   G4int index = 0;                             << 517   size_t index = 0;
483                                                   518   
484   // find the index of the shell named provShe    519   // find the index of the shell named provShellId in the vector
485   // storing the shells from which shellId can    520   // storing the shells from which shellId can be reached 
486   while (provShellId != transitionManager->       521   while (provShellId != transitionManager->
487    ReachableShell(Z,shellNum)->OriginatingShel    522    ReachableShell(Z,shellNum)->OriginatingShellId(index))
488     {                                             523     {
489       if(index ==  transitionSize-1)              524       if(index ==  transitionSize-1)
490   {                                               525   {
491     break;                                        526     break;
492   }                                               527   }
493       ++index;                                 << 528       index++;
494     }                                             529     }
495   // energy of the gamma leaving provShellId f    530   // energy of the gamma leaving provShellId for shellId
496   G4double transitionEnergy = transitionManage    531   G4double transitionEnergy = transitionManager->
497     ReachableShell(Z,shellNum)->TransitionEner    532     ReachableShell(Z,shellNum)->TransitionEnergy(index);
498                                                   533   
499   if (transitionEnergy < minGammaEnergy) retur << 534   if (transitionEnergy < minGammaEnergy) return 0;
500                                                   535 
501   // This is the shell where the new vacancy i    536   // This is the shell where the new vacancy is: it is the same
502   // shell where the electron came from           537   // shell where the electron came from
503   newShellId = transitionManager->                538   newShellId = transitionManager->
504     ReachableShell(Z,shellNum)->OriginatingShe    539     ReachableShell(Z,shellNum)->OriginatingShellId(index);
505                                                << 540   
                                                   >> 541   
506   G4DynamicParticle* newPart = new G4DynamicPa    542   G4DynamicParticle* newPart = new G4DynamicParticle(G4Gamma::Gamma(), 
507                  newGammaDirection,               543                  newGammaDirection,
508                  transitionEnergy);               544                  transitionEnergy);
509                                                << 
510   //Auger cascade by Burkhant Suerfu on March  << 
511   if (IsAugerCascadeActive()) vacancyArray.pus << 
512                                                << 
513   return newPart;                                 545   return newPart;
514 }                                                 546 }
515                                                   547 
516 //....oooOO0OOooo........oooOO0OOooo........oo << 
517                                                << 
518 G4DynamicParticle* G4UAtomicDeexcitation::Gene    548 G4DynamicParticle* G4UAtomicDeexcitation::GenerateAuger(G4int Z, G4int shellId)
519 {                                                 549 {
520   if(!IsAugerActive()) {                          550   if(!IsAugerActive()) { 
521     //    G4cout << "auger inactive!" << G4end    551     //    G4cout << "auger inactive!" << G4endl; //debug
522     return nullptr;                            << 552     return 0; 
523   }                                               553   }
524                                                   554   
525   if (shellId <=0 ) {                             555   if (shellId <=0 ) {
526     //G4Exception("G4UAtomicDeexcitation::Gene << 556     
527     //    JustWarning, "Energy deposited local << 557 
528     return nullptr;                            << 558       G4Exception("G4UAtomicDeexcitation::GenerateAuger()","de0002",JustWarning, "Energy deposited locally");
                                                   >> 559 
                                                   >> 560       return 0;
                                                   >> 561     
529   }                                               562   }
530                                                   563 
                                                   >> 564   // G4int provShellId = -1;
531   G4int maxNumOfShells = transitionManager->Nu    565   G4int maxNumOfShells = transitionManager->NumberOfReachableAugerShells(Z);  
532                                                   566   
533   const G4AugerTransition* refAugerTransition     567   const G4AugerTransition* refAugerTransition = 
534     transitionManager->ReachableAugerShell(Z,m << 568         transitionManager->ReachableAugerShell(Z,maxNumOfShells-1);
535                                                   569 
536   // This loop gives to shellNum the value of     570   // This loop gives to shellNum the value of the index of shellId
537   // in the vector storing the list of the vac    571   // in the vector storing the list of the vacancies in the variuos shells 
538   // that can originate a NON-radiative transi    572   // that can originate a NON-radiative transition
                                                   >> 573   
539   G4int shellNum = 0;                             574   G4int shellNum = 0;
540                                                << 575 
541   if ( shellId <= refAugerTransition->FinalShe    576   if ( shellId <= refAugerTransition->FinalShellId() ) 
542     // "FinalShellId" is final from the point  << 577     //"FinalShellId" is final from the point of view of the elctron who makes the transition, 
543     // who makes the transition,               << 
544     // being the Id of the shell in which ther    578     // being the Id of the shell in which there is a vacancy
545     {                                             579     {
546       G4int pippo = transitionManager->Reachab    580       G4int pippo = transitionManager->ReachableAugerShell(Z,shellNum)->FinalShellId();
547       if (shellId != pippo ) {                 << 581       if (shellId  != pippo ) {
548   do {                                            582   do { 
549     ++shellNum;                                << 583     shellNum++;
550     if(shellNum == maxNumOfShells)                584     if(shellNum == maxNumOfShells)
551       {                                           585       {
552         // G4cout << "No Auger transition foun << 586         //        G4cout << "No Auger transition found" << G4endl; //debug
553         return 0;                                 587         return 0;
554       }                                           588       }
555   }                                               589   }
556   while (shellId != (transitionManager->Reacha << 590   while (shellId != (transitionManager->ReachableAugerShell(Z,shellNum)->FinalShellId()) ) ;
557       }                                           591       }
558                                                   592 
                                                   >> 593 
559       // Now we have that shellnum is the shel    594       // Now we have that shellnum is the shellIndex of the shell named ShellId
                                                   >> 595 
560       //      G4cout << " the index of the she    596       //      G4cout << " the index of the shell is: "<<shellNum<<G4endl;
                                                   >> 597 
561       // But we have now to select two shells:    598       // But we have now to select two shells: one for the transition, 
562       // and another for the auger emission.      599       // and another for the auger emission.
                                                   >> 600 
563       G4int transitionLoopShellIndex = 0;         601       G4int transitionLoopShellIndex = 0;      
564       G4double partSum = 0;                       602       G4double partSum = 0;
565       const G4AugerTransition* anAugerTransiti    603       const G4AugerTransition* anAugerTransition = 
566   transitionManager->ReachableAugerShell(Z,she << 604             transitionManager->ReachableAugerShell(Z,shellNum);
                                                   >> 605 
                                                   >> 606       //      G4cout << " corresponding to the ID: "<< anAugerTransition->FinalShellId() << G4endl;
567                                                   607 
568       G4int transitionSize = (G4int)           << 608 
569   (anAugerTransition->TransitionOriginatingShe << 609       G4int transitionSize = 
                                                   >> 610             (anAugerTransition->TransitionOriginatingShellIds())->size();
570       while (transitionLoopShellIndex < transi    611       while (transitionLoopShellIndex < transitionSize) {
571                                                   612 
572         std::vector<G4int>::const_iterator pos    613         std::vector<G4int>::const_iterator pos = 
573     anAugerTransition->TransitionOriginatingSh << 614                anAugerTransition->TransitionOriginatingShellIds()->begin();
574                                                   615 
575         G4int transitionLoopShellId = *(pos+tr    616         G4int transitionLoopShellId = *(pos+transitionLoopShellIndex);
576         G4int numberOfPossibleAuger = (G4int)  << 617         G4int numberOfPossibleAuger = 
577     (anAugerTransition->AugerTransitionProbabi << 618               (anAugerTransition->AugerTransitionProbabilities(transitionLoopShellId))->size();
578         G4int augerIndex = 0;                     619         G4int augerIndex = 0;
579                                                << 620         //      G4int partSum2 = 0;
                                                   >> 621 
                                                   >> 622 
580   if (augerIndex < numberOfPossibleAuger) {       623   if (augerIndex < numberOfPossibleAuger) {
                                                   >> 624     
581     do                                            625     do 
582       {                                           626       {
583         G4double thisProb = anAugerTransition-    627         G4double thisProb = anAugerTransition->AugerTransitionProbability(augerIndex, 
584                     transitionLoopShellId);       628                     transitionLoopShellId);
585         partSum += thisProb;                      629         partSum += thisProb;
586         augerIndex++;                             630         augerIndex++;
587                                                   631         
588       } while (augerIndex < numberOfPossibleAu    632       } while (augerIndex < numberOfPossibleAuger);
589         }                                      << 633     }
590         ++transitionLoopShellIndex;            << 634         transitionLoopShellIndex++;
591       }                                           635       }
592                                                << 636       
                                                   >> 637 
                                                   >> 638 
                                                   >> 639       // Now we have the entire probability of an auger transition for the vacancy 
                                                   >> 640       // located in shellNum (index of shellId) 
                                                   >> 641 
                                                   >> 642       // AM *********************** F I X E D **************************** AM
                                                   >> 643       // Here we duplicate the previous loop, this time looking to the sum of the probabilities 
                                                   >> 644       // to be under the random number shoot by G4 UniformRdandom. This could have been done in the 
                                                   >> 645       // previuos loop, while integrating the probabilities. There is a bug that will be fixed 
                                                   >> 646       // 5 minutes from now: a line:
                                                   >> 647       // G4int numberOfPossibleAuger = (anAugerTransition->
                                                   >> 648       // AugerTransitionProbabilities(transitionLoopShellId))->size();
                                                   >> 649       // to be inserted.
                                                   >> 650       // AM *********************** F I X E D **************************** AM
                                                   >> 651 
                                                   >> 652       // Remains to get the same result with a single loop.
                                                   >> 653 
                                                   >> 654       // AM *********************** F I X E D **************************** AM
                                                   >> 655       // Another Bug: in EADL Auger Transition are normalized to all the transitions deriving from 
                                                   >> 656       // a vacancy in one shell, but not all of these are present in data tables. So if a transition 
                                                   >> 657       // doesn't occur in the main one a local energy deposition must occur, instead of (like now) 
                                                   >> 658       // generating the last transition present in EADL data.
                                                   >> 659       // AM *********************** F I X E D **************************** AM
                                                   >> 660 
                                                   >> 661 
593       G4double totalVacancyAugerProbability =     662       G4double totalVacancyAugerProbability = partSum;
594                                                   663 
                                                   >> 664 
595       //And now we start to select the right a    665       //And now we start to select the right auger transition and emission
596       G4int transitionRandomShellIndex = 0;       666       G4int transitionRandomShellIndex = 0;
597       G4int transitionRandomShellId = 1;          667       G4int transitionRandomShellId = 1;
598       G4int augerIndex = 0;                       668       G4int augerIndex = 0;
599       partSum = 0;                                669       partSum = 0; 
600       G4double partialProb = G4UniformRand();     670       G4double partialProb = G4UniformRand();
                                                   >> 671       // G4int augerOriginatingShellId = 0;
                                                   >> 672       
                                                   >> 673       G4int numberOfPossibleAuger = 0;
601                                                   674       
602       G4int numberOfPossibleAuger = 0;         << 
603       G4bool foundFlag = false;                   675       G4bool foundFlag = false;
604                                                   676 
605       while (transitionRandomShellIndex < tran    677       while (transitionRandomShellIndex < transitionSize) {
606                                                   678 
607         std::vector<G4int>::const_iterator pos    679         std::vector<G4int>::const_iterator pos = 
608     anAugerTransition->TransitionOriginatingSh << 680                anAugerTransition->TransitionOriginatingShellIds()->begin();
609                                                   681 
610         transitionRandomShellId = *(pos+transi    682         transitionRandomShellId = *(pos+transitionRandomShellIndex);
611                                                   683         
612   augerIndex = 0;                                 684   augerIndex = 0;
613   numberOfPossibleAuger = (G4int)(anAugerTrans << 685   numberOfPossibleAuger = (anAugerTransition-> 
614          AugerTransitionProbabilities(transiti    686          AugerTransitionProbabilities(transitionRandomShellId))->size();
615                                                   687 
616         while (augerIndex < numberOfPossibleAu    688         while (augerIndex < numberOfPossibleAuger) {
617     G4double thisProb =anAugerTransition->Auge    689     G4double thisProb =anAugerTransition->AugerTransitionProbability(augerIndex, 
618                      transitionRandomShellId);    690                      transitionRandomShellId);
619                                                   691 
620           partSum += thisProb;                    692           partSum += thisProb;
621                                                   693           
622           if (partSum >= (partialProb*totalVac    694           if (partSum >= (partialProb*totalVacancyAugerProbability) ) { // was /
623       foundFlag = true;                           695       foundFlag = true;
624       break;                                      696       break;
625     }                                             697     }
626           augerIndex++;                           698           augerIndex++;
627         }                                         699         }
628         if (partSum >= (partialProb*totalVacan    700         if (partSum >= (partialProb*totalVacancyAugerProbability) ) {break;} // was /
629         ++transitionRandomShellIndex;          << 701         transitionRandomShellIndex++;
630       }                                           702       }
631                                                   703 
632       // Now we have the index of the shell fr    704       // Now we have the index of the shell from wich comes the auger electron (augerIndex), 
633       // and the id of the shell, from which t    705       // and the id of the shell, from which the transition e- come (transitionRandomShellid)
634       // If no Transition has been found, 0 is    706       // If no Transition has been found, 0 is returned.  
                                                   >> 707 
635       if (!foundFlag) {                           708       if (!foundFlag) {
636   return nullptr;                              << 709   //  G4cout << "Auger not found (foundflag = false) " << G4endl; //debug
637       }                                        << 710   return 0;
                                                   >> 711 
                                                   >> 712 } 
638                                                   713       
639       // Isotropic angular distribution for th    714       // Isotropic angular distribution for the outcoming e-
640       G4double newcosTh = 1.-2.*G4UniformRand(    715       G4double newcosTh = 1.-2.*G4UniformRand();
641       G4double newsinTh = std::sqrt(1.-newcosT << 716       G4double  newsinTh = std::sqrt(1.-newcosTh*newcosTh);
642       G4double newPhi = twopi*G4UniformRand();    717       G4double newPhi = twopi*G4UniformRand();
643                                                   718       
644       G4double xDir = newsinTh*std::sin(newPhi << 719       G4double xDir =  newsinTh*std::sin(newPhi);
645       G4double yDir = newsinTh*std::cos(newPhi    720       G4double yDir = newsinTh*std::cos(newPhi);
646       G4double zDir = newcosTh;                   721       G4double zDir = newcosTh;
647                                                   722       
648       G4ThreeVector newElectronDirection(xDir,    723       G4ThreeVector newElectronDirection(xDir,yDir,zDir);
649                                                   724       
650       // energy of the auger electron emitted  << 725       // energy of the auger electron emitted
651       G4double transitionEnergy =              << 726       
652   anAugerTransition->AugerTransitionEnergy(aug << 727       
                                                   >> 728       G4double transitionEnergy = anAugerTransition->AugerTransitionEnergy(augerIndex, transitionRandomShellId);
                                                   >> 729       /*
                                                   >> 730   G4cout << "AUger TransitionId " << anAugerTransition->FinalShellId() << G4endl;
                                                   >> 731   G4cout << "augerIndex: " << augerIndex << G4endl;
                                                   >> 732   G4cout << "transitionShellId: " << transitionRandomShellId << G4endl;
                                                   >> 733       */
653                                                   734       
654       if (transitionEnergy < minElectronEnergy    735       if (transitionEnergy < minElectronEnergy) {
655   return nullptr;                              << 736   // G4cout << "Problem!  (transitionEnergy < minElectronEnergy)" << G4endl; // debug
                                                   >> 737   // G4cout << "minElectronEnergy(KeV): " << minElectronEnergy/keV << G4endl; // debug
                                                   >> 738   // G4cout << "transitionEnergy(KeV): " << transitionEnergy/keV << G4endl; // debug
                                                   >> 739   return 0;
656       }                                           740       }
657                                                   741 
658       // This is the shell where the new vacan    742       // This is the shell where the new vacancy is: it is the same
659       // shell where the electron came from       743       // shell where the electron came from
660       newShellId = transitionRandomShellId;       744       newShellId = transitionRandomShellId;
661                                                   745       
662       //Auger cascade by Burkhant Suerfu on Ma << 
663       if (IsAugerCascadeActive())              << 
664   {                                            << 
665     vacancyArray.push_back(newShellId);        << 
666     vacancyArray.push_back(anAugerTransition-> << 
667   }                                            << 
668                                                << 
669       return new G4DynamicParticle(G4Electron:    746       return new G4DynamicParticle(G4Electron::Electron(), 
670            newElectronDirection,                  747            newElectronDirection,
671            transitionEnergy);                     748            transitionEnergy);
672     }                                             749     }
673   else                                            750   else 
674     {                                             751     {
675       return nullptr;                          << 752       //      G4cout << "G4UAtomicDeexcitation: no auger transition found" << G4endl ;
                                                   >> 753       //      G4cout << "( shellId <= refAugerTransition->FinalShellId() )" << G4endl;
                                                   >> 754       return 0;
676     }                                             755     }
677 }                                                 756 }
678                                                   757