MaCh3  2.5.0
Reference Guide
Public Member Functions | Private Attributes | List of all members
TF1_red Class Reference

CW: A reduced TF1 class only. Only saves parameters for each TF1 and how many parameters each parameter set has. More...

#include <Splines/SplineStructs.h>

Inheritance diagram for TF1_red:
[legend]
Collaboration diagram for TF1_red:
[legend]

Public Member Functions

 TF1_red ()
 Empty constructor. More...
 
virtual ~TF1_red ()
 Empty destructor. More...
 
 TF1_red (M3::int_t nSize, M3::float_t *Array)
 The useful constructor with deep copy. More...
 
 TF1_red (TF1 *&Function)
 The TF1 constructor with deep copy. More...
 
void SetFunc (TF1 *&Func)
 Set the function. More...
 
double Eval (const double var) override
 Evaluate a variation. More...
 
void SetParameter (M3::int_t Parameter, M3::float_t Value)
 Set a parameter to a value. More...
 
double GetParameter (M3::int_t Parameter)
 Get a parameter value. More...
 
void SetSize (M3::int_t nSpline)
 Set the size. More...
 
int GetSize ()
 Get the size. More...
 
void Print () override
 Print detailed info. More...
 
TF1 * ConstructTF1 (const std::string &function, const int xmin, const int xmax)
 KS: Make a TF1 from the reduced TF1. More...
 
M3::int_t GetNp () override
 DL: Get number of points. More...
 
- Public Member Functions inherited from TResponseFunction_red
 TResponseFunction_red ()
 Empty constructor. More...
 
virtual ~TResponseFunction_red ()
 Empty destructor. More...
 

Private Attributes

M3::float_tPar
 The parameters. More...
 
M3::int_t length
 

Detailed Description

CW: A reduced TF1 class only. Only saves parameters for each TF1 and how many parameters each parameter set has.

Definition at line 149 of file SplineStructs.h.

Constructor & Destructor Documentation

◆ TF1_red() [1/3]

TF1_red::TF1_red ( )
inline

Empty constructor.

Definition at line 153 of file SplineStructs.h.

154  length = 0;
155  Par = nullptr;
156  }
M3::int_t length
M3::float_t * Par
The parameters.
TResponseFunction_red()
Empty constructor.

◆ ~TF1_red()

virtual TF1_red::~TF1_red ( )
inlinevirtual

Empty destructor.

Definition at line 159 of file SplineStructs.h.

159  {
160  if (Par != NULL) {
161  delete[] Par;
162  Par = nullptr;
163  }
164  }

◆ TF1_red() [2/3]

TF1_red::TF1_red ( M3::int_t  nSize,
M3::float_t Array 
)
inline

The useful constructor with deep copy.

Definition at line 167 of file SplineStructs.h.

168  length = nSize;
169  for (int i = 0; i < length; ++i) {
170  Par[i] = Array[i];
171  }
172  }

◆ TF1_red() [3/3]

TF1_red::TF1_red ( TF1 *&  Function)
inline

The TF1 constructor with deep copy.

Definition at line 175 of file SplineStructs.h.

176  Par = nullptr;
177  SetFunc(Function);
178  }
void SetFunc(TF1 *&Func)
Set the function.

Member Function Documentation

◆ ConstructTF1()

TF1* TF1_red::ConstructTF1 ( const std::string &  function,
const int  xmin,
const int  xmax 
)
inline

KS: Make a TF1 from the reduced TF1.

Definition at line 247 of file SplineStructs.h.

247  {
248  TF1 *func = new TF1("TF1", function.c_str(), xmin, xmax);
249  for(int i = 0; i < length; ++i) {
250  func->SetParameter(i, Par[i]);
251  }
252  return func;
253  }

◆ Eval()

double TF1_red::Eval ( const double  var)
inlineoverridevirtual

Evaluate a variation.

Implements TResponseFunction_red.

Definition at line 193 of file SplineStructs.h.

