From 685d4330329c9ef3d07cefad1335bcd6acb5d33f Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 28 Jan 2020 17:34:37 +0000 Subject: [PATCH] minor fixes in new physics classes --- lib/Physics/CorrelatorFitter.cpp | 13 +++++++++---- lib/Physics/CorrelatorFitter.hpp | 2 ++ lib/Physics/EffectiveMass.cpp | 30 ++++++++++++++++++++++++++++-- lib/Physics/EffectiveMass.hpp | 1 + 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/lib/Physics/CorrelatorFitter.cpp b/lib/Physics/CorrelatorFitter.cpp index 6677978..d48699f 100644 --- a/lib/Physics/CorrelatorFitter.cpp +++ b/lib/Physics/CorrelatorFitter.cpp @@ -128,17 +128,17 @@ CorrelatorModels::ModelPar CorrelatorModels::parseModel(const string s) if (regex_match(s, sm, regex("exp([0-9]+)"))) { par.type = CorrelatorType::exp; - par.nState = strTo(sm[0].str()); + par.nState = strTo(sm[1].str()); } else if (regex_match(s, sm, regex("cosh([0-9]+)"))) { par.type = CorrelatorType::cosh; - par.nState = strTo(sm[0].str()); + par.nState = strTo(sm[1].str()); } else if (regex_match(s, sm, regex("sinh([0-9]+)"))) { par.type = CorrelatorType::sinh; - par.nState = strTo(sm[0].str()); + par.nState = strTo(sm[1].str()); } else if (s == "linear") { @@ -189,7 +189,7 @@ DVec CorrelatorModels::parameterGuess(const DMatSample &corr, const ModelPar par) { DVec init; - Index nt = corr.size(); + Index nt = corr[central].size(); switch (par.type) { @@ -234,6 +234,11 @@ CorrelatorFitter::CorrelatorFitter(const std::vector &corr) setCorrelators(corr); } +XYSampleData & CorrelatorFitter::data(void) +{ + return *data_; +} + void CorrelatorFitter::setCorrelator(const DMatSample &corr) { std::vector vec; diff --git a/lib/Physics/CorrelatorFitter.hpp b/lib/Physics/CorrelatorFitter.hpp index fe4071e..018cb87 100644 --- a/lib/Physics/CorrelatorFitter.hpp +++ b/lib/Physics/CorrelatorFitter.hpp @@ -51,6 +51,8 @@ class CorrelatorFitter public: CorrelatorFitter(const DMatSample &corr); CorrelatorFitter(const std::vector &corr); + virtual ~CorrelatorFitter(void) = default; + XYSampleData & data(void); void setCorrelator(const DMatSample &corr); void setCorrelators(const std::vector &corr); const DMatSample & getCorrelator(const Index i = 0) const; diff --git a/lib/Physics/EffectiveMass.cpp b/lib/Physics/EffectiveMass.cpp index 672643f..aa21126 100644 --- a/lib/Physics/EffectiveMass.cpp +++ b/lib/Physics/EffectiveMass.cpp @@ -25,8 +25,9 @@ using namespace Latan; // constructors //////////////////////////////////////////////////////////////// EffectiveMass::EffectiveMass(const CorrelatorType type) -: type_(type) -{} +{ + setType(type); +} // access ////////////////////////////////////////////////////////////////////// CorrelatorType EffectiveMass::getType(void) const @@ -39,6 +40,31 @@ void EffectiveMass::setType(const CorrelatorType type) type_ = type; } +DVec EffectiveMass::getTime(const Index nt) const +{ + DVec tvec; + + switch (type_) + { + case CorrelatorType::undefined: + LATAN_ERROR(Argument, "correlator type is undefined"); + break; + case CorrelatorType::exp: + case CorrelatorType::linear: + tvec = DVec::LinSpaced(nt - 1, 0, nt - 2); + break; + case CorrelatorType::cosh: + case CorrelatorType::sinh: + tvec = DVec::LinSpaced(nt - 2, 1, nt - 2); + break; + case CorrelatorType::cst: + tvec = DVec::LinSpaced(nt, 0, nt - 1); + break; + } + + return tvec; +} + // compute effective mass ////////////////////////////////////////////////////// DVec EffectiveMass::operator()(const DVec &corr) const { diff --git a/lib/Physics/EffectiveMass.hpp b/lib/Physics/EffectiveMass.hpp index 500dab7..ed42c1e 100644 --- a/lib/Physics/EffectiveMass.hpp +++ b/lib/Physics/EffectiveMass.hpp @@ -37,6 +37,7 @@ public: // access CorrelatorType getType(void) const; void setType(const CorrelatorType type); + DVec getTime(const Index nt) const; // compute effective mass DVec operator()(const DVec &corr) const; DMatSample operator()(const DMatSample &corr) const;