diff --git a/src/external/Nonlocal/Makefile b/src/external/Nonlocal/Makefile new file mode 100644 index 00000000..66f3adb1 --- /dev/null +++ b/src/external/Nonlocal/Makefile @@ -0,0 +1,106 @@ +#--------------------------------------------------- +# Makefile +# +# Author: Andreas Suter +# e-mail: andreas.suter@psi.ch +# +# $Id$ +# +#--------------------------------------------------- + +#--------------------------------------------------- +# get compilation and library flags from root-config + +ROOTCFLAGS = $(shell $(ROOTSYS)/bin/root-config --cflags) +ROOTLIBS = $(shell $(ROOTSYS)/bin/root-config --libs) +ROOTGLIBS = $(shell $(ROOTSYS)/bin/root-config --glibs) + +#--------------------------------------------------- +# depending on the architecture, choose the compiler, +# linker, and the flags to use +# + +OSTYPE = $(shell uname) + +ifeq ($(OSTYPE),Linux) +OS = LINUX +endif +ifeq ($(OSTYPE),Linux-gnu) +OS = LINUX +endif +ifeq ($(OSTYPE),darwin) +OS = DARWIN +endif + +# -- Linux +ifeq ($(OS),LINUX) +CXX = g++ +CXXFLAGS = -Wall -Wno-trigraphs -fPIC +INCLUDES = -I../include +LD = g++ +LDFLAGS = -g +SOFLAGS = -O -shared +endif + +# -- Darwin +ifeq ($(OS),DARWIN) +CXX = g++ +CXXFLAGS = -Wall -Wno-trigraphs -fPIC +INCLUDES = -I../include +LD = g++ +LDFLAGS = -g +SOFLAGS = -dynamic +endif + +# the output from the root-config script: +CXXFLAGS += $(ROOTCFLAGS) +LDFLAGS += + +# the ROOT libraries (G = graphic) +LIBS = $(ROOTLIBS) -lXMLParser +GLIBS = $(ROOTGLIBS) -lXMLParser + +# some definitions: headers (used to generate *Dict* stuff), sources, objects,... +OBJS = +OBJS += PNL_StartupHandler.o PNL_StartupHandlerDict.o +OBJS += PNL_PippardFitter.o PNL_PippardFitterDict.o + +SHLIB = libPNL_PippardFitter.so + +# make the shared lib: +# +all: $(SHLIB) + +$(SHLIB): $(OBJS) + @echo "---> Building shared library $(SHLIB) ..." + /bin/rm -f $(SHLIB) + $(LD) $(OBJS) $(SOFLAGS) -o $(SHLIB) $(LIBS) + @echo "done" + +# clean up: remove all object file (and core files) +# semicolon needed to tell make there is no source +# for this target! +# +clean:; @rm -f $(OBJS) *Dict* core* + @echo "---> removing $(OBJS)" + +# +$(OBJS): %.o: %.cpp + $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< + +PNL_StartupHandlerDict.cpp: PNL_StartupHandler.h PNL_StartupHandlerLinkDef.h + @echo "Generating dictionary $@..." + rootcint -f $@ -c -p $^ + +PNL_PippardFitterDict.cpp: PNL_PippardFitter.h PNL_PippardFitterLinkDef.h + @echo "Generating dictionary $@..." + rootcint -f $@ -c -p $^ + +install: all + @echo "Installing shared lib: libPUserFcn.so ( you must be root ;-) )" +ifeq ($(OS),LINUX) + cp -pv $(SHLIB) $(ROOTSYS)/lib +# cp -pv ../include/PNonlocal.h $(ROOTSYS)/include +# cp -pv ../include/PNL_StartupHandler.h $(ROOTSYS)/include +# cp -pv ../include/PNL_PippardFitter.h $(ROOTSYS)/include +endif diff --git a/src/external/Nonlocal/PNL_PippardFitter.cpp b/src/external/Nonlocal/PNL_PippardFitter.cpp new file mode 100644 index 00000000..1d7e55e5 --- /dev/null +++ b/src/external/Nonlocal/PNL_PippardFitter.cpp @@ -0,0 +1,67 @@ +/*************************************************************************** + + PNL_PippardFitter.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * 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. * + ***************************************************************************/ + +#include "PNL_PippardFitter.h" + +ClassImp(PNL_PippardFitter) + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + * + */ +PNL_PippardFitter::PNL_PippardFitter() +{ +} + +//-------------------------------------------------------------------------- +// Destructor +//-------------------------------------------------------------------------- +/** + * + */ +PNL_PippardFitter::~PNL_PippardFitter() +{ +} + +//-------------------------------------------------------------------------- +// operator() +//-------------------------------------------------------------------------- +/** + * + */ +Double_t PNL_PippardFitter::operator()(Double_t t, const std::vector ¶m) const +{ +// assert(param.size() >= 4); + + return 0.0; +} diff --git a/src/external/Nonlocal/PNL_PippardFitter.h b/src/external/Nonlocal/PNL_PippardFitter.h new file mode 100644 index 00000000..60bb247f --- /dev/null +++ b/src/external/Nonlocal/PNL_PippardFitter.h @@ -0,0 +1,48 @@ +/*************************************************************************** + + PNL_PippardFitter.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * 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 _PNL_PIPPARDFITTER_H_ +#define _PNL_PIPPARDFITTER_H_ + +#include "PUserFcnBase.h" + +class PNL_PippardFitter : public PUserFcnBase +{ + public: + PNL_PippardFitter(); + virtual ~PNL_PippardFitter(); + + virtual Double_t operator()(Double_t t, const std::vector ¶m) const; + + ClassDef(PNL_PippardFitter, 1) +}; + +#endif // _PNL_PIPPARDFITTER_H_ diff --git a/src/external/Nonlocal/PNL_StartupHandler.cpp b/src/external/Nonlocal/PNL_StartupHandler.cpp new file mode 100644 index 00000000..8c233a7b --- /dev/null +++ b/src/external/Nonlocal/PNL_StartupHandler.cpp @@ -0,0 +1,270 @@ +/*************************************************************************** + + PNL_StartupHandler.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * 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. * + ***************************************************************************/ + +#include +#include +using namespace std; + +#include "PNL_StartupHandler.h" + +ClassImpQ(PNL_StartupHandler) + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + * + */ +PNL_StartupHandler::PNL_StartupHandler() +{ + fStartupFileFound = false; + fStartupFilePath = ""; + + fFourierPoints = 0; + fTrimSpDataPath = TString(""); + + // get default path (for the moment only linux like) + char startup_path_name[128]; + + // check if the startup file is found in the current directory + strcpy(startup_path_name, "./nonlocal_startup.xml"); + if (StartupFileExists(startup_path_name)) { + fStartupFileFound = true; + fStartupFilePath = TString(startup_path_name); + } else { // startup file is not found in the current directory + strncpy(startup_path_name, "/home/nemu/analysis/musrfit/src/external/Nonlocal/nonlocal_startup.xml", sizeof(startup_path_name)); + if (StartupFileExists(startup_path_name)) { + fStartupFileFound = true; + fStartupFilePath = TString(startup_path_name); + } + } +} + +//-------------------------------------------------------------------------- +// Destructor +//-------------------------------------------------------------------------- +/** + * + */ +PNL_StartupHandler::~PNL_StartupHandler() +{ + fTrimSpDataPathList.clear(); +} + +//-------------------------------------------------------------------------- +// OnStartDocument +//-------------------------------------------------------------------------- +/** + *

