MaCh3  2.2.3
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 150 of file SplineStructs.h.

Constructor & Destructor Documentation

◆ TF1_red() [1/3]

TF1_red::TF1_red ( )
inline

Empty constructor.

Definition at line 154 of file SplineStructs.h.

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

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

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

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

◆ TF1_red() [3/3]

TF1_red::TF1_red ( TF1 *&  Function)
inline

The TF1 constructor with deep copy.

Definition at line 176 of file SplineStructs.h.

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

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

◆ Eval()

double TF1_red::Eval ( const double  var)
inlineoverridevirtual

Evaluate a variation.

Implements TResponseFunction_red.

Definition at line 194 of file SplineStructs.h.

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

◆ GetNp()

M3::int_t TF1_red::GetNp ( )
inlineoverridevirtual

DL: Get number of points.

Implements TResponseFunction_red.

Definition at line 257 of file SplineStructs.h.

257 { return length; }

◆ GetParameter()

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

Get a parameter value.

Definition at line 222 of file SplineStructs.h.

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

◆ GetSize()

int TF1_red::GetSize ( )
inline

Get the size.

Definition at line 237 of file SplineStructs.h.

237 { return length; }

◆ Print()

void TF1_red::Print ( )
inlineoverridevirtual

Print detailed info.

Implements TResponseFunction_red.

Definition at line 239 of file SplineStructs.h.

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

◆ SetFunc()

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

Set the function.

Definition at line 182 of file SplineStructs.h.

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

◆ SetParameter()

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

Set a parameter to a value.

Definition at line 217 of file SplineStructs.h.

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

◆ SetSize()

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

Set the size.

Definition at line 232 of file SplineStructs.h.

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

Member Data Documentation

◆ length

M3::int_t TF1_red::length
private

Definition at line 262 of file SplineStructs.h.

◆ Par

M3::float_t* TF1_red::Par
private

The parameters.

Definition at line 261 of file SplineStructs.h.


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