GENIEGenerator
Loading...
Searching...
No Matches
CacheBranchFx.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
12
13using namespace genie;
14
16
17//____________________________________________________________________________
18namespace genie
19{
20 ostream & operator << (ostream & stream, const CacheBranchFx & cbntp)
21 {
22 cbntp.Print(stream);
23 return stream;
24 }
25}
26//____________________________________________________________________________
29{
30 this->Init();
31}
32//____________________________________________________________________________
35{
36 this->Init();
37 fName = name;
38}
39//____________________________________________________________________________
44//____________________________________________________________________________
46{
47 fName = "";
48 fSpline = 0;
49}
50//____________________________________________________________________________
52{
53 if(fSpline) delete fSpline;
54 fFx.clear();
55}
56//____________________________________________________________________________
58{
59 this->CleanUp();
60 this->Init();
61}
62//____________________________________________________________________________
63void CacheBranchFx::AddValues(double x, double y)
64{
65 fFx.insert(map<double,double>::value_type(x,y));
66}
67//____________________________________________________________________________
69{
70 int n = fFx.size();
71 double * x = new double[n];
72 double * y = new double[n];
73
74 int i=0;
75 map<double,double>::const_iterator iter = fFx.begin();
76 for( ; iter !=fFx.end(); ++iter) {
77 x[i] = iter->first;
78 y[i] = iter->second;
79 i++;
80 }
81
82 if(fSpline) delete fSpline;
83 fSpline = new Spline(n,x,y);
84 fSpline->SetType(type);
85
86 delete [] x;
87 delete [] y;
88}
89//____________________________________________________________________________
90void CacheBranchFx::Print(ostream & stream) const
91{
92 stream << "type: [CacheBranchFx] - nentries: " << fFx.size()
93 << " / spline: " << ((fSpline) ? "built" : "null");
94}
95//____________________________________________________________________________
96double CacheBranchFx::operator () (double x) const
97{
98 if(!fSpline) return 0;
99 else return fSpline->Evaluate(x);
100}
101//____________________________________________________________________________
ClassImp(CacheBranchFx)
A simple cache branch storing the cached data in a TNtuple.
void Print(ostream &stream) const
void CreateSpline(string type="TSpline3")
string fName
cache branch name
void AddValues(double x, double y)
Spline * fSpline
spline y = f(x)
double operator()(double x) const
map< double, double > fFx
x->y map
A numeric analysis tool class for interpolating 1-D functions.
Definition Spline.h:58
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)