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