Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TF1AbsComposition.h"
15#include <memory>
16#include <vector>
17#include "TF1.h"
18#include "TGraph.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 static Double_t fgExtraRangeFraction; ///<! Additional default fraction of the range used for FFT convolution
39
42 void InitializeDataMembers(TF1* function1, TF1* function2, Bool_t useFFT);
43 void MakeFFTConv();
44
45public:
47 TF1Convolution(TF1 *function1, TF1 *function2, Bool_t useFFT = true);
48 TF1Convolution(TF1 *function1, TF1 *function2, Double_t xmin, Double_t xmax, Bool_t useFFT = true);
49 TF1Convolution(TString formula, Double_t xmin = 1., Double_t xmax = 0., Bool_t useFFT = true);
50 TF1Convolution(TString formula1, TString formula2, Double_t xmin = 1., Double_t xmax = 0., Bool_t useFFT = true);
51
52 // Copy constructor
53 TF1Convolution(const TF1Convolution &conv);
54
56 ~TF1Convolution() override {}
57
58 void SetParameters(const Double_t *params) override;
59 void SetParameters(Double_t p0, Double_t p1, Double_t p2 = 0., Double_t p3 = 0., Double_t p4 = 0., Double_t p5 = 0.,
60 Double_t p6 = 0., Double_t p7 = 0.);
61 void SetRange(Double_t a, Double_t b) override;
62 void SetExtraRange(Double_t percentage);
64 void SetNumConv(Bool_t flag = true) { fFlagFFT = !flag; }
65
66 static Double_t SetDefaultExtraRange(Double_t percentage);
67
68 Int_t GetNpar() const { return (fNofParams1 + fNofParams2); }
69 Double_t GetXmin() const { return fXmin; }
70 Double_t GetXmax() const { return fXmax; }
71 const char *GetParName(Int_t ipar) const { return fParNames.at(ipar).Data(); }
72 void GetRange(Double_t &a, Double_t &b) const;
73
74 void Update() override;
75
76 Double_t operator()(const Double_t *x, const Double_t *p) override;
77
78 void Copy(TObject &obj) const override;
79
81};
82
83
84#endif
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
winID h TVirtualViewer3D TVirtualGLPainter p
float xmin
float xmax
Class wrapping convolution of two functions.
void SetNumConv(Bool_t flag=true)
std::vector< Double_t > fParams1
Double_t operator()(const Double_t *x, const Double_t *p) override
Used in TF1 when doing the fit, will be evaluated at each point.
void SetParameters(const Double_t *params) override
Set the vector of parameters p for the convolution function g(x,p) = f1 * f2.
~TF1Convolution() override
Int_t fCstIndex
Index of the constant parameter f the first function.
void GetRange(Double_t &a, Double_t &b) const
Get the range used for the convolution.
std::vector< TString > fParNames
Parameters' names.
std::unique_ptr< TF1 > fFunction1
First function to be convolved.
Int_t fNofPoints
Number of point for FFT array.
static Double_t SetDefaultExtraRange(Double_t percentage)
Set the default extra range fraction used when doing a FFT convolution.
Double_t GetXmin() const
std::vector< Double_t > fParams2
Double_t fXmin
Minimal bound of the range of the convolution.
Int_t GetNpar() const
void SetExtraRange(Double_t percentage)
Set the fraction of extra range used when doing an FFT convolution.
void Copy(TObject &obj) const override
Copy this to obj.
Double_t EvalNumConv(Double_t t)
Perform numerical convolution.
void Update() override
Update the two component functions of the convolution.
void SetRange(Double_t a, Double_t b) override
Set the actual range used for the convolution.
Bool_t fFlagFFT
Choose FFT or numerical convolution.
Double_t GetXmax() const
TF1Convolution & operator=(const TF1Convolution &rhs)
Operator =.
void MakeFFTConv()
Perform the FFT of the two functions.
static Double_t fgExtraRangeFraction
! Additional default fraction of the range used for FFT convolution
void SetNofPointsFFT(Int_t n)
Set the number of points used for the FFT convolution.
TF1Convolution()
constructor without arguments.
const char * GetParName(Int_t ipar) const
Double_t EvalFFTConv(Double_t t)
Perform FFT convolution.
Double_t fXmax
Maximal bound of the range of the convolution.
std::unique_ptr< TF1 > fFunction2
Second function to be convolved.
Bool_t fFlagGraph
! Tells if the graph is already done or not
void InitializeDataMembers(TF1 *function1, TF1 *function2, Bool_t useFFT)
Internal function to initialize data members.
std::unique_ptr< TGraph > fGraphConv
! Graph of the convolution
1-Dim function class
Definition TF1.h:233
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16