1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-04-11 03:20:46 +01:00

minor code cleaning

This commit is contained in:
Antonin Portelli 2016-03-16 18:33:06 +00:00
parent 2eb70aa975
commit 313a730bb2
5 changed files with 25 additions and 29 deletions

View File

@ -41,7 +41,6 @@ int main(void)
FitResult p; FitResult p;
MinuitMinimizer minimizer; MinuitMinimizer minimizer;
minimizer.setVerbosity(MinuitMinimizer::Verbosity::Debug);
p = data.fit(minimizer, init, f); p = data.fit(minimizer, init, f);
cout << "a= " << p(0) << " b= " << p(1); cout << "a= " << p(0) << " b= " << p(1);
cout << " chi^2/ndof= " << p.getChi2PerDof(); cout << " chi^2/ndof= " << p.getChi2PerDof();

View File

@ -26,9 +26,6 @@ using namespace Latan;
/****************************************************************************** /******************************************************************************
* FitInterface implementation * * FitInterface implementation *
******************************************************************************/ ******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
FitInterface::FitInterface(void)
{}
// add dimensions ////////////////////////////////////////////////////////////// // add dimensions //////////////////////////////////////////////////////////////
void FitInterface::addXDim(const string name, const Index nData, void FitInterface::addXDim(const string name, const Index nData,
@ -46,7 +43,7 @@ void FitInterface::addXDim(const string name, const Index nData,
xIsExact_.push_back(isExact); xIsExact_.push_back(isExact);
xDimIndex_[name] = xDimName_.size(); xDimIndex_[name] = xDimName_.size();
maxDataIndex_ *= nData; maxDataIndex_ *= nData;
createXData(nData); createXData(name, nData);
scheduleLayoutInit(); scheduleLayoutInit();
} }
} }
@ -56,7 +53,7 @@ void FitInterface::addYDim(const string name)
yDimName_.push_back(name); yDimName_.push_back(name);
yDataIndex_.push_back(map<Index, bool>()); yDataIndex_.push_back(map<Index, bool>());
yDimIndex_[name] = yDimName_.size(); yDimIndex_[name] = yDimName_.size();
createYData(); createYData(name);
scheduleLayoutInit(); scheduleLayoutInit();
} }
@ -375,6 +372,12 @@ DMat FitInterface::makeCorrFilter(void)
return f; return f;
} }
// schedule variance matrix initialization /////////////////////////////////////
void FitInterface::scheduleFitVarMatInit(const bool init)
{
initVarMat_ = init;
}
// register a data point /////////////////////////////////////////////////////// // register a data point ///////////////////////////////////////////////////////
void FitInterface::registerDataPoint(const Index k, const Index j) void FitInterface::registerDataPoint(const Index k, const Index j)
{ {
@ -390,11 +393,6 @@ void FitInterface::scheduleLayoutInit(void)
scheduleFitVarMatInit(); scheduleFitVarMatInit();
} }
void FitInterface::scheduleFitVarMatInit(const bool init)
{
initVarMat_ = init;
}
bool FitInterface::initVarMat(void) bool FitInterface::initVarMat(void)
{ {
return initVarMat_; return initVarMat_;

View File

@ -51,7 +51,7 @@ private:
} Layout; } Layout;
public: public:
// constructor // constructor
FitInterface(void); FitInterface(void) = default;
// destructor // destructor
virtual ~FitInterface(void) = default; virtual ~FitInterface(void) = default;
// add dimensions // add dimensions
@ -92,6 +92,8 @@ public:
bool isFitPoint(const Index k, const Index j) const; bool isFitPoint(const Index k, const Index j) const;
// make correlation filter for fit variance matrix // make correlation filter for fit variance matrix
DMat makeCorrFilter(void); DMat makeCorrFilter(void);
// schedule variance matrix initialization
void scheduleFitVarMatInit(const bool init = true);
// IO // IO
friend std::ostream & operator<<(std::ostream &out, FitInterface &f); friend std::ostream & operator<<(std::ostream &out, FitInterface &f);
protected: protected:
@ -101,11 +103,10 @@ protected:
static void addCorr(std::set<std::array<Index, 4>> &s, const bool isCorr, static void addCorr(std::set<std::array<Index, 4>> &s, const bool isCorr,
const std::array<Index, 4> &c); const std::array<Index, 4> &c);
// abstract methods to create data containers // abstract methods to create data containers
virtual void createXData(const Index nData) = 0; virtual void createXData(const std::string name, const Index nData) = 0;
virtual void createYData(void) = 0; virtual void createYData(const std::string name) = 0;
// global layout management // global layout management
void scheduleLayoutInit(void); void scheduleLayoutInit(void);
void scheduleFitVarMatInit(const bool init = true);
bool initVarMat(void); bool initVarMat(void);
void updateLayout(void); void updateLayout(void);
Index indX(const Index r, const Index i) const; Index indX(const Index r, const Index i) const;

