Geant4 Cross Reference |
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 #ifndef PAR03EMSHOWERMODEL_HH 27 #define PAR03EMSHOWERMODEL_HH 28 29 #include "G4VFastSimulationModel.hh" 30 31 class Par03EMShowerMessenger; 32 class G4FastSimHitMaker; 33 34 /** 35 * @brief Example fast simulation model for EM showers. 36 * 37 * Parametrisation of electrons, positrons, and gammas. It is triggered if those 38 * particles enter the detector so that there is sufficient length for the 39 * shower development (max depth, controlled by the UI command). 40 * 41 * Parametrisation is based on the PDG chapter on the electromagnetic cascades 42 * (chapter 33.5). Longitudinal profile of the shower is described with Gamma 43 * distribution, with beta parameter on average equal to 0.5 (default value, 44 * Fig. 33.21), and alpha parameter calcluated from the incident particle energy 45 * and material of the detector (critical energy) following Eq.(33.36). 46 * 47 * Transverse profile is in this model approximated by the Gaussian 48 * distribution, with the mean along the shower axis (incident particle momentum 49 * direction) and the standard deviation calculated from the detector material 50 * (Moliere radius). This assumes that EM shower is in 90% contained within a 51 * cylinder of radius equal to Moliere radius, and that area below Gaussian 52 * distribution from `mean-1.645 sigma` to `mean+1.645 sigma` is also equal to 53 * 90% of total distribution. 54 * 55 * Parameters of both distributions (alpha, beta for Gamma, sigma for Gaussian) 56 * can be overwritten by UI commands. 57 * 58 * Parametrisation creates N hits of same energy (N can be set by UI command), 59 * using rejection sampling to generate position along shower axis from Gamma 60 * distribution, and then sampling from uniform and Gaussian distributions to 61 * sample phi and radius, respectively. Created hits are deposited in the 62 * detector using its readout geometry, using the helper class G4FastSimHitMaker 63 * that locates the volume, and calls appropriate sensitive detector class. 64 * 65 * PDG Chapter 33: 66 * https://pdg.lbl.gov/2019/reviews/rpp2018-rev-passage-particles-matter.pdf 67 * 68 */ 69 70 class Par03EMShowerModel : public G4VFastSimulationModel 71 { 72 public: 73 Par03EMShowerModel(G4String, G4Region*); 74 Par03EMShowerModel(G4String); 75 ~Par03EMShowerModel(); 76 77 /// There are no kinematics constraints. True is returned. 78 virtual G4bool ModelTrigger(const G4FastTrack&) final; 79 /// Model is applicable to electrons, positrons, and photons. 80 virtual G4bool IsApplicable(const G4ParticleDefinition&) final; 81 /// Take particle out of the full simulation (kill it at the entrance 82 /// depositing all the energy). Calculate energy deposited in the detector 83 /// according to Gamma distribution (along the particle direction) and 84 /// Gaussian distribution in the transverse direction. Mean of the Gaussian is 85 /// centred on the shower axis. Create energy deposits on a cylindrical mesh. 86 /// Parameters of the mesh (size, number of cells) and of the distributions 87 /// (alpha, beta for Gamma, sigma for Gaussian) can be set with UI commands. 88 virtual void DoIt(const G4FastTrack&, G4FastStep&) final; 89 90 /// Print current settings. 91 void Print() const; 92 /// Set standard deviation of a Gaussian distribution that describes the 93 /// transverse shower profile. 94 inline void SetSigma(const G4double aSigma) { fSigma = aSigma; }; 95 /// Get standard deviation of a Gaussian distribution that describes the 96 /// transverse shower profile. 97 inline G4double GetSigma() const { return fSigma; }; 98 /// Set alpha parameter of a Gamma distribution that describes the 99 /// longitudinal shower profile. 100 inline void SetAlpha(const G4double aAlpha) { fAlpha = aAlpha; }; 101 /// Get alpha parameter of a Gamma distribution that describes the 102 /// longitudinal shower profile. 103 inline G4double GetAlpha() const { return fAlpha; }; 104 /// Set beta parameter of a Gamma distribution that describes the longitudinal 105 /// shower profile. 106 inline void SetBeta(const G4double aBeta) { fBeta = aBeta; }; 107 /// Get beta parameter of a Gamma distribution that describes the longitudinal 108 /// shower profile. 109 inline G4double GetBeta() const { return fBeta; }; 110 /// Set number of (same energy) hits created in the parametrisation. 111 inline void SetNbOfHits(const G4int aNumber) { fNbOfHits = aNumber; }; 112 /// Get number of (same energy) hits created in the parametrisation.s 113 inline G4int GetNbOfHits() const { return fNbOfHits; }; 114 /// Set maximum depth of shower created in fast simulation. It is expressed in 115 /// units of radiaton length. 116 inline void SetLongMaxDepth(const G4double aDepth) { fLongMaxDepth = aDepth; }; 117 /// Get maximum depth of shower created in fast simulation. It is expressed in 118 /// units of radiaton length. 119 inline G4double GetLongMaxDepth() const { return fLongMaxDepth; }; 120 121 private: 122 /// Gamma distribution 123 inline G4double Gamma(G4double x, G4double alpha, G4double beta) 124 { 125 return (std::pow(beta, alpha) / std::tgamma(alpha) * std::pow(x, alpha - 1) 126 * std::exp(-beta * x)); 127 } 128 /// Gaussian distribution 129 inline G4double Gaussian(G4double x, G4double sigma = 1, G4double x0 = 0) 130 { 131 G4double tmp = (x - x0) / sigma; 132 return (1.0 / (std::sqrt(2 * CLHEP::pi) * sigma)) * std::exp(-tmp * tmp / 2); 133 } 134 135 private: 136 /// Messenger for configuration 137 Par03EMShowerMessenger* fMessenger; 138 /// Helper class for creation of hits within the sensitive detector 139 std::unique_ptr<G4FastSimHitMaker> fHitMaker; 140 /// Standard deviation of the Gaussian distribution 141 /// Can be changed with UI command `/Par03/fastSim/transverseProfile/sigma 142 /// <sigma>` 143 /// If sigma is smaller than 0, it will be estimated from the detector 144 /// material (Moliere radius). 145 G4double fSigma = -1; 146 /// Alpha parameter of the Gamma distribution 147 /// Can be changed with UI command `/Par03/fastSim/longitudunalProfile/alpha 148 /// <alpha>` 149 /// If alpha is smaller than 0, it will be estimated from particle energy and 150 /// the detector material. 151 G4double fAlpha = -1; 152 /// Beta parameter of the Gamma distribution 153 /// Can be changed with UI command `/Par03/fastSim/longitudinalProfile/beta 154 /// <beta>` 155 G4double fBeta = 0.5; 156 /// Number of (same energy) hits created by the parametrisation. Can be 157 /// changed with UI command `/Par03/fastSim/numberOfHits <number>` 158 G4int fNbOfHits = 100; 159 /// Maximum depth of a shower created in fast simulation. 160 /// It is expressed in units of radiation length. Can be changed with UI 161 /// command `/Par03/fastSim/longitudinalProfile/maxDepth <depth>` 162 G4double fLongMaxDepth = 30; 163 }; 164 #endif /* PAR03EMSHOWERMODEL_HH */