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

Merge branch 'release/3.4'

This commit is contained in:
Antonin Portelli 2019-02-07 21:58:38 +00:00
commit 9f101686fa
11 changed files with 186 additions and 75 deletions

View File

@ -1,9 +1,5 @@
language: cpp
notifications:
email: false
slack: ukqcd:mQLXCtz8D2cg89xT8j1a4wku
cache:
directories:
- ci-scripts/local
@ -12,56 +8,34 @@ cache:
matrix:
include:
- os: osx
osx_image: xcode7.2
osx_image: xcode10.1
compiler: clang
- os: osx
osx_image: xcode7.2
osx_image: xcode10.1
compiler: gcc
env: VERSION=-5
env: VERSION=-7
- compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
- g++-7
- libgsl0-dev
- flex
- bison
env: VERSION=-4.9
- compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
- libgsl0-dev
- flex
- bison
env: VERSION=-5
env: VERSION=-7
- compiler: clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- g++-7
- libgsl0-dev
- flex
- bison
env: CLANG_LINK=http://llvm.org/releases/3.6.0/clang+llvm-3.6.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
- compiler: clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- libgsl0-dev
- flex
- bison
env: CLANG_LINK=http://llvm.org/releases/3.7.0/clang+llvm-3.7.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
env: CLANG_LINK=http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-14.04.tar.xz
before_install:
- export LATDIR=`pwd`
@ -72,7 +46,7 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gsl; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install bison flex; export PATH="/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH"; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CC" == "gcc" ]]; then brew install gcc5; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CC" == "gcc" ]]; then brew install gcc@${VERSION#-}; fi
install:
- export CC=$CC$VERSION
@ -85,6 +59,7 @@ install:
- ./install-deps.sh `pwd`/local
- cd ..
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export LD_LIBRARY_PATH=${LATDIR}/ci-scripts/local/lib:$LD_LIBRARY_PATH; fi
- if [[ "$CC" == "gcc-7" ]]; then export CXXFLAGS='-Wno-int-in-bool-context'; fi
script:
- cd ci-scripts

View File

@ -1,3 +1,5 @@
SUBDIRS = lib utils physics examples
bin_SCRIPTS=latan-config
ACLOCAL_AMFLAGS = -I .buildutils/m4

View File

@ -55,6 +55,17 @@ in the `ci-scripts` directory where `<prefix>` is where you want LatAnalyze (and
For a more customised installation, one first needs to generate the build system by running `./bootstrap.sh` in the root directory. Then the library can be built and installed through the usual GNU mantra `./configure <options> && make && make install`. Use `./configure --help` to obtain a list of possible options for `./configure`. Because Eigen expressions rely a lot on inlining and compiler optimisations it is strongly recommended to set the `CXXFLAGS` variable to `-O3 -march=native -mtune=native`.
## History
#### v3.4
Additions:
* `latan-config` utility to easily compile LatAnalyze-based programs
* Linear and constant models to the 2-point fitter
Changes:
* HDF5 is now a compulsory dependency
Fixes:
* Variance matrix computation fix.
#### v3.3
Additions:
* Sample plot CL utility.
@ -78,7 +89,7 @@ Fixes:
* Variance matrix computation fix.
#### v3.2.1
Fix:
Fixes:
* Wrong argument number check in `latan-resample`
#### v3.2 (needs LatCore 1.1)

View File

@ -14,6 +14,6 @@ cd ..
mkdir -p build
cd build
if [[ "$OS" == "osx" ]]; then EXTRA_FLAGS='--with-gsl=/usr/local'; fi
../configure --prefix=$PREFIX --with-minuit=$PREFIX --with-nlopt=$PREFIX --with-latcore=$PREFIX --with-hdf5=$PREFIX $EXTRA_FLAGS CXXFLAGS='-O3 -march=native -mtune=native'
../configure --prefix=$PREFIX --with-minuit=$PREFIX --with-nlopt=$PREFIX --with-latcore=$PREFIX --with-hdf5=$PREFIX $EXTRA_FLAGS CXXFLAGS="${CXXFLAGS} -O3 -march=native -mtune=native"
make -j4
make install

View File

@ -2,7 +2,7 @@
# Initialization
AC_PREREQ([2.63])
AC_INIT([LatAnalyze],[3.3],[antonin.portelli@me.com],[LatAnalyze])
AC_INIT([LatAnalyze],[3.4],[antonin.portelli@me.com],[LatAnalyze])
AC_CONFIG_AUX_DIR([.buildutils])
AC_CONFIG_SRCDIR([lib/Global.cpp])
AC_CONFIG_SRCDIR([utils/sample_read.cpp])
@ -53,9 +53,6 @@ AC_ARG_WITH([latcore],
[use this option for a non-standard install prefix of the LatCore library])],
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_latcore/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_latcore/lib"])
CFLAGS="$AM_CFLAGS $CFLAGS"
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
# Get compilers informations
AX_COMPILER_VENDOR
@ -78,6 +75,10 @@ AC_DEFINE_UNQUOTED([GXX_VERSION],["$GXX_VERSION"],
[version of g++ that will compile the code])
# Checks for libraries.
CXXFLAGS_CPY=$CXXFLAGS
LDFLAGS_CPY=$LDFLAGS
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
AC_CHECK_LIB([m],[cos],[],[AC_MSG_ERROR([libm library not found])])
AC_CHECK_LIB([gslcblas],[cblas_dgemm],[],
[AC_MSG_ERROR([GSL CBLAS library not found])])
@ -90,12 +91,8 @@ AC_CHECK_LIB([nlopt_cxx],[nlopt_create],
[LIBS="$LIBS -lnlopt_cxx"],[])
AM_CONDITIONAL([HAVE_NLOPT], [test x$have_nlopt = xtrue])
AC_CHECK_LIB([hdf5_cpp],[H5Fopen],
[AC_DEFINE([HAVE_HDF5],
[1],
[Define to 1 if you have the `HDF5' library (-lhdf5_cpp).])]
[have_hdf5=true]
[LIBS="$LIBS -lhdf5_cpp -lhdf5"],[],[-lhdf5])
AM_CONDITIONAL([HAVE_HDF5], [test x$have_hdf5 = xtrue])
[LIBS="$LIBS -lhdf5_cpp -lhdf5"],
[AC_MSG_ERROR([HDF5 library not found])], [-lhdf5])
SAVED_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -lMinuit2"
AC_MSG_CHECKING([for ROOT::Minuit2::BasicMinimumError in -lMinuit2]);
@ -123,24 +120,44 @@ AC_LINK_IFELSE(
[AC_MSG_RESULT([no])]
[AC_MSG_ERROR([LatCore library not found])])
LDFLAGS=$SAVED_LDFLAGS
CXXFLAGS=$CXXFLAGS_CPY
LDFLAGS=$LDFLAGS_CPY
# Checks for header files.
AC_HEADER_STDC
cwd=`pwd -P`; cd ${srcdir}; abs_srcdir=`pwd -P`; cd ${cwd}
LATAN_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
LATAN_LDFLAGS="$AM_LDFLAGS $LDFLAGS"
LATAN_LIBS=$LIBS
LATAN_SHORT_SHA=`git rev-parse --short HEAD`
LATAN_SHA=`git rev-parse HEAD`
LATAN_BRANCH=`git rev-parse --abbrev-ref HEAD`
AM_CXXFLAGS="-I${abs_srcdir}/lib $AM_CXXFLAGS"
AM_CFLAGS="-I${abs_srcdir}/lib $AM_CFLAGS"
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
AC_SUBST([LIBS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])
AC_SUBST([LATAN_CXXFLAGS])
AC_SUBST([LATAN_LDFLAGS])
AC_SUBST([LATAN_LIBS])
AC_SUBST([LATAN_SHA])
AC_SUBST([LATAN_BRANCH])
AC_CONFIG_FILES([Makefile lib/Makefile utils/Makefile physics/Makefile
examples/Makefile])
AC_CONFIG_FILES([latan-config], [chmod +x latan-config])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([lib/Makefile])
AC_CONFIG_FILES([utils/Makefile])
AC_CONFIG_FILES([physics/Makefile])
AC_CONFIG_FILES([examples/Makefile])
AC_OUTPUT
echo "*********************************************"
echo "* ${PACKAGE_NAME} v${VERSION}" build options
echo "*********************************************"
echo "* C++ compiler : $CXX"
echo "* HDF5 support : `test x$HAVE_HDF5_TRUE = 'x' && echo yes \
|| echo no`"
echo "* Minuit minimizers: `test x$HAVE_MINUIT_TRUE = 'x' && echo yes \
|| echo no`"
echo "* NLopt minimizers : `test x$HAVE_NLOPT_TRUE = 'x' && echo yes \

79
latan-config.in Normal file
View File

@ -0,0 +1,79 @@
#! /bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
includedir=@includedir@
usage()
{
cat <<EOF
Usage: latan-config [OPTION]
Known values for OPTION are:
--prefix show LatAnalyze installation prefix
--cxxflags print pre-processor and compiler flags
--ldflags print library linking flags
--libs print library linking information
--help display this help and exit
--version output version information
--git print git revision
EOF
exit $1
}
if test $# -eq 0; then
usage 1
fi
cflags=false
libs=false
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$1" in
--prefix)
echo $prefix
;;
--version)
echo @VERSION@
exit 0
;;
--git)
echo "@LATAN_BRANCH@ @LATAN_SHA@"
exit 0
;;
--help)
usage 0
;;
--cxxflags)
echo @LATAN_CXXFLAGS@
;;
--ldflags)
echo @LATAN_LDFLAGS@
;;
--libs)
echo @LIBS@
;;
*)
usage
exit 1
;;
esac
shift
done
exit 0

