Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
20 class TF1Convolution : public TF1AbsComposition {
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
32  Int_t fNofParams1;
33  Int_t fNofParams2;
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 
39  Double_t EvalNumConv(Double_t t);
40  Double_t EvalFFTConv(Double_t t);
41  void InitializeDataMembers(TF1* function1, TF1* function2, Bool_t useFFT);
42  void MakeFFTConv();
43 
44 public:
45  TF1Convolution();
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 
54  TF1Convolution &operator=(const TF1Convolution &rhs);
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 
77  ClassDef(TF1Convolution, 1);
78 };
79 
80 
81 #endif