Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:19:37

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 #ifndef CCalDataSet_h
0027 #define CCalDataSet_h
0028 
0029 #include "G4ParticleHPInterpolator.hh"
0030 #include <vector>
0031 
0032 // by JPW, working, but to be cleaned up. @@@@
0033 
0034 class CCalDataSet 
0035 {
0036 public:
0037 
0038   void insert(G4double anEnergy, G4double aXsection)
0039   {
0040     pair<G4double, G4double> aPoint(anEnergy, aXsection);
0041     theData.push_back(aPoint);
0042   }
0043   
0044   double getCrossSection(G4double anEnergy)
0045   {
0046     G4double result;
0047     if(anEnergy < theData[0].first)
0048     {
0049       result = 0;
0050     }
0051     else
0052     {
0053       G4double x1,x2;
0054       G4double y1,y2;
0055       if(anEnergy > theData[theData.size()-1].second)
0056       {
0057         // extrapolation
0058         G4int n=theData.size();
0059         x1 = theData[n-1].first;
0060         y1 = theData[n-1].second;
0061         x2 = theData[n-2].first;
0062         y2 = theData[n-2].second;
0063       }
0064       else
0065       {
0066         // linear search and interpolation
0067         unsigned int i;
0068         for(i=0; i<theData.size(); ++i)
0069         {
0070           if(theData[i].first>anEnergy) break;
0071         }
0072         x1 = theData[i-1].first;
0073         y1 = theData[i-1].second;
0074         x2 = theData[i].first;
0075         y2 = theData[i].second;
0076       }
0077       // interpolate logarithmic in energy and linear in cross-section
0078       result = theInterpolator.Interpolate(LOGLIN, anEnergy,  x1,x2,y1,y2);
0079     }
0080     return result*barn;
0081   }
0082 
0083 private:
0084 
0085   G4ParticleHPInterpolator theInterpolator;
0086   
0087 private:
0088 
0089   vector<pair<G4double, G4double> > theData;
0090 };
0091 #endif