diff --git a/lib/Core/Plot.cpp b/lib/Core/Plot.cpp index 3a236cd..a696be6 100644 --- a/lib/Core/Plot.cpp +++ b/lib/Core/Plot.cpp @@ -184,7 +184,7 @@ PlotData::PlotData(const DMatSample &x, const DVec &y, const bool abs) } else { - setCommand("'" + tmpFileName + "' u 1:($3):2 w xerr"); + setCommand("'" + tmpFileName + "' u 1:(abs($3)):2 w xerr"); } } @@ -206,6 +206,60 @@ PlotData::PlotData(const XYStatData &data, const Index i, const Index j, const b setCommand("'" + tmpFileName + "' " + usingCmd); } +// PlotPoint constructor /////////////////////////////////////////////////////// +PlotPoint::PlotPoint(const double x, const double y) +{ + DMat d(1, 2); + string usingCmd, tmpFileName; + + d(0, 0) = x; + d(0, 1) = y; + tmpFileName = dumpToTmpFile(d); + pushTmpFile(tmpFileName); + setCommand("'" + tmpFileName + "' u 1:2"); +} + +PlotPoint::PlotPoint(const DSample &x, const double y) +{ + DMat d(1, 3); + string usingCmd, tmpFileName; + + d(0, 0) = x[central]; + d(0, 2) = y; + d(0, 1) = sqrt(x.variance()); + tmpFileName = dumpToTmpFile(d); + pushTmpFile(tmpFileName); + setCommand("'" + tmpFileName + "' u 1:3:2 w xerr"); +} + +PlotPoint::PlotPoint(const double x, const DSample &y) +{ + DMat d(1, 3); + string usingCmd, tmpFileName; + + d(0, 0) = x; + d(0, 1) = y[central]; + d(0, 2) = sqrt(y.variance()); + tmpFileName = dumpToTmpFile(d); + pushTmpFile(tmpFileName); + setCommand("'" + tmpFileName + "' u 1:2:3 w yerr"); +} + +PlotPoint::PlotPoint(const DSample &x, const DSample &y) +{ + DMat d(1, 4); + string usingCmd, tmpFileName; + + d(0, 0) = x[central]; + d(0, 2) = y[central]; + d(0, 1) = sqrt(x.variance()); + d(0, 3) = sqrt(y.variance()); + tmpFileName = dumpToTmpFile(d); + pushTmpFile(tmpFileName); + setCommand("'" + tmpFileName + "' u 1:3:2:4 w xyerr"); +} + + // PlotLine constructor //////////////////////////////////////////////////////// PlotLine::PlotLine(const DVec &x, const DVec &y) { diff --git a/lib/Core/Plot.hpp b/lib/Core/Plot.hpp index 1c2901c..af3a6b4 100644 --- a/lib/Core/Plot.hpp +++ b/lib/Core/Plot.hpp @@ -98,6 +98,18 @@ public: virtual ~PlotData(void) = default; }; +class PlotPoint: public PlotObject +{ +public: + // constructor + PlotPoint(const double x, const double y); + PlotPoint(const DSample &x, const double y); + PlotPoint(const double x, const DSample &y); + PlotPoint(const DSample &x, const DSample &y); + // destructor + virtual ~PlotPoint(void) = default; +}; + class PlotHLine: public PlotObject { public: diff --git a/physics/2pt-fit.cpp b/physics/2pt-fit.cpp index 739f18f..6ba59be 100644 --- a/physics/2pt-fit.cpp +++ b/physics/2pt-fit.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,7 @@ int main(int argc, char *argv[]) { // parse arguments ///////////////////////////////////////////////////////// OptParser opt; - bool parsed, doPlot, doHeatmap, doCorr, fold, doScan; + bool parsed, doLaplace, doPlot, doHeatmap, doCorr, fold, doScan; string corrFileName, model, outFileName, outFmt, savePlot; Index ti, tf, shift, nPar, thinning; double svdTol; @@ -52,6 +53,8 @@ int main(int argc, char *argv[]) "only do the uncorrelated fit"); opt.addOption("" , "fold" , OptParser::OptType::trigger, true, "fold the correlator"); + opt.addOption("l" , "laplace" , OptParser::OptType::trigger, true, + "apply Laplace filter to the correlator"); opt.addOption("p", "plot" , OptParser::OptType::trigger, true, "show the fit plot"); opt.addOption("h", "heatmap" , OptParser::OptType::trigger, true, @@ -74,6 +77,7 @@ int main(int argc, char *argv[]) ti = opt.optionValue("ti"); tf = opt.optionValue("tf"); thinning = opt.optionValue("t"); + doLaplace = opt.gotOption("l"); shift = opt.optionValue("s"); model = opt.optionValue("m"); nPar = opt.optionValue("nPar"); @@ -110,6 +114,22 @@ int main(int argc, char *argv[]) nt = corr[central].rows(); corr = corr.block(0, 0, nt, 1); corr = CorrelatorUtils::shift(corr, shift); + + if (doLaplace) + { + vector filter = {1., -2., 1.}; + DVec buf; + + FOR_STAT_ARRAY(corr, s) + { + DWT::filterConvolution(buf, corr[s], filter, 1); + corr[s] = buf; + } + } + if (fold) + { + corr = CorrelatorUtils::fold(corr); + } // make model ////////////////////////////////////////////////////////////// CorrelatorFitter fitter(corr); @@ -283,7 +303,7 @@ int main(int argc, char *argv[]) DMat id = DMat::Identity(n, n), var = fitter.data().getFitVarMat(); - p << PlotMatrix(Math::varToCorr(var)); + p << PlotCorrMatrix(Math::varToCorr(var)); p << Caption("correlation matrix"); p.display(); if (svdTol > 0.)