View File

@ -200,6 +200,7 @@ double FitInterface::getSvdTolerance(void) const
void FitInterface::setSvdTolerance(const double &tol)
{
svdTol_ = tol;
scheduleLayoutInit();
}
VarName & FitInterface::xName(void)

View File

@ -20,9 +20,7 @@
#include <LatAnalyze/Io.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/AsciiFile.hpp>
#ifdef HAVE_HDF5
#include <LatAnalyze/Hdf5File.hpp>
#endif
using namespace std;
using namespace Latan;
@ -42,12 +40,10 @@ unique_ptr<File> Io::open(const std::string &fileName, const unsigned int mode)
{
return unique_ptr<File>(new AsciiFile(fileName, mode));
}
#ifdef HAVE_HDF5
else if (ext == "h5")
{
return unique_ptr<File>(new Hdf5File(fileName, mode));
}
#endif
else
{
LATAN_ERROR(Io, "unknown file extension '" + ext + "'");

View File

@ -35,6 +35,7 @@ libLatAnalyze_la_SOURCES = \
GslHybridRootFinder.cpp\
GslMinimizer.cpp \
GslQagsIntegrator.cpp \
Hdf5File.cpp \
Histogram.cpp \
includes.hpp \
Io.cpp \
@ -69,6 +70,7 @@ libLatAnalyze_la_HEADERS = \
GslHybridRootFinder.hpp\
GslMinimizer.hpp \
GslQagsIntegrator.hpp \
Hdf5File.hpp \
Histogram.hpp \
Integrator.hpp \
Io.hpp \
@ -87,10 +89,6 @@ libLatAnalyze_la_HEADERS = \
StatArray.hpp \
XYSampleData.hpp \
XYStatData.hpp
if HAVE_HDF5
libLatAnalyze_la_SOURCES += Hdf5File.cpp
libLatAnalyze_la_HEADERS += Hdf5File.hpp
endif
if HAVE_MINUIT
libLatAnalyze_la_SOURCES += MinuitMinimizer.cpp
libLatAnalyze_la_HEADERS += MinuitMinimizer.hpp

View File

@ -30,7 +30,7 @@ int main(int argc, char *argv[])
opt.addOption("s", "shift" , OptParser::OptType::value , true,
"time variable shift", "0");
opt.addOption("m", "model" , OptParser::OptType::value , true,
"fit model (exp|exp2|exp3|cosh|cosh2|cosh3|<interpreter code>)", "cosh");
"fit model (exp|exp2|exp3|cosh|cosh2|cosh3|explin|<interpreter code>)", "cosh");
opt.addOption("" , "nPar" , OptParser::OptType::value , true,
"number of model parameters for custom models "
"(-1 if irrelevant)", "-1");
@ -117,7 +117,7 @@ int main(int argc, char *argv[])
// make model //////////////////////////////////////////////////////////////
DoubleModel mod;
bool coshModel = false;
bool coshModel = false, linearModel = false;
if ((model == "exp") or (model == "exp1"))
{
@ -174,6 +174,15 @@ int main(int argc, char *argv[])
+ p[5]*(exp(-p[2]*x[0])+exp(-p[4]*(nt-x[0])));
}, 1, nPar);
}
else if (model == "explin")
{
linearModel = true;
nPar = 2;
mod.setFunction([](const double *x, const double *p)
{
return p[1] - p[0]*x[0];
}, 1, nPar);
}
else
{
if (nPar > 0)
@ -210,8 +219,16 @@ int main(int argc, char *argv[])
mod.parName().setName(p, "E_" + strFrom(p/2));
mod.parName().setName(p + 1, "Z_" + strFrom(p/2));
}
init(0) = log(data.y(nt/4, 0)[central]/data.y(nt/4 + 1, 0)[central]);
init(1) = data.y(nt/4, 0)[central]/(exp(-init(0)*nt/4));
if (linearModel)
{
init(0) = data.y(nt/4, 0)[central] - data.y(nt/4 + 1, 0)[central];
init(1) = data.y(nt/4, 0)[central] + nt/4*init(0);
}
else
{
init(0) = log(data.y(nt/4, 0)[central]/data.y(nt/4 + 1, 0)[central]);
init(1) = data.y(nt/4, 0)[central]/(exp(-init(0)*nt/4));
}
for (Index p = 2; p < nPar; p += 2)
{
init(p) = 2*init(p - 2);
@ -219,11 +236,19 @@ int main(int argc, char *argv[])
}
for (Index p = 0; p < nPar; p += 2)
{
globMin.setLowLimit(p, 0.);
globMin.setHighLimit(p, 10.*init(p));
globMin.setLowLimit(p + 1, -10.*init(p + 1));
globMin.setHighLimit(p + 1, 10.*init(p + 1));
locMin.setLowLimit(p, 0.);
if (linearModel)
{
globMin.setLowLimit(p, -10.*fabs(init(p)));
globMin.setHighLimit(p, 10.*fabs(init(p)));
}
else
{
globMin.setLowLimit(p, 0.);
locMin.setLowLimit(p, 0.);
globMin.setHighLimit(p, 10.*init(p));
}
globMin.setLowLimit(p + 1, -10.*fabs(init(p + 1)));
globMin.setHighLimit(p + 1, 10.*fabs(init(p + 1)));
}
globMin.setPrecision(0.001);
globMin.setMaxIteration(100000);
@ -264,7 +289,10 @@ int main(int argc, char *argv[])
double e0, e0Err;
p << PlotRange(Axis::x, 0, nt - 1);
p << LogScale(Axis::y);
if (!linearModel)
{
p << LogScale(Axis::y);
}
p << Color("rgb 'blue'") << PlotPredBand(fit.getModel(_), 0, nt - 1);
p << Color("rgb 'blue'") << PlotFunction(fit.getModel(), 0, nt - 1);
p << Color("rgb 'red'") << PlotData(data.getData());
@ -285,6 +313,16 @@ int main(int argc, char *argv[])
}
}
}
else if (linearModel)
{
FOR_STAT_ARRAY(effMass, s)
{
for (Index t = 0; t < nt - 1; ++t)
{
effMass[s](t) = corr[s](t) - corr[s](t+1);
}
}
}
else
{
FOR_STAT_ARRAY(effMass, s)
@ -302,7 +340,6 @@ int main(int argc, char *argv[])
p << Color("rgb 'blue'") << PlotHLine(e0);
p << Color("rgb 'red'") << PlotData(effMassT, effMass);
p.display();
p.save("test");
}
if (doHeatmap)
{

View File

@ -25,12 +25,7 @@
#ifndef DEF_NSAMPLE
#define DEF_NSAMPLE "100"
#endif
#ifdef HAVE_HDF5
#define DEF_FMT "h5"
#else
#define DEF_FMT "sample"
#endif
using namespace std;
using namespace Latan;