Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:27

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 /** \file G4INCLInterpolationTable.hh
0039  * \brief Simple interpolation table
0040  *
0041  * \date 30 January 2014
0042  * \author Davide Mancusi
0043  */
0044 
0045 #ifndef G4INCLINTERPOLATIONTABLE_HH_
0046 #define G4INCLINTERPOLATIONTABLE_HH_
0047 
0048 #include "G4INCLIFunction1D.hh"
0049 #include <algorithm>
0050 #include <functional>
0051 #include <sstream>
0052 
0053 namespace G4INCL {
0054 
0055   /// \brief Interpolation node
0056   class InterpolationNode {
0057     public:
0058       InterpolationNode(const G4double x0, const G4double y0, const G4double yPrime0) :
0059         x(x0),
0060         y(y0),
0061         yPrime(yPrime0)
0062     {}
0063 
0064       virtual ~InterpolationNode() {}
0065 
0066       G4bool operator<(const InterpolationNode &rhs) const {
0067         return (x < rhs.x);
0068       }
0069 
0070       G4bool operator<=(const InterpolationNode &rhs) const {
0071         return (x <= rhs.x);
0072       }
0073 
0074       G4bool operator>(const InterpolationNode &rhs) const {
0075         return (x > rhs.x);
0076       }
0077 
0078       G4bool operator>=(const InterpolationNode &rhs) const {
0079         return (x >= rhs.x);
0080       }
0081 
0082       G4double getX() const { return x; }
0083       G4double getY() const { return y; }
0084       G4double getYPrime() const { return yPrime; }
0085 
0086       void setX(const G4double x0) { x=x0; }
0087       void setY(const G4double y0) { y=y0; }
0088       void setYPrime(const G4double yPrime0) { yPrime=yPrime0; }
0089 
0090       std::string print() const {
0091         std::stringstream message;
0092         message << "x, y, yPrime: " << x << '\t' << y << '\t' << yPrime << '\n';
0093         return message.str();
0094       }
0095 
0096     protected:
0097       /// \brief abscissa
0098       G4double x;
0099       /// \brief function value
0100       G4double y;
0101       /// \brief function derivative
0102       G4double yPrime;
0103   };
0104 
0105   /// \brief Class for interpolating the  of a 1-dimensional function
0106   class InterpolationTable : public IFunction1D {
0107     public:
0108       InterpolationTable(std::vector<G4double> const &x, std::vector<G4double> const &y);
0109       virtual ~InterpolationTable() {}
0110 
0111       std::size_t getNumberOfNodes() const { return nodes.size(); }
0112 
0113       std::vector<G4double> getNodeAbscissae() const;
0114 
0115       std::vector<G4double> getNodeValues() const;
0116 
0117       G4double operator()(const G4double x) const;
0118 
0119       std::string print() const;
0120 
0121     protected:
0122       InterpolationTable();
0123 
0124       /// \brief Initialise the values of the node derivatives
0125       void initDerivatives();
0126 
0127       /// \brief Interpolating nodes
0128       std::vector<InterpolationNode> nodes;
0129 
0130   };
0131 
0132 }
0133 
0134 #endif // G4INCLINTERPOLATIONTABLE_HH_