Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/utils/src/G4VMultipleScattering.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/utils/src/G4VMultipleScattering.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4VMultipleScattering.cc (Version 8.2)


  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: G4VMultipleScattering.cc,v 1.39 2006/06/29 19:55:25 gunter Exp $
                                                   >>  27 // GEANT4 tag $Name: geant4-08-02 $
 26 //                                                 28 //
 27 // -------------------------------------------     29 // -------------------------------------------------------------------
 28 //                                                 30 //
 29 // GEANT4 Class file                               31 // GEANT4 Class file
 30 //                                                 32 //
 31 //                                                 33 //
 32 // File name:     G4VMultipleScattering            34 // File name:     G4VMultipleScattering
 33 //                                                 35 //
 34 // Author:        Vladimir Ivanchenko on base      36 // Author:        Vladimir Ivanchenko on base of Laszlo Urban code
 35 //                                                 37 //
 36 // Creation date: 25.03.2003                       38 // Creation date: 25.03.2003
 37 //                                                 39 //
 38 // Modifications:                                  40 // Modifications:
 39 //                                                 41 //
                                                   >>  42 // 13.04.03 Change printout (V.Ivanchenko)
                                                   >>  43 // 04-06-03 Fix compilation warnings (V.Ivanchenko)
 40 // 16-07-03 Use G4VMscModel interface (V.Ivanc     44 // 16-07-03 Use G4VMscModel interface (V.Ivanchenko)
 41 // 03-11-03 Fix initialisation problem in Retr     45 // 03-11-03 Fix initialisation problem in RetrievePhysicsTable (V.Ivanchenko)
 42 // 04-11-03 Update PrintInfoDefinition (V.Ivan     46 // 04-11-03 Update PrintInfoDefinition (V.Ivanchenko)
 43 // 01-03-04 SampleCosineTheta signature change     47 // 01-03-04 SampleCosineTheta signature changed
 44 // 22-04-04 SampleCosineTheta signature change     48 // 22-04-04 SampleCosineTheta signature changed back to original
 45 // 27-08-04 Add InitialiseForRun method (V.Iva     49 // 27-08-04 Add InitialiseForRun method (V.Ivanchneko)
 46 // 08-11-04 Migration to new interface of Stor     50 // 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivantchenko)
 47 // 11-03-05 Shift verbose level by 1 (V.Ivantc     51 // 11-03-05 Shift verbose level by 1 (V.Ivantchenko)
 48 // 15-04-05 optimize internal interface (V.Iva     52 // 15-04-05 optimize internal interface (V.Ivanchenko)
 49 // 15-04-05 remove boundary flag (V.Ivanchenko     53 // 15-04-05 remove boundary flag (V.Ivanchenko)
 50 // 27-10-05 introduce virtual function MscStep     54 // 27-10-05 introduce virtual function MscStepLimitation() (V.Ivanchenko)
 51 // 12-04-07 Add verbosity at destruction (V.Iv << 
 52 // 27-10-07 Virtual functions moved to source  << 
 53 // 11-03-08 Set skin value does not effect ste << 
 54 // 24-06-09 Removed hidden bin in G4PhysicsVec << 
 55 // 04-06-13 Adoptation to MT mode (V.Ivanchenk << 
 56 //                                                 55 //
                                                   >>  56 // Class Description:
                                                   >>  57 //
                                                   >>  58 // It is the generic process of multiple scattering it includes common
                                                   >>  59 // part of calculations for all charged particles
 57                                                    60 
 58 // -------------------------------------------     61 // -------------------------------------------------------------------
 59 //                                                 62 //
 60 //....oooOO0OOooo........oooOO0OOooo........oo     63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 61 //....oooOO0OOooo........oooOO0OOooo........oo     64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 62                                                    65 
 63 #include "G4VMultipleScattering.hh"                66 #include "G4VMultipleScattering.hh"
 64 #include "G4PhysicalConstants.hh"              << 
 65 #include "G4SystemOfUnits.hh"                  << 
 66 #include "G4LossTableManager.hh"                   67 #include "G4LossTableManager.hh"
 67 #include "G4MaterialCutsCouple.hh"             << 
 68 #include "G4Step.hh"                               68 #include "G4Step.hh"
 69 #include "G4ParticleDefinition.hh"                 69 #include "G4ParticleDefinition.hh"
 70 #include "G4VEmFluctuationModel.hh"                70 #include "G4VEmFluctuationModel.hh"
                                                   >>  71 #include "G4DataVector.hh"
                                                   >>  72 #include "G4PhysicsTable.hh"
                                                   >>  73 #include "G4PhysicsVector.hh"
                                                   >>  74 #include "G4PhysicsLogVector.hh"
 71 #include "G4UnitsTable.hh"                         75 #include "G4UnitsTable.hh"
 72 #include "G4ProductionCutsTable.hh"                76 #include "G4ProductionCutsTable.hh"
 73 #include "G4Electron.hh"                       <<  77 #include "G4Region.hh"
                                                   >>  78 #include "G4RegionStore.hh"
                                                   >>  79 #include "G4PhysicsTableHelper.hh"
 74 #include "G4GenericIon.hh"                         80 #include "G4GenericIon.hh"
 75 #include "G4TransportationManager.hh"          << 
 76 #include "G4SafetyHelper.hh"                   << 
 77 #include "G4ParticleTable.hh"                  << 
 78 #include "G4ProcessVector.hh"                  << 
 79 #include "G4ProcessManager.hh"                 << 
 80 #include "G4LossTableBuilder.hh"               << 
 81 #include "G4EmTableUtil.hh"                    << 
 82 #include <iostream>                            << 
 83                                                    81 
 84 //....oooOO0OOooo........oooOO0OOooo........oo     82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 85                                                    83 
 86 G4VMultipleScattering::G4VMultipleScattering(c <<  84 G4VMultipleScattering::G4VMultipleScattering(const G4String& name, G4ProcessType type):
 87   : G4VContinuousDiscreteProcess("msc", fElect <<  85                  G4VContinuousDiscreteProcess(name, type),
 88   fNewPosition(0.,0.,0.),                      <<  86   theLambdaTable(0),
 89   fNewDirection(0.,0.,1.)                      <<  87   firstParticle(0),
                                                   >>  88   currentParticle(0),
                                                   >>  89   currentCouple(0),
                                                   >>  90   nBins(120),
                                                   >>  91   latDisplasment(true),
                                                   >>  92   buildLambdaTable(true)
 90 {                                                  93 {
 91   theParameters = G4EmParameters::Instance();  <<  94   minKinEnergy = 100.0*eV;
                                                   >>  95   maxKinEnergy = 100.0*TeV;
 92   SetVerboseLevel(1);                              96   SetVerboseLevel(1);
 93   SetProcessSubType(fMultipleScattering);      << 
 94                                                << 
 95   lowestKinEnergy = 10*CLHEP::eV;              << 
 96                                                << 
 97   geomMin = 0.05*CLHEP::nm;                    << 
 98   minDisplacement2 = geomMin*geomMin;          << 
 99                                                    97 
100   pParticleChange = &fParticleChange;              98   pParticleChange = &fParticleChange;
101                                                    99 
102   modelManager = new G4EmModelManager();          100   modelManager = new G4EmModelManager();
103   emManager = G4LossTableManager::Instance();  << 101   (G4LossTableManager::Instance())->Register(this);
104   mscModels.reserve(2);                        << 102 
105   emManager->Register(this);                   << 
106 }                                                 103 }
107                                                   104 
108 //....oooOO0OOooo........oooOO0OOooo........oo    105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
109                                                   106 
110 G4VMultipleScattering::~G4VMultipleScattering(    107 G4VMultipleScattering::~G4VMultipleScattering()
111 {                                                 108 {
112   delete modelManager;                            109   delete modelManager;
113   emManager->DeRegister(this);                 << 110   if (theLambdaTable) theLambdaTable->clearAndDestroy();
                                                   >> 111   (G4LossTableManager::Instance())->DeRegister(this);
114 }                                                 112 }
115                                                   113 
116 //....oooOO0OOooo........oooOO0OOooo........oo    114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
117                                                   115 
118 void G4VMultipleScattering::AddEmModel(G4int o << 116 void G4VMultipleScattering::BuildPhysicsTable(const G4ParticleDefinition& part)
119                                        const G << 
120 {                                                 117 {
121   if(nullptr == ptr) { return; }               << 118   G4String num = part.GetParticleName();
122   G4VEmFluctuationModel* fm = nullptr;         << 119   if(1 < verboseLevel) {
123   modelManager->AddEmModel(order, ptr, fm, reg << 120     //    G4cout << "========================================================" << G4endl;
124   ptr->SetParticleChange(pParticleChange);     << 121     G4cout << "### G4VMultipleScattering::BuildPhysicsTable() for "
125 }                                              << 122            << GetProcessName()
                                                   >> 123            << " and particle " << num
                                                   >> 124            << G4endl;
                                                   >> 125   }
                                                   >> 126 
                                                   >> 127   if (buildLambdaTable && firstParticle == &part) {
                                                   >> 128 
                                                   >> 129     const G4ProductionCutsTable* theCoupleTable=
                                                   >> 130           G4ProductionCutsTable::GetProductionCutsTable();
                                                   >> 131     size_t numOfCouples = theCoupleTable->GetTableSize();
                                                   >> 132 
                                                   >> 133     for (size_t i=0; i<numOfCouples; i++) {
                                                   >> 134 
                                                   >> 135       if (theLambdaTable->GetFlag(i)) {
                                                   >> 136         // create physics vector and fill it
                                                   >> 137         const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
                                                   >> 138         G4PhysicsVector* aVector = PhysicsVector(couple);
                                                   >> 139         modelManager->FillLambdaVector(aVector, couple, false);
                                                   >> 140         G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector);
                                                   >> 141       }
                                                   >> 142     }
126                                                   143 
127 //....oooOO0OOooo........oooOO0OOooo........oo << 144     if(1 < verboseLevel) {
                                                   >> 145       G4cout << "Lambda table is built for "
                                                   >> 146              << num
                                                   >> 147              << G4endl;
                                                   >> 148     }
                                                   >> 149   }
                                                   >> 150   if(verboseLevel>0 && ( num == "e-" || num == "mu+" ||  
                                                   >> 151                          num == "proton" || num == "pi-" || num == "GenericIon")) {
                                                   >> 152     PrintInfoDefinition();
                                                   >> 153     if(2 < verboseLevel && theLambdaTable) G4cout << *theLambdaTable << G4endl;
                                                   >> 154   }
128                                                   155 
129 void G4VMultipleScattering::SetEmModel(G4VMscM << 156   if(1 < verboseLevel) {
130 {                                              << 157     G4cout << "### G4VMultipleScattering::BuildPhysicsTable() done for "
131   if(nullptr == ptr) { return; }               << 158            << GetProcessName()
132   if(!mscModels.empty()) {                     << 159            << " and particle " << num
133     for(auto & msc : mscModels) { if(msc == pt << 160            << G4endl;
134   }                                               161   }
135   mscModels.push_back(ptr);                    << 
136 }                                                 162 }
137                                                   163 
138 //....oooOO0OOooo........oooOO0OOooo........oo    164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
139                                                   165 
140 void                                           << 166 void G4VMultipleScattering::PreparePhysicsTable(const G4ParticleDefinition& part)
141 G4VMultipleScattering::PreparePhysicsTable(con << 
142 {                                                 167 {
143   G4bool master = emManager->IsMaster();       << 168   if (!firstParticle) {
144   if (nullptr == firstParticle) { firstParticl << 169     currentCouple = 0;
                                                   >> 170     if(part.GetParticleType() == "nucleus" && 
                                                   >> 171        part.GetParticleSubType() == "generic") 
                                                   >> 172          firstParticle = G4GenericIon::GenericIon();
                                                   >> 173     else firstParticle = &part; 
                                                   >> 174     currentParticle = &part;
                                                   >> 175   }
145                                                   176 
146   emManager->PreparePhysicsTable(&part, this); << 177   if(1 < verboseLevel) {
147   currParticle = nullptr;                      << 178     //    G4cout << "========================================================" << G4endl;
                                                   >> 179     G4cout << "### G4VMultipleScattering::PrepearPhysicsTable() for "
                                                   >> 180            << GetProcessName()
                                                   >> 181            << " and particle " << part.GetParticleName()
                                                   >> 182            << " local particle " << firstParticle->GetParticleName()
                                                   >> 183            << G4endl;
                                                   >> 184   }
148                                                   185 
149   if(firstParticle == &part) {                    186   if(firstParticle == &part) {
150     baseMat = emManager->GetTableBuilder()->Ge << 
151     G4EmTableUtil::PrepareMscProcess(this, par << 
152              stepLimit, facrange,              << 
153              latDisplacement, master,          << 
154              isIon, baseMat);                  << 
155                                                << 
156     numberOfModels = modelManager->NumberOfMod << 
157     currentModel = GetModelByIndex(0);         << 
158                                                << 
159     if (nullptr == safetyHelper) {             << 
160       safetyHelper = G4TransportationManager:: << 
161   ->GetSafetyHelper();                         << 
162       safetyHelper->InitialiseHelper();        << 
163     }                                          << 
164   }                                            << 
165 }                                              << 
166                                                   187 
167 //....oooOO0OOooo........oooOO0OOooo........oo << 188     InitialiseProcess(firstParticle);
                                                   >> 189     if(buildLambdaTable)
                                                   >> 190       theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
                                                   >> 191     const G4DataVector* theCuts = 
                                                   >> 192       modelManager->Initialise(firstParticle, 0, 10.0, verboseLevel);
168                                                   193 
169 void G4VMultipleScattering::BuildPhysicsTable( << 194     if(2 < verboseLevel) G4cout << theCuts << G4endl;
170 {                                              << 
171   G4bool master = emManager->IsMaster();       << 
172                                                   195 
173   if(firstParticle == &part) {                 << 
174     emManager->BuildPhysicsTable(&part);       << 
175   }                                            << 
176   const G4VMultipleScattering* ptr = this;     << 
177   if(!master) {                                << 
178     ptr = static_cast<const G4VMultipleScatter << 
179   }                                               196   }
180                                                << 
181   G4EmTableUtil::BuildMscProcess(this, ptr, pa << 
182          numberOfModels, master);              << 
183 }                                                 197 }
184                                                   198 
185 //....oooOO0OOooo........oooOO0OOooo........oo    199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
186                                                   200 
187 void G4VMultipleScattering::StreamInfo(std::os << 201 void G4VMultipleScattering::AddEmModel(G4int order, G4VEmModel* p,
188                   const G4ParticleDefinition&  << 202                                  const G4Region* region)
189 {                                                 203 {
190   G4String indent = (rst ? "  " : "");         << 204   G4VEmFluctuationModel* fm = 0;
191   outFile << G4endl << indent << GetProcessNam << 205   modelManager->AddEmModel(order, p, fm, region);
192   if (!rst) outFile << " for " << part.GetPart << 206   if(p)p->SetParticleChange(pParticleChange);
193   outFile  << "  SubType= " << GetProcessSubTy << 
194   modelManager->DumpModelList(outFile, verbose << 
195 }                                                 207 }
196                                                   208 
197 //....oooOO0OOooo........oooOO0OOooo........oo    209 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
198                                                   210 
199 void G4VMultipleScattering::StartTracking(G4Tr << 211 void G4VMultipleScattering::PrintInfoDefinition()
200 {                                                 212 {
201   G4VEnergyLossProcess* eloss = nullptr;       << 213   if (0 < verboseLevel) {
202   if(track->GetParticleDefinition() != currPar << 214     G4cout << G4endl << GetProcessName() << ":  Model variant of multiple scattering "
203     currParticle = track->GetParticleDefinitio << 215      << "for " << firstParticle->GetParticleName()
204     fIonisation = emManager->GetEnergyLossProc << 216      << G4endl;
205     eloss = fIonisation;                       << 217     if (theLambdaTable) {
206   }                                            << 218       G4cout << "      Lambda tables from "
207   for(G4int i=0; i<numberOfModels; ++i) {      << 219        << G4BestUnit(MinKinEnergy(),"Energy")
208     G4VMscModel* msc = GetModelByIndex(i);     << 220        << " to "
209     msc->StartTracking(track);                 << 221        << G4BestUnit(MaxKinEnergy(),"Energy")
210     if(nullptr != eloss) {                     << 222        << " in " << nBins << " bins."
211       msc->SetIonisation(eloss, currParticle); << 223        << G4endl;
212     }                                             224     }
213   }                                            << 225     PrintInfo();
214 }                                              << 226     if (2 < verboseLevel) {
215                                                << 227       G4cout << "LambdaTable address= " << theLambdaTable << G4endl;
216 //....oooOO0OOooo........oooOO0OOooo........oo << 228       if(theLambdaTable) G4cout << (*theLambdaTable) << G4endl;
217                                                << 
218 G4double G4VMultipleScattering::AlongStepGetPh << 
219                              const G4Track& tr << 
220                              G4double,         << 
221                              G4double currentM << 
222                              G4double&,        << 
223                              G4GPILSelection*  << 
224 {                                              << 
225   // get Step limit proposed by the process    << 
226   *selection = NotCandidateForSelection;       << 
227   physStepLimit = gPathLength = tPathLength =  << 
228                                                << 
229   G4double ekin = track.GetKineticEnergy();    << 
230   /*                                           << 
231   G4cout << "MSC::AlongStepGPIL: Ekin= " << ek << 
232          << "  " << currParticle->GetParticleN << 
233          << " currMod " << currentModel        << 
234          << G4endl;                            << 
235   */                                           << 
236   // isIon flag is used only to select a model << 
237   if(isIon) {                                  << 
238     ekin *= proton_mass_c2/track.GetParticleDe << 
239   }                                            << 
240   const G4MaterialCutsCouple* couple = track.G << 
241                                                << 
242   // select new model, static cast is possible << 
243   if(1 < numberOfModels) {                     << 
244     currentModel =                             << 
245       static_cast<G4VMscModel*>(SelectModel(ek << 
246   }                                            << 
247   currentModel->SetCurrentCouple(couple);      << 
248   // msc is active is model is active, energy  << 
249   // and step size is above the limit;         << 
250   // if it is active msc may limit the step    << 
251   if(currentModel->IsActive(ekin) && tPathLeng << 
252      && ekin >= lowestKinEnergy) {             << 
253     isActive = true;                           << 
254     tPathLength =                              << 
255       currentModel->ComputeTruePathLengthLimit << 
256     if (tPathLength < physStepLimit) {         << 
257       *selection = CandidateForSelection;      << 
258     }                                             229     }
259   } else {                                     << 230   }
260     isActive = false;                          << 
261     gPathLength = DBL_MAX;                     << 
262   }                                            << 
263                                                << 
264   //if(currParticle->GetPDGMass() > GeV)       << 
265   /*                                           << 
266   G4cout << "MSC::AlongStepGPIL: Ekin= " << ek << 
267          << "  " << currParticle->GetParticleN << 
268          << " gPathLength= " << gPathLength    << 
269          << " tPathLength= " << tPathLength    << 
270          << " currentMinimalStep= " << current << 
271          << " isActive " << isActive << G4endl << 
272   */                                           << 
273   return gPathLength;                          << 
274 }                                                 231 }
275                                                   232 
276 //....oooOO0OOooo........oooOO0OOooo........oo    233 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
277                                                   234 
278 G4double                                       << 235 G4PhysicsVector* G4VMultipleScattering::PhysicsVector(const G4MaterialCutsCouple* couple)
279 G4VMultipleScattering::PostStepGetPhysicalInte << 
280               const G4Track&, G4double, G4Forc << 
281 {                                                 236 {
282   *condition = NotForced;                      << 237   G4int nbins = 3;
283   return DBL_MAX;                              << 238   if( couple->IsUsed() ) nbins = nBins;
                                                   >> 239   G4PhysicsVector* v = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nbins);
                                                   >> 240   return v;
284 }                                                 241 }
285                                                   242 
286 //....oooOO0OOooo........oooOO0OOooo........oo << 243 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
287                                                   244 
288 G4VParticleChange*                             << 245 G4bool G4VMultipleScattering::StorePhysicsTable(const G4ParticleDefinition* part,
289 G4VMultipleScattering::AlongStepDoIt(const G4T << 246                         const G4String& directory,
                                                   >> 247                               G4bool ascii)
290 {                                                 248 {
291   fParticleChange.InitialiseMSC(track, step);  << 249   G4bool yes = true;
292   fNewPosition = fParticleChange.GetProposedPo << 250   if ( theLambdaTable && part == firstParticle) {
293   fPositionChanged = false;                    << 251     const G4String name = GetPhysicsTableFileName(part,directory,"Lambda",ascii);
294                                                << 252     G4bool yes = theLambdaTable->StorePhysicsTable(name,ascii);
295   G4double geomLength = step.GetStepLength();  << 253 
296                                                << 254     if ( yes ) {
297   // very small step - no msc                  << 255       if ( verboseLevel>0 ) {
298   if(!isActive) {                              << 256         G4cout << "Physics table are stored for " << part->GetParticleName()
299     tPathLength = geomLength;                  << 257                << " and process " << GetProcessName()
300                                                << 258          << " in the directory <" << directory
301     // sample msc                              << 259          << "> " << G4endl;
302   } else {                                     << 
303     G4double range =                           << 
304       currentModel->GetRange(currParticle,trac << 
305                              track.GetMaterial << 
306                                                << 
307     tPathLength = currentModel->ComputeTrueSte << 
308                                                << 
309     /*                                         << 
310     if(currParticle->GetPDGMass() > 0.9*GeV)   << 
311     G4cout << "G4VMsc::AlongStepDoIt: GeomLeng << 
312            << geomLength                       << 
313            << " tPathLength= " << tPathLength  << 
314            << " physStepLimit= " << physStepLi << 
315            << " dr= " << range - tPathLength   << 
316            << " ekin= " << track.GetKineticEne << 
317     */                                         << 
318     // protection against wrong t->g->t conver << 
319     tPathLength = std::min(tPathLength, physSt << 
320                                                << 
321     // do not sample scattering at the last or << 
322     if(tPathLength < range && tPathLength > ge << 
323                                                << 
324       static const G4double minSafety = 1.20*C << 
325       static const G4double sFact = 0.99;      << 
326                                                << 
327       G4ThreeVector displacement = currentMode << 
328         step.GetPostStepPoint()->GetMomentumDi << 
329                                                << 
330       G4double r2 = displacement.mag2();       << 
331       //G4cout << "    R= " << sqrt(r2) << " R << 
332       //     << " flag= " << fDispBeyondSafety << 
333       if(r2 > minDisplacement2) {              << 
334                                                << 
335         fPositionChanged = true;               << 
336         G4double dispR = std::sqrt(r2);        << 
337         G4double postSafety =                  << 
338           sFact*safetyHelper->ComputeSafety(fN << 
339         //G4cout<<"    R= "<< dispR<<" postSaf << 
340                                                << 
341         // far away from geometry boundary     << 
342         if(postSafety > 0.0 && dispR <= postSa << 
343           fNewPosition += displacement;        << 
344                                                << 
345           //near the boundary                  << 
346         } else {                               << 
347           // displaced point is definitely wit << 
348           //G4cout<<"    R= "<<dispR<<" postSa << 
349           if(dispR < postSafety) {             << 
350             fNewPosition += displacement;      << 
351                                                << 
352             // reduced displacement            << 
353           } else if(postSafety > geomMin) {    << 
354             fNewPosition += displacement*(post << 
355                                                << 
356             // very small postSafety           << 
357           } else {                             << 
358             fPositionChanged = false;          << 
359           }                                    << 
360         }                                      << 
361         if(fPositionChanged) {                 << 
362           safetyHelper->ReLocateWithinVolume(f << 
363           fParticleChange.ProposePosition(fNew << 
364         }                                      << 
365       }                                           260       }
                                                   >> 261     } else {
                                                   >> 262       G4cout << "Fail to store Physics Table for " << part->GetParticleName()
                                                   >> 263              << " and process " << GetProcessName()
                                                   >> 264        << " in the directory <" << directory
                                                   >> 265        << "> " << G4endl;
366     }                                             266     }
367   }                                               267   }
368   fParticleChange.ProposeTrueStepLength(tPathL << 268   return yes;
369   return &fParticleChange;                     << 
370 }                                              << 
371                                                << 
372 //....oooOO0OOooo........oooOO0OOooo........oo << 
373                                                << 
374 G4double G4VMultipleScattering::GetContinuousS << 
375                                        const G << 
376                                        G4doubl << 
377                                        G4doubl << 
378                                        G4doubl << 
379 {                                              << 
380   G4GPILSelection selection = NotCandidateForS << 
381   G4double x = AlongStepGetPhysicalInteraction << 
382                                                << 
383                                                << 
384                                                << 
385   return x;                                    << 
386 }                                              << 
387                                                << 
388 //....oooOO0OOooo........oooOO0OOooo........oo << 
389                                                << 
390 G4double G4VMultipleScattering::ContinuousStep << 
391                                        const G << 
392                                        G4doubl << 
393                                        G4doubl << 
394                                        G4doubl << 
395 {                                              << 
396   return GetContinuousStepLimit(track,previous << 
397                                 currentSafety) << 
398 }                                              << 
399                                                << 
400 //....oooOO0OOooo........oooOO0OOooo........oo << 
401                                                << 
402 G4double G4VMultipleScattering::GetMeanFreePat << 
403               const G4Track&, G4double, G4Forc << 
404 {                                              << 
405   *condition = Forced;                         << 
406   return DBL_MAX;                              << 
407 }                                                 269 }
408                                                   270 
409 //....oooOO0OOooo........oooOO0OOooo........oo    271 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
410                                                   272 
411 G4bool                                         << 273 G4bool G4VMultipleScattering::RetrievePhysicsTable(const G4ParticleDefinition* part,
412 G4VMultipleScattering::StorePhysicsTable(const << 274                      const G4String& directory,
413                                          const << 275                                    G4bool ascii)
414                                          G4boo << 276 {
415 {                                              << 277   if(0 < verboseLevel) {
                                                   >> 278 //    G4cout << "========================================================" << G4endl;
                                                   >> 279     G4cout << "G4VMultipleScattering::RetrievePhysicsTable() for "
                                                   >> 280            << part->GetParticleName() << " and process "
                                                   >> 281      << GetProcessName() << G4endl;
                                                   >> 282   }
416   G4bool yes = true;                              283   G4bool yes = true;
417   if(part != firstParticle || !emManager->IsMa << 
418                                                   284 
419   return G4EmTableUtil::StoreMscTable(this, pa << 285   if(!buildLambdaTable || firstParticle != part) return yes;
420               numberOfModels, verboseLevel,    << 
421                                       ascii);  << 
422 }                                              << 
423                                                   286 
424 //....oooOO0OOooo........oooOO0OOooo........oo << 287   const G4String particleName = part->GetParticleName();
425                                                   288 
426 G4bool                                         << 289   G4String filename = GetPhysicsTableFileName(part,directory,"Lambda",ascii);
427 G4VMultipleScattering::RetrievePhysicsTable(co << 290   yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,filename,ascii);
428                                             co << 291   if ( yes ) {
429                                             G4 << 292     if (0 < verboseLevel) {
430 {                                              << 293         G4cout << "Lambda table for " << part->GetParticleName() << " is retrieved from <"
431   return true;                                 << 294                << filename << ">"
                                                   >> 295                << G4endl;
                                                   >> 296     }
                                                   >> 297   } else {
                                                   >> 298     if (1 < verboseLevel) {
                                                   >> 299         G4cout << "Lambda table for " << part->GetParticleName() << " in file <"
                                                   >> 300                << filename << "> is not exist"
                                                   >> 301                << G4endl;
                                                   >> 302     }
                                                   >> 303   }
                                                   >> 304   return yes;
432 }                                                 305 }
433                                                   306 
434 //....oooOO0OOooo........oooOO0OOooo........oo    307 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
435                                                   308 
436 void G4VMultipleScattering::ProcessDescription << 309 void G4VMultipleScattering::MscStepLimitation(G4bool, G4double)
437 {                                              << 310 {}
438   if(nullptr != firstParticle) {               << 
439     StreamInfo(outFile, *firstParticle, true); << 
440   }                                            << 
441 }                                              << 
442                                                   311 
443 //....oooOO0OOooo........oooOO0OOooo........oo    312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
444                                                   313 
445                                                   314