first step towards nonlocal Pippard fitting

This commit is contained in:
nemu 2009-06-29 08:35:00 +00:00
parent 39b854bdee
commit ba9dc0f1de
8 changed files with 681 additions and 0 deletions

106
src/external/Nonlocal/Makefile vendored Normal file
View File

@ -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

View File

@ -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<Double_t> &param) const
{
// assert(param.size() >= 4);
return 0.0;
}

View File

@ -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<Double_t> &param) const;
ClassDef(PNL_PippardFitter, 1)
};
#endif // _PNL_PIPPARDFITTER_H_

View File

@ -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 <iostream>
#include <fstream>
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
//--------------------------------------------------------------------------
/**
* <p>
*/
void PNL_StartupHandler::OnStartDocument()
{
fKey = eEmpty;
}
//--------------------------------------------------------------------------
// OnEndDocument
//--------------------------------------------------------------------------
/**
* <p>
*/
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
//--------------------------------------------------------------------------
/**
* <p>
*
* \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
//--------------------------------------------------------------------------
/**
* <p>
*
* \param str
*/
void PNL_StartupHandler::OnEndElement(const char *str)
{
fKey = eEmpty;
}
//--------------------------------------------------------------------------
// OnCharacters
//--------------------------------------------------------------------------
/**
* <p>
*
* \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
//--------------------------------------------------------------------------
/**
* <p>
*
* \param str
*/
void PNL_StartupHandler::OnComment(const char *str)
{
// nothing to be done for now
}
//--------------------------------------------------------------------------
// OnWarning
//--------------------------------------------------------------------------
/**
* <p>
*
* \param str
*/
void PNL_StartupHandler::OnWarning(const char *str)
{
cout << endl << "PNL_StartupHandler **WARNING** " << str;
cout << endl;
}
//--------------------------------------------------------------------------
// OnError
//--------------------------------------------------------------------------
/**
* <p>
*
* \param str
*/
void PNL_StartupHandler::OnError(const char *str)
{
cout << endl << "PNL_StartupHandler **ERROR** " << str;
cout << endl;
}
//--------------------------------------------------------------------------
// OnFatalError
//--------------------------------------------------------------------------
/**
* <p>
*
* \param str
*/
void PNL_StartupHandler::OnFatalError(const char *str)
{
cout << endl << "PNL_StartupHandler **FATAL ERROR** " << str;
cout << endl;
}
//--------------------------------------------------------------------------
// OnCdataBlock
//--------------------------------------------------------------------------
/**
* <p>
*
* \param str
*/
void PNL_StartupHandler::OnCdataBlock(const char *str, Int_t len)
{
// nothing to be done for now
}
//--------------------------------------------------------------------------
// StartupFileExists
//--------------------------------------------------------------------------
/**
* <p>
*
*/
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
// -------------------------------------------------------------------------

View File

@ -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 <TObject.h>
#include <TQObject.h>
#include <TString.h>
#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_

View File

@ -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

46
src/external/Nonlocal/PNonlocal.h vendored Normal file
View File

@ -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 <vector>
#include <TString.h>
//-------------------------------------------------------------
/**
* <p> typedef to make to code more readable.
*/
typedef std::vector<TString> PStringVector;
#endif // _PNONLOCAL_H_

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<nonlocal xmlns="http://nemu.web.psi.ch/musrfit/nonlocal">
<comment>
$Id$
</comment>
<nonlocal_par>
<fourier_points>200000</fourier_points>
</nonlocal_par>
<trim_sp_part>
<data_path>/afs/psi.ch/project/nemu/analysis/2009/Nonlocal/In-37/In37</data_path>
<energy_list>
<energy>2.5</energy>
<energy>4.0</energy>
<energy>6.0</energy>
<energy>8.0</energy>
<energy>10.0</energy>
<energy>12.5</energy>
<energy>14.1</energy>
<energy>17.5</energy>
<energy>22.0</energy>
<energy>25.0</energy>
<energy>28.2</energy>
</energy_list>
</trim_sp_part>
</nonlocal>