Logo ROOT   6.16/01
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
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
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
static double p3(double t, double a, double b, double c, double d)
static double p1(double t, double a, double b)
static double p2(double t, double a, double b, double c)
int Int_t
Definition: RtypesCore.h:41
double Double_t
Definition: RtypesCore.h:55
#define ClassDef(name, id)
Definition: Rtypes.h:324
float xmin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
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
Definition: TF1NormSum.cxx:391
TF1NormSum & operator=(const TF1NormSum &rhs)
Operator =.
Definition: TF1NormSum.cxx:261
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.
Definition: TF1NormSum.cxx:312
Double_t fXmin
Definition: TF1NormSum.h:24
std::vector< double > GetParameters() const
Return array of parameters.
Definition: TF1NormSum.cxx:288
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)
Definition: TF1NormSum.cxx:54
void Copy(TObject &obj) const
Copy this to obj.
Definition: TF1NormSum.cxx:408
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,...
Definition: TF1NormSum.cxx:360
Double_t GetScale() const
Definition: TF1NormSum.h:64
void Update()
Update the component functions of the normalized sum.
Definition: TF1NormSum.cxx:400
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.
Definition: TF1NormSum.cxx:271
virtual ~TF1NormSum()
Definition: TF1NormSum.h:47
void SetRange(Double_t a, Double_t b)
Definition: TF1NormSum.cxx:373
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:211
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
Double_t x[n]
Definition: legend1.C:17
auto * a
Definition: textangle.C:12