1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00: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;
MinuitMinimizer minimizer;
minimizer.setVerbosity(MinuitMinimizer::Verbosity::Debug);
p = data.fit(minimizer, init, f);
cout << "a= " << p(0) << " b= " << p(1);
cout << " chi^2/ndof= " << p.getChi2PerDof();

View File

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

View File

@ -51,7 +51,7 @@ private:
} Layout;
public:
// constructor
FitInterface(void);
FitInterface(void) = default;
// destructor
virtual ~FitInterface(void) = default;
// add dimensions
@ -92,6 +92,8 @@ public:
bool isFitPoint(const Index k, const Index j) const;
// make correlation filter for fit variance matrix
DMat makeCorrFilter(void);
// schedule variance matrix initialization
void scheduleFitVarMatInit(const bool init = true);
// IO
friend std::ostream & operator<<(std::ostream &out, FitInterface &f);
protected:
@ -101,11 +103,10 @@ protected:
static void addCorr(std::set<std::array<Index, 4>> &s, const bool isCorr,
const std::array<Index, 4> &c);
// abstract methods to create data containers
virtual void createXData(const Index nData) = 0;
virtual void createYData(void) = 0;
virtual void createXData(const std::string name, const Index nData) = 0;
virtual void createYData(const std::string name) = 0;
// global layout management
void scheduleLayoutInit(void);
void scheduleFitVarMatInit(const bool init = true);
bool initVarMat(void);
void updateLayout(void);
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 *
******************************************************************************/
// 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();
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)
@ -247,13 +247,13 @@ FitResult XYStatData::fit(Minimizer &minimizer, const DVec &init,
}
// 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));
resizeVarMat();
}
void XYStatData::createYData(void)
void XYStatData::createYData(const std::string name __dumb)
{
yData_.push_back(map<Index, double>());
resizeVarMat();
@ -458,5 +458,3 @@ void XYStatData::updateChi2ModVec(const DVec p,
}
chi2ModVec_.segment(a, layout.totalXSize) = xsi;
}

View File

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