Logo ROOT   6.12/07
Reference Guide
TF1NormSum.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_TF1NormSum__
12 #define ROOT_TF1NormSum__
13 
14 #include <iostream>
15 #include "TF1.h"
16 #include <memory>
17 #include "TF1AbsComposition.h"
18 
19 class TF1NormSum : public TF1AbsComposition {
20 
21 protected:
22  unsigned int fNOfFunctions; ///< Number of functions to add
23  Double_t fScale; ///< Fixed Scale parameter to normalize function (e.g. bin width)
24  Double_t fXmin; /// Minimal bound of range of NormSum
25  Double_t fXmax; /// Maximal bound of range of NormSum
26  std::vector<std::unique_ptr<TF1>> fFunctions; ///< Vector of size fNOfFunctions containing TF1 functions
27  std::vector < Double_t > fCoeffs; ///< Vector of size afNOfFunctions containing coefficients in front of each function
28  std::vector < Int_t > fCstIndexes; ///< Vector with size of fNOfFunctions containing the index of the constant parameter/ function (the removed ones)
29  std::vector< TString > fParNames; ///< Parameter names
30 
31  void InitializeDataMembers(const std::vector<TF1 *> &functions, const std::vector<Double_t> &coeffs,
32  Double_t scale); // acts as a constructor
33 
34 public:
35 
36  TF1NormSum();
37  TF1NormSum(const std::vector <TF1*>&functions, const std::vector <Double_t> &coeffs, Double_t scale = 1.);
38  TF1NormSum(TF1* function1, TF1* function2, Double_t coeff1 = 1., Double_t coeff2 = 1., Double_t scale = 1.);
39  TF1NormSum(TF1* function1, TF1* function2, TF1*function3, Double_t coeff1 = 1., Double_t coeff2 = 1., Double_t coeff3 = 1., Double_t scale = 1.);
40  TF1NormSum(const TString &formula, Double_t xmin, Double_t xmax);
41 
42  // Copy constructor
43  TF1NormSum(const TF1NormSum &nsum);
44 
45  TF1NormSum &operator=(const TF1NormSum &rhs);
46 
47  virtual ~TF1NormSum() {}
48 
49  double operator()(const Double_t *x, const Double_t *p);
50 
51  std::vector<double> GetParameters() const;
52 
53  void SetScale(Double_t scale) { fScale = scale; };
54 
55  void SetParameters(const Double_t *params);
56 
58  Double_t p5=0., Double_t p6=0., Double_t p7=0., Double_t p8=0., Double_t p9=0., Double_t p10=0.);
59 
60  void SetRange(Double_t a, Double_t b);
61 
62  Int_t GetNpar() const;
63 
64  Double_t GetScale() const { return fScale; }
65 
66  const char* GetParName(Int_t ipar) const { return fParNames.at(ipar).Data(); }
67 
68  Double_t GetXmin() const { return fXmin; }
69 
70  Double_t GetXmax() const { return fXmax; }
71 
72  void GetRange(Double_t &a, Double_t &b) const;
73 
74  void Update();
75 
76  void Copy(TObject &obj) const;
77 
78  ClassDef(TF1NormSum, 1);
79 };
80 #endif /* defined(ROOT_TF1NormSum__) */
void InitializeDataMembers(const std::vector< TF1 *> &functions, const std::vector< Double_t > &coeffs, Double_t scale)
Definition: TF1NormSum.cxx:54
Int_t GetNpar() const
Return the number of (non constant) parameters including the coefficients: for 2 functions: c1...
Definition: TF1NormSum.cxx:360
float xmin
Definition: THbookFile.cxx:93
std::vector< TString > fParNames
Parameter names.
Definition: TF1NormSum.h:29
static double p3(double t, double a, double b, double c, double d)
const char * GetParName(Int_t ipar) const
Definition: TF1NormSum.h:66
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
unsigned int fNOfFunctions
Number of functions to add.
Definition: TF1NormSum.h:22
Double_t x[n]
Definition: legend1.C:17
std::vector< Int_t > fCstIndexes
Vector with size of fNOfFunctions containing the index of the constant parameter/ function (the remov...
Definition: TF1NormSum.h:28
#define ClassDef(name, id)
Definition: Rtypes.h:320
void SetScale(Double_t scale)
Definition: TF1NormSum.h:53
static double p2(double t, double a, double b, double c)
Double_t GetXmax() const
Definition: TF1NormSum.h:70
virtual ~TF1NormSum()
Definition: TF1NormSum.h:47
void SetRange(Double_t a, Double_t b)
Definition: TF1NormSum.cxx:373
Double_t GetXmin() const
Definition: TF1NormSum.h:68
auto * a
Definition: textangle.C:12
Double_t fXmin
Definition: TF1NormSum.h:24
Double_t GetScale() const
Definition: TF1NormSum.h:64
double operator()(const Double_t *x, const Double_t *p)
Overload the parenthesis to add the functions.
Definition: TF1NormSum.cxx:271
Class adding two functions: c1*f1+c2*f2.
Definition: TF1NormSum.h:19
static double p1(double t, double a, double b)
float xmax
Definition: THbookFile.cxx:93
void Update()
Update the component functions of the normalized sum.
Definition: TF1NormSum.cxx:400
std::vector< Double_t > fCoeffs
Vector of size afNOfFunctions containing coefficients in front of each function.
Definition: TF1NormSum.h:27
void GetRange(Double_t &a, Double_t &b) const
Definition: TF1NormSum.cxx:391
double Double_t
Definition: RtypesCore.h:55
Double_t fScale
Fixed Scale parameter to normalize function (e.g. bin width)
Definition: TF1NormSum.h:23
std::vector< double > GetParameters() const
Return array of parameters.
Definition: TF1NormSum.cxx:288
TF1NormSum & operator=(const TF1NormSum &rhs)
Operator =.
Definition: TF1NormSum.cxx:261
void Copy(TObject &obj) const
Copy this to obj.
Definition: TF1NormSum.cxx:408
void SetParameters(const Double_t *params)
Initialize array of all parameters.
Definition: TF1NormSum.cxx:312
Mother of all ROOT objects.
Definition: TObject.h:37
std::vector< std::unique_ptr< TF1 > > fFunctions
Maximal bound of range of NormSum.
Definition: TF1NormSum.h:26
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
Double_t fXmax
Minimal bound of range of NormSum.
Definition: TF1NormSum.h:25