G4SPSEneDistribution.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00027 //
00028 // MODULE:        G4SPSEneDistribution.hh
00029 //
00030 // Version:      1.0
00031 // Date:         5/02/04
00032 // Author:       Fan Lei 
00033 // Organisation: QinetiQ ltd.
00034 // Customer:     ESA/ESTEC
00035 //
00037 //
00038 // CHANGE HISTORY
00039 // --------------
00040 //
00041 //
00042 // Version 1.0, 05/02/2004, Fan Lei, Created.
00043 //    Based on the G4GeneralParticleSource class in Geant4 v6.0
00044 //
00046 //
00047 //
00048 // Class Description:
00049 //
00050 // To generate the energy of a primary vertex according to the defined distribution 
00051 //
00053 //
00054 // MEMBER FUNCTIONS
00055 // ----------------
00056 //
00057 // G4SPSEneDistribution ()
00058 //    Constructor: Initializes variables
00059 //
00060 // ~G4SPSEneDistribution ()
00061 //    Destructor: 
00062 //
00063 // void SetEnergyDisType(G4String)
00064 //    Allows the user to choose the energy distribution type. The arguments
00065 //    are Mono (mono-energetic), Lin (linear), Pow (power-law), Exp 
00066 //    (exponential), Gauss (gaussian), Brem (bremsstrahlung), BBody (black-body), Cdg
00067 //    (cosmic diffuse gamma-ray), User (user-defined), Arb (arbitrary
00068 //    point-wise), Epn (energy per nucleon).
00069 //
00070 // void SetEmin(G4double)
00071 //    Sets the minimum energy.
00072 //
00073 // void SetEmax(G4double)
00074 //    Sets the maximum energy.
00075 //
00076 // void SetMonoEnergy(G4double)
00077 //    Sets energy for mono-energetic distribution.
00078 //
00079 // void SetAlpha(G4double)
00080 //    Sets alpha for a power-law distribution.
00081 //
00082 // void SetTemp(G4double)
00083 //    Sets Temperature for a Brem or BBody distributions.
00084 //
00085 // void SetEzero(G4double)
00086 //    Sets Ezero for an exponential distribution.
00087 //
00088 // void SetGradient(G4double)
00089 //    Sets gradient for a linear distribution.
00090 //
00091 // void SetInterCept(G4double)
00092 //    Sets intercept for a linear distribution.
00093 //
00094 // void UserEnergyHisto(G4ThreeVector)
00095 //    Allows user to defined a histogram for the energy distribution.
00096 //
00097 // void ArbEnergyHisto(G4ThreeVector)
00098 //    Allows the user to define an Arbitrary set of points for the
00099 //    energy distribution.
00100 //
00101 // void EpnEnergyHisto(G4ThreeVector)
00102 //    Allows the user to define an Energy per nucleon histogram.
00103 //
00104 // void Calculate()
00105 //    Controls the calculation of Integral PDF for the Cdg and BBody
00106 //    distributions.
00107 //
00108 // void InputEnergySpectra(G4bool)
00109 //    Allows the user to choose between momentum and energy histograms
00110 //    for user-defined histograms and arbitrary point-wise spectr.
00111 //    The default is true (energy).
00112 //
00113 // void InputDifferentialSpectra(G4bool)
00114 //    Allows the user to choose between integral and differential 
00115 //    distributions when using the arbitrary point-wise option.
00116 //
00117 // void ArbInterpolate(G4String)
00118 //    ArbInterpolate allows the user to specify the type of function to
00119 //    interpolate the Arbitrary points spectrum with.
00120 //
00121 //  void SetBiasRndm (G4SPSRandomGenerator* a)
00122 //    Sets the biased random number generator
00123 //
00124 //  G4double GenerateOne(G4ParticleDefinition*);
00125 //    Generate one random energy for the specified particle
00126 //
00127 //  void ReSetHist(G4String);
00128 //    Re-sets the histogram for user defined distribution
00129 //
00130 // void SetVerbosity(G4int)
00131 //    Sets the verbosity level.
00132 //
00134 
00135 #ifndef G4SPSEneDistribution_h
00136 #define G4SPSEneDistribution_h 1
00137 
00138 #include "G4PhysicsOrderedFreeVector.hh"
00139 #include "G4ParticleMomentum.hh"
00140 #include "G4ParticleDefinition.hh"
00141 #include "G4DataInterpolation.hh"
00142 
00143 //
00144 #include "G4SPSRandomGenerator.hh"
00145 
00146 class G4SPSEneDistribution {
00147 public:
00148         G4SPSEneDistribution();
00149         ~G4SPSEneDistribution();
00150 
00151         void SetEnergyDisType(G4String);
00152         inline G4String GetEnergyDisType() {
00153                 return EnergyDisType;
00154         }
00155         ;
00156         void SetEmin(G4double);
00157         inline G4double GetEmin() {
00158                 return Emin;
00159         }
00160         ;
00161         inline G4double GetArbEmin() {
00162                 return ArbEmin;
00163         }
00164         ;
00165         void SetEmax(G4double);
00166         inline G4double GetEmax() {
00167                 return Emax;
00168         }
00169         ;
00170         inline G4double GetArbEmax() {
00171                 return ArbEmax;
00172         }
00173         ;
00174         void SetMonoEnergy(G4double);
00175         void SetAlpha(G4double);
00176         void SetBiasAlpha(G4double);
00177         void SetTemp(G4double);
00178         void SetBeamSigmaInE(G4double);
00179         void SetEzero(G4double);
00180         void SetGradient(G4double);
00181         void SetInterCept(G4double);
00182         void UserEnergyHisto(G4ThreeVector);
00183         void ArbEnergyHisto(G4ThreeVector);
00184         void ArbEnergyHistoFile(G4String);
00185         void EpnEnergyHisto(G4ThreeVector);
00186 
00187         void InputEnergySpectra(G4bool);
00188         void InputDifferentialSpectra(G4bool);
00189         void ArbInterpolate(G4String);
00190         inline G4String GetIntType() {
00191                 return IntType;
00192         }
00193         ;
00194         void Calculate();
00195         //
00196         void SetBiasRndm(G4SPSRandomGenerator* a) {
00197                 eneRndm = a;
00198         }
00199         ;
00200         // method to re-set the histograms
00201         void ReSetHist(G4String);
00202         // Set the verbosity level.
00203         void SetVerbosity(G4int a) {
00204                 verbosityLevel = a;
00205         }
00206         ;
00207         //x
00208         G4double GetWeight() {
00209                 return weight;
00210         }
00211 
00212         G4double GetMonoEnergy() {
00213                 return MonoEnergy;
00214         }
00215         ; //Mono-energteic energy
00216         G4double GetSE() {
00217                 return SE;
00218         }
00219         ; // Standard deviation for Gaussion distrbution in energy
00220         G4double Getalpha() {
00221                 return alpha;
00222         }
00223         ; // alpha (pow)
00224         G4double GetEzero() {
00225                 return Ezero;
00226         }
00227         ; // E0 (exp)
00228         G4double GetTemp() {
00229                 return Temp;
00230         }
00231         ; // Temp (bbody,brem)
00232         G4double Getgrad() {
00233                 return grad;
00234         }
00235         ; // gradient and intercept for linear spectra
00236         G4double Getcept() {
00237                 return cept;
00238         }
00239         ;
00240 
00241         inline G4PhysicsOrderedFreeVector GetUserDefinedEnergyHisto() {
00242                 return UDefEnergyH;
00243         }
00244         ;
00245         inline G4PhysicsOrderedFreeVector GetArbEnergyHisto() {
00246                 return ArbEnergyH;
00247         }
00248         ;
00249 
00250         G4double GenerateOne(G4ParticleDefinition*);
00251         G4double GetProbability (G4double);
00252 
00253 
00254 private:
00255         void LinearInterpolation();
00256         void LogInterpolation();
00257         void ExpInterpolation();
00258         void SplineInterpolation();
00259         void CalculateCdgSpectrum();
00260         void CalculateBbodySpectrum();
00261 
00262         // The following methods generate energies according to the spectral
00263         // parameters defined above.
00264         void GenerateMonoEnergetic();
00265         void GenerateLinearEnergies(G4bool);
00266         void GeneratePowEnergies(G4bool);
00267         void GenerateBiasPowEnergies();
00268         void GenerateExpEnergies(G4bool);
00269         void GenerateGaussEnergies();
00270         void GenerateBremEnergies();
00271         void GenerateBbodyEnergies();
00272         void GenerateCdgEnergies();
00273         void GenUserHistEnergies();
00274         void GenEpnHistEnergies();
00275         void GenArbPointEnergies();
00276         // converts energy per nucleon to energy.
00277         void ConvertEPNToEnergy();
00278 
00279 
00280 private:
00281 
00282         G4String EnergyDisType; // energy dis type Variable  - Mono,Lin,Exp,etc
00283         G4double weight; // particle weight
00284         G4double MonoEnergy; //Mono-energteic energy
00285         G4double SE; // Standard deviation for Gaussion distrbution in energy
00286         G4double Emin, Emax; // emin and emax
00287         G4double alpha, Ezero, Temp; // alpha (pow), E0 (exp) and Temp (bbody,brem)
00288         G4double biasalpha; // biased power index
00289         G4double grad, cept; // gradient and intercept for linear spectra
00290         G4double prob_norm; // normalisation factor use in calculate the probability 
00291         G4bool Biased; // true - biased to power-law
00292         G4bool EnergySpec; // true - energy spectra, false - momentum spectra
00293         G4bool DiffSpec; // true - differential spec, false integral spec
00294         //G4bool ApplyRig; // false no rigidity cutoff, true then apply one
00295         //G4double ERig; // energy of rigidity cutoff
00296         G4PhysicsOrderedFreeVector UDefEnergyH; // energy hist data
00297         G4PhysicsOrderedFreeVector IPDFEnergyH;
00298         G4bool IPDFEnergyExist, IPDFArbExist, Epnflag;
00299         G4PhysicsOrderedFreeVector ArbEnergyH; // Arb x,y histogram
00300         G4PhysicsOrderedFreeVector IPDFArbEnergyH; // IPDF for Arb
00301         G4PhysicsOrderedFreeVector EpnEnergyH;
00302         G4double CDGhist[3]; // cumulative histo for cdg
00303         G4double BBHist[10001], Bbody_x[10001];
00304         G4String IntType; // Interpolation type
00305         G4double Arb_grad[1024], Arb_cept[1024]; // grad and cept for 1024 segments
00306         G4double Arb_alpha[1024], Arb_Const[1024]; // alpha and constants
00307         G4double Arb_ezero[1024]; // ezero
00308         G4double ArbEmin, ArbEmax; // Emin and Emax for the whole arb distribution used primarily for debug.
00309 
00310         G4double particle_energy;
00311         G4ParticleDefinition* particle_definition;
00312 
00313         G4SPSRandomGenerator* eneRndm;
00314 
00315         // Verbosity
00316         G4int verbosityLevel;
00317 
00318         G4PhysicsOrderedFreeVector ZeroPhysVector; // for re-set only
00319 
00320         G4DataInterpolation *SplineInt[1024]; // holds Spline stuff required for sampling
00321         G4DataInterpolation *Splinetemp; // holds a temp Spline used for calculating area
00322 
00323 };
00324 
00325 #endif
00326 

Generated on Mon May 27 17:49:52 2013 for Geant4 by  doxygen 1.4.7