Logo ROOT   6.10/09
Reference Guide
TF1NormSum.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: L. Moneta May 2015
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2015 ROOT Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 //
11 // TF1NormSum.h
12 //
13 //
14 // Created by AurĂ©lie Flandi on 27.08.14.
15 //
16 //
17 
18 #ifndef ROOT_TF1NormSum__
19 #define ROOT_TF1NormSum__
20 
21 #include <iostream>
22 #include "TF1.h"
23 #include <memory>
24 
25 //class adding two functions: c1*f1+c2*f2
26 class TF1NormSum {
27 
28 protected:
29 
30  // vector market as temp data member could probably be removed
31 
32  unsigned int fNOfFunctions; //! Number of functions to add
33  //int> p1(new int(5));
34  Double_t fScale; // Fixed Scale parameter to normalize function (e.g. bin width)
35  std::vector < std::shared_ptr < TF1 > > fFunctions; // Vector of size fNOfFunctions containing TF1 functions
36  std::vector < Double_t > fCoeffs; // Vector of size afNOfFunctions containing coefficients in front of each function
37 // std::vector < Int_t > fNOfParams; //! Vector of size fNOfFunctions containing number of parameters for each function (does not contain the coefficients!)
38 // std::vector < Int_t > fNOfNonCstParams; // Vector of size fNOfFunctions containing the indices of the non-const parameter of each function
39 // std::vector < Double_t * > fParams; //! Vector of size [fNOfFunctions][Function_p] containing an array of all function parameters
40  // (non including coefficients) for each function
41  std::vector < Int_t > fCstIndexes; // vector with size of fNOfFunctions containing the index of the constant parameter/ function (the removed ones)
42  std::vector< TString > fParNames; // parameter names
43 
44  void InitializeDataMembers(const std::vector <std::shared_ptr < TF1 >> &functions, const std::vector <Double_t> &coeffs, Double_t scale); // acts as a constrcutor
45 
46  //smart pointer
47 public:
48 
49  TF1NormSum();
50  TF1NormSum(const std::vector <TF1*>&functions, const std::vector <Double_t> &coeffs, Double_t scale = 1.);
51  TF1NormSum(TF1* function1, TF1* function2, Double_t coeff1 = 1., Double_t coeff2 = 1., Double_t scale = 1.);
52  TF1NormSum(TF1* function1, TF1* function2, TF1*function3, Double_t coeff1 = 1., Double_t coeff2 = 1., Double_t coeff3 = 1., Double_t scale = 1.);
53  TF1NormSum(const TString &formula, Double_t xmin, Double_t xmax);
54 
55  double operator()(double* x, double* p);
56 
57  std::vector<double> GetParameters() const;
58 
59  void SetScale(Double_t scale) { fScale = scale; };
60 
61  void SetParameters(const double* params);
62 
64  Double_t p5=0., Double_t p6=0., Double_t p7=0., Double_t p8=0., Double_t p9=0., Double_t p10=0.);
65 
66  Int_t GetNpar() const;
67 
68  Double_t GetScale() const { return fScale; }
69 
70  const char * GetParName(Int_t ipar) const { return fParNames.at(ipar).Data(); }
71 
72  //ClassDef(TF1NormSum,1)
73 
74 };
75 #endif /* defined(ROOT_TF1NormSum__) */
Int_t GetNpar() const
Definition: TF1NormSum.cxx:362
float xmin
Definition: THbookFile.cxx:93
std::vector< TString > fParNames
Definition: TF1NormSum.h:42
static double p3(double t, double a, double b, double c, double d)
const char * GetParName(Int_t ipar) const
Definition: TF1NormSum.h:70
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
unsigned int fNOfFunctions
Definition: TF1NormSum.h:32
Double_t x[n]
Definition: legend1.C:17
std::vector< Int_t > fCstIndexes
Definition: TF1NormSum.h:41
void SetScale(Double_t scale)
Definition: TF1NormSum.h:59
static double p2(double t, double a, double b, double c)
void InitializeDataMembers(const std::vector< std::shared_ptr< TF1 >> &functions, const std::vector< Double_t > &coeffs, Double_t scale)
Definition: TF1NormSum.cxx:65
Double_t GetScale() const
Definition: TF1NormSum.h:68
Class adding two functions: c1*f1+c2*f2.
Definition: TF1NormSum.h:26
static double p1(double t, double a, double b)
float xmax
Definition: THbookFile.cxx:93
std::vector< Double_t > fCoeffs
Definition: TF1NormSum.h:36
double Double_t
Definition: RtypesCore.h:55
Double_t fScale
Number of functions to add.
Definition: TF1NormSum.h:34
std::vector< double > GetParameters() const
Return array of parameters.
Definition: TF1NormSum.cxx:293
void SetParameters(const double *params)
Initialize array of all parameters.
Definition: TF1NormSum.cxx:317
std::vector< std::shared_ptr< TF1 > > fFunctions
Definition: TF1NormSum.h:35
1-Dim function class
Definition: TF1.h:150
double operator()(double *x, double *p)
Overload the parenthesis to add the functions.
Definition: TF1NormSum.cxx:277