Logo ROOT  
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 "TF1AbsComposition.h"
15 #include <vector>
16 #include <memory>
17 #include "TF1.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 
57  void SetParameters(Double_t p0, Double_t p1, Double_t p2=0., Double_t p3=0., Double_t p4=0.,
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__) */
TF1NormSum::GetXmin
Double_t GetXmin() const
Definition: TF1NormSum.h:73
TF1NormSum::SetScale
void SetScale(Double_t scale)
Definition: TF1NormSum.h:58
TF1NormSum::GetRange
void GetRange(Double_t &a, Double_t &b) const
Definition: TF1NormSum.cxx:394
TF1NormSum::fParNames
std::vector< TString > fParNames
Parameter names.
Definition: TF1NormSum.h:34
xmax
float xmax
Definition: THbookFile.cxx:95
TF1NormSum
Definition: TF1NormSum.h:19
TF1AbsComposition
Definition: TF1AbsComposition.h:16
TF1NormSum::operator=
TF1NormSum & operator=(const TF1NormSum &rhs)
Operator =.
Definition: TF1NormSum.cxx:264
Int_t
int Int_t
Definition: RtypesCore.h:45
TF1NormSum::fNOfFunctions
unsigned int fNOfFunctions
Number of functions to add.
Definition: TF1NormSum.h:27
TF1NormSum::fXmin
Double_t fXmin
Definition: TF1NormSum.h:29
x
Double_t x[n]
Definition: legend1.C:17
TString
Definition: TString.h:136
TF1NormSum::InitializeDataMembers
void InitializeDataMembers(const std::vector< TF1 * > &functions, const std::vector< Double_t > &coeffs, Double_t scale)
Definition: TF1NormSum.cxx:55
b
#define b(i)
Definition: RSha256.hxx:118
xmin
float xmin
Definition: THbookFile.cxx:95
TF1NormSum::GetParName
const char * GetParName(Int_t ipar) const
Definition: TF1NormSum.h:71
TF1NormSum::fScale
Double_t fScale
Fixed Scale parameter to normalize function (e.g. bin width)
Definition: TF1NormSum.h:28
a
auto * a
Definition: textangle.C:12
TF1NormSum::TF1NormSum
TF1NormSum()
Definition: TF1NormSum.cxx:131
TF1NormSum::Update
void Update()
Update the component functions of the normalized sum.
Definition: TF1NormSum.cxx:403
TF1NormSum::SetRange
void SetRange(Double_t a, Double_t b)
Definition: TF1NormSum.cxx:376
TF1NormSum::fCstIndexes
std::vector< Int_t > fCstIndexes
Vector with size of fNOfFunctions containing the index of the constant parameter/ function (the remov...
Definition: TF1NormSum.h:33
TF1AbsComposition.h
TF1NormSum::GetScale
Double_t GetScale() const
Definition: TF1NormSum.h:69
TF1NormSum::operator()
double operator()(const Double_t *x, const Double_t *p)
Overload the parenthesis to add the functions.
Definition: TF1NormSum.cxx:274
Double_t
double Double_t
Definition: RtypesCore.h:59
TF1NormSum::Copy
void Copy(TObject &obj) const
Copy this to obj.
Definition: TF1NormSum.cxx:411
TF1.h
TF1NormSum::GetXmax
Double_t GetXmax() const
Definition: TF1NormSum.h:75
TF1NormSum::GetNpar
Int_t GetNpar() const
Return the number of (non constant) parameters including the coefficients: for 2 functions: c1,...
Definition: TF1NormSum.cxx:363
TF1NormSum::~TF1NormSum
virtual ~TF1NormSum()
Definition: TF1NormSum.h:52
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TF1NormSum::fXmax
Double_t fXmax
Minimal bound of range of NormSum.
Definition: TF1NormSum.h:30
TF1NormSum::SetParameters
void SetParameters(const Double_t *params)
Initialize array of all parameters.
Definition: TF1NormSum.cxx:315
TF1
1-Dim function class
Definition: TF1.h:212
TF1NormSum::fCoeffs
std::vector< Double_t > fCoeffs
Vector of size afNOfFunctions containing coefficients in front of each function.
Definition: TF1NormSum.h:32
TF1NormSum::GetParameters
std::vector< double > GetParameters() const
Return array of parameters.
Definition: TF1NormSum.cxx:291
int
TF1NormSum::fFunctions
std::vector< std::unique_ptr< TF1 > > fFunctions
Maximal bound of range of NormSum.
Definition: TF1NormSum.h:31