Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58: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 // INCL++ intra-nuclear cascade model
0027 // Alain Boudard, CEA-Saclay, France
0028 // Joseph Cugnon, University of Liege, Belgium
0029 // Jean-Christophe David, CEA-Saclay, France
0030 // Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
0031 // Sylvie Leray, CEA-Saclay, France
0032 // Davide Mancusi, CEA-Saclay, France
0033 //
0034 #define INCLXX_IN_GEANT4_MODE 1
0035 
0036 #include "globals.hh"
0037 
0038 #ifndef G4INCLGlobals_hh
0039 #define G4INCLGlobals_hh 1
0040 
0041 #include <cmath>
0042 #include <string>
0043 #include <vector>
0044 #include "G4INCLParticleType.hh"
0045 
0046 namespace G4INCL {
0047   class Particle;
0048 
0049   namespace PhysicalConstants {
0050     /// \brief \f$\hbar c\f$ [MeV*fm]
0051     const G4double hc = 197.328;
0052 
0053     /// \brief \f$\hbar^2 c^2\f$ [MeV^2*fm^2]
0054     const G4double hcSquared = hc*hc;
0055 
0056     /// \brief Fermi momentum [MeV/c]
0057     const G4double Pf = 1.37*hc;
0058     //  const G4double Pf = 1.36828*hc;
0059 
0060     /** \brief Coulomb conversion factor [MeV*fm]
0061      *
0062      * \f[ e^2/(4 pi epsilon_0) \f]
0063      */
0064     const G4double eSquared = 1.439964;
0065   }
0066 
0067   namespace Math {
0068     const G4double pi = 3.14159265358979323846264338328;
0069     const G4double twoPi = 2.0 * pi;
0070     const G4double tenPi = 10.0 * pi;
0071     const G4double piOverTwo = 0.5 * pi;
0072     const G4double oneOverSqrtTwo = 1./std::sqrt((G4double)2.);
0073     const G4double oneOverSqrtThree = 1./std::sqrt((G4double)3.);
0074     const G4double oneThird = 1./3.;
0075     const G4double twoThirds = 2./3.;
0076     const G4double sqrtFiveThirds = std::sqrt(5./3.);
0077     const G4double sqrtThreeFifths = std::sqrt(3./5.);
0078 
0079     inline G4double toDegrees(G4double radians) {
0080       return radians * (180.0 / pi);
0081     }
0082 
0083     inline G4int heaviside(G4int n) {
0084       if(n < 0) return 0;
0085       else return 1;
0086     }
0087 
0088     inline G4double pow13(G4double x) {
0089       return std::pow(x, oneThird);
0090     }
0091 
0092     inline G4double powMinus13(G4double x) {
0093       return std::pow(x, -oneThird);
0094     }
0095 
0096     inline G4double pow23(G4double x) {
0097       return std::pow(x, twoThirds);
0098     }
0099 
0100     inline G4double aSinH(G4double x) {
0101       return std::log(x + std::sqrt(x*x+1.));
0102     }
0103 
0104     /**
0105      * A simple sign function that allows us to port fortran code to c++ more easily.
0106      */
0107     template <typename T> inline G4int sign(const T t) {
0108       return t > 0 ? 1: t < 0 ? -1 : 0;
0109     }
0110 
0111     /// brief Return the largest of the two arguments
0112     template <typename T> inline T max(const T t1, const T t2) {
0113       return t1 > t2 ? t1 : t2;
0114     }
0115 
0116     /// brief Return the smallest of the two arguments
0117     template <typename T> inline T min(const T t1, const T t2) {
0118       return t1 < t2 ? t1 : t2;
0119     }
0120 
0121     /** \brief Cumulative distribution function for Gaussian
0122      *
0123      * A public-domain approximation taken from Abramowitz and Stegun. Applies
0124      * to a Gaussian with mean=0 and sigma=1.
0125      *
0126      * \param x a Gaussian variable
0127      */
0128     G4double gaussianCDF(const G4double x);
0129 
0130     /** \brief Generic cumulative distribution function for Gaussian
0131      *
0132      * A public-domain approximation taken from Abramowitz and Stegun. Applies
0133      * to a generic Gaussian.
0134      *
0135      * \param x a Gaussian variable
0136      * \param x0 mean of the Gaussian
0137      * \param sigma standard deviation of the Gaussian
0138      */
0139     G4double gaussianCDF(const G4double x, const G4double x0, const G4double sigma);
0140 
0141     /** \brief Inverse cumulative distribution function for Gaussian
0142      *
0143      * A public-domain approximation taken from Abramowitz and Stegun. Applies
0144      * to a Gaussian with mean=0 and sigma=1.
0145      *
0146      * \param x a uniform variate
0147      * \return a Gaussian variate
0148      */
0149     G4double inverseGaussianCDF(const G4double x);
0150 
0151     /// \brief Calculates arcsin with some tolerance on illegal arguments
0152     G4double arcSin(const G4double x);
0153 
0154     /// \brief Calculates arccos with some tolerance on illegal arguments
0155     G4double arcCos(const G4double x);
0156   }
0157 
0158   namespace ParticleConfig {
0159     G4bool isPair(Particle const * const p1, Particle const * const p2, ParticleType t1, ParticleType t2);
0160   }
0161 
0162 #ifndef INCLXX_IN_GEANT4_MODE
0163   namespace String {
0164     void wrap(std::string &str, const size_t lineLength=78, const std::string &separators=" \t");
0165     void replaceAll(std::string &str, const std::string &from, const std::string &to, const size_t maxPosition=std::string::npos);
0166     std::vector<std::string> tokenize(std::string const &str, const std::string &delimiters);
0167     G4bool isInteger(std::string const &str);
0168     std::string expandPath(std::string const &path);
0169   }
0170 #endif
0171 }
0172 #endif