Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:45

0001 // @(#)root/hist:$Id$
0002 // Authors: Lorenzo Moneta, Aurélie Flandi  27/08/14
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2015  ROOT  Team, CERN/PH-SFT                        *
0007  *                                                                    *
0008  *                                                                    *
0009  **********************************************************************/
0010 
0011 #ifndef ROOT_TF1NormSum__
0012 #define ROOT_TF1NormSum__
0013 
0014 #include "TF1AbsComposition.h"
0015 #include <vector>
0016 #include <memory>
0017 #include "TF1.h"
0018 
0019 class TF1NormSum : public TF1AbsComposition {
0020 
0021 protected:
0022    unsigned int fNOfFunctions;                         ///< Number of functions to add
0023    Double_t     fScale;                                ///< Fixed Scale parameter to normalize function (e.g. bin width)
0024    Double_t fXmin;                                     ///< Minimal bound of range of NormSum
0025    Double_t fXmax;                                     ///< Maximal bound of range of NormSum
0026    std::vector<std::unique_ptr<TF1>> fFunctions;       ///< Vector of size fNOfFunctions containing TF1 functions
0027    std::vector < Double_t  > fCoeffs;                  ///< Vector of size afNOfFunctions containing coefficients in front of each function
0028    std::vector < Int_t     > fCstIndexes;              ///< Vector with size of fNOfFunctions containing the index of the constant parameter/ function (the removed ones)
0029    std::vector< TString >    fParNames;                ///< Parameter names
0030 
0031    void InitializeDataMembers(const std::vector<TF1 *> &functions, const std::vector<Double_t> &coeffs,
0032                               Double_t scale); // acts as a constructor
0033 
0034 public:
0035 
0036    TF1NormSum();
0037    TF1NormSum(const std::vector <TF1*>&functions, const std::vector <Double_t> &coeffs, Double_t scale = 1.);
0038    TF1NormSum(TF1* function1, TF1* function2, Double_t coeff1 = 1., Double_t coeff2 = 1., Double_t scale = 1.);
0039    TF1NormSum(TF1* function1, TF1* function2, TF1*function3, Double_t coeff1 = 1., Double_t coeff2 = 1., Double_t coeff3 = 1., Double_t scale = 1.);
0040    TF1NormSum(const TString &formula, Double_t xmin, Double_t xmax);
0041 
0042    // Copy constructor
0043    TF1NormSum(const TF1NormSum &nsum);
0044 
0045    TF1NormSum &operator=(const TF1NormSum &rhs);
0046 
0047    ~TF1NormSum() override {}
0048 
0049    double operator()(const Double_t *x, const Double_t *p) override;
0050 
0051    std::vector<double> GetParameters() const;
0052 
0053    void        SetScale(Double_t scale) { fScale = scale; };
0054 
0055    void SetParameters(const Double_t *params) override;
0056 
0057    void        SetParameters(Double_t p0, Double_t p1, Double_t p2=0., Double_t p3=0., Double_t p4=0.,
0058                                    Double_t p5=0., Double_t p6=0., Double_t p7=0., Double_t p8=0., Double_t p9=0., Double_t p10=0.);
0059 
0060    void SetRange(Double_t a, Double_t b) override;
0061 
0062    Int_t       GetNpar() const;
0063 
0064    Double_t    GetScale() const { return fScale; }
0065 
0066    const char* GetParName(Int_t ipar) const { return fParNames.at(ipar).Data(); }
0067 
0068    Double_t GetXmin() const { return fXmin; }
0069 
0070    Double_t GetXmax() const { return fXmax; }
0071 
0072    void GetRange(Double_t &a, Double_t &b) const;
0073 
0074    void Update() override;
0075 
0076    void Copy(TObject &obj) const override;
0077 
0078    ClassDefOverride(TF1NormSum, 1);
0079 };
0080 #endif /* defined(ROOT_TF1NormSum__) */