DAS  3.0
Das Analysis System
GretaPolynomialReader< Log, Exp >

Description

template<double(*)(double) Log = log, double(*)(double) Exp = exp>
class DAS::GretaPolynomialReader< Log, Exp >

Wrapper to read series of 1D polynomials from a file

Expected format:

  • one column showing the low edge of the rapidity bin (valid until another is defined)
  • two columns showing the pt range
  • one column showing the degree (= #params - 1)
  • arbitrary number of columns containing the parameters (corresponding to the degree)

#include <Greta.h>

+ Collaboration diagram for GretaPolynomialReader< Log, Exp >:

Public Member Functions

void read (TString fname)
 
double operator() (double pt, double y)
 

Private Attributes

vector< double > ymins
 
vector< GretaPolynomial< Log, Exp > > pols
 

Member Function Documentation

◆ operator()()

double operator() ( double  pt,
double  y 
)
inline
253  {
254  y = abs(y);
255  size_t iy = ymins.size();
256  do --iy;
257  while (ymins.at(iy) > y);
258  auto& g = pols.at(iy);
259  return g(pt);
260  }

◆ read()

void read ( TString  fname)
inline
206  {
207  cout << "Reading " << fname << endl;
208  pols.clear();
209  ymins.clear();
210  ifstream infile;
211  infile.open(fname.Data());
212  if (infile.fail()) {
213  cerr << "Failure at opening the file " << fname << '\n';
214  exit(EXIT_FAILURE);
215  }
216 
217  while (infile.good()) {
218 
219  // getting values
220  double ymin, ptmin, ptmax;
221  int Npars;
222  infile >> ymin >> ptmin >> ptmax >> Npars;
223  double * pars = new double[Npars];
224  for (int i = 0; i < Npars; ++i) infile >> pars[i];
225 
226  if (infile.eof()) break;
227 
228  // instantiating
229  if (ymins.size() == 0) { assert(abs(ymin) < deps); }
230  else { assert(ymin > ymins.back()); }
231  ymins.push_back(ymin);
232  GretaPolynomial<Log,Exp> gp(pars, Npars, ptmin, ptmax);
233  pols.push_back(gp);
234  //pols.insert( { ymin, gp } );
235 
236  // print-out
237  cout << std::setw(3) << ymin
238  << std::setw(8) << (int) ptmin
239  << std::setw(8) << (int) ptmax
240  << std::setw(3) << Npars;
241  for (int j = 0; j < Npars; ++j) std::cout << std::setw(15) << pars[j];
242  cout << '\n';
243  }
244  cout << flush;
245 
246  assert(ymins.size() > 0);
247  assert(ymins.size() == pols.size());
248 
249  infile.close();
250  }

Member Data Documentation

◆ pols

vector<GretaPolynomial<Log,Exp> > pols
private

first index for low edge of rap bin

◆ ymins

vector<double> ymins
private

The documentation for this class was generated from the following file:
metPhiCorrectionExample.infile
string infile
Definition: metPhiCorrectionExample.py:25
Ntupliser_cfg.cerr
cerr
Definition: Ntupliser_cfg.py:93
jercExample.fname
fname
Definition: jercExample.py:88
jmarExample.pt
pt
Definition: jmarExample.py:19
DAS::GretaPolynomialReader::pols
vector< GretaPolynomial< Log, Exp > > pols
first index for low edge of rap bin
Definition: Greta.h:202
DAS::ymin
static const double ymin
Definition: binnings.h:48
DAS::ptmin
static const double ptmin
Definition: binnings.h:46
DAS::ptmax
static const double ptmax
Definition: binnings.h:47
DAS::GretaPolynomialReader::ymins
vector< double > ymins
Definition: Greta.h:201