diff --git a/src/classes/Makefile.PMusr b/src/classes/Makefile.PMusr index e502949d..db9848a0 100644 --- a/src/classes/Makefile.PMusr +++ b/src/classes/Makefile.PMusr @@ -27,10 +27,12 @@ ROOTGLIBS = $(shell $(ROOTSYS)/bin/root-config --glibs) # linker, and the flags to use # -ifeq ($(OSTYPE),linux) +OSTYPE = $(shell uname) + +ifeq ($(OSTYPE),Linux) OS = LINUX endif -ifeq ($(OSTYPE),linux-gnu) +ifeq ($(OSTYPE),Linux-gnu) OS = LINUX endif ifeq ($(OSTYPE),darwin) diff --git a/src/classes/PTheory.cpp b/src/classes/PTheory.cpp index 75c61159..0a00ca9b 100644 --- a/src/classes/PTheory.cpp +++ b/src/classes/PTheory.cpp @@ -93,6 +93,7 @@ PTheory::PTheory(PMsrHandler *msrInfo, unsigned int runNo, const bool hasParent) fMul = 0; fStaticKTLFFunc = 0; fUserFcnClassName = TString(""); + fUserFcn = 0; static unsigned int lineNo = 1; // lineNo static unsigned int depth = 0; // needed to handle '+' properly @@ -258,8 +259,12 @@ PTheory::PTheory(PMsrHandler *msrInfo, unsigned int runNo, const bool hasParent) if (!fUserFcnClassName.IsWhitespace()) { cout << endl << ">> user function class name: " << fUserFcnClassName.Data() << endl; if (!TClass::GetDict(fUserFcnClassName.Data())) { - cout << endl << "**ERROR**: PTheory: user function class '" << fUserFcnClassName.Data() << "' not found. See line no " << line->fLineNo; - fValid = false; + char libname[256]; + sprintf(libname, "lib%s.so", fUserFcnClassName.Data()); // add path needed?? + if (gSystem->Load(libname) < 0) { + cout << endl << "**ERROR**: PTheory: user function class '" << fUserFcnClassName.Data() << "' not found. See line no " << line->fLineNo; + fValid = false; + } } else { // invoke user function object fUserFcn = 0; fUserFcn = (PUserFcnBase*)TClass::GetClass(fUserFcnClassName.Data())->New(); diff --git a/src/classes/PUserFcnBase.cpp b/src/classes/PUserFcnBase.cpp new file mode 100644 index 00000000..13786375 --- /dev/null +++ b/src/classes/PUserFcnBase.cpp @@ -0,0 +1,56 @@ +/*************************************************************************** + + PUserFcnBase.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 "PUserFcnBase.h" + +ClassImp(PUserFcnBase) + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

+ * + */ +PUserFcnBase::PUserFcnBase() +{ +} + +//-------------------------------------------------------------------------- +// Destructor +//-------------------------------------------------------------------------- +/** + *

+ * + */ +PUserFcnBase::~PUserFcnBase() +{ +} diff --git a/src/include/PTheory.h b/src/include/PTheory.h index af309349..1bd36828 100644 --- a/src/include/PTheory.h +++ b/src/include/PTheory.h @@ -32,6 +32,7 @@ #ifndef _PTHEORY_H_ #define _PTHEORY_H_ +#include #include #include diff --git a/src/include/PUserFcnBase.h b/src/include/PUserFcnBase.h new file mode 100644 index 00000000..f8980789 --- /dev/null +++ b/src/include/PUserFcnBase.h @@ -0,0 +1,50 @@ +/*************************************************************************** + + PUserFcnBase.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 _PUSERFCNBASE_H_ +#define _PUSERFCNBASE_H_ + +#include + +#include "TObject.h" + +class PUserFcnBase : public TObject +{ + public: + PUserFcnBase(); + virtual ~PUserFcnBase(); + + virtual Double_t operator()(Double_t t, const std::vector ¶m) const = 0; + + ClassDef(PUserFcnBase, 1) +}; + +#endif // _PUSERFCNBASE_H_ diff --git a/src/include/PUserFcnBaseLinkDef.h b/src/include/PUserFcnBaseLinkDef.h new file mode 100644 index 00000000..52c8381c --- /dev/null +++ b/src/include/PUserFcnBaseLinkDef.h @@ -0,0 +1,40 @@ +/*************************************************************************** + + PUserFcnBaseLinkDef.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. * + ***************************************************************************/ + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class PUserFcnBase+; + +#endif diff --git a/src/tests/userFcn/Makefile b/src/tests/userFcn/Makefile index 72f3eccf..af2bf45c 100644 --- a/src/tests/userFcn/Makefile +++ b/src/tests/userFcn/Makefile @@ -19,12 +19,12 @@ ROOTGLIBS = $(shell $(ROOTSYS)/bin/root-config --glibs) # linker, and the flags to use # -OSTYPE = linux +OSTYPE = $(shell uname) -ifeq ($(OSTYPE),linux) +ifeq ($(OSTYPE),Linux) OS = LINUX endif -ifeq ($(OSTYPE),linux-gnu) +ifeq ($(OSTYPE),Linux-gnu) OS = LINUX endif ifeq ($(OSTYPE),darwin) @@ -58,7 +58,8 @@ LIBS = $(ROOTLIBS) -lXMLParser GLIBS = $(ROOTGLIBS) -lXMLParser # UserFcn lib -USERFCNLIB = -lTUserFcnBase -lTUserFcn +USERFCNLIB = -lTUserFcnBase +#-lTUserFcn INSTALLPATH = ./ diff --git a/src/tests/userFcn/userFcnTest.cpp b/src/tests/userFcn/userFcnTest.cpp index 3b6d7579..6a1c9fb2 100644 --- a/src/tests/userFcn/userFcnTest.cpp +++ b/src/tests/userFcn/userFcnTest.cpp @@ -36,7 +36,7 @@ #include using namespace std; -#include +#include #include #include #include @@ -54,9 +54,14 @@ int main(int argc, char *argv[]) { // check if class is found (argv[1] == class name) if (!TClass::GetDict("TUserFcn")) { - cout << endl << "**ERROR**: user function class 'TUserFcn' not found."; - cout << endl << endl; - return 0; + cout << endl << "could find TUserFcn, will try to load the shared lib ..."; + // try to load the shared library + TString libName = TString("libTUserFcn.so"); + if (gSystem->Load(libName.Data())<0) { + cout << endl << "**ERROR**: user function class 'TUserFcn' not found."; + cout << endl << endl; + return 0; + } } // generate class object