MaCh3  2.4.2
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 148 of file SplineStructs.h.

Constructor & Destructor Documentation

◆ TF1_red() [1/3]

TF1_red::TF1_red ( )
inline

Empty constructor.

Definition at line 152 of file SplineStructs.h.

153  length = 0;
154  Par = nullptr;
155  }
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 158 of file SplineStructs.h.

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

◆ 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 166 of file SplineStructs.h.

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

◆ TF1_red() [3/3]

TF1_red::TF1_red ( TF1 *&  Function)
inline

The TF1 constructor with deep copy.

Definition at line 174 of file SplineStructs.h.

175  Par = nullptr;
176  SetFunc(Function);
177  }
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 246 of file SplineStructs.h.

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

◆ Eval()

double TF1_red::Eval ( const double  var)
inlineoverridevirtual

Evaluate a variation.

Implements TResponseFunction_red.

Definition at line 192 of file SplineStructs.h.

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

◆ GetNp()

M3::int_t TF1_red::GetNp ( )
inlineoverridevirtual

DL: Get number of points.

Implements TResponseFunction_red.

Definition at line 255 of file SplineStructs.h.

255 { return length; }

◆ GetParameter()

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

Get a parameter value.

Definition at line 220 of file SplineStructs.h.

220  {
221  if (Parameter > length) {
222  MACH3LOG_ERROR("You requested parameter number {} but length is {} parameters", Parameter, length);
223  throw MaCh3Exception(__FILE__ , __LINE__ );
224  return -999.999;
225  }
226  return Par[Parameter];
227  }
#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 235 of file SplineStructs.h.

235 { return length; }

◆ Print()

void TF1_red::Print ( )
inlineoverridevirtual

Print detailed info.

Implements TResponseFunction_red.

Definition at line 237 of file SplineStructs.h.

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

◆ SetFunc()

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

Set the function.

Definition at line 180 of file SplineStructs.h.

180  {
181  length = M3::int_t(Func->GetNpar());
182  if (Par != nullptr) delete[] Par;
183  Par = new M3::float_t[length];
184  for (int i = 0; i < length; ++i) {
185  Par[i] = M3::float_t(Func->GetParameter(i));
186  }
187  delete Func;
188  Func = nullptr;
189  }
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 215 of file SplineStructs.h.

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

◆ SetSize()

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

Set the size.

Definition at line 230 of file SplineStructs.h.

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

Member Data Documentation

◆ length

M3::int_t TF1_red::length
private

Definition at line 260 of file SplineStructs.h.

◆ Par

M3::float_t* TF1_red::Par
private

The parameters.

Definition at line 259 of file SplineStructs.h.


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