1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00:00

code cleaning

This commit is contained in:
Antonin Portelli 2020-01-28 17:55:47 +00:00
parent 1775f4992b
commit 1d6a66263d
3 changed files with 26 additions and 2 deletions

View File

@ -23,6 +23,9 @@
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;
/******************************************************************************
* Correlator models *
******************************************************************************/
DoubleModel CorrelatorModels::makeExpModel(const Index nState) DoubleModel CorrelatorModels::makeExpModel(const Index nState)
{ {
DoubleModel mod; DoubleModel mod;
@ -224,6 +227,10 @@ DVec CorrelatorModels::parameterGuess(const DMatSample &corr,
return init; return init;
} }
/******************************************************************************
* CorrelatorFitter implementation *
******************************************************************************/
// constructors ////////////////////////////////////////////////////////////////
CorrelatorFitter::CorrelatorFitter(const DMatSample &corr) CorrelatorFitter::CorrelatorFitter(const DMatSample &corr)
{ {
setCorrelator(corr); setCorrelator(corr);
@ -234,6 +241,7 @@ CorrelatorFitter::CorrelatorFitter(const std::vector<DMatSample> &corr)
setCorrelators(corr); setCorrelators(corr);
} }
// access //////////////////////////////////////////////////////////////////////
XYSampleData & CorrelatorFitter::data(void) XYSampleData & CorrelatorFitter::data(void)
{ {
return *data_; return *data_;
@ -294,7 +302,7 @@ void CorrelatorFitter::setCorrelation(const bool isCorrelated, const Index i,
data_->assumeYYCorrelated(isCorrelated, i, j); data_->assumeYYCorrelated(isCorrelated, i, j);
} }
DMat CorrelatorFitter::getVarianceMatrix(void) DMat CorrelatorFitter::getVarianceMatrix(void) const
{ {
return data_->getFitVarMat(); return data_->getFitVarMat();
} }
@ -305,6 +313,7 @@ void CorrelatorFitter::setThinning(const Index thinning, const Index i)
refreshRanges(); refreshRanges();
} }
// fit functions ///////////////////////////////////////////////////////////////
SampleFitResult CorrelatorFitter::fit(Minimizer &minimizer, const DVec &init) SampleFitResult CorrelatorFitter::fit(Minimizer &minimizer, const DVec &init)
{ {
vector<Minimizer *> vecPt = {&minimizer}; vector<Minimizer *> vecPt = {&minimizer};
@ -325,6 +334,7 @@ SampleFitResult CorrelatorFitter::fit(vector<Minimizer *> &minimizer,
return data_->fit(minimizer, init, vecPt); return data_->fit(minimizer, init, vecPt);
} }
// internal function to refresh fit ranges /////////////////////////////////////
void CorrelatorFitter::refreshRanges(void) void CorrelatorFitter::refreshRanges(void)
{ {
for (unsigned int i = 0; i < range_.size(); ++i) for (unsigned int i = 0; i < range_.size(); ++i)

View File

@ -26,6 +26,9 @@
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE
/******************************************************************************
* Correlator types & models *
******************************************************************************/
enum class CorrelatorType {undefined, exp, cosh, sinh, linear, cst}; enum class CorrelatorType {undefined, exp, cosh, sinh, linear, cst};
namespace CorrelatorModels namespace CorrelatorModels
@ -46,12 +49,18 @@ namespace CorrelatorModels
DVec parameterGuess(const DMatSample &corr, const ModelPar par); DVec parameterGuess(const DMatSample &corr, const ModelPar par);
}; };
/******************************************************************************
* Correlator fit utility class *
******************************************************************************/
class CorrelatorFitter class CorrelatorFitter
{ {
public: public:
// constructors
CorrelatorFitter(const DMatSample &corr); CorrelatorFitter(const DMatSample &corr);
CorrelatorFitter(const std::vector<DMatSample> &corr); CorrelatorFitter(const std::vector<DMatSample> &corr);
// destructor
virtual ~CorrelatorFitter(void) = default; virtual ~CorrelatorFitter(void) = default;
// access
XYSampleData & data(void); XYSampleData & data(void);
void setCorrelator(const DMatSample &corr); void setCorrelator(const DMatSample &corr);
void setCorrelators(const std::vector<DMatSample> &corr); void setCorrelators(const std::vector<DMatSample> &corr);
@ -62,11 +71,13 @@ public:
void setFitRange(const Index tMin, const Index tMax, const Index i = 0); void setFitRange(const Index tMin, const Index tMax, const Index i = 0);
void setCorrelation(const bool isCorrelated, const Index i = 0, void setCorrelation(const bool isCorrelated, const Index i = 0,
const Index j = 0); const Index j = 0);
DMat getVarianceMatrix(void); DMat getVarianceMatrix(void) const;
void setThinning(const Index thinning, const Index i = 0); void setThinning(const Index thinning, const Index i = 0);
// fit functions
SampleFitResult fit(Minimizer &minimizer, const DVec &init); SampleFitResult fit(Minimizer &minimizer, const DVec &init);
SampleFitResult fit(std::vector<Minimizer *> &minimizer, const DVec &init); SampleFitResult fit(std::vector<Minimizer *> &minimizer, const DVec &init);
private: private:
// internal function to refresh fit ranges
void refreshRanges(void); void refreshRanges(void);
private: private:
Index nt_{0}; Index nt_{0};

View File

@ -23,6 +23,9 @@
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;
/******************************************************************************
* EffectiveMass implementation *
******************************************************************************/
// constructors //////////////////////////////////////////////////////////////// // constructors ////////////////////////////////////////////////////////////////
EffectiveMass::EffectiveMass(const CorrelatorType type) EffectiveMass::EffectiveMass(const CorrelatorType type)
{ {