diff --git a/src/classes/Makefile.PUserFcn b/src/classes/Makefile.PUserFcn new file mode 100644 index 00000000..584ab0a3 --- /dev/null +++ b/src/classes/Makefile.PUserFcn @@ -0,0 +1,99 @@ +#--------------------------------------------------- +# Makefile.PUserFcn +# +# 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 = -g -Wall -Wno-trigraphs -fPIC +INCLUDES = -I../include +LD = g++ +LDFLAGS = -g +SOFLAGS = -O -shared +endif + +# -- Darwin +ifeq ($(OS),DARWIN) +CXX = g++ +CXXFLAGS = -g -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 += PUserFcn.o PUserFcnDict.o + +SHLIB = libPUserFcn.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 $< + +PUserFcnDict.cpp: ../include/PUserFcn.h ../include/PUserFcnLinkDef.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/PUserFcn.h $(ROOTSYS)/include +endif diff --git a/src/classes/PUserFcn.cpp b/src/classes/PUserFcn.cpp new file mode 100644 index 00000000..f895d0e1 --- /dev/null +++ b/src/classes/PUserFcn.cpp @@ -0,0 +1,75 @@ +/*************************************************************************** + + PUserFcn.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007 by Andreas Suter * + * andreas.suter@psi.c * + * * + * 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 +using namespace std; + +#include + +#include "PUserFcn.h" + +ClassImp(PUserFcn) + +//------------------------------------------------------ +/** + * + */ +PUserFcn::PUserFcn() +{ +} + +//------------------------------------------------------ +/** + * + */ +PUserFcn::~PUserFcn() +{ +} + +//------------------------------------------------------ +/** + * + */ +Double_t PUserFcn::operator()(Double_t t, const std::vector ¶m) const +{ +/* + cout << endl << ">> Eval: t=" << t << ", param="; + for (unsigned int i=0; i= 4); + + return param[0] + param[1]*t + param[2]*t*t + param[3]*t*t*t; +} diff --git a/src/include/PUserFcn.h b/src/include/PUserFcn.h new file mode 100644 index 00000000..0faedb44 --- /dev/null +++ b/src/include/PUserFcn.h @@ -0,0 +1,50 @@ +/*************************************************************************** + + PUserFcn.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007 by Andreas Suter * + * andreas.suter@psi.c * + * * + * 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 _PUSERFCN_H_ +#define _PUSERFCN_H_ + +#include + +#include "PUserFcnBase.h" + +class PUserFcn : public PUserFcnBase +{ + public: + PUserFcn(); + ~PUserFcn(); + + Double_t operator()(Double_t t, const std::vector ¶m) const; + + ClassDef(PUserFcn, 1) +}; + +#endif // _PUSERFCN_H_