Logo ROOT   6.12/07
Reference Guide
TF1Convolution.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Authors: Lorenzo Moneta, AurĂ©lie Flandi 27/08/14
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2015 ROOT Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 #ifndef ROOT_TF1Convolution__
12 #define ROOT_TF1Convolution__
13 
14 #include <iostream>
15 #include "TF1.h"
16 #include "TGraph.h"
17 #include <memory>
18 #include "TF1AbsComposition.h"
19 
21  std::unique_ptr<TF1> fFunction1; ///< First function to be convolved
22  std::unique_ptr<TF1> fFunction2; ///< Second function to be convolved
23  std::unique_ptr<TGraph> fGraphConv; ///<! Graph of the convolution
24 
25  std::vector < Double_t > fParams1;
26  std::vector < Double_t > fParams2;
27 
28  std::vector< TString > fParNames; ///< Parameters' names
29 
30  Double_t fXmin; ///< Minimal bound of the range of the convolution
31  Double_t fXmax; ///< Maximal bound of the range of the convolution
34  Int_t fCstIndex; ///< Index of the constant parameter f the first function
35  Int_t fNofPoints; ///< Number of point for FFT array
36  Bool_t fFlagFFT; ///< Choose FFT or numerical convolution
37  Bool_t fFlagGraph = false; ///<! Tells if the graph is already done or not
38 
41  void InitializeDataMembers(TF1* function1, TF1* function2, Bool_t useFFT);
42  void MakeFFTConv();
43 
44 public:
46  TF1Convolution(TF1 *function1, TF1 *function2, Bool_t useFFT = true);
47  TF1Convolution(TF1 *function1, TF1 *function2, Double_t xmin, Double_t xmax, Bool_t useFFT = true);
48  TF1Convolution(TString formula, Double_t xmin = 1., Double_t xmax = 0., Bool_t useFFT = true);
49  TF1Convolution(TString formula1, TString formula2, Double_t xmin = 1., Double_t xmax = 0., Bool_t useFFT = true);
50 
51  // Copy constructor
52  TF1Convolution(const TF1Convolution &conv);
53 
55  virtual ~TF1Convolution() {}
56 
57  void SetParameters(const Double_t *params);
58  void SetParameters(Double_t p0, Double_t p1, Double_t p2 = 0., Double_t p3 = 0., Double_t p4 = 0., Double_t p5 = 0.,
59  Double_t p6 = 0., Double_t p7 = 0.);
60  void SetRange(Double_t a, Double_t b);
61  void SetExtraRange(Double_t percentage);
62  void SetNofPointsFFT(Int_t n);
63  void SetNumConv(Bool_t flag = true) { fFlagFFT = !flag; }
64 
65  Int_t GetNpar() const { return (fNofParams1 + fNofParams2); }
66  Double_t GetXmin() const { return fXmin; }
67  Double_t GetXmax() const { return fXmax; }
68  const char *GetParName(Int_t ipar) const { return fParNames.at(ipar).Data(); }
69  void GetRange(Double_t &a, Double_t &b) const;
70 
71  void Update();
72 
73  Double_t operator()(const Double_t *x, const Double_t *p);
74 
75  void Copy(TObject &obj) const;
76 
78 };
79 
80 
81 #endif
std::unique_ptr< TF1 > fFunction2
Second function to be convolved.
float xmin
Definition: THbookFile.cxx:93
static double p3(double t, double a, double b, double c, double d)
const char * GetParName(Int_t ipar) const
void Update()
Update the two component functions of the convolution.
std::unique_ptr< TF1 > fFunction1
First function to be convolved.
TF1Convolution()
constructor without arguments
Basic string class.
Definition: TString.h:125
std::vector< Double_t > fParams2
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Double_t operator()(const Double_t *x, const Double_t *p)
Used in TF1 when doing the fit, will be evaluated at each point.
TF1Convolution & operator=(const TF1Convolution &rhs)
Operator =.
Int_t fNofPoints
Number of point for FFT array.
Class wrapping convolution of two functions.
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:320
static double p2(double t, double a, double b, double c)
void MakeFFTConv()
Perform the FFT of the two functions.
void InitializeDataMembers(TF1 *function1, TF1 *function2, Bool_t useFFT)
Use copy instead of Clone.
Double_t fXmax
Maximal bound of the range of the convolution.
void SetRange(Double_t a, Double_t b)
virtual ~TF1Convolution()
auto * a
Definition: textangle.C:12
Double_t EvalNumConv(Double_t t)
Perform numerical convolution.
void SetNofPointsFFT(Int_t n)
Bool_t fFlagGraph
! Tells if the graph is already done or not
std::unique_ptr< TGraph > fGraphConv
! Graph of the convolution
static double p1(double t, double a, double b)
float xmax
Definition: THbookFile.cxx:93
Int_t GetNpar() const
double Double_t
Definition: RtypesCore.h:55
Double_t fXmin
Minimal bound of the range of the convolution.
Double_t EvalFFTConv(Double_t t)
Mother of all ROOT objects.
Definition: TObject.h:37
void Copy(TObject &obj) const
Copy this to obj.
1-Dim function class
Definition: TF1.h:211
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
Int_t fCstIndex
Index of the constant parameter f the first function.
Double_t GetXmin() const
std::vector< TString > fParNames
Parameters&#39; names.
Bool_t fFlagFFT
Choose FFT or numerical convolution.
Double_t GetXmax() const
void SetNumConv(Bool_t flag=true)
std::vector< Double_t > fParams1
const Int_t n
Definition: legend1.C:16
void GetRange(Double_t &a, Double_t &b) const
void SetExtraRange(Double_t percentage)
void SetParameters(const Double_t *params)