diff --git a/configure.ac b/configure.ac index a9eda71b..1c82456d 100644 --- a/configure.ac +++ b/configure.ac @@ -811,6 +811,7 @@ AC_CONFIG_FILES([Makefile \ src/external/libFitPofB/Makefile \ src/external/libFitPofB/classes/Makefile \ src/external/libLFRelaxation/Makefile \ + src/external/libZFRelaxation/Makefile \ src/external/libGapIntegrals/Makefile \ src/external/libCalcMeanFieldsLEM/Makefile \ src/external/Nonlocal/Makefile \ diff --git a/src/external/Makefile.am b/src/external/Makefile.am index ad090ce6..2f5f75e7 100644 --- a/src/external/Makefile.am +++ b/src/external/Makefile.am @@ -13,6 +13,7 @@ if BUILD_BMWLIBS BMWDIRS = BMWtools \ libFitPofB \ libLFRelaxation \ + libZFRelaxation \ libGapIntegrals \ libCalcMeanFieldsLEM endif diff --git a/src/external/libZFRelaxation/Makefile.am b/src/external/libZFRelaxation/Makefile.am new file mode 100644 index 00000000..139dbb67 --- /dev/null +++ b/src/external/libZFRelaxation/Makefile.am @@ -0,0 +1,57 @@ +## Process this file with automake to create Makefile.in +## $Id$ + +h_sources = \ + ZFRelaxation.h + +h_linkdef = \ + ZFRelaxationLinkDef.h + +dict_h_sources = \ + ZFRelaxationDict.h + +cpp_sources = \ + ZFRelaxation.cpp + +dict_cpp_sources = \ + ZFRelaxationDict.cpp + +include_HEADERS = $(h_sources) +noinst_HEADERS = $(h_linkdef) $(dict_h_sources) + +INCLUDES = -I$(top_srcdir)/src/include $(PMUSR_CFLAGS) $(ROOT_CFLAGS) +AM_CXXFLAGS = $(LOCAL_LIB_CXXFLAGS) + +BUILT_SOURCES = $(dict_cpp_sources) $(dict_h_sources) +AM_LDFLAGS = $(LOCAL_LIB_LDFLAGS) -L@ROOTLIBDIR@ +CLEANFILES = *Dict.cpp *Dict.h *~ core + +%Dict.cpp %Dict.h: %.h %LinkDef.h + @ROOTCINT@ -v -f $*Dict.cpp -c -p $(INCLUDES) $^ + +lib_LTLIBRARIES = libZFRelaxation.la + +libZFRelaxation_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources) +libZFRelaxation_la_LIBADD = $(USERFCN_LIBS) $(ROOT_LIBS) +libZFRelaxation_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -release $(PLUGIN_RELEASE) $(AM_LDFLAGS) + +## For the moment do not build pkgconfig files for musrfit plug-ins... +## pkgconfigdir = $(libdir)/pkgconfig +## pkgconfig_DATA = ZFRelaxation.pc + +## However, create some symbolic links to the shared library +## in order to unify the function call on different operating systems + +if IS_DARWIN +install-exec-hook: + $(LN_S) $(libdir)/libZFRelaxation.dylib $(libdir)/libZFRelaxation.so +uninstall-hook: + rm -f $(libdir)/libZFRelaxation.so +endif + +if IS_CYGWIN +install-exec-hook: + $(LN_S) $(bindir)/cygZFRelaxation-$(PLUGIN_MAJOR_VERSION)-$(PLUGIN_MINOR_VERSION)-$(PLUGIN_MAJOR_VERSION).dll $(libdir)/libZFRelaxation.so +uninstall-hook: + rm -f $(libdir)/libZFRelaxation.so +endif diff --git a/src/external/libZFRelaxation/ZFRelaxation.cpp b/src/external/libZFRelaxation/ZFRelaxation.cpp new file mode 100644 index 00000000..4cd656a1 --- /dev/null +++ b/src/external/libZFRelaxation/ZFRelaxation.cpp @@ -0,0 +1,73 @@ +/*************************************************************************** + + ZFRelaxation.cpp + + Author: Bastian M. Wojek + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Bastian M. Wojek * + * * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#define TWO_PI 6.28318530717958623 +#define DEG_TO_RAD 0.0174532925199432955 + +#include "ZFRelaxation.h" + +#include +#include +#include + +using namespace std; + +ClassImp(ZFMagGss) +ClassImp(ZFMagExp) + +//-------------------------------------------------------------------------- +// ZFMagGss::operator() +//-------------------------------------------------------------------------- +/** + *

Method returning the function value at a given time for a given set of parameters. + * + * \param t time \htmlonly (μs) \endhtmlonly \latexonly ($\mu\mathrm{s}$) \endlatexonly + * \param par parameters [\htmlonly α (1), ν (MHz), σT; (μs-1), σL; (μs-1)\endhtmlonly \latexonly $\alpha~(1)$, $\nu~(\mathrm{MHz})$, $\sigma_{\mathrm{T}}~(\mu\mathrm{s}^{-1})$, $\sigma_{\mathrm{L}}~(\mu\mathrm{s}^{-1})$ \endlatexonly] + */ +double ZFMagGss::operator()(double t, const vector &par) const { + assert(par.size()==4); + double w(TWO_PI * par[1]), sst(par[2]*par[2]*t); + return par[0] * (cos(w*t) - sst/w*sin(w*t)) * exp(-0.5*sst*t) + (1.0-par[0]) * exp(-0.5*par[3]*par[3]*t*t); +} + +//-------------------------------------------------------------------------- +// ZFMagExp::operator() +//-------------------------------------------------------------------------- +/** + *

Method returning the function value at a given time for a given set of parameters. + * + * \param t time \htmlonly (μs) \endhtmlonly \latexonly ($\mu\mathrm{s}$) \endlatexonly + * \param par parameters [\htmlonly α (1), ν (MHz), aT; (μs-1), aL; (μs-1)\endhtmlonly \latexonly $\alpha~(1)$, $\nu~(\mathrm{MHz})$, $a_{\mathrm{T}}~(\mu\mathrm{s}^{-1})$, $a_{\mathrm{L}}~(\mu\mathrm{s}^{-1})$ \endlatexonly] + */ +double ZFMagExp::operator()(double t, const vector &par) const { + assert(par.size()==4); + double w(TWO_PI * par[1]); + return par[0] * (cos(w*t) - par[2]/w*sin(w*t)) * exp(-par[2]*t) + (1.0-par[0]) * exp(-par[3]*t); +} diff --git a/src/external/libZFRelaxation/ZFRelaxation.h b/src/external/libZFRelaxation/ZFRelaxation.h new file mode 100644 index 00000000..8d8c8865 --- /dev/null +++ b/src/external/libZFRelaxation/ZFRelaxation.h @@ -0,0 +1,89 @@ +/*************************************************************************** + + ZFRelaxation.h + + Author: Bastian M. Wojek + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Bastian M. Wojek * + * * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _ZFRelaxation_H_ +#define _ZFRelaxation_H_ + +#include "PUserFcnBase.h" + +#include +using namespace std; + +//----------------------------------------------------------------------------------------------------------------- +/** + *

User function for the muon spin depolarization resulting from static Gaussian broadened randomly oriented internal fields + * See also: E.I. Kornilov and V.Yu. Pomjakushin + * \htmlonly Phys. Lett. A 153, 364–367 (1991), doi:10.1016/0375-9601(91)90959-C + * \endhtmlonly + * \latexonly Phys. Lett. A \textbf{153}, 364--367 (1991), \texttt{http://dx.doi.org/10.1016/0375-9601(91)90959-C} + * \endlatexonly + */ +class ZFMagGss : public PUserFcnBase { + +public: + // default constructor + ZFMagGss(){} ///< default constructor + ~ZFMagGss(){} ///< default destructor + + Bool_t NeedGlobalPart() const { return false; } + void SetGlobalPart(vector &globalPart, UInt_t idx) { } + Bool_t GlobalPartIsValid() const { return true; } + + double operator()(double, const vector&) const; + + ClassDef(ZFMagGss,1) +}; + +//----------------------------------------------------------------------------------------------------------------- +/** + *

User function for the muon spin depolarization resulting from static Lorentzian broadened randomly oriented internal fields + * See also: M. I. Larkin, Y. Fudamoto, I. M. Gat, A. Kinkhabwala, K. M. Kojima, G. M. Luke, J. Merrin, B. Nachumi, Y. J. Uemura, M. Azuma, T. Saito, and M. Takano + * \htmlonly Physica B 289–290, 153–156 (2000), doi:10.1016/S0921-4526(00)00337-9 + * \endhtmlonly + * \latexonly Physica B \textbf{289--290}, 153--156 (2000), \texttt{http://dx.doi.org/10.1016/S0921-4526(00)00337-9} + * \endlatexonly + */ +class ZFMagExp : public PUserFcnBase { + +public: + // default constructor + ZFMagExp(){} ///< default constructor + ~ZFMagExp(){} ///< default destructor + + Bool_t NeedGlobalPart() const { return false; } + void SetGlobalPart(vector &globalPart, UInt_t idx) { } + Bool_t GlobalPartIsValid() const { return true; } + + double operator()(double, const vector&) const; + + ClassDef(ZFMagExp,1) +}; + +#endif //_ZFRelaxation_H_ diff --git a/src/external/libZFRelaxation/ZFRelaxationLinkDef.h b/src/external/libZFRelaxation/ZFRelaxationLinkDef.h new file mode 100644 index 00000000..d817b1dc --- /dev/null +++ b/src/external/libZFRelaxation/ZFRelaxationLinkDef.h @@ -0,0 +1,43 @@ +/*************************************************************************** + + ZFRelaxationLinkDef.h + + Author: Bastian M. Wojek + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Bastian M. Wojek * + * * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +// root dictionary stuff -------------------------------------------------- +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class ZFMagGss+; +#pragma link C++ class ZFMagExp+; + +#endif //__CINT__ +// root dictionary stuff -------------------------------------------------- + diff --git a/src/tests/CheckMusrfitInstall/BMWlibs/data/deltat_pta_gps_4255.bin b/src/tests/CheckMusrfitInstall/BMWlibs/data/deltat_pta_gps_4255.bin new file mode 100644 index 00000000..70fb2977 Binary files /dev/null and b/src/tests/CheckMusrfitInstall/BMWlibs/data/deltat_pta_gps_4255.bin differ diff --git a/src/tests/CheckMusrfitInstall/BMWlibs/test-libZFRelaxation-PSI-BIN.msr b/src/tests/CheckMusrfitInstall/BMWlibs/test-libZFRelaxation-PSI-BIN.msr new file mode 100644 index 00000000..3e5cdb7d --- /dev/null +++ b/src/tests/CheckMusrfitInstall/BMWlibs/test-libZFRelaxation-PSI-BIN.msr @@ -0,0 +1,57 @@ +Test libZFRelaxation random fields Lorentzian broadened, asymmetry plot, PSI-BIN data file +############################################################### +FITPARAMETER +# No Name Value Step Pos_Error Boundaries + 1 precFrac 0.666667 0 none 0 1 + 2 field 171.20 0.55 none 0 none + 3 lambdaT 1.303 0.061 none 0 none + 4 lambdaL 0.099 0.012 none 0 none + + 5 asymmetry 0.1429 0.0039 none 0 0.3 + 6 alpha 0.8209 0.0027 none + +############################################################### +THEORY +asymmetry 5 +userFcn libZFRelaxation ZFMagExp 1 fun1 3 4 + +############################################################### +FUNCTIONS +fun1 = par2 * gamma_mu + +############################################################### +RUN data/deltat_pta_gps_4255 PIM3 PSI PSI-BIN (name beamline institute data-file-format) +fittype 2 (asymmetry fit) +alpha 6 +map 0 0 0 0 0 0 0 0 0 0 +forward 2 +backward 1 +t0 125 128 +data 128 8097 131 8112 +background 45 113 40 117 +fit 0 8 +packing 30 + +############################################################### +COMMANDS +MINIMIZE +HESSE +SAVE + +############################################################### +FOURIER +units Gauss # units either 'Gauss', 'MHz', or 'Mc/s' +fourier_power 8 +apodization NONE # NONE, WEAK, MEDIUM, STRONG +plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE +phase 0 +range 0 500 + +############################################################### +PLOT 2 (asymmetry plot) +runs 1 +range 0 4 -0.25 0.25 + +############################################################### +STATISTIC --- 2011-05-09 14:56:44 + chisq = 470.01394974044985, NDF = 208, chisq/NDF = 2.2596824506752395