Geant4 Cross Reference |
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.60 2008/11/20 20:32:40 vnivanch Exp $ >> 27 // GEANT4 tag $Name: geant4-09-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 55 // 12-04-07 Add verbosity at destruction (V.Ivanchenko) 52 // 27-10-07 Virtual functions moved to source 56 // 27-10-07 Virtual functions moved to source (V.Ivanchenko) 53 // 11-03-08 Set skin value does not effect ste 57 // 11-03-08 Set skin value does not effect step limit type (V.Ivanchenko) 54 // 24-06-09 Removed hidden bin in G4PhysicsVec << 55 // 04-06-13 Adoptation to MT mode (V.Ivanchenk << 56 // 58 // >> 59 // Class Description: >> 60 // >> 61 // It is the generic process of multiple scattering it includes common >> 62 // part of calculations for all charged particles 57 63 58 // ------------------------------------------- 64 // ------------------------------------------------------------------- 59 // 65 // 60 //....oooOO0OOooo........oooOO0OOooo........oo 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 61 //....oooOO0OOooo........oooOO0OOooo........oo 67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 62 68 63 #include "G4VMultipleScattering.hh" 69 #include "G4VMultipleScattering.hh" 64 #include "G4PhysicalConstants.hh" << 65 #include "G4SystemOfUnits.hh" << 66 #include "G4LossTableManager.hh" 70 #include "G4LossTableManager.hh" 67 #include "G4MaterialCutsCouple.hh" << 68 #include "G4Step.hh" 71 #include "G4Step.hh" 69 #include "G4ParticleDefinition.hh" 72 #include "G4ParticleDefinition.hh" 70 #include "G4VEmFluctuationModel.hh" 73 #include "G4VEmFluctuationModel.hh" >> 74 #include "G4DataVector.hh" >> 75 #include "G4PhysicsTable.hh" >> 76 #include "G4PhysicsVector.hh" >> 77 #include "G4PhysicsLogVector.hh" 71 #include "G4UnitsTable.hh" 78 #include "G4UnitsTable.hh" 72 #include "G4ProductionCutsTable.hh" 79 #include "G4ProductionCutsTable.hh" 73 #include "G4Electron.hh" << 80 #include "G4Region.hh" >> 81 #include "G4RegionStore.hh" >> 82 #include "G4PhysicsTableHelper.hh" 74 #include "G4GenericIon.hh" 83 #include "G4GenericIon.hh" 75 #include "G4TransportationManager.hh" << 84 #include "G4Electron.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 85 84 //....oooOO0OOooo........oooOO0OOooo........oo 86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 85 87 86 G4VMultipleScattering::G4VMultipleScattering(c << 88 G4VMultipleScattering::G4VMultipleScattering(const G4String& name, 87 : G4VContinuousDiscreteProcess("msc", fElect << 89 G4ProcessType type): 88 fNewPosition(0.,0.,0.), << 90 G4VContinuousDiscreteProcess(name, type), 89 fNewDirection(0.,0.,1.) << 91 buildLambdaTable(true), >> 92 theLambdaTable(0), >> 93 firstParticle(0), >> 94 stepLimit(fUseSafety), >> 95 skin(3.0), >> 96 facrange(0.02), >> 97 facgeom(2.5), >> 98 latDisplasment(true), >> 99 currentParticle(0), >> 100 currentCouple(0) 90 { 101 { 91 theParameters = G4EmParameters::Instance(); << 92 SetVerboseLevel(1); 102 SetVerboseLevel(1); 93 SetProcessSubType(fMultipleScattering); 103 SetProcessSubType(fMultipleScattering); 94 104 95 lowestKinEnergy = 10*CLHEP::eV; << 105 // Size of tables assuming spline >> 106 minKinEnergy = 0.1*keV; >> 107 maxKinEnergy = 100.0*TeV; >> 108 nBins = 84; 96 109 97 geomMin = 0.05*CLHEP::nm; << 110 // default limit on polar angle 98 minDisplacement2 = geomMin*geomMin; << 111 polarAngleLimit = 0.0; 99 112 100 pParticleChange = &fParticleChange; 113 pParticleChange = &fParticleChange; 101 114 102 modelManager = new G4EmModelManager(); 115 modelManager = new G4EmModelManager(); 103 emManager = G4LossTableManager::Instance(); << 116 (G4LossTableManager::Instance())->Register(this); 104 mscModels.reserve(2); << 117 105 emManager->Register(this); << 106 } 118 } 107 119 108 //....oooOO0OOooo........oooOO0OOooo........oo 120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 109 121 110 G4VMultipleScattering::~G4VMultipleScattering( 122 G4VMultipleScattering::~G4VMultipleScattering() 111 { 123 { >> 124 if(1 < verboseLevel) { >> 125 G4cout << "G4VMultipleScattering destruct " << GetProcessName() >> 126 << G4endl; >> 127 } 112 delete modelManager; 128 delete modelManager; 113 emManager->DeRegister(this); << 129 if (theLambdaTable) { >> 130 theLambdaTable->clearAndDestroy(); >> 131 delete theLambdaTable; >> 132 } >> 133 (G4LossTableManager::Instance())->DeRegister(this); 114 } 134 } 115 135 116 //....oooOO0OOooo........oooOO0OOooo........oo 136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 117 137 118 void G4VMultipleScattering::AddEmModel(G4int o << 138 void G4VMultipleScattering::BuildPhysicsTable(const G4ParticleDefinition& part) 119 const G << 120 { 139 { 121 if(nullptr == ptr) { return; } << 140 G4String num = part.GetParticleName(); 122 G4VEmFluctuationModel* fm = nullptr; << 141 if(1 < verboseLevel) { 123 modelManager->AddEmModel(order, ptr, fm, reg << 142 G4cout << "### G4VMultipleScattering::BuildPhysicsTable() for " 124 ptr->SetParticleChange(pParticleChange); << 143 << GetProcessName() 125 } << 144 << " and particle " << num >> 145 << G4endl; >> 146 } >> 147 >> 148 if (buildLambdaTable && firstParticle == &part) { >> 149 >> 150 const G4ProductionCutsTable* theCoupleTable= >> 151 G4ProductionCutsTable::GetProductionCutsTable(); >> 152 size_t numOfCouples = theCoupleTable->GetTableSize(); >> 153 >> 154 for (size_t i=0; i<numOfCouples; i++) { >> 155 >> 156 if (theLambdaTable->GetFlag(i)) { >> 157 // create physics vector and fill it >> 158 const G4MaterialCutsCouple* couple = >> 159 theCoupleTable->GetMaterialCutsCouple(i); >> 160 G4PhysicsVector* aVector = PhysicsVector(couple); >> 161 modelManager->FillLambdaVector(aVector, couple, false); >> 162 G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector); >> 163 } >> 164 } 126 165 127 //....oooOO0OOooo........oooOO0OOooo........oo << 166 if(1 < verboseLevel) { >> 167 G4cout << "Lambda table is built for " >> 168 << num >> 169 << G4endl; >> 170 } >> 171 } >> 172 if(verboseLevel>0 && ( num == "e-" || num == "mu+" || >> 173 num == "proton" || num == "pi-" || >> 174 num == "GenericIon")) { >> 175 PrintInfoDefinition(); >> 176 if(2 < verboseLevel && theLambdaTable) G4cout << *theLambdaTable << G4endl; >> 177 } 128 178 129 void G4VMultipleScattering::SetEmModel(G4VMscM << 179 if(1 < verboseLevel) { 130 { << 180 G4cout << "### G4VMultipleScattering::BuildPhysicsTable() done for " 131 if(nullptr == ptr) { return; } << 181 << GetProcessName() 132 if(!mscModels.empty()) { << 182 << " and particle " << num 133 for(auto & msc : mscModels) { if(msc == pt << 183 << G4endl; 134 } 184 } 135 mscModels.push_back(ptr); << 136 } 185 } 137 186 138 //....oooOO0OOooo........oooOO0OOooo........oo 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 139 188 140 void << 189 void G4VMultipleScattering::PreparePhysicsTable(const G4ParticleDefinition& part) 141 G4VMultipleScattering::PreparePhysicsTable(con << 142 { 190 { 143 G4bool master = emManager->IsMaster(); << 191 if (!firstParticle) { 144 if (nullptr == firstParticle) { firstParticl << 192 currentCouple = 0; 145 << 193 if(part.GetParticleType() == "nucleus" && 146 emManager->PreparePhysicsTable(&part, this); << 194 part.GetParticleSubType() == "generic") { 147 currParticle = nullptr; << 195 firstParticle = G4GenericIon::GenericIon(); >> 196 } else { >> 197 firstParticle = ∂ >> 198 } 148 199 149 if(firstParticle == &part) { << 200 currentParticle = ∂ 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 } 201 } 165 } << 166 << 167 //....oooOO0OOooo........oooOO0OOooo........oo << 168 202 169 void G4VMultipleScattering::BuildPhysicsTable( << 203 if(1 < verboseLevel) { 170 { << 204 G4cout << "### G4VMultipleScattering::PrepearPhysicsTable() for " 171 G4bool master = emManager->IsMaster(); << 205 << GetProcessName() >> 206 << " and particle " << part.GetParticleName() >> 207 << " local particle " << firstParticle->GetParticleName() >> 208 << G4endl; >> 209 } 172 210 173 if(firstParticle == &part) { 211 if(firstParticle == &part) { 174 emManager->BuildPhysicsTable(&part); << 175 } << 176 const G4VMultipleScattering* ptr = this; << 177 if(!master) { << 178 ptr = static_cast<const G4VMultipleScatter << 179 } << 180 212 181 G4EmTableUtil::BuildMscProcess(this, ptr, pa << 213 InitialiseProcess(firstParticle); 182 numberOfModels, master); << 214 if(buildLambdaTable) 183 } << 215 theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable); >> 216 const G4DataVector* theCuts = >> 217 modelManager->Initialise(firstParticle, >> 218 G4Electron::Electron(), >> 219 10.0, verboseLevel); 184 220 185 //....oooOO0OOooo........oooOO0OOooo........oo << 221 if(2 < verboseLevel) G4cout << theCuts << G4endl; 186 222 187 void G4VMultipleScattering::StreamInfo(std::os << 223 } 188 const G4ParticleDefinition& << 189 { << 190 G4String indent = (rst ? " " : ""); << 191 outFile << G4endl << indent << GetProcessNam << 192 if (!rst) outFile << " for " << part.GetPart << 193 outFile << " SubType= " << GetProcessSubTy << 194 modelManager->DumpModelList(outFile, verbose << 195 } 224 } 196 225 197 //....oooOO0OOooo........oooOO0OOooo........oo 226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 198 227 199 void G4VMultipleScattering::StartTracking(G4Tr << 228 void G4VMultipleScattering::PrintInfoDefinition() 200 { 229 { 201 G4VEnergyLossProcess* eloss = nullptr; << 230 if (0 < verboseLevel) { 202 if(track->GetParticleDefinition() != currPar << 231 G4cout << G4endl << GetProcessName() 203 currParticle = track->GetParticleDefinitio << 232 << ": for " << firstParticle->GetParticleName() 204 fIonisation = emManager->GetEnergyLossProc << 233 << " SubType= " << GetProcessSubType() 205 eloss = fIonisation; << 234 << G4endl; 206 } << 235 if (theLambdaTable) { 207 for(G4int i=0; i<numberOfModels; ++i) { << 236 G4cout << " Lambda tables from " 208 G4VMscModel* msc = GetModelByIndex(i); << 237 << G4BestUnit(MinKinEnergy(),"Energy") 209 msc->StartTracking(track); << 238 << " to " 210 if(nullptr != eloss) { << 239 << G4BestUnit(MaxKinEnergy(),"Energy") 211 msc->SetIonisation(eloss, currParticle); << 240 << " in " << nBins << " bins, spline: " >> 241 << (G4LossTableManager::Instance())->SplineFlag() >> 242 << G4endl; >> 243 } >> 244 PrintInfo(); >> 245 modelManager->DumpModelList(verboseLevel); >> 246 if (2 < verboseLevel) { >> 247 G4cout << "LambdaTable address= " << theLambdaTable << G4endl; >> 248 if(theLambdaTable) G4cout << (*theLambdaTable) << G4endl; 212 } 249 } 213 } 250 } 214 } 251 } 215 252 216 //....oooOO0OOooo........oooOO0OOooo........oo 253 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 217 254 218 G4double G4VMultipleScattering::AlongStepGetPh 255 G4double G4VMultipleScattering::AlongStepGetPhysicalInteractionLength( 219 const G4Track& tr 256 const G4Track& track, 220 G4double, 257 G4double, 221 G4double currentM 258 G4double currentMinimalStep, 222 G4double&, << 259 G4double& currentSafety, 223 G4GPILSelection* 260 G4GPILSelection* selection) 224 { 261 { 225 // get Step limit proposed by the process 262 // get Step limit proposed by the process 226 *selection = NotCandidateForSelection; << 263 valueGPILSelectionMSC = NotCandidateForSelection; 227 physStepLimit = gPathLength = tPathLength = << 264 G4double steplength = GetMscContinuousStepLimit(track, 228 << 265 track.GetKineticEnergy(), 229 G4double ekin = track.GetKineticEnergy(); << 266 currentMinimalStep, 230 /* << 267 currentSafety); 231 G4cout << "MSC::AlongStepGPIL: Ekin= " << ek << 268 // G4cout << "StepLimit= " << steplength << G4endl; 232 << " " << currParticle->GetParticleN << 269 // set return value for G4GPILSelection 233 << " currMod " << currentModel << 270 *selection = valueGPILSelectionMSC; 234 << G4endl; << 271 return steplength; 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 } << 259 } else { << 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 } 272 } 275 273 276 //....oooOO0OOooo........oooOO0OOooo........oo 274 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 277 275 278 G4double << 276 G4double G4VMultipleScattering::PostStepGetPhysicalInteractionLength( 279 G4VMultipleScattering::PostStepGetPhysicalInte << 280 const G4Track&, G4double, G4Forc 277 const G4Track&, G4double, G4ForceCondition* condition) 281 { 278 { 282 *condition = NotForced; << 279 *condition = Forced; 283 return DBL_MAX; 280 return DBL_MAX; 284 } 281 } 285 282 286 //....oooOO0OOooo........oooOO0OOooo........oo 283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 287 284 288 G4VParticleChange* << 285 G4double G4VMultipleScattering::GetContinuousStepLimit( 289 G4VMultipleScattering::AlongStepDoIt(const G4T << 286 const G4Track& track, >> 287 G4double previousStepSize, >> 288 G4double currentMinimalStep, >> 289 G4double& currentSafety) 290 { 290 { 291 fParticleChange.InitialiseMSC(track, step); << 291 return GetMscContinuousStepLimit(track,previousStepSize,currentMinimalStep, 292 fNewPosition = fParticleChange.GetProposedPo << 292 currentSafety); 293 fPositionChanged = false; << 293 } 294 << 295 G4double geomLength = step.GetStepLength(); << 296 294 297 // very small step - no msc << 295 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 298 if(!isActive) { << 299 tPathLength = geomLength; << 300 296 301 // sample msc << 297 G4double G4VMultipleScattering::GetMeanFreePath( 302 } else { << 298 const G4Track&, G4double, G4ForceCondition* condition) 303 G4double range = << 299 { 304 currentModel->GetRange(currParticle,trac << 300 *condition = Forced; 305 track.GetMaterial << 301 return DBL_MAX; 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 } << 366 } << 367 } << 368 fParticleChange.ProposeTrueStepLength(tPathL << 369 return &fParticleChange; << 370 } 302 } 371 303 372 //....oooOO0OOooo........oooOO0OOooo........oo 304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 373 305 374 G4double G4VMultipleScattering::GetContinuousS << 306 G4VParticleChange* G4VMultipleScattering::AlongStepDoIt(const G4Track&, 375 const G << 307 const G4Step& step) 376 G4doubl << 377 G4doubl << 378 G4doubl << 379 { 308 { 380 G4GPILSelection selection = NotCandidateForS << 309 fParticleChange.ProposeTrueStepLength( 381 G4double x = AlongStepGetPhysicalInteraction << 310 currentModel->ComputeTrueStepLength(step.GetStepLength())); 382 << 311 return &fParticleChange; 383 << 384 << 385 return x; << 386 } 312 } 387 313 388 //....oooOO0OOooo........oooOO0OOooo........oo 314 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 389 315 390 G4double G4VMultipleScattering::ContinuousStep << 316 G4VParticleChange* G4VMultipleScattering::PostStepDoIt(const G4Track& track, 391 const G << 317 const G4Step& step) 392 G4doubl << 393 G4doubl << 394 G4doubl << 395 { 318 { 396 return GetContinuousStepLimit(track,previous << 319 fParticleChange.Initialize(track); 397 currentSafety) << 320 currentModel->SampleScattering(track.GetDynamicParticle(), >> 321 step.GetPostStepPoint()->GetSafety()); >> 322 return &fParticleChange; 398 } 323 } 399 324 400 //....oooOO0OOooo........oooOO0OOooo........oo 325 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 401 326 402 G4double G4VMultipleScattering::GetMeanFreePat << 327 G4PhysicsVector* G4VMultipleScattering::PhysicsVector(const G4MaterialCutsCouple* couple) 403 const G4Track&, G4double, G4Forc << 404 { 328 { 405 *condition = Forced; << 329 G4int nbins = 3; 406 return DBL_MAX; << 330 if( couple->IsUsed() ) nbins = nBins; >> 331 G4PhysicsVector* v = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nbins); >> 332 v->SetSpline((G4LossTableManager::Instance())->SplineFlag()); >> 333 return v; 407 } 334 } 408 335 409 //....oooOO0OOooo........oooOO0OOooo........oo 336 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 410 337 411 G4bool << 338 G4bool G4VMultipleScattering::StorePhysicsTable(const G4ParticleDefinition* part, 412 G4VMultipleScattering::StorePhysicsTable(const << 339 const G4String& directory, 413 const << 340 G4bool ascii) 414 G4boo << 415 { 341 { 416 G4bool yes = true; 342 G4bool yes = true; 417 if(part != firstParticle || !emManager->IsMa << 343 if ( theLambdaTable && part == firstParticle) { 418 << 344 const G4String name = GetPhysicsTableFileName(part,directory,"Lambda",ascii); 419 return G4EmTableUtil::StoreMscTable(this, pa << 345 G4bool yes = theLambdaTable->StorePhysicsTable(name,ascii); 420 numberOfModels, verboseLevel, << 346 421 ascii); << 347 if ( yes ) { >> 348 if ( verboseLevel>0 ) { >> 349 G4cout << "Physics table are stored for " << part->GetParticleName() >> 350 << " and process " << GetProcessName() >> 351 << " in the directory <" << directory >> 352 << "> " << G4endl; >> 353 } >> 354 } else { >> 355 G4cout << "Fail to store Physics Table for " << part->GetParticleName() >> 356 << " and process " << GetProcessName() >> 357 << " in the directory <" << directory >> 358 << "> " << G4endl; >> 359 } >> 360 } >> 361 return yes; 422 } 362 } 423 363 424 //....oooOO0OOooo........oooOO0OOooo........oo 364 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 425 365 426 G4bool << 366 G4bool G4VMultipleScattering::RetrievePhysicsTable(const G4ParticleDefinition* part, 427 G4VMultipleScattering::RetrievePhysicsTable(co << 367 const G4String& directory, 428 co << 368 G4bool ascii) 429 G4 << 369 { 430 { << 370 if(0 < verboseLevel) { 431 return true; << 371 // G4cout << "========================================================" << G4endl; 432 } << 372 G4cout << "G4VMultipleScattering::RetrievePhysicsTable() for " >> 373 << part->GetParticleName() << " and process " >> 374 << GetProcessName() << G4endl; >> 375 } >> 376 G4bool yes = true; 433 377 434 //....oooOO0OOooo........oooOO0OOooo........oo << 378 if(!buildLambdaTable || firstParticle != part) return yes; 435 379 436 void G4VMultipleScattering::ProcessDescription << 380 const G4String particleName = part->GetParticleName(); 437 { << 381 438 if(nullptr != firstParticle) { << 382 G4String filename = GetPhysicsTableFileName(part,directory,"Lambda",ascii); 439 StreamInfo(outFile, *firstParticle, true); << 383 yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,filename,ascii); >> 384 if ( yes ) { >> 385 if (0 < verboseLevel) { >> 386 G4cout << "Lambda table for " << part->GetParticleName() << " is retrieved from <" >> 387 << filename << ">" >> 388 << G4endl; >> 389 } >> 390 if((G4LossTableManager::Instance())->SplineFlag()) { >> 391 size_t n = theLambdaTable->length(); >> 392 for(size_t i=0; i<n; i++) {(* theLambdaTable)[i]->SetSpline(true);} >> 393 } >> 394 } else { >> 395 if (1 < verboseLevel) { >> 396 G4cout << "Lambda table for " << part->GetParticleName() << " in file <" >> 397 << filename << "> is not exist" >> 398 << G4endl; >> 399 } 440 } 400 } >> 401 return yes; 441 } 402 } 442 403 443 //....oooOO0OOooo........oooOO0OOooo........oo 404 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 444 405 445 406