diff --git a/math/fumili/src/TFumiliMinimizer.cxx b/math/fumili/src/TFumiliMinimizer.cxx index f90ef0d883f3bd50325cd8894815f15057dd0183..e9889b19c55d5b75b2526573cb3fa9ba492bbb25 100644 --- a/math/fumili/src/TFumiliMinimizer.cxx +++ b/math/fumili/src/TFumiliMinimizer.cxx @@ -399,6 +399,7 @@ bool TFumiliMinimizer::SetVariable(unsigned int ivar, const std::string & name, // set a free variable. if (fFumili == 0) { Error("SetVariableValue","invalid TFumili pointer. Set function first "); + return false; } #ifdef DEBUG std::cout << "set variable " << ivar << " " << name << " value " << val << " step " << step << std::endl; @@ -416,6 +417,7 @@ bool TFumiliMinimizer::SetLimitedVariable(unsigned int ivar, const std::string & // set a limited variable. if (fFumili == 0) { Error("SetVariableValue","invalid TFumili pointer. Set function first "); + return false; } #ifdef DEBUG std::cout << "set limited variable " << ivar << " " << name << " value " << val << " step " << step << std::endl; @@ -442,6 +444,7 @@ bool TFumiliMinimizer::SetFixedVariable(unsigned int ivar, const std::string & n // set a fixed variable. if (fFumili == 0) { Error("SetVariableValue","invalid TFumili pointer. Set function first "); + return false; } @@ -463,10 +466,9 @@ bool TFumiliMinimizer::SetVariableValue(unsigned int ivar, double val) { // set the variable value if (fFumili == 0) { Error("SetVariableValue","invalid TFumili pointer. Set function first "); + return false; } - TString name = fFumili->GetParName(ivar - -); + TString name = fFumili->GetParName(ivar); double oldval, verr, vlow, vhigh = 0; int ierr = fFumili->GetParameter( ivar, &name[0], oldval, verr, vlow, vhigh); if (ierr) { @@ -492,7 +494,11 @@ bool TFumiliMinimizer::Minimize() { // Return true if the found minimum is valid and update internal chached values of // minimum values, errors and covariance matrix. - assert(fFumili != 0 ); + if (fFumili == 0) { + Error("SetVariableValue","invalid TFumili pointer. Set function first "); + return false; + } + // need to set static instance to be used when calling FCN fgFumili = fFumili; diff --git a/math/mathcore/inc/Fit/PoissonLikelihoodFCN.h b/math/mathcore/inc/Fit/PoissonLikelihoodFCN.h index 2f6d5ca67a28c43d8afd564399d34162972f81c0..cc74156afc0e2ab4ac7ed45aa8a13c54c5984dc5 100644 --- a/math/mathcore/inc/Fit/PoissonLikelihoodFCN.h +++ b/math/mathcore/inc/Fit/PoissonLikelihoodFCN.h @@ -145,10 +145,7 @@ private: const BinData & fData; const IModelFunction & fFunc; - unsigned int fNDim; - unsigned int fNPoints; // size of the data mutable unsigned int fNEffPoints; // number of effective points used in the fit - mutable unsigned int fNCalls; mutable std::vector<double> fGrad; // for derivatives diff --git a/math/mathcore/inc/Math/FitMethodFunction.h b/math/mathcore/inc/Math/FitMethodFunction.h index 2a7a94393e92e663c2b204916c8362b41166c87f..5abffef9ca9aec845f38cdaadf206d0d71813532 100644 --- a/math/mathcore/inc/Math/FitMethodFunction.h +++ b/math/mathcore/inc/Math/FitMethodFunction.h @@ -102,9 +102,9 @@ protected: private: - unsigned int fNDim; + unsigned int fNDim; // function dimension unsigned int fNPoints; // size of the data - mutable unsigned int fNCalls; + mutable unsigned int fNCalls; // number of function calls }; diff --git a/math/mathcore/inc/Math/MinimTransformFunction.h b/math/mathcore/inc/Math/MinimTransformFunction.h index a35c01c1f4cd2c5a03441b98c48f5ac1fcc9d543..264607731b7338a16e7a466977bc6580e7a80874 100644 --- a/math/mathcore/inc/Math/MinimTransformFunction.h +++ b/math/mathcore/inc/Math/MinimTransformFunction.h @@ -130,7 +130,6 @@ private: std::vector<MinimizerVariable> fVariables; // vector of variable settings and tranformation function std::vector<unsigned int> fIndex; // vector with external indices for internal variables const IMultiGradFunction * fFunc; // user function - bool fHasTransform; // a function transformation is applied }; diff --git a/math/mathcore/src/AdaptiveIntegratorMultiDim.cxx b/math/mathcore/src/AdaptiveIntegratorMultiDim.cxx index fbfff0564952a42b42af91466ecc114a3bdc9826..ea88abb17cc1970d7e51d7019d1911222016e162 100644 --- a/math/mathcore/src/AdaptiveIntegratorMultiDim.cxx +++ b/math/mathcore/src/AdaptiveIntegratorMultiDim.cxx @@ -16,11 +16,13 @@ AdaptiveIntegratorMultiDim::AdaptiveIntegratorMultiDim(double absTol, double rel fDim(0), fAbsTol(absTol), fRelTol(relTol), - fSize(size) - + fSize(size), + fResult(0), fError(0), + fNEval(0), + fStatus(-1), + fFun(0) { // constructor - without passing a function - fFun = 0; } AdaptiveIntegratorMultiDim::AdaptiveIntegratorMultiDim( const IMultiGenFunction &f, double absTol, double relTol, unsigned int size): @@ -28,6 +30,9 @@ AdaptiveIntegratorMultiDim::AdaptiveIntegratorMultiDim( const IMultiGenFunction fAbsTol(absTol), fRelTol(relTol), fSize(size), + fResult(0), fError(0), + fNEval(0), + fStatus(-1), fFun(&f) { // constructur passing a multi-dimensional function interface diff --git a/math/mathcore/src/DataRange.cxx b/math/mathcore/src/DataRange.cxx index 3c89e01e241a2bf8995b9e30e188b92d79bbca44..1b0736a46ba0ea27fabffeaa320701ed771851b9 100644 --- a/math/mathcore/src/DataRange.cxx +++ b/math/mathcore/src/DataRange.cxx @@ -154,7 +154,7 @@ void DataRange::CleanRangeSet(unsigned int icoord, double xmin, double xmax) { for (RangeSet::iterator itr = ranges.begin(); itr != ranges.end(); ++itr) { // delete included ranges if ( itr->first >= xmin && itr->second <= xmax) { - ranges.erase(itr); + itr = ranges.erase(itr); // itr goes to next element, so go back before adding --itr; } diff --git a/math/mathcore/src/Fitter.cxx b/math/mathcore/src/Fitter.cxx index d0d7679797e36e5a8185a545f58f55a80a9c268d..ed6740f9e3496a78a1d8be9e29cf086f8f51c0f4 100644 --- a/math/mathcore/src/Fitter.cxx +++ b/math/mathcore/src/Fitter.cxx @@ -83,7 +83,8 @@ void Fitter::SetFunction(const IModelFunction & func) // set the fit model function (clone the given one and keep a copy ) //std::cout << "set a non-grad function" << std::endl; - fFunc = dynamic_cast<IModelFunction *> ( func.Clone() ); + fFunc = dynamic_cast<IModelFunction *>(func.Clone() ); + assert(fFunc != 0); // creates the parameter settings fConfig.CreateParamsSettings(*fFunc); diff --git a/math/mathcore/src/UnBinData.cxx b/math/mathcore/src/UnBinData.cxx index 65b01c10e1a05f409987d4068bd721b9edae5e9d..1698ad5bfe0e6db0ccce842ba578c182cb713ac6 100644 --- a/math/mathcore/src/UnBinData.cxx +++ b/math/mathcore/src/UnBinData.cxx @@ -189,16 +189,21 @@ void UnBinData::Resize(unsigned int npoints) { MATH_ERROR_MSGVAL("BinData::Resize"," Invalid data size ", npoints ); return; } - - int nextraPoints = npoints - DataSize()/fDim; - if (nextraPoints == 0) return; - else if (nextraPoints < 0) { - // delete extra points - if (!fDataVector) return; - (fDataVector->Data()).resize( npoints * fDim); - } - else - Initialize(nextraPoints, fDim ); + if (fDataVector != 0) { + int nextraPoints = npoints - fDataVector->Size()/fDim; + if (nextraPoints < 0) { + // delete extra points + (fDataVector->Data()).resize( npoints * fDim); + } + else if (nextraPoints > 0) { + // add extra points + Initialize(nextraPoints, fDim ); + } + else // nextraPoints == 0 + return; + } + else // no DataVector create + fDataVector = new DataVector( npoints*fDim); } diff --git a/math/mathmore/inc/Math/GSLRndmEngines.h b/math/mathmore/inc/Math/GSLRndmEngines.h index 7149a8147d7e97dce8e6dc75850f98f9431a5aee..172dff195ff15d52bfce391b260036de02218d30 100644 --- a/math/mathmore/inc/Math/GSLRndmEngines.h +++ b/math/mathmore/inc/Math/GSLRndmEngines.h @@ -97,9 +97,9 @@ namespace Math { void Terminate(); /** - no operation, rng is delete in Terminate() + call Terminate() */ - virtual ~GSLRandomEngine() {} + virtual ~GSLRandomEngine(); /** Generate a random number between ]0,1] diff --git a/math/mathmore/src/GSLMCIntegrator.cxx b/math/mathmore/src/GSLMCIntegrator.cxx index ab5d7cd4a552ed582d9d7f9d10c1ed726b77a6f6..0dba37af9802f08ef3b17753cf232a82d2d5b59e 100644 --- a/math/mathmore/src/GSLMCIntegrator.cxx +++ b/math/mathmore/src/GSLMCIntegrator.cxx @@ -315,6 +315,7 @@ double GSLMCIntegrator::Sigma() if(fType == MCIntegration::kVEGAS) { GSLVegasIntegrationWorkspace * ws = dynamic_cast<GSLVegasIntegrationWorkspace *>(fWorkspace); + assert (ws != 0); return ws->GetWS()->sigma; } else @@ -334,6 +335,7 @@ double GSLMCIntegrator::ChiSqr() if(fType == MCIntegration::kVEGAS) { GSLVegasIntegrationWorkspace * ws = dynamic_cast<GSLVegasIntegrationWorkspace *>(fWorkspace); + assert(ws != 0); return ws->GetWS()->chisq; } else diff --git a/math/mathmore/src/GSLMinimizer.cxx b/math/mathmore/src/GSLMinimizer.cxx index 184a1bb2b6006b52654dc5e7f7f6057d61f8fb19..2aae542523821749d01cc888ed55247610bd9cc7 100644 --- a/math/mathmore/src/GSLMinimizer.cxx +++ b/math/mathmore/src/GSLMinimizer.cxx @@ -186,7 +186,8 @@ void GSLMinimizer::SetFunction(const ROOT::Math::IMultiGenFunction & func) { void GSLMinimizer::SetFunction(const ROOT::Math::IMultiGradFunction & func) { // set the function to minimizer - fObjFunc = dynamic_cast< const ROOT::Math::IMultiGradFunction *>(func.Clone() ); + fObjFunc = dynamic_cast<const ROOT::Math::IMultiGradFunction *>( func.Clone()); + assert(fObjFunc != 0); fDim = fObjFunc->NDim(); } diff --git a/math/mathmore/src/GSLRndmEngines.cxx b/math/mathmore/src/GSLRndmEngines.cxx index 250c0402b7cada4db82646017335ad813d444b8f..48f1ad016c2d204afc24dad96ff32402cb28f437 100644 --- a/math/mathmore/src/GSLRndmEngines.cxx +++ b/math/mathmore/src/GSLRndmEngines.cxx @@ -62,6 +62,11 @@ namespace Math { } + GSLRandomEngine::~GSLRandomEngine() { + // destructor : call terminate + if (fRng) Terminate(); + } + void GSLRandomEngine::Initialize() { //---------------------------------------------------- assert(fRng != 0); diff --git a/math/mathmore/src/GSLSimAnMinimizer.cxx b/math/mathmore/src/GSLSimAnMinimizer.cxx index 53a8fb599f1d2fd52eb673d9232d0c8a1120600e..39180d75098407b73ee699bbfb2091e8db27d9d7 100644 --- a/math/mathmore/src/GSLSimAnMinimizer.cxx +++ b/math/mathmore/src/GSLSimAnMinimizer.cxx @@ -31,7 +31,8 @@ namespace ROOT { GSLSimAnMinimizer::GSLSimAnMinimizer( int /* ROOT::Math::EGSLSimAnMinimizerType type */ ) : fDim(0), fOwnFunc(false), - fObjFunc(0) + fObjFunc(0), + fMinVal(0) { // Constructor implementation : create GSLMultiFit wrapper object diff --git a/math/minuit/src/TLinearFitter.cxx b/math/minuit/src/TLinearFitter.cxx index 6b385a01e08af25546d24fcf8bf08116f7cfc4c8..37a5d354ac7df1e5c1fa06d085687d9357888ef5 100644 --- a/math/minuit/src/TLinearFitter.cxx +++ b/math/minuit/src/TLinearFitter.cxx @@ -186,23 +186,24 @@ ClassImp(TLinearFitter) //______________________________________________________________________________ -TLinearFitter::TLinearFitter() - :TVirtualFitter(), - fParams(), - fParCovar(), - fTValues(), - fDesign(), - fDesignTemp(), - fDesignTemp2(), - fDesignTemp3(), - fAtb(), - fAtbTemp(), - fAtbTemp2(), - fAtbTemp3(), - fFunctions(), - fY(), - fX(), - fE() +TLinearFitter::TLinearFitter() : +TVirtualFitter(), + fParams(), + fParCovar(), + fTValues(), + fDesign(), + fDesignTemp(), + fDesignTemp2(), + fDesignTemp3(), + fAtb(), + fAtbTemp(), + fAtbTemp2(), + fAtbTemp3(), + fFunctions(), + fY(), + fX(), + fE(), + fVal() { //default c-tor, input data is stored //If you don't want to store the input data, @@ -222,10 +223,13 @@ TLinearFitter::TLinearFitter() fStoreData =kTRUE; fRobust =kFALSE; fNfunctions = 0; + fFormulaSize = 0; + fH = 0; } //______________________________________________________________________________ -TLinearFitter::TLinearFitter(Int_t ndim) +TLinearFitter::TLinearFitter(Int_t ndim) : + fVal() { //The parameter stands for number of dimensions in the fitting formula //The input data is stored. If you don't want to store the input data, @@ -245,6 +249,8 @@ TLinearFitter::TLinearFitter(Int_t ndim) fStoreData=kTRUE; fRobust = kFALSE; fNfunctions = 0; + fFormulaSize = 0; + fH = 0; } //______________________________________________________________________________ diff --git a/math/minuit/src/TLinearMinimizer.cxx b/math/minuit/src/TLinearMinimizer.cxx index a6af452d211caf6ad174462748d513f5e0c65540..41cbf8e50e7caaf0b5c8d119900b7f7c59c53490 100644 --- a/math/minuit/src/TLinearMinimizer.cxx +++ b/math/minuit/src/TLinearMinimizer.cxx @@ -68,6 +68,8 @@ ClassImp(TLinearMinimizer) TLinearMinimizer::TLinearMinimizer(int ) : fRobust(false), fDim(0), + fNFree(0), + fMinVal(0), fObjFunc(0), fFitter(0) { @@ -78,6 +80,8 @@ TLinearMinimizer::TLinearMinimizer(int ) : TLinearMinimizer::TLinearMinimizer ( const char * type ) : fRobust(false), fDim(0), + fNFree(0), + fMinVal(0), fObjFunc(0), fFitter(0) { diff --git a/math/minuit/src/TMinuitMinimizer.cxx b/math/minuit/src/TMinuitMinimizer.cxx index 99d90e4db369cf7c80b91a7d8d8a50a59f2aa9d5..074a620cc767efa56bd4b8b85e04a444a2801f15 100644 --- a/math/minuit/src/TMinuitMinimizer.cxx +++ b/math/minuit/src/TMinuitMinimizer.cxx @@ -47,6 +47,7 @@ ClassImp(TMinuitMinimizer) TMinuitMinimizer::TMinuitMinimizer(ROOT::Minuit::EMinimizerType type ) : fUsed(false), + fMinosRun(false), fDim(0), fStrategy(1), fType(type), @@ -60,6 +61,7 @@ TMinuitMinimizer::TMinuitMinimizer(ROOT::Minuit::EMinimizerType type ) : TMinuitMinimizer::TMinuitMinimizer(const char * type ) : fUsed(false), + fMinosRun(false), fDim(0), fStrategy(1), fMinuit(fgMinuit)