Geant4 Cross Reference

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


  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 //
                                                   >>  23 // $Id: G4MuPairProductionModel.cc,v 1.13 2003/10/21 13:30:05 maire Exp $
                                                   >>  24 // GEANT4 tag $Name: geant4-06-00-patch-01 $
 26 //                                                 25 //
 27 // -------------------------------------------     26 // -------------------------------------------------------------------
 28 //                                                 27 //
 29 // GEANT4 Class file                               28 // GEANT4 Class file
 30 //                                                 29 //
 31 //                                                 30 //
 32 // File name:     G4MuPairProductionModel          31 // File name:     G4MuPairProductionModel
 33 //                                                 32 //
 34 // Author:        Vladimir Ivanchenko on base      33 // Author:        Vladimir Ivanchenko on base of Laszlo Urban code
 35 //                                                 34 //
 36 // Creation date: 24.06.2002                       35 // Creation date: 24.06.2002
 37 //                                                 36 //
 38 // Modifications:                                  37 // Modifications:
 39 //                                                 38 //
 40 // 04-12-02 Change G4DynamicParticle construct     39 // 04-12-02 Change G4DynamicParticle constructor in PostStep (V.Ivanchenko)
 41 // 23-12-02 Change interface in order to move      40 // 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
 42 // 24-01-03 Fix for compounds (V.Ivanchenko)       41 // 24-01-03 Fix for compounds (V.Ivanchenko)
 43 // 27-01-03 Make models region aware (V.Ivanch     42 // 27-01-03 Make models region aware (V.Ivanchenko)
 44 // 13-02-03 Add model (V.Ivanchenko)               43 // 13-02-03 Add model (V.Ivanchenko)
 45 // 06-06-03 Fix in cross section calculation f     44 // 06-06-03 Fix in cross section calculation for high energy (V.Ivanchenko)
 46 // 20-10-03 2*xi in ComputeDDMicroscopicCrossS     45 // 20-10-03 2*xi in ComputeDDMicroscopicCrossSection   (R.Kokoulin)
 47 //          8 integration points in ComputeDMi <<  46 //          8 integration points in ComputeDMicroscopicCrossSection 
 48 // 12-01-04 Take min cut of e- and e+ not its  << 
 49 // 10-02-04 Update parameterisation using R.Ko << 
 50 // 28-04-04 For complex materials repeat calcu << 
 51 //          material (V.Ivanchenko)            << 
 52 // 01-11-04 Fix bug inside ComputeDMicroscopic << 
 53 // 08-04-05 Major optimisation of internal int << 
 54 // 03-08-05 Add SetParticle method (V.Ivantche << 
 55 // 23-10-05 Add protection in sampling of e+e- << 
 56 //          low cuts (V.Ivantchenko)           << 
 57 // 13-02-06 Add ComputeCrossSectionPerAtom (mm << 
 58 // 24-04-07 Add protection in SelectRandomAtom << 
 59 // 12-05-06 Updated sampling (use cut) in Sele << 
 60 // 11-10-07 Add ignoreCut flag (V.Ivanchenko)  << 
 61                                                    47 
 62 //                                                 48 //
 63 // Class Description:                              49 // Class Description:
 64 //                                                 50 //
 65 //                                                 51 //
 66 // -------------------------------------------     52 // -------------------------------------------------------------------
 67 //                                                 53 //
 68 //....oooOO0OOooo........oooOO0OOooo........oo     54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 69 //....oooOO0OOooo........oooOO0OOooo........oo     55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70                                                    56 
 71 #include "G4MuPairProductionModel.hh"              57 #include "G4MuPairProductionModel.hh"
 72 #include "G4PhysicalConstants.hh"              << 
 73 #include "G4SystemOfUnits.hh"                  << 
 74 #include "G4EmParameters.hh"                   << 
 75 #include "G4Electron.hh"                           58 #include "G4Electron.hh"
 76 #include "G4Positron.hh"                           59 #include "G4Positron.hh"
 77 #include "G4MuonMinus.hh"                          60 #include "G4MuonMinus.hh"
 78 #include "G4MuonPlus.hh"                           61 #include "G4MuonPlus.hh"
 79 #include "Randomize.hh"                            62 #include "Randomize.hh"
 80 #include "G4Material.hh"                           63 #include "G4Material.hh"
 81 #include "G4Element.hh"                            64 #include "G4Element.hh"
 82 #include "G4ElementVector.hh"                      65 #include "G4ElementVector.hh"
 83 #include "G4ElementDataRegistry.hh"            << 
 84 #include "G4ProductionCutsTable.hh"                66 #include "G4ProductionCutsTable.hh"
 85 #include "G4ParticleChangeForLoss.hh"          << 
 86 #include "G4ModifiedMephi.hh"                  << 
 87 #include "G4Log.hh"                            << 
 88 #include "G4Exp.hh"                            << 
 89 #include "G4AutoLock.hh"                       << 
 90                                                << 
 91 #include <iostream>                            << 
 92 #include <fstream>                             << 
 93                                                    67 
 94 //....oooOO0OOooo........oooOO0OOooo........oo     68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 95                                                    69 
 96 const G4int G4MuPairProductionModel::ZDATPAIR[ <<  70 // static members
                                                   >>  71 //
                                                   >>  72 G4double G4MuPairProductionModel::zdat[]={1.,4.,13.,29.,92.};
                                                   >>  73 G4double G4MuPairProductionModel::adat[]={1.01,9.01,26.98,63.55,238.03};
                                                   >>  74 G4double G4MuPairProductionModel::tdat[]={1.e3,1.e4,1.e5,1.e6,1.e7,1.e8,
                                                   >>  75                                           1.e9,1.e10};
 97                                                    76 
 98 const G4double G4MuPairProductionModel::xgi[]  <<  77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 99     0.0198550717512320, 0.1016667612931865, 0. << 
100     0.5917173212478250, 0.7627662049581645, 0. << 
101   };                                           << 
102                                                    78 
103 const G4double G4MuPairProductionModel::wgi[]  <<  79 G4MuPairProductionModel::G4MuPairProductionModel(const G4ParticleDefinition*,
104     0.0506142681451880, 0.1111905172266870, 0. <<  80                                                  const G4String& nam)
105     0.1813418916891810, 0.1568533229389435, 0. <<  81   : G4VEmModel(nam),
106   };                                           <<  82   minPairEnergy(4.*electron_mass_c2),
                                                   >>  83   highKinEnergy(1000000.*TeV),
                                                   >>  84   lowKinEnergy(minPairEnergy),
                                                   >>  85   nzdat(5),
                                                   >>  86   ntdat(8),
                                                   >>  87   NBIN(1000),
                                                   >>  88   samplingTablesAreFilled(false)
                                                   >>  89 { }
