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 7.0)


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