GENIEGenerator
Loading...
Searching...
No Matches
genie::CacheBranchFx Class Reference

A simple cache branch storing the cached data in a TNtuple. More...

#include <CacheBranchFx.h>

Inheritance diagram for genie::CacheBranchFx:
[legend]
Collaboration diagram for genie::CacheBranchFx:
[legend]

Public Member Functions

 CacheBranchFx ()
 CacheBranchFx (string name)
 ~CacheBranchFx ()
const map< double, double > & Map (void) const
SplineSpl (void) const
void CreateSpline (string type="TSpline3")
void AddValues (double x, double y)
void Reset (void)
void Print (ostream &stream) const
double operator() (double x) const
Public Member Functions inherited from genie::CacheBranchI
virtual ~CacheBranchI ()

Private Member Functions

void Init (void)
void CleanUp (void)

Private Attributes

string fName
 cache branch name
map< double, double > fFx
 x->y map
SplinefSpline
 spline y = f(x)

Friends

ostream & operator<< (ostream &stream, const CacheBranchFx &cbntp)

Additional Inherited Members

Protected Member Functions inherited from genie::CacheBranchI
 CacheBranchI ()

Detailed Description

A simple cache branch storing the cached data in a TNtuple.

Author
Costas Andreopoulos <c.andreopoulos \at cern.ch> University of Liverpool

Update May 15, 2022 IK: Now type of spline can be: TSpline3, TSpline5 and ROOT::Math::GSLInterpolator (LINEAR, POLYNOMIAL, CSPLINE, CSPLINE_PERIODIC, AKIMA, AKIMA_PERIODIC)

References:\n [1] GENIE docdb 297
Author
Costas Andreopoulos <c.andreopoulos \at cern.ch> University of Liverpool
Igor Kakorin kakor.nosp@m.in@j.nosp@m.inr.r.nosp@m.u Joint Institute for Nuclear Research
Created:\n November 26, 2004
License:\n Copyright (c) 2003-2025, The GENIE Collaboration
For the full text of the license visit http://copyright.genie-mc.org

Definition at line 49 of file CacheBranchFx.h.

Constructor & Destructor Documentation

◆ CacheBranchFx() [1/2]

CacheBranchFx::CacheBranchFx ( void )

Definition at line 27 of file CacheBranchFx.cxx.

27 :
29{
30 this->Init();
31}

References genie::CacheBranchI::CacheBranchI(), and Init().

Referenced by operator<<.

◆ CacheBranchFx() [2/2]

CacheBranchFx::CacheBranchFx ( string name)

Definition at line 33 of file CacheBranchFx.cxx.

33 :
35{
36 this->Init();
37 fName = name;
38}
string fName
cache branch name

References genie::CacheBranchI::CacheBranchI(), fName, and Init().

◆ ~CacheBranchFx()

CacheBranchFx::~CacheBranchFx ( )

Definition at line 40 of file CacheBranchFx.cxx.

41{
42 this->CleanUp();
43}

References CleanUp().

Member Function Documentation

◆ AddValues()

◆ CleanUp()

void CacheBranchFx::CleanUp ( void )
private

Definition at line 51 of file CacheBranchFx.cxx.

52{
53 if(fSpline) delete fSpline;
54 fFx.clear();
55}
Spline * fSpline
spline y = f(x)

References fFx, and fSpline.

Referenced by Reset(), and ~CacheBranchFx().

◆ CreateSpline()

void CacheBranchFx::CreateSpline ( string type = "TSpline3")

Definition at line 68 of file CacheBranchFx.cxx.

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}

References fFx, and fSpline.

Referenced by genie::DISXSec::CacheFreeNucleonXSec(), genie::DMDISXSec::CacheFreeNucleonXSec(), genie::KineGeneratorWithCache::CacheMaxXSec(), genie::ReinSehgalRESXSecWithCache::CacheResExcitationXSec(), genie::ReinSehgalRESXSecWithCacheFast::CacheResExcitationXSec(), genie::SPPXSecWithCache::CacheResExcitationXSec(), and genie::KNOTunedQPMDISPXSec::DISRESJoinSuppressionFactor().

◆ Init()

void CacheBranchFx::Init ( void )
private

Definition at line 45 of file CacheBranchFx.cxx.

46{
47 fName = "";
48 fSpline = 0;
49}

References fName, and fSpline.

Referenced by CacheBranchFx(), CacheBranchFx(), and Reset().

◆ Map()

const map< double, double > & genie::CacheBranchFx::Map ( void ) const
inline

Definition at line 58 of file CacheBranchFx.h.

58{ return fFx; }

References fFx.

Referenced by genie::KineGeneratorWithCache::CacheMaxXSec(), and genie::KineGeneratorWithCache::FindMaxXSec().

◆ operator()()

double CacheBranchFx::operator() ( double x) const

Definition at line 96 of file CacheBranchFx.cxx.

97{
98 if(!fSpline) return 0;
99 else return fSpline->Evaluate(x);
100}

References fSpline.

◆ Print()

void CacheBranchFx::Print ( ostream & stream) const

Definition at line 90 of file CacheBranchFx.cxx.

91{
92 stream << "type: [CacheBranchFx] - nentries: " << fFx.size()
93 << " / spline: " << ((fSpline) ? "built" : "null");
94}

References fFx, and fSpline.

Referenced by operator<<.

◆ Reset()

void CacheBranchFx::Reset ( void )

Definition at line 57 of file CacheBranchFx.cxx.

58{
59 this->CleanUp();
60 this->Init();
61}

References CleanUp(), and Init().

◆ Spl()

Spline * genie::CacheBranchFx::Spl ( void ) const
inline

Definition at line 59 of file CacheBranchFx.h.

59{ return fSpline; }

References fSpline.

Referenced by genie::KineGeneratorWithCache::CacheMaxXSec(), and genie::KineGeneratorWithCache::FindMaxXSec().

◆ operator<<

ostream & operator<< ( ostream & stream,
const CacheBranchFx & cbntp )
friend

Definition at line 20 of file CacheBranchFx.cxx.

21 {
22 cbntp.Print(stream);
23 return stream;
24 }
void Print(ostream &stream) const

References CacheBranchFx(), and Print().

Member Data Documentation

◆ fFx

map<double,double> genie::CacheBranchFx::fFx
private

x->y map

Definition at line 75 of file CacheBranchFx.h.

Referenced by AddValues(), CleanUp(), CreateSpline(), Map(), and Print().

◆ fName

string genie::CacheBranchFx::fName
private

cache branch name

Definition at line 74 of file CacheBranchFx.h.

Referenced by CacheBranchFx(), and Init().

◆ fSpline

Spline* genie::CacheBranchFx::fSpline
private

spline y = f(x)

Definition at line 76 of file CacheBranchFx.h.

Referenced by CleanUp(), CreateSpline(), Init(), operator()(), Print(), and Spl().


The documentation for this class was generated from the following files: