Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/utils/src/G4EnergyLossTables.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/utils/src/G4EnergyLossTables.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4EnergyLossTables.cc (Version 9.0)


  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 // $Id: G4EnergyLossTables.cc,v 1.33 2006/06/29 19:55:09 gunter Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-00 $
 27 //                                                 29 //
 28 // -------------------------------------------     30 // -------------------------------------------------------------------
 29 // first version created by P.Urban , 06/04/19     31 // first version created by P.Urban , 06/04/1998
 30 // modifications + "precise" functions added b     32 // modifications + "precise" functions added by L.Urban , 27/05/98
 31 // modifications , TOF functions , 26/10/98, L     33 // modifications , TOF functions , 26/10/98, L.Urban
 32 // cache mechanism in order to gain time, 11/0     34 // cache mechanism in order to gain time, 11/02/99, L.Urban
 33 // bug fixed , 12/04/99 , L.Urban                  35 // bug fixed , 12/04/99 , L.Urban
 34 // 10.11.99: moved from RWT hash dictionary to     36 // 10.11.99: moved from RWT hash dictionary to STL map, G.Barrand, M.Maire
 35 // 27.09.01 L.Urban , bug fixed (negative ener     37 // 27.09.01 L.Urban , bug fixed (negative energy deposit)
 36 // 26.10.01 all static functions moved from .i     38 // 26.10.01 all static functions moved from .icc files (mma)
 37 // 15.01.03 Add interfaces required for "cut p     39 // 15.01.03 Add interfaces required for "cut per region" (V.Ivanchenko)
 38 // 12.03.03 Add warnings to obsolete interface     40 // 12.03.03 Add warnings to obsolete interfaces (V.Ivanchenko)
 39 // 10.04.03 Add call to G4LossTableManager is      41 // 10.04.03 Add call to G4LossTableManager is particle is not registered (V.Ivanchenko)
 40 //                                                 42 //
 41 // -------------------------------------------     43 // -------------------------------------------------------------------
 42                                                    44 
 43 #include "G4EnergyLossTables.hh"                   45 #include "G4EnergyLossTables.hh"
 44 #include "G4SystemOfUnits.hh"                  << 
 45 #include "G4MaterialCutsCouple.hh"                 46 #include "G4MaterialCutsCouple.hh"
 46 #include "G4RegionStore.hh"                        47 #include "G4RegionStore.hh"
 47 #include "G4LossTableManager.hh"                   48 #include "G4LossTableManager.hh"
 48                                                    49 
 49                                                    50 
 50 //....oooOO0OOooo........oooOO0OOooo........oo     51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 51                                                    52 
 52 G4EnergyLossTablesHelper *G4EnergyLossTables:: <<  53 G4EnergyLossTablesHelper G4EnergyLossTables::t  ;
 53 G4EnergyLossTablesHelper *G4EnergyLossTables:: <<  54 G4EnergyLossTablesHelper G4EnergyLossTables::null_loss ;
 54 G4ParticleDefinition* G4EnergyLossTables::last <<  55 const G4ParticleDefinition* G4EnergyLossTables::lastParticle = 0;
 55 G4double G4EnergyLossTables::QQPositron = 1.0; <<  56 G4double G4EnergyLossTables::QQPositron = eplus*eplus ;
 56 G4double G4EnergyLossTables::Chargesquare ;        57 G4double G4EnergyLossTables::Chargesquare ;
 57 G4int    G4EnergyLossTables::oldIndex = -1 ;       58 G4int    G4EnergyLossTables::oldIndex = -1 ;
 58 G4double G4EnergyLossTables::rmin = 0. ;           59 G4double G4EnergyLossTables::rmin = 0. ;
 59 G4double G4EnergyLossTables::rmax = 0. ;           60 G4double G4EnergyLossTables::rmax = 0. ;
 60 G4double G4EnergyLossTables::Thigh = 0. ;          61 G4double G4EnergyLossTables::Thigh = 0. ;
 61 G4int    G4EnergyLossTables::let_counter = 0;      62 G4int    G4EnergyLossTables::let_counter = 0;
 62 G4int    G4EnergyLossTables::let_max_num_warni     63 G4int    G4EnergyLossTables::let_max_num_warnings = 100;
 63 G4bool   G4EnergyLossTables::first_loss = true     64 G4bool   G4EnergyLossTables::first_loss = true;
 64                                                    65 
 65 G4EnergyLossTables::helper_map *G4EnergyLossTa <<  66 G4EnergyLossTables::helper_map G4EnergyLossTables::dict;
 66                                                    67 
 67 //....oooOO0OOooo........oooOO0OOooo........oo     68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 68                                                    69 
 69 G4EnergyLossTablesHelper::G4EnergyLossTablesHe     70 G4EnergyLossTablesHelper::G4EnergyLossTablesHelper(
 70   const G4PhysicsTable* aDEDXTable,                71   const G4PhysicsTable* aDEDXTable,
 71   const G4PhysicsTable* aRangeTable,               72   const G4PhysicsTable* aRangeTable,
 72   const G4PhysicsTable* anInverseRangeTable,       73   const G4PhysicsTable* anInverseRangeTable,
 73   const G4PhysicsTable* aLabTimeTable,             74   const G4PhysicsTable* aLabTimeTable,
 74   const G4PhysicsTable* aProperTimeTable,          75   const G4PhysicsTable* aProperTimeTable,
 75   G4double aLowestKineticEnergy,                   76   G4double aLowestKineticEnergy,
 76   G4double aHighestKineticEnergy,                  77   G4double aHighestKineticEnergy,
 77   G4double aMassRatio,                             78   G4double aMassRatio,
 78   G4int aNumberOfBins)                             79   G4int aNumberOfBins)
 79   :                                                80   :
 80   theDEDXTable(aDEDXTable), theRangeTable(aRan     81   theDEDXTable(aDEDXTable), theRangeTable(aRangeTable),
 81   theInverseRangeTable(anInverseRangeTable),       82   theInverseRangeTable(anInverseRangeTable),
 82   theLabTimeTable(aLabTimeTable),                  83   theLabTimeTable(aLabTimeTable),
 83   theProperTimeTable(aProperTimeTable),            84   theProperTimeTable(aProperTimeTable),
 84   theLowestKineticEnergy(aLowestKineticEnergy)     85   theLowestKineticEnergy(aLowestKineticEnergy),
 85   theHighestKineticEnergy(aHighestKineticEnerg     86   theHighestKineticEnergy(aHighestKineticEnergy),
 86   theMassRatio(aMassRatio),                        87   theMassRatio(aMassRatio),
 87   theNumberOfBins(aNumberOfBins)                   88   theNumberOfBins(aNumberOfBins)
 88 { }                                                89 { }
 89                                                    90 
 90 //....oooOO0OOooo........oooOO0OOooo........oo     91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 91                                                    92 
 92 G4EnergyLossTablesHelper::G4EnergyLossTablesHe     93 G4EnergyLossTablesHelper::G4EnergyLossTablesHelper()
 93 {                                              <<  94 { }
 94   theLowestKineticEnergy = 0.0;                << 
 95   theHighestKineticEnergy= 0.0;                << 
 96   theMassRatio = 0.0;                          << 
 97   theNumberOfBins = 0;                         << 
 98   theDEDXTable = theRangeTable = theInverseRan << 
 99     = theProperTimeTable = nullptr;            << 
100 }                                              << 
101                                                    95 
102 //....oooOO0OOooo........oooOO0OOooo........oo     96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103                                                    97 
104 void G4EnergyLossTables::Register(                 98 void G4EnergyLossTables::Register(
105   const G4ParticleDefinition* p,                   99   const G4ParticleDefinition* p,
106   const G4PhysicsTable* tDEDX,                    100   const G4PhysicsTable* tDEDX,
107   const G4PhysicsTable* tRange,                   101   const G4PhysicsTable* tRange,
108   const G4PhysicsTable* tInverseRange,            102   const G4PhysicsTable* tInverseRange,
109   const G4PhysicsTable* tLabTime,                 103   const G4PhysicsTable* tLabTime,
110   const G4PhysicsTable* tProperTime,              104   const G4PhysicsTable* tProperTime,
111   G4double lowestKineticEnergy,                   105   G4double lowestKineticEnergy,
112   G4double highestKineticEnergy,                  106   G4double highestKineticEnergy,
113   G4double massRatio,                             107   G4double massRatio,
114   G4int NumberOfBins)                             108   G4int NumberOfBins)
115 {                                                 109 {
116   if (!dict) dict = new G4EnergyLossTables::he << 110   dict[p]= G4EnergyLossTablesHelper(tDEDX, tRange,tInverseRange,
117   if (!null_loss) null_loss = new G4EnergyLoss << 
118   if (!t) t = new G4EnergyLossTablesHelper;    << 
119                                                << 
120   (*dict)[p]= G4EnergyLossTablesHelper(tDEDX,  << 
121                     tLabTime,tProperTime,lowes    111                     tLabTime,tProperTime,lowestKineticEnergy,
122         highestKineticEnergy, massRatio,Number    112         highestKineticEnergy, massRatio,NumberOfBins);
123                                                   113 
124   *t = GetTables(p) ;    // important for cach << 114   t = GetTables(p) ;    // important for cache !!!!!
125   lastParticle = (G4ParticleDefinition*) p ;   << 115   lastParticle = p ;
126   Chargesquare = (p->GetPDGCharge())*(p->GetPD    116   Chargesquare = (p->GetPDGCharge())*(p->GetPDGCharge())/
127                   QQPositron ;                    117                   QQPositron ;
128   if (first_loss ) {                              118   if (first_loss ) {
129     *null_loss = G4EnergyLossTablesHelper(     << 119     null_loss = G4EnergyLossTablesHelper(0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0);
130                  nullptr, nullptr, nullptr, nu << 
131     first_loss = false;                           120     first_loss = false;
132   }                                               121   }
133 }                                                 122 }
134                                                   123 
135 //....oooOO0OOooo........oooOO0OOooo........oo    124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136                                                   125 
137 const G4PhysicsTable* G4EnergyLossTables::GetD    126 const G4PhysicsTable* G4EnergyLossTables::GetDEDXTable(
138   const G4ParticleDefinition* p)                  127   const G4ParticleDefinition* p)
139 {                                                 128 {
140   if (!dict) dict = new G4EnergyLossTables::he << 
141   helper_map::iterator it;                        129   helper_map::iterator it;
142   if((it=dict->find(p))==dict->end()) return n << 130   if((it=dict.find(p))==dict.end()) return 0;
143   return (*it).second.theDEDXTable;               131   return (*it).second.theDEDXTable;
144 }                                                 132 }
145                                                   133 
146 //....oooOO0OOooo........oooOO0OOooo........oo    134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147                                                   135 
148 const G4PhysicsTable* G4EnergyLossTables::GetR    136 const G4PhysicsTable* G4EnergyLossTables::GetRangeTable(
149   const G4ParticleDefinition* p)                  137   const G4ParticleDefinition* p)
150 {                                                 138 {
151   if (!dict) dict = new G4EnergyLossTables::he << 
152   helper_map::iterator it;                        139   helper_map::iterator it;
153   if((it=dict->find(p))==dict->end()) return n << 140   if((it=dict.find(p))==dict.end()) return 0;
154   return (*it).second.theRangeTable;              141   return (*it).second.theRangeTable;
155 }                                                 142 }
156                                                   143 
157 //....oooOO0OOooo........oooOO0OOooo........oo    144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
158                                                   145 
159 const G4PhysicsTable* G4EnergyLossTables::GetI    146 const G4PhysicsTable* G4EnergyLossTables::GetInverseRangeTable(
160   const G4ParticleDefinition* p)                  147   const G4ParticleDefinition* p)
161 {                                                 148 {
162   if (!dict) dict = new G4EnergyLossTables::he << 
163   helper_map::iterator it;                        149   helper_map::iterator it;
164   if((it=dict->find(p))==dict->end()) return n << 150   if((it=dict.find(p))==dict.end()) return 0;
165   return (*it).second.theInverseRangeTable;       151   return (*it).second.theInverseRangeTable;
166 }                                                 152 }
167                                                   153 
168 //....oooOO0OOooo........oooOO0OOooo........oo    154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169                                                   155 
170 const G4PhysicsTable* G4EnergyLossTables::GetL    156 const G4PhysicsTable* G4EnergyLossTables::GetLabTimeTable(
171   const G4ParticleDefinition* p)                  157   const G4ParticleDefinition* p)
172 {                                                 158 {
173   if (!dict) dict = new G4EnergyLossTables::he << 
174   helper_map::iterator it;                        159   helper_map::iterator it;
175   if((it=dict->find(p))==dict->end()) return n << 160   if((it=dict.find(p))==dict.end()) return 0;
176   return (*it).second.theLabTimeTable;            161   return (*it).second.theLabTimeTable;
177 }                                                 162 }
178                                                   163 
179 //....oooOO0OOooo........oooOO0OOooo........oo    164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180                                                   165 
181 const G4PhysicsTable* G4EnergyLossTables::GetP    166 const G4PhysicsTable* G4EnergyLossTables::GetProperTimeTable(
182   const G4ParticleDefinition* p)                  167   const G4ParticleDefinition* p)
183 {                                                 168 {
184   if (!dict) dict = new G4EnergyLossTables::he << 
185   helper_map::iterator it;                        169   helper_map::iterator it;
186   if((it=dict->find(p))==dict->end()) return n << 170   if((it=dict.find(p))==dict.end()) return 0;
187   return (*it).second.theProperTimeTable;         171   return (*it).second.theProperTimeTable;
188 }                                                 172 }
189                                                   173 
190 //....oooOO0OOooo........oooOO0OOooo........oo    174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
191                                                   175 
192 G4EnergyLossTablesHelper G4EnergyLossTables::G    176 G4EnergyLossTablesHelper G4EnergyLossTables::GetTables(
193   const G4ParticleDefinition* p)                  177   const G4ParticleDefinition* p)
194 {                                                 178 {
195   if (!dict) dict = new G4EnergyLossTables::he << 
196   if (!null_loss) null_loss = new G4EnergyLoss << 
197                                                << 
198   helper_map::iterator it;                        179   helper_map::iterator it;
199   if ((it=dict->find(p))==dict->end()) {       << 180   if ((it=dict.find(p))==dict.end()) {
200     return *null_loss;                         << 181 //    G4cout << "Table is not found out for " << p->GetParticleName() << G4endl;
                                                   >> 182 //    G4Exception("G4EnergyLossTables::GetTables: table not found!");
                                                   >> 183 //    exit(1);
                                                   >> 184     return null_loss;
201   }                                               185   }
202   return (*it).second;                            186   return (*it).second;
203 }                                                 187 }
204                                                   188 
205 //....oooOO0OOooo........oooOO0OOooo........oo    189 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
206                                                   190 
207 G4double G4EnergyLossTables::GetDEDX(             191 G4double G4EnergyLossTables::GetDEDX(
208     const G4ParticleDefinition *aParticle,        192     const G4ParticleDefinition *aParticle,
209     G4double KineticEnergy,                       193     G4double KineticEnergy,
210     const G4Material *aMaterial)                  194     const G4Material *aMaterial)
211 {                                                 195 {
212   if (!t) t = new G4EnergyLossTablesHelper;    << 
213                                                << 
214   CPRWarning();                                   196   CPRWarning();
215   if(aParticle != (const G4ParticleDefinition* << 197   if(aParticle != lastParticle)
216   {                                               198   {
217     *t= GetTables(aParticle);                  << 199     t= GetTables(aParticle);
218     lastParticle = (G4ParticleDefinition*) aPa << 200     lastParticle = aParticle ;
219     Chargesquare = (aParticle->GetPDGCharge())    201     Chargesquare = (aParticle->GetPDGCharge())*
220                    (aParticle->GetPDGCharge())    202                    (aParticle->GetPDGCharge())/
221                    QQPositron ;                   203                    QQPositron ;
222     oldIndex = -1 ;                               204     oldIndex = -1 ;
223   }                                               205   }
224   const G4PhysicsTable*  dEdxTable= t->theDEDX << 206   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
225   if (!dEdxTable) {                            << 207   if (!dEdxTable) ParticleHaveNoLoss(aParticle,"dEdx");
226     ParticleHaveNoLoss(aParticle,"dEdx");      << 
227     return 0.0;                                << 
228   }                                            << 
229                                                   208 
230   G4int materialIndex = (G4int)aMaterial->GetI << 209   G4int materialIndex = aMaterial->GetIndex();
231   G4double scaledKineticEnergy = KineticEnergy << 210   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
232   G4double dEdx;                                  211   G4double dEdx;
233   G4bool isOut;                                   212   G4bool isOut;
234                                                   213 
235   if (scaledKineticEnergy<t->theLowestKineticE << 214   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
236                                                   215 
237      dEdx =(*dEdxTable)(materialIndex)->GetVal    216      dEdx =(*dEdxTable)(materialIndex)->GetValue(
238               t->theLowestKineticEnergy,isOut) << 217               t.theLowestKineticEnergy,isOut)
239            *std::sqrt(scaledKineticEnergy/t->t << 218            *std::sqrt(scaledKineticEnergy/t.theLowestKineticEnergy);
240                                                   219 
241   } else if (scaledKineticEnergy>t->theHighest << 220   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
242                                                   221 
243      dEdx = (*dEdxTable)(materialIndex)->GetVa    222      dEdx = (*dEdxTable)(materialIndex)->GetValue(
244         t->theHighestKineticEnergy,isOut);     << 223         t.theHighestKineticEnergy,isOut);
245                                                   224 
246   } else {                                        225   } else {
247                                                   226 
248     dEdx = (*dEdxTable)(materialIndex)->GetVal    227     dEdx = (*dEdxTable)(materialIndex)->GetValue(
249          scaledKineticEnergy,isOut);              228          scaledKineticEnergy,isOut);
250                                                   229 
251   }                                               230   }
252                                                   231 
253   return dEdx*Chargesquare;                       232   return dEdx*Chargesquare;
254 }                                                 233 }
255                                                   234 
256 //....oooOO0OOooo........oooOO0OOooo........oo    235 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
257                                                   236 
258 G4double G4EnergyLossTables::GetLabTime(          237 G4double G4EnergyLossTables::GetLabTime(
259     const G4ParticleDefinition *aParticle,        238     const G4ParticleDefinition *aParticle,
260     G4double KineticEnergy,                       239     G4double KineticEnergy,
261     const G4Material *aMaterial)                  240     const G4Material *aMaterial)
262 {                                                 241 {
263   if (!t) t = new G4EnergyLossTablesHelper;    << 
264                                                << 
265   CPRWarning();                                   242   CPRWarning();
266   if(aParticle != (const G4ParticleDefinition* << 243   if(aParticle != lastParticle)
267   {                                               244   {
268     *t= GetTables(aParticle);                  << 245     t= GetTables(aParticle);
269     lastParticle = (G4ParticleDefinition*) aPa << 246     lastParticle = aParticle ;
270     oldIndex = -1 ;                               247     oldIndex = -1 ;
271   }                                               248   }
272   const G4PhysicsTable* labtimeTable= t->theLa << 249   const G4PhysicsTable* labtimeTable= t.theLabTimeTable;
273   if (!labtimeTable) {                         << 250   if (!labtimeTable) ParticleHaveNoLoss(aParticle,"LabTime");
274     ParticleHaveNoLoss(aParticle,"LabTime");   << 
275     return 0.0;                                << 
276   }                                            << 
277                                                   251 
278   const G4double parlowen=0.4 , ppar=0.5-parlo    252   const G4double parlowen=0.4 , ppar=0.5-parlowen ;
279   G4int materialIndex = (G4int)aMaterial->GetI << 253   G4int materialIndex = aMaterial->GetIndex();
280   G4double scaledKineticEnergy = KineticEnergy << 254   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
281   G4double time;                                  255   G4double time;
282   G4bool isOut;                                   256   G4bool isOut;
283                                                   257 
284   if (scaledKineticEnergy<t->theLowestKineticE << 258   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
285                                                   259 
286      time = std::exp(ppar*std::log(scaledKinet << 260      time = std::exp(ppar*std::log(scaledKineticEnergy/t.theLowestKineticEnergy))*
287             (*labtimeTable)(materialIndex)->Ge    261             (*labtimeTable)(materialIndex)->GetValue(
288               t->theLowestKineticEnergy,isOut) << 262               t.theLowestKineticEnergy,isOut);
289                                                   263 
290                                                   264 
291   } else if (scaledKineticEnergy>t->theHighest << 265   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
292                                                   266 
293      time = (*labtimeTable)(materialIndex)->Ge    267      time = (*labtimeTable)(materialIndex)->GetValue(
294               t->theHighestKineticEnergy,isOut << 268               t.theHighestKineticEnergy,isOut);
295                                                   269 
296   } else {                                        270   } else {
297                                                   271 
298     time = (*labtimeTable)(materialIndex)->Get    272     time = (*labtimeTable)(materialIndex)->GetValue(
299                scaledKineticEnergy,isOut);        273                scaledKineticEnergy,isOut);
300                                                   274 
301   }                                               275   }
302                                                   276 
303   return time/t->theMassRatio ;                << 277   return time/t.theMassRatio ;
304 }                                                 278 }
305                                                   279 
306 //....oooOO0OOooo........oooOO0OOooo........oo    280 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
307                                                   281 
308 G4double G4EnergyLossTables::GetDeltaLabTime(     282 G4double G4EnergyLossTables::GetDeltaLabTime(
309     const G4ParticleDefinition *aParticle,        283     const G4ParticleDefinition *aParticle,
310     G4double KineticEnergyStart,                  284     G4double KineticEnergyStart,
311     G4double KineticEnergyEnd,                    285     G4double KineticEnergyEnd,
312     const G4Material *aMaterial)                  286     const G4Material *aMaterial)
313 {                                                 287 {
314   if (!t) t = new G4EnergyLossTablesHelper;    << 
315                                                << 
316   CPRWarning();                                   288   CPRWarning();
317   if(aParticle != (const G4ParticleDefinition* << 289   if(aParticle != lastParticle)
318   {                                               290   {
319     *t= GetTables(aParticle);                  << 291     t= GetTables(aParticle);
320     lastParticle = (G4ParticleDefinition*) aPa << 292     lastParticle = aParticle ;
321     oldIndex = -1 ;                               293     oldIndex = -1 ;
322   }                                               294   }
323   const G4PhysicsTable* labtimeTable= t->theLa << 295   const G4PhysicsTable* labtimeTable= t.theLabTimeTable;
324   if (!labtimeTable) {                         << 296   if (!labtimeTable) ParticleHaveNoLoss(aParticle,"LabTime");
325     ParticleHaveNoLoss(aParticle,"LabTime");   << 
326     return 0.0;                                << 
327   }                                            << 
328                                                   297 
329   const G4double parlowen=0.4 , ppar=0.5-parlo    298   const G4double parlowen=0.4 , ppar=0.5-parlowen ;
330   const G4double dToverT = 0.05 , facT = 1. -d    299   const G4double dToverT = 0.05 , facT = 1. -dToverT ;
331   G4double timestart,timeend,deltatime,dTT;       300   G4double timestart,timeend,deltatime,dTT;
332   G4bool isOut;                                   301   G4bool isOut;
333                                                   302 
334   G4int materialIndex = (G4int)aMaterial->GetI << 303   G4int materialIndex = aMaterial->GetIndex();
335   G4double scaledKineticEnergy = KineticEnergy << 304   G4double scaledKineticEnergy = KineticEnergyStart*t.theMassRatio;
336                                                   305 
337   if (scaledKineticEnergy<t->theLowestKineticE << 306   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
338                                                   307 
339      timestart = std::exp(ppar*std::log(scaled << 308      timestart = std::exp(ppar*std::log(scaledKineticEnergy/t.theLowestKineticEnergy))*
340                 (*labtimeTable)(materialIndex)    309                 (*labtimeTable)(materialIndex)->GetValue(
341                 t->theLowestKineticEnergy,isOu << 310                 t.theLowestKineticEnergy,isOut);
342                                                   311 
343                                                   312 
344   } else if (scaledKineticEnergy>t->theHighest << 313   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
345                                                   314 
346      timestart = (*labtimeTable)(materialIndex    315      timestart = (*labtimeTable)(materialIndex)->GetValue(
347                 t->theHighestKineticEnergy,isO << 316                 t.theHighestKineticEnergy,isOut);
348                                                   317 
349   } else {                                        318   } else {
350                                                   319 
351     timestart = (*labtimeTable)(materialIndex)    320     timestart = (*labtimeTable)(materialIndex)->GetValue(
352                 scaledKineticEnergy,isOut);       321                 scaledKineticEnergy,isOut);
353                                                   322 
354   }                                               323   }
355                                                   324 
356   dTT = (KineticEnergyStart - KineticEnergyEnd    325   dTT = (KineticEnergyStart - KineticEnergyEnd)/KineticEnergyStart ;
357                                                   326 
358   if( dTT < dToverT )                             327   if( dTT < dToverT )
359     scaledKineticEnergy = facT*KineticEnergySt << 328     scaledKineticEnergy = facT*KineticEnergyStart*t.theMassRatio;
360   else                                            329   else
361     scaledKineticEnergy = KineticEnergyEnd*t-> << 330     scaledKineticEnergy = KineticEnergyEnd*t.theMassRatio;
362                                                   331 
363   if (scaledKineticEnergy<t->theLowestKineticE << 332   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
364                                                   333 
365      timeend = std::exp(ppar*std::log(scaledKi << 334      timeend = std::exp(ppar*std::log(scaledKineticEnergy/t.theLowestKineticEnergy))*
366                 (*labtimeTable)(materialIndex)    335                 (*labtimeTable)(materialIndex)->GetValue(
367                 t->theLowestKineticEnergy,isOu << 336                 t.theLowestKineticEnergy,isOut);
368                                                   337 
369                                                   338 
370   } else if (scaledKineticEnergy>t->theHighest << 339   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
371                                                   340 
372      timeend = (*labtimeTable)(materialIndex)-    341      timeend = (*labtimeTable)(materialIndex)->GetValue(
373                 t->theHighestKineticEnergy,isO << 342                 t.theHighestKineticEnergy,isOut);
374                                                   343 
375   } else {                                        344   } else {
376                                                   345 
377     timeend = (*labtimeTable)(materialIndex)->    346     timeend = (*labtimeTable)(materialIndex)->GetValue(
378                 scaledKineticEnergy,isOut);       347                 scaledKineticEnergy,isOut);
379                                                   348 
380   }                                               349   }
381                                                   350 
382   deltatime = timestart - timeend ;               351   deltatime = timestart - timeend ;
383                                                   352 
384   if( dTT < dToverT )                             353   if( dTT < dToverT )
385     deltatime *= dTT/dToverT;                     354     deltatime *= dTT/dToverT;
386                                                   355 
387   return deltatime/t->theMassRatio ;           << 356   return deltatime/t.theMassRatio ;
388 }                                                 357 }
389                                                   358 
390 //....oooOO0OOooo........oooOO0OOooo........oo    359 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
391                                                   360 
392 G4double G4EnergyLossTables::GetProperTime(       361 G4double G4EnergyLossTables::GetProperTime(
393     const G4ParticleDefinition *aParticle,        362     const G4ParticleDefinition *aParticle,
394     G4double KineticEnergy,                       363     G4double KineticEnergy,
395     const G4Material *aMaterial)                  364     const G4Material *aMaterial)
396 {                                                 365 {
397   if (!t) t = new G4EnergyLossTablesHelper;    << 
398                                                << 
399   CPRWarning();                                   366   CPRWarning();
400   if(aParticle != (const G4ParticleDefinition* << 367   if(aParticle != lastParticle)
401   {                                               368   {
402     *t= GetTables(aParticle);                  << 369     t= GetTables(aParticle);
403     lastParticle = (G4ParticleDefinition*) aPa << 370     lastParticle = aParticle ;
404     oldIndex = -1 ;                               371     oldIndex = -1 ;
405   }                                               372   }
406   const G4PhysicsTable* propertimeTable= t->th << 373   const G4PhysicsTable* propertimeTable= t.theProperTimeTable;
407   if (!propertimeTable) {                      << 374   if (!propertimeTable) ParticleHaveNoLoss(aParticle,"ProperTime");
408     ParticleHaveNoLoss(aParticle,"ProperTime") << 
409     return 0.0;                                << 
410   }                                            << 
411                                                   375 
412   const G4double parlowen=0.4 , ppar=0.5-parlo    376   const G4double parlowen=0.4 , ppar=0.5-parlowen ;
413   G4int materialIndex = (G4int)aMaterial->GetI << 377   G4int materialIndex = aMaterial->GetIndex();
414   G4double scaledKineticEnergy = KineticEnergy << 378   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
415   G4double time;                                  379   G4double time;
416   G4bool isOut;                                   380   G4bool isOut;
417                                                   381 
418   if (scaledKineticEnergy<t->theLowestKineticE << 382   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
419                                                   383 
420      time = std::exp(ppar*std::log(scaledKinet << 384      time = std::exp(ppar*std::log(scaledKineticEnergy/t.theLowestKineticEnergy))*
421             (*propertimeTable)(materialIndex)-    385             (*propertimeTable)(materialIndex)->GetValue(
422               t->theLowestKineticEnergy,isOut) << 386               t.theLowestKineticEnergy,isOut);
423                                                   387 
424                                                   388 
425   } else if (scaledKineticEnergy>t->theHighest << 389   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
426                                                   390 
427      time = (*propertimeTable)(materialIndex)-    391      time = (*propertimeTable)(materialIndex)->GetValue(
428               t->theHighestKineticEnergy,isOut << 392               t.theHighestKineticEnergy,isOut);
429                                                   393 
430   } else {                                        394   } else {
431                                                   395 
432     time = (*propertimeTable)(materialIndex)->    396     time = (*propertimeTable)(materialIndex)->GetValue(
433                scaledKineticEnergy,isOut);        397                scaledKineticEnergy,isOut);
434                                                   398 
435   }                                               399   }
436                                                   400 
437   return time/t->theMassRatio ;                << 401   return time/t.theMassRatio ;
438 }                                                 402 }
439                                                   403 
440 //....oooOO0OOooo........oooOO0OOooo........oo    404 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
441                                                   405 
442 G4double G4EnergyLossTables::GetDeltaProperTim    406 G4double G4EnergyLossTables::GetDeltaProperTime(
443     const G4ParticleDefinition *aParticle,        407     const G4ParticleDefinition *aParticle,
444     G4double KineticEnergyStart,                  408     G4double KineticEnergyStart,
445     G4double KineticEnergyEnd,                    409     G4double KineticEnergyEnd,
446     const G4Material *aMaterial)                  410     const G4Material *aMaterial)
447 {                                                 411 {
448   if (!t) t = new G4EnergyLossTablesHelper;    << 
449                                                << 
450   CPRWarning();                                   412   CPRWarning();
451   if(aParticle != (const G4ParticleDefinition* << 413   if(aParticle != lastParticle)
452   {                                               414   {
453     *t= GetTables(aParticle);                  << 415     t= GetTables(aParticle);
454     lastParticle = (G4ParticleDefinition*) aPa << 416     lastParticle = aParticle ;
455     oldIndex = -1 ;                               417     oldIndex = -1 ;
456   }                                               418   }
457   const G4PhysicsTable* propertimeTable= t->th << 419   const G4PhysicsTable* propertimeTable= t.theProperTimeTable;
458   if (!propertimeTable) {                      << 420   if (!propertimeTable) ParticleHaveNoLoss(aParticle,"ProperTime");
459     ParticleHaveNoLoss(aParticle,"ProperTime") << 
460     return 0.0;                                << 
461   }                                            << 
462                                                   421 
463   const G4double parlowen=0.4 , ppar=0.5-parlo    422   const G4double parlowen=0.4 , ppar=0.5-parlowen ;
464   const G4double dToverT = 0.05 , facT = 1. -d    423   const G4double dToverT = 0.05 , facT = 1. -dToverT ;
465   G4double timestart,timeend,deltatime,dTT;       424   G4double timestart,timeend,deltatime,dTT;
466   G4bool isOut;                                   425   G4bool isOut;
467                                                   426 
468   G4int materialIndex = (G4int)aMaterial->GetI << 427   G4int materialIndex = aMaterial->GetIndex();
469   G4double scaledKineticEnergy = KineticEnergy << 428   G4double scaledKineticEnergy = KineticEnergyStart*t.theMassRatio;
470                                                   429 
471   if (scaledKineticEnergy<t->theLowestKineticE << 430   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
472                                                   431 
473      timestart = std::exp(ppar*std::log(scaled << 432      timestart = std::exp(ppar*std::log(scaledKineticEnergy/t.theLowestKineticEnergy))*
474                 (*propertimeTable)(materialInd    433                 (*propertimeTable)(materialIndex)->GetValue(
475                 t->theLowestKineticEnergy,isOu << 434                 t.theLowestKineticEnergy,isOut);
476                                                   435 
477                                                   436 
478   } else if (scaledKineticEnergy>t->theHighest << 437   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
479                                                   438 
480      timestart = (*propertimeTable)(materialIn    439      timestart = (*propertimeTable)(materialIndex)->GetValue(
481                 t->theHighestKineticEnergy,isO << 440                 t.theHighestKineticEnergy,isOut);
482                                                   441 
483   } else {                                        442   } else {
484                                                   443 
485     timestart = (*propertimeTable)(materialInd    444     timestart = (*propertimeTable)(materialIndex)->GetValue(
486                 scaledKineticEnergy,isOut);       445                 scaledKineticEnergy,isOut);
487                                                   446 
488   }                                               447   }
489                                                   448 
490   dTT = (KineticEnergyStart - KineticEnergyEnd    449   dTT = (KineticEnergyStart - KineticEnergyEnd)/KineticEnergyStart ;
491                                                   450 
492   if( dTT < dToverT )                             451   if( dTT < dToverT )
493     scaledKineticEnergy = facT*KineticEnergySt << 452     scaledKineticEnergy = facT*KineticEnergyStart*t.theMassRatio;
494   else                                            453   else
495     scaledKineticEnergy = KineticEnergyEnd*t-> << 454     scaledKineticEnergy = KineticEnergyEnd*t.theMassRatio;
496                                                   455 
497   if (scaledKineticEnergy<t->theLowestKineticE << 456   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
498                                                   457 
499      timeend = std::exp(ppar*std::log(scaledKi << 458      timeend = std::exp(ppar*std::log(scaledKineticEnergy/t.theLowestKineticEnergy))*
500                 (*propertimeTable)(materialInd    459                 (*propertimeTable)(materialIndex)->GetValue(
501                 t->theLowestKineticEnergy,isOu << 460                 t.theLowestKineticEnergy,isOut);
502                                                   461 
503                                                   462 
504   } else if (scaledKineticEnergy>t->theHighest << 463   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
505                                                   464 
506      timeend = (*propertimeTable)(materialInde    465      timeend = (*propertimeTable)(materialIndex)->GetValue(
507                 t->theHighestKineticEnergy,isO << 466                 t.theHighestKineticEnergy,isOut);
508                                                   467 
509   } else {                                        468   } else {
510                                                   469 
511     timeend = (*propertimeTable)(materialIndex    470     timeend = (*propertimeTable)(materialIndex)->GetValue(
512                 scaledKineticEnergy,isOut);       471                 scaledKineticEnergy,isOut);
513                                                   472 
514   }                                               473   }
515                                                   474 
516   deltatime = timestart - timeend ;               475   deltatime = timestart - timeend ;
517                                                   476 
518   if( dTT < dToverT )                             477   if( dTT < dToverT )
519     deltatime *= dTT/dToverT ;                    478     deltatime *= dTT/dToverT ;
520                                                   479 
521   return deltatime/t->theMassRatio ;           << 480   return deltatime/t.theMassRatio ;
522 }                                                 481 }
523                                                   482 
524 //....oooOO0OOooo........oooOO0OOooo........oo    483 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
525                                                   484 
526 G4double G4EnergyLossTables::GetRange(            485 G4double G4EnergyLossTables::GetRange(
527     const G4ParticleDefinition *aParticle,        486     const G4ParticleDefinition *aParticle,
528     G4double KineticEnergy,                       487     G4double KineticEnergy,
529     const G4Material *aMaterial)                  488     const G4Material *aMaterial)
530 {                                                 489 {
531   if (!t) t = new G4EnergyLossTablesHelper;    << 
532                                                << 
533   CPRWarning();                                   490   CPRWarning();
534   if(aParticle != (const G4ParticleDefinition* << 491   if(aParticle != lastParticle)
535   {                                               492   {
536     *t= GetTables(aParticle);                  << 493     t= GetTables(aParticle);
537     lastParticle = (G4ParticleDefinition*) aPa << 494     lastParticle = aParticle ;
538     Chargesquare = (aParticle->GetPDGCharge())    495     Chargesquare = (aParticle->GetPDGCharge())*
539                    (aParticle->GetPDGCharge())    496                    (aParticle->GetPDGCharge())/
540                     QQPositron ;                  497                     QQPositron ;
541     oldIndex = -1 ;                               498     oldIndex = -1 ;
542   }                                               499   }
543   const G4PhysicsTable* rangeTable= t->theRang << 500   const G4PhysicsTable* rangeTable= t.theRangeTable;
544   const G4PhysicsTable*  dEdxTable= t->theDEDX << 501   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
545   if (!rangeTable) {                           << 502   if (!rangeTable) ParticleHaveNoLoss(aParticle,"Range");
546     ParticleHaveNoLoss(aParticle,"Range");     << 
547     return 0.0;                                << 
548   }                                            << 
549                                                   503 
550   G4int materialIndex = (G4int)aMaterial->GetI << 504   G4int materialIndex = aMaterial->GetIndex();
551   G4double scaledKineticEnergy = KineticEnergy << 505   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
552   G4double Range;                                 506   G4double Range;
553   G4bool isOut;                                   507   G4bool isOut;
554                                                   508 
555   if (scaledKineticEnergy<t->theLowestKineticE << 509   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
556                                                   510 
557     Range = std::sqrt(scaledKineticEnergy/t->t << 511     Range = std::sqrt(scaledKineticEnergy/t.theLowestKineticEnergy)*
558             (*rangeTable)(materialIndex)->GetV    512             (*rangeTable)(materialIndex)->GetValue(
559               t->theLowestKineticEnergy,isOut) << 513               t.theLowestKineticEnergy,isOut);
560                                                   514 
561   } else if (scaledKineticEnergy>t->theHighest << 515   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
562                                                   516 
563     Range = (*rangeTable)(materialIndex)->GetV    517     Range = (*rangeTable)(materialIndex)->GetValue(
564         t->theHighestKineticEnergy,isOut)+     << 518         t.theHighestKineticEnergy,isOut)+
565             (scaledKineticEnergy-t->theHighest << 519             (scaledKineticEnergy-t.theHighestKineticEnergy)/
566             (*dEdxTable)(materialIndex)->GetVa    520             (*dEdxTable)(materialIndex)->GetValue(
567               t->theHighestKineticEnergy,isOut << 521               t.theHighestKineticEnergy,isOut);
568                                                   522 
569   } else {                                        523   } else {
570                                                   524 
571     Range = (*rangeTable)(materialIndex)->GetV    525     Range = (*rangeTable)(materialIndex)->GetValue(
572          scaledKineticEnergy,isOut);              526          scaledKineticEnergy,isOut);
573                                                   527 
574   }                                               528   }
575                                                   529 
576   return Range/(Chargesquare*t->theMassRatio); << 530   return Range/(Chargesquare*t.theMassRatio);
577 }                                                 531 }
578                                                   532 
579 //....oooOO0OOooo........oooOO0OOooo........oo    533 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
580                                                   534 
581 G4double G4EnergyLossTables::GetPreciseEnergyF    535 G4double G4EnergyLossTables::GetPreciseEnergyFromRange(
582                                      const G4P    536                                      const G4ParticleDefinition *aParticle,
583                                            G4d    537                                            G4double range,
584                                      const G4M    538                                      const G4Material *aMaterial)
585 // it returns the value of the kinetic energy     539 // it returns the value of the kinetic energy for a given range
586 {                                                 540 {
587   if (!t) t = new G4EnergyLossTablesHelper;    << 
588                                                << 
589   CPRWarning();                                   541   CPRWarning();
590   if( aParticle != (const G4ParticleDefinition << 542   if( aParticle != lastParticle)
591   {                                               543   {
592     *t= GetTables(aParticle);                  << 544     t= GetTables(aParticle);
593     lastParticle = (G4ParticleDefinition*) aPa << 545     lastParticle = aParticle;
594     Chargesquare = (aParticle->GetPDGCharge())    546     Chargesquare = (aParticle->GetPDGCharge())*
595                    (aParticle->GetPDGCharge())    547                    (aParticle->GetPDGCharge())/
596                     QQPositron ;                  548                     QQPositron ;
597     oldIndex = -1 ;                               549     oldIndex = -1 ;
598   }                                               550   }
599   const G4PhysicsTable*  dEdxTable= t->theDEDX << 551   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
600   const G4PhysicsTable*  inverseRangeTable= t- << 552   const G4PhysicsTable*  inverseRangeTable= t.theInverseRangeTable;
601   if (!inverseRangeTable) {                    << 553   if (!inverseRangeTable) ParticleHaveNoLoss(aParticle,"InverseRange");
602     ParticleHaveNoLoss(aParticle,"InverseRange << 
603     return 0.0;                                << 
604   }                                            << 
605                                                   554 
606   G4double scaledrange,scaledKineticEnergy ;      555   G4double scaledrange,scaledKineticEnergy ;
607   G4bool isOut ;                                  556   G4bool isOut ;
608                                                   557 
609   G4int materialIndex = (G4int)aMaterial->GetI << 558   G4int materialIndex = aMaterial->GetIndex() ;
610                                                   559 
611   if(materialIndex != oldIndex)                   560   if(materialIndex != oldIndex)
612   {                                               561   {
613     oldIndex = materialIndex ;                    562     oldIndex = materialIndex ;
614     rmin = (*inverseRangeTable)(materialIndex)    563     rmin = (*inverseRangeTable)(materialIndex)->
615                               GetLowEdgeEnergy    564                               GetLowEdgeEnergy(0) ;
616     rmax = (*inverseRangeTable)(materialIndex)    565     rmax = (*inverseRangeTable)(materialIndex)->
617                    GetLowEdgeEnergy(t->theNumb << 566                    GetLowEdgeEnergy(t.theNumberOfBins-2) ;
618     Thigh = (*inverseRangeTable)(materialIndex    567     Thigh = (*inverseRangeTable)(materialIndex)->
619                               GetValue(rmax,is    568                               GetValue(rmax,isOut) ;
620   }                                               569   }
621                                                   570 
622   scaledrange = range*Chargesquare*t->theMassR << 571   scaledrange = range*Chargesquare*t.theMassRatio ;
623                                                   572 
624   if(scaledrange < rmin)                          573   if(scaledrange < rmin)
625   {                                               574   {
626     scaledKineticEnergy = t->theLowestKineticE << 575     scaledKineticEnergy = t.theLowestKineticEnergy*
627                    scaledrange*scaledrange/(rm    576                    scaledrange*scaledrange/(rmin*rmin) ;
628   }                                               577   }
629   else                                            578   else
630   {                                               579   {
631     if(scaledrange < rmax)                        580     if(scaledrange < rmax)
632     {                                             581     {
633       scaledKineticEnergy = (*inverseRangeTabl    582       scaledKineticEnergy = (*inverseRangeTable)(materialIndex)->
634                               GetValue( scaled    583                               GetValue( scaledrange,isOut) ;
635     }                                             584     }
636     else                                          585     else
637     {                                             586     {
638       scaledKineticEnergy = Thigh +               587       scaledKineticEnergy = Thigh +
639                       (scaledrange-rmax)*         588                       (scaledrange-rmax)*
640                       (*dEdxTable)(materialInd    589                       (*dEdxTable)(materialIndex)->
641                                  GetValue(Thig    590                                  GetValue(Thigh,isOut) ;
642     }                                             591     }
643   }                                               592   }
644                                                   593 
645   return scaledKineticEnergy/t->theMassRatio ; << 594   return scaledKineticEnergy/t.theMassRatio ;
646 }                                                 595 }
647                                                   596 
648 //....oooOO0OOooo........oooOO0OOooo........oo    597 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
649                                                   598 
650  G4double G4EnergyLossTables::GetPreciseDEDX(     599  G4double G4EnergyLossTables::GetPreciseDEDX(
651     const G4ParticleDefinition *aParticle,        600     const G4ParticleDefinition *aParticle,
652     G4double KineticEnergy,                       601     G4double KineticEnergy,
653     const G4Material *aMaterial)                  602     const G4Material *aMaterial)
654 {                                                 603 {
655   if (!t) t = new G4EnergyLossTablesHelper;    << 
656                                                << 
657   CPRWarning();                                   604   CPRWarning();
658   if( aParticle != (const G4ParticleDefinition << 605   if( aParticle != lastParticle)
659   {                                               606   {
660     *t= GetTables(aParticle);                  << 607     t= GetTables(aParticle);
661     lastParticle = (G4ParticleDefinition*) aPa << 608     lastParticle = aParticle;
662     Chargesquare = (aParticle->GetPDGCharge())    609     Chargesquare = (aParticle->GetPDGCharge())*
663                    (aParticle->GetPDGCharge())    610                    (aParticle->GetPDGCharge())/
664                     QQPositron ;                  611                     QQPositron ;
665     oldIndex = -1 ;                               612     oldIndex = -1 ;
666   }                                               613   }
667   const G4PhysicsTable*  dEdxTable= t->theDEDX << 614   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
668   if (!dEdxTable) {                            << 615   if (!dEdxTable) ParticleHaveNoLoss(aParticle,"dEdx");
669     ParticleHaveNoLoss(aParticle,"dEdx");      << 
670     return 0.0;                                << 
671   }                                            << 
672                                                   616 
673   G4int materialIndex = (G4int)aMaterial->GetI << 617   G4int materialIndex = aMaterial->GetIndex();
674   G4double scaledKineticEnergy = KineticEnergy << 618   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
675   G4double dEdx;                                  619   G4double dEdx;
676   G4bool isOut;                                   620   G4bool isOut;
677                                                   621 
678   if (scaledKineticEnergy<t->theLowestKineticE << 622   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
679                                                   623 
680      dEdx = std::sqrt(scaledKineticEnergy/t->t << 624      dEdx = std::sqrt(scaledKineticEnergy/t.theLowestKineticEnergy)
681             *(*dEdxTable)(materialIndex)->GetV    625             *(*dEdxTable)(materialIndex)->GetValue(
682               t->theLowestKineticEnergy,isOut) << 626               t.theLowestKineticEnergy,isOut);
683                                                   627 
684   } else if (scaledKineticEnergy>t->theHighest << 628   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
685                                                   629 
686      dEdx = (*dEdxTable)(materialIndex)->GetVa    630      dEdx = (*dEdxTable)(materialIndex)->GetValue(
687         t->theHighestKineticEnergy,isOut);     << 631         t.theHighestKineticEnergy,isOut);
688                                                   632 
689   } else {                                        633   } else {
690                                                   634 
691       dEdx = (*dEdxTable)(materialIndex)->GetV    635       dEdx = (*dEdxTable)(materialIndex)->GetValue(
692                           scaledKineticEnergy,    636                           scaledKineticEnergy,isOut) ;
693                                                   637 
694   }                                               638   }
695                                                   639 
696   return dEdx*Chargesquare;                       640   return dEdx*Chargesquare;
697 }                                                 641 }
698                                                   642 
699 //....oooOO0OOooo........oooOO0OOooo........oo    643 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
700                                                   644 
701  G4double G4EnergyLossTables::GetPreciseRangeF    645  G4double G4EnergyLossTables::GetPreciseRangeFromEnergy(
702     const G4ParticleDefinition *aParticle,        646     const G4ParticleDefinition *aParticle,
703     G4double KineticEnergy,                       647     G4double KineticEnergy,
704     const G4Material *aMaterial)                  648     const G4Material *aMaterial)
705 {                                                 649 {
706   if (!t) t = new G4EnergyLossTablesHelper;    << 
707                                                << 
708   CPRWarning();                                   650   CPRWarning();
709   if( aParticle != (const G4ParticleDefinition << 651   if( aParticle != lastParticle)
710   {                                               652   {
711     *t= GetTables(aParticle);                  << 653     t= GetTables(aParticle);
712     lastParticle = (G4ParticleDefinition*) aPa << 654     lastParticle = aParticle;
713     Chargesquare = (aParticle->GetPDGCharge())    655     Chargesquare = (aParticle->GetPDGCharge())*
714                    (aParticle->GetPDGCharge())    656                    (aParticle->GetPDGCharge())/
715                     QQPositron ;                  657                     QQPositron ;
716     oldIndex = -1 ;                               658     oldIndex = -1 ;
717   }                                               659   }
718   const G4PhysicsTable* rangeTable= t->theRang << 660   const G4PhysicsTable* rangeTable= t.theRangeTable;
719   const G4PhysicsTable*  dEdxTable= t->theDEDX << 661   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
720   if (!rangeTable) {                           << 662   if (!rangeTable) ParticleHaveNoLoss(aParticle,"Range");
721     ParticleHaveNoLoss(aParticle,"Range");     << 
722     return 0.0;                                << 
723   }                                            << 
724   G4int materialIndex = (G4int)aMaterial->GetI << 
725                                                   663 
726   G4double Thighr = t->theHighestKineticEnergy << 664   G4int materialIndex = aMaterial->GetIndex();
                                                   >> 665 
                                                   >> 666   G4double Thighr = t.theHighestKineticEnergy*t.theLowestKineticEnergy/
727                    (*rangeTable)(materialIndex    667                    (*rangeTable)(materialIndex)->
728                    GetLowEdgeEnergy(1) ;          668                    GetLowEdgeEnergy(1) ;
729                                                   669 
730   G4double scaledKineticEnergy = KineticEnergy << 670   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
731   G4double Range;                                 671   G4double Range;
732   G4bool isOut;                                   672   G4bool isOut;
733                                                   673 
734   if (scaledKineticEnergy<t->theLowestKineticE << 674   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
735                                                   675 
736     Range = std::sqrt(scaledKineticEnergy/t->t << 676     Range = std::sqrt(scaledKineticEnergy/t.theLowestKineticEnergy)*
737             (*rangeTable)(materialIndex)->GetV    677             (*rangeTable)(materialIndex)->GetValue(
738               t->theLowestKineticEnergy,isOut) << 678               t.theLowestKineticEnergy,isOut);
739                                                   679 
740   } else if (scaledKineticEnergy>Thighr) {        680   } else if (scaledKineticEnergy>Thighr) {
741                                                   681 
742     Range = (*rangeTable)(materialIndex)->GetV    682     Range = (*rangeTable)(materialIndex)->GetValue(
743         Thighr,isOut)+                            683         Thighr,isOut)+
744             (scaledKineticEnergy-Thighr)/         684             (scaledKineticEnergy-Thighr)/
745             (*dEdxTable)(materialIndex)->GetVa    685             (*dEdxTable)(materialIndex)->GetValue(
746               Thighr,isOut);                      686               Thighr,isOut);
747                                                   687 
748   } else {                                        688   } else {
749                                                   689 
750      Range = (*rangeTable)(materialIndex)->Get    690      Range = (*rangeTable)(materialIndex)->GetValue(
751                        scaledKineticEnergy,isO    691                        scaledKineticEnergy,isOut) ;
752                                                   692 
753   }                                               693   }
754                                                   694 
755   return Range/(Chargesquare*t->theMassRatio); << 695   return Range/(Chargesquare*t.theMassRatio);
756 }                                                 696 }
757                                                   697 
758 //....oooOO0OOooo........oooOO0OOooo........oo    698 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
759                                                   699 
760 G4double G4EnergyLossTables::GetDEDX(             700 G4double G4EnergyLossTables::GetDEDX(
761     const G4ParticleDefinition *aParticle,        701     const G4ParticleDefinition *aParticle,
762     G4double KineticEnergy,                       702     G4double KineticEnergy,
763     const G4MaterialCutsCouple *couple,           703     const G4MaterialCutsCouple *couple,
764     G4bool check)                                 704     G4bool check)
765 {                                                 705 {
766   if (!t) t = new G4EnergyLossTablesHelper;    << 706   if(aParticle != lastParticle)
767                                                << 
768   if(aParticle != (const G4ParticleDefinition* << 
769   {                                               707   {
770     *t= GetTables(aParticle);                  << 708     t= GetTables(aParticle);
771     lastParticle = (G4ParticleDefinition*) aPa << 709     lastParticle = aParticle ;
772     Chargesquare = (aParticle->GetPDGCharge())    710     Chargesquare = (aParticle->GetPDGCharge())*
773                    (aParticle->GetPDGCharge())    711                    (aParticle->GetPDGCharge())/
774                    QQPositron ;                   712                    QQPositron ;
775     oldIndex = -1 ;                               713     oldIndex = -1 ;
776   }                                               714   }
777   const G4PhysicsTable*  dEdxTable= t->theDEDX << 715   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
778                                                   716   
779   if (!dEdxTable ) {                              717   if (!dEdxTable ) {
780     if (check) return G4LossTableManager::Inst    718     if (check) return G4LossTableManager::Instance()->GetDEDX(aParticle,KineticEnergy,couple);
781     else       ParticleHaveNoLoss(aParticle, "    719     else       ParticleHaveNoLoss(aParticle, "dEdx");
782     return 0.0;                                << 
783   }                                               720   }
784                                                   721 
785   G4int materialIndex = couple->GetIndex();       722   G4int materialIndex = couple->GetIndex();
786   G4double scaledKineticEnergy = KineticEnergy << 723   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
787   G4double dEdx;                                  724   G4double dEdx;
788   G4bool isOut;                                   725   G4bool isOut;
789                                                   726 
790   if (scaledKineticEnergy<t->theLowestKineticE << 727   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
791                                                   728 
792      dEdx =(*dEdxTable)(materialIndex)->GetVal    729      dEdx =(*dEdxTable)(materialIndex)->GetValue(
793               t->theLowestKineticEnergy,isOut) << 730               t.theLowestKineticEnergy,isOut)
794            *std::sqrt(scaledKineticEnergy/t->t << 731            *std::sqrt(scaledKineticEnergy/t.theLowestKineticEnergy);
795                                                   732 
796   } else if (scaledKineticEnergy>t->theHighest << 733   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
797                                                   734 
798      dEdx = (*dEdxTable)(materialIndex)->GetVa    735      dEdx = (*dEdxTable)(materialIndex)->GetValue(
799         t->theHighestKineticEnergy,isOut);     << 736         t.theHighestKineticEnergy,isOut);
800                                                   737 
801   } else {                                        738   } else {
802                                                   739 
803     dEdx = (*dEdxTable)(materialIndex)->GetVal    740     dEdx = (*dEdxTable)(materialIndex)->GetValue(
804          scaledKineticEnergy,isOut);              741          scaledKineticEnergy,isOut);
805                                                   742 
806   }                                               743   }
807                                                   744 
808   return dEdx*Chargesquare;                       745   return dEdx*Chargesquare;
809 }                                                 746 }
810                                                   747 
811 //....oooOO0OOooo........oooOO0OOooo........oo    748 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
812                                                   749 
813 G4double G4EnergyLossTables::GetRange(            750 G4double G4EnergyLossTables::GetRange(
814     const G4ParticleDefinition *aParticle,        751     const G4ParticleDefinition *aParticle,
815     G4double KineticEnergy,                       752     G4double KineticEnergy,
816     const G4MaterialCutsCouple *couple,           753     const G4MaterialCutsCouple *couple,
817     G4bool check)                                 754     G4bool check)
818 {                                                 755 {
819   if (!t) t = new G4EnergyLossTablesHelper;    << 756   if(aParticle != lastParticle)
820                                                << 
821   if(aParticle != (const G4ParticleDefinition* << 
822   {                                               757   {
823     *t= GetTables(aParticle);                  << 758     t= GetTables(aParticle);
824     lastParticle = (G4ParticleDefinition*) aPa << 759     lastParticle = aParticle ;
825     Chargesquare = (aParticle->GetPDGCharge())    760     Chargesquare = (aParticle->GetPDGCharge())*
826                    (aParticle->GetPDGCharge())    761                    (aParticle->GetPDGCharge())/
827                     QQPositron ;                  762                     QQPositron ;
828     oldIndex = -1 ;                               763     oldIndex = -1 ;
829   }                                               764   }
830   const G4PhysicsTable* rangeTable= t->theRang << 765   const G4PhysicsTable* rangeTable= t.theRangeTable;
831   const G4PhysicsTable*  dEdxTable= t->theDEDX << 766   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
832   if (!rangeTable) {                              767   if (!rangeTable) {
833     if(check) return G4LossTableManager::Insta    768     if(check) return G4LossTableManager::Instance()->GetRange(aParticle,KineticEnergy,couple);
834     else      return DBL_MAX;                     769     else      return DBL_MAX;      
835       //ParticleHaveNoLoss(aParticle,"Range");    770       //ParticleHaveNoLoss(aParticle,"Range");
836   }                                               771   }
837                                                   772 
838   G4int materialIndex = couple->GetIndex();       773   G4int materialIndex = couple->GetIndex();
839   G4double scaledKineticEnergy = KineticEnergy << 774   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
840   G4double Range;                                 775   G4double Range;
841   G4bool isOut;                                   776   G4bool isOut;
842                                                   777 
843   if (scaledKineticEnergy<t->theLowestKineticE << 778   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
844                                                   779 
845     Range = std::sqrt(scaledKineticEnergy/t->t << 780     Range = std::sqrt(scaledKineticEnergy/t.theLowestKineticEnergy)*
846             (*rangeTable)(materialIndex)->GetV    781             (*rangeTable)(materialIndex)->GetValue(
847               t->theLowestKineticEnergy,isOut) << 782               t.theLowestKineticEnergy,isOut);
848                                                   783 
849   } else if (scaledKineticEnergy>t->theHighest << 784   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
850                                                   785 
851     Range = (*rangeTable)(materialIndex)->GetV    786     Range = (*rangeTable)(materialIndex)->GetValue(
852         t->theHighestKineticEnergy,isOut)+     << 787         t.theHighestKineticEnergy,isOut)+
853             (scaledKineticEnergy-t->theHighest << 788             (scaledKineticEnergy-t.theHighestKineticEnergy)/
854             (*dEdxTable)(materialIndex)->GetVa    789             (*dEdxTable)(materialIndex)->GetValue(
855               t->theHighestKineticEnergy,isOut << 790               t.theHighestKineticEnergy,isOut);
856                                                   791 
857   } else {                                        792   } else {
858                                                   793 
859     Range = (*rangeTable)(materialIndex)->GetV    794     Range = (*rangeTable)(materialIndex)->GetValue(
860          scaledKineticEnergy,isOut);              795          scaledKineticEnergy,isOut);
861                                                   796 
862   }                                               797   }
863                                                   798 
864   return Range/(Chargesquare*t->theMassRatio); << 799   return Range/(Chargesquare*t.theMassRatio);
865 }                                                 800 }
866                                                   801 
867 //....oooOO0OOooo........oooOO0OOooo........oo    802 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
868                                                   803 
869 G4double G4EnergyLossTables::GetPreciseEnergyF    804 G4double G4EnergyLossTables::GetPreciseEnergyFromRange(
870                                      const G4P    805                                      const G4ParticleDefinition *aParticle,
871                                            G4d    806                                            G4double range,
872                                      const G4M    807                                      const G4MaterialCutsCouple *couple,
873                    G4bool check)                  808                    G4bool check)
874 // it returns the value of the kinetic energy     809 // it returns the value of the kinetic energy for a given range
875 {                                                 810 {
876   if (!t) t = new G4EnergyLossTablesHelper;    << 811   if( aParticle != lastParticle)
877                                                << 
878   if( aParticle != (const G4ParticleDefinition << 
879   {                                               812   {
880     *t= GetTables(aParticle);                  << 813     t= GetTables(aParticle);
881     lastParticle = (G4ParticleDefinition*) aPa << 814     lastParticle = aParticle;
882     Chargesquare = (aParticle->GetPDGCharge())    815     Chargesquare = (aParticle->GetPDGCharge())*
883                    (aParticle->GetPDGCharge())    816                    (aParticle->GetPDGCharge())/
884                     QQPositron ;                  817                     QQPositron ;
885     oldIndex = -1 ;                               818     oldIndex = -1 ;
886   }                                               819   }
887   const G4PhysicsTable*  dEdxTable= t->theDEDX << 820   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
888   const G4PhysicsTable*  inverseRangeTable= t- << 821   const G4PhysicsTable*  inverseRangeTable= t.theInverseRangeTable;
889                                                   822   
890   if (!inverseRangeTable) {                       823   if (!inverseRangeTable) {
891     if(check) return G4LossTableManager::Insta    824     if(check) return G4LossTableManager::Instance()->GetEnergy(aParticle,range,couple);
892     else      return DBL_MAX;                     825     else      return DBL_MAX;      
893     //    else      ParticleHaveNoLoss(aPartic    826     //    else      ParticleHaveNoLoss(aParticle,"InverseRange");
894   }                                               827   }
895                                                   828 
896   G4double scaledrange,scaledKineticEnergy ;      829   G4double scaledrange,scaledKineticEnergy ;
897   G4bool isOut ;                                  830   G4bool isOut ;
898                                                   831 
899   G4int materialIndex = couple->GetIndex() ;      832   G4int materialIndex = couple->GetIndex() ;
900                                                   833 
901   if(materialIndex != oldIndex)                   834   if(materialIndex != oldIndex)
902   {                                               835   {
903     oldIndex = materialIndex ;                    836     oldIndex = materialIndex ;
904     rmin = (*inverseRangeTable)(materialIndex)    837     rmin = (*inverseRangeTable)(materialIndex)->
905                               GetLowEdgeEnergy    838                               GetLowEdgeEnergy(0) ;
906     rmax = (*inverseRangeTable)(materialIndex)    839     rmax = (*inverseRangeTable)(materialIndex)->
907                    GetLowEdgeEnergy(t->theNumb << 840                    GetLowEdgeEnergy(t.theNumberOfBins-2) ;
908     Thigh = (*inverseRangeTable)(materialIndex    841     Thigh = (*inverseRangeTable)(materialIndex)->
909                               GetValue(rmax,is    842                               GetValue(rmax,isOut) ;
910   }                                               843   }
911                                                   844 
912   scaledrange = range*Chargesquare*t->theMassR << 845   scaledrange = range*Chargesquare*t.theMassRatio ;
913                                                   846 
914   if(scaledrange < rmin)                          847   if(scaledrange < rmin)
915   {                                               848   {
916     scaledKineticEnergy = t->theLowestKineticE << 849     scaledKineticEnergy = t.theLowestKineticEnergy*
917                    scaledrange*scaledrange/(rm    850                    scaledrange*scaledrange/(rmin*rmin) ;
918   }                                               851   }
919   else                                            852   else
920   {                                               853   {
921     if(scaledrange < rmax)                        854     if(scaledrange < rmax)
922     {                                             855     {
923       scaledKineticEnergy = (*inverseRangeTabl    856       scaledKineticEnergy = (*inverseRangeTable)(materialIndex)->
924                               GetValue( scaled    857                               GetValue( scaledrange,isOut) ;
925     }                                             858     }
926     else                                          859     else
927     {                                             860     {
928       scaledKineticEnergy = Thigh +               861       scaledKineticEnergy = Thigh +
929                       (scaledrange-rmax)*         862                       (scaledrange-rmax)*
930                       (*dEdxTable)(materialInd    863                       (*dEdxTable)(materialIndex)->
931                                  GetValue(Thig    864                                  GetValue(Thigh,isOut) ;
932     }                                             865     }
933   }                                               866   }
934                                                   867 
935   return scaledKineticEnergy/t->theMassRatio ; << 868   return scaledKineticEnergy/t.theMassRatio ;
936 }                                                 869 }
937                                                   870 
938 //....oooOO0OOooo........oooOO0OOooo........oo    871 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
939                                                   872 
940 G4double G4EnergyLossTables::GetPreciseDEDX(      873 G4double G4EnergyLossTables::GetPreciseDEDX(
941     const G4ParticleDefinition *aParticle,        874     const G4ParticleDefinition *aParticle,
942     G4double KineticEnergy,                       875     G4double KineticEnergy,
943     const G4MaterialCutsCouple *couple)           876     const G4MaterialCutsCouple *couple)
944 {                                                 877 {
945   if (!t) t = new G4EnergyLossTablesHelper;    << 
946                                                   878 
947   if( aParticle != (const G4ParticleDefinition << 879   if( aParticle != lastParticle)
948   {                                               880   {
949     *t= GetTables(aParticle);                  << 881     t= GetTables(aParticle);
950     lastParticle = (G4ParticleDefinition*) aPa << 882     lastParticle = aParticle;
951     Chargesquare = (aParticle->GetPDGCharge())    883     Chargesquare = (aParticle->GetPDGCharge())*
952                    (aParticle->GetPDGCharge())    884                    (aParticle->GetPDGCharge())/
953                     QQPositron ;                  885                     QQPositron ;
954     oldIndex = -1 ;                               886     oldIndex = -1 ;
955   }                                               887   }
956   const G4PhysicsTable*  dEdxTable= t->theDEDX << 888   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
957   if ( !dEdxTable )                               889   if ( !dEdxTable )
958     return G4LossTableManager::Instance()->Get    890     return G4LossTableManager::Instance()->GetDEDX(aParticle,KineticEnergy,couple);
959                                                   891 
960   G4int materialIndex = couple->GetIndex();       892   G4int materialIndex = couple->GetIndex();
961   G4double scaledKineticEnergy = KineticEnergy << 893   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
962   G4double dEdx;                                  894   G4double dEdx;
963   G4bool isOut;                                   895   G4bool isOut;
964                                                   896 
965   if (scaledKineticEnergy<t->theLowestKineticE << 897   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
966                                                   898 
967      dEdx = std::sqrt(scaledKineticEnergy/t->t << 899      dEdx = std::sqrt(scaledKineticEnergy/t.theLowestKineticEnergy)
968             *(*dEdxTable)(materialIndex)->GetV    900             *(*dEdxTable)(materialIndex)->GetValue(
969               t->theLowestKineticEnergy,isOut) << 901               t.theLowestKineticEnergy,isOut);
970                                                   902 
971   } else if (scaledKineticEnergy>t->theHighest << 903   } else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
972                                                   904 
973      dEdx = (*dEdxTable)(materialIndex)->GetVa    905      dEdx = (*dEdxTable)(materialIndex)->GetValue(
974         t->theHighestKineticEnergy,isOut);     << 906         t.theHighestKineticEnergy,isOut);
975                                                   907 
976   } else {                                        908   } else {
977                                                   909 
978       dEdx = (*dEdxTable)(materialIndex)->GetV    910       dEdx = (*dEdxTable)(materialIndex)->GetValue(
979                           scaledKineticEnergy,    911                           scaledKineticEnergy,isOut) ;
980                                                   912 
981   }                                               913   }
982                                                   914 
983   return dEdx*Chargesquare;                       915   return dEdx*Chargesquare;
984 }                                                 916 }
985                                                   917 
986 //....oooOO0OOooo........oooOO0OOooo........oo    918 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
987                                                   919 
988 G4double G4EnergyLossTables::GetPreciseRangeFr    920 G4double G4EnergyLossTables::GetPreciseRangeFromEnergy(
989     const G4ParticleDefinition *aParticle,        921     const G4ParticleDefinition *aParticle,
990     G4double KineticEnergy,                       922     G4double KineticEnergy,
991     const G4MaterialCutsCouple *couple)           923     const G4MaterialCutsCouple *couple)
992 {                                                 924 {
993   if (!t) t = new G4EnergyLossTablesHelper;    << 925   if( aParticle != lastParticle)
994                                                << 
995   if( aParticle != (const G4ParticleDefinition << 
996   {                                               926   {
997     *t= GetTables(aParticle);                  << 927     t= GetTables(aParticle);
998     lastParticle = (G4ParticleDefinition*) aPa << 928     lastParticle = aParticle;
999     Chargesquare = (aParticle->GetPDGCharge())    929     Chargesquare = (aParticle->GetPDGCharge())*
1000                    (aParticle->GetPDGCharge()    930                    (aParticle->GetPDGCharge())/
1001                     QQPositron ;                 931                     QQPositron ;
1002     oldIndex = -1 ;                              932     oldIndex = -1 ;
1003   }                                              933   }
1004   const G4PhysicsTable* rangeTable= t->theRan << 934   const G4PhysicsTable* rangeTable= t.theRangeTable;
1005   const G4PhysicsTable*  dEdxTable= t->theDED << 935   const G4PhysicsTable*  dEdxTable= t.theDEDXTable;
1006   if ( !dEdxTable || !rangeTable)                936   if ( !dEdxTable || !rangeTable)
1007     return G4LossTableManager::Instance()->Ge    937     return G4LossTableManager::Instance()->GetDEDX(aParticle,KineticEnergy,couple);
1008                                                  938 
1009   G4int materialIndex = couple->GetIndex();      939   G4int materialIndex = couple->GetIndex();
1010                                                  940 
1011   G4double Thighr = t->theHighestKineticEnerg << 941   G4double Thighr = t.theHighestKineticEnergy*t.theLowestKineticEnergy/
1012                    (*rangeTable)(materialInde    942                    (*rangeTable)(materialIndex)->
1013                    GetLowEdgeEnergy(1) ;         943                    GetLowEdgeEnergy(1) ;
1014                                                  944 
1015   G4double scaledKineticEnergy = KineticEnerg << 945   G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
1016   G4double Range;                                946   G4double Range;
1017   G4bool isOut;                                  947   G4bool isOut;
1018                                                  948 
1019   if (scaledKineticEnergy<t->theLowestKinetic << 949   if (scaledKineticEnergy<t.theLowestKineticEnergy) {
1020                                                  950 
1021     Range = std::sqrt(scaledKineticEnergy/t-> << 951     Range = std::sqrt(scaledKineticEnergy/t.theLowestKineticEnergy)*
1022             (*rangeTable)(materialIndex)->Get    952             (*rangeTable)(materialIndex)->GetValue(
1023               t->theLowestKineticEnergy,isOut << 953               t.theLowestKineticEnergy,isOut);
1024                                                  954 
1025   } else if (scaledKineticEnergy>Thighr) {       955   } else if (scaledKineticEnergy>Thighr) {
1026                                                  956 
1027     Range = (*rangeTable)(materialIndex)->Get    957     Range = (*rangeTable)(materialIndex)->GetValue(
1028         Thighr,isOut)+                           958         Thighr,isOut)+
1029             (scaledKineticEnergy-Thighr)/        959             (scaledKineticEnergy-Thighr)/
1030             (*dEdxTable)(materialIndex)->GetV    960             (*dEdxTable)(materialIndex)->GetValue(
1031               Thighr,isOut);                     961               Thighr,isOut);
1032                                                  962 
1033   } else {                                       963   } else {
1034                                                  964 
1035      Range = (*rangeTable)(materialIndex)->Ge    965      Range = (*rangeTable)(materialIndex)->GetValue(
1036                        scaledKineticEnergy,is    966                        scaledKineticEnergy,isOut) ;
1037                                                  967 
1038   }                                              968   }
1039                                                  969 
1040   return Range/(Chargesquare*t->theMassRatio) << 970   return Range/(Chargesquare*t.theMassRatio);
1041 }                                                971 }
1042                                                  972 
1043 //....oooOO0OOooo........oooOO0OOooo........o    973 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1044                                                  974 
1045 void G4EnergyLossTables::CPRWarning()            975 void G4EnergyLossTables::CPRWarning()
1046 {                                                976 {
1047   if (let_counter <  let_max_num_warnings) {     977   if (let_counter <  let_max_num_warnings) {
1048                                                  978 
1049     G4cout << G4endl;                            979     G4cout << G4endl;
1050     G4cout << "##### G4EnergyLossTable WARNIN    980     G4cout << "##### G4EnergyLossTable WARNING: The obsolete interface is used!" << G4endl;
1051     G4cout << "##### RESULTS ARE NOT GARANTEE    981     G4cout << "##### RESULTS ARE NOT GARANTEED!" << G4endl;
1052     G4cout << "##### Please, substitute G4Mat    982     G4cout << "##### Please, substitute G4Material by G4MaterialCutsCouple" << G4endl;
1053     G4cout << "##### Obsolete interface will     983     G4cout << "##### Obsolete interface will be removed soon" << G4endl;
1054     G4cout << G4endl;                            984     G4cout << G4endl;
1055     let_counter++;                               985     let_counter++;
                                                   >> 986 //  if ((G4RegionStore::GetInstance())->size() > 1) {
                                                   >> 987 //     G4Exception("G4EnergyLossTables:: More than 1 region - table can't be accessed with obsolete interface");
                                                   >> 988 //     exit(1);
                                                   >> 989 //  }
1056                                                  990 
1057   } else if (let_counter == let_max_num_warni    991   } else if (let_counter == let_max_num_warnings) {
1058                                                  992 
1059     G4cout << "##### G4EnergyLossTable WARNIN    993     G4cout << "##### G4EnergyLossTable WARNING closed" << G4endl;
1060     let_counter++;                               994     let_counter++;
1061   }                                              995   }
1062 }                                                996 }
1063                                                  997 
1064 //....oooOO0OOooo........oooOO0OOooo........o    998 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1065                                                  999 
1066 void                                          << 1000 void G4EnergyLossTables::ParticleHaveNoLoss(const G4ParticleDefinition* aParticle, const G4String& q)
1067 G4EnergyLossTables::ParticleHaveNoLoss(const  << 
1068                const G4String& /*q*/)         << 
1069 {                                                1001 {
                                                   >> 1002   G4String s = "G4EnergyLossTables:: " + q + " table not found for "
                                                   >> 1003              + aParticle->GetParticleName() + "!";
                                                   >> 1004   G4Exception(s);
                                                   >> 1005   exit(1);
1070 }                                                1006 }
1071                                                  1007 
1072 //....oooOO0OOooo........oooOO0OOooo........o    1008 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1073                                                  1009