From 76f20033f5cac52f1c08a3f051ae7aa86a2f662c Mon Sep 17 00:00:00 2001
From: Lorenzo Moneta <Lorenzo.Moneta@cern.ch>
Date: Thu, 19 Feb 2015 14:09:33 +0100
Subject: [PATCH] Fixes for ROOT-7085. change name to
 TFormula::SetParameters(double*,int)  since it conflicts with
 TFormula::SetParameters(double,double)

---
 hist/hist/inc/TF1.h        |  3 ---
 hist/hist/inc/TFormula.h   |  4 ++--
 hist/hist/src/HFitImpl.cxx |  7 ++++---
 hist/hist/src/TFormula.cxx | 36 +++++++++++++++++++-----------------
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/hist/hist/inc/TF1.h b/hist/hist/inc/TF1.h
index d2577658a44..5fbd680c1f4 100644
--- a/hist/hist/inc/TF1.h
+++ b/hist/hist/inc/TF1.h
@@ -387,9 +387,6 @@ public:
    virtual void     SetParameter(const TString &name, Double_t value) {
       (fFormula) ? fFormula->SetParameter(name,value) : fParams->SetParameter(name,value);
    }
-   virtual void     SetParameters(const Double_t *params,Int_t size) {
-      (fFormula) ? fFormula->SetParameters(params,size) : fParams->SetParameters(params);
-   }
    virtual void     SetParameters(const Double_t *params) {
       (fFormula) ? fFormula->SetParameters(params) : fParams->SetParameters(params); 
    }
diff --git a/hist/hist/inc/TFormula.h b/hist/hist/inc/TFormula.h
index 85204d2f0ab..1ad98609e0a 100644
--- a/hist/hist/inc/TFormula.h
+++ b/hist/hist/inc/TFormula.h
@@ -122,6 +122,7 @@ protected:
    void   ProcessFormula(TString &formula);
    Bool_t PrepareFormula(TString &formula);
    void   DoAddParameter(const TString &name, Double_t value, bool processFormula);
+   void   DoSetParameters(const Double_t * p, Int_t size); 
 
    Double_t       DoEval(const Double_t * x  = nullptr, const Double_t * p = nullptr);
 
@@ -163,12 +164,11 @@ public:
    Double_t*      GetParameters() const;
    void           GetParameters(Double_t *params) const;
    Double_t       GetVariable(const TString &name);
-   Bool_t         IsValid() const { return fReadyToExecute && fAllParametersSetted; }
+   Bool_t         IsValid() const { return fReadyToExecute; }
    Bool_t         IsLinear() const { return TestBit(kLinear); } 
    void           Print(Option_t *option = "") const;
    void           SetParameter(const char* name, Double_t value);
    void           SetParameter(Int_t param, Double_t value);
-   void           SetParameters(const Double_t *params,Int_t size);
    void           SetParameters(const Double_t *params);
    //void           SetParameters(const pair<TString,Double_t> *params, const Int_t size);
    void           SetParameters(Double_t p0,Double_t p1,Double_t p2=0,Double_t p3=0,Double_t p4=0,
diff --git a/hist/hist/src/HFitImpl.cxx b/hist/hist/src/HFitImpl.cxx
index c1855e4f5dd..fbdcf0b9df9 100644
--- a/hist/hist/src/HFitImpl.cxx
+++ b/hist/hist/src/HFitImpl.cxx
@@ -373,8 +373,8 @@ TFitResultPtr HFit::Fit(FitObject * h1, TF1 *f1 , Foption_t & fitOption , const
       f1->SetNDF(fitResult.Ndf() );
       f1->SetNumberFitPoints(fitdata->Size() );
 
-
-      f1->SetParameters( const_cast<double*>(&(fitResult.Parameters().front())),(Int_t)fitResult.Parameters().size() ); 
+      assert((Int_t)fitResult.Parameters().size() >= f1->GetNpar() );
+      f1->SetParameters( const_cast<double*>(&(fitResult.Parameters().front()))); 
       if ( int( fitResult.Errors().size()) >= f1->GetNpar() ) 
          f1->SetParErrors( &(fitResult.Errors().front()) ); 
   
@@ -862,7 +862,8 @@ TFitResultPtr ROOT::Fit::UnBinFit(ROOT::Fit::UnBinData * data, TF1 * fitfunc, Fo
       fitfunc->SetNDF(fitResult.Ndf() );
       fitfunc->SetNumberFitPoints(fitdata->Size() );
 
-      fitfunc->SetParameters( const_cast<double*>(&(fitResult.Parameters().front())), (Int_t)fitResult.Parameters().size());
+      assert(  (Int_t)fitResult.Parameters().size() >= fitfunc->GetNpar() );
+      fitfunc->SetParameters( const_cast<double*>(&(fitResult.Parameters().front())));
       if ( int( fitResult.Errors().size()) >= fitfunc->GetNpar() ) 
          fitfunc->SetParErrors( &(fitResult.Errors().front()) ); 
   
diff --git a/hist/hist/src/TFormula.cxx b/hist/hist/src/TFormula.cxx
index 33a14c83e5e..32bbe0fe2f5 100644
--- a/hist/hist/src/TFormula.cxx
+++ b/hist/hist/src/TFormula.cxx
@@ -1718,14 +1718,32 @@ void TFormula::SetParameters(const pair<TString,Double_t> *params,const Int_t si
 }
 #endif
 
+void TFormula::DoSetParameters(const Double_t *params, Int_t size)
+{
+   if(!params || size < 0 || size > fNpar) return;
+   // reset vector of cling parameters
+   if (size != (int) fClingParameters.size() ) {
+      Warning("SetParameters","size is not same of cling parameter size %d - %d",size,int(fClingParameters.size()) );
+      for(Int_t i = 0; i < size; ++i)
+      {
+         TString name = TString::Format("%d",i);
+         SetParameter(name,params[i]);
+      }
+      return; 
+   }
+   fAllParametersSetted = true;
+   std::copy(params, params+size, fClingParameters.begin() );
+}
+
 void TFormula::SetParameters(const Double_t *params)
 {
-   SetParameters(params,fNpar);
+   DoSetParameters(params,fNpar);
 }
 void TFormula::SetParameters(Double_t p0,Double_t p1,Double_t p2,Double_t p3,Double_t p4,
                    Double_t p5,Double_t p6,Double_t p7,Double_t p8,
                    Double_t p9,Double_t p10)
 {
+   printf("setting parameters\n");
    if(fNpar >= 1) SetParameter(0,p0);
    if(fNpar >= 2) SetParameter(1,p1);
    if(fNpar >= 3) SetParameter(2,p2);
@@ -1838,22 +1856,6 @@ void TFormula::SetParName(Int_t ipar, const char * name)
 
 
 
-}
-void TFormula::SetParameters(const Double_t *params, Int_t size)
-{
-   if(!params || size < 0 || size > fNpar) return;
-   // reset vector of cling parameters
-   if (size != (int) fClingParameters.size() ) {
-      Warning("SetParameters","size is not same of cling parameter size %d - %d",size,int(fClingParameters.size()) );
-      for(Int_t i = 0; i < size; ++i)
-      {
-         TString name = TString::Format("%d",i);
-         SetParameter(name,params[i]);
-      }
-      return; 
-   }
-   fAllParametersSetted = true;
-   std::copy(params, params+size, fClingParameters.begin() );
 }
 Double_t TFormula::EvalPar(const Double_t *x,const Double_t *params)
 {
-- 
GitLab