source: trunk/source/processes/electromagnetic/utils/include/G4VMultipleScattering.hh@ 991

Last change on this file since 991 was 991, checked in by garnier, 17 years ago

update

File size: 18.9 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id: G4VMultipleScattering.hh,v 1.54 2008/07/31 13:01:26 vnivanch Exp $
27// GEANT4 tag $Name: geant4-09-02 $
28//
29// -------------------------------------------------------------------
30//
31// GEANT4 Class header file
32//
33//
34// File name: G4VMultipleScattering
35//
36// Author: Vladimir Ivanchenko on base of Laszlo Urban code
37//
38// Creation date: 12.03.2002
39//
40// Modifications:
41//
42// 16-07-03 Update GetRange interface (V.Ivanchenko)
43//
44//
45// Class Description:
46//
47// It is the generic process of multiple scattering it includes common
48// part of calculations for all charged particles
49//
50// 26-11-03 bugfix in AlongStepDoIt (L.Urban)
51// 25-05-04 add protection against case when range is less than steplimit (VI)
52// 30-06-04 make destructor virtual (V.Ivanchenko)
53// 27-08-04 Add InitialiseForRun method (V.Ivanchneko)
54// 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivanchenko)
55// 15-04-05 optimize internal interfaces (V.Ivanchenko)
56// 15-04-05 remove boundary flag (V.Ivanchenko)
57// 07-10-05 error in a protection in GetContinuousStepLimit corrected (L.Urban)
58// 27-10-05 introduce virtual function MscStepLimitation() (V.Ivanchenko)
59// 26-01-06 Rename GetRange -> GetRangeFromRestricteDEDX (V.Ivanchenko)
60// 17-02-06 Save table of transport cross sections not mfp (V.Ivanchenko)
61// 07-03-06 Move step limit calculation to model (V.Ivanchenko)
62// 13-05-06 Add method to access model by index (V.Ivanchenko)
63// 12-02-07 Add get/set skin (V.Ivanchenko)
64// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
65// 15-07-08 Reorder class members for further multi-thread development (VI)
66//
67
68// -------------------------------------------------------------------
69//
70
71#ifndef G4VMultipleScattering_h
72#define G4VMultipleScattering_h 1
73
74#include "G4VContinuousDiscreteProcess.hh"
75#include "globals.hh"
76#include "G4Material.hh"
77#include "G4MaterialCutsCouple.hh"
78#include "G4ParticleChangeForMSC.hh"
79#include "G4Track.hh"
80#include "G4Step.hh"
81#include "G4EmModelManager.hh"
82#include "G4VEmModel.hh"
83#include "G4MscStepLimitType.hh"
84
85class G4ParticleDefinition;
86class G4DataVector;
87class G4PhysicsTable;
88class G4PhysicsVector;
89
90//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
91
92class G4VMultipleScattering : public G4VContinuousDiscreteProcess
93{
94public:
95
96 G4VMultipleScattering(const G4String& name = "msc",
97 G4ProcessType type = fElectromagnetic);
98
99 virtual ~G4VMultipleScattering();
100
101 //------------------------------------------------------------------------
102 // Virtual methods to be implemented for the concrete model
103 //------------------------------------------------------------------------
104
105 virtual G4bool IsApplicable(const G4ParticleDefinition& p) = 0;
106
107 virtual void PrintInfo() = 0;
108
109protected:
110
111 virtual void InitialiseProcess(const G4ParticleDefinition*) = 0;
112
113public:
114
115 //------------------------------------------------------------------------
116 // Generic methods common to all ContinuousDiscrete processes
117 //------------------------------------------------------------------------
118
119 // Initialise for build of tables
120 void PreparePhysicsTable(const G4ParticleDefinition&);
121
122 // Build physics table during initialisation
123 void BuildPhysicsTable(const G4ParticleDefinition&);
124
125 // Print out of generic class parameters
126 void PrintInfoDefinition();
127
128 G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&);
129
130 G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&);
131
132 // Store PhysicsTable in a file.
133 // Return false in case of failure at I/O
134 G4bool StorePhysicsTable(const G4ParticleDefinition*,
135 const G4String& directory,
136 G4bool ascii = false);
137
138 // Retrieve Physics from a file.
139 // (return true if the Physics Table can be build by using file)
140 // (return false if the process has no functionality or in case of failure)
141 // File name should is constructed as processName+particleName and the
142 // should be placed under the directory specifed by the argument.
143 G4bool RetrievePhysicsTable(const G4ParticleDefinition*,
144 const G4String& directory,
145 G4bool ascii);
146
147 //------------------------------------------------------------------------
148 // Specific methods for msc processes
149 //------------------------------------------------------------------------
150
151 // The function overloads the corresponding function of the base
152 // class.It limits the step near to boundaries only
153 // and invokes the method GetMscContinuousStepLimit at every step.
154 virtual G4double AlongStepGetPhysicalInteractionLength(
155 const G4Track&,
156 G4double previousStepSize,
157 G4double currentMinimalStep,
158 G4double& currentSafety,
159 G4GPILSelection* selection);
160
161 // The function overloads the corresponding function of the base
162 // class.
163 G4double PostStepGetPhysicalInteractionLength(
164 const G4Track&,
165 G4double previousStepSize,
166 G4ForceCondition* condition);
167
168 // This method does not used for tracking, it is intended only for tests
169 inline G4double ContinuousStepLimit(const G4Track& track,
170 G4double previousStepSize,
171 G4double currentMinimalStep,
172 G4double& currentSafety);
173
174 //------------------------------------------------------------------------
175 // Specific methods to build and access Physics Tables
176 //------------------------------------------------------------------------
177
178 // Build empty Physics Vector
179 G4PhysicsVector* PhysicsVector(const G4MaterialCutsCouple*);
180
181 inline void SetBinning(G4int nbins);
182 inline G4int Binning() const;
183
184 inline void SetMinKinEnergy(G4double e);
185 inline G4double MinKinEnergy() const;
186
187 inline void SetMaxKinEnergy(G4double e);
188 inline G4double MaxKinEnergy() const;
189
190 inline void SetBuildLambdaTable(G4bool val);
191
192 inline G4PhysicsTable* LambdaTable() const;
193
194 //------------------------------------------------------------------------
195 // Define and access particle type
196 //------------------------------------------------------------------------
197
198 inline const G4ParticleDefinition* Particle() const;
199 inline void SetParticle(const G4ParticleDefinition*);
200
201 //------------------------------------------------------------------------
202 // Specific methods to set, access, modify models
203 //------------------------------------------------------------------------
204
205 inline void AddEmModel(G4int, G4VEmModel*, const G4Region* region = 0);
206
207 inline G4VEmModel* SelectModelForMaterial(G4double kinEnergy,
208 size_t& idxRegion) const;
209
210 // Access to models
211 inline G4VEmModel* GetModelByIndex(G4int idx = 0, G4bool ver = false);
212
213 //------------------------------------------------------------------------
214 // Set parameters for simulation of multiple scattering
215 //------------------------------------------------------------------------
216
217 inline void SetLateralDisplasmentFlag(G4bool val);
218
219 inline void SetSkin(G4double val);
220
221 inline void SetRangeFactor(G4double val);
222
223 inline void SetGeomFactor(G4double val);
224
225 inline void SetPolarAngleLimit(G4double val);
226
227 inline void SetStepLimitType(G4MscStepLimitType val);
228
229protected:
230
231 // This method is used for tracking, it returns mean free path value
232 G4double GetMeanFreePath(const G4Track& track,
233 G4double,
234 G4ForceCondition* condition);
235
236 //------------------------------------------------------------------------
237 // Run time methods
238 //------------------------------------------------------------------------
239
240 // This method is not used for tracking, it returns step limit
241 G4double GetContinuousStepLimit(const G4Track& track,
242 G4double previousStepSize,
243 G4double currentMinimalStep,
244 G4double& currentSafety);
245
246 inline G4double GetLambda(const G4ParticleDefinition* p,
247 G4double& kineticEnergy);
248
249 // This method is used for tracking, it returns step limit
250 inline G4double GetMscContinuousStepLimit(const G4Track& track,
251 G4double scaledKinEnergy,
252 G4double currentMinimalStep,
253 G4double& currentSafety);
254
255 inline G4VEmModel* SelectModel(G4double kinEnergy);
256 // Select concrete model
257
258 inline const G4MaterialCutsCouple* CurrentMaterialCutsCouple() const;
259
260 // define current material
261 inline void DefineMaterial(const G4MaterialCutsCouple* couple);
262
263 //------------------------------------------------------------------------
264 // Access parameters of multiple scattering
265 //------------------------------------------------------------------------
266
267 inline G4ParticleChangeForMSC* GetParticleChange();
268
269 inline G4double Skin() const;
270
271 inline G4double RangeFactor() const;
272
273 inline G4double GeomFactor() const;
274
275 inline G4double PolarAngleLimit() const;
276
277 inline G4MscStepLimitType StepLimitType() const;
278
279 inline G4bool LateralDisplasmentFlag() const;
280
281private:
282
283 // hide assignment operator
284
285 G4VMultipleScattering(G4VMultipleScattering &);
286 G4VMultipleScattering & operator=(const G4VMultipleScattering &right);
287
288 // ======== Parameters of the class fixed at construction =========
289
290 G4EmModelManager* modelManager;
291 G4bool buildLambdaTable;
292
293 // ======== Parameters of the class fixed at initialisation =======
294
295 G4PhysicsTable* theLambdaTable;
296 const G4ParticleDefinition* firstParticle;
297
298 G4MscStepLimitType stepLimit;
299
300 G4double minKinEnergy;
301 G4double maxKinEnergy;
302 G4double skin;
303 G4double facrange;
304 G4double facgeom;
305 G4double polarAngleLimit;
306
307 G4int nBins;
308
309 G4bool latDisplasment;
310
311 // ======== Cashed values - may be state dependent ================
312
313protected:
314
315 G4GPILSelection valueGPILSelectionMSC;
316 G4ParticleChangeForMSC fParticleChange;
317
318private:
319
320 G4VEmModel* currentModel;
321
322 // cache
323 const G4ParticleDefinition* currentParticle;
324 const G4MaterialCutsCouple* currentCouple;
325 size_t currentMaterialIndex;
326
327};
328
329//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
330//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
331
332inline
333void G4VMultipleScattering::DefineMaterial(const G4MaterialCutsCouple* couple)
334{
335 if(couple != currentCouple) {
336 currentCouple = couple;
337 currentMaterialIndex = couple->GetIndex();
338 }
339}
340
341//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
342
343inline G4double G4VMultipleScattering::GetMscContinuousStepLimit(
344 const G4Track& track,
345 G4double scaledKinEnergy,
346 G4double currentMinimalStep,
347 G4double&)
348{
349 G4double x = currentMinimalStep;
350 DefineMaterial(track.GetMaterialCutsCouple());
351 currentModel = SelectModel(scaledKinEnergy);
352 if(x > 0.0 && scaledKinEnergy > 0.0) {
353 G4double tPathLength =
354 currentModel->ComputeTruePathLengthLimit(track, theLambdaTable, x);
355 if (tPathLength < x) valueGPILSelectionMSC = CandidateForSelection;
356 x = currentModel->ComputeGeomPathLength(tPathLength);
357 // G4cout << "tPathLength= " << tPathLength
358 // << " stepLimit= " << x
359 // << " currentMinimalStep= " << currentMinimalStep<< G4endl;
360 }
361 return x;
362}
363
364//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
365
366inline G4double G4VMultipleScattering::ContinuousStepLimit(
367 const G4Track& track,
368 G4double previousStepSize,
369 G4double currentMinimalStep,
370 G4double& currentSafety)
371{
372 return GetMscContinuousStepLimit(track,previousStepSize,currentMinimalStep,
373 currentSafety);
374}
375
376//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
377
378inline
379G4double G4VMultipleScattering::GetLambda(const G4ParticleDefinition* p,
380 G4double& e)
381{
382 G4double x;
383 if(theLambdaTable) {
384 G4bool b;
385 x = ((*theLambdaTable)[currentMaterialIndex])->GetValue(e, b);
386 } else {
387 x = currentModel->CrossSection(currentCouple,p,e);
388 }
389 if(x > DBL_MIN) x = 1./x;
390 else x = DBL_MAX;
391 return x;
392}
393
394//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
395
396inline G4VEmModel* G4VMultipleScattering::SelectModel(G4double kinEnergy)
397{
398 return modelManager->SelectModel(kinEnergy, currentMaterialIndex);
399}
400
401//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
402
403inline G4VEmModel* G4VMultipleScattering::SelectModelForMaterial(
404 G4double kinEnergy, size_t& idxRegion) const
405{
406 return modelManager->SelectModel(kinEnergy, idxRegion);
407}
408
409//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
410
411inline void G4VMultipleScattering::SetBinning(G4int nbins)
412{
413 nBins = nbins;
414}
415
416//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
417
418inline G4int G4VMultipleScattering::Binning() const
419{
420 return nBins;
421}
422
423//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
424
425inline void G4VMultipleScattering::SetMinKinEnergy(G4double e)
426{
427 minKinEnergy = e;
428}
429
430//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
431
432inline G4double G4VMultipleScattering::MinKinEnergy() const
433{
434 return minKinEnergy;
435}
436
437//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
438
439inline void G4VMultipleScattering::SetMaxKinEnergy(G4double e)
440{
441 maxKinEnergy = e;
442}
443
444//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
445
446inline G4double G4VMultipleScattering::MaxKinEnergy() const
447{
448 return maxKinEnergy;
449}
450
451//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
452
453inline G4bool G4VMultipleScattering::LateralDisplasmentFlag() const
454{
455 return latDisplasment;
456}
457
458//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
459
460inline void G4VMultipleScattering::SetLateralDisplasmentFlag(G4bool val)
461{
462 latDisplasment = val;
463}
464
465//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
466
467inline G4ParticleChangeForMSC* G4VMultipleScattering::GetParticleChange()
468{
469 return &fParticleChange;
470}
471
472//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
473
474inline G4double G4VMultipleScattering::Skin() const
475{
476 return skin;
477}
478
479//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
480
481inline void G4VMultipleScattering::SetSkin(G4double val)
482{
483 if(val < 1.0) skin = 0.0;
484 else skin = val;
485}
486
487//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
488
489inline G4double G4VMultipleScattering::RangeFactor() const
490{
491 return facrange;
492}
493
494//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
495
496inline void G4VMultipleScattering::SetRangeFactor(G4double val)
497{
498 if(val > 0.0) facrange = val;
499}
500
501//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
502
503inline G4double G4VMultipleScattering::GeomFactor() const
504{
505 return facgeom;
506}
507
508//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
509
510inline void G4VMultipleScattering::SetGeomFactor(G4double val)
511{
512 if(val > 0.0) facgeom = val;
513}
514
515//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
516
517inline G4double G4VMultipleScattering::PolarAngleLimit() const
518{
519 return polarAngleLimit;
520}
521
522//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
523
524inline void G4VMultipleScattering::SetPolarAngleLimit(G4double val)
525{
526 if(val < 0.0) polarAngleLimit = 0.0;
527 else if(val > pi) polarAngleLimit = pi;
528 else polarAngleLimit = val;
529}
530
531//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
532
533inline G4MscStepLimitType G4VMultipleScattering::StepLimitType() const
534{
535 return stepLimit;
536}
537
538//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
539
540inline void G4VMultipleScattering::SetStepLimitType(G4MscStepLimitType val)
541{
542 stepLimit = val;
543 if(val == fMinimal) facrange = 0.2;
544}
545
546//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
547
548inline void G4VMultipleScattering::SetBuildLambdaTable(G4bool val)
549{
550 buildLambdaTable = val;
551}
552
553//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
554
555inline const G4ParticleDefinition* G4VMultipleScattering::Particle() const
556{
557 return currentParticle;
558}
559
560//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
561
562inline G4PhysicsTable* G4VMultipleScattering::LambdaTable() const
563{
564 return theLambdaTable;
565}
566
567//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
568
569inline
570const G4MaterialCutsCouple* G4VMultipleScattering::CurrentMaterialCutsCouple() const
571{
572 return currentCouple;
573}
574
575//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
576
577inline void G4VMultipleScattering::AddEmModel(G4int order, G4VEmModel* p,
578 const G4Region* region)
579{
580 G4VEmFluctuationModel* fm = 0;
581 modelManager->AddEmModel(order, p, fm, region);
582 if(p) p->SetParticleChange(pParticleChange);
583}
584
585//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
586
587inline
588G4VEmModel* G4VMultipleScattering::GetModelByIndex(G4int idx, G4bool ver)
589{
590 return modelManager->GetModel(idx, ver);
591}
592
593//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
594
595#endif
Note: See TracBrowser for help on using the repository browser.