107                                                    90 
108 namespace                                      <<  91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109 {                                              << 
110   G4Mutex theMuPairMutex = G4MUTEX_INITIALIZER << 
111                                                    92 
112   const G4double ak1 = 6.9;                    <<  93 G4MuPairProductionModel::~G4MuPairProductionModel()
113   const G4double ak2 = 1.0;                    <<  94 {
                                                   >>  95   size_t n = partialSumSigma.size();
                                                   >>  96   if(n > 0) {
                                                   >>  97     for(size_t i=0; i<n; i++) {
                                                   >>  98       delete partialSumSigma[i];
                                                   >>  99     }
                                                   >> 100   }
114 }                                                 101 }
115                                                   102 
116 //....oooOO0OOooo........oooOO0OOooo........oo    103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117                                                   104 
118 G4MuPairProductionModel::G4MuPairProductionMod << 105 G4double G4MuPairProductionModel::HighEnergyLimit(const G4ParticleDefinition*)
119                                                << 
120   : G4VEmModel(nam),                           << 
121   factorForCross(CLHEP::fine_structure_const*C << 
122      CLHEP::classic_electr_radius*CLHEP::class << 
123      4./(3.*CLHEP::pi)),                       << 
124   sqrte(std::sqrt(G4Exp(1.))),                 << 
125   minPairEnergy(4.*CLHEP::electron_mass_c2),   << 
126   lowestKinEnergy(0.85*CLHEP::GeV)             << 
127 {                                                 106 {
128   nist = G4NistManager::Instance();            << 107   return highKinEnergy;
129                                                << 
130   theElectron = G4Electron::Electron();        << 
131   thePositron = G4Positron::Positron();        << 
132                                                << 
133   if(nullptr != p) {                           << 
134     SetParticle(p);                            << 
135     lowestKinEnergy = std::max(lowestKinEnergy << 
136   }                                            << 
137   emin = lowestKinEnergy;                      << 
138   emax = emin*10000.;                          << 
139   SetAngularDistribution(new G4ModifiedMephi() << 
140 }                                                 108 }
141                                                   109 
142 //....oooOO0OOooo........oooOO0OOooo........oo    110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143                                                   111 
144 G4double G4MuPairProductionModel::MinPrimaryEn << 112 G4double G4MuPairProductionModel::LowEnergyLimit(const G4ParticleDefinition*)
145                                                << 
146                                                << 
147 {                                                 113 {
148   return std::max(lowestKinEnergy, cut);       << 114   return lowKinEnergy;
149 }                                                 115 }
150                                                   116 
151 //....oooOO0OOooo........oooOO0OOooo........oo    117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152                                                   118 
153 void G4MuPairProductionModel::Initialise(const << 119 G4double G4MuPairProductionModel::MinEnergyCut(const G4ParticleDefinition*,
154                                          const << 120                                             const G4MaterialCutsCouple* couple)
155 {                                              << 121 {
156   SetParticle(p);                              << 
157                                                   122 
158   if (nullptr == fParticleChange) {            << 123   size_t index = couple->GetIndex();
159     fParticleChange = GetParticleChangeForLoss << 124   const G4ProductionCutsTable* theCoupleTable =
                                                   >> 125         G4ProductionCutsTable::GetProductionCutsTable();
160                                                   126 
161     // define scale of internal table for each << 127   G4double eCut = (*(theCoupleTable->GetEnergyCutsVector(1)))[index];
162     if (0 == nbine) {                          << 128   G4double pCut = (*(theCoupleTable->GetEnergyCutsVector(2)))[index];
163       emin = std::max(lowestKinEnergy, LowEner << 129   G4double x = 2*electron_mass_c2 + eCut + pCut;
164       emax = std::max(HighEnergyLimit(), emin* << 130   if(x < minPairEnergy) x = minPairEnergy;
165       nbine = std::size_t(nYBinPerDecade*std:: << 
166       if(nbine < 3) { nbine = 3; }             << 
167                                                   131 
168       ymin = G4Log(minPairEnergy/emin);        << 132  //// if (eCut < highKinEnergy && pCut < highKinEnergy) {
169       dy = -ymin/G4double(nbiny);              << 133  ////   x +=  eCut + pCut;
170     }                                          << 134  //// } else {
171     if (p == particle) {                       << 135  ////   x = 0.5*highKinEnergy;
172       G4int pdg = std::abs(p->GetPDGEncoding() << 136  //// }
173       if (pdg == 2212) {                       << 137 
174   dataName = "pEEPairProd";                    << 138   return x;
175       } else if (pdg == 321) {                 << 139 }
176   dataName = "kaonEEPairProd";                 << 
177       } else if (pdg == 211) {                 << 
178   dataName = "pionEEPairProd";                 << 
179       } else if (pdg == 11) {                  << 
180   dataName = "eEEPairProd";                    << 
181       } else if (pdg == 13) {                  << 
182         if (GetName() == "muToMuonPairProd") { << 
183           dataName = "muMuMuPairProd";         << 
184   } else {                                     << 
185     dataName = "muEEPairProd";                 << 
186   }                                            << 
187       }                                        << 
188     }                                          << 
189   }                                            << 
190                                                   140 
191   // for low-energy application this process s << 141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
192   if(lowestKinEnergy >= HighEnergyLimit()) { r << 
193                                                   142 
194   if (p == particle) {                         << 143 G4bool G4MuPairProductionModel::IsInCharge(const G4ParticleDefinition* p)
195     fElementData =                             << 144 {
196       G4ElementDataRegistry::Instance()->GetEl << 145   return (p == G4MuonMinus::MuonMinus() || p == G4MuonPlus::MuonPlus());
197     if (nullptr == fElementData) {             << 
198       G4AutoLock l(&theMuPairMutex);           << 
199       fElementData =                           << 
200   G4ElementDataRegistry::Instance()->GetElemen << 
201       if (nullptr == fElementData) {           << 
202   fElementData = new G4ElementData(NZDATPAIR); << 
203   fElementData->SetName(dataName);             << 
204       }                                        << 
205       G4bool useDataFile = G4EmParameters::Ins << 
206       if (useDataFile)  { useDataFile = Retrie << 
207       if (!useDataFile) { MakeSamplingTables() << 
208       if (fTableToFile) { StoreTables(); }     << 
209       l.unlock();                              << 
210     }                                          << 
211     if (IsMaster()) {                          << 
212       InitialiseElementSelectors(p, cuts);     << 
213     }                                          << 
214   }                                            << 
215 }                                                 146 }
216                                                   147 
217 //....oooOO0OOooo........oooOO0OOooo........oo << 148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
218                                                   149 
219 void G4MuPairProductionModel::InitialiseLocal( << 150 void G4MuPairProductionModel::Initialise(const G4ParticleDefinition*,
220                                                << 151                                          const G4DataVector& cuts)
221 {                                                 152 {
222   if(p == particle && lowestKinEnergy < HighEn << 153   const G4ProductionCutsTable* theCoupleTable =
223     SetElementSelectors(masterModel->GetElemen << 154         G4ProductionCutsTable::GetProductionCutsTable();
                                                   >> 155   size_t numOfCouples = theCoupleTable->GetTableSize();
                                                   >> 156   G4double fixedEnergy = sqrt(lowKinEnergy*highKinEnergy);
                                                   >> 157 
                                                   >> 158   for (size_t ii=0; ii<partialSumSigma.size(); ii++) {
                                                   >> 159     G4DataVector* a=partialSumSigma[ii];
                                                   >> 160     if ( a )  delete a;
                                                   >> 161   }
                                                   >> 162   partialSumSigma.clear();
                                                   >> 163   for (size_t i=0; i<numOfCouples; i++) {
                                                   >> 164     const G4MaterialCutsCouple* couple=theCoupleTable->GetMaterialCutsCouple(i);
                                                   >> 165     const G4Material* material = couple->GetMaterial();
                                                   >> 166     G4DataVector* dv = ComputePartialSumSigma(material, fixedEnergy,
                                                   >> 167                              std::min(cuts[i], 0.25*highKinEnergy));
                                                   >> 168     partialSumSigma.push_back(dv);
224   }                                               169   }
                                                   >> 170   if (!samplingTablesAreFilled) MakeSamplingTables();
225 }                                                 171 }
226                                                   172 
227 //....oooOO0OOooo........oooOO0OOooo........oo    173 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
228                                                   174 
229 G4double G4MuPairProductionModel::ComputeDEDXP << 175 G4double 
230                                                << 176 G4MuPairProductionModel::ComputeDEDX(const G4MaterialCutsCouple* couple,
231                                                << 177                                      const G4ParticleDefinition*,
232                                                << 178                                      G4double kineticEnergy, G4double cutEnergy)
233                                                << 
234 {                                                 179 {
235   G4double dedx = 0.0;                            180   G4double dedx = 0.0;
236   if (cutEnergy <= minPairEnergy || kineticEne << 181   if (minPairEnergy >= cutEnergy) return dedx;
237     { return dedx; }                           << 182   G4double cut = cutEnergy;
                                                   >> 183   if (kineticEnergy <= cutEnergy) cut = kineticEnergy;
238                                                   184 
                                                   >> 185   const G4Material* material = couple->GetMaterial();
239   const G4ElementVector* theElementVector = ma    186   const G4ElementVector* theElementVector = material->GetElementVector();
240   const G4double* theAtomicNumDensityVector =  << 187   const G4double* theAtomicNumDensityVector = 
241                                    material->G    188                                    material->GetAtomicNumDensityVector();
242                                                   189 
243   //  loop for elements in the material           190   //  loop for elements in the material
244   for (std::size_t i=0; i<material->GetNumberO << 191   for (size_t i=0; i<material->GetNumberOfElements(); i++) {
245      G4double Z = (*theElementVector)[i]->GetZ    192      G4double Z = (*theElementVector)[i]->GetZ();
246      G4double tmax = MaxSecondaryEnergyForElem << 193      G4double loss = ComputMuPairLoss(Z, kineticEnergy, cut);
247      G4double loss = ComputMuPairLoss(Z, kinet << 
248      dedx += loss*theAtomicNumDensityVector[i]    194      dedx += loss*theAtomicNumDensityVector[i];
249   }                                               195   }
250   dedx = std::max(dedx, 0.0);                  << 196   if (dedx < 0.) dedx = 0.;
251   return dedx;                                    197   return dedx;
252 }                                                 198 }
253                                                   199 
254 //....oooOO0OOooo........oooOO0OOooo........oo    200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
255                                                   201 
256 G4double G4MuPairProductionModel::ComputMuPair << 202 G4double 
257                                                << 203 G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
258                                                << 204                                           G4double tkin, G4double cutEnergy)
259                                                << 
260 {                                                 205 {
                                                   >> 206   static const
                                                   >> 207   G4double xgi[] ={ 0.0199,0.1017,0.2372,0.4083,0.5917,0.7628,0.8983,0.9801};
                                                   >> 208   static const
                                                   >> 209   G4double wgi[] ={ 0.0506,0.1112,0.1569,0.1813,0.1813,0.1569,0.1112,0.0506};
                                                   >> 210   static const G4double ak1=6.9;
                                                   >> 211   static const G4double ak2=1.0;
                                                   >> 212   static const G4double sqrte = sqrt(exp(1.));
                                                   >> 213   static const G4double aaa = log(minPairEnergy);
                                                   >> 214   G4double z13 = pow(Z,0.333333333);
                                                   >> 215 
261   G4double loss = 0.0;                            216   G4double loss = 0.0;
262                                                   217 
263   G4double cut = std::min(cutEnergy, tmax);    << 218   G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass();
264   if(cut <= minPairEnergy) { return loss; }    << 219   G4double tmax = tkin + particleMass*(1.-0.75*sqrte*z13);
                                                   >> 220 
                                                   >> 221   G4double cut = cutEnergy;
                                                   >> 222   if(tmax <= cutEnergy) cut = tmax;
                                                   >> 223   if(cut <= minPairEnergy) return loss;
265                                                   224 
266   // calculate the rectricted loss                225   // calculate the rectricted loss
267   // numerical integration in log(PairEnergy)     226   // numerical integration in log(PairEnergy)
268   G4double aaa = G4Log(minPairEnergy);         << 227   G4double bbb = log(cut);
269   G4double bbb = G4Log(cut);                   << 228   G4int    kkk = (G4int)((bbb-aaa)/ak1+ak2);
270                                                << 229   if (kkk > 8) kkk = 8;
271   G4int kkk = std::min(std::max(G4lrint((bbb-a << 230   G4double hhh = (bbb-aaa)/(G4double)kkk;
272   G4double hhh = (bbb-aaa)/kkk;                << 
273   G4double x = aaa;                               231   G4double x = aaa;
274                                                   232 
275   for (G4int l=0 ; l<kkk; ++l) {               << 233   for (G4int l=0 ; l<kkk; l++)
276     for (G4int ll=0; ll<NINTPAIR; ++ll) {      << 234   {
277       G4double ep = G4Exp(x+xgi[ll]*hhh);      << 235 
                                                   >> 236     for (G4int ll=0; ll<8; ll++)
                                                   >> 237     {
                                                   >> 238       G4double ep = exp(x+xgi[ll]*hhh);
278       loss += wgi[ll]*ep*ep*ComputeDMicroscopi    239       loss += wgi[ll]*ep*ep*ComputeDMicroscopicCrossSection(tkin, Z, ep);
279     }                                             240     }
280     x += hhh;                                     241     x += hhh;
281   }                                               242   }
282   loss *= hhh;                                    243   loss *= hhh;
283   loss = std::max(loss, 0.0);                  << 244   if (loss < 0.) loss = 0.;
284   return loss;                                    245   return loss;
285 }                                                 246 }
286                                                   247 
287 //....oooOO0OOooo........oooOO0OOooo........oo    248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
288                                                   249 
289 G4double G4MuPairProductionModel::ComputeMicro    250 G4double G4MuPairProductionModel::ComputeMicroscopicCrossSection(
290                                            G4d    251                                            G4double tkin,
291                                            G4d    252                                            G4double Z,
292                                            G4d << 253                                            G4double cut)
293 {                                              << 
294   G4double cross = 0.;                         << 
295   G4double tmax = MaxSecondaryEnergyForElement << 
296   G4double cut  = std::max(cutEnergy, minPairE << 
297   if (tmax <= cut) { return cross; }           << 
298                                                << 
299   G4double aaa = G4Log(cut);                   << 
300   G4double bbb = G4Log(tmax);                  << 
301   G4int kkk = std::min(std::max(G4lrint((bbb-a << 
302                                                   254 
303   G4double hhh = (bbb-aaa)/(kkk);              << 255 {
                                                   >> 256   static const G4double ak1=6.9 ;
                                                   >> 257   static const G4double ak2=1.0 ;
                                                   >> 258   static const G4double sqrte = sqrt(exp(1.));
                                                   >> 259   static const G4double
                                                   >> 260   xgi[]={ 0.0199,0.1017,0.2372,0.4083,0.5917,0.7628,0.8983,0.9801 };
                                                   >> 261   static const G4double
                                                   >> 262   wgi[]={ 0.0506,0.1112,0.1569,0.1813,0.1813,0.1569,0.1112,0.0506 };
                                                   >> 263   G4double z13 = pow(Z,0.333333333);
                                                   >> 264 
                                                   >> 265   G4double cross = 0. ;
                                                   >> 266 
                                                   >> 267   G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass();
                                                   >> 268   G4double tmax = tkin + particleMass*(1.-0.75*sqrte*z13);
                                                   >> 269 
                                                   >> 270   if (tmax <= cut) return cross;
                                                   >> 271 
                                                   >> 272   G4double aaa = log(cut);
                                                   >> 273   G4double bbb = log(tmax);
                                                   >> 274   G4int kkk = (G4int)((bbb-aaa)/ak1 + ak2);
                                                   >> 275   if(kkk > 8) kkk = 8;
                                                   >> 276   G4double hhh = (bbb-aaa)/float(kkk);
304   G4double x = aaa;                               277   G4double x = aaa;
305                                                   278 
306   for (G4int l=0; l<kkk; ++l) {                << 279   for(G4int l=0; l<kkk; l++)
307     for (G4int i=0; i<NINTPAIR; ++i) {         << 280   {
308       G4double ep = G4Exp(x + xgi[i]*hhh);     << 281     for(G4int i=0; i<8; i++)
                                                   >> 282     {
                                                   >> 283       G4double ep = exp(x + xgi[i]*hhh);
309       cross += ep*wgi[i]*ComputeDMicroscopicCr    284       cross += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, ep);
310     }                                             285     }
311     x += hhh;                                     286     x += hhh;
312   }                                               287   }
313                                                   288 
314   cross *= hhh;                                << 289   cross *=hhh;
315   cross = std::max(cross, 0.0);                << 290   if(cross < 0.0) cross = 0.0;
316   return cross;                                   291   return cross;
317 }                                                 292 }
318                                                   293 
319 //....oooOO0OOooo........oooOO0OOooo........oo    294 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320                                                   295 
321 G4double G4MuPairProductionModel::ComputeDMicr    296 G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
322                                            G4d    297                                            G4double tkin,
323                                            G4d    298                                            G4double Z,
324                                            G4d    299                                            G4double pairEnergy)
325 // Calculates the  differential (D) microscopi << 300  // Calculates the  differential (D) microscopic cross section
326 // using the cross section formula of R.P. Kok << 301  // using the cross section formula of R.P. Kokoulin (18/01/98)
327 // Code modified by R.P. Kokoulin, V.N. Ivanch << 302 {
328 {                                              << 303   static const G4double
329   static const G4double bbbtf= 183. ;          << 304   xgi[] ={ 0.0199,0.1017,0.2372,0.4083,0.5917,0.7628,0.8983,0.9801 };
330   static const G4double bbbh = 202.4 ;         << 
331   static const G4double g1tf = 1.95e-5 ;       << 
332   static const G4double g2tf = 5.3e-5 ;        << 
333   static const G4double g1h  = 4.4e-5 ;        << 
334   static const G4double g2h  = 4.8e-5 ;        << 
335                                                   305 
336   if (pairEnergy <= minPairEnergy)             << 306   static const G4double
337     return 0.0;                                << 307   wgi[] ={ 0.0506,0.1112,0.1569,0.1813,0.1813,0.1569,0.1112,0.0506 };
338                                                   308 
339   G4double totalEnergy  = tkin + particleMass; << 309   G4double cross = 0.;
340   G4double residEnergy  = totalEnergy - pairEn << 
341                                                   310 
342   if (residEnergy <= 0.75*sqrte*z13*particleMa << 311   G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass();
343     return 0.0;                                << 312   G4double totalEnergy  = tkin + particleMass;
                                                   >> 313   G4double energyLoss   = totalEnergy - pairEnergy;
                                                   >> 314   G4double a = 6.*particleMass*particleMass/(totalEnergy*energyLoss) ;
                                                   >> 315   G4double b = 4.*electron_mass_c2/pairEnergy;
                                                   >> 316 
                                                   >> 317   G4double tmn = (b+2.*a*(1.-b))/(1.+(1.-a)*sqrt(1.-b));
                                                   >> 318   if(tmn <= 0.) return cross;
                                                   >> 319   tmn = log(tmn);
344                                                   320 
345   G4double a0 = 1.0 / (totalEnergy * residEner << 321   // Gaussian integration in ln(1-ro) ( with 8 points)
346   G4double alf = 4.0 * electron_mass_c2 / pair << 322   for (G4int i=0; i<8; i++)
347   G4double rt = std::sqrt(1.0 - alf);          << 323   {
348   G4double delta = 6.0 * particleMass * partic << 324     G4double ro = 1.-exp(tmn*xgi[i]);
349   G4double tmnexp = alf/(1.0 + rt) + delta*rt; << 325     cross += wgi[i]*(1.-ro)*ComputeDDMicroscopicCrossSection(
                                                   >> 326                                                          tkin,Z,pairEnergy,ro);
                                                   >> 327   }
                                                   >> 328   cross *= -tmn;
                                                   >> 329   return cross;
                                                   >> 330 }
350                                                   331 
351   if(tmnexp >= 1.0) { return 0.0; }            << 332 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
352                                                   333 
353   G4double tmn = G4Log(tmnexp);                << 334 G4double G4MuPairProductionModel::ComputeDDMicroscopicCrossSection(
                                                   >> 335                                            G4double tkin,
                                                   >> 336                                            G4double Z,
                                                   >> 337                                            G4double pairEnergy,
                                                   >> 338                                            G4double asymmetry)
                                                   >> 339  // Calculates the  differential (D) microscopic cross section
                                                   >> 340  // using the cross section formula of R.P. Kokoulin (18/01/98)
                                                   >> 341 {
                                                   >> 342   static const G4double sqrte = sqrt(exp(1.)) ;
                                                   >> 343 
                                                   >> 344   G4double bbbtf= 183. ;
                                                   >> 345   G4double bbbh = 202.4 ;
                                                   >> 346   G4double g1tf = 1.95e-5 ;
                                                   >> 347   G4double g2tf = 5.3e-5 ;
                                                   >> 348   G4double g1h  = 4.4e-5 ;
                                                   >> 349   G4double g2h  = 4.8e-5 ;
354                                                   350 
355   G4double massratio = particleMass/CLHEP::ele << 351   G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass();
356   G4double massratio2 = massratio*massratio;   << 352   G4double totalEnergy  = tkin + particleMass;
357   G4double inv_massratio2 = 1.0 / massratio2;  << 353   G4double energyLoss   = totalEnergy - pairEnergy;
                                                   >> 354   G4double massratio    = particleMass/electron_mass_c2 ;
                                                   >> 355   G4double massratio2   = massratio*massratio ;
                                                   >> 356 
                                                   >> 357   G4double z13 = pow(Z,0.333333333);
                                                   >> 358   G4double z23 = z13*z13 ;
                                                   >> 359 
                                                   >> 360   G4double c3 = 3.*sqrte*particleMass/4. ;
                                                   >> 361 
                                                   >> 362   G4double DDCrossSection = 0. ;
                                                   >> 363   if (energyLoss <= c3*z13) return DDCrossSection;
                                                   >> 364 
                                                   >> 365   G4double c7 = 4.*electron_mass_c2;
                                                   >> 366   G4double c8 = 6.*particleMass*particleMass;
                                                   >> 367   G4double alf = c7/pairEnergy;
                                                   >> 368   G4double a3 = 1. - alf;
                                                   >> 369   if (a3 <= 0.) return DDCrossSection;
358                                                   370 
359   // zeta calculation                          << 371  // zeta calculation
360   G4double bbb,g1,g2;                          << 372   G4double bbb,g1,g2,zeta1,zeta2,zeta,z2;
361   if( Z < 1.5 ) { bbb = bbbh ; g1 = g1h ; g2 =    373   if( Z < 1.5 ) { bbb = bbbh ; g1 = g1h ; g2 = g2h ; }
362   else          { bbb = bbbtf; g1 = g1tf; g2 =    374   else          { bbb = bbbtf; g1 = g1tf; g2 = g2tf; }
363                                                << 375   zeta1 = 0.073 * log(totalEnergy/(particleMass+g1*z23*totalEnergy))-0.26 ;
364   G4double zeta = 0.0;                         << 376   if ( zeta1 > 0.)
365   G4double z1exp = totalEnergy / (particleMass << 
366                                                << 
367   // 35.221047195922 is the root of zeta1(x) = << 
368   // condition below is the same as zeta1 > 0. << 
369   if (z1exp > 35.221047195922)                 << 
370   {                                               377   {
371     G4double z2exp = totalEnergy / (particleMa << 378     zeta2 = 0.058*log(totalEnergy/(particleMass+g2*z13*totalEnergy))-0.14 ;
372     zeta = (0.073 * G4Log(z1exp) - 0.26) / (0. << 379     zeta  = zeta1/zeta2 ;
                                                   >> 380   }
                                                   >> 381   else
                                                   >> 382   {
                                                   >> 383     zeta = 0. ;
373   }                                               384   }
374                                                   385 
375   G4double z2 = Z*(Z+zeta);                    << 386   z2 = Z*(Z+zeta);
376   G4double screen0 = 2.*electron_mass_c2*sqrte << 
377   G4double beta = 0.5*pairEnergy*pairEnergy*a0 << 
378   G4double xi0 = 0.5*massratio2*beta;          << 
379                                                << 
380   // Gaussian integration in ln(1-ro) ( with 8 << 
381   G4double rho[NINTPAIR];                      << 
382   G4double rho2[NINTPAIR];                     << 
383   G4double xi[NINTPAIR];                       << 
384   G4double xi1[NINTPAIR];                      << 
385   G4double xii[NINTPAIR];                      << 
386                                                   387 
387   for (G4int i = 0; i < NINTPAIR; ++i)         << 388   G4double screen0 = 2.*electron_mass_c2*sqrte*bbb/(z13*pairEnergy);
                                                   >> 389   G4double a0 = totalEnergy*energyLoss;
                                                   >> 390   G4double a1 = pairEnergy*pairEnergy/a0;
                                                   >> 391   G4double bet = 0.5*a1;
                                                   >> 392   G4double xi0 = 0.25*massratio2*a1;
                                                   >> 393   G4double del = c8/a0;
                                                   >> 394 
                                                   >> 395   G4double romin = 0. ;
                                                   >> 396   G4double romax = (1.-del)*sqrt(1.-c7/pairEnergy);
                                                   >> 397 
                                                   >> 398   if((asymmetry < romin) || (asymmetry > romax)) return DDCrossSection;
                                                   >> 399 
                                                   >> 400   G4double a4 = 1.-asymmetry ;
                                                   >> 401   G4double a5 = a4*(2.-a4) ;
                                                   >> 402   G4double a6 = 1.-a5 ;
                                                   >> 403   G4double a7 = 1.+a6 ;
                                                   >> 404   G4double a9 = 3.+a6 ;
                                                   >> 405   G4double xi = xi0*a5 ;
                                                   >> 406   G4double xii = 1./xi ;
                                                   >> 407   G4double xi1 = 1.+xi ;
                                                   >> 408   G4double screen = screen0*xi1/a5 ;
                                                   >> 409 
                                                   >> 410   G4double yeu = 5.-a6+4.*bet*a7 ;
                                                   >> 411   G4double yed = 2.*(1.+3.*bet)*log(3.+xii)-a6-a1*(2.-a6) ;
                                                   >> 412   G4double yel = 1.+yeu/yed ;
                                                   >> 413   G4double ale=log(bbb/z13*sqrt(xi1*yel)/(1.+screen*yel)) ;
                                                   >> 414   G4double cre = 0.5*log(1.+2.25/(massratio2*z23)*xi1*yel) ;
                                                   >> 415   G4double be;
                                                   >> 416   if (xi <= 1.e3) be = ((2.+a6)*(1.+bet)+xi*a9)*log(1.+xii)+(a5-bet)/xi1-a9;
                                                   >> 417   else            be = (3.-a6+a1*a7)/(2*xi);
                                                   >> 418   G4double fe = (ale-cre)*be;
                                                   >> 419   if ( fe < 0.) fe = 0. ;
                                                   >> 420 
                                                   >> 421   G4double ymu = 4.+a6 +3.*bet*a7 ;
                                                   >> 422   G4double ymd = a7*(1.5+a1)*log(3.+xi)+1.-1.5*a6 ;
                                                   >> 423   G4double ym1 = 1.+ymu/ymd ;
                                                   >> 424   G4double alm_crm = log(bbb*massratio/(1.5*z23*(1.+screen*ym1)));
                                                   >> 425   G4double a10,bm;
                                                   >> 426   if ( xi >= 1.e-3)
388   {                                               427   {
389     rho[i] = G4Exp(tmn*xgi[i]) - 1.0; // rho = << 428     a10 = (1.+a1)*a5 ;
390     rho2[i] = rho[i] * rho[i];                 << 429     bm  = (a7*(1.+1.5*bet)-a10*xii)*log(xi1)+xi*(a5-bet)/xi1+a10;
391     xi[i] = xi0*(1.0-rho2[i]);                 << 
392     xi1[i] = 1.0 + xi[i];                      << 
393     xii[i] = 1.0 / xi[i];                      << 
394   }                                               430   }
                                                   >> 431   else
                                                   >> 432     bm = (5.-a6+bet*a9)*(xi/2.);
                                                   >> 433     
                                                   >> 434   G4double fm = alm_crm*bm;
                                                   >> 435   if ( fm < 0.) fm = 0. ;
395                                                   436 
396   G4double ye1[NINTPAIR];                      << 437   DDCrossSection = (fe+fm/massratio2);
397   G4double ym1[NINTPAIR];                      << 
398                                                   438 
399   G4double b40 = 4.0 * beta;                   << 439   DDCrossSection *= 4.*fine_structure_const*fine_structure_const
400   G4double b62 = 6.0 * beta + 2.0;             << 440                    *classic_electr_radius*classic_electr_radius/(3.*pi);
401                                                   441 
402   for (G4int i = 0; i < NINTPAIR; ++i)         << 442   DDCrossSection *= z2*energyLoss/(totalEnergy*pairEnergy);
403   {                                            << 
404     G4double yeu = (b40 + 5.0) + (b40 - 1.0) * << 
405     G4double yed = b62*G4Log(3.0 + xii[i]) + ( << 
406                                                   443 
407     G4double ymu = b62 * (1.0 + rho2[i]) + 6.0 << 444   return DDCrossSection;
408     G4double ymd = (b40 + 3.0)*(1.0 + rho2[i]) << 
409       + 2.0 - 3.0 * rho2[i];                   << 
410                                                << 
411     ye1[i] = 1.0 + yeu / yed;                  << 
412     ym1[i] = 1.0 + ymu / ymd;                  << 
413   }                                            << 
414                                                << 
415   G4double be[NINTPAIR];                       << 
416   G4double bm[NINTPAIR];                       << 
417                                                << 
418   for(G4int i = 0; i < NINTPAIR; ++i) {        << 
419     if(xi[i] <= 1000.0) {                      << 
420       be[i] = ((2.0 + rho2[i])*(1.0 + beta) +  << 
421          xi[i]*(3.0 + rho2[i]))*G4Log(1.0 + xi << 
422   (1.0 - rho2[i] - beta)/xi1[i] - (3.0 + rho2[ << 
423     } else {                                   << 
424       be[i] = 0.5*(3.0 - rho2[i] + 2.0*beta*(1 << 
425     }                                          << 
426                                                   445 
427     if(xi[i] >= 0.001) {                       << 446 }
428       G4double a10 = (1.0 + 2.0 * beta) * (1.0 << 
429       bm[i] = ((1.0 + rho2[i])*(1.0 + 1.5 * be << 
430                 xi[i] * (1.0 - rho2[i] - beta) << 
431     } else {                                   << 
432       bm[i] = 0.5*(5.0 - rho2[i] + beta * (3.0 << 
433     }                                          << 
434   }                                            << 
435                                                   447 
436   G4double sum = 0.0;                          << 448 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
437                                                   449 
438   for (G4int i = 0; i < NINTPAIR; ++i) {       << 450 G4double 
439     G4double screen = screen0*xi1[i]/(1.0 - rh << 451 G4MuPairProductionModel::CrossSection(const G4MaterialCutsCouple* couple,
440     G4double ale = G4Log(bbb/z13*std::sqrt(xi1 << 452                                       const G4ParticleDefinition*,
441     G4double cre = 0.5*G4Log(1. + 2.25*z23*xi1 << 453                                       G4double kineticEnergy,
                                                   >> 454                                       G4double cutEnergy, G4double maxEnergy)
                                                   >> 455 {
                                                   >> 456   G4double cross = 0.0;
442                                                   457 
443     G4double fe = (ale-cre)*be[i];             << 458   G4double tmax = std::min(maxEnergy, kineticEnergy);
444     fe = std::max(fe, 0.0);                    << 459   if (cutEnergy >= tmax) return cross;
445                                                   460 
446     G4double alm_crm = G4Log(bbb*massratio/(1. << 461   const G4Material* material = couple->GetMaterial();
447     G4double fm = std::max(alm_crm*bm[i], 0.0) << 462   const G4ElementVector* theElementVector = material->GetElementVector();
                                                   >> 463   const G4double* theAtomNumDensityVector=material->GetAtomicNumDensityVector();
448                                                   464 
449     sum += wgi[i]*(1.0 + rho[i])*(fe + fm);    << 465   for (size_t i=0; i<material->GetNumberOfElements(); i++) {
450   }                                            << 466     G4double Z = (*theElementVector)[i]->GetZ();
                                                   >> 467     G4double cr = ComputeMicroscopicCrossSection(kineticEnergy, Z, cutEnergy);
451                                                   468 
452   return -tmn*sum*factorForCross*z2*residEnerg << 469     if (maxEnergy < kineticEnergy) {
                                                   >> 470       cr -= ComputeMicroscopicCrossSection(kineticEnergy, Z, maxEnergy);
                                                   >> 471     }
                                                   >> 472     cross += theAtomNumDensityVector[i] * cr;
                                                   >> 473   }
                                                   >> 474   return cross;
453 }                                                 475 }
454                                                   476 
455 //....oooOO0OOooo........oooOO0OOooo........oo    477 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
456                                                   478 
457 G4double G4MuPairProductionModel::ComputeCross << 479 G4DataVector* G4MuPairProductionModel::ComputePartialSumSigma(
458                                            con << 480                                        const G4Material* material,
459                                                << 481                                              G4double kineticEnergy,
460                                                << 482                                              G4double cut)
461                                                << 483 
462                                                << 484 // Build the table of cross section per element. 
                                                   >> 485 // This table is used by DoIt to select randomly an element in the material.
463 {                                                 486 {
                                                   >> 487   G4int nElements = material->GetNumberOfElements();
                                                   >> 488   const G4ElementVector* theElementVector = material->GetElementVector();
                                                   >> 489   const G4double* theAtomNumDensityVector=material->GetAtomicNumDensityVector();
                                                   >> 490 
                                                   >> 491   G4DataVector* dv = new G4DataVector();
                                                   >> 492 
464   G4double cross = 0.0;                           493   G4double cross = 0.0;
465   if (kineticEnergy <= lowestKinEnergy) { retu << 
466                                                   494 
467   G4double maxPairEnergy = MaxSecondaryEnergyF << 495   for (G4int i=0; i<nElements; i++ ) {
468   G4double tmax = std::min(maxEnergy, maxPairE << 496     G4double Z = (*theElementVector)[i]->GetZ();
469   G4double cut  = std::max(cutEnergy, minPairE << 497     cross += theAtomNumDensityVector[i] * ComputeMicroscopicCrossSection(
470   if (cut >= tmax) { return cross; }           << 498                                           kineticEnergy, Z, cut);
471                                                << 499     dv->push_back(cross);
472   cross = ComputeMicroscopicCrossSection(kinet << 
473   if(tmax < kineticEnergy) {                   << 
474     cross -= ComputeMicroscopicCrossSection(ki << 
475   }                                               500   }
476   return cross;                                << 501   return dv;
477 }                                                 502 }
478                                                   503 
479 //....oooOO0OOooo........oooOO0OOooo........oo    504 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
480                                                   505 
481 void G4MuPairProductionModel::MakeSamplingTabl    506 void G4MuPairProductionModel::MakeSamplingTables()
482 {                                                 507 {
483   G4double factore = G4Exp(G4Log(emax/emin)/G4 << 508   static const G4double sqrte = sqrt(exp(1.)) ;
                                                   >> 509   G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass();
484                                                   510 
485   for (G4int iz=0; iz<NZDATPAIR; ++iz) {       << 511   for (G4int iz=0; iz<nzdat; iz++)
                                                   >> 512   {
                                                   >> 513     G4double atomicNumber = zdat[iz];
                                                   >> 514     G4double z13 = exp(log(atomicNumber)/3.) ;
486                                                   515 
487     G4double Z = ZDATPAIR[iz];                 << 516     for (G4int it=0; it<ntdat; it++)
488     G4Physics2DVector* pv = new G4Physics2DVec << 517     {
489     G4double kinEnergy = emin;                 << 518       G4double kineticEnergy = tdat[it];
490                                                << 519       G4double maxPairEnergy = kineticEnergy+particleMass*(1.-0.75*sqrte*z13) ;
491     for (std::size_t it=0; it<=nbine; ++it) {  << 520 
492                                                << 521       G4double CrossSection = 0.0 ;
493       pv->PutY(it, G4Log(kinEnergy/CLHEP::MeV) << 522 
494       G4double maxPairEnergy = MaxSecondaryEne << 523       G4double ymin = -5. ;
495       /*                                       << 524       G4double ymax = 0. ;
496       G4cout << "it= " << it << " E= " << kinE << 525       G4double dy = (ymax-ymin)/NBIN ;
497              << "  " << particle->GetParticleN << 526 
498              << " maxE= " << maxPairEnergy <<  << 527       G4double y = ymin - 0.5*dy ;
499              << " ymin= " << ymin << G4endl;   << 528       G4double yy = ymin - dy ;
500       */                                       << 529       G4double x = exp(y);
501       G4double coef = G4Log(minPairEnergy/kinE << 530       G4double fac = exp(dy);
502       G4double ymax = G4Log(maxPairEnergy/kinE << 531       G4double dx = exp(yy)*(fac - 1.0);
503       G4double fac  = (ymax - ymin)/dy;        << 532 
504       std::size_t imax   = (std::size_t)fac;   << 533       if (maxPairEnergy > minPairEnergy) {
505       fac -= (G4double)imax;                   << 534         G4double c = log(maxPairEnergy/minPairEnergy);
506                                                << 535         for (G4int i=0 ; i<NBIN; i++)
507       G4double xSec = 0.0;                     << 536         {
508       G4double x = ymin;                       << 537           y += dy ;
509       /*                                       << 538           x *= fac;
510       G4cout << "Z= " << currentZ << " z13= "  << 539           dx*= fac;
511              << " mE= " << maxPairEnergy << "  << 540           G4double ep = minPairEnergy*exp(c*x) ;
512              << " dy= " << dy << "  c= " << co << 541           CrossSection += ep*dx*ComputeDMicroscopicCrossSection(
513       */                                       << 542                                       kineticEnergy, atomicNumber, ep);
514       // start from zero                       << 543           ya[i] = y;
515       pv->PutValue(0, it, 0.0);                << 544           proba[iz][it][i] = CrossSection;
516       if(0 == it) { pv->PutX(nbiny, 0.0); }    << 
517                                                << 
518       for (std::size_t i=0; i<nbiny; ++i) {    << 
519                                                << 
520         if(0 == it) { pv->PutX(i, x); }        << 
521                                                << 
522         if(i < imax) {                         << 
523           G4double ep = kinEnergy*G4Exp(coef*( << 
524                                                << 
525           // not multiplied by interval, becau << 
526           // will be used only for sampling    << 
527           //G4cout << "i= " << i << " x= " <<  << 
528           //         << " Egamma= " << ep << G << 
529           xSec += ep*ComputeDMicroscopicCrossS << 
530                                                << 
531           // last bin before the kinematic lim << 
532         } else if(i == imax) {                 << 
533           G4double ep = kinEnergy*G4Exp(coef*( << 
534           xSec += ep*fac*ComputeDMicroscopicCr << 
535         }                                         545         }
536         pv->PutValue(i + 1, it, xSec);         << 546       } else {
537         x += dy;                               << 547         for (G4int i=0 ; i<NBIN; i++)
538       }                                        << 548     {
539       kinEnergy *= factore;                    << 549            y += dy ;
                                                   >> 550            ya[i] = y ;
                                                   >> 551            proba[iz][it][i] = 0.0 ;
                                                   >> 552     }
                                                   >> 553       }
                                                   >> 554 
                                                   >> 555       ya[NBIN]=0. ;
                                                   >> 556 
                                                   >> 557       proba[iz][it][NBIN] = CrossSection;
540                                                   558 
541       // to avoid precision lost               << 559       if(CrossSection > 0.)
542       if(it+1 == nbine) { kinEnergy = emax; }  << 560       {
                                                   >> 561         for(G4int ib=0; ib<=NBIN; ib++)
                                                   >> 562         {
                                                   >> 563           proba[iz][it][ib] /= CrossSection ;
                                                   >> 564 
                                                   >> 565         }
                                                   >> 566       }
543     }                                             567     }
544     fElementData->InitialiseForElement(iz, pv) << 
545   }                                               568   }
                                                   >> 569   samplingTablesAreFilled = true;
546 }                                                 570 }
547                                                   571 
548 //....oooOO0OOooo........oooOO0OOooo........oo    572 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
549                                                   573 
550 void G4MuPairProductionModel::SampleSecondarie << 574 G4DynamicParticle* G4MuPairProductionModel::SampleSecondary(
551                               std::vector<G4Dy << 575                              const G4MaterialCutsCouple*,
552                               const G4Material << 576                              const G4DynamicParticle*,
553                               const G4DynamicP << 577                                    G4double,
554                               G4double tmin,   << 578                                    G4double)
555                               G4double tmax)   << 579 {
556 {                                              << 580   return 0;
557   G4double kinEnergy = aDynamicParticle->GetKi << 581 }
558   //G4cout << "------- G4MuPairProductionModel << 582 
559   //         << kinEnergy << "  "              << 583 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
560   //         << aDynamicParticle->GetDefinitio << 584 
561   G4double totalEnergy   = kinEnergy + particl << 585 std::vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondaries(
562   G4double totalMomentum =                     << 586                              const G4MaterialCutsCouple* couple,
563     std::sqrt(kinEnergy*(kinEnergy + 2.0*parti << 587                              const G4DynamicParticle* aDynamicParticle,
564                                                << 588                                    G4double minEnergy,
565   G4ThreeVector partDirection = aDynamicPartic << 589                                    G4double maxEnergy)
566                                                << 590 {
567   // select randomly one element constituing t << 591    static const G4double esq = sqrt(exp(1.));
568   const G4Element* anElement = SelectRandomAto << 592    G4double kineticEnergy = aDynamicParticle->GetKineticEnergy();
569                                                << 593    G4double particleMass  = aDynamicParticle->GetDefinition()->GetPDGMass();
570   // define interval of energy transfer        << 594    G4ParticleMomentum ParticleDirection =
571   G4double maxPairEnergy = MaxSecondaryEnergyF << 595                                       aDynamicParticle->GetMomentumDirection();
572                                                << 596 
573   G4double maxEnergy = std::min(tmax, maxPairE << 597    // select randomly one element constituing the material
574   G4double minEnergy = std::max(tmin, minPairE << 598    const G4Element* anElement = SelectRandomAtom(couple);
575                                                << 599 
576   if (minEnergy >= maxEnergy) { return; }      << 600    // limits of the energy sampling
577   //G4cout << "emin= " << minEnergy << " emax= << 601    G4double totalEnergy = kineticEnergy + particleMass ;
578   // << " minPair= " << minPairEnergy << " max << 602    //G4double TotalMomentum = sqrt(KineticEnergy*(TotalEnergy+particleMass)) ;
579   //    << " ymin= " << ymin << " dy= " << dy  << 603    G4double Z3 = anElement->GetIonisation()->GetZ3() ;
580                                                << 604    G4double maxPairEnergy = totalEnergy-0.75*esq*particleMass*Z3 ;
581   G4double coeff = G4Log(minPairEnergy/kinEner << 605    if(maxPairEnergy > maxEnergy) maxPairEnergy = maxEnergy;
582                                                << 606 
583   // compute limits                            << 607    // check against insufficient energy
584   G4double yymin = G4Log(minEnergy/kinEnergy)/ << 608    if(minEnergy >= maxPairEnergy) return 0;
585   G4double yymax = G4Log(maxEnergy/kinEnergy)/ << 609 
586                                                << 610    // sample e-e+ energy, pair energy first
587   //G4cout << "yymin= " << yymin << "  yymax=  << 611    G4double PairEnergy,x,yc,y ;
588                                                << 612    // G4int iZ,iT;
589   // units should not be used, bacause table w << 613    G4int iy ;
590   G4double logTkin = G4Log(kinEnergy/CLHEP::Me << 614 
591                                                << 615    // select sampling table ;
592   // sample e-e+ energy, pair energy first     << 616    G4double lnZ = log(anElement->GetZ()) ;
593                                                << 617    G4double delmin = 1.e10 ;
594   // select sample table via Z                 << 618    G4double del ;
595   G4int iz1(0), iz2(0);                        << 619    G4int izz = 0;
596   for (G4int iz=0; iz<NZDATPAIR; ++iz) {       << 620    G4int itt = 0;
597     if(currentZ == ZDATPAIR[iz]) {             << 621    G4int NBINminus1 = NBIN-1;
598       iz1 = iz2 = iz;                          << 622    for (G4int iz=0; iz<nzdat; iz++)
599       break;                                   << 623    {
600     } else if(currentZ < ZDATPAIR[iz]) {       << 624      del = abs(lnZ-log(zdat[iz])) ;
601       iz2 = iz;                                << 625      if(del<delmin)
602       if(iz > 0) { iz1 = iz-1; }               << 626      {
603       else { iz1 = iz2; }                      << 627         delmin=del ;
604       break;                                   << 628         izz=iz ;
605     }                                          << 629      }
606   }                                            << 630    }
607   if (0 == iz1) { iz1 = iz2 = NZDATPAIR-1; }   << 631    delmin = 1.e10 ;
608                                                << 632    for (G4int it=0; it<ntdat; it++)
609   G4double pairEnergy = 0.0;                   << 633    {
610   G4int count = 0;                             << 634      del = abs(log(kineticEnergy)-log(tdat[it])) ;
611   //G4cout << "start loop Z1= " << iz1 << " Z2 << 635      if(del<delmin)
612   do {                                         << 636      {
613     ++count;                                   << 637        delmin=del;
614     // sampling using only one random number   << 638        itt=it ;
615     G4double rand = G4UniformRand();           << 639      }
616                                                << 640    }
617     G4double x = FindScaledEnergy(iz1, rand, l << 641 
618     if(iz1 != iz2) {                           << 642    if( minEnergy <= minPairEnergy)
619       G4double x2 = FindScaledEnergy(iz2, rand << 643      iy = 0 ;
620       G4double lz1= nist->GetLOGZ(ZDATPAIR[iz1 << 644    else
621       G4double lz2= nist->GetLOGZ(ZDATPAIR[iz2 << 645    {
622       //G4cout << count << ".  x= " << x << "  << 646     G4double xc = log(minEnergy/minPairEnergy)/log(maxPairEnergy/minPairEnergy);
623       //             << " Z1= " << iz1 << " Z2 << 647     yc = log(xc) ;
624       x += (x2 - x)*(lnZ - lz1)/(lz2 - lz1);   << 648     iy = -1 ;
625     }                                          << 649     do { iy += 1;} while ((ya[iy] < yc )&&(iy < NBINminus1));
626     //G4cout << "x= " << x << "  coeff= " << c << 650    }
627     pairEnergy = kinEnergy*G4Exp(x*coeff);     << 651 
628                                                << 652    G4double norm = proba[izz][itt][iy];
629     // Loop checking, 03-Aug-2015, Vladimir Iv << 653 
630   } while((pairEnergy < minEnergy || pairEnerg << 654    G4double r = norm+G4UniformRand()*(1.-norm);
                                                   >> 655 
                                                   >> 656    iy -= 1;
                                                   >> 657    do { iy += 1;} while ((proba[izz][itt][iy] < r)&&(iy < NBINminus1));
                                                   >> 658 
                                                   >> 659    //sampling is uniformly in y in the bin
                                                   >> 660    if( iy < NBIN ) y = ya[iy] + G4UniformRand() * ( ya[iy+1] - ya[iy]);
                                                   >> 661    else            y = ya[iy];
                                                   >> 662 
                                                   >> 663    x = exp(y);
                                                   >> 664 
                                                   >> 665    PairEnergy = minPairEnergy*exp(x*log(maxPairEnergy/minPairEnergy));
                                                   >> 666 
                                                   >> 667   // sample r=(E+-E-)/PairEnergy  ( uniformly .....)
                                                   >> 668    G4double rmax = (1.-6.*particleMass*particleMass/(totalEnergy*
                                                   >> 669                                                (totalEnergy-PairEnergy)))
                                                   >> 670                                        *sqrt(1.-minPairEnergy/PairEnergy);
                                                   >> 671    r = rmax * (-1.+2.*G4UniformRand()) ;
                                                   >> 672 
                                                   >> 673   // compute energies from PairEnergy,r
                                                   >> 674    G4double ElectronEnergy=(1.-r)*PairEnergy/2. ;
                                                   >> 675    G4double PositronEnergy=(1.+r)*PairEnergy/2. ;
                                                   >> 676 
                                                   >> 677    //  angles of the emitted particles ( Z - axis along the parent particle)
                                                   >> 678    //      (mean theta for the moment)
                                                   >> 679    G4double Teta = electron_mass_c2/totalEnergy ;
                                                   >> 680 
                                                   >> 681    G4double Phi  = twopi * G4UniformRand() ;
                                                   >> 682    G4double dirx = sin(Teta)*cos(Phi) , diry = sin(Teta)*sin(Phi) ,
                                                   >> 683             dirz = cos(Teta) ;
                                                   >> 684 
                                                   >> 685    G4double ElectronMomentum , PositronMomentum ;
                                                   >> 686    //G4double finalPx,finalPy,finalPz ;
                                                   >> 687    G4double ElectKineEnergy = ElectronEnergy - electron_mass_c2 ;
                                                   >> 688 
                                                   >> 689    ElectronMomentum = sqrt(ElectKineEnergy*(ElectronEnergy+electron_mass_c2));
                                                   >> 690    G4ThreeVector ElectDirection ( dirx, diry, dirz );
                                                   >> 691    ElectDirection.rotateUz(ParticleDirection);
                                                   >> 692 
                                                   >> 693    // create G4DynamicParticle object for the particle1
                                                   >> 694    G4DynamicParticle* aParticle1= new G4DynamicParticle();
                                                   >> 695    aParticle1->SetDefinition(G4Electron::Electron());
                                                   >> 696    aParticle1->SetMomentumDirection(ElectDirection);
                                                   >> 697    aParticle1->SetKineticEnergy(ElectKineEnergy);
                                                   >> 698 
                                                   >> 699 
                                                   >> 700    G4double PositKineEnergy = PositronEnergy - electron_mass_c2 ;
                                                   >> 701    PositronMomentum = sqrt(PositKineEnergy*(PositronEnergy+electron_mass_c2));
                                                   >> 702 
                                                   >> 703    G4ThreeVector PositDirection ( -dirx, -diry, dirz );
                                                   >> 704    PositDirection.rotateUz(ParticleDirection);
                                                   >> 705 
                                                   >> 706    // create G4DynamicParticle object for the particle2
                                                   >> 707    G4DynamicParticle* aParticle2= new G4DynamicParticle();
                                                   >> 708    aParticle2->SetDefinition(G4Positron::Positron());
                                                   >> 709    aParticle2->SetMomentumDirection(PositDirection);
                                                   >> 710    aParticle2->SetKineticEnergy(PositKineEnergy);
631                                                   711 
632   //G4cout << "## pairEnergy(GeV)= " << pairEn << 
633   //         << " Etot(GeV)= " << totalEnergy/ << 
634                                                   712 
635   // sample r=(E+-E-)/pairEnergy  ( uniformly  << 713   std::vector<G4DynamicParticle*>* vdp = new std::vector<G4DynamicParticle*>;
636   G4double rmax =                              << 
637     (1.-6.*particleMass*particleMass/(totalEne << 
638     *std::sqrt(1.-minPairEnergy/pairEnergy);   << 
639   G4double r = rmax * (-1.+2.*G4UniformRand()) << 
640                                                << 
641   // compute energies from pairEnergy,r        << 
642   G4double eEnergy = (1.-r)*pairEnergy*0.5;    << 
643   G4double pEnergy = pairEnergy - eEnergy;     << 
644                                                << 
645   // Sample angles                             << 
646   G4ThreeVector eDirection, pDirection;        << 
647   //                                           << 
648   GetAngularDistribution()->SamplePairDirectio << 
649                                                << 
650                                                << 
651   // create G4DynamicParticle object for e+e-  << 
652   eEnergy = std::max(eEnergy - CLHEP::electron << 
653   pEnergy = std::max(pEnergy - CLHEP::electron << 
654   auto aParticle1 = new G4DynamicParticle(theE << 
655   auto aParticle2 = new G4DynamicParticle(theP << 
656   // Fill output vector                        << 
657   vdp->push_back(aParticle1);                     714   vdp->push_back(aParticle1);
658   vdp->push_back(aParticle2);                     715   vdp->push_back(aParticle2);
659                                                   716 
660   // primary change                            << 717   return vdp;
661   kinEnergy -= pairEnergy;                     << 
662   partDirection *= totalMomentum;              << 
663   partDirection -= (aParticle1->GetMomentum()  << 
664   partDirection = partDirection.unit();        << 
665                                                << 
666   // if energy transfer is higher than thresho << 
667   // then stop tracking the primary particle a << 
668   if (pairEnergy > SecondaryThreshold()) {     << 
669     fParticleChange->ProposeTrackStatus(fStopA << 
670     fParticleChange->SetProposedKineticEnergy( << 
671     auto newdp = new G4DynamicParticle(particl << 
672     vdp->push_back(newdp);                     << 
673   } else { // continue tracking the primary e- << 
674     fParticleChange->SetProposedMomentumDirect << 
675     fParticleChange->SetProposedKineticEnergy( << 
676   }                                            << 
677   //G4cout << "-- G4MuPairProductionModel::Sam << 
678 }                                                 718 }
679                                                   719 
680 //....oooOO0OOooo........oooOO0OOooo........oo    720 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
681                                                   721 
682 G4double                                       << 722 const G4Element* G4MuPairProductionModel::SelectRandomAtom(
683 G4MuPairProductionModel::FindScaledEnergy(G4in << 723            const G4MaterialCutsCouple* couple) const
684             G4double logTkin,                  << 
685             G4double yymin, G4double yymax)    << 
686 {                                                 724 {
687   G4double res = yymin;                        << 725   // select randomly 1 element within the material
688   G4Physics2DVector* pv = fElementData->GetEle << 
689   if (nullptr != pv) {                         << 
690     G4double pmin = pv->Value(yymin, logTkin); << 
691     G4double pmax = pv->Value(yymax, logTkin); << 
692     G4double p0   = pv->Value(0.0, logTkin);   << 
693     if(p0 <= 0.0) { DataCorrupted(ZDATPAIR[iz] << 
694     else { res = pv->FindLinearX((pmin + rand* << 
695   } else {                                     << 
696     DataCorrupted(ZDATPAIR[iz], logTkin);      << 
697   }                                            << 
698   return res;                                  << 
699 }                                              << 
700                                                   726 
701 //....oooOO0OOooo........oooOO0OOooo........oo << 727   const G4Material* material = couple->GetMaterial();
702                                                << 728   G4int nElements = material->GetNumberOfElements();
703 void G4MuPairProductionModel::DataCorrupted(G4 << 729   const G4ElementVector* theElementVector = material->GetElementVector();
704 {                                              << 730   if (nElements == 1) return (*theElementVector)[0];
705   G4ExceptionDescription ed;                   << 731   else if (nElements < 1) return 0;
706   ed << "G4ElementData is not properly initial << 
707      << " Ekin(MeV)= " << G4Exp(logTkin)       << 
708      << " IsMasterThread= " << IsMaster()      << 
709      << " Model " << GetName();                << 
710   G4Exception("G4MuPairProductionModel::()", " << 
711 }                                              << 
712                                                << 
713 //....oooOO0OOooo........oooOO0OOooo........oo << 
714                                                   732 
715 void G4MuPairProductionModel::StoreTables() co << 733   G4DataVector* dv = partialSumSigma[couple->GetIndex()];
716 {                                              << 734   G4double rval = G4UniformRand()*((*dv)[nElements-1]);
717   for (G4int iz=0; iz<NZDATPAIR; ++iz) {       << 735   for (G4int i=0; i<nElements; i++) {
718     G4int Z = ZDATPAIR[iz];                    << 736     if (rval <= (*dv)[i]) return (*theElementVector)[i];
719     G4Physics2DVector* pv = fElementData->GetE << 
720     if(nullptr == pv) {                        << 
721       DataCorrupted(Z, 1.0);                   << 
722       return;                                  << 
723     }                                          << 
724     std::ostringstream ss;                     << 
725     ss << "mupair/" << particle->GetParticleNa << 
726     std::ofstream outfile(ss.str());           << 
727     pv->Store(outfile);                        << 
728   }                                               737   }
                                                   >> 738   return (*theElementVector)[nElements-1];
729 }                                                 739 }
730                                                   740 
731 //....oooOO0OOooo........oooOO0OOooo........oo    741 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
732                                                   742 
733 G4bool G4MuPairProductionModel::RetrieveTables << 
734 {                                              << 
735   for (G4int iz=0; iz<NZDATPAIR; ++iz) {       << 
736     G4double Z = ZDATPAIR[iz];                 << 
737     G4Physics2DVector* pv = new G4Physics2DVec << 
738     std::ostringstream ss;                     << 
739     ss << G4EmParameters::Instance()->GetDirLE << 
740        << particle->GetParticleName() << Z <<  << 
741     std::ifstream infile(ss.str(), std::ios::i << 
742     if(!pv->Retrieve(infile)) {                << 
743       delete pv;                               << 
744       return false;                            << 
745     }                                          << 
746     fElementData->InitialiseForElement(iz, pv) << 
747   }                                            << 
748   return true;                                 << 
749 }                                              << 
750                                                   743 
751 //....oooOO0OOooo........oooOO0OOooo........oo << 
752                                                   744