Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/muons/src/G4MuBetheBlochModel.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/muons/src/G4MuBetheBlochModel.cc (Version 11.3.0) and /processes/electromagnetic/muons/src/G4MuBetheBlochModel.cc (Version 8.1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: G4MuBetheBlochModel.cc,v 1.22 2006/06/29 19:49:36 gunter Exp $
                                                   >>  27 // GEANT4 tag $Name: geant4-08-01 $
 26 //                                                 28 //
 27 // -------------------------------------------     29 // -------------------------------------------------------------------
 28 //                                                 30 //
 29 // GEANT4 Class header file                        31 // GEANT4 Class header file
 30 //                                                 32 //
 31 //                                                 33 //
 32 // File name:     G4MuBetheBlochModel              34 // File name:     G4MuBetheBlochModel
 33 //                                                 35 //
 34 // Author:        Vladimir Ivanchenko on base      36 // Author:        Vladimir Ivanchenko on base of Laszlo Urban code
 35 //                                                 37 //
 36 // Creation date: 09.08.2002                       38 // Creation date: 09.08.2002
 37 //                                                 39 //
 38 // Modifications:                                  40 // Modifications:
 39 //                                                 41 //
 40 // 04-12-02 Fix problem of G4DynamicParticle c     42 // 04-12-02 Fix problem of G4DynamicParticle constructor (V.Ivanchenko)
 41 // 23-12-02 Change interface in order to move      43 // 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
 42 // 27-01-03 Make models region aware (V.Ivanch     44 // 27-01-03 Make models region aware (V.Ivanchenko)
 43 // 13-02-03 Add name (V.Ivanchenko)                45 // 13-02-03 Add name (V.Ivanchenko)
 44 // 10-02-04 Calculation of radiative correctio     46 // 10-02-04 Calculation of radiative corrections using R.Kokoulin model (V.I)
 45 // 08-04-05 Major optimisation of internal int     47 // 08-04-05 Major optimisation of internal interfaces (V.Ivantchenko)
 46 // 12-04-05 Add usage of G4EmCorrections (V.Iv     48 // 12-04-05 Add usage of G4EmCorrections (V.Ivanchenko)
 47 // 13-02-06 ComputeCrossSectionPerElectron, Co     49 // 13-02-06 ComputeCrossSectionPerElectron, ComputeCrossSectionPerAtom (mma)
 48 //                                                 50 //
 49                                                    51 
 50 //                                                 52 //
 51 // -------------------------------------------     53 // -------------------------------------------------------------------
 52 //                                                 54 //
 53                                                    55 
                                                   >>  56 
 54 //....oooOO0OOooo........oooOO0OOooo........oo     57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 55 //....oooOO0OOooo........oooOO0OOooo........oo     58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 56                                                    59 
 57 #include "G4MuBetheBlochModel.hh"                  60 #include "G4MuBetheBlochModel.hh"
 58 #include "G4PhysicalConstants.hh"              << 
 59 #include "G4SystemOfUnits.hh"                  << 
 60 #include "Randomize.hh"                            61 #include "Randomize.hh"
 61 #include "G4Electron.hh"                           62 #include "G4Electron.hh"
 62 #include "G4LossTableManager.hh"                   63 #include "G4LossTableManager.hh"
 63 #include "G4EmCorrections.hh"                      64 #include "G4EmCorrections.hh"
 64 #include "G4ParticleChangeForLoss.hh"              65 #include "G4ParticleChangeForLoss.hh"
 65 #include "G4Log.hh"                            << 
 66 #include "G4Exp.hh"                            << 
 67 #include "G4DeltaAngle.hh"                     << 
 68                                                    66 
 69 G4double G4MuBetheBlochModel::xgi[]={ 0.0199,      67 G4double G4MuBetheBlochModel::xgi[]={ 0.0199, 0.1017, 0.2372, 0.4083, 0.5917,
 70                                       0.7628,      68                                       0.7628, 0.8983, 0.9801 };
 71                                                <<  69               
 72 G4double G4MuBetheBlochModel::wgi[]={ 0.0506,      70 G4double G4MuBetheBlochModel::wgi[]={ 0.0506, 0.1112, 0.1569, 0.1813, 0.1813,
 73                                       0.1569,      71                                       0.1569, 0.1112, 0.0506 };
 74                                                    72 
 75 //....oooOO0OOooo........oooOO0OOooo........oo     73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 76                                                    74 
                                                   >>  75 using namespace std;
                                                   >>  76 
 77 G4MuBetheBlochModel::G4MuBetheBlochModel(const     77 G4MuBetheBlochModel::G4MuBetheBlochModel(const G4ParticleDefinition* p,
 78                                          const     78                                          const G4String& nam)
 79   : G4VEmModel(nam),                               79   : G4VEmModel(nam),
 80     limitRadCorrection(250.*CLHEP::MeV),       <<  80   particle(0),
 81     limitKinEnergy(100.*CLHEP::keV),           <<  81   limitKinEnergy(100.*keV),
 82     logLimitKinEnergy(G4Log(limitKinEnergy)),  <<  82   logLimitKinEnergy(log(limitKinEnergy)),
 83     twoln10(2.0*G4Log(10.0)),                  <<  83   twoln10(2.0*log(10.0)),
 84     alphaprime(CLHEP::fine_structure_const/CLH <<  84   bg2lim(0.0169),
                                                   >>  85   taulim(8.4146e-3),
                                                   >>  86   alphaprime(fine_structure_const/twopi)
 85 {                                                  87 {
 86   theElectron = G4Electron::Electron();            88   theElectron = G4Electron::Electron();
 87   corr = G4LossTableManager::Instance()->EmCor     89   corr = G4LossTableManager::Instance()->EmCorrections();
 88   if(nullptr != p) { SetParticle(p); }         << 
 89 }                                              << 
 90                                                    90 
 91 //....oooOO0OOooo........oooOO0OOooo........oo <<  91   if(p) SetParticle(p);
 92                                                << 
 93 G4double G4MuBetheBlochModel::MinEnergyCut(con << 
 94                                            con << 
 95 {                                              << 
 96   return couple->GetMaterial()->GetIonisation( << 
 97 }                                                  92 }
 98                                                    93 
 99 //....oooOO0OOooo........oooOO0OOooo........oo <<  94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100                                                    95 
101 G4double G4MuBetheBlochModel::MaxSecondaryEner <<  96 G4MuBetheBlochModel::~G4MuBetheBlochModel()
102                                                <<  97 {}
103 {                                              << 
104   G4double tau  = kinEnergy/mass;              << 
105   G4double tmax = 2.0*CLHEP::electron_mass_c2* << 
106                   (1. + 2.0*(tau + 1.)*ratio + << 
107   return tmax;                                 << 
108 }                                              << 
109                                                    98 
110 //....oooOO0OOooo........oooOO0OOooo........oo     99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
111                                                   100 
112 void G4MuBetheBlochModel::SetParticle(const G4    101 void G4MuBetheBlochModel::SetParticle(const G4ParticleDefinition* p)
113 {                                                 102 {
114   if(nullptr == particle) {                    << 103   if(!particle) {
115     particle = p;                                 104     particle = p;
116     mass = particle->GetPDGMass();                105     mass = particle->GetPDGMass();
117     massSquare = mass*mass;                       106     massSquare = mass*mass;
118     ratio = CLHEP::electron_mass_c2/mass;      << 107     ratio = electron_mass_c2/mass;
119   }                                               108   }
120 }                                                 109 }
121                                                   110 
122 //....oooOO0OOooo........oooOO0OOooo........oo    111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123                                                   112 
                                                   >> 113 G4double G4MuBetheBlochModel::MinEnergyCut(const G4ParticleDefinition*,
                                                   >> 114                                            const G4MaterialCutsCouple* couple)
                                                   >> 115 {
                                                   >> 116   return couple->GetMaterial()->GetIonisation()->GetMeanExcitationEnergy();
                                                   >> 117 }
                                                   >> 118 
                                                   >> 119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 120 
124 void G4MuBetheBlochModel::Initialise(const G4P    121 void G4MuBetheBlochModel::Initialise(const G4ParticleDefinition* p,
125                                      const G4D    122                                      const G4DataVector&)
126 {                                                 123 {
127   SetParticle(p);                              << 124   if(p) SetParticle(p);
128   if(nullptr == fParticleChange) {             << 125 
129     fParticleChange = GetParticleChangeForLoss << 126   if(pParticleChange)
130     if(UseAngularGeneratorFlag() && nullptr == << 127     fParticleChange = reinterpret_cast<G4ParticleChangeForLoss*>
131       SetAngularDistribution(new G4DeltaAngle( << 128                                                              (pParticleChange);
132     }                                          << 129   else
133   }                                            << 130     fParticleChange = new G4ParticleChangeForLoss();
134 }                                                 131 }
135                                                   132 
136 //....oooOO0OOooo........oooOO0OOooo........oo    133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137                                                   134 
138 G4double G4MuBetheBlochModel::ComputeCrossSect    135 G4double G4MuBetheBlochModel::ComputeCrossSectionPerElectron(
139                                            con    136                                            const G4ParticleDefinition* p,
140                                                   137                                                  G4double kineticEnergy,
141                                                   138                                                  G4double cutEnergy,
142                                                   139                                                  G4double maxKinEnergy)
143 {                                                 140 {
144   G4double cross = 0.0;                           141   G4double cross = 0.0;
145   G4double tmax = MaxSecondaryEnergy(p, kineti    142   G4double tmax = MaxSecondaryEnergy(p, kineticEnergy);
146   G4double maxEnergy = std::min(tmax, maxKinEn << 143   G4double maxEnergy = min(tmax,maxKinEnergy);
147   if(cutEnergy < maxEnergy) {                     144   if(cutEnergy < maxEnergy) {
148                                                   145 
149     G4double totEnergy = kineticEnergy + mass;    146     G4double totEnergy = kineticEnergy + mass;
150     G4double energy2 = totEnergy*totEnergy;    << 147     G4double energy2   = totEnergy*totEnergy;
151     G4double beta2 = kineticEnergy*(kineticEne << 148     G4double beta2     = kineticEnergy*(kineticEnergy + 2.0*mass)/energy2;
152                                                   149 
153     cross = 1.0/cutEnergy - 1.0/maxEnergy -    << 150     cross = 1.0/cutEnergy - 1.0/maxEnergy - beta2*log(maxEnergy/cutEnergy)/tmax
154       beta2*G4Log(maxEnergy/cutEnergy)/tmax +  << 151           + 0.5*(maxEnergy - cutEnergy)/energy2;
155       0.5*(maxEnergy - cutEnergy)/energy2;     << 
156                                                   152 
157     // radiative corrections of R. Kokoulin       153     // radiative corrections of R. Kokoulin
158     if (maxEnergy > limitKinEnergy && kineticE << 154     if (maxEnergy > limitKinEnergy) {
159                                                   155 
160       G4double logtmax = G4Log(maxEnergy);     << 156       G4double logtmax = log(maxEnergy);
161       G4double logtmin = G4Log(std::max(cutEne << 157       G4double logtmin = log(max(cutEnergy,limitKinEnergy));
162       G4double logstep = logtmax - logtmin;       158       G4double logstep = logtmax - logtmin;
163       G4double dcross  = 0.0;                     159       G4double dcross  = 0.0;
164                                                   160 
165       for (G4int ll=0; ll<8; ++ll) {           << 161       for (G4int ll=0; ll<8; ll++)
166         G4double ep = G4Exp(logtmin + xgi[ll]* << 162       {
167         G4double a1 = G4Log(1.0 + 2.0*ep/CLHEP << 163         G4double ep = exp(logtmin + xgi[ll]*logstep);
168         G4double a3 = G4Log(4.0*totEnergy*(tot << 164         G4double a1 = log(1.0 + 2.0*ep/electron_mass_c2);
                                                   >> 165         G4double a3 = log(4.0*totEnergy*(totEnergy - ep)/massSquare);
169         dcross += wgi[ll]*(1.0/ep - beta2/tmax    166         dcross += wgi[ll]*(1.0/ep - beta2/tmax + 0.5*ep/energy2)*a1*(a3 - a1);
170       }                                           167       }
                                                   >> 168 
171       cross += dcross*logstep*alphaprime;         169       cross += dcross*logstep*alphaprime;
172     }                                             170     }
173     cross *= CLHEP::twopi_mc2_rcl2/beta2;      << 171 
                                                   >> 172     cross *= twopi_mc2_rcl2/beta2;
                                                   >> 173 
174   }                                               174   }
                                                   >> 175 
175   //  G4cout << "tmin= " << cutEnergy << " tma    176   //  G4cout << "tmin= " << cutEnergy << " tmax= " << tmax
176   //         << " cross= " << cross << G4endl; << 177   //         << " cross= " << cross << G4endl;
                                                   >> 178   
177   return cross;                                   179   return cross;
178 }                                                 180 }
179                                                   181 
180 //....oooOO0OOooo........oooOO0OOooo........oo    182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
181                                                   183 
182 G4double G4MuBetheBlochModel::ComputeCrossSect    184 G4double G4MuBetheBlochModel::ComputeCrossSectionPerAtom(
183                                            con    185                                            const G4ParticleDefinition* p,
184                                                   186                                                  G4double kineticEnergy,
185                                                << 187              G4double Z, G4double,
186                                                   188                                                  G4double cutEnergy,
187                                                   189                                                  G4double maxEnergy)
188 {                                                 190 {
189   G4double cross = Z*ComputeCrossSectionPerEle    191   G4double cross = Z*ComputeCrossSectionPerElectron
190                                          (p,ki    192                                          (p,kineticEnergy,cutEnergy,maxEnergy);
191   return cross;                                   193   return cross;
192 }                                                 194 }
193                                                   195 
194 //....oooOO0OOooo........oooOO0OOooo........oo    196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
195                                                   197 
196 G4double G4MuBetheBlochModel::CrossSectionPerV    198 G4double G4MuBetheBlochModel::CrossSectionPerVolume(
197                                            con << 199              const G4Material* material,
198                                            con    200                                            const G4ParticleDefinition* p,
199                                                   201                                                  G4double kineticEnergy,
200                                                   202                                                  G4double cutEnergy,
201                                                   203                                                  G4double maxEnergy)
202 {                                                 204 {
203   G4double eDensity = material->GetElectronDen    205   G4double eDensity = material->GetElectronDensity();
204   G4double cross = eDensity*ComputeCrossSectio    206   G4double cross = eDensity*ComputeCrossSectionPerElectron
205                                          (p,ki    207                                          (p,kineticEnergy,cutEnergy,maxEnergy);
206   return cross;                                   208   return cross;
207 }                                                 209 }
208                                                   210 
209 //....oooOO0OOooo........oooOO0OOooo........oo    211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210                                                   212 
211 G4double G4MuBetheBlochModel::ComputeDEDXPerVo    213 G4double G4MuBetheBlochModel::ComputeDEDXPerVolume(const G4Material* material,
212                                                << 214               const G4ParticleDefinition* p,
213                                                << 215               G4double kineticEnergy,
214                                                << 216               G4double cut)
215 {                                                 217 {
216   G4double tmax  = MaxSecondaryEnergy(p, kinet    218   G4double tmax  = MaxSecondaryEnergy(p, kineticEnergy);
217   G4double tau   = kineticEnergy/mass;            219   G4double tau   = kineticEnergy/mass;
218   G4double cutEnergy = std::min(cut, tmax);    << 220   G4double cutEnergy = min(cut,tmax);
219   G4double gam   = tau + 1.0;                     221   G4double gam   = tau + 1.0;
220   G4double bg2   = tau * (tau+2.0);               222   G4double bg2   = tau * (tau+2.0);
221   G4double beta2 = bg2/(gam*gam);                 223   G4double beta2 = bg2/(gam*gam);
222                                                   224 
223   G4double eexc  = material->GetIonisation()->    225   G4double eexc  = material->GetIonisation()->GetMeanExcitationEnergy();
224   G4double eexc2 = eexc*eexc;                     226   G4double eexc2 = eexc*eexc;
                                                   >> 227   G4double cden  = material->GetIonisation()->GetCdensity();
                                                   >> 228   G4double mden  = material->GetIonisation()->GetMdensity();
                                                   >> 229   G4double aden  = material->GetIonisation()->GetAdensity();
                                                   >> 230   G4double x0den = material->GetIonisation()->GetX0density();
                                                   >> 231   G4double x1den = material->GetIonisation()->GetX1density();
225                                                   232 
226   G4double eDensity = material->GetElectronDen    233   G4double eDensity = material->GetElectronDensity();
227                                                   234 
228   G4double dedx = G4Log(2.0*CLHEP::electron_ma << 235   G4double dedx = log(2.0*electron_mass_c2*bg2*cutEnergy/eexc2)
229                  -(1.0 + cutEnergy/tmax)*beta2    236                  -(1.0 + cutEnergy/tmax)*beta2;
230                                                   237 
231   G4double totEnergy = kineticEnergy + mass;      238   G4double totEnergy = kineticEnergy + mass;
232   G4double del = 0.5*cutEnergy/totEnergy;         239   G4double del = 0.5*cutEnergy/totEnergy;
233   dedx += del*del;                                240   dedx += del*del;
234                                                   241 
235   // density correction                           242   // density correction
236   G4double x = G4Log(bg2)/twoln10;             << 243   G4double x = log(bg2)/twoln10;
237   dedx -= material->GetIonisation()->DensityCo << 244   if ( x >= x0den ) {
                                                   >> 245     dedx -= twoln10*x - cden ;
                                                   >> 246     if ( x < x1den ) dedx -= aden*pow((x1den-x),mden) ;
                                                   >> 247   }
238                                                   248 
239   // shell and high order corrections          << 249   // shell correction
240   dedx -= 2.0*corr->ShellCorrection(p,material    250   dedx -= 2.0*corr->ShellCorrection(p,material,kineticEnergy);
241                                                   251 
                                                   >> 252   // now compute the total ionization loss
                                                   >> 253 
                                                   >> 254   if (dedx < 0.0) dedx = 0.0 ;
                                                   >> 255 
242   // radiative corrections of R. Kokoulin         256   // radiative corrections of R. Kokoulin
243   if (cutEnergy > limitKinEnergy && kineticEne << 257   if (cutEnergy > limitKinEnergy) {
244                                                   258 
245     G4double logtmax = G4Log(cutEnergy);       << 259     G4double logtmax = log(cutEnergy);
246     G4double logstep = logtmax - logLimitKinEn    260     G4double logstep = logtmax - logLimitKinEnergy;
247     G4double dloss = 0.0;                         261     G4double dloss = 0.0;
248     G4double ftot2= 0.5/(totEnergy*totEnergy);    262     G4double ftot2= 0.5/(totEnergy*totEnergy);
249                                                   263 
250     for (G4int ll=0; ll<8; ++ll) {             << 264     for (G4int ll=0; ll<8; ll++)
251       G4double ep = G4Exp(logLimitKinEnergy +  << 265     {
252       G4double a1 = G4Log(1.0 + 2.0*ep/CLHEP:: << 266       G4double ep = exp(logLimitKinEnergy + xgi[ll]*logstep);
253       G4double a3 = G4Log(4.0*totEnergy*(totEn << 267       G4double a1 = log(1.0 + 2.0*ep/electron_mass_c2);
                                                   >> 268       G4double a3 = log(4.0*totEnergy*(totEnergy - ep)/massSquare);
254       dloss += wgi[ll]*(1.0 - beta2*ep/tmax +     269       dloss += wgi[ll]*(1.0 - beta2*ep/tmax + ep*ep*ftot2)*a1*(a3 - a1);
255     }                                             270     }
256     dedx += dloss*logstep*alphaprime;             271     dedx += dloss*logstep*alphaprime;
257   }                                               272   }
258   dedx *= CLHEP::twopi_mc2_rcl2*eDensity/beta2 << 273 
                                                   >> 274   dedx *= twopi_mc2_rcl2*eDensity/beta2;
259                                                   275 
260   //High order corrections                        276   //High order corrections
261   dedx += corr->HighOrderCorrections(p,materia << 277   dedx += corr->HighOrderCorrections(p,material,kineticEnergy);
262   dedx = std::max(dedx, 0.);                   << 278 
263   return dedx;                                    279   return dedx;
264 }                                                 280 }
265                                                   281 
266 //....oooOO0OOooo........oooOO0OOooo........oo    282 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
267                                                   283 
268 void G4MuBetheBlochModel::SampleSecondaries(   << 284 vector<G4DynamicParticle*>* G4MuBetheBlochModel::SampleSecondaries(
269                           std::vector<G4Dynami << 285                              const G4MaterialCutsCouple*,
270         const G4MaterialCutsCouple* couple,    << 286                              const G4DynamicParticle* dp,
271         const G4DynamicParticle* dp,           << 287                                    G4double minKinEnergy,
272         G4double minKinEnergy,                 << 288                                    G4double maxEnergy)
273         G4double maxEnergy)                    << 
274 {                                                 289 {
275   G4double kineticEnergy = dp->GetKineticEnerg << 290   G4double tmax = MaxSecondaryKinEnergy(dp);
276   G4double tmax = MaxSecondaryEnergy(dp->GetDe << 291   G4double maxKinEnergy = min(maxEnergy,tmax);
277   G4double maxKinEnergy = std::min(maxEnergy,  << 292   if(minKinEnergy >= maxKinEnergy) return 0;
278   if(minKinEnergy >= maxKinEnergy) { return; } << 
279                                                   293 
280   G4double totEnergy = kineticEnergy + mass;   << 294   G4double kineticEnergy = dp->GetKineticEnergy();
281   G4double etot2 = totEnergy*totEnergy;        << 295   G4double totEnergy     = kineticEnergy + mass;
282   G4double beta2 = kineticEnergy*(kineticEnerg << 296   G4double etot2         = totEnergy*totEnergy;
                                                   >> 297   G4double beta2         = kineticEnergy*(kineticEnergy + 2.0*mass)/etot2;
283                                                   298  
284   G4double grej  = 1.;                            299   G4double grej  = 1.;
285   G4bool radC = (tmax > limitKinEnergy && kine << 300   if(tmax > limitKinEnergy) {
286   if(radC) {                                   << 301     G4double a0    = log(2.*totEnergy/mass);
287     G4double a0 = G4Log(2.*totEnergy/mass);    << 302     grej  += alphaprime*a0*a0;
288     grej += alphaprime*a0*a0;                  << 
289   }                                               303   }
290                                                   304 
291   G4double tkin, f;                            << 305   G4double deltaKinEnergy, f;
292                                                   306 
293   // sampling follows ...                         307   // sampling follows ...
294   do {                                            308   do {
295     G4double q = G4UniformRand();                 309     G4double q = G4UniformRand();
296     tkin = minKinEnergy*maxKinEnergy/(minKinEn << 310     deltaKinEnergy = minKinEnergy*maxKinEnergy
297     f = 1.0 - beta2*tkin/tmax + 0.5*tkin*tkin/ << 311                     /(minKinEnergy*(1.0 - q) + maxKinEnergy*q);
                                                   >> 312 
                                                   >> 313 
                                                   >> 314     f = 1.0 - beta2*deltaKinEnergy/tmax 
                                                   >> 315             + 0.5*deltaKinEnergy*deltaKinEnergy/etot2;
298                                                   316 
299     if(radC && tkin > limitKinEnergy) {        << 317     if(deltaKinEnergy > limitKinEnergy) {
300       G4double a1 = G4Log(1.0 + 2.0*tkin/CLHEP << 318       G4double a1 = log(1.0 + 2.0*deltaKinEnergy/electron_mass_c2);
301       G4double a3 = G4Log(4.0*totEnergy*(totEn << 319       G4double a3 = log(4.0*totEnergy*(totEnergy - deltaKinEnergy)/massSquare);
302       f *= (1. + alphaprime*a1*(a3 - a1));        320       f *= (1. + alphaprime*a1*(a3 - a1));
303     }                                             321     }
304                                                   322 
305     if(f > grej) {                                323     if(f > grej) {
306         G4cout << "G4MuBetheBlochModel::Sample    324         G4cout << "G4MuBetheBlochModel::SampleSecondary Warning! "
307                << "Majorant " << grej << " < "    325                << "Majorant " << grej << " < "
308                << f << " for edelta= " << tkin << 326                << f << " for edelta= " << deltaKinEnergy
309                << " tmin= " << minKinEnergy <<    327                << " tmin= " << minKinEnergy << " max= " << maxKinEnergy
310                << G4endl;                         328                << G4endl;
311     }                                             329     }
312     // Loop checking, 03-Aug-2015, Vladimir Iv << 330 
                                                   >> 331 
313   } while( grej*G4UniformRand() > f );            332   } while( grej*G4UniformRand() > f );
314                                                   333 
315   G4ThreeVector deltaDirection;                << 334   G4double deltaMomentum =
                                                   >> 335            sqrt(deltaKinEnergy * (deltaKinEnergy + 2.0*electron_mass_c2));
                                                   >> 336   G4double totalMomentum = totEnergy*sqrt(beta2);
                                                   >> 337   G4double cost = deltaKinEnergy * (totEnergy + electron_mass_c2) /
                                                   >> 338                                    (deltaMomentum * totalMomentum);
                                                   >> 339 
                                                   >> 340   G4double sint = sqrt(1.0 - cost*cost);
                                                   >> 341 
                                                   >> 342   G4double phi = twopi * G4UniformRand() ;
                                                   >> 343 
                                                   >> 344   G4ThreeVector deltaDirection(sint*cos(phi),sint*sin(phi), cost) ;
                                                   >> 345   G4ThreeVector direction = dp->GetMomentumDirection();
                                                   >> 346   deltaDirection.rotateUz(direction);
316                                                   347 
317   if(UseAngularGeneratorFlag()) {              << 348   // primary change
318     const G4Material* mat = couple->GetMateria << 349   kineticEnergy -= deltaKinEnergy;
319     deltaDirection = GetAngularDistribution()- << 350   G4ThreeVector dir = totalMomentum*direction - deltaMomentum*deltaDirection;
320                      SelectRandomAtomNumber(ma << 351   direction = dir.unit();
321   } else {                                     << 352   fParticleChange->SetProposedKineticEnergy(kineticEnergy);
322                                                << 353   fParticleChange->SetProposedMomentumDirection(direction);
323     G4double deltaMom = std::sqrt(tkin * (tkin << 
324     G4double totalMom = totEnergy*std::sqrt(be << 
325     G4double cost = tkin * (totEnergy + CLHEP: << 
326       (deltaMom * totalMom);                   << 
327     cost = std::min(cost, 1.0);                << 
328     const G4double sint = std::sqrt((1.0 - cos << 
329     const G4double phi = twopi*G4UniformRand() << 
330                                                   354 
331     deltaDirection.set(sint*std::cos(phi),sint << 
332     deltaDirection.rotateUz(dp->GetMomentumDir << 
333   }                                            << 
334   // create G4DynamicParticle object for delta    355   // create G4DynamicParticle object for delta ray
335   auto delta = new G4DynamicParticle(theElectr << 356   G4DynamicParticle* delta = new G4DynamicParticle(theElectron,
                                                   >> 357                                                  deltaDirection,deltaKinEnergy);
                                                   >> 358   vector<G4DynamicParticle*>* vdp = new vector<G4DynamicParticle*>;
336   vdp->push_back(delta);                          359   vdp->push_back(delta);
337                                                   360 
338   // primary change                            << 361   return vdp;
339   kineticEnergy -= tkin;                       << 
340   G4ThreeVector dir = dp->GetMomentum() - delt << 
341   dir = dir.unit();                            << 
342   fParticleChange->SetProposedKineticEnergy(ki << 
343   fParticleChange->SetProposedMomentumDirectio << 
344 }                                                 362 }
345                                                   363 
346 //....oooOO0OOooo........oooOO0OOooo........oo    364 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
347                                                   365