ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VEmProcess.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VEmProcess.hh
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 // -------------------------------------------------------------------
27 //
28 // GEANT4 Class header file
29 //
30 //
31 // File name: G4VEmProcess
32 //
33 // Author: Vladimir Ivanchenko
34 //
35 // Creation date: 01.10.2003
36 //
37 // Modifications: Vladimir Ivanchenko
38 //
39 // Class Description:
40 //
41 // It is the base class - EM discrete and rest/discrete process
42 
43 // -------------------------------------------------------------------
44 //
45 
46 #ifndef G4VEmProcess_h
47 #define G4VEmProcess_h 1
48 
50 
51 #include "G4VDiscreteProcess.hh"
52 #include "globals.hh"
53 #include "G4Material.hh"
54 #include "G4MaterialCutsCouple.hh"
55 #include "G4Track.hh"
56 #include "G4EmModelManager.hh"
57 #include "G4UnitsTable.hh"
58 #include "G4ParticleDefinition.hh"
60 #include "G4EmDataHandler.hh"
61 #include "G4EmParameters.hh"
62 
63 class G4Step;
64 class G4VEmModel;
65 class G4DataVector;
66 class G4VParticleChange;
67 class G4PhysicsTable;
68 class G4PhysicsVector;
69 class G4EmBiasingManager;
70 class G4LossTableManager;
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
73 
75 {
76 public:
77 
79 
80  virtual ~G4VEmProcess();
81 
82  //------------------------------------------------------------------------
83  // Virtual methods to be implemented in concrete processes
84  //------------------------------------------------------------------------
85 
86  virtual G4bool IsApplicable(const G4ParticleDefinition& p) override = 0;
87 
88  // obsolete
89  virtual void PrintInfo() {};
90 
91  virtual void ProcessDescription(std::ostream& outFile) const override;
92 
93 protected:
94 
95  virtual void StreamProcessInfo(std::ostream&) const {};
96 
97  virtual void InitialiseProcess(const G4ParticleDefinition*) = 0;
98 
99  //------------------------------------------------------------------------
100  // Method with standard implementation; may be overwritten if needed
101  //------------------------------------------------------------------------
102 
104  const G4Material*);
105 
106  //------------------------------------------------------------------------
107  // Implementation of virtual methods common to all Discrete processes
108  //------------------------------------------------------------------------
109 
110 public:
111 
112  // Initialise for build of tables
113  virtual void PreparePhysicsTable(const G4ParticleDefinition&) override;
114 
115  // Build physics table during initialisation
116  virtual void BuildPhysicsTable(const G4ParticleDefinition&) override;
117 
118  // Called before tracking of each new G4Track
119  virtual void StartTracking(G4Track*) override;
120 
121  // implementation of virtual method, specific for G4VEmProcess
123  const G4Track& track,
124  G4double previousStepSize,
125  G4ForceCondition* condition) override;
126 
127  // implementation of virtual method, specific for G4VEmProcess
128  virtual G4VParticleChange* PostStepDoIt(const G4Track&,
129  const G4Step&) override;
130 
131  // Store PhysicsTable in a file.
132  // Return false in case of failure at I/O
134  const G4String& directory,
135  G4bool ascii = false) override;
136 
137  // Retrieve Physics from a file.
138  // (return true if the Physics Table can be build by using file)
139  // (return false if the process has no functionality or in case of failure)
140  // File name should is constructed as processName+particleName and the
141  // should be placed under the directory specifed by the argument.
143  const G4String& directory,
144  G4bool ascii) override;
145 
146  // allowing check process name
147  virtual G4VEmProcess* GetEmProcess(const G4String& name);
148 
149  //------------------------------------------------------------------------
150  // Specific methods for Discrete EM post step simulation
151  //------------------------------------------------------------------------
152 
153  // It returns the cross section per volume for energy/ material
154  G4double CrossSectionPerVolume(G4double kineticEnergy,
155  const G4MaterialCutsCouple* couple);
156 
157  // It returns the cross section of the process per atom
159  G4double Z, G4double A=0.,
160  G4double cut=0.0);
161 
163 
164  // It returns cross section per volume
165  inline G4double GetLambda(G4double kinEnergy,
166  const G4MaterialCutsCouple* couple);
167  inline G4double GetLambda(G4double kinEnergy,
168  const G4MaterialCutsCouple* couple,
169  G4double logKinEnergy);
170 
171  //------------------------------------------------------------------------
172  // Specific methods to build and access Physics Tables
173  //------------------------------------------------------------------------
174 
175  // Binning for lambda table
176  void SetLambdaBinning(G4int nbins);
177 
178  // Min kinetic energy for tables
179  void SetMinKinEnergy(G4double e);
180 
181  // Min kinetic energy for high energy table
183 
184  // Max kinetic energy for tables
185  void SetMaxKinEnergy(G4double e);
186 
187  // Cross section table pointers
188  inline G4PhysicsTable* LambdaTable() const;
189  inline G4PhysicsTable* LambdaTablePrim() const;
190 
191  //------------------------------------------------------------------------
192  // Define and access particle type
193  //------------------------------------------------------------------------
194 
195  inline const G4ParticleDefinition* Particle() const;
196  inline const G4ParticleDefinition* SecondaryParticle() const;
197 
198  //------------------------------------------------------------------------
199  // Specific methods to set, access, modify models and basic parameters
200  //------------------------------------------------------------------------
201 
202 protected:
203  // Select model in run time
204  inline G4VEmModel* SelectModel(G4double kinEnergy, size_t index);
205 
206 public:
207  // Select model by energy and region index
208  inline G4VEmModel* SelectModelForMaterial(G4double kinEnergy,
209  size_t idxRegion) const;
210 
211  // Add model for region, smaller value of order defines which
212  // model will be selected for a given energy interval
213  void AddEmModel(G4int, G4VEmModel*, const G4Region* region = nullptr);
214 
215  // Assign a model to a process local list, to enable the list in run time
216  // the derived process should execute AddEmModel(..) for all such models
217  void SetEmModel(G4VEmModel*, G4int index = 0);
218 
219  // return a model from the local list
220  G4VEmModel* EmModel(size_t index = 0) const;
221 
222  // Define new energy range for the model identified by the name
223  void UpdateEmModel(const G4String&, G4double, G4double);
224 
225  // Access to models
226  G4int GetNumberOfModels() const;
227  G4int GetNumberOfRegionModels(size_t couple_index) const;
228  G4VEmModel* GetRegionModel(G4int idx, size_t couple_index) const;
229  G4VEmModel* GetModelByIndex(G4int idx = 0, G4bool ver = false) const;
230 
231  // Access to active model
232  inline const G4VEmModel* GetCurrentModel() const;
233 
234  // Access to the current G4Element
235  const G4Element* GetCurrentElement() const;
236 
237  // Biasing parameters
238  void SetCrossSectionBiasingFactor(G4double f, G4bool flag = true);
239  inline G4double CrossSectionBiasingFactor() const;
240 
241  // Activate forced interaction
243  const G4String& r = "",
244  G4bool flag = true);
245 
246  void ActivateSecondaryBiasing(const G4String& region, G4double factor,
247  G4double energyLimit);
248 
249  inline void SetEmMasterProcess(const G4VEmProcess*);
250 
251  inline void SetIntegral(G4bool val);
252 
253  inline void SetBuildTableFlag(G4bool val);
254 
255  inline void CurrentSetup(const G4MaterialCutsCouple*, G4double energy);
256 
257  //------------------------------------------------------------------------
258  // Other generic methods
259  //------------------------------------------------------------------------
260 
261 protected:
262 
263  virtual G4double GetMeanFreePath(const G4Track& track,
264  G4double previousStepSize,
265  G4ForceCondition* condition) override;
266 
268 
269  inline G4int LambdaBinning() const;
270 
271  inline G4double MinKinEnergy() const;
272 
273  inline G4double MaxKinEnergy() const;
274 
275  // Single scattering parameters
276  inline G4double PolarAngleLimit() const;
277 
278  inline G4bool IsIntegral() const;
279 
280  inline G4double RecalculateLambda(G4double kinEnergy,
281  const G4MaterialCutsCouple* couple);
282 
284 
285  inline void SetParticle(const G4ParticleDefinition* p);
286 
287  inline void SetSecondaryParticle(const G4ParticleDefinition* p);
288 
289  inline size_t CurrentMaterialCutsCoupleIndex() const;
290 
291  inline const G4MaterialCutsCouple* MaterialCutsCouple() const;
292 
293  inline G4bool ApplyCuts() const;
294 
295  inline G4double GetGammaEnergyCut();
296 
298 
299  inline void SetStartFromNullFlag(G4bool val);
300 
301  inline void SetSplineFlag(G4bool val);
302 
303  inline const G4Element* GetTargetElement() const;
304 
305  inline const G4Isotope* GetTargetIsotope() const;
306 
307 private:
308 
309  void Clear();
310 
311  void BuildLambdaTable();
312 
313  void StreamInfo(std::ostream& outFile, const G4ParticleDefinition&,
314  G4bool rst=false) const;
315 
316  void FindLambdaMax();
317 
318  void PrintWarning(G4String tit, G4double val);
319 
320  void ComputeIntegralLambda(G4double kinEnergy, G4double logKinEnergy);
321 
322  inline void DefineMaterial(const G4MaterialCutsCouple* couple);
323 
324  inline G4double GetLambdaFromTable(G4double kinEnergy);
325  inline G4double GetLambdaFromTable(G4double kinEnergy, G4double logKinEnergy);
326 
327  inline G4double GetLambdaFromTablePrim(G4double kinEnergy);
328  inline G4double GetLambdaFromTablePrim(G4double kinEnergy,
329  G4double logKinEnergy);
330 
331  inline G4double GetCurrentLambda(G4double kinEnergy);
332  inline G4double GetCurrentLambda(G4double kinEnergy, G4double logKinEnergy);
333 
334  inline G4double ComputeCurrentLambda(G4double kinEnergy);
335 
336  // hide copy constructor and assignment operator
337  G4VEmProcess(G4VEmProcess &) = delete;
338  G4VEmProcess & operator=(const G4VEmProcess &right) = delete;
339 
340  // ======== Parameters of the class fixed at construction =========
341 
345 
347 
348  // ======== Parameters of the class fixed at initialisation =======
349 
350  std::vector<G4VEmModel*> emModels;
352 
353  // tables and vectors
356  std::vector<G4double> theEnergyOfCrossSectionMax;
357  std::vector<G4double> theCrossSectionMax;
358 
359  size_t idxLambda;
361 
362  const std::vector<G4double>* theCuts;
363  const std::vector<G4double>* theCutsGamma;
364  const std::vector<G4double>* theCutsElectron;
365  const std::vector<G4double>* theCutsPositron;
366 
368 
376 
386 
387  // ======== Cashed values - may be state dependent ================
388 
389 protected:
390 
393 
398  std::vector<G4DynamicParticle*> secParticles;
401  const std::vector<G4double>* theDensityFactor;
402  const std::vector<G4int>* theDensityIdx;
403 
406 
412 
414 
419 
420 private:
421 
425 
428 
429  // cache
431 
435 };
436 
437 // ======== Run time inline methods ================
438 
440 {
441  return applyCuts;
442 }
443 
444 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
445 
447 {
448  return currentCoupleIndex;
449 }
450 
451 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
452 
454 {
455  return currentCouple;
456 }
457 
458 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
459 
461 {
462  return (*theCutsGamma)[currentCoupleIndex];
463 }
464 
465 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
466 
468 {
470 }
471 
472 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
473 
475 {
476  if(couple != currentCouple) {
477  currentCouple = couple;
478  currentMaterial = couple->GetMaterial();
481  currentCoupleIndex = couple->GetIndex();
482  basedCoupleIndex = (*theDensityIdx)[currentCoupleIndex];
483  fFactor = biasFactor*(*theDensityFactor)[currentCoupleIndex];
485  preStepKinEnergy = 0.0;
486  idxLambda = idxLambdaPrim = 0;
487  }
488 }
489 
490 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
491 
492 inline
494 {
495  if(1 < numberOfModels) {
496  currentModel = modelManager->SelectModel(kinEnergy, index);
497  }
499  return currentModel;
500 }
501 
502 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
503 
504 inline
506  size_t idxRegion) const
507 {
508  return modelManager->SelectModel(kinEnergy, idxRegion);
509 }
510 
511 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
512 
514 {
515  return ((*theLambdaTable)[basedCoupleIndex])->Value(e, idxLambda);
516 }
517 
519 {
520  return ((*theLambdaTable)[basedCoupleIndex])->LogVectorValue(e, loge);
521 }
522 
523 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
524 
526 {
527  return ((*theLambdaTablePrim)[basedCoupleIndex])->Value(e, idxLambdaPrim)/e;
528 }
529 
531 {
532  return ((*theLambdaTablePrim)[basedCoupleIndex])->LogVectorValue(e, loge)/e;
533 }
534 
535 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
536 
538 {
541 }
542 
543 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
544 
546 {
547  G4double x(0.0);
548  if(e >= minKinEnergyPrim) { x = GetLambdaFromTablePrim(e); }
549  else if(theLambdaTable) { x = GetLambdaFromTable(e); }
550  else if(currentModel) { x = ComputeCurrentLambda(e); }
551  return fFactor*x;
552 }
553 
555 {
556  G4double x(0.0);
557  if(e >= minKinEnergyPrim) { x = GetLambdaFromTablePrim(e, loge); }
558  else if(theLambdaTable) { x = GetLambdaFromTable(e, loge); }
559  else if(currentModel) { x = ComputeCurrentLambda(e); }
560  return fFactor*x;
561 }
562 
563 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
564 
565 inline void
567 {
568  DefineMaterial(couple);
570 }
571 
572 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
573 
574 inline G4double
576 {
577  CurrentSetup(couple, kinEnergy);
578  return GetCurrentLambda(kinEnergy);
579 }
580 
581 inline G4double
583  G4double logKinEnergy)
584 {
585  CurrentSetup(couple, kinEnergy);
586  return GetCurrentLambda(kinEnergy, logKinEnergy);
587 }
588 
589 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
590 
591 inline G4double
593 {
594  CurrentSetup(couple, e);
595  return fFactor*ComputeCurrentLambda(e);
596 }
597 
598 // ======== Get/Set inline methods used at initialisation ================
599 
600 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
601 
603 {
604  return nLambdaBins;
605 }
606 
607 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
608 
610 {
611  return minKinEnergy;
612 }
613 
614 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
615 
617 {
618  return maxKinEnergy;
619 }
620 
621 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
622 
624 {
625  return theParameters->MscThetaLimit();
626 }
627 
628 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
629 
631 {
632  return biasFactor;
633 }
634 
635 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
636 
638 {
639  return theLambdaTable;
640 }
641 
642 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
643 
645 {
646  return theLambdaTablePrim;
647 }
648 
649 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
650 
652 {
653  return particle;
654 }
655 
656 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
657 
659 {
660  return secondaryParticle;
661 }
662 
663 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
664 
666 {
667  integral = val;
668 }
669 
670 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
671 
673 {
674  return integral;
675 }
676 
677 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
678 
680 {
681  buildLambdaTable = val;
682 }
683 
684 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
685 
687 {
688  return &fParticleChange;
689 }
690 
691 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
692 
694 {
695  particle = p;
696  currentParticle = p;
697 }
698 
699 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
700 
702 {
704 }
705 
706 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
707 
709 {
710  startFromNull = val;
711 }
712 
713 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
714 
716 {
717  splineFlag = val;
718  actSpline = true;
719 }
720 
721 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
722 
724 {
726 }
727 
728 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
729 
731 {
733 }
734 
735 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
736 
738 {
739  return currentModel;
740 }
741 
742 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
743 
745 {
746  masterProc = ptr;
747 }
748 
749 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
750 
751 #endif