Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-02 08:29:37

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 ////////////////////////////////////////////////////////////////////////////////
0027 //
0028 //  GEANT4 Class header file
0029 //
0030 //  G4VRadioactiveDecay
0031 //
0032 //  Authors: F. Lei and P.R. Truscott
0033 //  Date:   15 June 2000
0034 //
0035 //  9 August 2017 D.H. Wright (SLAC) introduced multi-threaded mode
0036 //  30 May 2024   V. Ivanchenko rename the class 
0037 //
0038 //  Description: This class is the base for simulation of radioactive
0039 //               decays. It performs alpha, beta, gamma, electron capture,
0040 //               and isomeric transition decays of radioactive nuclei.
0041 //
0042 ///////////////////////////////////////////////////////////////////////////////
0043 
0044 #ifndef G4VRadioactiveDecay_h
0045 #define G4VRadioactiveDecay_h 1
0046 
0047 #include <vector>
0048 #include <map>
0049 #include <CLHEP/Units/SystemOfUnits.h>
0050 
0051 #include "G4ios.hh"
0052 #include "globals.hh"
0053 #include "G4VRestDiscreteProcess.hh"
0054 #include "G4ParticleChangeForRadDecay.hh"
0055 
0056 #include "G4NucleusLimits.hh"
0057 #include "G4ThreeVector.hh"
0058 #include "G4RadioactiveDecayMode.hh"
0059 
0060 class G4Fragment;
0061 class G4RadioactiveDecayMessenger;
0062 class G4PhotonEvaporation;
0063 class G4Ions;
0064 class G4DecayTable;
0065 class G4ITDecay;
0066 
0067 typedef std::map<G4String, G4DecayTable*> DecayTableMap;
0068 
0069 class G4VRadioactiveDecay : public G4VRestDiscreteProcess 
0070 {
0071   // class description
0072 
0073   // Implementation of the radioactive decay process which simulates the
0074   // decays of radioactive nuclei.  These nuclei are submitted to RDM as
0075   // G4Ions.  The required half-lives and decay schemes are retrieved from
0076   // the Radioactivity database which was derived from ENSDF.
0077   // All decay products are submitted back to the particle tracking process
0078   // through the G4ParticleChangeForRadDecay object.
0079   // class description - end 
0080 
0081   public: // with description
0082 
0083     G4VRadioactiveDecay(const G4String& processName="RadioactiveDecay",
0084                         const G4double timeThreshold=-1.0);
0085     ~G4VRadioactiveDecay() override;
0086 
0087     G4bool IsApplicable(const G4ParticleDefinition&) override;
0088     // Return true if the specified isotope is
0089     //  1) defined as "nucleus" and
0090     //  2) it is within theNucleusLimit
0091 
0092     G4VParticleChange* AtRestDoIt(const G4Track& theTrack,
0093                                   const G4Step& theStep) override;
0094 
0095     G4VParticleChange* PostStepDoIt(const G4Track& theTrack,
0096                                     const G4Step& theStep) override;
0097 
0098     void BuildPhysicsTable(const G4ParticleDefinition &) override;
0099 
0100     void ProcessDescription(std::ostream& outFile) const override;
0101 
0102     virtual G4VParticleChange* DecayIt(const G4Track& theTrack,
0103                                        const G4Step& theStep);
0104 
0105     // Return decay table if it exists, if not, load it from file
0106     G4DecayTable* GetDecayTable(const G4ParticleDefinition*);
0107 
0108     // Select a logical volume in which RDM applies
0109     void SelectAVolume(const G4String& aVolume);
0110 
0111     // Remove a logical volume from the RDM applied list
0112     void DeselectAVolume(const G4String& aVolume);
0113 
0114     // Select all logical volumes for the application of RDM
0115     void SelectAllVolumes();
0116 
0117     // Remove all logical volumes from RDM applications
0118     void DeselectAllVolumes();
0119 
0120     // Enable/disable ARM
0121     inline void SetARM(G4bool arm) { applyARM = arm; }
0122 
0123     G4DecayTable* LoadDecayTable(const G4Ions*);
0124     // Load the decay data of isotope theParentNucleus
0125 
0126     void AddUserDecayDataFile(G4int Z, G4int A, const G4String& filename);
0127     // Allow the user to replace the radio-active decay data provided in Geant4
0128     // by its own data file for a given isotope
0129 
0130     inline void SetNucleusLimits(G4NucleusLimits theNucleusLimits1)
0131       { theNucleusLimits = theNucleusLimits1; }
0132     // Sets theNucleusLimits which specifies the range of isotopes
0133     // the G4VRadioactiveDecay applies.
0134 
0135     // Returns theNucleusLimits which specifies the range of isotopes used
0136     // by G4VRadioactiveDecay
0137     inline G4NucleusLimits GetNucleusLimits() const { return theNucleusLimits; }
0138 
0139     inline void SetDecayDirection(const G4ThreeVector& theDir) {
0140       forceDecayDirection = theDir.unit();
0141     }
0142 
0143     inline const G4ThreeVector& GetDecayDirection() const {
0144       return forceDecayDirection; 
0145     }
0146 
0147     inline void SetDecayHalfAngle(G4double halfAngle=0.*CLHEP::deg) {
0148       forceDecayHalfAngle = std::min(std::max(0.*CLHEP::deg,halfAngle),180.*CLHEP::deg);
0149     }
0150 
0151     inline G4double GetDecayHalfAngle() const { return forceDecayHalfAngle; }
0152 
0153     // Force direction (random within half-angle) for "visible" daughters
0154     // (applies to electrons, positrons, gammas, neutrons, protons or alphas)
0155     inline void SetDecayCollimation(const G4ThreeVector& theDir,
0156                                     G4double halfAngle = 0.*CLHEP::deg) {
0157       SetDecayDirection(theDir);
0158       SetDecayHalfAngle(halfAngle);
0159     }
0160 
0161     // Ignore radioactive decays at rest of nuclides happening
0162     // after this (very long) time threshold
0163     inline void SetThresholdForVeryLongDecayTime(const G4double inputThreshold) {
0164       fThresholdForVeryLongDecayTime = std::max( 0.0, inputThreshold );
0165     }
0166     inline G4double GetThresholdForVeryLongDecayTime() const {
0167       return fThresholdForVeryLongDecayTime;
0168     }
0169 
0170     void StreamInfo(std::ostream& os, const G4String& endline);
0171 
0172     G4VRadioactiveDecay(const G4VRadioactiveDecay& right) = delete;
0173     G4VRadioactiveDecay& operator=(const G4VRadioactiveDecay& right) = delete;
0174 
0175   protected:
0176 
0177     G4double GetMeanFreePath(const G4Track& theTrack, G4double previousStepSize,
0178                              G4ForceCondition* condition) override;
0179 
0180     G4double GetMeanLifeTime(const G4Track& theTrack,
0181                              G4ForceCondition* condition) override;
0182 
0183     // sampling of products 
0184     void DecayAnalog(const G4Track& theTrack, G4DecayTable*);
0185 
0186     // sampling products at rest
0187     G4DecayProducts* DoDecay(const G4ParticleDefinition&, G4DecayTable*);
0188 
0189     // Apply directional bias for "visible" daughters (e+-, gamma, n, p, alpha)
0190     void CollimateDecay(G4DecayProducts* products);
0191     void CollimateDecayProduct(G4DynamicParticle* product);
0192     G4ThreeVector ChooseCollimationDirection() const;
0193 
0194     // ParticleChange for decay process
0195     G4ParticleChangeForRadDecay fParticleChangeForRadDecay;
0196 
0197     G4RadioactiveDecayMessenger* theRadioactiveDecayMessenger;
0198     G4PhotonEvaporation* photonEvaporation;
0199     G4ITDecay* decayIT;
0200 
0201     std::vector<G4String> ValidVolumes;
0202     G4bool isAllVolumesMode{true};
0203 
0204     static const G4double levelTolerance;
0205 
0206     // Library of decay tables
0207     static DecayTableMap* master_dkmap;
0208 
0209   private:
0210 
0211     G4NucleusLimits theNucleusLimits;
0212 
0213     G4bool isInitialised{false};
0214     G4bool applyARM{true};
0215 
0216     // Parameters for pre-collimated (biased) decay products
0217     G4ThreeVector forceDecayDirection{G4ThreeVector(0., 0., 0.)};
0218     G4double forceDecayHalfAngle{0.0};
0219     static const G4ThreeVector origin;  // (0,0,0) for convenience
0220 
0221     // Radioactive decay database directory path 
0222     static G4String dirPath;
0223 
0224     // User define radioactive decay data files replacing some files in the G4RADECAY database
0225     static std::map<G4int, G4String>* theUserRDataFiles;
0226 
0227     // The last RadDecayMode
0228     G4RadioactiveDecayMode theRadDecayMode{G4RadioactiveDecayMode::IT};
0229  
0230     // Ignore radioactive decays at rest of nuclides happening after this (very long) time threshold
0231     G4double fThresholdForVeryLongDecayTime;
0232 };
0233 
0234 #endif
0235