Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /irt/include/DataInterpolation.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // Copyright 2025, Alexander Kiselev
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 //
0005 // GEANT G4DataInterpolation emulation class
0006 //
0007 
0008 #include <iterator>
0009 #include <utility>
0010 #include <vector>
0011 
0012 #pragma once
0013 
0014 class DataInterpolation {
0015 public:
0016   DataInterpolation(const double WL[], const double QE[], unsigned dim) : m_LookupTableStep(0.0) {
0017     for (unsigned iq = 0; iq < dim; iq++)
0018       m_RawData.push_back(std::make_pair(WL[iq], QE[iq]));
0019   };
0020   ~DataInterpolation() {};
0021 
0022   enum order { ZeroOrder, FirstOrder };
0023 
0024   void CreateLookupTable(unsigned nbins);
0025 
0026   bool WithinRange(double x) const;
0027   double GetInterpolatedValue(double x, DataInterpolation::order order) const;
0028 
0029 private:
0030   std::vector<std::pair<double, double>> m_RawData;
0031 
0032   double m_LookupTableStep;
0033   std::vector<std::pair<double, double>> m_LookupTable;
0034 };