193  {
194  return Par[1]+Par[0]*var;
195 
196  /* FIXME in future we might introduce more TF1
197  //If we have 5 parameters we're using a fifth order polynomial
198  if (Type == kFifthOrderPolynomial) {
199  return 1+Par[0]*var+Par[1]*var*var+Par[2]*var*var*var+Par[3]*var*var*var*var+Par[4]*var*var*var*var*var;
200  } else if (Type == kTwoLinears) {
201  return (var <= 0)*(Par[2]+Par[0]*var)+(var > 0)*(Par[2]+Par[1]*var);
202  } else if (Type == kLinear) {
203  return (Par[1]+Par[0]*var);
204  } else if (Type == kPseudoHeaviside) {
205  return (var <= 0)*(1+Par[0]*var) + (1 >= var)*(var > 0)*(1+Par[1]*var) + (var > 1)*(Par[3]+Par[2]*var);
206  }else {
207  MACH3LOG_ERROR(" Class only knows about 5th order polynomial, two superposed linear functions, linear function, or pseudo Heaviside.");
208  MACH3LOG_ERROR(" You have tried something else than this, which remains unimplemented.");
209  MACH3LOG_ERROR("{}: {}", __FILE__, __LINE__);
210  throw MaCh3Exception(__FILE__ , __LINE__ );
211  }
212  */
213  }

◆ GetNp()

M3::int_t TF1_red::GetNp ( )
inlineoverridevirtual

DL: Get number of points.

Implements TResponseFunction_red.

Definition at line 256 of file SplineStructs.h.

256 { return length; }

◆ GetParameter()

double TF1_red::GetParameter ( M3::int_t  Parameter)
inline

Get a parameter value.

Definition at line 221 of file SplineStructs.h.

221  {
222  if (Parameter > length) {
223  MACH3LOG_ERROR("You requested parameter number {} but length is {} parameters", Parameter, length);
224  throw MaCh3Exception(__FILE__ , __LINE__ );
225  return -999.999;
226  }
227  return Par[Parameter];
228  }
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:37
Custom exception class used throughout MaCh3.

◆ GetSize()

int TF1_red::GetSize ( )
inline

Get the size.

Definition at line 236 of file SplineStructs.h.

236 { return length; }

◆ Print()

void TF1_red::Print ( )
inlineoverridevirtual

Print detailed info.

Implements TResponseFunction_red.

Definition at line 238 of file SplineStructs.h.

238  {
239  MACH3LOG_INFO("Printing TF1_red:");
240  MACH3LOG_INFO(" Length = {}", length);
241  for (int i = 0; i < length; i++) {
242  MACH3LOG_INFO(" Coeff {} = {}", i, Par[i]);
243  }
244  }
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:35

◆ SetFunc()

void TF1_red::SetFunc ( TF1 *&  Func)
inline

Set the function.

Definition at line 181 of file SplineStructs.h.

181  {
182  length = M3::int_t(Func->GetNpar());
183  if (Par != nullptr) delete[] Par;
184  Par = new M3::float_t[length];
185  for (int i = 0; i < length; ++i) {
186  Par[i] = M3::float_t(Func->GetParameter(i));
187  }
188  delete Func;
189  Func = nullptr;
190  }
double float_t
Definition: Core.h:37
int int_t
Definition: Core.h:38

◆ SetParameter()

void TF1_red::SetParameter ( M3::int_t  Parameter,
M3::float_t  Value 
)
inline

Set a parameter to a value.

Definition at line 216 of file SplineStructs.h.

216  {
217  Par[Parameter] = Value;
218  }

◆ SetSize()

void TF1_red::SetSize ( M3::int_t  nSpline)
inline

Set the size.

Definition at line 231 of file SplineStructs.h.

231  {
232  length = nSpline;
233  Par = new M3::float_t[length];
234  }

Member Data Documentation

◆ length

M3::int_t TF1_red::length
private

Definition at line 261 of file SplineStructs.h.

◆ Par

M3::float_t* TF1_red::Par
private

The parameters.

Definition at line 260 of file SplineStructs.h.


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