Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:13:17

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