Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
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__) */