Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
20
21protected:
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
34public:
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
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
79};
80#endif /* defined(ROOT_TF1NormSum__) */
#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 ClassDef(name, id)
Definition Rtypes.h:325
float xmin
float xmax
Class adding two functions: c1*f1+c2*f2.
Definition TF1NormSum.h:19
Double_t fScale
Fixed Scale parameter to normalize function (e.g. bin width)
Definition TF1NormSum.h:23
Double_t GetXmax() const
Definition TF1NormSum.h:70
void SetScale(Double_t scale)
Definition TF1NormSum.h:53
const char * GetParName(Int_t ipar) const
Definition TF1NormSum.h:66
void GetRange(Double_t &a, Double_t &b) const
TF1NormSum & operator=(const TF1NormSum &rhs)
Operator =.
Double_t fXmax
Minimal bound of range of NormSum.
Definition TF1NormSum.h:25
Double_t GetXmin() const
Definition TF1NormSum.h:68
std::vector< TString > fParNames
Parameter names.
Definition TF1NormSum.h:29
void SetParameters(const Double_t *params)
Initialize array of all parameters.
Double_t fXmin
Definition TF1NormSum.h:24
std::vector< double > GetParameters() const
Return array of parameters.
std::vector< std::unique_ptr< TF1 > > fFunctions
Maximal bound of range of NormSum.
Definition TF1NormSum.h:26
void InitializeDataMembers(const std::vector< TF1 * > &functions, const std::vector< Double_t > &coeffs, Double_t scale)
void Copy(TObject &obj) const
Copy this to obj.
std::vector< Double_t > fCoeffs
Vector of size afNOfFunctions containing coefficients in front of each function.
Definition TF1NormSum.h:27
Int_t GetNpar() const
Return the number of (non constant) parameters including the coefficients: for 2 functions: c1,...
Double_t GetScale() const
Definition TF1NormSum.h:64
void Update()
Update the component functions of the normalized sum.
unsigned int fNOfFunctions
Number of functions to add.
Definition TF1NormSum.h:22
double operator()(const Double_t *x, const Double_t *p)
Overload the parenthesis to add the functions.
virtual ~TF1NormSum()
Definition TF1NormSum.h:47
void SetRange(Double_t a, Double_t b)
std::vector< Int_t > fCstIndexes
Vector with size of fNOfFunctions containing the index of the constant parameter/ function (the remov...
Definition TF1NormSum.h:28
1-Dim function class
Definition TF1.h:213
Mother of all ROOT objects.
Definition TObject.h:37
Basic string class.
Definition TString.h:136
Double_t x[n]
Definition legend1.C:17