From 9e3861ce62e68dbfbcf354b58c11f29f552bdbdc Mon Sep 17 00:00:00 2001 From: Fons Rademakers <Fons.Rademakers@cern.ch> Date: Mon, 4 Feb 2013 18:36:25 +0000 Subject: [PATCH] fix warnings reported by the latest Apple LLVM 4.2 clang++ (based on llvm 3.2svn). Mostly were: warning: private field 'fOneDim' is not used [-Wunused-private-field] git-svn-id: http://root.cern.ch/svn/root/trunk@48467 27541ba8-7e3a-0410-8455-c3a389f83636 --- graf2d/asimage/src/libAfterImage/afterbase.c | 3 +- hist/hbook/src/THbookFile.cxx | 6 +- main/src/h2root.cxx | 2 +- math/foam/inc/TFoamSampler.h | 2 +- math/foam/src/TFoamSampler.cxx | 108 ++++++------ math/mathmore/inc/Math/GSLNLSMinimizer.h | 163 +++++++++--------- .../inc/Minuit2/FumiliStandardChi2FCN.h | 84 +++++---- .../FumiliStandardMaximumLikelihoodFCN.h | 50 +++--- 8 files changed, 203 insertions(+), 215 deletions(-) diff --git a/graf2d/asimage/src/libAfterImage/afterbase.c b/graf2d/asimage/src/libAfterImage/afterbase.c index b9dc251f69e..d6581bc6a64 100644 --- a/graf2d/asimage/src/libAfterImage/afterbase.c +++ b/graf2d/asimage/src/libAfterImage/afterbase.c @@ -705,7 +705,8 @@ double asim_parse_math(const char* str, char** endptr, double size) { num = asim_parse_math(str + 1, &ptr, size); else if (*str == '$') { - for (ptr = (char*)str + 1 ; *ptr && !isspace(*ptr) && *ptr != '+' && *ptr != '-' && *ptr != '*' && *ptr != '!' && *ptr != '/' && *ptr != ')' ; ptr++); + for (ptr = (char*)str + 1 ; *ptr && !isspace(*ptr) && *ptr != '+' && *ptr != '-' && *ptr != '*' && *ptr != '!' && *ptr != '/' && *ptr != ')' ; ptr++) + ; num = asim_asxml_var_nget((char*)str + 1, ptr - (str + 1)); }else num = strtod(str, &ptr); diff --git a/hist/hbook/src/THbookFile.cxx b/hist/hbook/src/THbookFile.cxx index e374e44b4ee..d0bf42652a2 100644 --- a/hist/hbook/src/THbookFile.cxx +++ b/hist/hbook/src/THbookFile.cxx @@ -284,7 +284,7 @@ THbookFile::THbookFile(const char *fname, Int_t lrecl) char topdir[20]; snprintf(topdir,19,"lun%d",fLun); - Int_t ier; + Int_t ier = 0; #ifndef WIN32 hropen(fLun,PASSCHAR(topdir),PASSCHAR(fname),PASSCHAR("p"),lrecl,ier,strlen(topdir),strlen(fname),1); #else @@ -885,7 +885,7 @@ TObject *THbookFile::ConvertProfile(Int_t id) const Int_t kCON1 = 9; Int_t i; - Float_t x; + Float_t x = 0.0; Float_t y = 0.5*(ymin+ymax); for (i=1;i<=ncx;i++) { Int_t n = Int_t(q[ln+i]); @@ -974,7 +974,7 @@ TObject *THbookFile::Convert2D(Int_t id) Int_t lw = lq[lcont]; if (lw) h2->Sumw2(); - Float_t x,y; + Float_t x = 0.0, y = 0.0; for (Int_t j=0;j<=ncy+1;j++) { for (Int_t i=0;i<=ncx+1;i++) { hijxy(id,i,j,x,y); diff --git a/main/src/h2root.cxx b/main/src/h2root.cxx index bf3c8f33af1..c8a9b7b696d 100644 --- a/main/src/h2root.cxx +++ b/main/src/h2root.cxx @@ -521,7 +521,7 @@ void convert_2d(Int_t id) Int_t lw = lq[lcont]; if (lw) h2->Sumw2(); - Float_t x,y; + Float_t x = 0.0, y = 0.0; for (Int_t j=0;j<=ncy+1;j++) { for (Int_t i=0;i<=ncx+1;i++) { hijxy(id,i,j,x,y); diff --git a/math/foam/inc/TFoamSampler.h b/math/foam/inc/TFoamSampler.h index 409cc29e17a..7b30c327587 100644 --- a/math/foam/inc/TFoamSampler.h +++ b/math/foam/inc/TFoamSampler.h @@ -123,7 +123,7 @@ protected: private: // private member - bool fOneDim; // flag to indicate if the function is 1 dimension +// bool fOneDim; // flag to indicate if the function is 1 dimension // bool fHasMode; // flag to indicate if a mode is set // bool fHasArea; // flag to indicate if a area is set // double fMode; // mode of dist diff --git a/math/foam/src/TFoamSampler.cxx b/math/foam/src/TFoamSampler.cxx index f7265897fe1..5f1c11dad7e 100644 --- a/math/foam/src/TFoamSampler.cxx +++ b/math/foam/src/TFoamSampler.cxx @@ -26,13 +26,13 @@ #include <cassert> #include <cmath> -class FoamDistribution : public TFoamIntegrand { +class FoamDistribution : public TFoamIntegrand { public: - FoamDistribution(const ROOT::Math::IMultiGenFunction & f, const ROOT::Fit::DataRange & range) : - fFunc(f), - fX(std::vector<double>(f.NDim() ) ), + FoamDistribution(const ROOT::Math::IMultiGenFunction & f, const ROOT::Fit::DataRange & range) : + fFunc(f), + fX(std::vector<double>(f.NDim() ) ), fMinX(std::vector<double>(f.NDim() ) ), fDeltaX(std::vector<double>(f.NDim() ) ) { @@ -41,33 +41,33 @@ public: for (unsigned int i = 0; i < range.NDim(); ++i) { if (range.Size(i) == 0) Error("FoamDistribution","Range is not set for coordinate dim %d",i); - else if (range.Size(i)>1) + else if (range.Size(i)>1) Warning("FoamDistribution","Using only first range in coordinate dim %d",i); - std::pair<double,double> r = range(i); + std::pair<double,double> r = range(i); fMinX[i] = r.first; - fDeltaX[i] = r.second - r.first; + fDeltaX[i] = r.second - r.first; } - } + } // in principle function does not need to be cloned virtual double Density(int ndim, double * x) { assert(ndim == (int) fFunc.NDim() ); for (int i = 0; i < ndim; ++i) - fX[i] = fMinX[i] + x[i] * fDeltaX[i]; + fX[i] = fMinX[i] + x[i] * fDeltaX[i]; return (fFunc)(&fX[0]); } double MinX(unsigned int i) { return fMinX[i]; } double DeltaX(unsigned int i) { return fDeltaX[i]; } - + private: const ROOT::Math::IMultiGenFunction & fFunc; - std::vector<double> fX; - std::vector<double> fMinX; - std::vector<double> fDeltaX; + std::vector<double> fX; + std::vector<double> fMinX; + std::vector<double> fDeltaX; }; @@ -80,12 +80,12 @@ ClassImp(TFoamSampler) /** TFoamSampler class class implementing the ROOT::Math::DistSampler interface using FOAM - for sampling arbitrary distributions. + for sampling arbitrary distributions. */ -TFoamSampler::TFoamSampler() : ROOT::Math::DistSampler(), - fOneDim(false), +TFoamSampler::TFoamSampler() : ROOT::Math::DistSampler(), +// fOneDim(false) // fDiscrete(false), // fHasMode(false), fHasArea(false), // fMode(0), fArea(0), @@ -96,20 +96,20 @@ TFoamSampler::TFoamSampler() : ROOT::Math::DistSampler(), TFoamSampler::~TFoamSampler() { assert(fFoam != 0); - delete fFoam; - if (fFoamDist) delete fFoamDist; + delete fFoam; + if (fFoamDist) delete fFoamDist; } -bool TFoamSampler::Init(const char *) { +bool TFoamSampler::Init(const char *) { // initialize using default options ROOT::Math::DistSamplerOptions opt(0); - ROOT::Math::IOptions * foamOpt = ROOT::Math::DistSamplerOptions::FindDefault("Foam"); - if (foamOpt) opt.SetExtraOptions(*foamOpt); + ROOT::Math::IOptions * foamOpt = ROOT::Math::DistSamplerOptions::FindDefault("Foam"); + if (foamOpt) opt.SetExtraOptions(*foamOpt); return Init(opt); } -bool TFoamSampler::Init(const ROOT::Math::DistSamplerOptions & opt) { +bool TFoamSampler::Init(const ROOT::Math::DistSamplerOptions & opt) { // initialize foam classes using the given algorithm assert (fFoam != 0 ); if (NDim() == 0) { @@ -117,24 +117,24 @@ bool TFoamSampler::Init(const ROOT::Math::DistSamplerOptions & opt) { return false; } - // initialize the foam + // initialize the foam fFoam->SetkDim(NDim() ); - // initialize random number + // initialize random number if (!GetRandom()) SetRandom(gRandom); - // create TFoamIntegrand class - if (fFoamDist) delete fFoamDist; + // create TFoamIntegrand class + if (fFoamDist) delete fFoamDist; fFoamDist = new FoamDistribution(ParentPdf(),PdfRange()); fFoam->SetRho(fFoamDist); // set print level fFoam->SetChat(opt.PrintLevel()); - // get extra options - ROOT::Math::IOptions * fopt = opt.ExtraOptions(); - if (fopt) { - int nval = 0; + // get extra options + ROOT::Math::IOptions * fopt = opt.ExtraOptions(); + if (fopt) { + int nval = 0; double fval = 0; if (fopt->GetIntValue("nCells", nval) ) fFoam->SetnCells(nval); if (fopt->GetIntValue("nCell1D", nval) && NDim() ==1) fFoam->SetnCells(nval); @@ -154,55 +154,55 @@ bool TFoamSampler::Init(const ROOT::Math::DistSamplerOptions & opt) { fFoam->Initialize(); return true; - + } -void TFoamSampler::SetFunction(TF1 * pdf) { - // set function from a TF1 pointer +void TFoamSampler::SetFunction(TF1 * pdf) { + // set function from a TF1 pointer SetFunction<TF1>(*pdf, pdf->GetNdim()); -} +} -void TFoamSampler::SetRandom(TRandom * r) { +void TFoamSampler::SetRandom(TRandom * r) { // set random generator (must be called before Init to have effect) - fFoam->SetPseRan(r); -} + fFoam->SetPseRan(r); +} -void TFoamSampler::SetSeed(unsigned int seed) { +void TFoamSampler::SetSeed(unsigned int seed) { // set random generator seed (must be called before Init to have effect) TRandom * r = fFoam->GetPseRan(); if (r) r->SetSeed(seed); -} +} -TRandom * TFoamSampler::GetRandom() { - // get random generator used - return fFoam->GetPseRan(); -} +TRandom * TFoamSampler::GetRandom() { + // get random generator used + return fFoam->GetPseRan(); +} -// double TFoamSampler::Sample1D() { +// double TFoamSampler::Sample1D() { // // sample 1D distributions -// return (fDiscrete) ? (double) fFoam->SampleDiscr() : fFoam->Sample(); +// return (fDiscrete) ? (double) fFoam->SampleDiscr() : fFoam->Sample(); // } -bool TFoamSampler::Sample(double * x) { +bool TFoamSampler::Sample(double * x) { // sample multi-dim distributions fFoam->MakeEvent(); fFoam->GetMCvect(x); - // adjust for the range - for (unsigned int i = 0; i < NDim(); ++i) + // adjust for the range + for (unsigned int i = 0; i < NDim(); ++i) x[i] = ( (FoamDistribution*)fFoamDist)->MinX(i) + ( ( (FoamDistribution*) fFoamDist)->DeltaX(i))*x[i]; - return true; -} + return true; +} bool TFoamSampler::SampleBin(double prob, double & value, double *error) { // sample a bin according to Poisson statistics - TRandom * r = GetRandom(); - if (!r) return false; - value = r->Poisson(prob); + TRandom * r = GetRandom(); + if (!r) return false; + value = r->Poisson(prob); if (error) *error = std::sqrt(value); - return true; + return true; } diff --git a/math/mathmore/inc/Math/GSLNLSMinimizer.h b/math/mathmore/inc/Math/GSLNLSMinimizer.h index 6e5abb1d24f..9fa2ed2ff8e 100644 --- a/math/mathmore/inc/Math/GSLNLSMinimizer.h +++ b/math/mathmore/inc/Math/GSLNLSMinimizer.h @@ -55,88 +55,88 @@ #include <map> #include <string> -namespace ROOT { +namespace ROOT { - namespace Math { + namespace Math { - class GSLMultiFit; + class GSLMultiFit; //________________________________________________________________________________ -/** - LSResidualFunc class description. +/** + LSResidualFunc class description. Internal class used for accessing the residuals of the Least Square function - and their derivates which are estimated numerically using GSL numerical derivation. - The class contains a pointer to the fit method function and an index specifying + and their derivates which are estimated numerically using GSL numerical derivation. + The class contains a pointer to the fit method function and an index specifying the i-th residual and wraps it in a multi-dim gradient function interface - ROOT::Math::IGradientFunctionMultiDim. + ROOT::Math::IGradientFunctionMultiDim. The class is used by ROOT::Math::GSLNLSMinimizer (GSL non linear least square fitter) @ingroup MultiMin */ -class LSResidualFunc : public IMultiGradFunction { -public: +class LSResidualFunc : public IMultiGradFunction { +public: - //default ctor (required by CINT) + //default ctor (required by CINT) LSResidualFunc() : fIndex(0), fChi2(0) {} - LSResidualFunc(const ROOT::Math::FitMethodFunction & func, unsigned int i) : - fIndex(i), - fChi2(&func), + LSResidualFunc(const ROOT::Math::FitMethodFunction & func, unsigned int i) : + fIndex(i), + fChi2(&func), fX2(std::vector<double>(func.NDim() ) ) {} // copy ctor LSResidualFunc(const LSResidualFunc & rhs) : - IMultiGenFunction(), - IMultiGradFunction() - { + IMultiGenFunction(), + IMultiGradFunction() + { operator=(rhs); - } + } // assignment - LSResidualFunc & operator= (const LSResidualFunc & rhs) - { + LSResidualFunc & operator= (const LSResidualFunc & rhs) + { fIndex = rhs.fIndex; - fChi2 = rhs.fChi2; + fChi2 = rhs.fChi2; fX2 = rhs.fX2; return *this; - } + } - IMultiGenFunction * Clone() const { - return new LSResidualFunc(*fChi2,fIndex); + IMultiGenFunction * Clone() const { + return new LSResidualFunc(*fChi2,fIndex); } unsigned int NDim() const { return fChi2->NDim(); } - void Gradient( const double * x, double * g) const { - double f0 = 0; + void Gradient( const double * x, double * g) const { + double f0 = 0; FdF(x,f0,g); } - void FdF (const double * x, double & f, double * g) const { - unsigned int n = NDim(); + void FdF (const double * x, double & f, double * g) const { + unsigned int n = NDim(); std::copy(x,x+n,fX2.begin()); const double kEps = 1.0E-4; - f = DoEval(x); - for (unsigned int i = 0; i < n; ++i) { + f = DoEval(x); + for (unsigned int i = 0; i < n; ++i) { fX2[i] += kEps; g[i] = ( DoEval(&fX2.front()) - f )/kEps; fX2[i] = x[i]; } - } - + } -private: - double DoEval (const double * x) const { +private: + + double DoEval (const double * x) const { return fChi2->DataElement(x, fIndex); } - - double DoDerivative(const double * x, unsigned int icoord) const { + + double DoDerivative(const double * x, unsigned int icoord) const { //return ROOT::Math::Derivator::Eval(*this, x, icoord, 1E-8); std::copy(x,x+NDim(),fX2.begin()); const double kEps = 1.0E-4; @@ -144,117 +144,114 @@ private: return ( DoEval(&fX2.front()) - DoEval(x) )/kEps; } - unsigned int fIndex; - const ROOT::Math::FitMethodFunction * fChi2; + unsigned int fIndex; + const ROOT::Math::FitMethodFunction * fChi2; mutable std::vector<double> fX2; // cached vector }; //_____________________________________________________________________________________________________ -/** +/** GSLNLSMinimizer class for Non Linear Least Square fitting - It Uses the Levemberg-Marquardt algorithm from + It Uses the Levemberg-Marquardt algorithm from <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Nonlinear-Least_002dSquares-Fitting.html"> GSL Non Linear Least Square fitting</A>. @ingroup MultiMin -*/ +*/ class GSLNLSMinimizer : public ROOT::Math::BasicMinimizer { -public: +public: - /** + /** Default constructor - */ - GSLNLSMinimizer (int type = 0); + */ + GSLNLSMinimizer (int type = 0); - /** + /** Destructor (no operations) - */ - ~GSLNLSMinimizer (); + */ + ~GSLNLSMinimizer (); private: // usually copying is non trivial, so we make this unaccessible - /** + /** Copy constructor - */ - GSLNLSMinimizer(const GSLNLSMinimizer &) : ROOT::Math::BasicMinimizer() {} + */ + GSLNLSMinimizer(const GSLNLSMinimizer &) : ROOT::Math::BasicMinimizer() {} - /** + /** Assignment operator - */ + */ GSLNLSMinimizer & operator = (const GSLNLSMinimizer & rhs) { if (this == &rhs) return *this; // time saving self-test return *this; } -public: +public: /// set the function to minimize - virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func); + virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func); /// set gradient the function to minimize - virtual void SetFunction(const ROOT::Math::IMultiGradFunction & func); + virtual void SetFunction(const ROOT::Math::IMultiGradFunction & func); + - /// method to perform the minimization - virtual bool Minimize(); + virtual bool Minimize(); /// return expected distance reached from the minimum virtual double Edm() const { return fEdm; } // not impl. } - /// return pointer to gradient values at the minimum - virtual const double * MinGradient() const; + /// return pointer to gradient values at the minimum + virtual const double * MinGradient() const; - /// number of function calls to reach the minimum - virtual unsigned int NCalls() const { return (fChi2Func) ? fChi2Func->NCalls() : 0; } + /// number of function calls to reach the minimum + virtual unsigned int NCalls() const { return (fChi2Func) ? fChi2Func->NCalls() : 0; } - /// number of free variables (real dimension of the problem) - /// this is <= Function().NDim() which is the total -// virtual unsigned int NFree() const { return fNFree; } + /// number of free variables (real dimension of the problem) + /// this is <= Function().NDim() which is the total +// virtual unsigned int NFree() const { return fNFree; } /// minimizer provides error and error matrix - virtual bool ProvidesError() const { return true; } + virtual bool ProvidesError() const { return true; } - /// return errors at the minimum + /// return errors at the minimum virtual const double * Errors() const { return (fErrors.size() > 0) ? &fErrors.front() : 0; } -// { -// static std::vector<double> err; +// { +// static std::vector<double> err; // err.resize(fDim); -// return &err.front(); +// return &err.front(); // } - /** return covariance matrices elements + /** return covariance matrices elements if the variable is fixed the matrix is zero The ordering of the variables is the same as in errors - */ + */ virtual double CovMatrix(unsigned int , unsigned int ) const; /// return covariance matrix status virtual int CovMatrixStatus() const; -protected: +protected: -private: - +private: - unsigned int fNFree; // dimension of the internal function to be minimized + unsigned int fNFree; // dimension of the internal function to be minimized unsigned int fSize; // number of fit points (residuals) - - ROOT::Math::GSLMultiFit * fGSLMultiFit; // pointer to GSL multi fit solver + ROOT::Math::GSLMultiFit * fGSLMultiFit; // pointer to GSL multi fit solver const ROOT::Math::FitMethodFunction * fChi2Func; // pointer to Least square function - - double fMinVal; // minimum function value + double fEdm; // edm value double fLSTolerance; // Line Search Tolerance - std::vector<double> fValues; + std::vector<double> fValues; std::vector<double> fErrors; - std::vector<double> fCovMatrix; // cov matrix (stored as cov[ i * dim + j] + std::vector<double> fCovMatrix; // cov matrix (stored as cov[ i * dim + j] std::vector<double> fSteps; std::vector<std::string> fNames; std::vector<LSResidualFunc> fResiduals; //! transient Vector of the residual functions @@ -263,7 +260,7 @@ private: std::map< unsigned int, std::pair<double, double> > fBounds; // map specifying the bound using as key the parameter index -}; +}; } // end namespace Math diff --git a/math/minuit2/inc/Minuit2/FumiliStandardChi2FCN.h b/math/minuit2/inc/Minuit2/FumiliStandardChi2FCN.h index 1909ff4f058..fbf7fb10d12 100644 --- a/math/minuit2/inc/Minuit2/FumiliStandardChi2FCN.h +++ b/math/minuit2/inc/Minuit2/FumiliStandardChi2FCN.h @@ -1,5 +1,5 @@ // @(#)root/minuit2:$Id$ -// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 +// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 /********************************************************************** * * @@ -10,7 +10,7 @@ #ifndef ROOT_Minuit2_FumiliStandardChi2FCN #define ROOT_Minuit2_FumiliStandardChi2FCN - + #include "Minuit2/FumiliChi2FCN.h" #include "Minuit2/ParametricFunction.h" #include <assert.h> @@ -26,8 +26,8 @@ namespace ROOT { /** Class implementing the standard chi square function, which -is the sum of the squares of the figures-of-merit calculated for each measurement -point, the individual figures-of-merit being: (the Value predicted by the +is the sum of the squares of the figures-of-merit calculated for each measurement +point, the individual figures-of-merit being: (the Value predicted by the model-measured Value)/standard deviation. @author Andras Zsenei and Lorenzo Moneta, Creation date: 31 Aug 2004 @@ -46,9 +46,9 @@ public: /** - + Constructor which initializes chi square function for one-dimensional model function - + @param modelFCN the model function used for describing the data. @param meas vector containing the measured values. @@ -56,7 +56,7 @@ public: @param pos vector containing the x values corresponding to the measurements - @param mvar vector containing the variances corresponding to each + @param mvar vector containing the variances corresponding to each measurement (where the variance equals the standard deviation squared). If the variances are zero, a Value of 1 is used (as it is done in ROOT/PAW) @@ -64,36 +64,36 @@ public: FumiliStandardChi2FCN(const ParametricFunction& modelFCN, const std::vector<double>& meas, const std::vector<double>& pos, - const std::vector<double>& mvar) : - fErrorDef(1.) { //this->fModelFCN = &modelFunction; - this->SetModelFunction(modelFCN); + const std::vector<double>& mvar) + { //this->fModelFCN = &modelFunction; + this->SetModelFunction(modelFCN); assert(meas.size() == pos.size()); assert(meas.size() == mvar.size()); fMeasurements = meas; - std::vector<double> x(1); - unsigned int n = mvar.size(); + std::vector<double> x(1); + unsigned int n = mvar.size(); fPositions.reserve( n); // correct for variance == 0 fInvErrors.resize(n); - for (unsigned int i = 0; i < n; ++i) - { + for (unsigned int i = 0; i < n; ++i) + { x[0] = pos[i]; fPositions.push_back(x); // PAW/ROOT hack : use 1 for 0 entries bins - if (mvar[i] == 0) - fInvErrors[i] = 1; - else - fInvErrors[i] = 1.0/std::sqrt(mvar[i]); + if (mvar[i] == 0) + fInvErrors[i] = 1; + else + fInvErrors[i] = 1.0/std::sqrt(mvar[i]); } } /** - + Constructor which initializes the multi-dimensional model function. - + @param modelFCN the model function used for describing the data. @param meas vector containing the measured values. @@ -101,7 +101,7 @@ public: @param pos vector containing the x values corresponding to the measurements - @param mvar vector containing the variances corresponding to each + @param mvar vector containing the variances corresponding to each measurement (where the variance equals the standard deviation squared). If the variances are zero, a Value of 1 is used (as it is done in ROOT/PAW) @@ -109,24 +109,24 @@ public: FumiliStandardChi2FCN(const ParametricFunction& modelFCN, const std::vector<double>& meas, const std::vector<std::vector<double> >& pos, - const std::vector<double>& mvar) : - fErrorDef(1.) { //this->fModelFCN = &modelFunction; - this->SetModelFunction(modelFCN); + const std::vector<double>& mvar) + { //this->fModelFCN = &modelFunction; + this->SetModelFunction(modelFCN); assert(meas.size() == pos.size()); assert(meas.size() == mvar.size()); fMeasurements = meas; fPositions = pos; // correct for variance == 0 - unsigned int n = mvar.size(); + unsigned int n = mvar.size(); fInvErrors.resize(n); - for (unsigned int i = 0; i < n; ++i) - { + for (unsigned int i = 0; i < n; ++i) + { // PAW/ROOT hack : use 1 for 0 entries bins - if (mvar[i] == 0) - fInvErrors[i] = 1; - else - fInvErrors[i] = 1.0/std::sqrt(mvar[i]); + if (mvar[i] == 0) + fInvErrors[i] = 1; + else + fInvErrors[i] = 1.0/std::sqrt(mvar[i]); } } @@ -142,16 +142,16 @@ public: /** - Evaluates the model function for the different measurement points and + Evaluates the model function for the different measurement points and the Parameter values supplied, calculates a figure-of-merit for each measurement and returns a vector containing the result of this - evaluation. The figure-of-merit is (Value predicted by the model + evaluation. The figure-of-merit is (Value predicted by the model function-measured Value)/standard deviation. @param par vector of Parameter values to feed to the model function. - @return A vector containing the figures-of-merit for the model function evaluated - for each set of measurements. + @return A vector containing the figures-of-merit for the model function evaluated + for each set of measurements. \todo What to do when the variances are 0???!! (right now just pushes back 0...) @@ -176,7 +176,7 @@ public: /** - Accessor to the number of measurements used for calculating + Accessor to the number of measurements used for calculating the chi-square. @return the number of measurements. @@ -187,16 +187,16 @@ public: /** - + Evaluate function Value, Gradient and Hessian using Fumili approximation, for values of parameters p - The resul is cached inside and is return from the FumiliFCNBase::Value , FumiliFCNBase::Gradient and - FumiliFCNBase::Hessian methods + The resul is cached inside and is return from the FumiliFCNBase::Value , FumiliFCNBase::Gradient and + FumiliFCNBase::Hessian methods @param par vector of parameters **/ - virtual void EvaluateAll( const std::vector<double> & par ); + virtual void EvaluateAll( const std::vector<double> & par ); private: @@ -206,10 +206,6 @@ public: // support multi dim coordinates std::vector<std::vector<double> > fPositions; std::vector<double> fInvErrors; - double fErrorDef; - - - }; } // namespace Minuit2 diff --git a/math/minuit2/inc/Minuit2/FumiliStandardMaximumLikelihoodFCN.h b/math/minuit2/inc/Minuit2/FumiliStandardMaximumLikelihoodFCN.h index ab6ea60604c..4bd2c68373c 100644 --- a/math/minuit2/inc/Minuit2/FumiliStandardMaximumLikelihoodFCN.h +++ b/math/minuit2/inc/Minuit2/FumiliStandardMaximumLikelihoodFCN.h @@ -1,5 +1,5 @@ // @(#)root/minuit2:$Id$ -// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 +// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 /********************************************************************** * * @@ -24,7 +24,7 @@ namespace ROOT { /** -Class implementing the Elements member function for the standard +Class implementing the Elements member function for the standard maximum likelihood method. @author Andras Zsenei and Lorenzo Moneta, Creation date: 4 Sep 2004 @@ -41,9 +41,9 @@ public: /** - + Constructor which initializes the measurement points for the one dimensional model function. - + @param modelFCN the model function used for describing the data. @param pos vector containing the x values corresponding to the @@ -51,26 +51,25 @@ public: */ - FumiliStandardMaximumLikelihoodFCN(const ParametricFunction& modelFCN, - const std::vector<double>& pos) : - fErrorDef(0.5) + FumiliStandardMaximumLikelihoodFCN(const ParametricFunction& modelFCN, + const std::vector<double>& pos) { - this->SetModelFunction(modelFCN); - unsigned int n = pos.size(); + this->SetModelFunction(modelFCN); + unsigned int n = pos.size(); fPositions.reserve( n ); std::vector<double> x(1); - for (unsigned int i = 0; i < n; ++i) { + for (unsigned int i = 0; i < n; ++i) { x[0] = pos[i]; - fPositions.push_back(x); + fPositions.push_back(x); } } /** - + Constructor which initializes the measurement points for the multi dimensional model function. - + @param modelFCN the model function used for describing the data. @param pos vector containing the x values corresponding to the @@ -78,10 +77,9 @@ public: */ - FumiliStandardMaximumLikelihoodFCN(const ParametricFunction& modelFCN, - const std::vector<std::vector<double> >& pos) : - fErrorDef(0.5) { - this->SetModelFunction(modelFCN); + FumiliStandardMaximumLikelihoodFCN(const ParametricFunction& modelFCN, + const std::vector<std::vector<double> >& pos) { + this->SetModelFunction(modelFCN); fPositions = pos; } @@ -96,13 +94,13 @@ public: /** - Evaluates the model function for the different measurement points and + Evaluates the model function for the different measurement points and the Parameter values supplied. @param par vector of Parameter values to feed to the model function. - @return A vector containing the model function evaluated - for each measurement point. + @return A vector containing the model function evaluated + for each measurement point. */ @@ -126,7 +124,7 @@ public: /** - Accessor to the number of measurements used for calculating + Accessor to the number of measurements used for calculating the maximum likelihood. @return the number of measurements. @@ -136,10 +134,10 @@ public: virtual int GetNumberOfMeasurements() const; /** - + Evaluate function Value, Gradient and Hessian using Fumili approximation, for values of parameters p - The resul is cached inside and is return from the FumiliFCNBase::Value , FumiliFCNBase::Gradient and - FumiliFCNBase::Hessian methods + The resul is cached inside and is return from the FumiliFCNBase::Value , FumiliFCNBase::Gradient and + FumiliFCNBase::Hessian methods @param par vector of parameters @@ -151,10 +149,6 @@ public: private: std::vector<std::vector<double> > fPositions; - double fErrorDef; - - - }; } // namespace Minuit2 -- GitLab