Logo ROOT  
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
44public:
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.);
61 void SetExtraRange(Double_t percentage);
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
#define b(i)
Definition: RSha256.hxx:100
int Int_t
Definition: RtypesCore.h:43
double Double_t
Definition: RtypesCore.h:57
#define ClassDef(name, id)
Definition: Rtypes.h:322
float xmin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
Class wrapping convolution of two functions.
void SetNumConv(Bool_t flag=true)
std::vector< Double_t > fParams1
void Copy(TObject &obj) const
Copy this to obj.
Int_t fCstIndex
Index of the constant parameter f the first function.
void SetRange(Double_t a, Double_t b)
void GetRange(Double_t &a, Double_t &b) const
std::vector< TString > fParNames
Parameters' names.
virtual ~TF1Convolution()
std::unique_ptr< TF1 > fFunction1
First function to be convolved.
Int_t fNofPoints
Number of point for FFT array.
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)
Double_t EvalNumConv(Double_t t)
Perform numerical 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.
Double_t operator()(const Double_t *x, const Double_t *p)
Used in TF1 when doing the fit, will be evaluated at each point.
void SetParameters(const Double_t *params)
void SetNofPointsFFT(Int_t n)
TF1Convolution()
constructor without arguments
const char * GetParName(Int_t ipar) const
Double_t EvalFFTConv(Double_t t)
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)
Use copy instead of Clone.
void Update()
Update the two component functions of the convolution.
std::unique_ptr< TGraph > fGraphConv
! Graph of the convolution
1-Dim function class
Definition: TF1.h:210
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
auto * a
Definition: textangle.C:12