+ */ +void PNL_StartupHandler::OnStartDocument() +{ + fKey = eEmpty; +} + +//-------------------------------------------------------------------------- +// OnEndDocument +//-------------------------------------------------------------------------- +/** + *

+ */ +void PNL_StartupHandler::OnEndDocument() +{ + // check if anything was set, and if not set some default stuff + if (fFourierPoints == 0) { + fFourierPoints = 262144; + cout << endl << "PNL_StartupHandler::OnEndDocument: **WARNING** \"fourier_points\" not defined in nonlocal_startup.xml."; + cout << endl << " will set it to " << fFourierPoints << "." << endl; + } +} + +//-------------------------------------------------------------------------- +// OnStartElement +//-------------------------------------------------------------------------- +/** + *

+ * + * \param str + * \param attributes + */ +void PNL_StartupHandler::OnStartElement(const char *str, const TList *attributes) +{ + if (!strcmp(str, "fourier_points")) { + fKey = eFourierPoints; + } else if (!strcmp(str, "data_path")) { + fKey = eDataPath; + } else if (!strcmp(str, "energy")) { + fKey = eEnergy; + } +} + +//-------------------------------------------------------------------------- +// OnEndElement +//-------------------------------------------------------------------------- +/** + *

+ * + * \param str + */ +void PNL_StartupHandler::OnEndElement(const char *str) +{ + fKey = eEmpty; +} + +//-------------------------------------------------------------------------- +// OnCharacters +//-------------------------------------------------------------------------- +/** + *

+ * + * \param str + */ +void PNL_StartupHandler::OnCharacters(const char *str) +{ + TString tstr; + + switch (fKey) { + case eFourierPoints: + tstr = str; + if (tstr.IsDigit()) { + fFourierPoints = tstr.Atoi(); + } else { + cout << endl << "PNL_StartupHandler::OnCharacters: **ERROR** when finding fourier_points:"; + cout << endl << "\"" << str << "\" is not a number, will ignore it and use the default value."; + cout << endl; + } + break; + case eDataPath: + fTrimSpDataPath = str; + break; + case eEnergy: + tstr = fTrimSpDataPath + TString(str); + fTrimSpDataPathList.push_back(tstr); + break; + default: + break; + } +} + +//-------------------------------------------------------------------------- +// OnComment +//-------------------------------------------------------------------------- +/** + *

+ * + * \param str + */ +void PNL_StartupHandler::OnComment(const char *str) +{ + // nothing to be done for now +} + +//-------------------------------------------------------------------------- +// OnWarning +//-------------------------------------------------------------------------- +/** + *

+ * + * \param str + */ +void PNL_StartupHandler::OnWarning(const char *str) +{ + cout << endl << "PNL_StartupHandler **WARNING** " << str; + cout << endl; +} + +//-------------------------------------------------------------------------- +// OnError +//-------------------------------------------------------------------------- +/** + *

+ * + * \param str + */ +void PNL_StartupHandler::OnError(const char *str) +{ + cout << endl << "PNL_StartupHandler **ERROR** " << str; + cout << endl; +} + +//-------------------------------------------------------------------------- +// OnFatalError +//-------------------------------------------------------------------------- +/** + *

+ * + * \param str + */ +void PNL_StartupHandler::OnFatalError(const char *str) +{ + cout << endl << "PNL_StartupHandler **FATAL ERROR** " << str; + cout << endl; +} + +//-------------------------------------------------------------------------- +// OnCdataBlock +//-------------------------------------------------------------------------- +/** + *

+ * + * \param str + */ +void PNL_StartupHandler::OnCdataBlock(const char *str, Int_t len) +{ + // nothing to be done for now +} + +//-------------------------------------------------------------------------- +// StartupFileExists +//-------------------------------------------------------------------------- +/** + *

+ * + */ +bool PNL_StartupHandler::StartupFileExists(char *fln) +{ + bool result = false; + + ifstream ifile(fln); + + if (ifile.fail()) { + result = false; + } else { + result = true; + ifile.close(); + } + + return result; +} + +// ------------------------------------------------------------------------- +// end +// ------------------------------------------------------------------------- diff --git a/src/external/Nonlocal/PNL_StartupHandler.h b/src/external/Nonlocal/PNL_StartupHandler.h new file mode 100644 index 00000000..ac2deaab --- /dev/null +++ b/src/external/Nonlocal/PNL_StartupHandler.h @@ -0,0 +1,79 @@ +/*************************************************************************** + + PNL_StartupHandler.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * 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 _PNL_STARTUPHANDLER_H_ +#define _PNL_STARTUPHANDLER_H_ + +#include +#include +#include + +#include "PNonlocal.h" + +class PNL_StartupHandler : public TObject +{ + public: + PNL_StartupHandler(); + virtual ~PNL_StartupHandler(); + + virtual void OnStartDocument(); // SLOT + virtual void OnEndDocument(); // SLOT + virtual void OnStartElement(const char*, const TList*); // SLOT + virtual void OnEndElement(const char*); // SLOT + virtual void OnCharacters(const char*); // SLOT + virtual void OnComment(const char*); // SLOT + virtual void OnWarning(const char*); // SLOT + virtual void OnError(const char*); // SLOT + virtual void OnFatalError(const char*); // SLOT + virtual void OnCdataBlock(const char*, Int_t); // SLOT + + virtual const Int_t GetFourierPoints() const { return fFourierPoints; } + virtual const PStringVector GetTrimSpDataPathList() const { return fTrimSpDataPathList; } + + virtual bool StartupFileFound() { return fStartupFileFound; } + + private: + enum EKeyWords {eEmpty, eComment, eFourierPoints, eDataPath, eEnergy}; + EKeyWords fKey; + + bool fStartupFileFound; + TString fStartupFilePath; + + Int_t fFourierPoints; + TString fTrimSpDataPath; + PStringVector fTrimSpDataPathList; + + bool StartupFileExists(char *fln); + + ClassDef(PNL_StartupHandler, 1) +}; + +#endif // _PNL_STARTUPHANDLER_H_ diff --git a/src/external/Nonlocal/PNL_StartupHandlerLinkDef.h b/src/external/Nonlocal/PNL_StartupHandlerLinkDef.h new file mode 100644 index 00000000..de5b24c1 --- /dev/null +++ b/src/external/Nonlocal/PNL_StartupHandlerLinkDef.h @@ -0,0 +1,40 @@ +/*************************************************************************** + + PNL_StartupHandlerLinkDef.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * 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. * + ***************************************************************************/ + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class PNL_StartupHandler+; + +#endif diff --git a/src/external/Nonlocal/PNonlocal.h b/src/external/Nonlocal/PNonlocal.h new file mode 100644 index 00000000..139297f1 --- /dev/null +++ b/src/external/Nonlocal/PNonlocal.h @@ -0,0 +1,46 @@ +/*************************************************************************** + + PNonlocal.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * 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 _PNONLOCAL_H_ +#define _PNONLOCAL_H_ + +#include + +#include + +//------------------------------------------------------------- +/** + *

typedef to make to code more readable. + */ +typedef std::vector PStringVector; + + +#endif // _PNONLOCAL_H_ diff --git a/src/external/Nonlocal/nonlocal_startup.xml b/src/external/Nonlocal/nonlocal_startup.xml new file mode 100644 index 00000000..c31f6790 --- /dev/null +++ b/src/external/Nonlocal/nonlocal_startup.xml @@ -0,0 +1,25 @@ + + + + $Id$ + + + 200000 + + + /afs/psi.ch/project/nemu/analysis/2009/Nonlocal/In-37/In37 + + 2.5 + 4.0 + 6.0 + 8.0 + 10.0 + 12.5 + 14.1 + 17.5 + 22.0 + 25.0 + 28.2 + + +