some more work on userFcn

This commit is contained in:
nemu 2008-06-06 08:42:35 +00:00
parent 6159700e85
commit cc8d9981c3
8 changed files with 172 additions and 12 deletions

View File

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

View File

@ -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();

View File

@ -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
//--------------------------------------------------------------------------
/**
* <p>
*
*/
PUserFcnBase::PUserFcnBase()
{
}
//--------------------------------------------------------------------------
// Destructor
//--------------------------------------------------------------------------
/**
* <p>
*
*/
PUserFcnBase::~PUserFcnBase()
{
}

View File

@ -32,6 +32,7 @@
#ifndef _PTHEORY_H_
#define _PTHEORY_H_
#include <TSystem.h>
#include <TString.h>
#include <TF1.h>

View File

@ -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 <vector>
#include "TObject.h"
class PUserFcnBase : public TObject
{
public:
PUserFcnBase();
virtual ~PUserFcnBase();
virtual Double_t operator()(Double_t t, const std::vector<Double_t> &param) const = 0;
ClassDef(PUserFcnBase, 1)
};
#endif // _PUSERFCNBASE_H_

View File

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

View File

@ -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 = ./

View File

@ -36,7 +36,7 @@
#include <cassert>
using namespace std;
#include <TApplication.h>
#include <TSystem.h>
#include <TClass.h>
#include <TString.h>
#include <TTime.h>
@ -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