OMSim
Geant4 for IceCube optical module studies
OMSimG4RadioactiveDecay.hh
Go to the documentation of this file.
1 
17 #ifndef G4RadioactiveDecay_h
18 #define G4RadioactiveDecay_h 1
19 
20 
21 #include <vector>
22 #include <map>
23 #include <CLHEP/Units/SystemOfUnits.h>
24 
25 #include "G4ios.hh"
26 #include "globals.hh"
27 #include "G4VRestDiscreteProcess.hh"
28 #include "G4ParticleChangeForRadDecay.hh"
29 
30 #include "G4NucleusLimits.hh"
31 #include "G4ThreeVector.hh"
32 #include "G4RadioactiveDecayMode.hh"
33 
34 class G4Fragment;
35 class G4RadioactiveDecayMessenger;
36 class G4PhotonEvaporation;
37 class G4Ions;
38 class G4DecayTable;
39 class G4ITDecay;
40 
41 typedef std::map<G4String, G4DecayTable*> DecayTableMap;
42 
43 
44 class G4RadioactiveDecay : public G4VRestDiscreteProcess
45 {
46  // class description
47 
48  // Implementation of the radioactive decay process which simulates the
49  // decays of radioactive nuclei. These nuclei are submitted to RDM as
50  // G4Ions. The required half-lives and decay schemes are retrieved from
51  // the Radioactivity database which was derived from ENSDF.
52  // All decay products are submitted back to the particle tracking process
53  // through the G4ParticleChangeForRadDecay object.
54  // class description - end
55 
56  public: // with description
57 
58  G4RadioactiveDecay(const G4String& processName="RadioactiveDecay",
59  const G4double timeThreshold=-1.0);
60  ~G4RadioactiveDecay() override;
61 
62  G4bool IsApplicable(const G4ParticleDefinition&) override;
63  // Return true if the specified isotope is
64  // 1) defined as "nucleus" and
65  // 2) it is within theNucleusLimit
66 
67  G4VParticleChange* AtRestDoIt(const G4Track& theTrack,
68  const G4Step& theStep) override;
69 
70  G4VParticleChange* PostStepDoIt(const G4Track& theTrack,
71  const G4Step& theStep) override;
72 
73  void BuildPhysicsTable(const G4ParticleDefinition &) override;
74 
75  void ProcessDescription(std::ostream& outFile) const override;
76 
77  virtual G4VParticleChange* DecayIt(const G4Track& theTrack,
78  const G4Step& theStep);
79 
80  // Return decay table if it exists, if not, load it from file
81  G4DecayTable* GetDecayTable(const G4ParticleDefinition*);
82 
83  // Select a logical volume in which RDM applies
84  void SelectAVolume(const G4String& aVolume);
85 
86  // Remove a logical volume from the RDM applied list
87  void DeselectAVolume(const G4String& aVolume);
88 
89  // Select all logical volumes for the application of RDM
90  void SelectAllVolumes();
91 
92  // Remove all logical volumes from RDM applications
93  void DeselectAllVolumes();
94 
95  // Enable/disable ARM
96  void SetARM(G4bool arm) {applyARM = arm;}
97 
98  G4DecayTable* LoadDecayTable(const G4Ions*);
99  // Load the decay data of isotope theParentNucleus
100 
101  void AddUserDecayDataFile(G4int Z, G4int A, const G4String& filename);
102  // Allow the user to replace the radio-active decay data provided in Geant4
103  // by its own data file for a given isotope
104 
105  inline void SetNucleusLimits(G4NucleusLimits theNucleusLimits1)
106  {theNucleusLimits = theNucleusLimits1 ;}
107  // Sets theNucleusLimits which specifies the range of isotopes
108  // the G4RadioactiveDecay applies.
109 
110  // Returns theNucleusLimits which specifies the range of isotopes used
111  // by G4RadioactiveDecay
112  inline G4NucleusLimits GetNucleusLimits() const {return theNucleusLimits;}
113 
114  inline void SetDecayDirection(const G4ThreeVector& theDir) {
115  forceDecayDirection = theDir.unit();
116  }
117 
118  inline const G4ThreeVector& GetDecayDirection() const {
119  return forceDecayDirection;
120  }
121 
122  inline void SetDecayHalfAngle(G4double halfAngle=0.*CLHEP::deg) {
123  forceDecayHalfAngle = std::min(std::max(0.*CLHEP::deg,halfAngle),180.*CLHEP::deg);
124  }
125 
126  inline G4double GetDecayHalfAngle() const {return forceDecayHalfAngle;}
127 
128  // Force direction (random within half-angle) for "visible" daughters
129  // (applies to electrons, positrons, gammas, neutrons, protons or alphas)
130  inline void SetDecayCollimation(const G4ThreeVector& theDir,
131  G4double halfAngle = 0.*CLHEP::deg) {
132  SetDecayDirection(theDir);
133  SetDecayHalfAngle(halfAngle);
134  }
135 
136  // Ignore radioactive decays at rest of nuclides happening after this (very long) time threshold
137  inline void SetThresholdForVeryLongDecayTime(const G4double inputThreshold) {
138  fThresholdForVeryLongDecayTime = std::max( 0.0, inputThreshold );
139  }
140  inline G4double GetThresholdForVeryLongDecayTime() const {return fThresholdForVeryLongDecayTime;}
141 
142  void StreamInfo(std::ostream& os, const G4String& endline);
143 
144  G4RadioactiveDecay(const G4RadioactiveDecay& right) = delete;
145  G4RadioactiveDecay& operator=(const G4RadioactiveDecay& right) = delete;
146 
147  protected:
148  G4VParticleChange* TerminateDecay();
149  G4double GetMeanFreePath(const G4Track& theTrack, G4double previousStepSize,
150  G4ForceCondition* condition) override;
151 
152  G4double GetMeanLifeTime(const G4Track& theTrack,
153  G4ForceCondition* condition) override;
154 
155  // sampling of products
156  void DecayAnalog(const G4Track& theTrack, G4DecayTable*);
157 
158  // sampling products at rest
159  G4DecayProducts* DoDecay(const G4ParticleDefinition&, G4DecayTable*);
160 
161  // Apply directional bias for "visible" daughters (e+-, gamma, n, p, alpha)
162  void CollimateDecay(G4DecayProducts* products);
163  void CollimateDecayProduct(G4DynamicParticle* product);
164  G4ThreeVector ChooseCollimationDirection() const;
165 
166  // ParticleChange for decay process
167  G4ParticleChangeForRadDecay fParticleChangeForRadDecay;
168 
169  G4RadioactiveDecayMessenger* theRadioactiveDecayMessenger;
170  G4PhotonEvaporation* photonEvaporation;
171  G4ITDecay* decayIT;
172 
173  std::vector<G4String> ValidVolumes;
174  bool isAllVolumesMode{true};
175 
176  static const G4double levelTolerance;
177 
178  // Library of decay tables
179  static DecayTableMap* master_dkmap;
180 
181  private:
182 
183  G4NucleusLimits theNucleusLimits;
184 
185  G4bool isInitialised{false};
186  G4bool applyARM{true};
187 
188  // Parameters for pre-collimated (biased) decay products
189  G4ThreeVector forceDecayDirection{G4ThreeVector(0., 0., 0.)};
190  G4double forceDecayHalfAngle{0.0};
191  static const G4ThreeVector origin; // (0,0,0) for convenience
192 
193  // Radioactive decay database directory path
194  static G4String dirPath;
195 
196  // User define radioactive decay data files replacing some files in the G4RADECAY database
197  static std::map<G4int, G4String>* theUserRDataFiles;
198 
199  // The last RadDecayMode
200  G4RadioactiveDecayMode theRadDecayMode{G4RadioactiveDecayMode::IT};
201 
202  // Ignore radioactive decays at rest of nuclides happening after this (very long) time threshold
203  G4double fThresholdForVeryLongDecayTime;
204 };
205 
206 #endif
Definition: OMSimG4RadioactiveDecay.hh:45