Changeset 1315 for trunk/source/processes/electromagnetic/utils
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- Location:
- trunk/source/processes/electromagnetic/utils
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/electromagnetic/utils/History
r1228 r1315 1 $Id: History,v 1.4 00 2009/11/22 19:48:30vnivanch Exp $1 $Id: History,v 1.424 2010/06/04 15:36:39 vnivanch Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 17 17 * Reverse chronological order (last date on top), please * 18 18 ---------------------------------------------------------- 19 20 4 June 10: V.Ivant (emutils-V09-03-16) 21 Previous tag was set from wrong directory 22 23 4 June 10: V.Ivant (emutils-V09-03-15) 24 G4EmConfigurator - fixed case of more than one model is added per a process 25 26 4 June 10: V.Ivant (emutils-V09-03-14) 27 G4EmCorrections - moved G4AtomicShell header into source 28 29 26 May 10: V.Ivant (emutils-V09-03-13) 30 G4VEmModel - added method ChargeSquareRatio to access current charge of an ion 31 G4VEnergyLossProcess - use this new method 32 33 10 May 10: V.Ivant (emutils-V09-03-12) 34 G4VEmProcess - cleanup printout at initialisation for scattering process 35 36 28 April 10: V.Ivant (emutils-V09-03-11) 37 G4VEmProcess, G4VEnergyLossProcess, G4VEmModel - provided GetCurrentElement method 38 (addressed bug report #1115 and HyperNews request) 39 40 27 April 10: V.Ivant (emutils-V09-03-10) 41 G4LossTableManager - added class member and a method GetNumberOfBinsPerDecade 42 G4VEmModel - use GetNumberOfBinsPerDecade and spline flag to initialise 43 G4EmElementSelector (addressed bug report #1115) 44 G4EmElementSelector - use spline flag to construct vectors probabilities 45 G4EmProcessOptions - removed double implementation of initialisation code, 46 which already exist in G4LossTableManager 47 G4VEnergyLossProcess - call CorrectionsAlongStep only for ions (minor CPU saving) 48 49 23 April 10: V.Ivant (emutils-V09-03-09) 50 G4VEnergyLossProcess - removed unused variable 51 52 12 April 10: V.Ivant (emutils-V09-03-08) 53 G4EmModelManager - do not use min energy cut defined by models allowing 54 decreasing of cuts in limit to zero 55 G4EmCalculator - fixed GetCrossSection method 56 57 12 April 10: V.Ivant (emutils-V09-03-07) 58 G4LossTableManager - added methods PreparePhsyicsTables, BuildPhysicsTables, 59 and changed initialisation of models via G4EmConfigurator 60 G4VEnergyLossProcess, G4VEmProcess, G4VMultipleScattering - added 61 calls of new G4LossTableManager methods 62 PreparePhsyicsTables, BuildPhysicsTables 63 G4EmConfigarator - upgraded and fixed old problem 64 65 06 April 10: V.Ivant (emutils-V09-03-06) 66 G4VEnergyLossProcess - use the same method to build cross section table 67 as DEDX table (use copy constructors to reduce 68 number of calls to std::exp) 69 G4EmModelManager - cleanup comments 70 71 22 March 10: V.Ivant (emutils-V09-03-05) 72 G4EmCorrections - added protection against large Barkas and Bloch 73 corrections in the case of large negatively charged 74 particle (100*e-) - fixed problem reported by ATLAS 75 G4EmCalculator - cleanup 76 77 10 March 10: V.Ivant (emutils-V09-03-04) 78 G4VEmModel, G4VEmProcess, G4VEnergyLossProcess, G4VMultipleScattering, 79 G4LossTableManager - reorder inline methods and add comments 80 81 05 March 10: V.Ivant (emutils-V09-03-03) 82 G4VMscModel, G4VMultipleScattering - set skin=1.0 as a default 83 84 24 February 10: V.Ivant (emutils-V09-03-02) 85 G4VEmProcess - move SetBuildTableFlag method from protected to public 86 87 17 February 10: V.Ivant (emutils-V09-03-01) 88 G4VEmProcess - fixed problem for ion processes by adding pointer to 89 currentParticle which may be different from GenericIon 90 91 22 January 10: V.Ivant (emutils-V09-03-00) 92 G4VEmProcess - added protection against negative cross section 93 G4VEnergyLossProcess - added protection against negative cross section; 94 - improved logic in RetrieveTable method 19 95 20 96 23 November 09: V.Ivant (emutils-V09-02-24) -
trunk/source/processes/electromagnetic/utils/include/G4EmCalculator.hh
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmCalculator.hh,v 1. 19 2009/11/11 23:59:48vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4EmCalculator.hh,v 1.20 2010/04/13 10:58:03 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // … … 249 249 const G4Material* currentMaterial; 250 250 const G4ParticleDefinition* currentParticle; 251 const G4ParticleDefinition* lambdaParticle; 251 252 const G4ParticleDefinition* baseParticle; 252 253 const G4PhysicsTable* currentLambda; … … 260 261 261 262 G4String currentName; 263 G4String lambdaName; 262 264 G4double currentCut; 263 265 G4double chargeSquare; -
trunk/source/processes/electromagnetic/utils/include/G4EmConfigurator.hh
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmConfigurator.hh,v 1. 2 2008/11/21 12:30:29vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4EmConfigurator.hh,v 1.3 2010/04/12 11:44:40 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 58 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 59 59 60 class G4VEnergyLossProcess; 61 class G4VEmProcess; 62 class G4VMultipleScattering; 63 60 64 class G4EmConfigurator 61 65 { 62 66 public: 63 67 64 G4EmConfigurator( );68 G4EmConfigurator(G4int verboseLevel = 1); 65 69 66 70 ~G4EmConfigurator(); 67 71 68 // Add EM model to the list of extra models potentially to be69 // declared for the G4Region and energy interval70 //71 void AddExtraEmModel(const G4String& particleName,72 G4VEmModel*, G4VEmFluctuationModel* fm = 0);73 74 // Declare EM model for particle type and process to75 // be active for the G4Region and energy interval76 // The model should be previously added to the configurator77 // or be "dummy"78 //79 void AddModelForRegion(const G4String& particleName,80 const G4String& processName,81 const G4String& modelName,82 const G4String& regionName = "",83 G4double emin = 0.0,84 G4double emax = DBL_MAX,85 const G4String& flucModelName = "");86 87 72 // Set EM model for particle type and process to 88 73 // be active for the G4Region and energy interval 74 // The model will be added to the list 89 75 // 90 76 void SetExtraEmModel(const G4String& particleName, … … 97 83 98 84 // Add all previously declared models to corresponding processes 85 // Can be called in ConstructPhysics 86 // 99 87 void AddModels(); 88 89 // These methods called by G4LossTableManager 90 // 91 void PrepareModels(const G4ParticleDefinition* aParticle, 92 G4VEnergyLossProcess* p); 93 94 void PrepareModels(const G4ParticleDefinition* aParticle, 95 G4VEmProcess* p); 96 97 void PrepareModels(const G4ParticleDefinition* aParticle, 98 G4VMultipleScattering* p); 99 100 void Clear(); 101 102 inline void SetVerbose(G4int value); 100 103 101 104 private: 102 105 103 void SetModelForRegion(const G4String& particleName, 106 G4Region* FindRegion(const G4String&); 107 108 void SetModelForRegion(G4VEmModel* model, 109 G4VEmFluctuationModel* fm, 110 G4Region* reg, 111 const G4String& particleName, 104 112 const G4String& processName, 105 const G4String& modelName,106 const G4String& regionName,107 const G4String& flucModelName,108 113 G4double emin, 109 114 G4double emax); 115 116 G4bool UpdateModelEnergyRange(G4VEmModel* mod, 117 G4double emin, G4double emax); 110 118 111 119 // hide assignment operator … … 113 121 G4EmConfigurator(const G4EmConfigurator&); 114 122 123 std::vector<G4VEmModel*> models; 124 std::vector<G4VEmFluctuationModel*> flucModels; 115 125 std::vector<G4String> particles; 116 126 std::vector<G4String> processes; 117 std::vector<G4String> models;118 127 std::vector<G4String> regions; 119 std::vector<G4String> flucModels;120 128 std::vector<G4double> lowEnergy; 121 129 std::vector<G4double> highEnergy; 122 130 123 std::vector<G4String> particleList;124 std::vector<G4VEmModel*> modelList;125 std::vector<G4VEmFluctuationModel*> flucModelList;126 127 131 G4int index; 132 G4int verbose; 128 133 }; 129 134 130 135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 136 137 inline void G4EmConfigurator::SetVerbose(G4int value) 138 { 139 verbose = value; 140 } 131 141 132 142 #endif -
trunk/source/processes/electromagnetic/utils/include/G4EmCorrections.hh
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmCorrections.hh,v 1.2 4 2008/09/12 14:44:48vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4EmCorrections.hh,v 1.25 2010/06/04 09:28:46 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 56 56 57 57 #include "globals.hh" 58 #include "G4AtomicShells.hh"59 58 #include "G4ionEffectiveCharge.hh" 60 59 #include "G4Material.hh" … … 263 262 G4int nbinCorr; 264 263 265 G4AtomicShells shells;266 264 G4ionEffectiveCharge effCharge; 267 265 … … 356 354 tmax = 2.0*electron_mass_c2*bg2 /(1. + 2.0*gamma*ratio + ratio*ratio); 357 355 charge = p->GetPDGCharge()/eplus; 358 if(charge < 1.5) {q2 = charge*charge;} 359 else { 360 q2 = effCharge.EffectiveChargeSquareRatio(p,mat,kinEnergy); 361 charge = std::sqrt(q2); 362 } 356 //if(charge < 1.5) {q2 = charge*charge;} 357 //else { 358 // q2 = effCharge.EffectiveChargeSquareRatio(p,mat,kinEnergy); 359 // charge = std::sqrt(q2); 360 //} 361 if(charge > 1.5) { charge = effCharge.EffectiveCharge(p,mat,kinEnergy); } 362 q2 = charge*charge; 363 363 } 364 364 if(mat != material) { -
trunk/source/processes/electromagnetic/utils/include/G4LossTableManager.hh
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4LossTableManager.hh,v 1.5 5 2009/10/29 19:25:28vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4LossTableManager.hh,v 1.58 2010/04/27 16:59:52 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // … … 61 61 // 12-02-07 Add SetSkin, SetLinearLossLimit (V.Ivanchenko) 62 62 // 18-06-07 Move definition of msc parameters to G4EmProcessOptions (V.Ivanchenko) 63 // 12-04-10 Added PreparePhsyicsTables and BuildPhysicsTables entries (V.Ivanchenko) 63 64 // 64 65 // Class Description: … … 93 94 class G4EmConfigurator; 94 95 class G4LossTableBuilder; 96 class G4Region; 95 97 96 98 class G4LossTableManager … … 103 105 ~G4LossTableManager(); 104 106 107 //------------------------------------------------- 108 // called from destructor 109 //------------------------------------------------- 110 105 111 void Clear(); 106 112 107 // get the DEDX or the range for a given particle/energy/material 113 //------------------------------------------------- 114 // initialisation before a new run 115 //------------------------------------------------- 116 117 void PreparePhysicsTable(const G4ParticleDefinition* aParticle, 118 G4VEnergyLossProcess* p); 119 void PreparePhysicsTable(const G4ParticleDefinition* aParticle, 120 G4VEmProcess* p); 121 void PreparePhysicsTable(const G4ParticleDefinition* aParticle, 122 G4VMultipleScattering* p); 123 void BuildPhysicsTable(const G4ParticleDefinition* aParticle); 124 void BuildPhysicsTable(const G4ParticleDefinition* aParticle, 125 G4VEnergyLossProcess* p); 126 127 //------------------------------------------------- 128 // Run time access to DEDX, range, energy for a given particle, 129 // energy, and G4MaterialCutsCouple 130 //------------------------------------------------- 131 108 132 inline G4double GetDEDX( 109 133 const G4ParticleDefinition *aParticle, … … 141 165 G4double& length); 142 166 143 // to be called only by energy loss processes 167 //------------------------------------------------- 168 // Methods to be called only at initialisation 169 //------------------------------------------------- 170 144 171 void Register(G4VEnergyLossProcess* p); 145 172 … … 162 189 void DeRegister(G4VEmFluctuationModel* p); 163 190 164 void EnergyLossProcessIsInitialised(const G4ParticleDefinition* aParticle,165 G4VEnergyLossProcess* p);166 167 191 void RegisterIon(const G4ParticleDefinition* aParticle, 168 192 G4VEnergyLossProcess* p); … … 171 195 G4VEnergyLossProcess* p); 172 196 173 void BuildPhysicsTable(const G4ParticleDefinition* aParticle,174 G4VEnergyLossProcess* p);175 176 197 void SetLossFluctuations(G4bool val); 177 198 178 void SetSubCutoff(G4bool val );199 void SetSubCutoff(G4bool val, const G4Region* r=0); 179 200 180 201 void SetIntegral(G4bool val); … … 198 219 void SetLambdaBinning(G4int val); 199 220 221 G4int GetNumberOfBinsPerDecade() const; 222 200 223 void SetStepFunction(G4double v1, G4double v2); 201 224 … … 214 237 void SetVerbose(G4int val); 215 238 239 //------------------------------------------------- 240 // Access methods 241 //------------------------------------------------- 242 216 243 G4EnergyLossMessenger* GetMessenger(); 217 244 … … 241 268 242 269 private: 270 271 //------------------------------------------------- 272 // Private methods and members 273 //------------------------------------------------- 243 274 244 275 G4LossTableManager(); … … 251 282 void ParticleHaveNoLoss(const G4ParticleDefinition* aParticle); 252 283 253 void SetParameters(G4VEnergyLossProcess*); 284 void SetParameters(const G4ParticleDefinition* aParticle, 285 G4VEnergyLossProcess*); 254 286 255 287 void CopyDEDXTables(); 256 288 257 private:258 259 289 static G4LossTableManager* theInstance; 260 290 261 291 typedef const G4ParticleDefinition* PD; 292 262 293 std::map<PD,G4VEnergyLossProcess*,std::less<PD> > loss_map; 263 294 … … 279 310 PD currentParticle; 280 311 PD theElectron; 312 PD firstParticle; 281 313 282 314 G4int n_loss; … … 284 316 285 317 G4bool all_tables_are_built; 286 // G4bool first_entry; 318 G4bool startInitialisation; 319 287 320 G4bool lossFluctuationFlag; 288 321 G4bool subCutoffFlag; … … 290 323 G4bool integral; 291 324 G4bool integralActive; 292 G4bool all_tables_are_stored;293 325 G4bool buildCSDARange; 294 326 G4bool minEnergyActive; … … 314 346 G4EmConfigurator* emConfigurator; 315 347 316 const G4ParticleDefinition* firstParticle; 348 G4int nbinsLambda; 349 G4int nbinsPerDecade; 317 350 G4int verbose; 318 351 … … 322 355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 323 356 357 inline G4VEnergyLossProcess* G4LossTableManager::GetEnergyLossProcess( 358 const G4ParticleDefinition *aParticle) 359 { 360 if(aParticle != currentParticle) { 361 currentParticle = aParticle; 362 std::map<PD,G4VEnergyLossProcess*,std::less<PD> >::const_iterator pos; 363 if ((pos = loss_map.find(aParticle)) != loss_map.end()) { 364 currentLoss = (*pos).second; 365 } else { 366 currentLoss = 0; 367 // ParticleHaveNoLoss(aParticle); 368 } 369 } 370 return currentLoss; 371 } 372 373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 374 324 375 inline G4double G4LossTableManager::GetDEDX( 325 376 const G4ParticleDefinition *aParticle, … … 327 378 const G4MaterialCutsCouple *couple) 328 379 { 329 if(aParticle != currentParticle) GetEnergyLossProcess(aParticle);380 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } 330 381 G4double x; 331 if(currentLoss) x = currentLoss->GetDEDX(kineticEnergy, couple);332 else x = G4EnergyLossTables::GetDEDX(333 currentParticle,kineticEnergy,couple,false); 382 if(currentLoss) { x = currentLoss->GetDEDX(kineticEnergy, couple); } 383 else { x = G4EnergyLossTables::GetDEDX(currentParticle, 384 kineticEnergy,couple,false); } 334 385 return x; 335 386 } … … 342 393 const G4MaterialCutsCouple *couple) 343 394 { 344 if(aParticle != currentParticle) GetEnergyLossProcess(aParticle);395 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } 345 396 G4double x = 0.0; 346 if(currentLoss) x = currentLoss->GetDEDXForSubsec(kineticEnergy, couple);397 if(currentLoss) { x = currentLoss->GetDEDXForSubsec(kineticEnergy, couple); } 347 398 return x; 348 399 } … … 355 406 const G4MaterialCutsCouple *couple) 356 407 { 357 if(aParticle != currentParticle) GetEnergyLossProcess(aParticle);408 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } 358 409 G4double x = DBL_MAX; 359 if(currentLoss) x = currentLoss->GetCSDARange(kineticEnergy, couple);410 if(currentLoss) { x = currentLoss->GetCSDARange(kineticEnergy, couple); } 360 411 return x; 361 412 } … … 368 419 const G4MaterialCutsCouple *couple) 369 420 { 370 if(aParticle != currentParticle) GetEnergyLossProcess(aParticle);421 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } 371 422 G4double x; 372 if(currentLoss) x = currentLoss->GetRangeForLoss(kineticEnergy, couple);373 else 374 x = G4EnergyLossTables::GetRange(currentParticle,kineticEnergy,couple,false); 423 if(currentLoss) { x = currentLoss->GetRangeForLoss(kineticEnergy, couple); } 424 else { x = G4EnergyLossTables::GetRange(currentParticle,kineticEnergy, 425 couple,false); } 375 426 return x; 376 427 } … … 383 434 const G4MaterialCutsCouple *couple) 384 435 { 385 if(aParticle != currentParticle) GetEnergyLossProcess(aParticle);436 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } 386 437 G4double x; 387 if(currentLoss) x = currentLoss->GetRange(kineticEnergy, couple);388 else 389 x = G4EnergyLossTables::GetRange(currentParticle,kineticEnergy,couple,false); 438 if(currentLoss) { x = currentLoss->GetRange(kineticEnergy, couple); } 439 else { x = G4EnergyLossTables::GetRange(currentParticle,kineticEnergy, 440 couple,false); } 390 441 return x; 391 442 } … … 398 449 const G4MaterialCutsCouple *couple) 399 450 { 400 if(aParticle != currentParticle) GetEnergyLossProcess(aParticle);451 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } 401 452 G4double x; 402 if(currentLoss) x = currentLoss->GetKineticEnergy(range, couple);403 else x = G4EnergyLossTables::GetPreciseEnergyFromRange(404 currentParticle,range,couple,false); 453 if(currentLoss) { x = currentLoss->GetKineticEnergy(range, couple); } 454 else { x = G4EnergyLossTables::GetPreciseEnergyFromRange(currentParticle,range, 455 couple,false); } 405 456 return x; 406 457 } … … 428 479 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 429 480 430 inline G4VEnergyLossProcess* G4LossTableManager::GetEnergyLossProcess(431 const G4ParticleDefinition *aParticle)432 {433 if(aParticle != currentParticle) {434 currentParticle = aParticle;435 std::map<PD,G4VEnergyLossProcess*,std::less<PD> >::const_iterator pos;436 if ((pos = loss_map.find(aParticle)) != loss_map.end()) {437 currentLoss = (*pos).second;438 } else {439 currentLoss = 0;440 // ParticleHaveNoLoss(aParticle);441 }442 }443 return currentLoss;444 }445 446 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......447 448 481 #endif 449 482 -
trunk/source/processes/electromagnetic/utils/include/G4VAtomDeexcitation.hh
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VAtomDeexcitation.hh,v 1. 1 2009/07/09 11:42:52vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VAtomDeexcitation.hh,v 1.3 2010/03/30 09:19:56 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 63 63 virtual ~G4VAtomDeexcitation(); 64 64 65 //initialization 65 //========== initialization ========== 66 66 67 virtual void PreparePhysicsTable(const G4ParticleDefinition&); 67 68 virtual void BuildPhysicsTable(const G4ParticleDefinition&); 68 69 // Get atomic shell by shell index, used by discrete processes70 // (for example, photoelectric), when shell vacancy sampled by the model71 virtual const G4AtomicChell* GetAtomicShell(G4int Z, G4int ShellIndex);72 73 // selection of random shell for ionisation process74 virtual const G4AtomicShell* SelectRandomShell(const G4DynamicParticle*,75 G4int Z);76 77 // generation of deexcitation for given atom and shell vacancy78 virtual void GenerateParticles(std::vector<G4DynamicParticle*>*,79 const G4AtomicChell*, G4int Z);80 81 // access or compute PIXE cross section82 virtual G4double GetPIXECrossSection (const G4ParticleDefinition*,83 G4int Z, G4double kinE);84 85 // calculate PIXE cross section from the models86 virtual G4double CalculatePIXECrossSection(const G4ParticleDefinition*,87 G4int Z, G4double kinE);88 89 // Sampling of PIXE for ionisation processes90 virtual void91 AlongStepDeexcitation(std::vector<G4DynamicParticle*>* secVect,92 const G4DynamicParticle* icidentParticle,93 const G4MaterialCutsCouple*,94 G4double trueStepLenght,95 G4double eLoss);96 97 // Check if deexcitation is active for a given geometry volume98 G4bool CheckActiveRegion(G4int coupleIndex);99 100 // Access flags defined in the CheckActiveVolume method101 inline G4bool IsFluorescenceActive() const;102 inline G4bool IsPIXECrossSectionActive() const;103 69 104 70 // PIXE model name … … 115 81 void SetPIXECrossSectionActiveRegion(const G4String& rname = ""); 116 82 83 //========== Run time methods ========== 84 85 // Check if deexcitation is active for a given geometry volume 86 G4bool CheckFluorescenceActiveRegion(G4int coupleIndex); 87 88 // Check if deexcitation is active for a given geometry volume 89 G4bool CheckPIXEActiveRegion(G4int coupleIndex); 90 91 // Get atomic shell by shell index, used by discrete processes 92 // (for example, photoelectric), when shell vacancy sampled by the model 93 const G4AtomicShell* GetAtomicShell(G4int Z, G4int ShellIndex); 94 95 // selection of random shell for ionisation process 96 virtual const G4AtomicShell* SelectRandomShell(const G4DynamicParticle*, 97 G4int Z); 98 99 // generation of deexcitation for given atom and shell vacancy 100 virtual void GenerateParticles(std::vector<G4DynamicParticle*>*, 101 const G4AtomicShell*, G4int Z) = 0; 102 103 // access or compute PIXE cross section 104 virtual G4double GetPIXECrossSection (const G4ParticleDefinition*, 105 G4int Z, G4double kinE) = 0; 106 107 // calculate PIXE cross section from the models 108 virtual G4double CalculatePIXECrossSection(const G4ParticleDefinition*, 109 G4int Z, G4double kinE) = 0; 110 111 // Sampling of PIXE for ionisation processes 112 virtual void 113 AlongStepDeexcitation(std::vector<G4DynamicParticle*>* secVect, 114 const G4DynamicParticle* icidentParticle, 115 const G4MaterialCutsCouple*, 116 G4double trueStepLenght, 117 G4double eLoss) = 0; 118 119 120 117 121 private: 118 122 … … 122 126 123 127 G4String namePIXE; 124 G4bool isFluoActive;125 G4bool isPIXEActive;126 128 127 129 }; 128 129 inline G4bool IsFluorescenceActive() const130 {131 return isFluoActive;132 }133 134 inline G4bool IsPIXECrossSectionActive() const135 {136 return isPIXEActive;137 }138 130 139 131 inline -
trunk/source/processes/electromagnetic/utils/include/G4VEmModel.hh
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VEmModel.hh,v 1.7 2 2009/09/23 14:42:47vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VEmModel.hh,v 1.75 2010/05/26 10:41:34 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 150 150 151 151 // Compute effective ion charge square 152 virtual G4double ChargeSquareRatio(const G4Track&); 153 154 // Compute effective ion charge square 152 155 virtual G4double GetChargeSquareRatio(const G4ParticleDefinition*, 153 156 const G4Material*, … … 228 231 G4double maxEnergy = DBL_MAX); 229 232 233 // select isotope in order to have precise mass of the nucleus 234 inline G4int SelectIsotopeNumber(const G4Element*); 235 230 236 // atom can be selected effitiantly if element selectors are initialised 231 237 inline const G4Element* SelectRandomAtom(const G4MaterialCutsCouple*, … … 236 242 237 243 // to select atom cross section per volume is recomputed for each element 238 inline const G4Element* SelectRandomAtom(const G4Material*, 239 const G4ParticleDefinition*, 240 G4double kineticEnergy, 241 G4double cutEnergy = 0.0, 242 G4double maxEnergy = DBL_MAX); 243 244 // select isotope in order to have precise mass of the nucleus 245 inline G4int SelectIsotopeNumber(const G4Element*); 244 const G4Element* SelectRandomAtom(const G4Material*, 245 const G4ParticleDefinition*, 246 G4double kineticEnergy, 247 G4double cutEnergy = 0.0, 248 G4double maxEnergy = DBL_MAX); 246 249 247 250 //------------------------------------------------------------------------ … … 291 294 inline void SetCurrentCouple(const G4MaterialCutsCouple*); 292 295 296 inline const G4Element* GetCurrentElement() const; 297 293 298 protected: 294 299 … … 296 301 297 302 inline void SetCurrentElement(const G4Element*); 298 299 inline const G4Element* GetCurrentElement() const;300 303 301 304 private: … … 341 344 }; 342 345 343 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 346 // ======== Run time inline methods ================ 347 348 inline void G4VEmModel::SetCurrentCouple(const G4MaterialCutsCouple* p) 349 { 350 currentCouple = p; 351 } 352 353 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 354 355 inline const G4MaterialCutsCouple* G4VEmModel::CurrentCouple() const 356 { 357 return currentCouple; 358 } 359 360 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 361 362 inline void G4VEmModel::SetCurrentElement(const G4Element* elm) 363 { 364 currentElement = elm; 365 } 366 367 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 368 369 inline const G4Element* G4VEmModel::GetCurrentElement() const 370 { 371 return currentElement; 372 } 373 374 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 375 376 inline 377 G4double G4VEmModel::MaxSecondaryKinEnergy(const G4DynamicParticle* dynPart) 378 { 379 return MaxSecondaryEnergy(dynPart->GetDefinition(), 380 dynPart->GetKineticEnergy()); 381 } 382 344 383 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 345 384 … … 375 414 G4double mfp = DBL_MAX; 376 415 G4double cross = CrossSectionPerVolume(material,p,ekin,emin,emax); 377 if (cross > DBL_MIN) mfp = 1./cross;416 if (cross > DBL_MIN) { mfp = 1./cross; } 378 417 return mfp; 379 418 } … … 415 454 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 416 455 417 inline418 const G4Element* G4VEmModel::SelectRandomAtom(const G4Material* material,419 const G4ParticleDefinition* pd,420 G4double kinEnergy,421 G4double tcut,422 G4double tmax)423 {424 const G4ElementVector* theElementVector = material->GetElementVector();425 G4int n = material->GetNumberOfElements() - 1;426 currentElement = (*theElementVector)[n];427 if (n > 0) {428 G4double x = G4UniformRand()*429 G4VEmModel::CrossSectionPerVolume(material,pd,kinEnergy,tcut,tmax);430 for(G4int i=0; i<n; i++) {431 if (x <= xsec[i]) {432 currentElement = (*theElementVector)[i];433 break;434 }435 }436 }437 return currentElement;438 }439 440 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......441 442 456 inline G4int G4VEmModel::SelectIsotopeNumber(const G4Element* elm) 443 457 { … … 450 464 G4double* ab = elm->GetRelativeAbundanceVector(); 451 465 G4double x = G4UniformRand(); 452 for(; idx<ni; idx++) {466 for(; idx<ni; ++idx) { 453 467 x -= ab[idx]; 454 if (x <= 0.0) break;468 if (x <= 0.0) { break; } 455 469 } 456 if(idx >= ni) idx = ni - 1;470 if(idx >= ni) { idx = ni - 1; } 457 471 } 458 472 N = elm->GetIsotope(idx)->GetN(); … … 461 475 } 462 476 463 // ....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......477 // ======== Get/Set inline methods used at initialisation ================ 464 478 465 479 inline G4VEmFluctuationModel* G4VEmModel::GetModelOfFluctuations() … … 578 592 { 579 593 nuclearStopping = val; 580 }581 582 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......583 584 inline585 G4double G4VEmModel::MaxSecondaryKinEnergy(const G4DynamicParticle* dynPart)586 {587 return MaxSecondaryEnergy(dynPart->GetDefinition(),588 dynPart->GetKineticEnergy());589 594 } 590 595 … … 601 606 G4VEmFluctuationModel* f = 0) 602 607 { 603 if(p && pParticleChange != p) pParticleChange = p;608 if(p && pParticleChange != p) { pParticleChange = p; } 604 609 fluc = f; 605 610 } … … 607 612 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 608 613 609 inline void G4VEmModel::SetCurrentCouple(const G4MaterialCutsCouple* p)610 {611 currentCouple = p;612 }613 614 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......615 616 inline const G4MaterialCutsCouple* G4VEmModel::CurrentCouple() const617 {618 return currentCouple;619 }620 621 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......622 623 inline void G4VEmModel::SetCurrentElement(const G4Element* elm)624 {625 currentElement = elm;626 }627 628 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......629 630 inline const G4Element* G4VEmModel::GetCurrentElement() const631 {632 return currentElement;633 }634 635 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......636 637 614 #endif 638 615 -
trunk/source/processes/electromagnetic/utils/include/G4VEmProcess.hh
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VEmProcess.hh,v 1. 55 2009/09/23 14:42:47vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VEmProcess.hh,v 1.60 2010/04/28 14:43:13 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 56 56 // 27-10-07 Virtual functions moved to source (V.Ivanchenko) 57 57 // 15-07-08 Reorder class members for further multi-thread development (VI) 58 // 17-02-10 Added pointer currentParticle (VI) 58 59 // 59 60 // Class Description: … … 158 159 159 160 // It returns the cross section of the process per atom 160 inlineG4double ComputeCrossSectionPerAtom(G4double kineticEnergy,161 162 163 164 inlineG4double MeanFreePath(const G4Track& track);161 G4double ComputeCrossSectionPerAtom(G4double kineticEnergy, 162 G4double Z, G4double A=0., 163 G4double cut=0.0); 164 165 G4double MeanFreePath(const G4Track& track); 165 166 166 167 // It returns cross section per volume … … 225 226 G4VEmModel* GetModelByIndex(G4int idx = 0, G4bool ver = false); 226 227 228 // access atom on which interaction happens 229 const G4Element* GetCurrentElement() const; 230 227 231 inline void SetLambdaFactor(G4double val); 228 232 … … 231 235 232 236 inline void SetApplyCuts(G4bool val); 237 238 inline void SetBuildTableFlag(G4bool val); 233 239 234 240 //------------------------------------------------------------------------ … … 245 251 246 252 inline G4double RecalculateLambda(G4double kinEnergy, 247 const G4MaterialCutsCouple* couple);253 const G4MaterialCutsCouple* couple); 248 254 249 255 inline G4ParticleChangeForGamma* GetParticleChange(); … … 258 264 259 265 inline G4double GetElectronEnergyCut(); 260 261 inline void SetBuildTableFlag(G4bool val);262 266 263 267 inline void SetStartFromNullFlag(G4bool val); … … 340 344 341 345 const G4ParticleDefinition* particle; 346 const G4ParticleDefinition* currentParticle; 342 347 343 348 // cash … … 352 357 }; 353 358 354 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 356 357 inline G4double G4VEmProcess::ComputeCrossSectionPerAtom( 358 G4double kineticEnergy, G4double Z, G4double A, G4double cut) 359 { 360 SelectModel(kineticEnergy, currentCoupleIndex); 361 G4double x = 0.0; 362 if(currentModel) { 363 x = currentModel->ComputeCrossSectionPerAtom(particle,kineticEnergy, 364 Z,A,cut); 365 } 366 return x; 367 } 368 369 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 370 371 inline G4double G4VEmProcess::MeanFreePath(const G4Track& track) 372 { 373 DefineMaterial(track.GetMaterialCutsCouple()); 374 preStepLambda = GetCurrentLambda(track.GetKineticEnergy()); 375 G4double x = DBL_MAX; 376 if(DBL_MIN < preStepLambda) x = 1.0/preStepLambda; 377 return x; 378 } 379 380 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 381 382 inline G4double G4VEmProcess::GetLambda(G4double& kineticEnergy, 383 const G4MaterialCutsCouple* couple) 384 { 385 DefineMaterial(couple); 386 return GetCurrentLambda(kineticEnergy); 387 } 388 389 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 390 391 inline void G4VEmProcess::SetLambdaBinning(G4int nbins) 392 { 393 nLambdaBins = nbins; 394 } 395 396 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 397 398 inline G4int G4VEmProcess::LambdaBinning() const 399 { 400 return nLambdaBins; 401 } 402 403 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 404 405 inline void G4VEmProcess::SetMinKinEnergy(G4double e) 406 { 407 minKinEnergy = e; 408 } 409 410 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 411 412 inline G4double G4VEmProcess::MinKinEnergy() const 413 { 414 return minKinEnergy; 415 } 416 417 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 418 419 inline void G4VEmProcess::SetMaxKinEnergy(G4double e) 420 { 421 maxKinEnergy = e; 422 } 423 424 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 425 426 inline G4double G4VEmProcess::MaxKinEnergy() const 427 { 428 return maxKinEnergy; 429 } 430 431 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 432 433 inline void G4VEmProcess::SetPolarAngleLimit(G4double val) 434 { 435 if(val < 0.0) polarAngleLimit = 0.0; 436 else if(val > pi) polarAngleLimit = pi; 437 else polarAngleLimit = val; 438 } 439 440 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 441 442 inline G4double G4VEmProcess::PolarAngleLimit() const 443 { 444 return polarAngleLimit; 445 } 446 447 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 448 449 inline const G4PhysicsTable* G4VEmProcess::LambdaTable() const 450 { 451 return theLambdaTable; 452 } 453 454 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 455 456 inline const G4ParticleDefinition* G4VEmProcess::Particle() const 457 { 458 return particle; 459 } 460 461 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 462 463 inline const G4ParticleDefinition* G4VEmProcess::SecondaryParticle() const 464 { 465 return secondaryParticle; 466 } 467 468 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 469 470 inline 471 G4VEmModel* G4VEmProcess::SelectModel(G4double& kinEnergy, size_t index) 472 { 473 currentModel = modelManager->SelectModel(kinEnergy, index); 474 currentModel->SetCurrentCouple(currentCouple); 475 return currentModel; 476 } 477 478 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 479 480 inline 481 G4VEmModel* G4VEmProcess::SelectModelForMaterial(G4double kinEnergy, 482 size_t& idxRegion) const 483 { 484 return modelManager->SelectModel(kinEnergy, idxRegion); 485 } 486 487 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 488 489 inline void G4VEmProcess::SetLambdaFactor(G4double val) 490 { 491 if(val > 0.0 && val <= 1.0) lambdaFactor = val; 492 } 493 494 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 495 496 inline void G4VEmProcess::SetIntegral(G4bool val) 497 { 498 if(particle && particle != theGamma) integral = val; 499 if(integral) buildLambdaTable = true; 500 } 501 502 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 503 504 inline G4bool G4VEmProcess::IsIntegral() const 505 { 506 return integral; 507 } 508 509 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 510 511 inline void G4VEmProcess::SetApplyCuts(G4bool val) 512 { 513 applyCuts = val; 514 } 515 516 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 517 518 inline G4double G4VEmProcess::RecalculateLambda(G4double e, 519 const G4MaterialCutsCouple* couple) 520 { 521 DefineMaterial(couple); 522 return ComputeCurrentLambda(e); 523 } 524 525 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 526 527 inline G4ParticleChangeForGamma* G4VEmProcess::GetParticleChange() 528 { 529 return &fParticleChange; 530 } 531 532 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 533 534 inline void G4VEmProcess::SetParticle(const G4ParticleDefinition* p) 535 { 536 particle = p; 537 } 538 539 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 540 541 inline void G4VEmProcess::SetSecondaryParticle(const G4ParticleDefinition* p) 542 { 543 secondaryParticle = p; 544 } 545 546 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 359 // ======== Run time inline methods ================ 547 360 548 361 inline size_t G4VEmProcess::CurrentMaterialCutsCoupleIndex() const … … 563 376 { 564 377 return (*theCutsElectron)[currentCoupleIndex]; 565 }566 567 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....568 569 inline void G4VEmProcess::SetBuildTableFlag(G4bool val)570 {571 buildLambdaTable = val;572 if(!val) integral = false;573 }574 575 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....576 577 inline void G4VEmProcess::SetStartFromNullFlag(G4bool val)578 {579 startFromNull = val;580 }581 582 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....583 584 inline void G4VEmProcess::InitialiseStep(const G4Track& track)585 {586 preStepKinEnergy = track.GetKineticEnergy();587 DefineMaterial(track.GetMaterialCutsCouple());588 SelectModel(preStepKinEnergy, currentCoupleIndex);589 if (theNumberOfInteractionLengthLeft < 0.0) mfpKinEnergy = DBL_MAX;590 378 } 591 379 … … 600 388 mfpKinEnergy = DBL_MAX; 601 389 } 390 } 391 392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 393 394 inline 395 G4VEmModel* G4VEmProcess::SelectModel(G4double& kinEnergy, size_t index) 396 { 397 currentModel = modelManager->SelectModel(kinEnergy, index); 398 currentModel->SetCurrentCouple(currentCouple); 399 return currentModel; 400 } 401 402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 403 404 inline 405 G4VEmModel* G4VEmProcess::SelectModelForMaterial(G4double kinEnergy, 406 size_t& idxRegion) const 407 { 408 return modelManager->SelectModel(kinEnergy, idxRegion); 409 } 410 411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 412 413 inline void G4VEmProcess::InitialiseStep(const G4Track& track) 414 { 415 currentParticle = track.GetDefinition(); 416 preStepKinEnergy = track.GetKineticEnergy(); 417 DefineMaterial(track.GetMaterialCutsCouple()); 418 SelectModel(preStepKinEnergy, currentCoupleIndex); 419 if (theNumberOfInteractionLengthLeft < 0.0) mfpKinEnergy = DBL_MAX; 420 } 421 422 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 423 424 inline G4double G4VEmProcess::GetLambdaFromTable(G4double e) 425 { 426 return (((*theLambdaTable)[currentCoupleIndex])->Value(e)); 427 } 428 429 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 430 431 inline G4double G4VEmProcess::ComputeCurrentLambda(G4double e) 432 { 433 SelectModel(e, currentCoupleIndex); 434 return currentModel->CrossSectionPerVolume(currentMaterial,currentParticle, 435 e,(*theCuts)[currentCoupleIndex]); 436 } 437 438 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 439 440 inline G4double G4VEmProcess::GetCurrentLambda(G4double e) 441 { 442 G4double x = 0.0; 443 if(theLambdaTable) { x = GetLambdaFromTable(e); } 444 else { x = ComputeCurrentLambda(e); } 445 return x; 446 } 447 448 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 449 450 inline G4double G4VEmProcess::GetLambda(G4double& kineticEnergy, 451 const G4MaterialCutsCouple* couple) 452 { 453 DefineMaterial(couple); 454 return GetCurrentLambda(kineticEnergy); 455 } 456 457 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 458 459 inline G4double G4VEmProcess::RecalculateLambda(G4double e, 460 const G4MaterialCutsCouple* couple) 461 { 462 DefineMaterial(couple); 463 return ComputeCurrentLambda(e); 602 464 } 603 465 … … 625 487 } 626 488 627 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 628 629 inline G4double G4VEmProcess::GetLambdaFromTable(G4double e) 630 { 631 return (((*theLambdaTable)[currentCoupleIndex])->Value(e)); 632 } 633 634 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 635 636 inline G4double G4VEmProcess::GetCurrentLambda(G4double e) 637 { 638 G4double x = 0.0; 639 if(theLambdaTable) { x = GetLambdaFromTable(e); } 640 else { x = ComputeCurrentLambda(e); } 641 return x; 642 } 643 644 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 645 646 inline G4double G4VEmProcess::ComputeCurrentLambda(G4double e) 647 { 648 SelectModel(e, currentCoupleIndex); 649 return currentModel->CrossSectionPerVolume(currentMaterial,particle, 650 e,(*theCuts)[currentCoupleIndex]); 489 // ======== Get/Set inline methods used at initialisation ================ 490 491 inline void G4VEmProcess::SetLambdaBinning(G4int nbins) 492 { 493 nLambdaBins = nbins; 494 } 495 496 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 497 498 inline G4int G4VEmProcess::LambdaBinning() const 499 { 500 return nLambdaBins; 501 } 502 503 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 504 505 inline void G4VEmProcess::SetMinKinEnergy(G4double e) 506 { 507 minKinEnergy = e; 508 } 509 510 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 511 512 inline G4double G4VEmProcess::MinKinEnergy() const 513 { 514 return minKinEnergy; 515 } 516 517 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 518 519 inline void G4VEmProcess::SetMaxKinEnergy(G4double e) 520 { 521 maxKinEnergy = e; 522 } 523 524 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 525 526 inline G4double G4VEmProcess::MaxKinEnergy() const 527 { 528 return maxKinEnergy; 529 } 530 531 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 532 533 inline void G4VEmProcess::SetPolarAngleLimit(G4double val) 534 { 535 if(val < 0.0) polarAngleLimit = 0.0; 536 else if(val > pi) polarAngleLimit = pi; 537 else polarAngleLimit = val; 538 } 539 540 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 541 542 inline G4double G4VEmProcess::PolarAngleLimit() const 543 { 544 return polarAngleLimit; 545 } 546 547 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 548 549 inline const G4PhysicsTable* G4VEmProcess::LambdaTable() const 550 { 551 return theLambdaTable; 552 } 553 554 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 555 556 inline const G4ParticleDefinition* G4VEmProcess::Particle() const 557 { 558 return particle; 559 } 560 561 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 562 563 inline const G4ParticleDefinition* G4VEmProcess::SecondaryParticle() const 564 { 565 return secondaryParticle; 566 } 567 568 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 569 570 inline void G4VEmProcess::SetLambdaFactor(G4double val) 571 { 572 if(val > 0.0 && val <= 1.0) { lambdaFactor = val; } 573 } 574 575 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 576 577 inline void G4VEmProcess::SetIntegral(G4bool val) 578 { 579 if(particle && particle != theGamma) { integral = val; } 580 if(integral) { buildLambdaTable = true; } 581 } 582 583 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 584 585 inline G4bool G4VEmProcess::IsIntegral() const 586 { 587 return integral; 588 } 589 590 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 591 592 inline void G4VEmProcess::SetApplyCuts(G4bool val) 593 { 594 applyCuts = val; 595 } 596 597 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 598 599 inline void G4VEmProcess::SetBuildTableFlag(G4bool val) 600 { 601 buildLambdaTable = val; 602 if(!val) { integral = false; } 603 } 604 605 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 606 607 inline G4ParticleChangeForGamma* G4VEmProcess::GetParticleChange() 608 { 609 return &fParticleChange; 610 } 611 612 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 613 614 inline void G4VEmProcess::SetParticle(const G4ParticleDefinition* p) 615 { 616 particle = p; 617 currentParticle = p; 618 } 619 620 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 621 622 inline void G4VEmProcess::SetSecondaryParticle(const G4ParticleDefinition* p) 623 { 624 secondaryParticle = p; 625 } 626 627 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 628 629 inline void G4VEmProcess::SetStartFromNullFlag(G4bool val) 630 { 631 startFromNull = val; 651 632 } 652 633 -
trunk/source/processes/electromagnetic/utils/include/G4VEnergyLossProcess.hh
r1196 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VEnergyLossProcess.hh,v 1. 89 2009/07/03 14:39:17vnivanch Exp $26 // $Id: G4VEnergyLossProcess.hh,v 1.92 2010/04/28 14:43:13 vnivanch Exp $ 27 27 // GEANT4 tag $Name: 28 28 // … … 196 196 // Sampling of secondaries in vicinity of geometrical boundary 197 197 void SampleSubCutSecondaries(std::vector<G4Track*>&, const G4Step&, 198 G4VEmModel* model, G4int matIdx, 199 G4double& extraEdep); 198 G4VEmModel* model, G4int matIdx); 200 199 201 200 // PostStep sampling of secondaries … … 418 417 // Run time method for simulation of ionisation 419 418 //------------------------------------------------------------------------ 419 420 // access atom on which interaction happens 421 const G4Element* GetCurrentElement() const; 420 422 421 423 // sample range at the end of a step … … 553 555 }; 554 556 555 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 556 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 557 // ======== Run time inline methods ================ 557 558 558 559 inline size_t G4VEnergyLossProcess::CurrentMaterialCutsCoupleIndex() const … … 586 587 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 587 588 588 inline void G4VEnergyLossProcess::SetFluctModel(G4VEmFluctuationModel* p) 589 { 590 fluctModel = p; 591 } 592 593 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 594 595 inline G4VEmFluctuationModel* G4VEnergyLossProcess::FluctModel() 596 { 597 return fluctModel; 598 } 599 600 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 601 602 inline void G4VEnergyLossProcess::SetParticle(const G4ParticleDefinition* p) 603 { 604 particle = p; 605 } 606 607 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 608 609 inline void G4VEnergyLossProcess::SetSecondaryParticle(const G4ParticleDefinition* p) 610 { 611 secondaryParticle = p; 612 } 613 614 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 615 616 inline void G4VEnergyLossProcess::SetBaseParticle(const G4ParticleDefinition* p) 617 { 618 baseParticle = p; 619 } 620 621 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 622 623 inline const G4ParticleDefinition* G4VEnergyLossProcess::Particle() const 624 { 625 return particle; 626 } 627 628 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 629 630 inline const G4ParticleDefinition* G4VEnergyLossProcess::BaseParticle() const 631 { 632 return baseParticle; 633 } 634 635 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 636 637 inline const G4ParticleDefinition* G4VEnergyLossProcess::SecondaryParticle() const 638 { 639 return secondaryParticle; 640 } 641 642 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 643 644 inline void G4VEnergyLossProcess::SetLossFluctuations(G4bool val) 645 { 646 lossFluctuationFlag = val; 647 } 648 649 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 650 651 inline void G4VEnergyLossProcess::SetRandomStep(G4bool val) 652 { 653 rndmStepFlag = val; 654 } 655 656 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 657 658 inline void G4VEnergyLossProcess::SetIntegral(G4bool val) 659 { 660 integral = val; 661 } 662 663 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 664 665 inline G4bool G4VEnergyLossProcess::IsIntegral() const 666 { 667 return integral; 668 } 669 670 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 671 672 inline void G4VEnergyLossProcess::SetIonisation(G4bool val) 673 { 674 isIonisation = val; 675 if(val) aGPILSelection = CandidateForSelection; 676 else aGPILSelection = NotCandidateForSelection; 677 } 678 679 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 680 681 inline G4bool G4VEnergyLossProcess::IsIonisationProcess() const 682 { 683 return isIonisation; 684 } 685 686 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 687 688 inline void G4VEnergyLossProcess::SetLinearLossLimit(G4double val) 689 { 690 linLossLimit = val; 691 } 692 693 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 694 695 inline void G4VEnergyLossProcess::SetMinSubRange(G4double val) 696 { 697 minSubRange = val; 698 } 699 700 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 701 702 inline void G4VEnergyLossProcess::SetLambdaFactor(G4double val) 703 { 704 if(val > 0.0 && val <= 1.0) lambdaFactor = val; 705 } 706 707 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 708 709 void G4VEnergyLossProcess::SetStepFunction(G4double v1, G4double v2) 710 { 711 dRoverRange = v1; 712 finalRange = v2; 713 if (dRoverRange > 0.999) dRoverRange = 1.0; 714 currentCouple = 0; 715 mfpKinEnergy = DBL_MAX; 716 } 717 718 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 719 720 inline void G4VEnergyLossProcess::SetLowestEnergyLimit(G4double val) 721 { 722 lowestKinEnergy = val; 723 } 724 725 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 726 727 inline G4int G4VEnergyLossProcess::NumberOfSubCutoffRegions() const 728 { 729 return nSCoffRegions; 730 } 731 732 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 733 734 inline G4int G4VEnergyLossProcess::NumberOfDERegions() const 735 { 736 return nDERegions; 737 } 738 739 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 740 741 inline void G4VEnergyLossProcess::SetDEDXBinning(G4int nbins) 742 { 743 nBins = nbins; 744 } 745 746 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 747 748 inline void G4VEnergyLossProcess::SetLambdaBinning(G4int nbins) 749 { 750 nBins = nbins; 751 } 752 753 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 754 755 inline void G4VEnergyLossProcess::SetDEDXBinningForCSDARange(G4int nbins) 756 { 757 nBinsCSDA = nbins; 758 } 759 760 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 761 762 inline void G4VEnergyLossProcess::SetMinKinEnergy(G4double e) 763 { 764 minKinEnergy = e; 765 } 766 767 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 768 769 inline G4double G4VEnergyLossProcess::MinKinEnergy() const 770 { 771 return minKinEnergy; 772 } 773 774 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 775 776 inline void G4VEnergyLossProcess::SetMaxKinEnergy(G4double e) 777 { 778 maxKinEnergy = e; 779 if(e < maxKinEnergyCSDA) maxKinEnergyCSDA = e; 780 } 781 782 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 783 784 inline G4double G4VEnergyLossProcess::MaxKinEnergy() const 785 { 786 return maxKinEnergy; 787 } 788 789 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 790 791 inline void G4VEnergyLossProcess::SetMaxKinEnergyForCSDARange(G4double e) 792 { 793 maxKinEnergyCSDA = e; 794 } 795 796 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 797 798 inline G4double G4VEnergyLossProcess::GetDEDX(G4double& kineticEnergy, 799 const G4MaterialCutsCouple* couple) 589 inline void 590 G4VEnergyLossProcess::DefineMaterial(const G4MaterialCutsCouple* couple) 591 { 592 if(couple != currentCouple) { 593 currentCouple = couple; 594 currentMaterial = couple->GetMaterial(); 595 currentMaterialIndex = couple->GetIndex(); 596 mfpKinEnergy = DBL_MAX; 597 } 598 } 599 600 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 601 602 inline void G4VEnergyLossProcess::SetDynamicMassCharge(G4double massratio, 603 G4double charge2ratio) 604 { 605 massRatio = massratio; 606 chargeSqRatio = charge2ratio; 607 reduceFactor = 1.0/(chargeSqRatio*massRatio); 608 } 609 610 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 611 612 inline G4double G4VEnergyLossProcess::GetDEDXForScaledEnergy(G4double e) 613 { 614 G4double x = ((*theDEDXTable)[currentMaterialIndex]->Value(e))*chargeSqRatio; 615 if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); } 616 return x; 617 } 618 619 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 620 621 inline G4double G4VEnergyLossProcess::GetSubDEDXForScaledEnergy(G4double e) 622 { 623 G4double x = ((*theDEDXSubTable)[currentMaterialIndex]->Value(e))*chargeSqRatio; 624 if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); } 625 return x; 626 } 627 628 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 629 630 inline G4double G4VEnergyLossProcess::GetIonisationForScaledEnergy(G4double e) 631 { 632 //G4double x = 0.0; 633 // if(theIonisationTable) { 634 G4double x = ((*theIonisationTable)[currentMaterialIndex]->Value(e))*chargeSqRatio; 635 if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); } 636 //} 637 return x; 638 } 639 640 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 641 642 inline 643 G4double G4VEnergyLossProcess::GetSubIonisationForScaledEnergy(G4double e) 644 { 645 // G4double x = 0.0; 646 //if(theIonisationSubTable) { 647 G4double x = ((*theIonisationSubTable)[currentMaterialIndex]->Value(e))*chargeSqRatio; 648 if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); } 649 //} 650 return x; 651 } 652 653 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 654 655 inline G4double G4VEnergyLossProcess::GetScaledRangeForScaledEnergy(G4double e) 656 { 657 G4double x = ((*theRangeTableForLoss)[currentMaterialIndex])->Value(e); 658 if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); } 659 return x; 660 } 661 662 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 663 664 inline G4double 665 G4VEnergyLossProcess::GetLimitScaledRangeForScaledEnergy(G4double e) 666 { 667 G4double x; 668 669 if (e < maxKinEnergyCSDA) { 670 x = ((*theCSDARangeTable)[currentMaterialIndex])->Value(e); 671 if(e < minKinEnergy) x *= std::sqrt(e/minKinEnergy); 672 } else { 673 x = theRangeAtMaxEnergy[currentMaterialIndex] + 674 (e - maxKinEnergyCSDA)/theDEDXAtMaxEnergy[currentMaterialIndex]; 675 } 676 return x; 677 } 678 679 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 680 681 inline G4double G4VEnergyLossProcess::ScaledKinEnergyForLoss(G4double r) 682 { 683 G4PhysicsVector* v = (*theInverseRangeTable)[currentMaterialIndex]; 684 G4double rmin = v->Energy(0); 685 G4double e = 0.0; 686 if(r >= rmin) { e = v->Value(r); } 687 else if(r > 0.0) { 688 G4double x = r/rmin; 689 e = minKinEnergy*x*x; 690 } 691 return e; 692 } 693 694 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 695 696 inline G4double G4VEnergyLossProcess::GetLambdaForScaledEnergy(G4double e) 697 { 698 return chargeSqRatio*(((*theLambdaTable)[currentMaterialIndex])->Value(e)); 699 } 700 701 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 702 703 inline G4double 704 G4VEnergyLossProcess::GetDEDX(G4double& kineticEnergy, 705 const G4MaterialCutsCouple* couple) 800 706 { 801 707 DefineMaterial(couple); … … 805 711 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 806 712 807 inline G4double G4VEnergyLossProcess::GetDEDXForSubsec(G4double& kineticEnergy, 808 const G4MaterialCutsCouple* couple) 713 inline G4double 714 G4VEnergyLossProcess::GetDEDXForSubsec(G4double& kineticEnergy, 715 const G4MaterialCutsCouple* couple) 809 716 { 810 717 DefineMaterial(couple); … … 814 721 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 815 722 816 inline G4double G4VEnergyLossProcess::GetRange(G4double& kineticEnergy, 817 const G4MaterialCutsCouple* couple) 723 inline G4double 724 G4VEnergyLossProcess::GetRange(G4double& kineticEnergy, 725 const G4MaterialCutsCouple* couple) 818 726 { 819 727 G4double x = fRange; … … 831 739 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 832 740 833 inline G4double G4VEnergyLossProcess::GetCSDARange( 834 G4double& kineticEnergy, const G4MaterialCutsCouple* couple) 741 inline G4double 742 G4VEnergyLossProcess::GetCSDARange(G4double& kineticEnergy, 743 const G4MaterialCutsCouple* couple) 835 744 { 836 745 DefineMaterial(couple); … … 844 753 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 845 754 846 inline G4double G4VEnergyLossProcess::GetRangeForLoss(847 848 const G4MaterialCutsCouple* couple)755 inline G4double 756 G4VEnergyLossProcess::GetRangeForLoss(G4double& kineticEnergy, 757 const G4MaterialCutsCouple* couple) 849 758 { 850 759 DefineMaterial(couple); … … 859 768 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 860 769 861 inline G4double G4VEnergyLossProcess::GetKineticEnergy(862 863 const G4MaterialCutsCouple* couple)770 inline G4double 771 G4VEnergyLossProcess::GetKineticEnergy(G4double& range, 772 const G4MaterialCutsCouple* couple) 864 773 { 865 774 DefineMaterial(couple); … … 871 780 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 872 781 873 inline G4double G4VEnergyLossProcess::GetLambda(G4double& kineticEnergy, 874 const G4MaterialCutsCouple* couple) 782 inline G4double 783 G4VEnergyLossProcess::GetLambda(G4double& kineticEnergy, 784 const G4MaterialCutsCouple* couple) 875 785 { 876 786 DefineMaterial(couple); 877 787 G4double x = 0.0; 878 if(theLambdaTable) x = GetLambdaForScaledEnergy(kineticEnergy*massRatio);788 if(theLambdaTable) { x = GetLambdaForScaledEnergy(kineticEnergy*massRatio); } 879 789 return x; 880 }881 882 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....883 884 inline G4bool G4VEnergyLossProcess::TablesAreBuilt() const885 {886 return tablesAreBuilt;887 }888 889 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....890 891 inline G4PhysicsTable* G4VEnergyLossProcess::DEDXTable() const892 {893 return theDEDXTable;894 }895 896 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....897 898 inline G4PhysicsTable* G4VEnergyLossProcess::DEDXTableForSubsec() const899 {900 return theDEDXSubTable;901 }902 903 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....904 905 inline G4PhysicsTable* G4VEnergyLossProcess::DEDXunRestrictedTable() const906 {907 return theDEDXunRestrictedTable;908 }909 910 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....911 912 inline G4PhysicsTable* G4VEnergyLossProcess::IonisationTable() const913 {914 G4PhysicsTable* t = theDEDXTable;915 if(theIonisationTable) t = theIonisationTable;916 return t;917 }918 919 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....920 921 inline G4PhysicsTable* G4VEnergyLossProcess::IonisationTableForSubsec() const922 {923 G4PhysicsTable* t = theDEDXSubTable;924 if(theIonisationSubTable) t = theIonisationSubTable;925 return t;926 }927 928 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....929 930 inline G4PhysicsTable* G4VEnergyLossProcess::CSDARangeTable() const931 {932 return theCSDARangeTable;933 }934 935 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....936 937 inline G4PhysicsTable* G4VEnergyLossProcess::RangeTableForLoss() const938 {939 return theRangeTableForLoss;940 }941 942 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....943 944 inline G4PhysicsTable* G4VEnergyLossProcess::InverseRangeTable() const945 {946 return theInverseRangeTable;947 }948 949 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....950 951 inline G4PhysicsTable* G4VEnergyLossProcess::LambdaTable()952 {953 return theLambdaTable;954 }955 956 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....957 958 inline G4PhysicsTable* G4VEnergyLossProcess::SubLambdaTable()959 {960 return theSubLambdaTable;961 }962 963 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....964 965 inline G4double G4VEnergyLossProcess::SampleRange()966 {967 G4double e = amu_c2*preStepKinEnergy/particle->GetPDGMass();968 G4double s = fRange*std::pow(10.,vstrag->Value(e));969 G4double x = fRange + G4RandGauss::shoot(0.0,s);970 if(x > 0.0) fRange = x;971 return fRange;972 }973 974 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....975 976 inline void G4VEnergyLossProcess::SetDynamicMassCharge(G4double massratio,977 G4double charge2ratio)978 {979 massRatio = massratio;980 chargeSqRatio = charge2ratio;981 reduceFactor = 1.0/(chargeSqRatio*massRatio);982 }983 984 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....985 986 inline void G4VEnergyLossProcess::DefineMaterial(987 const G4MaterialCutsCouple* couple)988 {989 if(couple != currentCouple) {990 currentCouple = couple;991 currentMaterial = couple->GetMaterial();992 currentMaterialIndex = couple->GetIndex();993 mfpKinEnergy = DBL_MAX;994 }995 }996 997 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....998 999 inline G4double G4VEnergyLossProcess::GetDEDXForScaledEnergy(G4double e)1000 {1001 G4double x = ((*theDEDXTable)[currentMaterialIndex]->Value(e))*chargeSqRatio;1002 if(e < minKinEnergy) x *= std::sqrt(e/minKinEnergy);1003 return x;1004 }1005 1006 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....1007 1008 inline G4double G4VEnergyLossProcess::GetSubDEDXForScaledEnergy(G4double e)1009 {1010 G4double x = ((*theDEDXSubTable)[currentMaterialIndex]->Value(e))*chargeSqRatio;1011 if(e < minKinEnergy) x *= std::sqrt(e/minKinEnergy);1012 return x;1013 }1014 1015 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....1016 1017 inline G4double G4VEnergyLossProcess::GetIonisationForScaledEnergy(G4double e)1018 {1019 //G4double x = 0.0;1020 // if(theIonisationTable) {1021 G4double x = ((*theIonisationTable)[currentMaterialIndex]->Value(e))*chargeSqRatio;1022 if(e < minKinEnergy) x *= std::sqrt(e/minKinEnergy);1023 //}1024 return x;1025 }1026 1027 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....1028 1029 inline1030 G4double G4VEnergyLossProcess::GetSubIonisationForScaledEnergy(G4double e)1031 {1032 // G4double x = 0.0;1033 //if(theIonisationSubTable) {1034 G4double x = ((*theIonisationSubTable)[currentMaterialIndex]->Value(e))*chargeSqRatio;1035 if(e < minKinEnergy) x *= std::sqrt(e/minKinEnergy);1036 //}1037 return x;1038 }1039 1040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....1041 1042 inline G4double G4VEnergyLossProcess::GetScaledRangeForScaledEnergy(G4double e)1043 {1044 G4double x = ((*theRangeTableForLoss)[currentMaterialIndex])->Value(e);1045 if(e < minKinEnergy) x *= std::sqrt(e/minKinEnergy);1046 return x;1047 }1048 1049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....1050 1051 inline G4double G4VEnergyLossProcess::GetLimitScaledRangeForScaledEnergy(1052 G4double e)1053 {1054 G4double x;1055 1056 if (e < maxKinEnergyCSDA) {1057 x = ((*theCSDARangeTable)[currentMaterialIndex])->Value(e);1058 if(e < minKinEnergy) x *= std::sqrt(e/minKinEnergy);1059 } else {1060 x = theRangeAtMaxEnergy[currentMaterialIndex] +1061 (e - maxKinEnergyCSDA)/theDEDXAtMaxEnergy[currentMaterialIndex];1062 }1063 return x;1064 }1065 1066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....1067 1068 inline G4double G4VEnergyLossProcess::ScaledKinEnergyForLoss(G4double r)1069 {1070 G4PhysicsVector* v = (*theInverseRangeTable)[currentMaterialIndex];1071 G4double rmin = v->Energy(0);1072 G4double e = 0.0;1073 if(r >= rmin) { e = v->Value(r); }1074 else if(r > 0.0) {1075 G4double x = r/rmin;1076 e = minKinEnergy*x*x;1077 }1078 return e;1079 }1080 1081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....1082 1083 inline G4double G4VEnergyLossProcess::GetLambdaForScaledEnergy(G4double e)1084 {1085 return chargeSqRatio*(((*theLambdaTable)[currentMaterialIndex])->Value(e));1086 790 } 1087 791 … … 1111 815 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1112 816 817 inline G4double G4VEnergyLossProcess::SampleRange() 818 { 819 G4double e = amu_c2*preStepKinEnergy/particle->GetPDGMass(); 820 G4double s = fRange*std::pow(10.,vstrag->Value(e)); 821 G4double x = fRange + G4RandGauss::shoot(0.0,s); 822 if(x > 0.0) { fRange = x; } 823 return fRange; 824 } 825 826 // ======== Get/Set inline methods used at initialisation ================ 827 828 inline void G4VEnergyLossProcess::SetFluctModel(G4VEmFluctuationModel* p) 829 { 830 fluctModel = p; 831 } 832 833 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 834 835 inline G4VEmFluctuationModel* G4VEnergyLossProcess::FluctModel() 836 { 837 return fluctModel; 838 } 839 840 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 841 842 inline void G4VEnergyLossProcess::SetParticle(const G4ParticleDefinition* p) 843 { 844 particle = p; 845 } 846 847 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 848 849 inline void G4VEnergyLossProcess::SetSecondaryParticle(const G4ParticleDefinition* p) 850 { 851 secondaryParticle = p; 852 } 853 854 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 855 856 inline void G4VEnergyLossProcess::SetBaseParticle(const G4ParticleDefinition* p) 857 { 858 baseParticle = p; 859 } 860 861 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 862 863 inline const G4ParticleDefinition* G4VEnergyLossProcess::Particle() const 864 { 865 return particle; 866 } 867 868 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 869 870 inline const G4ParticleDefinition* G4VEnergyLossProcess::BaseParticle() const 871 { 872 return baseParticle; 873 } 874 875 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 876 877 inline const G4ParticleDefinition* G4VEnergyLossProcess::SecondaryParticle() const 878 { 879 return secondaryParticle; 880 } 881 882 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 883 884 inline void G4VEnergyLossProcess::SetLossFluctuations(G4bool val) 885 { 886 lossFluctuationFlag = val; 887 } 888 889 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 890 891 inline void G4VEnergyLossProcess::SetRandomStep(G4bool val) 892 { 893 rndmStepFlag = val; 894 } 895 896 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 897 898 inline void G4VEnergyLossProcess::SetIntegral(G4bool val) 899 { 900 integral = val; 901 } 902 903 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 904 905 inline G4bool G4VEnergyLossProcess::IsIntegral() const 906 { 907 return integral; 908 } 909 910 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 911 912 inline void G4VEnergyLossProcess::SetIonisation(G4bool val) 913 { 914 isIonisation = val; 915 if(val) { aGPILSelection = CandidateForSelection; } 916 else { aGPILSelection = NotCandidateForSelection; } 917 } 918 919 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 920 921 inline G4bool G4VEnergyLossProcess::IsIonisationProcess() const 922 { 923 return isIonisation; 924 } 925 926 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 927 928 inline void G4VEnergyLossProcess::SetLinearLossLimit(G4double val) 929 { 930 linLossLimit = val; 931 } 932 933 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 934 935 inline void G4VEnergyLossProcess::SetMinSubRange(G4double val) 936 { 937 minSubRange = val; 938 } 939 940 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 941 942 inline void G4VEnergyLossProcess::SetLambdaFactor(G4double val) 943 { 944 if(val > 0.0 && val <= 1.0) { lambdaFactor = val; } 945 } 946 947 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 948 949 void G4VEnergyLossProcess::SetStepFunction(G4double v1, G4double v2) 950 { 951 dRoverRange = v1; 952 finalRange = v2; 953 if (dRoverRange > 0.999) { dRoverRange = 1.0; } 954 currentCouple = 0; 955 mfpKinEnergy = DBL_MAX; 956 } 957 958 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 959 960 inline void G4VEnergyLossProcess::SetLowestEnergyLimit(G4double val) 961 { 962 lowestKinEnergy = val; 963 } 964 965 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 966 967 inline G4int G4VEnergyLossProcess::NumberOfSubCutoffRegions() const 968 { 969 return nSCoffRegions; 970 } 971 972 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 973 974 inline G4int G4VEnergyLossProcess::NumberOfDERegions() const 975 { 976 return nDERegions; 977 } 978 979 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 980 981 inline void G4VEnergyLossProcess::SetDEDXBinning(G4int nbins) 982 { 983 nBins = nbins; 984 } 985 986 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 987 988 inline void G4VEnergyLossProcess::SetLambdaBinning(G4int nbins) 989 { 990 nBins = nbins; 991 } 992 993 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 994 995 inline void G4VEnergyLossProcess::SetDEDXBinningForCSDARange(G4int nbins) 996 { 997 nBinsCSDA = nbins; 998 } 999 1000 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1001 1002 inline void G4VEnergyLossProcess::SetMinKinEnergy(G4double e) 1003 { 1004 minKinEnergy = e; 1005 } 1006 1007 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1008 1009 inline G4double G4VEnergyLossProcess::MinKinEnergy() const 1010 { 1011 return minKinEnergy; 1012 } 1013 1014 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1015 1016 inline void G4VEnergyLossProcess::SetMaxKinEnergy(G4double e) 1017 { 1018 maxKinEnergy = e; 1019 if(e < maxKinEnergyCSDA) { maxKinEnergyCSDA = e; } 1020 } 1021 1022 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1023 1024 inline G4double G4VEnergyLossProcess::MaxKinEnergy() const 1025 { 1026 return maxKinEnergy; 1027 } 1028 1029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1030 1031 inline void G4VEnergyLossProcess::SetMaxKinEnergyForCSDARange(G4double e) 1032 { 1033 maxKinEnergyCSDA = e; 1034 } 1035 1036 1037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1038 1039 inline G4bool G4VEnergyLossProcess::TablesAreBuilt() const 1040 { 1041 return tablesAreBuilt; 1042 } 1043 1044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1045 1046 inline G4PhysicsTable* G4VEnergyLossProcess::DEDXTable() const 1047 { 1048 return theDEDXTable; 1049 } 1050 1051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1052 1053 inline G4PhysicsTable* G4VEnergyLossProcess::DEDXTableForSubsec() const 1054 { 1055 return theDEDXSubTable; 1056 } 1057 1058 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1059 1060 inline G4PhysicsTable* G4VEnergyLossProcess::DEDXunRestrictedTable() const 1061 { 1062 return theDEDXunRestrictedTable; 1063 } 1064 1065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1066 1067 inline G4PhysicsTable* G4VEnergyLossProcess::IonisationTable() const 1068 { 1069 G4PhysicsTable* t = theDEDXTable; 1070 if(theIonisationTable) { t = theIonisationTable; } 1071 return t; 1072 } 1073 1074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1075 1076 inline G4PhysicsTable* G4VEnergyLossProcess::IonisationTableForSubsec() const 1077 { 1078 G4PhysicsTable* t = theDEDXSubTable; 1079 if(theIonisationSubTable) { t = theIonisationSubTable; } 1080 return t; 1081 } 1082 1083 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1084 1085 inline G4PhysicsTable* G4VEnergyLossProcess::CSDARangeTable() const 1086 { 1087 return theCSDARangeTable; 1088 } 1089 1090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1091 1092 inline G4PhysicsTable* G4VEnergyLossProcess::RangeTableForLoss() const 1093 { 1094 return theRangeTableForLoss; 1095 } 1096 1097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1098 1099 inline G4PhysicsTable* G4VEnergyLossProcess::InverseRangeTable() const 1100 { 1101 return theInverseRangeTable; 1102 } 1103 1104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1105 1106 inline G4PhysicsTable* G4VEnergyLossProcess::LambdaTable() 1107 { 1108 return theLambdaTable; 1109 } 1110 1111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1112 1113 inline G4PhysicsTable* G4VEnergyLossProcess::SubLambdaTable() 1114 { 1115 return theSubLambdaTable; 1116 } 1117 1118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1119 1113 1120 #endif -
trunk/source/processes/electromagnetic/utils/include/G4VMultipleScattering.hh
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VMultipleScattering.hh,v 1.6 2 2009/10/29 17:56:04vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VMultipleScattering.hh,v 1.63 2010/03/10 18:29:51 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 154 154 // The function overloads the corresponding function of the base 155 155 // class. 156 inlineG4double PostStepGetPhysicalInteractionLength(156 G4double PostStepGetPhysicalInteractionLength( 157 157 const G4Track&, 158 158 G4double previousStepSize, … … 160 160 161 161 // Along step actions 162 inlineG4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&);162 G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&); 163 163 164 164 // Post step actions 165 inlineG4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&);165 G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&); 166 166 167 167 // This method does not used for tracking, it is intended only for tests 168 inlineG4double ContinuousStepLimit(const G4Track& track,169 170 171 168 G4double ContinuousStepLimit(const G4Track& track, 169 G4double previousStepSize, 170 G4double currentMinimalStep, 171 G4double& currentSafety); 172 172 173 173 //------------------------------------------------------------------------ … … 318 318 }; 319 319 320 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 321 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 322 323 inline G4double G4VMultipleScattering::ContinuousStepLimit( 324 const G4Track& track, 325 G4double previousStepSize, 326 G4double currentMinimalStep, 327 G4double& currentSafety) 328 { 329 return GetContinuousStepLimit(track,previousStepSize,currentMinimalStep, 330 currentSafety); 331 } 332 333 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 334 335 inline void G4VMultipleScattering::SetBinning(G4int nbins) 336 { 337 nBins = nbins; 338 } 339 340 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 341 342 inline G4int G4VMultipleScattering::Binning() const 343 { 344 return nBins; 345 } 346 347 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 348 349 inline void G4VMultipleScattering::SetMinKinEnergy(G4double e) 350 { 351 minKinEnergy = e; 352 } 353 354 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 355 356 inline G4double G4VMultipleScattering::MinKinEnergy() const 357 { 358 return minKinEnergy; 359 } 360 361 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 362 363 inline void G4VMultipleScattering::SetMaxKinEnergy(G4double e) 364 { 365 maxKinEnergy = e; 366 } 367 368 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 369 370 inline G4double G4VMultipleScattering::MaxKinEnergy() const 371 { 372 return maxKinEnergy; 373 } 374 375 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 376 377 inline void G4VMultipleScattering::SetBuildLambdaTable(G4bool val) 378 { 379 buildLambdaTable = val; 380 } 381 382 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 383 384 inline G4PhysicsTable* G4VMultipleScattering::LambdaTable() const 385 { 386 return theLambdaTable; 387 } 388 389 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 390 391 inline const G4ParticleDefinition* G4VMultipleScattering::Particle() const 392 { 393 return currentParticle; 394 } 395 396 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 397 398 inline G4VEmModel* G4VMultipleScattering::SelectModel(G4double kinEnergy) 399 { 400 return modelManager->SelectModel(kinEnergy, currentMaterialIndex); 401 } 402 403 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 404 405 inline G4VEmModel* G4VMultipleScattering::SelectModelForMaterial( 406 G4double kinEnergy, size_t& idxRegion) const 407 { 408 return modelManager->SelectModel(kinEnergy, idxRegion); 409 } 410 411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 412 413 inline G4bool G4VMultipleScattering::LateralDisplasmentFlag() const 414 { 415 return latDisplasment; 416 } 417 418 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 419 420 inline void G4VMultipleScattering::SetLateralDisplasmentFlag(G4bool val) 421 { 422 latDisplasment = val; 423 } 424 425 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 426 427 inline G4double G4VMultipleScattering::Skin() const 428 { 429 return skin; 430 } 431 432 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 433 434 inline void G4VMultipleScattering::SetSkin(G4double val) 435 { 436 if(val < 1.0) skin = 0.0; 437 else skin = val; 438 } 439 440 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 441 442 inline G4double G4VMultipleScattering::RangeFactor() const 443 { 444 return facrange; 445 } 446 447 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 448 449 inline void G4VMultipleScattering::SetRangeFactor(G4double val) 450 { 451 if(val > 0.0) facrange = val; 452 } 453 454 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 455 456 inline G4double G4VMultipleScattering::GeomFactor() const 457 { 458 return facgeom; 459 } 460 461 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 462 463 inline void G4VMultipleScattering::SetGeomFactor(G4double val) 464 { 465 if(val > 0.0) facgeom = val; 466 } 467 468 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 469 470 inline G4double G4VMultipleScattering::PolarAngleLimit() const 471 { 472 return polarAngleLimit; 473 } 474 475 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 476 477 inline void G4VMultipleScattering::SetPolarAngleLimit(G4double val) 478 { 479 if(val < 0.0) polarAngleLimit = 0.0; 480 else if(val > pi) polarAngleLimit = pi; 481 else polarAngleLimit = val; 482 } 483 484 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 485 486 inline G4MscStepLimitType G4VMultipleScattering::StepLimitType() const 487 { 488 return stepLimit; 489 } 490 491 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 492 493 inline void G4VMultipleScattering::SetStepLimitType(G4MscStepLimitType val) 494 { 495 stepLimit = val; 496 if(val == fMinimal) facrange = 0.2; 320 // ======== Run time inline methods ================ 321 322 inline const G4MaterialCutsCouple* 323 G4VMultipleScattering::CurrentMaterialCutsCouple() const 324 { 325 return currentCouple; 326 } 327 328 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 329 330 inline 331 void G4VMultipleScattering::DefineMaterial(const G4MaterialCutsCouple* couple) 332 { 333 if(couple != currentCouple) { 334 currentCouple = couple; 335 currentMaterialIndex = couple->GetIndex(); 336 } 497 337 } 498 338 … … 509 349 x = currentModel->CrossSection(currentCouple,p,e); 510 350 } 511 if(x > DBL_MIN) x = 1./x;512 else x = DBL_MAX;351 if(x > DBL_MIN) { x = 1./x; } 352 else { x = DBL_MAX; } 513 353 return x; 514 354 } … … 516 356 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 517 357 518 inline 519 void G4VMultipleScattering::DefineMaterial(const G4MaterialCutsCouple* couple) 520 { 521 if(couple != currentCouple) { 522 currentCouple = couple; 523 currentMaterialIndex = couple->GetIndex(); 524 } 525 } 526 527 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 528 529 inline const G4MaterialCutsCouple* 530 G4VMultipleScattering::CurrentMaterialCutsCouple() const 531 { 532 return currentCouple; 533 } 534 535 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 536 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 537 538 // Follwoing methods are virtual, they are inlined because they applied at 539 // each simulation step and some compilers may inline these methods 540 541 inline G4double 542 G4VMultipleScattering::PostStepGetPhysicalInteractionLength( 543 const G4Track&, G4double, G4ForceCondition* condition) 544 { 545 *condition = Forced; 546 return DBL_MAX; 547 } 548 549 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 550 551 inline G4VParticleChange* 552 G4VMultipleScattering::AlongStepDoIt(const G4Track& track, const G4Step& step) 553 { 554 if(currentModel->IsActive(track.GetKineticEnergy())) { 555 fParticleChange.ProposeTrueStepLength(currentModel->ComputeTrueStepLength(step.GetStepLength())); 556 } 557 return &fParticleChange; 558 } 559 560 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 561 562 inline G4VParticleChange* 563 G4VMultipleScattering::PostStepDoIt(const G4Track& track, const G4Step& step) 564 { 565 fParticleChange.Initialize(track); 566 if(currentModel->IsActive(track.GetKineticEnergy())) { 567 currentModel->SampleScattering(track.GetDynamicParticle(), 568 step.GetPostStepPoint()->GetSafety()); 569 } 570 return &fParticleChange; 358 inline G4VEmModel* G4VMultipleScattering::SelectModel(G4double kinEnergy) 359 { 360 return modelManager->SelectModel(kinEnergy, currentMaterialIndex); 361 } 362 363 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 364 365 inline G4VEmModel* G4VMultipleScattering::SelectModelForMaterial( 366 G4double kinEnergy, size_t& idxRegion) const 367 { 368 return modelManager->SelectModel(kinEnergy, idxRegion); 369 } 370 371 // ======== Get/Set inline methods used at initialisation ================ 372 373 inline void G4VMultipleScattering::SetBinning(G4int nbins) 374 { 375 nBins = nbins; 376 } 377 378 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 379 380 inline G4int G4VMultipleScattering::Binning() const 381 { 382 return nBins; 383 } 384 385 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 386 387 inline void G4VMultipleScattering::SetMinKinEnergy(G4double e) 388 { 389 minKinEnergy = e; 390 } 391 392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 393 394 inline G4double G4VMultipleScattering::MinKinEnergy() const 395 { 396 return minKinEnergy; 397 } 398 399 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 400 401 inline void G4VMultipleScattering::SetMaxKinEnergy(G4double e) 402 { 403 maxKinEnergy = e; 404 } 405 406 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 407 408 inline G4double G4VMultipleScattering::MaxKinEnergy() const 409 { 410 return maxKinEnergy; 411 } 412 413 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 414 415 inline void G4VMultipleScattering::SetBuildLambdaTable(G4bool val) 416 { 417 buildLambdaTable = val; 418 } 419 420 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 421 422 inline G4PhysicsTable* G4VMultipleScattering::LambdaTable() const 423 { 424 return theLambdaTable; 425 } 426 427 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 428 429 inline const G4ParticleDefinition* G4VMultipleScattering::Particle() const 430 { 431 return currentParticle; 432 } 433 434 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 435 436 inline G4bool G4VMultipleScattering::LateralDisplasmentFlag() const 437 { 438 return latDisplasment; 439 } 440 441 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 442 443 inline void G4VMultipleScattering::SetLateralDisplasmentFlag(G4bool val) 444 { 445 latDisplasment = val; 446 } 447 448 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 449 450 inline G4double G4VMultipleScattering::Skin() const 451 { 452 return skin; 453 } 454 455 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 456 457 inline void G4VMultipleScattering::SetSkin(G4double val) 458 { 459 if(val < 1.0) { skin = 0.0; } 460 else { skin = val; } 461 } 462 463 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 464 465 inline G4double G4VMultipleScattering::RangeFactor() const 466 { 467 return facrange; 468 } 469 470 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 471 472 inline void G4VMultipleScattering::SetRangeFactor(G4double val) 473 { 474 if(val > 0.0) facrange = val; 475 } 476 477 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 478 479 inline G4double G4VMultipleScattering::GeomFactor() const 480 { 481 return facgeom; 482 } 483 484 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 485 486 inline void G4VMultipleScattering::SetGeomFactor(G4double val) 487 { 488 if(val > 0.0) facgeom = val; 489 } 490 491 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 492 493 inline G4double G4VMultipleScattering::PolarAngleLimit() const 494 { 495 return polarAngleLimit; 496 } 497 498 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 499 500 inline void G4VMultipleScattering::SetPolarAngleLimit(G4double val) 501 { 502 if(val < 0.0) { polarAngleLimit = 0.0; } 503 else if(val > CLHEP::pi) { polarAngleLimit = CLHEP::pi; } 504 else { polarAngleLimit = val; } 505 } 506 507 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 508 509 inline G4MscStepLimitType G4VMultipleScattering::StepLimitType() const 510 { 511 return stepLimit; 512 } 513 514 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 515 516 inline void G4VMultipleScattering::SetStepLimitType(G4MscStepLimitType val) 517 { 518 stepLimit = val; 519 if(val == fMinimal) { facrange = 0.2; } 571 520 } 572 521 -
trunk/source/processes/electromagnetic/utils/src/G4EmCalculator.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmCalculator.cc,v 1. 49 2009/11/22 17:58:39vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4EmCalculator.cc,v 1.53 2010/04/13 10:58:03 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 94 94 currentMaterial = 0; 95 95 currentParticle = 0; 96 lambdaParticle = 0; 96 97 baseParticle = 0; 97 98 currentLambda = 0; … … 102 103 currentParticleName= ""; 103 104 currentMaterialName= ""; 105 currentName = ""; 106 lambdaName = ""; 104 107 theGenericIon = G4GenericIon::GenericIon(); 105 108 ionEffCharge = new G4ionEffectiveCharge(); … … 113 116 { 114 117 delete ionEffCharge; 115 for (G4int i=0; i<nLocalMaterials; i++) {118 for (G4int i=0; i<nLocalMaterials; ++i) { 116 119 delete localCouples[i]; 117 120 } … … 310 313 G4int idx = couple->GetIndex(); 311 314 FindLambdaTable(p, processName); 315 312 316 if(currentLambda) { 313 317 G4double e = kinEnergy*massRatio; 314 318 res = (((*currentLambda)[idx])->Value(e))*chargeSquare; 315 319 if(verbose>0) { 316 G4cout << " E(MeV)= " << kinEnergy/MeV320 G4cout << "G4EmCalculator::GetXSPerVolume: E(MeV)= " << kinEnergy/MeV 317 321 << " cross(cm-1)= " << res*cm 318 322 << " " << p->GetParticleName() 319 323 << " in " << mat->GetName(); 320 324 if(verbose>1) 321 G4cout << " idx= " << idx << " e(MeV)= " << e325 G4cout << " idx= " << idx << " Escaled((MeV)= " << e 322 326 << " q2= " << chargeSquare; 323 327 G4cout << G4endl; … … 350 354 G4double res = DBL_MAX; 351 355 G4double x = GetCrossSectionPerVolume(kinEnergy,p, processName, mat,region); 352 if(x > 0.0) res = 1.0/x;356 if(x > 0.0) { res = 1.0/x; } 353 357 if(verbose>1) { 354 358 G4cout << "G4EmCalculator::GetMeanFreePath: E(MeV)= " << kinEnergy/MeV … … 495 499 << " in " << currentMaterialName 496 500 << " Zi^2= " << chargeSquare 501 << " isIon=" << isIon 497 502 << G4endl; 498 503 } … … 516 521 lManager->GetEnergyLossProcessVector(); 517 522 G4int n = vel.size(); 518 for(G4int i=0; i<n; i++) {523 for(G4int i=0; i<n; ++i) { 519 524 const G4ParticleDefinition* p = (vel[i])->Particle(); 520 if((!isIon && p == part) || (isIon && p == theGenericIon)) 525 if((!isIon && p == part) || (isIon && p == theGenericIon)) { 521 526 dedx += ComputeDEDX(kinEnergy,part,(vel[i])->GetProcessName(),mat,cut); 527 } 522 528 } 523 529 } … … 619 625 } 620 626 if(verbose>0) { 621 G4cout << " E(MeV)= " << kinEnergy/MeV627 G4cout << "G4EmCalculator::ComputeXSPerVolume: E(MeV)= " << kinEnergy/MeV 622 628 << " cross(cm-1)= " << res*cm 629 << " cut(keV)= " << cut/keV 623 630 << " " << p->GetParticleName() 624 631 << " in " << mat->GetName() … … 686 693 return ComputeCrossSectionPerAtom(kinEnergy,FindParticle(particle), 687 694 processName, 688 elm->GetZ(),elm->Get A(),cut);695 elm->GetZ(),elm->GetN(),cut); 689 696 } 690 697 … … 886 893 currentMaterial = material; 887 894 currentMaterialName = material->GetName(); 888 for (G4int i=0; i<nLocalMaterials; i++) {895 for (G4int i=0; i<nLocalMaterials; ++i) { 889 896 if(material == localMaterials[i] && cut == localCuts[i]) { 890 897 currentCouple = localCouples[i]; … … 911 918 { 912 919 // Search for the process 913 if (p != currentParticle || processName != currentName) { 914 currentName = processName; 915 currentLambda = 0; 920 if (!currentLambda || p != lambdaParticle || processName != lambdaName) { 921 lambdaName = processName; 922 currentLambda = 0; 923 lambdaParticle = p; 916 924 917 925 G4String partname = p->GetParticleName(); … … 924 932 lManager->GetEnergyLossProcessVector(); 925 933 G4int n = vel.size(); 926 for(G4int i=0; i<n; i++) {927 if((vel[i])->GetProcessName() == currentName &&934 for(G4int i=0; i<n; ++i) { 935 if((vel[i])->GetProcessName() == lambdaName && 928 936 (vel[i])->Particle() == part) 929 937 { 930 938 currentLambda = (vel[i])->LambdaTable(); 931 939 isApplicable = true; 932 break; 940 if(verbose>1) { 941 G4cout << "G4VEnergyLossProcess is found out: " 942 << currentName << G4endl; 943 } 944 return; 933 945 } 934 946 } … … 938 950 const std::vector<G4VEmProcess*> vem = lManager->GetEmProcessVector(); 939 951 G4int n = vem.size(); 940 for(G4int i=0; i<n; i++) {941 if((vem[i])->GetProcessName() == currentName &&952 for(G4int i=0; i<n; ++i) { 953 if((vem[i])->GetProcessName() == lambdaName && 942 954 (vem[i])->Particle() == part) 943 955 { 944 956 currentLambda = (vem[i])->LambdaTable(); 945 957 isApplicable = true; 946 break; 958 if(verbose>1) { 959 G4cout << "G4VEmProcess is found out: " 960 << currentName << G4endl; 961 } 962 return; 947 963 } 948 964 } … … 954 970 lManager->GetMultipleScatteringVector(); 955 971 G4int n = vmsc.size(); 956 for(G4int i=0; i<n; i++) {957 if((vmsc[i])->GetProcessName() == currentName &&972 for(G4int i=0; i<n; ++i) { 973 if((vmsc[i])->GetProcessName() == lambdaName && 958 974 (vmsc[i])->Particle() == part) 959 975 { 960 976 currentLambda = (vmsc[i])->LambdaTable(); 961 977 isApplicable = true; 962 break; 978 if(verbose>1) { 979 G4cout << "G4VMultipleScattering is found out: " 980 << currentName << G4endl; 981 } 982 return; 963 983 } 964 984 } … … 1002 1022 G4int n = vel.size(); 1003 1023 G4VEnergyLossProcess* elproc = 0; 1004 for(G4int i=0; i<n; i++) {1024 for(G4int i=0; i<n; ++i) { 1005 1025 // G4cout << "i= " << i << " part= " 1006 1026 // << (vel[i])->Particle()->GetParticleName() … … 1023 1043 currentModel = elproc->SelectModelForMaterial(scaledEnergy, idx); 1024 1044 G4double eth = currentModel->LowEnergyLimit(); 1025 loweModel = elproc->SelectModelForMaterial(eth - CLHEP::eV, idx); 1045 if(eth > 0.0) { 1046 loweModel = elproc->SelectModelForMaterial(eth - CLHEP::eV, idx); 1047 } 1026 1048 } 1027 1049 … … 1030 1052 const std::vector<G4VEmProcess*> vem = lManager->GetEmProcessVector(); 1031 1053 G4int n = vem.size(); 1032 for(G4int i=0; i<n; i++) {1054 for(G4int i=0; i<n; ++i) { 1033 1055 if((vem[i])->GetProcessName() == currentName && 1034 1056 (vem[i])->Particle() == part) … … 1036 1058 currentModel = (vem[i])->SelectModelForMaterial(kinEnergy, idx); 1037 1059 G4double eth = currentModel->LowEnergyLimit(); 1038 loweModel = (vem[i])->SelectModelForMaterial(eth - CLHEP::eV, idx); 1060 if(eth > 0.0) { 1061 loweModel = (vem[i])->SelectModelForMaterial(eth - CLHEP::eV, idx); 1062 } 1039 1063 break; 1040 1064 } … … 1047 1071 lManager->GetMultipleScatteringVector(); 1048 1072 G4int n = vmsc.size(); 1049 for(G4int i=0; i<n; i++) {1073 for(G4int i=0; i<n; ++i) { 1050 1074 if((vmsc[i])->GetProcessName() == currentName && 1051 1075 (vmsc[i])->Particle() == part) … … 1053 1077 currentModel = (vmsc[i])->SelectModelForMaterial(kinEnergy, idx); 1054 1078 G4double eth = currentModel->LowEnergyLimit(); 1055 loweModel = (vmsc[i])->SelectModelForMaterial(eth - CLHEP::eV, idx); 1079 if(eth > 0.0) { 1080 loweModel = (vmsc[i])->SelectModelForMaterial(eth - CLHEP::eV, idx); 1081 } 1056 1082 break; 1057 1083 } … … 1082 1108 const G4ParticleDefinition* part = p; 1083 1109 1084 if(p->GetParticleType() == "nucleus" && 1085 partname != "deuteron" && 1086 partname != "triton") { part = theGenericIon; } 1110 if(p->GetParticleType() == "nucleus" 1111 && currentParticleName != "deuteron" 1112 && currentParticleName != "triton" 1113 && currentParticleName != "alpha+" 1114 && currentParticleName != "helium" 1115 && currentParticleName != "hydrogen" 1116 ) { part = theGenericIon; } 1087 1117 1088 1118 G4LossTableManager* lManager = G4LossTableManager::Instance(); … … 1090 1120 lManager->GetEnergyLossProcessVector(); 1091 1121 G4int n = vel.size(); 1092 for(G4int i=0; i<n; i++) {1122 for(G4int i=0; i<n; ++i) { 1093 1123 if( (vel[i])->Particle() == part ) { 1094 1124 elp = vel[i]; -
trunk/source/processes/electromagnetic/utils/src/G4EmConfigurator.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmConfigurator.cc,v 1. 6 2009/11/22 19:48:30vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4EmConfigurator.cc,v 1.8 2010/06/04 15:33:56 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 61 61 #include "G4VMultipleScattering.hh" 62 62 63 enum PType {unknown=0, eloss, discrete, msc}; 64 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 66 67 G4EmConfigurator::G4EmConfigurator() 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 65 G4EmConfigurator::G4EmConfigurator(G4int val):verbose(val) 68 66 { 69 67 index = -10; … … 74 72 G4EmConfigurator::~G4EmConfigurator() 75 73 {} 76 77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......78 79 void G4EmConfigurator::AddExtraEmModel(const G4String& particleName,80 G4VEmModel* em,81 G4VEmFluctuationModel* fm)82 {83 particleList.push_back(particleName);84 modelList.push_back(em);85 flucModelList.push_back(fm);86 }87 88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......89 90 void G4EmConfigurator::AddModelForRegion(const G4String& particleName,91 const G4String& processName,92 const G4String& modelName,93 const G4String& regionName,94 G4double emin, G4double emax,95 const G4String& flucModelName)96 {97 particles.push_back(particleName);98 processes.push_back(processName);99 models.push_back(modelName);100 regions.push_back(regionName);101 flucModels.push_back(flucModelName);102 lowEnergy.push_back(emin);103 highEnergy.push_back(emax);104 }105 74 106 75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 114 83 G4VEmFluctuationModel* fm) 115 84 { 116 AddExtraEmModel(particleName, mod, fm); 117 G4String fname = ""; 118 if(fm) fname = fm->GetName(); 119 G4String mname = ""; 120 if(mod) mname = mod->GetName(); 121 AddModelForRegion(particleName, processName, mname, regionName, 122 emin, emax, fname); 85 if(1 < verbose) { 86 G4cout << " G4EmConfigurator::SetExtraEmModel " << mod->GetName() 87 << " for " << particleName 88 << " and " << processName 89 << " in the region <" << regionName 90 << "> Emin(MeV)= " << emin/MeV 91 << " Emax(MeV)= " << emax/MeV 92 << G4endl; 93 } 94 if(mod || fm) { 95 models.push_back(mod); 96 flucModels.push_back(fm); 97 } else { 98 models.push_back(new G4DummyModel()); 99 flucModels.push_back(0); 100 } 101 102 particles.push_back(particleName); 103 processes.push_back(processName); 104 regions.push_back(regionName); 105 lowEnergy.push_back(emin); 106 highEnergy.push_back(emax); 123 107 } 124 108 … … 127 111 void G4EmConfigurator::AddModels() 128 112 { 113 size_t n = models.size(); 114 if(0 < verbose) { 115 G4cout << "### G4EmConfigurator::AddModels n= " << n << G4endl; 116 } 117 if(n > 0) { 118 for(size_t i=0; i<n; ++i) { 119 if(models[i]) { 120 G4Region* reg = FindRegion(regions[i]); 121 if(reg) { 122 --index; 123 SetModelForRegion(models[i],flucModels[i],reg, 124 particles[i],processes[i], 125 lowEnergy[i],highEnergy[i]); 126 } 127 } 128 } 129 } 130 Clear(); 131 } 132 133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 134 135 void G4EmConfigurator::SetModelForRegion(G4VEmModel* mod, 136 G4VEmFluctuationModel* fm, 137 G4Region* reg, 138 const G4String& particleName, 139 const G4String& processName, 140 G4double emin, G4double emax) 141 { 142 if(1 < verbose) { 143 G4cout << " G4EmConfigurator::SetModelForRegion: " << mod->GetName() 144 << G4endl; 145 G4cout << " For " << particleName 146 << " and " << processName 147 << " in the region <" << reg->GetName() 148 << " Emin(MeV)= " << emin/MeV 149 << " Emax(MeV)= " << emax/MeV; 150 if(fm) { G4cout << " FLmodel " << fm->GetName(); } 151 G4cout << G4endl; 152 } 153 G4ParticleTable::G4PTblDicIterator* theParticleIterator = 154 G4ParticleTable::GetParticleTable()->GetIterator(); 155 156 theParticleIterator->reset(); 157 while( (*theParticleIterator)() ) { 158 const G4ParticleDefinition* part = theParticleIterator->value(); 159 160 //G4cout << particleName << " " << part->GetParticleName() << G4endl; 161 162 if((part->GetParticleName() == particleName) || 163 (particleName == "all") || 164 (particleName == "charged" && part->GetPDGCharge() != 0.0)) { 165 166 // search for process 167 G4ProcessManager* pmanager = part->GetProcessManager(); 168 G4ProcessVector* plist = pmanager->GetProcessList(); 169 G4int np = pmanager->GetProcessListLength(); 170 171 //G4cout << processName << " in list of " << np << G4endl; 172 173 G4VProcess* proc = 0; 174 for(G4int i=0; i<np; i++) { 175 if(processName == (*plist)[i]->GetProcessName()) { 176 proc = (*plist)[i]; 177 break; 178 } 179 } 180 if(!proc) { 181 G4cout << "### G4EmConfigurator WARNING: fails to find a process <" 182 << processName << "> for " << particleName << G4endl; 183 return; 184 185 } 186 187 if(mod) { 188 if(!UpdateModelEnergyRange(mod, emin,emax)) { return; } 189 } 190 // classify process 191 G4int ii = proc->GetProcessSubType(); 192 if(10 == ii && mod) { 193 G4VMultipleScattering* p = static_cast<G4VMultipleScattering*>(proc); 194 p->AddEmModel(index,mod,reg); 195 if(1 < verbose) { 196 G4cout << "### Added msc model order= " << index << " for " 197 << particleName << " and " << processName << G4endl; 198 } 199 return; 200 } else if(2 <= ii && 4 >= ii) { 201 G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc); 202 if(!mod && fm) { 203 p->SetFluctModel(fm); 204 } else { 205 p->AddEmModel(index,mod,fm,reg); 206 if(1 < verbose) { 207 G4cout << "### Added eloss model order= " << index << " for " 208 << particleName << " and " << processName << G4endl; 209 } 210 } 211 return; 212 } else if(mod) { 213 G4VEmProcess* p = static_cast<G4VEmProcess*>(proc); 214 p->AddEmModel(index,mod,reg); 215 if(1 < verbose) { 216 G4cout << "### Added em model order= " << index << " for " 217 << particleName << " and " << processName << G4endl; 218 } 219 return; 220 } else { 221 return; 222 } 223 } 224 } 225 } 226 227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 228 229 void 230 G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle, 231 G4VEnergyLossProcess* p) 232 { 129 233 size_t n = particles.size(); 130 //G4cout << " G4EmConfigurator::AddModels n= " << n << G4endl; 234 if(1 < verbose) { 235 G4cout << " G4EmConfigurator::PrepareModels for EnergyLoss n= " 236 << n << G4endl; 237 } 131 238 if(n > 0) { 132 for(size_t i=0; i<n; i++) { 133 SetModelForRegion(particles[i],processes[i],models[i],regions[i], 134 flucModels[i],lowEnergy[i],highEnergy[i]); 239 G4String particleName = aParticle->GetParticleName(); 240 G4String processName = p->GetProcessName(); 241 //G4cout << particleName << " " << processName << G4endl; 242 for(size_t i=0; i<n; ++i) { 243 //G4cout << particles[i] << " " << processes[i] << G4endl; 244 if(processName == processes[i]) { 245 if((particleName == particles[i]) || 246 (particles[i] == "all") || 247 (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) { 248 G4Region* reg = FindRegion(regions[i]); 249 //G4cout << "Region " << reg << G4endl; 250 if(reg) { 251 --index; 252 G4VEmModel* mod = models[i]; 253 G4VEmFluctuationModel* fm = flucModels[i]; 254 if(mod) { 255 if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) { 256 p->AddEmModel(index,mod,fm,reg); 257 if(1 < verbose) { 258 G4cout << "### Added eloss model order= " << index << " for " 259 << particleName << " and " << processName << G4endl; 260 } 261 } 262 } else if(fm) { 263 p->SetFluctModel(fm); 264 } 265 } 266 } 267 } 135 268 } 136 269 } 270 } 271 272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 273 274 void 275 G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle, 276 G4VEmProcess* p) 277 { 278 size_t n = particles.size(); 279 if(1 < verbose) { 280 G4cout << " G4EmConfigurator::PrepareModels for EM process n= " 281 << n << G4endl; 282 } 283 if(n > 0) { 284 G4String particleName = aParticle->GetParticleName(); 285 G4String processName = p->GetProcessName(); 286 //G4cout << particleName << " " << particleName << G4endl; 287 for(size_t i=0; i<n; ++i) { 288 if(processName == processes[i]) { 289 if((particleName == particles[i]) || 290 (particles[i] == "all") || 291 (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) { 292 G4Region* reg = FindRegion(regions[i]); 293 //G4cout << "Region " << reg << G4endl; 294 if(reg) { 295 --index; 296 G4VEmModel* mod = models[i]; 297 if(mod) { 298 if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) { 299 p->AddEmModel(index,mod,reg); 300 if(1 < verbose) { 301 G4cout << "### Added em model order= " << index << " for " 302 << particleName << " and " << processName << G4endl; 303 } 304 } 305 } 306 } 307 } 308 } 309 } 310 } 311 } 312 313 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 314 315 void 316 G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle, 317 G4VMultipleScattering* p) 318 { 319 size_t n = particles.size(); 320 if(1 < verbose) { 321 G4cout << " G4EmConfigurator::PrepareModels for MSC process n= " 322 << n << G4endl; 323 } 324 325 if(n > 0) { 326 G4String particleName = aParticle->GetParticleName(); 327 G4String processName = p->GetProcessName(); 328 for(size_t i=0; i<n; ++i) { 329 if(processName == processes[i]) { 330 if((particleName == particles[i]) || 331 (particles[i] == "all") || 332 (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) { 333 G4Region* reg = FindRegion(regions[i]); 334 if(reg) { 335 --index; 336 G4VEmModel* mod = models[i]; 337 if(mod) { 338 if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) { 339 p->AddEmModel(index,mod,reg); 340 G4cout << "### Added msc model order= " << index << " for " 341 << particleName << " and " << processName << G4endl; 342 } 343 } 344 } 345 } 346 } 347 } 348 } 349 } 350 351 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 352 353 void G4EmConfigurator::Clear() 354 { 137 355 particles.clear(); 138 356 processes.clear(); … … 146 364 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 147 365 148 void G4EmConfigurator::SetModelForRegion(const G4String& particleName, 149 const G4String& processName, 150 const G4String& modelName, 151 const G4String& regionName, 152 const G4String& flucModelName, 153 G4double emin, G4double emax) 154 { 155 //G4cout << " G4EmConfigurator::SetModelForRegion" << G4endl; 156 157 // new set 158 --index; 159 160 G4ParticleTable::G4PTblDicIterator* theParticleIterator = 161 G4ParticleTable::GetParticleTable()->GetIterator(); 162 163 theParticleIterator->reset(); 164 while( (*theParticleIterator)() ) { 165 const G4ParticleDefinition* part = theParticleIterator->value(); 166 167 //G4cout << particleName << " " << part->GetParticleName() << G4endl; 168 169 if(particleName == part->GetParticleName() || 170 (particleName == "charged" && part->GetPDGCharge() != 0.0) ) { 171 172 173 // search for process 174 G4ProcessManager* pmanager = part->GetProcessManager(); 175 G4ProcessVector* plist = pmanager->GetProcessList(); 176 G4int np = pmanager->GetProcessListLength(); 177 178 //G4cout << processName << " in list of " << np << G4endl; 179 180 G4VProcess* proc = 0; 181 for(G4int i=0; i<np; i++) { 182 if(processName == (*plist)[i]->GetProcessName()) { 183 proc = (*plist)[i]; 184 break; 185 } 186 } 187 if(!proc) { 188 G4cout << "### G4EmConfigurator WARNING: fails to find a process <" 189 << processName << "> for " << particleName << G4endl; 190 191 } else { 192 193 // classify process 194 PType ptype = discrete; 195 G4int ii = proc->GetProcessSubType(); 196 if(10 == ii) ptype = msc; 197 else if(2 <= ii && 4 >= ii) ptype = eloss; 198 199 // find out model 200 G4VEmModel* mod = 0; 201 G4VEmFluctuationModel* fluc = 0; 202 203 G4int nm = modelList.size(); 204 //G4cout << "Search model " << modelName << " in " << nm << G4endl; 205 206 for(G4int i=0; i<nm; i++) { 207 G4String mname = ""; 208 if(modelList[i]) mname = modelList[i]->GetName(); 209 G4String fname = ""; 210 if(flucModelList[i]) fname = flucModelList[i]->GetName(); 211 if(modelName == mname && flucModelName == fname && 212 (particleList[i] == "" || particleList[i] == particleName) ) { 213 mod = modelList[i]; 214 fluc = flucModelList[i]; 215 break; 216 } 217 } 218 219 if("dummy" == modelName) mod = new G4DummyModel(); 220 221 if(!mod) { 222 223 // set fluctuation model for ionisation processes 224 if(fluc && ptype == eloss) { 225 G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc); 226 p->SetFluctModel(fluc); 227 228 } else { 229 G4cout << "### G4EmConfigurator WARNING: fails to find a model <" 230 << modelName << "> for process <" 231 << processName << "> and " << particleName 232 << G4endl; 233 if(flucModelName != "") { 234 G4cout << " fluctuation model <" 235 << flucModelName << G4endl; 236 } 237 } 238 } else { 239 240 // search for region 241 G4Region* reg = 0; 242 G4RegionStore* regStore = G4RegionStore::GetInstance(); 243 G4String r = regionName; 244 if(r == "" || r == "world" || r == "World") r = "DefaultRegionForTheWorld"; 245 reg = regStore->GetRegion(r, true); 246 if(!reg) { 247 G4cout << "### G4EmConfigurator WARNING: fails to find a region <" 248 << r << "> for model <" << modelName << "> of the process " 249 << processName << " and " << particleName << G4endl; 250 return; 251 } 252 253 // energy limits 254 G4double e1 = std::max(emin,mod->LowEnergyLimit()); 255 G4double e2 = std::min(emax,mod->HighEnergyLimit()); 256 if(e2 < e1) e2 = e1; 257 mod->SetLowEnergyLimit(e1); 258 mod->SetHighEnergyLimit(e2); 259 260 //G4cout << "index= " << index << " e1= " << e1 << " e2= " << e2 << G4endl; 261 262 // added model 263 if(ptype == eloss) { 264 G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc); 265 p->AddEmModel(index,mod,fluc,reg); 266 //G4cout << "### Added eloss model order= " << index << " for " 267 // << particleName << " and " << processName << " " << mod << G4endl; 268 } else if(ptype == discrete) { 269 G4VEmProcess* p = static_cast<G4VEmProcess*>(proc); 270 p->AddEmModel(index,mod,reg); 271 } else if(ptype == msc) { 272 //G4cout << "### Added msc model order= " << index << " for " 273 // << particleName << " and " << processName << " " << mod << G4endl; 274 G4VMultipleScattering* p = static_cast<G4VMultipleScattering*>(proc); 275 p->AddEmModel(index,mod,reg); 276 } 277 } 278 } 279 } 280 } 281 } 282 283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 284 285 286 287 288 289 290 291 366 G4Region* G4EmConfigurator::FindRegion(const G4String& regionName) 367 { 368 // search for region 369 G4Region* reg = 0; 370 G4RegionStore* regStore = G4RegionStore::GetInstance(); 371 G4String r = regionName; 372 if(r == "" || r == "world" || r == "World") { 373 r = "DefaultRegionForTheWorld"; 374 } 375 reg = regStore->GetRegion(r, true); 376 if(!reg) { 377 G4cout << "### G4EmConfigurator WARNING: fails to find a region <" 378 << r << G4endl; 379 } else if(verbose > 1) { 380 G4cout << "### G4EmConfigurator finds out G4Region <" << r << ">" 381 << G4endl; 382 } 383 return reg; 384 } 385 386 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 387 388 G4bool G4EmConfigurator::UpdateModelEnergyRange(G4VEmModel* mod, 389 G4double emin, G4double emax) 390 { 391 // energy limits 392 G4double e1 = std::max(emin,mod->LowEnergyLimit()); 393 G4double e2 = std::min(emax,mod->HighEnergyLimit()); 394 if(e2 <= e1) { 395 G4cout << "### G4EmConfigurator WARNING: empty energy interval" 396 << " for <" << mod->GetName() 397 << "> Emin(MeV)= " << e1/CLHEP::MeV 398 << "> Emax(MeV)= " << e2/CLHEP::MeV 399 << G4endl; 400 return false; 401 } 402 mod->SetLowEnergyLimit(e1); 403 mod->SetHighEnergyLimit(e2); 404 if(verbose > 1) { 405 G4cout << "### G4EmConfigurator for " << mod->GetName() 406 << " Emin(MeV)= " << e1/MeV << " Emax(MeV)= " << e2/MeV 407 << G4endl; 408 } 409 return true; 410 } 411 412 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/source/processes/electromagnetic/utils/src/G4EmCorrections.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmCorrections.cc,v 1.5 4 2009/10/29 17:56:36 vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4EmCorrections.cc,v 1.58 2010/06/04 09:28:46 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 68 68 #include "G4ProductionCutsTable.hh" 69 69 #include "G4MaterialCutsCouple.hh" 70 #include "G4AtomicShells.hh" 70 71 71 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... … … 123 124 G4double sum = (2.0*(Barkas + Bloch) + Mott); 124 125 125 if(verbose > 1) 126 if(verbose > 1) { 126 127 G4cout << "EmCorrections: E(MeV)= " << e/MeV << " Barkas= " << Barkas 127 128 << " Bloch= " << Bloch << " Mott= " << Mott 128 << " Sum= " << sum << G4endl;129 129 << " Sum= " << sum << " q2= " << q2 << G4endl; 130 } 130 131 sum *= material->GetElectronDensity() * q2 * twopi_mc2_rcl2 /beta2; 131 132 return sum; … … 165 166 // Other corrections from S.P.Ahlen Rev. Mod. Phys., Vol 52, No1, 1980 166 167 SetupKinematics(p, mat, e); 167 if(tau <= 0.0) return 0.0;168 if(tau <= 0.0) { return 0.0; } 168 169 169 170 G4double Barkas = BarkasCorrection (p, mat, e); … … 180 181 sum *= material->GetElectronDensity() * q2 * twopi_mc2_rcl2 /beta2; 181 182 182 if(verbose > 1) G4cout << " Sum= " << sum << G4endl;183 if(verbose > 1) { G4cout << " Sum= " << sum << G4endl; } 183 184 return sum; 184 185 } … … 219 220 sum = ComputeIonCorrections(p,couple->GetMaterial(),e) - rest/e; 220 221 221 if(verbose > 1) G4cout << " Sum= " << sum << " dSum= " << rest/e << G4endl;222 if(verbose > 1) { G4cout << " Sum= " << sum << " dSum= " << rest/e << G4endl; } 222 223 } 223 224 return sum; … … 267 268 } 268 269 G4double e0= 13.6*eV*Z2; 269 term += f*atomDensity[i]*KShell( shells.GetBindingEnergy(iz,0)/e0,ba2/Z2)/Z;270 term += f*atomDensity[i]*KShell(G4AtomicShells::GetBindingEnergy(iz,0)/e0,ba2/Z2)/Z; 270 271 } 271 272 … … 293 294 G4double e0= 13.6*eV*Z2*0.25; 294 295 G4double f = 0.125; 295 G4int nmax = std::min(4, shells.GetNumberOfShells(iz));296 G4int nmax = std::min(4,G4AtomicShells::GetNumberOfShells(iz)); 296 297 for(G4int j=1; j<nmax; j++) { 297 G4double ne = G4double( shells.GetNumberOfElectrons(iz,j));298 G4double e1 = shells.GetBindingEnergy(iz,j);298 G4double ne = G4double(G4AtomicShells::GetNumberOfElectrons(iz,j)); 299 G4double e1 = G4AtomicShells::GetBindingEnergy(iz,j); 299 300 // G4cout << "LShell: j= " << j << " ne= " << ne << " e(eV)= " << e/eV 300 301 // << " e0(eV)= " << e0/eV << G4endl; … … 417 418 for (G4int i = 0; i<numberOfElements; i++) { 418 419 420 G4double res = 0.0; 419 421 G4double Z = (*theElementVector)[i]->GetZ(); 420 422 G4int iz = G4int(Z); … … 426 428 } 427 429 G4double e0= 13.6*eV*Z2; 428 term += f*atomDensity[i]*KShell(shells.GetBindingEnergy(iz,0)/e0,ba2/Z2)/Z;430 res += f*KShell(G4AtomicShells::GetBindingEnergy(iz,0)/e0,ba2/Z2); 429 431 if(2 < iz) { 430 432 G4double Zeff = Z - ZD[10]; … … 434 436 f = 0.125; 435 437 G4double eta = ba2/Z2; 436 G4int ntot = shells.GetNumberOfShells(iz);438 G4int ntot = G4AtomicShells::GetNumberOfShells(iz); 437 439 G4int nmax = std::min(4, ntot); 438 440 G4double norm = 0.0; 439 441 G4double eshell = 0.0; 440 for(G4int j=1; j<nmax; j++) {441 G4double x = G4double(shells.GetNumberOfElectrons(iz,j));442 G4 double e1 = shells.GetBindingEnergy(iz,j);443 norm += x;444 eshell += e1* x;445 term += f*x*atomDensity[i]*LShell(e1/e0,eta)/Z;442 for(G4int j=1; j<nmax; ++j) { 443 G4double e1 = G4AtomicShells::GetBindingEnergy(iz,j); 444 G4int ne = G4AtomicShells::GetNumberOfElectrons(iz,j); 445 norm += ne; 446 eshell += e1*ne; 447 res += f*ne*LShell(e1/e0,eta); 446 448 } 447 if( 10 < iz) {449 if(ntot > nmax) { 448 450 eshell /= norm; 449 451 G4double eeff = eshell*eta; 450 for(G4int k=nmax; k<ntot; k++) {451 G4double x = G4double(shells.GetNumberOfElectrons(iz,k));452 G4double e1 = shells.GetBindingEnergy(iz,k);453 term += f*x*atomDensity[i]*LShell(e1/e0,eeff/e1)/Z;454 // term += f*x*atomDensity[i]*LShell(eshell/e0,eeff/e1)/Z;452 for(G4int k=nmax; k<ntot; ++k) { 453 G4int ne = G4AtomicShells::GetNumberOfElectrons(iz,k); 454 G4double e1 = G4AtomicShells::GetBindingEnergy(iz,k); 455 res += f*ne*LShell(e1/e0,eeff/e1); 456 //res += f*ne*LShell(e1/eshell,eeff/e1); 455 457 } 458 } 456 459 /* 457 460 if(28 >= iz) { 458 term += f*(Z - 10.)*atomDensity[i]*LShell(eshell,HM[iz-11]*eta)/Z;461 res += f*(Z - 10.)*LShell(eshell,HM[iz-11]*eta); 459 462 } else if(32 >= iz) { 460 term += f*18.0*atomDensity[i]*LShell(eshell,HM[iz-11]*eta)/Z;463 res += f*18.0*LShell(eshell,HM[iz-11]*eta); 461 464 } else if(60 >= iz) { 462 term += f*18.0*atomDensity[i]*LShell(eshell,HM[iz-11]*eta)/Z;463 term += f*(Z - 28.)*atomDensity[i]*LShell(eshell,HN[iz-33]*eta)/Z;465 res += f*18.0*LShell(eshell,HM[iz-11]*eta); 466 res += f*(Z - 28.)*LShell(eshell,HN[iz-33]*eta); 464 467 } else { 465 term += f*18.0*atomDensity[i]*LShell(eshell,HM[53]*eta)/Z;466 term += f*32.0*atomDensity[i]*LShell(eshell,HN[30]*eta)/Z;467 term += f*(Z - 60.)*atomDensity[i]*LShell(eshell,150.*eta)/Z;468 res += f*18.0*LShell(eshell,HM[50]*eta); 469 res += f*32.0*LShell(eshell,HN[30]*eta); 470 res += f*(Z - 60.)*LShell(eshell,150.*eta); 468 471 } 469 472 */ 470 471 }472 //term += atomDensity[i]*MSH[iz]/(ba2*ba2);473 } 474 //term += atomDensity[i]*(res/Z + MSH[iz]/(ba2*ba2)); 475 term += res*atomDensity[i]/Z; 473 476 } 474 477 475 478 term /= material->GetTotNbOfAtomsPerVolume(); 479 //if(charge < 0.0) { term = -term; } 476 480 return term; 477 481 } … … 552 556 553 557 BarkasTerm *= 1.29*charge/material->GetTotNbOfAtomsPerVolume(); 558 559 // temporary protection 560 if(charge < -7.0 ) { BarkasTerm *= (-7.0/charge); } 561 554 562 return BarkasTerm; 555 563 } … … 574 582 } while (del > 0.01*term); 575 583 576 return -y2*term; 584 G4double res = -y2*term; 585 // temporary protection 586 if(q2 > 49. && res < -0.2) { res = -0.2; } 587 588 return res; 577 589 } 578 590 … … 808 820 ionList[idx] = ion; 809 821 stopData[idx] = vv; 810 if(verbose>1) G4cout << "End data set " << G4endl;822 if(verbose>1) { G4cout << "End data set " << G4endl; } 811 823 } 812 824 … … 1395 1407 18.2 1396 1408 }; 1397 for(i=0; i<53; i++) {HM[i] = hm[i];}1398 for(i=0; i<31; i++) {HN[i] = hn[i];}1409 for(i=0; i<53; ++i) {HM[i] = hm[i];} 1410 for(i=0; i<31; ++i) {HN[i] = hn[i];} 1399 1411 1400 1412 const G4double mm[93] = { -
trunk/source/processes/electromagnetic/utils/src/G4EmElementSelector.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmElementSelector.cc,v 1.1 1 2009/09/29 11:31:37vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4EmElementSelector.cc,v 1.12 2010/04/27 16:59:52 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 58 58 G4double emin, 59 59 G4double emax, 60 G4bool /*spline*/):60 G4bool spline): 61 61 model(mod), material(mat), nbins(bins), cutEnergy(-1.0), 62 62 lowEnergy(emin), highEnergy(emax) … … 68 68 if(nElmMinusOne > 0) { 69 69 xSections.reserve(n); 70 for(G4int i=0; i<n; ++i) { 71 G4PhysicsLogVector* v = new G4PhysicsLogVector(lowEnergy,highEnergy,nbins); 72 //v->SetSpline(spline); 70 G4PhysicsLogVector* v0 = new G4PhysicsLogVector(lowEnergy,highEnergy,nbins); 71 xSections.push_back(v0); 72 v0->SetSpline(spline); 73 for(G4int i=1; i<n; ++i) { 74 G4PhysicsLogVector* v = new G4PhysicsLogVector(*v0); 75 v->SetSpline(spline); 73 76 xSections.push_back(v); 74 77 } … … 102 105 const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume(); 103 106 104 G4int i;105 106 107 // loop over bins 107 108 for(G4int j=0; j<=nbins; ++j) { … … 110 111 cross = 0.0; 111 112 //G4cout << "j= " << j << " e(MeV)= " << e/MeV << G4endl; 112 for ( i=0; i<=nElmMinusOne; ++i) {113 for (G4int i=0; i<=nElmMinusOne; ++i) { 113 114 cross += theAtomNumDensityVector[i]* 114 115 model->ComputeCrossSectionPerAtom(part, (*theElementVector)[i], e, … … 119 120 120 121 // xSections start from null, so use probabilities from the next bin 121 if( DBL_MIN >= (*xSections[nElmMinusOne])[0]) {122 for ( i=0; i<=nElmMinusOne; ++i) {122 if(0.0 == (*xSections[nElmMinusOne])[0]) { 123 for (G4int i=0; i<=nElmMinusOne; ++i) { 123 124 xSections[i]->PutValue(0, (*xSections[i])[1]); 124 125 } 125 126 } 126 127 // xSections ends with null, so use probabilities from the previous bin 127 if( DBL_MIN >= (*xSections[nElmMinusOne])[nbins]) {128 for ( i=0; i<=nElmMinusOne; ++i) {128 if(0.0 == (*xSections[nElmMinusOne])[nbins]) { 129 for (G4int i=0; i<=nElmMinusOne; ++i) { 129 130 xSections[i]->PutValue(nbins, (*xSections[i])[nbins-1]); 130 131 } … … 134 135 cross = (*xSections[nElmMinusOne])[j]; 135 136 // only for positive X-section 136 if(cross > DBL_MIN) {137 for ( i=0; i<nElmMinusOne; ++i) {137 if(cross > 0.0) { 138 for (G4int i=0; i<nElmMinusOne; ++i) { 138 139 G4double x = (*xSections[i])[j]/cross; 139 140 xSections[i]->PutValue(j, x); -
trunk/source/processes/electromagnetic/utils/src/G4EmModelManager.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmModelManager.cc,v 1. 58 2009/10/29 18:07:08vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4EmModelManager.cc,v 1.60 2010/04/12 18:28:40 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 420 420 size_t idx = 1; 421 421 if(secondaryParticle) { 422 if( secondaryParticle == G4Gamma::Gamma() ) idx = 0;423 else if( secondaryParticle == G4Positron::Positron()) idx = 2;424 } 425 426 if(numOfCouples > theCuts.size()) { theCuts.resize(numOfCouples);}422 if( secondaryParticle == G4Gamma::Gamma() ) { idx = 0; } 423 else if( secondaryParticle == G4Positron::Positron()) { idx = 2; } 424 } 425 426 if(numOfCouples > theCuts.size()) { theCuts.resize(numOfCouples); } 427 427 if(minSubRange < 1.0 && numOfCouples > theSubCuts.size()) { 428 428 theSubCuts.resize(numOfCouples); … … 460 460 G4double tcutmax = 461 461 theCoupleTable->ConvertRangeToEnergy(secondaryParticle,material,rcut); 462 if(tcutmax < subcut) subcut = tcutmax;463 } 464 } 465 462 if(tcutmax < subcut) { subcut = tcutmax; } 463 } 464 } 465 /* 466 466 G4int nm = setOfRegionModels[reg]->NumberOfModels(); 467 467 for(G4int j=0; j<nm; ++j) { 468 468 469 469 G4VEmModel* model = models[setOfRegionModels[reg]->ModelIndex(j)]; 470 471 470 G4double tcutmin = model->MinEnergyCut(particle, couple); 472 471 473 if(cut < tcutmin) cut = tcutmin;474 if(subcut < tcutmin) subcut = tcutmin;472 if(cut < tcutmin) { cut = tcutmin; } 473 if(subcut < tcutmin) { subcut = tcutmin; } 475 474 if(1 < verboseLevel) { 476 475 G4cout << "The model # " << j … … 482 481 } 483 482 } 483 */ 484 484 theCuts[i] = cut; 485 if(minSubRange < 1.0) theSubCuts[i] = subcut;485 if(minSubRange < 1.0) { theSubCuts[i] = subcut; } 486 486 } 487 487 … … 497 497 } 498 498 } 499 if(1 == nn) severalModels = false;499 if(1 == nn) { severalModels = false; } 500 500 501 501 if(1 < verboseLevel) { -
trunk/source/processes/electromagnetic/utils/src/G4EmProcessOptions.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmProcessOptions.cc,v 1.2 7 2009/10/29 19:25:28vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4EmProcessOptions.cc,v 1.28 2010/04/27 16:59:52 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 79 79 { 80 80 theManager->SetLossFluctuations(val); 81 } 82 83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 84 85 void G4EmProcessOptions::SetSubCutoff(G4bool val, const G4Region* r) 86 { 87 theManager->SetSubCutoff(val, r); 88 } 89 90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 91 92 void G4EmProcessOptions::SetIntegral(G4bool val) 93 { 94 theManager->SetIntegral(val); 95 } 96 97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 98 99 void G4EmProcessOptions::SetMinSubRange(G4double val) 100 { 101 theManager->SetMinSubRange(val); 102 } 103 104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 105 106 void G4EmProcessOptions::SetMinEnergy(G4double val) 107 { 108 theManager->SetMinEnergy(val); 109 } 110 111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 112 113 void G4EmProcessOptions::SetMaxEnergy(G4double val) 114 { 115 theManager->SetMaxEnergy(val); 116 } 117 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 119 120 void G4EmProcessOptions::SetMaxEnergyForCSDARange(G4double val) 121 { 122 theManager->SetMaxEnergyForCSDARange(val); 123 } 124 125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 126 127 void G4EmProcessOptions::SetMaxEnergyForMuons(G4double val) 128 { 129 theManager->SetMaxEnergyForMuons(val); 130 } 131 132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 133 134 void G4EmProcessOptions::SetDEDXBinning(G4int val) 135 { 136 theManager->SetDEDXBinning(val); 137 } 138 139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 140 141 void G4EmProcessOptions::SetDEDXBinningForCSDARange(G4int val) 142 { 143 theManager->SetDEDXBinningForCSDARange(val); 144 } 145 146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 147 148 void G4EmProcessOptions::SetLambdaBinning(G4int val) 149 { 150 theManager->SetLambdaBinning(val); 151 } 152 153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 154 155 void G4EmProcessOptions::SetStepFunction(G4double v1, G4double v2) 156 { 157 theManager->SetStepFunction(v1, v2); 158 } 159 160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 161 162 void G4EmProcessOptions::SetRandomStep(G4bool val) 163 { 164 theManager->SetRandomStep(val); 165 } 166 167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 168 169 void G4EmProcessOptions::SetApplyCuts(G4bool val) 170 { 171 const std::vector<G4VEmProcess*>& w = 172 theManager->GetEmProcessVector(); 173 std::vector<G4VEmProcess*>::const_iterator itp; 174 for(itp = w.begin(); itp != w.end(); itp++) { 175 G4VEmProcess* q = *itp; 176 if(q) { q->SetApplyCuts(val); } 177 } 178 } 179 180 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 181 182 void G4EmProcessOptions::SetBuildCSDARange(G4bool val) 183 { 184 theManager->SetBuildCSDARange(val); 185 } 186 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 188 189 void G4EmProcessOptions::SetVerbose(G4int val, const G4String& name) 190 { 191 G4bool all = false; 192 if("all" == name) { all = true; } 193 const std::vector<G4VEnergyLossProcess*>& v = 194 theManager->GetEnergyLossProcessVector(); 195 196 if(all) { 197 theManager->SetVerbose(val); 198 return; 199 } 200 201 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 202 for(itr = v.begin(); itr != v.end(); ++itr) { 203 G4VEnergyLossProcess* p = *itr; 204 if(p) { 205 if (p->GetProcessName() == name) { p->SetVerboseLevel(val); } 206 } 207 } 208 const std::vector<G4VEmProcess*>& w = 209 theManager->GetEmProcessVector(); 210 std::vector<G4VEmProcess*>::const_iterator itp; 211 for(itp = w.begin(); itp != w.end(); itp++) { 212 G4VEmProcess* q = *itp; 213 if(q) { 214 if (q->GetProcessName() == name) { q->SetVerboseLevel(val); } 215 } 216 } 217 const std::vector<G4VMultipleScattering*>& u = 218 theManager->GetMultipleScatteringVector(); 219 std::vector<G4VMultipleScattering*>::const_iterator itm; 220 for(itm = u.begin(); itm != u.end(); itm++) { 221 G4VMultipleScattering* s = *itm; 222 if(s) { 223 if (s->GetProcessName() == name) { s->SetVerboseLevel(val); } 224 } 225 } 226 } 227 228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 229 230 void G4EmProcessOptions::SetLambdaFactor(G4double val) 231 { 81 232 const std::vector<G4VEnergyLossProcess*>& v = 82 233 theManager->GetEnergyLossProcessVector(); … … 84 235 for(itr = v.begin(); itr != v.end(); itr++) { 85 236 G4VEnergyLossProcess* p = *itr; 86 if(p) p->SetLossFluctuations(val); 87 } 88 } 89 90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 91 92 void G4EmProcessOptions::SetSubCutoff(G4bool val, const G4Region* r) 93 { 94 theManager->SetSubCutoff(val); 95 const std::vector<G4VEnergyLossProcess*>& v = 96 theManager->GetEnergyLossProcessVector(); 97 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 98 for(itr = v.begin(); itr != v.end(); itr++) { 99 G4VEnergyLossProcess* p = *itr; 100 if(p) p->ActivateSubCutoff(val, r); 101 } 102 } 103 104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 105 106 void G4EmProcessOptions::SetIntegral(G4bool val) 107 { 108 theManager->SetIntegral(val); 109 const std::vector<G4VEnergyLossProcess*>& v = 110 theManager->GetEnergyLossProcessVector(); 111 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 112 for(itr = v.begin(); itr != v.end(); itr++) { 113 G4VEnergyLossProcess* p = *itr; 114 if(p) p->SetIntegral(val); 115 } 116 } 117 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 119 120 void G4EmProcessOptions::SetMinSubRange(G4double val) 121 { 122 theManager->SetMinSubRange(val); 123 const std::vector<G4VEnergyLossProcess*>& v = 124 theManager->GetEnergyLossProcessVector(); 125 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 126 for(itr = v.begin(); itr != v.end(); itr++) { 127 G4VEnergyLossProcess* p = *itr; 128 if(p) p->SetMinSubRange(val); 129 } 130 } 131 132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 133 134 void G4EmProcessOptions::SetMinEnergy(G4double val) 135 { 136 theManager->SetMinEnergy(val); 137 const std::vector<G4VEnergyLossProcess*>& v = 138 theManager->GetEnergyLossProcessVector(); 139 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 140 for(itr = v.begin(); itr != v.end(); itr++) { 141 G4VEnergyLossProcess* p = *itr; 142 if(p) p->SetMinKinEnergy(val); 143 } 144 const std::vector<G4VEmProcess*>& w = 145 theManager->GetEmProcessVector(); 146 std::vector<G4VEmProcess*>::const_iterator itp; 147 for(itp = w.begin(); itp != w.end(); itp++) { 148 G4VEmProcess* q = *itp; 149 if(q) q->SetMinKinEnergy(val); 150 } 151 const std::vector<G4VMultipleScattering*>& u = 152 theManager->GetMultipleScatteringVector(); 153 std::vector<G4VMultipleScattering*>::const_iterator itm; 154 for(itm = u.begin(); itm != u.end(); itm++) { 155 G4VMultipleScattering* s = *itm; 156 if(s) s->SetMinKinEnergy(val); 157 } 158 } 159 160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 161 162 void G4EmProcessOptions::SetMaxEnergy(G4double val) 163 { 164 theManager->SetMaxEnergy(val); 165 const std::vector<G4VEnergyLossProcess*>& v = 166 theManager->GetEnergyLossProcessVector(); 167 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 168 for(itr = v.begin(); itr != v.end(); itr++) { 169 G4VEnergyLossProcess* p = *itr; 170 if(p) p->SetMaxKinEnergy(val); 171 } 172 const std::vector<G4VEmProcess*>& w = 173 theManager->GetEmProcessVector(); 174 std::vector<G4VEmProcess*>::const_iterator itp; 175 for(itp = w.begin(); itp != w.end(); itp++) { 176 G4VEmProcess* q = *itp; 177 if(q) q->SetMaxKinEnergy(val); 178 } 179 const std::vector<G4VMultipleScattering*>& u = 180 theManager->GetMultipleScatteringVector(); 181 std::vector<G4VMultipleScattering*>::const_iterator itm; 182 for(itm = u.begin(); itm != u.end(); itm++) { 183 G4VMultipleScattering* s = *itm; 184 if(s) s->SetMaxKinEnergy(val); 185 } 186 } 187 188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 189 190 void G4EmProcessOptions::SetMaxEnergyForCSDARange(G4double val) 191 { 192 theManager->SetMaxEnergyForCSDARange(val); 193 const std::vector<G4VEnergyLossProcess*>& v = 194 theManager->GetEnergyLossProcessVector(); 195 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 196 for(itr = v.begin(); itr != v.end(); itr++) { 197 G4VEnergyLossProcess* p = *itr; 198 if(p) p->SetMaxKinEnergyForCSDARange(val); 199 } 200 } 201 202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 203 204 void G4EmProcessOptions::SetMaxEnergyForMuons(G4double val) 205 { 206 theManager->SetMaxEnergyForMuons(val); 237 if(p) { p->SetLambdaFactor(val); } 238 } 239 } 240 241 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 242 243 void G4EmProcessOptions::ActivateDeexcitation(const G4String& pname, 244 G4bool val, 245 const G4String& reg) 246 { 247 G4RegionStore* regionStore = G4RegionStore::GetInstance(); 248 const G4Region* r = 0; 249 if(reg == "" || reg == "World") { 250 r = regionStore->GetRegion("DefaultRegionForTheWorld", false); 251 } else { 252 r = regionStore->GetRegion(reg, false); 253 } 254 if(!r) { 255 G4cout << "G4EmProcessOptions::ActivateDeexcitation ERROR: G4Region <" 256 << reg << "> not found, the command ignored" << G4endl; 257 return; 258 } 259 207 260 const std::vector<G4VEnergyLossProcess*>& v = 208 261 theManager->GetEnergyLossProcessVector(); … … 211 264 G4VEnergyLossProcess* p = *itr; 212 265 if(p) { 213 if(std::abs(p->Particle()->GetPDGMass() - 105.66*MeV) < MeV) 214 p->SetMaxKinEnergy(val); 266 if(pname == p->GetProcessName()) { p->ActivateDeexcitation(val,r); } 215 267 } 216 268 } … … 221 273 G4VEmProcess* q = *itp; 222 274 if(q) { 223 if(std::abs(q->Particle()->GetPDGMass() - 105.66*MeV) < MeV) 224 q->SetMaxKinEnergy(val); 225 } 226 } 227 /* 228 const std::vector<G4VMultipleScattering*>& u = 229 theManager->GetMultipleScatteringVector(); 230 std::vector<G4VMultipleScattering*>::const_iterator itm; 231 for(itm = u.begin(); itm != u.end(); itm++) { 232 G4VMultipleScattering* s = *itm; 233 if(s) { 234 if(std::abs(s->Particle()->GetPDGMass() - 105.66*MeV) < MeV) 235 s->SetMaxKinEnergy(val); 236 } 237 } 238 */ 239 } 240 241 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 242 243 void G4EmProcessOptions::SetDEDXBinning(G4int val) 244 { 245 theManager->SetDEDXBinning(val); 246 const std::vector<G4VEnergyLossProcess*>& v = 247 theManager->GetEnergyLossProcessVector(); 248 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 249 for(itr = v.begin(); itr != v.end(); itr++) { 250 G4VEnergyLossProcess* p = *itr; 251 if(p) p->SetDEDXBinning(val); 252 } 253 } 254 255 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 256 257 void G4EmProcessOptions::SetDEDXBinningForCSDARange(G4int val) 258 { 259 theManager->SetDEDXBinningForCSDARange(val); 260 const std::vector<G4VEnergyLossProcess*>& v = 261 theManager->GetEnergyLossProcessVector(); 262 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 263 for(itr = v.begin(); itr != v.end(); itr++) { 264 G4VEnergyLossProcess* p = *itr; 265 if(p) p->SetDEDXBinningForCSDARange(val); 266 } 267 } 268 269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 270 271 void G4EmProcessOptions::SetLambdaBinning(G4int val) 272 { 273 theManager->SetLambdaBinning(val); 275 if(pname == q->GetProcessName()) { q->ActivateDeexcitation(val,r); } 276 } 277 } 278 } 279 280 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 281 282 void G4EmProcessOptions::SetMscStepLimitation(G4MscStepLimitType val) 283 { 284 const std::vector<G4VMultipleScattering*>& u = 285 theManager->GetMultipleScatteringVector(); 286 std::vector<G4VMultipleScattering*>::const_iterator itm; 287 for(itm = u.begin(); itm != u.end(); itm++) { 288 if(*itm) (*itm)->SetStepLimitType(val); 289 } 290 } 291 292 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 293 294 void G4EmProcessOptions::SetMscLateralDisplacement(G4bool val) 295 { 296 const std::vector<G4VMultipleScattering*>& u = 297 theManager->GetMultipleScatteringVector(); 298 std::vector<G4VMultipleScattering*>::const_iterator itm; 299 for(itm = u.begin(); itm != u.end(); itm++) { 300 if(*itm) { (*itm)->SetLateralDisplasmentFlag(val); } 301 } 302 } 303 304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 305 306 void G4EmProcessOptions::SetSkin(G4double val) 307 { 308 if(val < 0.0) return; 309 const std::vector<G4VMultipleScattering*>& u = 310 theManager->GetMultipleScatteringVector(); 311 std::vector<G4VMultipleScattering*>::const_iterator itm; 312 for(itm = u.begin(); itm != u.end(); itm++) { 313 if(*itm) { (*itm)->SetSkin(val); } 314 } 315 } 316 317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 318 319 void G4EmProcessOptions::SetMscRangeFactor(G4double val) 320 { 321 if(val < 0.0) return; 322 const std::vector<G4VMultipleScattering*>& u = 323 theManager->GetMultipleScatteringVector(); 324 std::vector<G4VMultipleScattering*>::const_iterator itm; 325 for(itm = u.begin(); itm != u.end(); itm++) { 326 if(*itm) { (*itm)->SetRangeFactor(val); } 327 } 328 } 329 330 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 331 332 void G4EmProcessOptions::SetMscGeomFactor(G4double val) 333 { 334 if(val < 0.0) { return; } 335 const std::vector<G4VMultipleScattering*>& u = 336 theManager->GetMultipleScatteringVector(); 337 std::vector<G4VMultipleScattering*>::const_iterator itm; 338 for(itm = u.begin(); itm != u.end(); itm++) { 339 if(*itm) { (*itm)->SetGeomFactor(val); } 340 } 341 } 342 343 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 344 345 void G4EmProcessOptions::SetPolarAngleLimit(G4double val) 346 { 347 const std::vector<G4VMultipleScattering*>& u = 348 theManager->GetMultipleScatteringVector(); 349 std::vector<G4VMultipleScattering*>::const_iterator itm; 350 for(itm = u.begin(); itm != u.end(); itm++) { 351 if(*itm) { (*itm)->SetPolarAngleLimit(val); } 352 } 274 353 const std::vector<G4VEmProcess*>& w = 275 354 theManager->GetEmProcessVector(); … … 277 356 for(itp = w.begin(); itp != w.end(); itp++) { 278 357 G4VEmProcess* q = *itp; 279 if(q) q->SetLambdaBinning(val); 280 } 281 const std::vector<G4VMultipleScattering*>& u = 282 theManager->GetMultipleScatteringVector(); 283 std::vector<G4VMultipleScattering*>::const_iterator itm; 284 for(itm = u.begin(); itm != u.end(); itm++) { 285 G4VMultipleScattering* s = *itm; 286 if(s) s->SetBinning(val); 287 } 288 } 289 290 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 291 292 void G4EmProcessOptions::SetStepFunction(G4double v1, G4double v2) 293 { 294 theManager->SetStepFunction(v1, v2); 295 const std::vector<G4VEnergyLossProcess*>& v = 296 theManager->GetEnergyLossProcessVector(); 297 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 298 for(itr = v.begin(); itr != v.end(); itr++) { 299 G4VEnergyLossProcess* p = *itr; 300 if(p) p->SetStepFunction(v1, v2); 301 } 302 } 303 304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 305 306 void G4EmProcessOptions::SetRandomStep(G4bool val) 307 { 308 theManager->SetRandomStep(val); 309 const std::vector<G4VEnergyLossProcess*>& v = 310 theManager->GetEnergyLossProcessVector(); 311 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 312 for(itr = v.begin(); itr != v.end(); itr++) { 313 G4VEnergyLossProcess* p = *itr; 314 if(p) p->SetRandomStep(val); 315 } 316 } 317 318 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 319 320 void G4EmProcessOptions::SetApplyCuts(G4bool val) 321 { 322 const std::vector<G4VEmProcess*>& w = 323 theManager->GetEmProcessVector(); 324 std::vector<G4VEmProcess*>::const_iterator itp; 325 for(itp = w.begin(); itp != w.end(); itp++) { 326 G4VEmProcess* q = *itp; 327 if(q) q->SetApplyCuts(val); 328 } 329 } 330 331 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 332 333 void G4EmProcessOptions::SetBuildCSDARange(G4bool val) 334 { 335 theManager->SetBuildCSDARange(val); 336 } 337 338 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 339 340 void G4EmProcessOptions::SetVerbose(G4int val, const G4String& name) 341 { 342 G4bool all = false; 343 if("all" == name) all = true; 344 const std::vector<G4VEnergyLossProcess*>& v = 345 theManager->GetEnergyLossProcessVector(); 346 347 if(all) theManager->SetVerbose(val); 348 349 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 350 for(itr = v.begin(); itr != v.end(); itr++) { 351 G4VEnergyLossProcess* p = *itr; 352 if(p) { 353 if(all) p->SetVerboseLevel(val); 354 else if (p->GetProcessName() == name) p->SetVerboseLevel(val); 355 } 356 } 357 const std::vector<G4VEmProcess*>& w = 358 theManager->GetEmProcessVector(); 359 std::vector<G4VEmProcess*>::const_iterator itp; 360 for(itp = w.begin(); itp != w.end(); itp++) { 361 G4VEmProcess* q = *itp; 362 if(q) { 363 if(all) q->SetVerboseLevel(val); 364 else if (q->GetProcessName() == name) q->SetVerboseLevel(val); 365 } 366 } 367 const std::vector<G4VMultipleScattering*>& u = 368 theManager->GetMultipleScatteringVector(); 369 std::vector<G4VMultipleScattering*>::const_iterator itm; 370 for(itm = u.begin(); itm != u.end(); itm++) { 371 G4VMultipleScattering* s = *itm; 372 if(s) { 373 if(all) s->SetVerboseLevel(val); 374 else if (s->GetProcessName() == name) s->SetVerboseLevel(val); 375 } 376 } 377 } 378 379 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 380 381 void G4EmProcessOptions::SetLambdaFactor(G4double val) 382 { 383 const std::vector<G4VEnergyLossProcess*>& v = 384 theManager->GetEnergyLossProcessVector(); 385 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 386 for(itr = v.begin(); itr != v.end(); itr++) { 387 G4VEnergyLossProcess* p = *itr; 388 if(p) p->SetLambdaFactor(val); 389 } 390 391 } 392 393 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 394 395 void G4EmProcessOptions::ActivateDeexcitation(const G4String& pname, 396 G4bool val, 397 const G4String& reg) 398 { 399 G4RegionStore* regionStore = G4RegionStore::GetInstance(); 400 const G4Region* r = 0; 401 if(reg == "" || reg == "World") { 402 r = regionStore->GetRegion("DefaultRegionForTheWorld", false); 403 } else { 404 r = regionStore->GetRegion(reg, false); 405 } 406 if(!r) { 407 G4cout << "G4EmProcessOptions::ActivateDeexcitation ERROR: G4Region <" 408 << reg << "> not found, the command ignored" << G4endl; 409 return; 410 } 411 412 const std::vector<G4VEnergyLossProcess*>& v = 413 theManager->GetEnergyLossProcessVector(); 414 std::vector<G4VEnergyLossProcess*>::const_iterator itr; 415 for(itr = v.begin(); itr != v.end(); itr++) { 416 G4VEnergyLossProcess* p = *itr; 417 if(p) { 418 if(pname == p->GetProcessName()) p->ActivateDeexcitation(val,r); 419 } 420 } 421 const std::vector<G4VEmProcess*>& w = 422 theManager->GetEmProcessVector(); 423 std::vector<G4VEmProcess*>::const_iterator itp; 424 for(itp = w.begin(); itp != w.end(); itp++) { 425 G4VEmProcess* q = *itp; 426 if(q) { 427 if(pname == q->GetProcessName()) q->ActivateDeexcitation(val,r); 428 } 429 } 430 } 431 432 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 433 434 void G4EmProcessOptions::SetMscStepLimitation(G4MscStepLimitType val) 435 { 436 const std::vector<G4VMultipleScattering*>& u = 437 theManager->GetMultipleScatteringVector(); 438 std::vector<G4VMultipleScattering*>::const_iterator itm; 439 for(itm = u.begin(); itm != u.end(); itm++) { 440 if(*itm) (*itm)->SetStepLimitType(val); 441 } 442 } 443 444 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 445 446 void G4EmProcessOptions::SetMscLateralDisplacement(G4bool val) 447 { 448 const std::vector<G4VMultipleScattering*>& u = 449 theManager->GetMultipleScatteringVector(); 450 std::vector<G4VMultipleScattering*>::const_iterator itm; 451 for(itm = u.begin(); itm != u.end(); itm++) { 452 if(*itm) (*itm)->SetLateralDisplasmentFlag(val); 453 } 454 } 455 456 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 457 458 void G4EmProcessOptions::SetSkin(G4double val) 459 { 460 if(val < 0.0) return; 461 const std::vector<G4VMultipleScattering*>& u = 462 theManager->GetMultipleScatteringVector(); 463 std::vector<G4VMultipleScattering*>::const_iterator itm; 464 for(itm = u.begin(); itm != u.end(); itm++) { 465 if(*itm) { 466 (*itm)->SetSkin(val); 467 } 468 } 469 } 470 471 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 472 473 void G4EmProcessOptions::SetMscRangeFactor(G4double val) 474 { 475 if(val < 0.0) return; 476 const std::vector<G4VMultipleScattering*>& u = 477 theManager->GetMultipleScatteringVector(); 478 std::vector<G4VMultipleScattering*>::const_iterator itm; 479 for(itm = u.begin(); itm != u.end(); itm++) { 480 if(*itm) (*itm)->SetRangeFactor(val); 481 } 482 } 483 484 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 485 486 void G4EmProcessOptions::SetMscGeomFactor(G4double val) 487 { 488 if(val < 0.0) return; 489 const std::vector<G4VMultipleScattering*>& u = 490 theManager->GetMultipleScatteringVector(); 491 std::vector<G4VMultipleScattering*>::const_iterator itm; 492 for(itm = u.begin(); itm != u.end(); itm++) { 493 if(*itm) (*itm)->SetGeomFactor(val); 494 } 495 } 496 497 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 498 499 void G4EmProcessOptions::SetPolarAngleLimit(G4double val) 500 { 501 const std::vector<G4VMultipleScattering*>& u = 502 theManager->GetMultipleScatteringVector(); 503 std::vector<G4VMultipleScattering*>::const_iterator itm; 504 for(itm = u.begin(); itm != u.end(); itm++) { 505 if(*itm) (*itm)->SetPolarAngleLimit(val); 506 } 507 const std::vector<G4VEmProcess*>& w = 508 theManager->GetEmProcessVector(); 509 std::vector<G4VEmProcess*>::const_iterator itp; 510 for(itp = w.begin(); itp != w.end(); itp++) { 511 G4VEmProcess* q = *itp; 512 if(q) q->SetPolarAngleLimit(val); 358 if(q) { q->SetPolarAngleLimit(val); } 513 359 } 514 360 } -
trunk/source/processes/electromagnetic/utils/src/G4LossTableManager.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4LossTableManager.cc,v 1. 97 2009/10/29 19:25:28vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4LossTableManager.cc,v 1.101 2010/06/04 15:33:56 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 70 70 // 12-02-07 Add SetSkin, SetLinearLossLimit (V.Ivanchenko) 71 71 // 18-06-07 Move definition of msc parameters to G4EmProcessOptions (V.Ivanchenko) 72 // 21-02-08 Add G4EmSaturation (V.Ivanchenko) 72 // 21-02-08 Added G4EmSaturation (V.Ivanchenko) 73 // 12-04-10 Added PreparePhsyicsTables and BuildPhysicsTables entries (V.Ivanchenko) 73 74 // 74 75 // Class Description: … … 96 97 #include "G4EmTableType.hh" 97 98 #include "G4LossTableBuilder.hh" 99 #include "G4Region.hh" 98 100 99 101 G4LossTableManager* G4LossTableManager::theInstance = 0; … … 114 116 G4LossTableManager::~G4LossTableManager() 115 117 { 116 for (G4int i=0; i<n_loss; i++) {117 if( loss_vector[i] ) delete loss_vector[i];118 for (G4int i=0; i<n_loss; ++i) { 119 if( loss_vector[i] ) { delete loss_vector[i]; } 118 120 } 119 121 size_t msc = msc_vector.size(); 120 for (size_t j=0; j<msc; j++) {121 if( msc_vector[j] ) delete msc_vector[j];122 for (size_t j=0; j<msc; ++j) { 123 if( msc_vector[j] ) { delete msc_vector[j]; } 122 124 } 123 125 size_t emp = emp_vector.size(); 124 for (size_t k=0; k<emp; k++) {125 if( emp_vector[k] ) delete emp_vector[k];126 for (size_t k=0; k<emp; ++k) { 127 if( emp_vector[k] ) { delete emp_vector[k]; } 126 128 } 127 129 size_t mod = mod_vector.size(); 128 for (size_t a=0; a<mod; a++) {129 if( mod_vector[a] ) delete mod_vector[a];130 for (size_t a=0; a<mod; ++a) { 131 if( mod_vector[a] ) { delete mod_vector[a]; } 130 132 } 131 133 size_t fmod = fmod_vector.size(); 132 for (size_t b=0; b<fmod; b++) {133 if( fmod_vector[b] ) delete fmod_vector[b];134 for (size_t b=0; b<fmod; ++b) { 135 if( fmod_vector[b] ) { delete fmod_vector[b]; } 134 136 } 135 137 Clear(); … … 146 148 n_loss = 0; 147 149 run = 0; 148 // first_entry = true;150 startInitialisation = false; 149 151 all_tables_are_built = false; 150 all_tables_are_stored = false;151 152 currentLoss = 0; 152 153 currentParticle = 0; 154 firstParticle = 0; 153 155 lossFluctuationFlag = true; 154 156 subCutoffFlag = false; … … 158 160 maxFinalStep = 0.0; 159 161 minKinEnergy = 0.1*keV; 160 maxKinEnergy = 100.0*TeV; 161 maxKinEnergyForMuons = 100.*TeV; 162 theMessenger = new G4EnergyLossMessenger(); 163 theElectron = G4Electron::Electron(); 164 tableBuilder = new G4LossTableBuilder(); 165 emCorrections= new G4EmCorrections(); 166 emSaturation = new G4EmSaturation(); 167 emConfigurator = new G4EmConfigurator(); 162 maxKinEnergy = 10.0*TeV; 163 nbinsLambda = 77; 164 nbinsPerDecade = 7; 165 maxKinEnergyForMuons = 10.*TeV; 168 166 integral = true; 169 167 integralActive = false; … … 178 176 factorForAngleLimit = 1.0; 179 177 verbose = 1; 178 theMessenger = new G4EnergyLossMessenger(); 179 theElectron = G4Electron::Electron(); 180 tableBuilder = new G4LossTableBuilder(); 181 emCorrections= new G4EmCorrections(); 182 emSaturation = new G4EmSaturation(); 183 emConfigurator = new G4EmConfigurator(verbose); 180 184 tableBuilder->SetSplineFlag(splineFlag); 181 185 } … … 207 211 void G4LossTableManager::Register(G4VEnergyLossProcess* p) 208 212 { 209 n_loss++;213 ++n_loss; 210 214 loss_vector.push_back(p); 211 215 part_vector.push_back(0); … … 217 221 isActive.push_back(true); 218 222 all_tables_are_built = false; 219 if(!lossFluctuationFlag) p->SetLossFluctuations(false);220 if(subCutoffFlag) p->ActivateSubCutoff(true);221 if(rndmStepFlag) p->SetRandomStep(true);222 if(stepFunctionActive) p->SetStepFunction(maxRangeVariation, maxFinalStep);223 if(integralActive) p->SetIntegral(integral);224 if(minEnergyActive) p->SetMinKinEnergy(minKinEnergy);225 if(maxEnergyActive) p->SetMaxKinEnergy(maxKinEnergy);223 if(!lossFluctuationFlag) { p->SetLossFluctuations(false); } 224 if(subCutoffFlag) { p->ActivateSubCutoff(true); } 225 if(rndmStepFlag) { p->SetRandomStep(true); } 226 if(stepFunctionActive) { p->SetStepFunction(maxRangeVariation, maxFinalStep); } 227 if(integralActive) { p->SetIntegral(integral); } 228 if(minEnergyActive) { p->SetMinKinEnergy(minKinEnergy); } 229 if(maxEnergyActive) { p->SetMaxKinEnergy(maxKinEnergy); } 226 230 if(verbose > 1) 227 231 G4cout << "G4LossTableManager::Register G4VEnergyLossProcess : " … … 233 237 void G4LossTableManager::DeRegister(G4VEnergyLossProcess* p) 234 238 { 235 for (G4int i=0; i<n_loss; i++) {236 if(loss_vector[i] == p) loss_vector[i] = 0;239 for (G4int i=0; i<n_loss; ++i) { 240 if(loss_vector[i] == p) { loss_vector[i] = 0; } 237 241 } 238 242 } … … 254 258 { 255 259 size_t msc = msc_vector.size(); 256 for (size_t i=0; i<msc; i++) {257 if(msc_vector[i] == p) msc_vector[i] = 0;260 for (size_t i=0; i<msc; ++i) { 261 if(msc_vector[i] == p) { msc_vector[i] = 0; } 258 262 } 259 263 } … … 275 279 { 276 280 size_t emp = emp_vector.size(); 277 for (size_t i=0; i<emp; i++) {278 if(emp_vector[i] == p) emp_vector[i] = 0;281 for (size_t i=0; i<emp; ++i) { 282 if(emp_vector[i] == p) { emp_vector[i] = 0; } 279 283 } 280 284 } … … 296 300 { 297 301 size_t n = mod_vector.size(); 298 for (size_t i=0; i<n; i++) {299 if(mod_vector[i] == p) mod_vector[i] = 0;302 for (size_t i=0; i<n; ++i) { 303 if(mod_vector[i] == p) { mod_vector[i] = 0; } 300 304 } 301 305 } … … 317 321 { 318 322 size_t n = fmod_vector.size(); 319 for (size_t i=0; i<n; i++) {320 if(fmod_vector[i] == p) fmod_vector[i] = 0;323 for (size_t i=0; i<n; ++i) { 324 if(fmod_vector[i] == p) { fmod_vector[i] = 0; } 321 325 } 322 326 } … … 336 340 G4VEnergyLossProcess* p) 337 341 { 338 n_loss++;342 ++n_loss; 339 343 loss_vector.push_back(p); 340 344 part_vector.push_back(part); … … 349 353 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 350 354 351 void G4LossTableManager::EnergyLossProcessIsInitialised( 352 const G4ParticleDefinition* particle, 353 G4VEnergyLossProcess* p) 354 { 355 if (run == 0 || (particle == firstParticle && all_tables_are_built) ) { 355 void 356 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle, 357 G4VEnergyLossProcess* p) 358 { 359 if (1 < verbose) { 360 G4cout << "G4LossTableManager::PreparePhysicsTable for " 361 << particle->GetParticleName() 362 << " and " << p->GetProcessName() << " run= " << run << G4endl; 363 } 364 // start initialisation for the first run 365 startInitialisation = true; 366 367 if( 0 == run ) { 368 emConfigurator->PrepareModels(particle, p); 369 370 // initialise particles for given process 371 for (G4int j=0; j<n_loss; ++j) { 372 if (p == loss_vector[j]) { 373 if (!part_vector[j]) { part_vector[j] = particle; } 374 } 375 } 376 } 377 } 378 379 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 380 381 void 382 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle, 383 G4VEmProcess* p) 384 { 385 if (1 < verbose) { 386 G4cout << "G4LossTableManager::PreparePhysicsTable for " 387 << particle->GetParticleName() 388 << " and " << p->GetProcessName() << G4endl; 389 } 390 // start initialisation for the first run 391 if( 0 == run ) { 392 emConfigurator->PrepareModels(particle, p); 393 } 394 startInitialisation = true; 395 } 396 397 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 398 399 void 400 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle, 401 G4VMultipleScattering* p) 402 { 403 if (1 < verbose) { 404 G4cout << "G4LossTableManager::PreparePhysicsTable for " 405 << particle->GetParticleName() 406 << " and " << p->GetProcessName() << G4endl; 407 } 408 // start initialisation for the first run 409 if( 0 == run ) { 410 emConfigurator->PrepareModels(particle, p); 411 } 412 } 413 414 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 415 416 void 417 G4LossTableManager::BuildPhysicsTable(const G4ParticleDefinition*) 418 { 419 if(0 == run && startInitialisation) { 420 emConfigurator->Clear(); 421 } 422 } 423 424 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 425 426 void G4LossTableManager::BuildPhysicsTable( 427 const G4ParticleDefinition* aParticle, 428 G4VEnergyLossProcess* p) 429 { 430 if(1 < verbose) { 431 G4cout << "### G4LossTableManager::BuildDEDXTable() is requested for " 432 << aParticle->GetParticleName() 433 << " and process " << p->GetProcessName() 434 << G4endl; 435 } 436 // clear configurator 437 if(0 == run && startInitialisation) { 438 emConfigurator->Clear(); 439 firstParticle = aParticle; 440 } 441 startInitialisation = false; 442 443 // initialisation before any table is built 444 if ( aParticle == firstParticle ) { 356 445 all_tables_are_built = true; 357 446 358 if(1 < verbose) 359 G4cout << "### G4LossTableManager start initilisation of tables" 447 if(1 < verbose) { 448 G4cout << "### G4LossTableManager start initilisation for first particle " 449 << firstParticle->GetParticleName() 360 450 << G4endl; 361 for (G4int i=0; i<n_loss; i++) { 451 } 452 for (G4int i=0; i<n_loss; ++i) { 362 453 G4VEnergyLossProcess* el = loss_vector[i]; 363 454 … … 365 456 const G4ProcessManager* pm = el->GetProcessManager(); 366 457 isActive[i] = pm->GetProcessActivation(el); 458 if(0 == run) { base_part_vector[i] = el->BaseParticle(); } 367 459 tables_are_built[i] = false; 368 all_tables_are_built 369 if(!isActive[i]) el->SetIonisation(false);460 all_tables_are_built= false; 461 if(!isActive[i]) { el->SetIonisation(false); } 370 462 371 463 if(1 < verbose) { … … 374 466 << " active= " << pm->GetProcessActivation(el) 375 467 << " table= " << tables_are_built[i] 376 << " isIonisation= " << el->IsIonisationProcess() 377 << G4endl; 468 << " isIonisation= " << el->IsIonisationProcess(); 469 if(base_part_vector[i]) { 470 G4cout << " base particle " << base_part_vector[i]->GetParticleName(); 471 } 472 G4cout << G4endl; 378 473 } 379 474 } else { … … 382 477 } 383 478 } 384 if (0 == run) firstParticle = particle; 385 run++; 386 } 387 388 currentParticle = 0; 389 390 SetParameters(p); 391 for (G4int j=0; j<n_loss; j++) { 392 if (p == loss_vector[j]) { 393 394 if (!part_vector[j]) { 395 part_vector[j] = particle; 396 base_part_vector[j] = p->BaseParticle(); 479 ++run; 480 currentParticle = 0; 481 } 482 483 // Set run time parameters 484 SetParameters(aParticle, p); 485 486 if (all_tables_are_built) { return; } 487 488 // Build tables for given particle 489 all_tables_are_built = true; 490 491 for(G4int i=0; i<n_loss; ++i) { 492 if(p == loss_vector[i] && !tables_are_built[i] && !base_part_vector[i]) { 493 const G4ParticleDefinition* curr_part = part_vector[i]; 494 if(1 < verbose) { 495 G4cout << "### BuildPhysicsTable for " << p->GetProcessName() 496 << " and " << curr_part->GetParticleName() 497 << " start BuildTable " << G4endl; 397 498 } 398 if(maxEnergyForMuonsActive) {399 G4double dm = std::abs(particle->GetPDGMass() - 105.7*MeV);400 if(dm < 5.*MeV) p->SetMaxKinEnergy(maxKinEnergyForMuons);401 }402 403 if(1 < verbose) {404 G4cout << "For " << p->GetProcessName()405 << " for " << part_vector[j]->GetParticleName()406 << " tables_are_built= " << tables_are_built[j]407 << " procFlag= " << loss_vector[j]->TablesAreBuilt()408 << " all_tables_are_built= " << all_tables_are_built409 << G4endl;410 }411 }412 }413 }414 415 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....416 417 G4EnergyLossMessenger* G4LossTableManager::GetMessenger()418 {419 return theMessenger;420 }421 422 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....423 424 void G4LossTableManager::ParticleHaveNoLoss(425 const G4ParticleDefinition* aParticle)426 {427 G4String s = " dE/dx table not found for "428 + aParticle->GetParticleName() + " !";429 G4Exception("G4LossTableManager::ParticleHaveNoLoss", "EM01",430 FatalException, s);431 432 }433 434 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....435 436 G4bool G4LossTableManager::BuildCSDARange() const437 {438 return buildCSDARange;439 }440 441 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....442 443 void G4LossTableManager::BuildPhysicsTable(444 const G4ParticleDefinition* aParticle,445 G4VEnergyLossProcess* p)446 {447 if(1 < verbose) {448 G4cout << "### G4LossTableManager::BuildDEDXTable() is requested for "449 << aParticle->GetParticleName()450 << " and process " << p->GetProcessName()451 << G4endl;452 }453 if (all_tables_are_built) return;454 all_tables_are_built = true;455 456 for(G4int i=0; i<n_loss; i++) {457 if(!tables_are_built[i] && !base_part_vector[i]) {458 const G4ParticleDefinition* curr_part = part_vector[i];459 499 G4VEnergyLossProcess* curr_proc = BuildTables(curr_part); 460 if(curr_proc) CopyTables(curr_part, curr_proc); 461 } 462 } 463 464 for (G4int ii=0; ii<n_loss; ii++) { 465 if ( !tables_are_built[ii] ) { 466 all_tables_are_built = false; 467 break; 468 } 500 if(curr_proc) { CopyTables(curr_part, curr_proc); } 501 } 502 if ( !tables_are_built[i] ) { all_tables_are_built = false; } 469 503 } 470 504 … … 473 507 << "all_tables_are_built= " << all_tables_are_built 474 508 << G4endl; 475 476 if(all_tables_are_built) 509 510 if(all_tables_are_built) { 477 511 G4cout << "### All dEdx and Range tables are built #####" << G4endl; 512 } 478 513 } 479 514 } … … 484 519 G4VEnergyLossProcess* base_proc) 485 520 { 486 for (G4int j=0; j<n_loss; j++) {521 for (G4int j=0; j<n_loss; ++j) { 487 522 488 523 G4VEnergyLossProcess* proc = loss_vector[j]; 489 if(proc == base_proc || proc->Particle() == part)490 tables_are_built[j] = true;524 //if(proc == base_proc || proc->Particle() == part) 525 // tables_are_built[j] = true; 491 526 492 527 if (!tables_are_built[j] && part == base_part_vector[j]) { … … 511 546 } 512 547 513 if (theElectron == part && theElectron == proc->SecondaryParticle() ) 548 if (theElectron == part && theElectron == proc->SecondaryParticle() ) { 514 549 proc->SetSecondaryRangeTable(base_proc->RangeTableForLoss()); 550 } 515 551 } 516 552 } … … 535 571 G4int i; 536 572 537 for (i=0; i<n_loss; i++) {573 for (i=0; i<n_loss; ++i) { 538 574 p = loss_vector[i]; 539 575 if (p && aParticle == part_vector[i] && !tables_are_built[i]) { … … 602 638 std::vector<G4PhysicsTable*> listCSDA; 603 639 604 for (i=0; i<n_dedx; i++) {640 for (i=0; i<n_dedx; ++i) { 605 641 p = loss_list[i]; 606 642 p->SetIonisation(false); … … 658 694 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 659 695 696 G4EnergyLossMessenger* G4LossTableManager::GetMessenger() 697 { 698 return theMessenger; 699 } 700 701 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 702 703 void G4LossTableManager::ParticleHaveNoLoss( 704 const G4ParticleDefinition* aParticle) 705 { 706 G4String s = " dE/dx table not found for " 707 + aParticle->GetParticleName() + " !"; 708 G4Exception("G4LossTableManager::ParticleHaveNoLoss", "EM01", 709 FatalException, s); 710 711 } 712 713 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 714 715 G4bool G4LossTableManager::BuildCSDARange() const 716 { 717 return buildCSDARange; 718 } 719 720 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 721 660 722 void G4LossTableManager::SetLossFluctuations(G4bool val) 661 723 { 662 724 lossFluctuationFlag = val; 663 for(G4int i=0; i<n_loss; i++) {664 if(loss_vector[i]) loss_vector[i]->SetLossFluctuations(val);665 } 666 } 667 668 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 669 670 void G4LossTableManager::SetSubCutoff(G4bool val )725 for(G4int i=0; i<n_loss; ++i) { 726 if(loss_vector[i]) { loss_vector[i]->SetLossFluctuations(val); } 727 } 728 } 729 730 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 731 732 void G4LossTableManager::SetSubCutoff(G4bool val, const G4Region* r) 671 733 { 672 734 subCutoffFlag = val; 673 for(G4int i=0; i<n_loss; i++) {674 if(loss_vector[i]) loss_vector[i]->ActivateSubCutoff(val);735 for(G4int i=0; i<n_loss; ++i) { 736 if(loss_vector[i]) { loss_vector[i]->ActivateSubCutoff(val, r); } 675 737 } 676 738 } … … 682 744 integral = val; 683 745 integralActive = true; 684 for(G4int i=0; i<n_loss; i++) {685 if(loss_vector[i]) loss_vector[i]->SetIntegral(val);746 for(G4int i=0; i<n_loss; ++i) { 747 if(loss_vector[i]) { loss_vector[i]->SetIntegral(val); } 686 748 } 687 749 size_t emp = emp_vector.size(); 688 for (size_t k=0; k<emp; k++) {689 if(emp_vector[k]) emp_vector[k]->SetIntegral(val);750 for (size_t k=0; k<emp; ++k) { 751 if(emp_vector[k]) { emp_vector[k]->SetIntegral(val); } 690 752 } 691 753 } … … 696 758 { 697 759 minSubRange = val; 698 for(G4int i=0; i<n_loss; i++) {699 if(loss_vector[i]) loss_vector[i]->SetMinSubRange(val);760 for(G4int i=0; i<n_loss; ++i) { 761 if(loss_vector[i]) { loss_vector[i]->SetMinSubRange(val); } 700 762 } 701 763 } … … 706 768 { 707 769 rndmStepFlag = val; 708 for(G4int i=0; i<n_loss; i++) {709 if(loss_vector[i]) loss_vector[i]->SetRandomStep(val);770 for(G4int i=0; i<n_loss; ++i) { 771 if(loss_vector[i]) { loss_vector[i]->SetRandomStep(val); } 710 772 } 711 773 } … … 717 779 minEnergyActive = true; 718 780 minKinEnergy = val; 719 for(G4int i=0; i<n_loss; i++) {720 if(loss_vector[i]) loss_vector[i]->SetMinKinEnergy(val);781 for(G4int i=0; i<n_loss; ++i) { 782 if(loss_vector[i]) { loss_vector[i]->SetMinKinEnergy(val); } 721 783 } 722 784 size_t msc = msc_vector.size(); 723 for (size_t j=0; j<msc; j++) {724 if(msc_vector[j]) msc_vector[j]->SetMinKinEnergy(val);785 for (size_t j=0; j<msc; ++j) { 786 if(msc_vector[j]) { msc_vector[j]->SetMinKinEnergy(val); } 725 787 } 726 788 size_t emp = emp_vector.size(); 727 for (size_t k=0; k<emp; k++) {728 if(emp_vector[k]) emp_vector[k]->SetMinKinEnergy(val);789 for (size_t k=0; k<emp; ++k) { 790 if(emp_vector[k]) { emp_vector[k]->SetMinKinEnergy(val); } 729 791 } 730 792 } … … 736 798 maxEnergyActive = true; 737 799 maxKinEnergy = val; 738 for(G4int i=0; i<n_loss; i++) {739 if(loss_vector[i]) loss_vector[i]->SetMaxKinEnergy(val);800 for(G4int i=0; i<n_loss; ++i) { 801 if(loss_vector[i]) { loss_vector[i]->SetMaxKinEnergy(val); } 740 802 } 741 803 size_t msc = msc_vector.size(); 742 for (size_t j=0; j<msc; j++) {743 if(msc_vector[j]) msc_vector[j]->SetMaxKinEnergy(val);804 for (size_t j=0; j<msc; ++j) { 805 if(msc_vector[j]) { msc_vector[j]->SetMaxKinEnergy(val); } 744 806 } 745 807 size_t emp = emp_vector.size(); 746 for (size_t k=0; k<emp; k++) {747 if(emp_vector[k]) emp_vector[k]->SetMaxKinEnergy(val);808 for (size_t k=0; k<emp; ++k) { 809 if(emp_vector[k]) { emp_vector[k]->SetMaxKinEnergy(val); } 748 810 } 749 811 } … … 753 815 void G4LossTableManager::SetMaxEnergyForCSDARange(G4double val) 754 816 { 755 for(G4int i=0; i<n_loss; i++) {756 if(loss_vector[i]) loss_vector[i]->SetMaxKinEnergyForCSDARange(val);817 for(G4int i=0; i<n_loss; ++i) { 818 if(loss_vector[i]) { loss_vector[i]->SetMaxKinEnergyForCSDARange(val); } 757 819 } 758 820 } … … 770 832 void G4LossTableManager::SetDEDXBinning(G4int val) 771 833 { 772 for(G4int i=0; i<n_loss; i++) {773 if(loss_vector[i]) loss_vector[i]->SetDEDXBinning(val);834 for(G4int i=0; i<n_loss; ++i) { 835 if(loss_vector[i]) { loss_vector[i]->SetDEDXBinning(val); } 774 836 } 775 837 } … … 779 841 void G4LossTableManager::SetDEDXBinningForCSDARange(G4int val) 780 842 { 781 for(G4int i=0; i<n_loss; i++) {782 if(loss_vector[i]) loss_vector[i]->SetDEDXBinningForCSDARange(val);843 for(G4int i=0; i<n_loss; ++i) { 844 if(loss_vector[i]) { loss_vector[i]->SetDEDXBinningForCSDARange(val); } 783 845 } 784 846 } … … 788 850 void G4LossTableManager::SetLambdaBinning(G4int val) 789 851 { 852 G4int n = val/G4int(std::log10(maxKinEnergy/minKinEnergy)); 853 if(n < 5) { 854 G4cout << "G4LossTableManager::SetLambdaBinning WARNING " 855 << "too small number of bins " << val << " ignored" 856 << G4endl; 857 return; 858 } 859 nbinsLambda = val; 860 nbinsPerDecade = n; 790 861 size_t msc = msc_vector.size(); 791 for (size_t j=0; j<msc; j++) {792 if(msc_vector[j]) msc_vector[j]->SetBinning(val);862 for (size_t j=0; j<msc; ++j) { 863 if(msc_vector[j]) { msc_vector[j]->SetBinning(val); } 793 864 } 794 865 size_t emp = emp_vector.size(); 795 for (size_t k=0; k<emp; k++) { 796 if(emp_vector[k]) emp_vector[k]->SetLambdaBinning(val); 797 } 866 for (size_t k=0; k<emp; ++k) { 867 if(emp_vector[k]) { emp_vector[k]->SetLambdaBinning(val); } 868 } 869 } 870 871 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 872 873 G4int G4LossTableManager::GetNumberOfBinsPerDecade() const 874 { 875 return nbinsPerDecade; 798 876 } 799 877 … … 803 881 { 804 882 verbose = val; 805 for(G4int i=0; i<n_loss; i++) {806 if(loss_vector[i]) loss_vector[i]->SetVerboseLevel(val);883 for(G4int i=0; i<n_loss; ++i) { 884 if(loss_vector[i]) { loss_vector[i]->SetVerboseLevel(val); } 807 885 } 808 886 size_t msc = msc_vector.size(); 809 for (size_t j=0; j<msc; j++) {810 if(msc_vector[j]) msc_vector[j]->SetVerboseLevel(val);887 for (size_t j=0; j<msc; ++j) { 888 if(msc_vector[j]) { msc_vector[j]->SetVerboseLevel(val); } 811 889 } 812 890 size_t emp = emp_vector.size(); 813 for (size_t k=0; k<emp; k++) { 814 if(emp_vector[k]) emp_vector[k]->SetVerboseLevel(val); 815 } 891 for (size_t k=0; k<emp; ++k) { 892 if(emp_vector[k]) { emp_vector[k]->SetVerboseLevel(val); } 893 } 894 emConfigurator->SetVerbose(val); 895 //tableBuilder->SetVerbose(val); 896 //emCorrections->SetVerbose(val); 897 emSaturation->SetVerbose(val); 816 898 } 817 899 … … 823 905 maxRangeVariation = v1; 824 906 maxFinalStep = v2; 825 for(G4int i=0; i<n_loss; i++) {826 if(loss_vector[i]) loss_vector[i]->SetStepFunction(v1, v2);907 for(G4int i=0; i<n_loss; ++i) { 908 if(loss_vector[i]) { loss_vector[i]->SetStepFunction(v1, v2); } 827 909 } 828 910 } … … 832 914 void G4LossTableManager::SetLinearLossLimit(G4double val) 833 915 { 834 for(G4int i=0; i<n_loss; i++) {835 if(loss_vector[i]) loss_vector[i]->SetLinearLossLimit(val);916 for(G4int i=0; i<n_loss; ++i) { 917 if(loss_vector[i]) { loss_vector[i]->SetLinearLossLimit(val); } 836 918 } 837 919 } … … 846 928 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 847 929 848 void G4LossTableManager::SetParameters(G4VEnergyLossProcess* p) 849 { 850 if(stepFunctionActive) p->SetStepFunction(maxRangeVariation, maxFinalStep); 851 if(integralActive) p->SetIntegral(integral); 852 if(minEnergyActive) p->SetMinKinEnergy(minKinEnergy); 853 if(maxEnergyActive) p->SetMaxKinEnergy(maxKinEnergy); 930 void 931 G4LossTableManager::SetParameters(const G4ParticleDefinition* aParticle, 932 G4VEnergyLossProcess* p) 933 { 934 if(stepFunctionActive) { p->SetStepFunction(maxRangeVariation, maxFinalStep); } 935 if(integralActive) { p->SetIntegral(integral); } 936 if(minEnergyActive) { p->SetMinKinEnergy(minKinEnergy); } 937 if(maxEnergyActive) { p->SetMaxKinEnergy(maxKinEnergy); } 854 938 p->SetVerboseLevel(verbose); 939 if(maxEnergyForMuonsActive) { 940 G4double dm = std::abs(aParticle->GetPDGMass() - 105.7*MeV); 941 if(dm < 5.*MeV) { p->SetMaxKinEnergy(maxKinEnergyForMuons); } 942 } 855 943 } 856 944 … … 858 946 859 947 const std::vector<G4VEnergyLossProcess*>& 860 948 G4LossTableManager::GetEnergyLossProcessVector() 861 949 { 862 950 return loss_vector; … … 873 961 874 962 const std::vector<G4VMultipleScattering*>& 875 963 G4LossTableManager::GetMultipleScatteringVector() 876 964 { 877 965 return msc_vector; … … 925 1013 void G4LossTableManager::SetFactorForAngleLimit(G4double val) 926 1014 { 927 if(val > 0.0) factorForAngleLimit = val;1015 if(val > 0.0) { factorForAngleLimit = val; } 928 1016 } 929 1017 -
trunk/source/processes/electromagnetic/utils/src/G4VEmModel.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VEmModel.cc,v 1.3 0 2009/09/23 14:42:47vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VEmModel.cc,v 1.35 2010/05/26 18:06:25 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 80 80 G4int n = elmSelectors.size(); 81 81 if(n > 0) { 82 for(G4int i=0; i<n; i++) {82 for(G4int i=0; i<n; ++i) { 83 83 delete elmSelectors[i]; 84 84 } … … 121 121 // initialise before run 122 122 flagDeexcitation = false; 123 124 G4int nbins = G4int(std::log10(highLimit/lowLimit) + 0.5); 125 if(nbins < 3) nbins = 3; 126 G4bool spline = G4LossTableManager::Instance()->SplineFlag(); 123 G4LossTableManager* man = G4LossTableManager::Instance(); 124 G4bool spline = man->SplineFlag(); 125 126 // two times less bins because probability functon is normalized 127 // so correspondingly is more smooth 128 G4int nbins = (man->GetNumberOfBinsPerDecade()/3)* 129 G4int(std::log10(highLimit/lowLimit) + 0.5); 130 if(nbins < 5) { nbins = 5; } 127 131 128 132 G4ProductionCutsTable* theCoupleTable= … … 131 135 132 136 // prepare vector 133 if(numOfCouples > nSelectors) elmSelectors.reserve(numOfCouples); 137 if(numOfCouples > nSelectors) { 138 elmSelectors.reserve(numOfCouples); 139 for(G4int i=nSelectors; i<numOfCouples; ++i) { elmSelectors.push_back(0); } 140 nSelectors = numOfCouples; 141 } 134 142 135 143 // initialise vector 136 for(G4int i=0; i<numOfCouples; i++) {144 for(G4int i=0; i<numOfCouples; ++i) { 137 145 currentCouple = theCoupleTable->GetMaterialCutsCouple(i); 138 146 const G4Material* material = currentCouple->GetMaterial(); … … 141 149 // selector already exist check if should be deleted 142 150 G4bool create = true; 143 if(i < nSelectors) { 144 if(elmSelectors[i]) { 145 if(material == elmSelectors[i]->GetMaterial()) create = false; 146 else delete elmSelectors[i]; 147 } 148 } else { 149 nSelectors++; 150 elmSelectors.push_back(0); 151 if(elmSelectors[i]) { 152 if(material == elmSelectors[i]->GetMaterial()) { create = false; } 153 else { delete elmSelectors[i]; } 151 154 } 152 155 if(create) { … … 195 198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 196 199 200 const G4Element* G4VEmModel::SelectRandomAtom(const G4Material* material, 201 const G4ParticleDefinition* pd, 202 G4double kinEnergy, 203 G4double tcut, 204 G4double tmax) 205 { 206 const G4ElementVector* theElementVector = material->GetElementVector(); 207 G4int n = material->GetNumberOfElements() - 1; 208 currentElement = (*theElementVector)[n]; 209 if (n > 0) { 210 G4double x = G4UniformRand()* 211 G4VEmModel::CrossSectionPerVolume(material,pd,kinEnergy,tcut,tmax); 212 for(G4int i=0; i<n; ++i) { 213 if (x <= xsec[i]) { 214 currentElement = (*theElementVector)[i]; 215 break; 216 } 217 } 218 } 219 return currentElement; 220 } 221 222 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 223 197 224 G4double G4VEmModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition*, 198 225 G4double, G4double, G4double, … … 217 244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 218 245 246 G4double G4VEmModel::ChargeSquareRatio(const G4Track& track) 247 { 248 return GetChargeSquareRatio(track.GetDefinition(), 249 track.GetMaterial(), track.GetKineticEnergy()); 250 } 251 252 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 253 219 254 G4double G4VEmModel::GetChargeSquareRatio(const G4ParticleDefinition* p, 220 255 const G4Material*, G4double) -
trunk/source/processes/electromagnetic/utils/src/G4VEmProcess.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VEmProcess.cc,v 1. 79 2009/11/10 20:30:55vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VEmProcess.cc,v 1.87 2010/05/10 13:35:32 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 53 53 // 27-10-07 Virtual functions moved to source (V.Ivanchenko) 54 54 // 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko) 55 // 17-02-10 Added pointer currentParticle (VI) 55 56 // 56 57 // Class Description: … … 98 99 currentModel(0), 99 100 particle(0), 101 currentParticle(0), 100 102 currentCouple(0) 101 103 { … … 165 167 G4VEmFluctuationModel* fm = 0; 166 168 modelManager->AddEmModel(order, p, fm, region); 167 if(p) p->SetParticleChange(pParticleChange);169 if(p) { p->SetParticleChange(pParticleChange); } 168 170 } 169 171 … … 205 207 void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part) 206 208 { 207 if(!particle) particle = ∂209 if(!particle) { SetParticle(&part); } 208 210 if(1 < verboseLevel) { 209 211 G4cout << "G4VEmProcess::PreparePhysicsTable() for " … … 214 216 } 215 217 216 (G4LossTableManager::Instance())-> EmConfigurator()->AddModels();218 (G4LossTableManager::Instance())->PreparePhysicsTable(&part, this); 217 219 218 220 if(particle == &part) { … … 230 232 } 231 233 232 theCuts = modelManager->Initialise(particle,secondaryParticle,2.,verboseLevel); 234 theCuts = modelManager->Initialise(particle,secondaryParticle, 235 2.,verboseLevel); 233 236 const G4ProductionCutsTable* theCoupleTable= 234 237 G4ProductionCutsTable::GetProductionCutsTable(); … … 242 245 } 243 246 } 244 // Sub Cutoff andDeexcitation247 // Deexcitation 245 248 if (nDERegions>0) { 246 249 … … 287 290 } 288 291 292 (G4LossTableManager::Instance())->BuildPhysicsTable(particle); 289 293 if(buildLambdaTable) { 290 294 BuildLambdaTable(); … … 294 298 // reduce printout for nuclear stopping 295 299 G4bool gproc = true; 296 if(GetProcessName() == "nuclearStopping" && 300 G4int st = GetProcessSubType(); 301 if(st == fCoulombScattering && part.GetParticleType() == "nucleus" && 297 302 partname != "GenericIon" && partname != "alpha") { gproc = false; } 298 303 … … 354 359 << particle->GetParticleName() 355 360 << G4endl; 356 if(2 < verboseLevel) {357 G4cout << *theLambdaTable << G4endl;358 }359 361 } 360 362 } … … 385 387 if(verboseLevel > 2 && buildLambdaTable) { 386 388 G4cout << " LambdaTable address= " << theLambdaTable << G4endl; 387 if(theLambdaTable) G4cout << (*theLambdaTable) << G4endl;389 if(theLambdaTable) { G4cout << (*theLambdaTable) << G4endl; } 388 390 } 389 391 } … … 399 401 *condition = NotForced; 400 402 G4double x = DBL_MAX; 401 if(previousStepSize <= DBL_MIN) theNumberOfInteractionLengthLeft = -1.0;403 if(previousStepSize <= DBL_MIN) { theNumberOfInteractionLengthLeft = -1.0; } 402 404 InitialiseStep(track); 403 if(!currentModel->IsActive(preStepKinEnergy)) return x;405 if(!currentModel->IsActive(preStepKinEnergy)) { return x; } 404 406 405 407 if(preStepKinEnergy < mfpKinEnergy) { … … 428 430 G4cout << "G4VEmProcess::PostStepGetPhysicalInteractionLength "; 429 431 G4cout << "[ " << GetProcessName() << "]" << G4endl; 430 G4cout << " for " << particle->GetParticleName()432 G4cout << " for " << currentParticle->GetParticleName() 431 433 << " in Material " << currentMaterial->GetName() 432 434 << " Ekin(MeV)= " << preStepKinEnergy/MeV … … 461 463 // Do not make anything if particle is stopped, the annihilation then 462 464 // should be performed by the AtRestDoIt! 463 if (track.GetTrackStatus() == fStopButAlive) return &fParticleChange;465 if (track.GetTrackStatus() == fStopButAlive) { return &fParticleChange; } 464 466 465 467 G4double finalT = track.GetKineticEnergy(); … … 469 471 G4double lx = GetLambda(finalT, currentCouple); 470 472 if(preStepLambda<lx && 1 < verboseLevel) { 471 G4cout << "WARING: for " << particle->GetParticleName()473 G4cout << "WARING: for " << currentParticle->GetParticleName() 472 474 << " and " << GetProcessName() 473 475 << " E(MeV)= " << finalT/MeV … … 483 485 484 486 SelectModel(finalT, currentCoupleIndex); 485 if(!currentModel->IsActive(finalT)) return &fParticleChange;487 if(!currentModel->IsActive(finalT)) { return &fParticleChange; } 486 488 if(useDeexcitation) { 487 489 currentModel->SetDeexcitationFlag(idxDERegions[currentCoupleIndex]); … … 662 664 SelectModel(kineticEnergy, currentCoupleIndex); 663 665 cross = currentModel->CrossSectionPerVolume(currentMaterial, 664 particle,kineticEnergy); 665 } 666 666 currentParticle,kineticEnergy); 667 } 668 669 if(cross < 0.0) { cross = 0.0; } 667 670 return cross; 668 671 } … … 676 679 *condition = NotForced; 677 680 return G4VEmProcess::MeanFreePath(track); 681 } 682 683 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 684 685 G4double G4VEmProcess::MeanFreePath(const G4Track& track) 686 { 687 DefineMaterial(track.GetMaterialCutsCouple()); 688 preStepLambda = GetCurrentLambda(track.GetKineticEnergy()); 689 G4double x = DBL_MAX; 690 if(DBL_MIN < preStepLambda) x = 1.0/preStepLambda; 691 return x; 692 } 693 694 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 695 696 G4double 697 G4VEmProcess::ComputeCrossSectionPerAtom(G4double kineticEnergy, 698 G4double Z, G4double A, G4double cut) 699 { 700 SelectModel(kineticEnergy, currentCoupleIndex); 701 G4double x = 0.0; 702 if(currentModel) { 703 x = currentModel->ComputeCrossSectionPerAtom(currentParticle,kineticEnergy, 704 Z,A,cut); 705 } 706 return x; 678 707 } 679 708 … … 714 743 theEnergyOfCrossSectionMax[i] = emax; 715 744 theCrossSectionMax[i] = smax; 716 if( 2< verboseLevel) {745 if(1 < verboseLevel) { 717 746 G4cout << "For " << particle->GetParticleName() 718 747 << " Max CS at i= " << i << " emax(MeV)= " << emax/MeV … … 733 762 734 763 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 764 765 const G4Element* G4VEmProcess::GetCurrentElement() const 766 { 767 const G4Element* elm = 0; 768 if(currentModel) {elm = currentModel->GetCurrentElement(); } 769 return elm; 770 } 771 772 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... -
trunk/source/processes/electromagnetic/utils/src/G4VEnergyLossProcess.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VEnergyLossProcess.cc,v 1.1 58 2009/10/29 18:07:08vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VEnergyLossProcess.cc,v 1.167 2010/05/26 10:41:34 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 336 336 { 337 337 modelManager->AddEmModel(order, p, fluc, region); 338 if(p) p->SetParticleChange(pParticleChange, fluc);338 if(p) { p->SetParticleChange(pParticleChange, fluc); } 339 339 } 340 340 … … 406 406 particle = ∂ 407 407 if(part.GetParticleType() == "nucleus") { 408 if(!theGenericIon) theGenericIon = G4GenericIon::GenericIon();408 if(!theGenericIon) { theGenericIon = G4GenericIon::GenericIon(); } 409 409 if(particle == theGenericIon) { isIon = true; } 410 410 else if(part.GetPDGCharge() > eplus) { … … 426 426 lManager->RegisterExtraParticle(&part, this); 427 427 } 428 if(1 < verboseLevel) { 429 G4cout << "### G4VEnergyLossProcess::PreparePhysicsTable() end for " 430 << part.GetParticleName() << G4endl; 431 } 428 432 return; 429 433 } 430 434 431 435 Clean(); 432 lManager-> EmConfigurator()->AddModels();436 lManager->PreparePhysicsTable(&part, this); 433 437 434 438 // Base particle and set of models can be defined here … … 502 506 G4bool reg = false; 503 507 for(G4int i=0; i<nSCoffRegions; ++i) { 504 if( pcuts == scoffRegions[i]->GetProductionCuts()) reg = true;508 if( pcuts == scoffRegions[i]->GetProductionCuts()) { reg = true; } 505 509 } 506 510 idxSCoffRegions[j] = reg; … … 509 513 G4bool reg = false; 510 514 for(G4int i=0; i<nDERegions; ++i) { 511 if( pcuts == deRegions[i]->GetProductionCuts()) reg = true;515 if( pcuts == deRegions[i]->GetProductionCuts()) { reg = true; } 512 516 } 513 517 idxDERegions[j] = reg; … … 515 519 } 516 520 } 517 518 lManager->EnergyLossProcessIsInitialised(particle, this);519 521 520 522 if (1 < verboseLevel) { … … 568 570 569 571 // Added tracking cut to avoid tracking artifacts 570 if(isIonisation) fParticleChange.SetLowEnergyLimit(lowestKinEnergy);572 if(isIonisation) { fParticleChange.SetLowEnergyLimit(lowestKinEnergy); } 571 573 572 574 if(1 < verboseLevel) { … … 574 576 << GetProcessName() 575 577 << " and particle " << part.GetParticleName(); 576 if(isIonisation) G4cout << " isIonisation flag = 1";578 if(isIonisation) { G4cout << " isIonisation flag = 1"; } 577 579 G4cout << G4endl; 578 580 } … … 590 592 } 591 593 G4PhysicsTable* table = 0; 592 G4double emin = minKinEnergy;593 594 G4double emax = maxKinEnergy; 594 595 G4int bin = nBins; … … 619 620 G4cout << numOfCouples << " materials" 620 621 << " minKinEnergy= " << minKinEnergy 621 << " maxKinEnergy= " << maxKinEnergy 622 << " maxKinEnergy= " << emax 623 << " nbin= " << bin 622 624 << " EmTableType= " << tType 623 625 << " table= " << table … … 642 644 theCoupleTable->GetMaterialCutsCouple(i); 643 645 if(!bVector) { 644 aVector = new G4PhysicsLogVector( emin, emax, bin);646 aVector = new G4PhysicsLogVector(minKinEnergy, emax, bin); 645 647 bVector = aVector; 646 648 } else { 647 649 aVector = new G4PhysicsLogVector(*bVector); 648 650 } 649 // G4PhysicsVector* aVector = new G4PhysicsLogVector(emin, emax, bin);650 651 aVector->SetSpline(splineFlag); 651 652 652 653 modelManager->FillDEDXVector(aVector, couple, tType); 653 if(splineFlag) aVector->FillSecondDerivatives();654 if(splineFlag) { aVector->FillSecondDerivatives(); } 654 655 655 656 // Insert vector for this material into the table … … 701 702 702 703 G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag(); 704 G4PhysicsLogVector* aVector = 0; 705 G4PhysicsLogVector* bVector = 0; 703 706 704 707 for(size_t i=0; i<numOfCouples; ++i) { … … 709 712 const G4MaterialCutsCouple* couple = 710 713 theCoupleTable->GetMaterialCutsCouple(i); 711 G4double cut = (*theCuts)[i]; 712 if(fSubRestricted == tType) cut = (*theSubCuts)[i]; 713 G4PhysicsVector* aVector = LambdaPhysicsVector(couple, cut); 714 if(!bVector) { 715 aVector = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nBins); 716 bVector = aVector; 717 } else { 718 aVector = new G4PhysicsLogVector(*bVector); 719 } 714 720 aVector->SetSpline(splineFlag); 715 721 716 722 modelManager->FillLambdaVector(aVector, couple, true, tType); 717 if(splineFlag) aVector->FillSecondDerivatives();723 if(splineFlag) { aVector->FillSecondDerivatives(); } 718 724 719 725 // Insert vector for this material into the table … … 881 887 if(x > finalRange && y < currentMinStep) { 882 888 x = y + finalRange*(1.0 - dRoverRange)*(2.0 - finalRange/fRange); 883 } else if (rndmStepFlag) { x = SampleRange();}889 } else if (rndmStepFlag) { x = SampleRange(); } 884 890 //G4cout<<GetProcessName()<<": e= "<<preStepKinEnergy 885 891 // <<" range= "<<fRange <<" cMinSt="<<currentMinStep … … 912 918 preStepScaledEnergy = preStepKinEnergy*massRatio; 913 919 SelectModel(preStepScaledEnergy); 914 if(!currentModel->IsActive(preStepScaledEnergy)) return x; 915 916 if(isIon) { 917 chargeSqRatio = 918 currentModel->GetChargeSquareRatio(currPart,currentMaterial,preStepKinEnergy); 920 if(!currentModel->IsActive(preStepScaledEnergy)) { return x; } 921 922 if(isIon) { 923 chargeSqRatio = currentModel->ChargeSquareRatio(track); 919 924 reduceFactor = 1.0/(chargeSqRatio*massRatio); 920 925 } 921 926 //G4cout << "q2= " << chargeSqRatio << " massRatio= " << massRatio << G4endl; 922 927 // initialisation for sampling of the interaction length 923 if(previousStepSize <= DBL_MIN) theNumberOfInteractionLengthLeft = -1.0;924 if(theNumberOfInteractionLengthLeft < 0.0) mfpKinEnergy = DBL_MAX;928 if(previousStepSize <= DBL_MIN) { theNumberOfInteractionLengthLeft = -1.0; } 929 if(theNumberOfInteractionLengthLeft < 0.0) { mfpKinEnergy = DBL_MAX; } 925 930 926 931 // compute mean free path 927 932 if(preStepScaledEnergy < mfpKinEnergy) { 928 if (integral) ComputeLambdaForScaledEnergy(preStepScaledEnergy);929 else preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy);930 if(preStepLambda <= DBL_MIN) mfpKinEnergy = 0.0;933 if (integral) { ComputeLambdaForScaledEnergy(preStepScaledEnergy); } 934 else { preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy); } 935 if(preStepLambda <= DBL_MIN) { mfpKinEnergy = 0.0; } 931 936 } 932 937 … … 940 945 // subtract NumberOfInteractionLengthLeft 941 946 SubtractNumberOfInteractionLengthLeft(previousStepSize); 942 if(theNumberOfInteractionLengthLeft < 0.) 947 if(theNumberOfInteractionLengthLeft < 0.) { 943 948 theNumberOfInteractionLengthLeft = perMillion; 949 } 944 950 } 945 951 … … 966 972 // subtract NumberOfInteractionLengthLeft 967 973 SubtractNumberOfInteractionLengthLeft(previousStepSize); 968 if(theNumberOfInteractionLengthLeft < 0.) 974 if(theNumberOfInteractionLengthLeft < 0.) { 969 975 theNumberOfInteractionLengthLeft = perMillion; 976 } 970 977 } 971 978 currentInteractionLength = DBL_MAX; … … 987 994 // Get the actual (true) Step length 988 995 G4double length = step.GetStepLength(); 989 if(length <= DBL_MIN) return &fParticleChange;996 if(length <= DBL_MIN) { return &fParticleChange; } 990 997 G4double eloss = 0.0; 991 G4double esecdep = 0.0;992 998 993 999 /* … … 1071 1077 1072 1078 // Check boundary 1073 if(prePoint->GetStepStatus() == fGeomBoundary) yes = true;1079 if(prePoint->GetStepStatus() == fGeomBoundary) { yes = true; } 1074 1080 1075 1081 // Check PrePoint … … 1083 1089 } 1084 1090 1085 if(preSafety < rcut) yes = true;1091 if(preSafety < rcut) { yes = true; } 1086 1092 1087 1093 // Check PostPoint … … 1091 1097 postSafety = 1092 1098 safetyHelper->ComputeSafety(step.GetPostStepPoint()->GetPosition()); 1093 if(postSafety < rcut) yes = true;1099 if(postSafety < rcut) { yes = true; } 1094 1100 } 1095 1101 } … … 1103 1109 scTracks.clear(); 1104 1110 SampleSubCutSecondaries(scTracks, step, 1105 currentModel,currentMaterialIndex, 1106 esecdep); 1111 currentModel,currentMaterialIndex); 1107 1112 // add bremsstrahlung sampling 1108 1113 /* … … 1112 1117 scTracks, step, (scProcesses[i])-> 1113 1118 SelectModelForMaterial(preStepKinEnergy, currentMaterialIndex), 1114 currentMaterialIndex ,esecdep);1119 currentMaterialIndex); 1115 1120 } 1116 1121 } … … 1123 1128 G4Track* t = scTracks[i]; 1124 1129 G4double e = t->GetKineticEnergy(); 1125 if (t->GetDefinition() == thePositron) e += 2.0*electron_mass_c2;1130 if (t->GetDefinition() == thePositron) { e += 2.0*electron_mass_c2; } 1126 1131 esec += e; 1127 1132 pParticleChange->AddSecondary(t); … … 1133 1138 1134 1139 // Corrections, which cannot be tabulated 1135 currentModel->CorrectionsAlongStep(currentCouple, dynParticle, 1136 eloss, esecdep, length); 1140 if(isIon) { 1141 G4double eadd = 0.0; 1142 currentModel->CorrectionsAlongStep(currentCouple, dynParticle, 1143 eloss, eadd, length); 1144 } 1137 1145 1138 1146 // Sample fluctuations … … 1140 1148 G4VEmFluctuationModel* fluc = currentModel->GetModelOfFluctuations(); 1141 1149 if(fluc && 1142 (eloss + esec + esecdep +lowestKinEnergy) < preStepKinEnergy) {1150 (eloss + esec + lowestKinEnergy) < preStepKinEnergy) { 1143 1151 1144 1152 G4double tmax = … … 1158 1166 } 1159 1167 } 1160 // add low-energy subcutoff particles1161 eloss += esecdep;1162 if(eloss < 0.0) eloss = 0.0;1163 1168 1164 1169 // deexcitation 1165 elseif (useDeexcitation) {1166 if(idxDERegions[currentMaterialIndex] ) {1170 if (useDeexcitation) { 1171 if(idxDERegions[currentMaterialIndex] && eloss > 0.0) { 1167 1172 currentModel->SampleDeexcitationAlongStep(currentMaterial, track, eloss); 1168 if(eloss < 0.0) eloss = 0.0;1173 if(eloss < 0.0) { eloss = 0.0; } 1169 1174 } 1170 1175 } … … 1203 1208 const G4Step& step, 1204 1209 G4VEmModel* model, 1205 G4int idx, 1206 G4double& /*extraEdep*/) 1210 G4int idx) 1207 1211 { 1208 1212 // Fast check weather subcutoff can work 1209 1213 G4double subcut = (*theSubCuts)[idx]; 1210 1214 G4double cut = (*theCuts)[idx]; 1211 if(cut <= subcut) return;1215 if(cut <= subcut) { return; } 1212 1216 1213 1217 const G4Track* track = step.GetTrack(); … … 1218 1222 1219 1223 // negligible probability to get any interaction 1220 if(length*cross < perMillion) return;1224 if(length*cross < perMillion) { return; } 1221 1225 /* 1222 1226 if(-1 < verboseLevel) … … 1269 1273 if(addSec) { 1270 1274 G4Track* t = new G4Track((*it), pretime + fragment*dt, r); 1271 //G4Track* t = new G4Track((*it), pretime, r);1272 1275 t->SetTouchableHandle(track->GetTouchableHandle()); 1273 1276 tracks.push_back(t); … … 1296 1299 G4double postStepScaledEnergy = finalT*massRatio; 1297 1300 1298 if(!currentModel->IsActive(postStepScaledEnergy)) return &fParticleChange;1301 if(!currentModel->IsActive(postStepScaledEnergy)) { return &fParticleChange; } 1299 1302 /* 1300 1303 if(-1 < verboseLevel) { … … 1506 1509 G4bool mandatory) 1507 1510 { 1508 G4bool res = true;1511 G4bool isRetrieved = false; 1509 1512 G4String filename = GetPhysicsTableFileName(part,directory,tname,ascii); 1510 G4bool yes = aTable->ExistPhysicsTable(filename); 1511 if(yes) { 1512 if(!aTable) aTable = G4PhysicsTableHelper::PreparePhysicsTable(0); 1513 yes = G4PhysicsTableHelper::RetrievePhysicsTable(aTable,filename,ascii); 1514 1515 if((G4LossTableManager::Instance())->SplineFlag()) { 1516 size_t n = aTable->length(); 1517 for(size_t i=0; i<n; ++i) { 1518 if((*aTable)[i]) { 1519 (*aTable)[i]->SetSpline(true); 1513 if(aTable) { 1514 if(aTable->ExistPhysicsTable(filename)) { 1515 if(G4PhysicsTableHelper::RetrievePhysicsTable(aTable,filename,ascii)) { 1516 isRetrieved = true; 1517 if((G4LossTableManager::Instance())->SplineFlag()) { 1518 size_t n = aTable->length(); 1519 for(size_t i=0; i<n; ++i) { 1520 if((*aTable)[i]) { (*aTable)[i]->SetSpline(true); } 1521 } 1520 1522 } 1521 } 1522 } 1523 } 1524 if(yes) { 1525 if (0 < verboseLevel) { 1526 G4cout << tname << " table for " << part->GetParticleName() 1527 << " is Retrieved from <" << filename << ">" 1528 << G4endl; 1529 } 1530 } else { 1531 if(mandatory) res = false; 1532 if(mandatory || 1 < verboseLevel) { 1523 if (0 < verboseLevel) { 1524 G4cout << tname << " table for " << part->GetParticleName() 1525 << " is Retrieved from <" << filename << ">" 1526 << G4endl; 1527 } 1528 } 1529 } 1530 } 1531 if(mandatory && !isRetrieved) { 1532 if(0 < verboseLevel) { 1533 1533 G4cout << tname << " table for " << part->GetParticleName() 1534 1534 << " from file <" … … 1536 1536 << G4endl; 1537 1537 } 1538 } 1539 return res; 1538 return false; 1539 } 1540 return true; 1540 1541 } 1541 1542 … … 1574 1575 (*theCuts)[currentMaterialIndex]); 1575 1576 } 1576 1577 if(cross < 0.0) { cross = 0.0; } 1577 1578 return cross; 1578 1579 } … … 1585 1586 preStepLambda = GetLambdaForScaledEnergy(track.GetKineticEnergy()*massRatio); 1586 1587 G4double x = DBL_MAX; 1587 if(DBL_MIN < preStepLambda) x = 1.0/preStepLambda;1588 if(DBL_MIN < preStepLambda) { x = 1.0/preStepLambda; } 1588 1589 return x; 1589 1590 } … … 1622 1623 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1623 1624 1624 G4PhysicsVector* G4VEnergyLossProcess::LambdaPhysicsVector( 1625 const G4MaterialCutsCouple* couple, G4double cut) 1626 { 1625 G4PhysicsVector* 1626 G4VEnergyLossProcess::LambdaPhysicsVector(const G4MaterialCutsCouple* /*couple*/, 1627 G4double /*cut*/) 1628 { 1629 /* 1627 1630 G4double tmin = 1628 1631 std::max(MinPrimaryEnergy(particle, couple->GetMaterial(), cut), 1629 1632 minKinEnergy); 1630 if(tmin >= maxKinEnergy) tmin = 0.5*maxKinEnergy;1633 if(tmin >= maxKinEnergy) { tmin = 0.5*maxKinEnergy; } 1631 1634 G4PhysicsVector* v = new G4PhysicsLogVector(tmin, maxKinEnergy, nBins); 1635 */ 1636 G4PhysicsVector* v = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nBins); 1632 1637 v->SetSpline((G4LossTableManager::Instance())->SplineFlag()); 1633 1638 return v; … … 1640 1645 { 1641 1646 G4bool add = true; 1642 if(p->GetProcessName() != "eBrem") add = false;1647 if(p->GetProcessName() != "eBrem") { add = false; } 1643 1648 if(add && nProcesses > 0) { 1644 1649 for(G4int i=0; i<nProcesses; ++i) { … … 1699 1704 void G4VEnergyLossProcess::SetCSDARangeTable(G4PhysicsTable* p) 1700 1705 { 1701 if(theCSDARangeTable != p) theCSDARangeTable = p;1706 if(theCSDARangeTable != p) { theCSDARangeTable = p; } 1702 1707 1703 1708 if(p) { … … 1768 1773 << " and process " << GetProcessName() << G4endl; 1769 1774 } 1770 if(theLambdaTable != p) theLambdaTable = p;1775 if(theLambdaTable != p) { theLambdaTable = p; } 1771 1776 tablesAreBuilt = true; 1772 1777 … … 1822 1827 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1823 1828 1829 const G4Element* G4VEnergyLossProcess::GetCurrentElement() const 1830 { 1831 const G4Element* elm = 0; 1832 if(currentModel) { elm = currentModel->GetCurrentElement(); } 1833 return elm; 1834 } 1835 1836 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1837 -
trunk/source/processes/electromagnetic/utils/src/G4VMscModel.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VMscModel.cc,v 1.1 3 2009/07/20 17:32:47vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VMscModel.cc,v 1.16 2010/04/06 09:24:46 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 61 61 facgeom(2.5), 62 62 facsafety(0.3), 63 skin( 3.0),63 skin(1.0), 64 64 dtrl(0.05), 65 65 lambdalimit(mm), -
trunk/source/processes/electromagnetic/utils/src/G4VMultipleScattering.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VMultipleScattering.cc,v 1. 77 2009/10/29 18:07:08vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VMultipleScattering.cc,v 1.82 2010/04/12 11:45:03 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 95 95 firstParticle(0), 96 96 stepLimit(fUseSafety), 97 skin( 3.0),97 skin(1.0), 98 98 facrange(0.04), 99 99 facgeom(2.5), … … 144 144 G4VEmFluctuationModel* fm = 0; 145 145 modelManager->AddEmModel(order, p, fm, region); 146 if(p) p->SetParticleChange(pParticleChange);146 if(p) { p->SetParticleChange(pParticleChange); } 147 147 } 148 148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... … … 170 170 { 171 171 return modelManager->GetModel(idx, ver); 172 }173 174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....175 176 void G4VMultipleScattering::BuildPhysicsTable(const G4ParticleDefinition& part)177 {178 G4String num = part.GetParticleName();179 if(1 < verboseLevel) {180 G4cout << "### G4VMultipleScattering::BuildPhysicsTable() for "181 << GetProcessName()182 << " and particle " << num183 << G4endl;184 }185 186 if (buildLambdaTable && firstParticle == &part) {187 188 const G4ProductionCutsTable* theCoupleTable=189 G4ProductionCutsTable::GetProductionCutsTable();190 size_t numOfCouples = theCoupleTable->GetTableSize();191 192 G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag();193 194 G4PhysicsLogVector* aVector = 0;195 G4PhysicsLogVector* bVector = 0;196 197 for (size_t i=0; i<numOfCouples; ++i) {198 199 if (theLambdaTable->GetFlag(i)) {200 // create physics vector and fill it201 const G4MaterialCutsCouple* couple =202 theCoupleTable->GetMaterialCutsCouple(i);203 if(!bVector) {204 aVector = static_cast<G4PhysicsLogVector*>(PhysicsVector(couple));205 bVector = aVector;206 } else {207 aVector = new G4PhysicsLogVector(*bVector);208 }209 //G4PhysicsVector* aVector = PhysicsVector(couple);210 aVector->SetSpline(splineFlag);211 modelManager->FillLambdaVector(aVector, couple, false);212 if(splineFlag) aVector->FillSecondDerivatives();213 G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector);214 }215 }216 217 if(1 < verboseLevel) {218 G4cout << "Lambda table is built for "219 << num220 << G4endl;221 }222 }223 if(verboseLevel>0 && ( num == "e-" || num == "mu+" ||224 num == "proton" || num == "pi-" ||225 num == "GenericIon")) {226 PrintInfoDefinition();227 if(2 < verboseLevel && theLambdaTable) G4cout << *theLambdaTable << G4endl;228 }229 230 if(1 < verboseLevel) {231 G4cout << "### G4VMultipleScattering::BuildPhysicsTable() done for "232 << GetProcessName()233 << " and particle " << num234 << G4endl;235 }236 172 } 237 173 … … 260 196 } 261 197 198 (G4LossTableManager::Instance())->PreparePhysicsTable(&part, this); 199 262 200 if(1 < verboseLevel) { 263 201 G4cout << "### G4VMultipleScattering::PrepearPhysicsTable() for " … … 267 205 << G4endl; 268 206 } 269 270 (G4LossTableManager::Instance())->EmConfigurator()->AddModels();271 207 272 208 if(firstParticle == &part) { … … 307 243 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 308 244 245 void G4VMultipleScattering::BuildPhysicsTable(const G4ParticleDefinition& part) 246 { 247 G4String num = part.GetParticleName(); 248 if(1 < verboseLevel) { 249 G4cout << "### G4VMultipleScattering::BuildPhysicsTable() for " 250 << GetProcessName() 251 << " and particle " << num 252 << G4endl; 253 } 254 255 (G4LossTableManager::Instance())->BuildPhysicsTable(firstParticle); 256 257 if (buildLambdaTable && firstParticle == &part) { 258 259 const G4ProductionCutsTable* theCoupleTable= 260 G4ProductionCutsTable::GetProductionCutsTable(); 261 size_t numOfCouples = theCoupleTable->GetTableSize(); 262 263 G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag(); 264 265 G4PhysicsLogVector* aVector = 0; 266 G4PhysicsLogVector* bVector = 0; 267 268 for (size_t i=0; i<numOfCouples; ++i) { 269 270 if (theLambdaTable->GetFlag(i)) { 271 // create physics vector and fill it 272 const G4MaterialCutsCouple* couple = 273 theCoupleTable->GetMaterialCutsCouple(i); 274 if(!bVector) { 275 aVector = static_cast<G4PhysicsLogVector*>(PhysicsVector(couple)); 276 bVector = aVector; 277 } else { 278 aVector = new G4PhysicsLogVector(*bVector); 279 } 280 //G4PhysicsVector* aVector = PhysicsVector(couple); 281 aVector->SetSpline(splineFlag); 282 modelManager->FillLambdaVector(aVector, couple, false); 283 if(splineFlag) aVector->FillSecondDerivatives(); 284 G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector); 285 } 286 } 287 288 if(1 < verboseLevel) { 289 G4cout << "Lambda table is built for " 290 << num 291 << G4endl; 292 } 293 } 294 if(verboseLevel>0 && ( num == "e-" || num == "mu+" || 295 num == "proton" || num == "pi-" || 296 num == "GenericIon")) { 297 PrintInfoDefinition(); 298 if(2 < verboseLevel && theLambdaTable) G4cout << *theLambdaTable << G4endl; 299 } 300 301 if(1 < verboseLevel) { 302 G4cout << "### G4VMultipleScattering::BuildPhysicsTable() done for " 303 << GetProcessName() 304 << " and particle " << num 305 << G4endl; 306 } 307 } 308 309 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 310 309 311 void G4VMultipleScattering::PrintInfoDefinition() 310 312 { … … 362 364 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 363 365 366 G4double 367 G4VMultipleScattering::PostStepGetPhysicalInteractionLength( 368 const G4Track&, G4double, G4ForceCondition* condition) 369 { 370 *condition = Forced; 371 return DBL_MAX; 372 } 373 374 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 375 376 G4VParticleChange* 377 G4VMultipleScattering::AlongStepDoIt(const G4Track& track, const G4Step& step) 378 { 379 if(currentModel->IsActive(track.GetKineticEnergy())) { 380 fParticleChange.ProposeTrueStepLength(currentModel->ComputeTrueStepLength(step.GetStepLength())); 381 } 382 return &fParticleChange; 383 } 384 385 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 386 387 G4VParticleChange* 388 G4VMultipleScattering::PostStepDoIt(const G4Track& track, const G4Step& step) 389 { 390 fParticleChange.Initialize(track); 391 if(currentModel->IsActive(track.GetKineticEnergy())) { 392 currentModel->SampleScattering(track.GetDynamicParticle(), 393 step.GetPostStepPoint()->GetSafety()); 394 } 395 return &fParticleChange; 396 } 397 398 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 399 364 400 G4double G4VMultipleScattering::GetContinuousStepLimit( 365 401 const G4Track& track, … … 371 407 return AlongStepGetPhysicalInteractionLength(track,previousStepSize,currentMinimalStep, 372 408 currentSafety, selection); 409 } 410 411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 412 413 G4double G4VMultipleScattering::ContinuousStepLimit( 414 const G4Track& track, 415 G4double previousStepSize, 416 G4double currentMinimalStep, 417 G4double& currentSafety) 418 { 419 return GetContinuousStepLimit(track,previousStepSize,currentMinimalStep, 420 currentSafety); 373 421 } 374 422 -
trunk/source/processes/electromagnetic/utils/test/testG4EnergyLossTables.cc
r1199 r1315 26 26 // 27 27 // $Id: testG4EnergyLossTables.cc,v 1.7 2006/06/29 19:55:29 gunter Exp $ 28 // GEANT4 tag $Name: geant4-09-0 3-cand-01 $28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 //-------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.