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.5)


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