Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:26

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 // G4VRangeToEnergyConverter
0027 //
0028 // Class description:
0029 //
0030 // Base class for Range to Energy Converters.
0031 // Cut in energy corresponding to given cut value in range
0032 // is calculated for a material by using Convert() method.
0033 
0034 // Author: H.Kurashige, 05 October 2002 - First implementation
0035 // --------------------------------------------------------------------
0036 #ifndef G4VRangeToEnergyConverter_hh
0037 #define G4VRangeToEnergyConverter_hh 1
0038 
0039 #include <vector>
0040 
0041 #include "globals.hh"
0042 #include "G4ParticleDefinition.hh"
0043 #include "G4Material.hh"
0044 
0045 class G4VRangeToEnergyConverter
0046 {
0047 public:
0048 
0049   explicit G4VRangeToEnergyConverter();
0050 
0051   virtual ~G4VRangeToEnergyConverter();
0052 
0053   // operators are not used
0054   G4VRangeToEnergyConverter(const G4VRangeToEnergyConverter& r) = delete;
0055   G4VRangeToEnergyConverter& operator=
0056   (const G4VRangeToEnergyConverter &r) = delete;
0057   G4bool operator==(const G4VRangeToEnergyConverter& r) const = delete;
0058   G4bool operator!=(const G4VRangeToEnergyConverter& r) const = delete;
0059 
0060   // Calculate energy cut from given range cut for the material
0061   virtual G4double Convert(const G4double rangeCut, const G4Material* material);
0062 
0063   // Set energy range for all particle type
0064   // if highedge > 10 GeV, highedge value is not changed
0065   static void SetEnergyRange(const G4double lowedge, const G4double highedge);
0066 
0067   // Get energy range for all particle type
0068   static G4double GetLowEdgeEnergy();
0069   static G4double GetHighEdgeEnergy();
0070 
0071   // Get/set max cut energy for all particle type
0072   // No check on the value
0073   static G4double GetMaxEnergyCut();
0074   static void SetMaxEnergyCut(const G4double value);
0075   
0076   // Return pointer to the particle type which this converter takes care of
0077   inline const G4ParticleDefinition* GetParticleType() const;
0078 
0079   inline void SetVerboseLevel(G4int value);
0080   inline G4int GetVerboseLevel() const;
0081       // control flag for output message
0082       //  0: Silent
0083       //  1: Warning message
0084       //  2: More
0085 
0086 protected:
0087 
0088   virtual G4double ComputeValue(const G4int Z, const G4double kinEnergy) = 0;
0089 
0090 private:
0091 
0092   static void FillEnergyVector(const G4double emin, const G4double emax);
0093 
0094   G4double ConvertForGamma(const G4double rangeCut, const G4Material* material);
0095 
0096   G4double ConvertForElectron(const G4double rangeCut, 
0097                               const G4Material* material);
0098 
0099   inline G4double LiniearInterpolation(const G4double e1, const G4double e2, 
0100                                        const G4double r1, const G4double r2, 
0101                                        const G4double r);
0102 
0103 protected:
0104 
0105   const G4ParticleDefinition* theParticle = nullptr;
0106   G4int fPDG = 0;
0107 
0108 private:
0109 
0110   static G4double sEmin;
0111   static G4double sEmax; 
0112   static std::vector<G4double>* sEnergy;
0113   static G4int sNbinPerDecade;
0114   static G4int sNbin;
0115 
0116   G4int verboseLevel = 1;
0117   G4bool isFirstInstance = false;
0118 };
0119 
0120 // ------------------
0121 // Inline methods
0122 // ------------------
0123 
0124 inline 
0125 void G4VRangeToEnergyConverter::SetVerboseLevel(G4int value)
0126 {
0127   verboseLevel = value;
0128 }
0129 
0130 inline 
0131 G4int G4VRangeToEnergyConverter::GetVerboseLevel() const
0132 {
0133   return verboseLevel;
0134 }
0135 
0136 inline 
0137 const G4ParticleDefinition* G4VRangeToEnergyConverter::GetParticleType() const
0138 {
0139   return theParticle;
0140 }
0141 
0142 inline G4double G4VRangeToEnergyConverter::LiniearInterpolation(
0143                 const G4double e1, const G4double e2, 
0144                 const G4double r1, const G4double r2, const G4double r)
0145 {
0146   return (r1 == r2) ? e1 : e1 + (e2 - e1)*(r - r1)/(r2 - r1);
0147 }
0148 
0149 #endif