Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 09:11:43

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 // Scintillation Light Class Definition
0028 ////////////////////////////////////////////////////////////////////////
0029 //
0030 // File:        G4Scintillation.hh
0031 // Description: Discrete Process - Generation of Scintillation Photons
0032 // Version:     1.0
0033 // Created:     1998-11-07
0034 // Author:      Peter Gumplinger
0035 // Updated:     2010-10-20 Allow the scintillation yield to be a function
0036 //                         of energy deposited by particle type
0037 //                         Thanks to Zach Hartwig (Department of Nuclear
0038 //                         Science and Engineeering - MIT)
0039 //              2005-07-28 add G4ProcessType to constructor
0040 //              2002-11-21 change to user G4Poisson for small MeanNumPotons
0041 //              2002-11-07 allow for fast and slow scintillation
0042 //              2002-11-05 make use of constant material properties
0043 //              2002-05-16 changed to inherit from VRestDiscreteProcess
0044 //              2002-05-09 changed IsApplicable method
0045 //              1999-10-29 add method and class descriptors
0046 //
0047 //
0048 ////////////////////////////////////////////////////////////////////////
0049 
0050 #ifndef G4Scintillation_h
0051 #define G4Scintillation_h 1
0052 
0053 #include "globals.hh"
0054 #include "G4EmSaturation.hh"
0055 #include "G4OpticalPhoton.hh"
0056 #include "G4VRestDiscreteProcess.hh"
0057 
0058 #include <map>
0059 
0060 class G4PhysicsTable;
0061 class G4Step;
0062 class G4Track;
0063 
0064 // Class Description:
0065 // RestDiscrete Process - Generation of Scintillation Photons.
0066 // Class inherits publicly from G4VRestDiscreteProcess.
0067 // Class Description - End:
0068 
0069 class G4Scintillation : public G4VRestDiscreteProcess
0070 {
0071  public:
0072   explicit G4Scintillation(const G4String& processName = "Scintillation",
0073                            G4ProcessType type          = fElectromagnetic);
0074   ~G4Scintillation();
0075 
0076   G4Scintillation(const G4Scintillation& right) = delete;
0077   G4Scintillation& operator=(const G4Scintillation& right) = delete;
0078 
0079   // G4Scintillation Process has both PostStepDoIt (for energy
0080   // deposition of particles in flight) and AtRestDoIt (for energy
0081   // given to the medium by particles at rest)
0082 
0083   G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
0084   // Returns true -> 'is applicable', for any particle type except
0085   // for an 'opticalphoton' and for short-lived particles
0086 
0087   void ProcessDescription(std::ostream&) const override;
0088   void DumpInfo() const override {ProcessDescription(G4cout);};
0089 
0090   void BuildPhysicsTable(const G4ParticleDefinition& aParticleType) override;
0091   // Build table at the right time
0092 
0093   void PreparePhysicsTable(const G4ParticleDefinition& part) override;
0094   void Initialise();
0095 
0096   G4double GetMeanFreePath(const G4Track& aTrack, G4double,
0097                            G4ForceCondition*) override;
0098   // Returns infinity; i. e. the process does not limit the step,
0099   // but sets the 'StronglyForced' condition for the DoIt to be
0100   // invoked at every step.
0101 
0102   G4double GetMeanLifeTime(const G4Track& aTrack, G4ForceCondition*) override;
0103   // Returns infinity; i. e. the process does not limit the time,
0104   // but sets the 'StronglyForced' condition for the DoIt to be
0105   // invoked at every step.
0106 
0107   G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
0108                                   const G4Step& aStep) override;
0109   G4VParticleChange* AtRestDoIt(const G4Track& aTrack,
0110                                 const G4Step& aStep) override;
0111 
0112   G4double GetScintillationYieldByParticleType(const G4Track& aTrack,
0113                                                const G4Step& aStep,
0114                                                G4double& yield1,
0115                                                G4double& yield2,
0116                                                G4double& yield3,
0117                                                G4double& timeconstant1,
0118                                                G4double& timeconstant2,
0119                                                G4double& timeconstant3);
0120   // allow multiple time constants with scint by particle type
0121   // Returns the number of scintillation photons calculated when
0122   // scintillation depends on the particle type and energy
0123   // deposited (includes nonlinear dependendency) and updates the
0124   // yields for each channel
0125 
0126   void SetTrackSecondariesFirst(const G4bool state);
0127   // If set, the primary particle tracking is interrupted and any
0128   // produced scintillation photons are tracked next. When all
0129   // have been tracked, the tracking of the primary resumes.
0130 
0131   G4bool GetTrackSecondariesFirst() const;
0132   // Returns the boolean flag for tracking secondaries first.
0133 
0134   void SetFiniteRiseTime(const G4bool state);
0135   // If set, the G4Scintillation process expects the user to have
0136   // set the constant material property SCINTILLATIONRISETIME{1,2,3}.
0137 
0138   G4bool GetFiniteRiseTime() const;
0139   // Returns the boolean flag for a finite scintillation rise time.
0140 
0141   G4PhysicsTable* GetIntegralTable1() const;
0142   // Returns the address of scintillation integral table #1.
0143 
0144   G4PhysicsTable* GetIntegralTable2() const;
0145   // Returns the address of scintillation integral table #2.
0146 
0147   G4PhysicsTable* GetIntegralTable3() const;
0148   // Returns the address of scintillation integral table #3.
0149 
0150   void AddSaturation(G4EmSaturation* sat);
0151   // Adds Birks Saturation to the process.
0152 
0153   void RemoveSaturation();
0154   // Removes the Birks Saturation from the process.
0155 
0156   G4EmSaturation* GetSaturation() const;
0157   // Returns the Birks Saturation.
0158 
0159   void SetScintillationByParticleType(const G4bool);
0160   // Called by the user to set the scintillation yield as a function
0161   // of energy deposited by particle type
0162 
0163   G4bool GetScintillationByParticleType() const;
0164   // Return the boolean that determines the method of scintillation
0165   // production
0166 
0167   void SetScintillationTrackInfo(const G4bool trackType);
0168   // Call by the user to set the G4ScintillationTrackInformation
0169   // to scintillation photon track
0170 
0171   G4bool GetScintillationTrackInfo() const;
0172   // Return the boolean for whether or not the
0173   // G4ScintillationTrackInformation is set to the scint. photon track
0174 
0175   void SetStackPhotons(const G4bool);
0176   // Call by the user to set the flag for stacking the scint. photons
0177 
0178   G4bool GetStackPhotons() const;
0179   // Return the boolean for whether or not the scint. photons are stacked
0180 
0181   G4int GetNumPhotons() const;
0182   // Returns the current number of scint. photons (after PostStepDoIt)
0183 
0184   void DumpPhysicsTable() const;
0185   // Prints the fast and slow scintillation integral tables.
0186 
0187   void SetVerboseLevel(G4int);
0188   // sets verbosity
0189 
0190  private:
0191   void BuildInverseCdfTable(const G4MaterialPropertyVector* MPV,
0192                             G4PhysicsFreeVector* vec) const;
0193   // Build the inverse cumulative distribution function (C.D.F.) table
0194   // for the scintillation photon energy spectrum
0195 
0196  private:
0197 
0198   G4PhysicsTable* fIntegralTable1;
0199   G4PhysicsTable* fIntegralTable2;
0200   G4PhysicsTable* fIntegralTable3;
0201   std::map<std::size_t, std::size_t> fIndexMPT;
0202 
0203   G4EmSaturation* fEmSaturation;
0204   const G4ParticleDefinition* opticalphoton =
0205     G4OpticalPhoton::OpticalPhotonDefinition();
0206 
0207   G4int fNumPhotons;
0208   
0209   G4bool fScintillationByParticleType;
0210   G4bool fScintillationTrackInfo;
0211   G4bool fStackingFlag;
0212   G4bool fTrackSecondariesFirst;
0213   G4bool fFiniteRiseTime;
0214 
0215 #ifdef G4DEBUG_SCINTILLATION
0216   G4double ScintTrackEDep, ScintTrackYield;
0217 #endif
0218 
0219   G4double single_exp(G4double t, G4double tau2);
0220   G4double bi_exp(G4double t, G4double tau1, G4double tau2);
0221 
0222   // emission time distribution when there is a finite rise time
0223   G4double sample_time(G4double tau1, G4double tau2);
0224 
0225   G4int secID = -1;  // creator modelID
0226   G4int fNumEnergyWarnings = 0;
0227 
0228 };
0229 
0230 ////////////////////
0231 // Inline methods
0232 ////////////////////
0233 
0234 inline G4bool G4Scintillation::GetTrackSecondariesFirst() const
0235 {
0236   return fTrackSecondariesFirst;
0237 }
0238 
0239 inline G4bool G4Scintillation::GetFiniteRiseTime() const
0240 {
0241   return fFiniteRiseTime;
0242 }
0243 
0244 inline G4PhysicsTable* G4Scintillation::GetIntegralTable1() const
0245 {
0246   return fIntegralTable1;
0247 }
0248 
0249 inline G4PhysicsTable* G4Scintillation::GetIntegralTable2() const
0250 {
0251   return fIntegralTable2;
0252 }
0253 
0254 inline G4PhysicsTable* G4Scintillation::GetIntegralTable3() const
0255 {
0256   return fIntegralTable3;
0257 }
0258 
0259 inline void G4Scintillation::AddSaturation(G4EmSaturation* sat)
0260 {
0261   fEmSaturation = sat;
0262 }
0263 
0264 inline void G4Scintillation::RemoveSaturation() { fEmSaturation = nullptr; }
0265 
0266 inline G4EmSaturation* G4Scintillation::GetSaturation() const
0267 {
0268   return fEmSaturation;
0269 }
0270 
0271 inline G4bool G4Scintillation::GetScintillationByParticleType() const
0272 {
0273   return fScintillationByParticleType;
0274 }
0275 
0276 inline G4bool G4Scintillation::GetScintillationTrackInfo() const
0277 {
0278   return fScintillationTrackInfo;
0279 }
0280 
0281 inline G4bool G4Scintillation::GetStackPhotons() const { return fStackingFlag; }
0282 
0283 inline G4int G4Scintillation::GetNumPhotons() const { return fNumPhotons; }
0284 
0285 inline G4double G4Scintillation::single_exp(G4double t, G4double tau2)
0286 {
0287   return std::exp(-1.0 * t / tau2) / tau2;
0288 }
0289 
0290 inline G4double G4Scintillation::bi_exp(G4double t, G4double tau1,
0291                                         G4double tau2)
0292 {
0293   return std::exp(-1.0 * t / tau2) * (1 - std::exp(-1.0 * t / tau1)) / tau2 /
0294          tau2 * (tau1 + tau2);
0295 }
0296 
0297 #endif /* G4Scintillation_h */