View File

@ -57,20 +57,20 @@ const DoubleFunction & FitResult::getModel(const Index j) const
* XYStatData implementation * * XYStatData implementation *
******************************************************************************/ ******************************************************************************/
// data access ///////////////////////////////////////////////////////////////// // data access /////////////////////////////////////////////////////////////////
double & XYStatData::x(const Index vi, const Index i) double & XYStatData::x(const Index r, const Index i)
{ {
checkXIndex(vi, i); checkXIndex(r, i);
scheduleXMapInit(); scheduleXMapInit();
scheduleChi2DataVecInit(); scheduleChi2DataVecInit();
return xData_[i](vi); return xData_[i](r);
} }
const double & XYStatData::x(const Index vi, const Index i) const const double & XYStatData::x(const Index r, const Index i) const
{ {
checkXIndex(vi, i); checkXIndex(r, i);
return xData_[i](vi); return xData_[i](r);
} }
double & XYStatData::y(const Index k, const Index j) double & XYStatData::y(const Index k, const Index j)
@ -247,13 +247,13 @@ FitResult XYStatData::fit(Minimizer &minimizer, const DVec &init,
} }
// create data ///////////////////////////////////////////////////////////////// // create data /////////////////////////////////////////////////////////////////
void XYStatData::createXData(const Index nData) void XYStatData::createXData(const std::string name __dumb, const Index nData)
{ {
xData_.push_back(DVec::Zero(nData)); xData_.push_back(DVec::Zero(nData));
resizeVarMat(); resizeVarMat();
} }
void XYStatData::createYData(void) void XYStatData::createYData(const std::string name __dumb)
{ {
yData_.push_back(map<Index, double>()); yData_.push_back(map<Index, double>());
resizeVarMat(); resizeVarMat();
@ -458,5 +458,3 @@ void XYStatData::updateChi2ModVec(const DVec p,
} }
chi2ModVec_.segment(a, layout.totalXSize) = xsi; chi2ModVec_.segment(a, layout.totalXSize) = xsi;
} }

View File

@ -63,8 +63,8 @@ public:
// destructor // destructor
virtual ~XYStatData(void) = default; virtual ~XYStatData(void) = default;
// data access // data access
double & x(const Index vi, const Index i = 0); double & x(const Index r, const Index i = 0);
const double & x(const Index vi, const Index i = 0) const; const double & x(const Index r, const Index i = 0) const;
double & y(const Index k, const Index j = 0); double & y(const Index k, const Index j = 0);
const double & y(const Index k, const Index j = 0) const; const double & y(const Index k, const Index j = 0) const;
void setXXVar(const Index i1, const Index i2, const DMat &m); void setXXVar(const Index i1, const Index i2, const DMat &m);
@ -88,8 +88,8 @@ public:
const DoubleModel &model, const Ts... models); const DoubleModel &model, const Ts... models);
protected: protected:
// create data // create data
virtual void createXData(const Index nData); virtual void createXData(const std::string name, const Index nData);
virtual void createYData(void); virtual void createYData(const std::string name);
void resizeVarMat(void); void resizeVarMat(void);
private: private:
// schedule buffer computation // schedule buffer computation