MaCh3  2.6.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) const 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) const
 Get a parameter value. More...
 
void SetSize (M3::int_t nSpline)
 Set the size. More...
 
int GetSize () const
 Get the size. More...
 
void Print () const 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 () const 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 151 of file SplineStructs.h.

Constructor & Destructor Documentation

◆ TF1_red() [1/3]

TF1_red::TF1_red ( )
inline

Empty constructor.

Definition at line 155 of file SplineStructs.h.

156  length = 0;
157  Par = nullptr;
158  }
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 161 of file SplineStructs.h.

161  {
162  if (Par != nullptr) {
163  delete[] Par;
164  Par = nullptr;
165  }
166  }

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

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

◆ TF1_red() [3/3]

TF1_red::TF1_red ( TF1 *&  Function)
inline

The TF1 constructor with deep copy.

Definition at line 177 of file SplineStructs.h.

178  Par = nullptr;
179  SetFunc(Function);
180  }
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 249 of file SplineStructs.h.

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

◆ Eval()

double TF1_red::Eval ( const double  var) const
inlineoverridevirtual

Evaluate a variation.

Implements TResponseFunction_red.

Definition at line 195 of file SplineStructs.h.

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

◆ GetNp()

M3::int_t TF1_red::GetNp ( ) const
inlineoverridevirtual

DL: Get number of points.

Implements TResponseFunction_red.

Definition at line 258 of file SplineStructs.h.

258 { return length; }

◆ GetParameter()

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

Get a parameter value.

Definition at line 223 of file SplineStructs.h.

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

◆ GetSize()

int TF1_red::GetSize ( ) const
inline

Get the size.

Definition at line 238 of file SplineStructs.h.

238 { return length; }

◆ Print()

void TF1_red::Print ( ) const
inlineoverridevirtual

Print detailed info.

Implements TResponseFunction_red.

Definition at line 240 of file SplineStructs.h.

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

◆ SetFunc()

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

Set the function.

Definition at line 183 of file SplineStructs.h.

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

218  {
219  Par[Parameter] = Value;
220  }

◆ SetSize()

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

Set the size.

Definition at line 233 of file SplineStructs.h.

233  {
234  length = nSpline;
235  Par = new M3::float_t[length];
236  }

Member Data Documentation

◆ length

M3::int_t TF1_red::length
private

Definition at line 263 of file SplineStructs.h.

◆ Par

M3::float_t* TF1_red::Par
private

The parameters.

Definition at line 262 of file SplineStructs.h.


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