[ROOT] root as extension language

From: Rüdiger Berlich (ruediger@ep1.ruhr-uni-bochum.de)
Date: Mon Mar 24 2003 - 09:52:26 MET


Hi there,

I've created an implementation of evolutionary strategies,
that lets you perform optimizations either in serial mode, via
POSIX threads on a multi-processor machine or via MPI on a
cluster. The library is intended primarily for the optimization of
cuts in particle physics analysis using a quality measure based
e.g. on the significance of a peak. Calculating the quality of a
given set of cuts thus requires processing some event data, like
in any standard analysis.

The obvious idea is now to use root as an extension language,
i.e, to start the execution of a root script performing such an
analysis in each individual of the Evolutionary Algorithms' population.
I'm therefore looking for a possibility to embed root (i.e. cint +
all standard root libraries) into my code.

Basically all I need at the moment is a way to call root from within
my (C++ / gcc 3.2) program when needed and let it execute a script,
that in addition must have access to some data supplied by the program
and be able to return the (floating point) result of running the script -
 i.e. a single double.

In other words, I'm looking for a way of doing this :


double EVA::customValue(void) // evaluation function used in Evol. Algorithm;
                                             //  this is compiled code
{
   double result=
    
 commandToRunRoot("/where/script/resides/script.cc",stlVectorWithDoubles);
 return result;
}


stlVectorWithDoubles would be a standard STL vector<double> , holding e.g.
the cut values the root script is supposed to use in its run through the
 data. It is defined in the "EVA" class.

If supplying an STL vector to the root script is a problem then,
alternatively, being able to give it a "double *myCuts" plus the variable
"nCuts" specifying the length of the array would be sufficient as well.

I know that it is possible to run root in batch mode (root -b ???) and that I
could use a call similar to system("root -b myscript.cc") . I'm already doing
this succesfully with PAW, i.e. system("paw -b myscript.kumac"), since there
is no better way, as far as I know.

I believe that this can be done in a much more elegant way with root, and
would like to ask you for a pointer to some good examples or any other
available information.

I am not bound to a specific version of root, i.e., any version that
satisfies my requirements is fine. My code is currently designed to run
solely on Linux machines. Making it more portable is the next step once I
have this feature in place. I.e., if there is a portable way of doing what I
have described above that would of course be great, but getting this feature
to work on a Linux box is my first priority.

In any case thanks for your help !

Kind Regards / Mit freundlichen Grüßen,
Rüdiger Berlich

--
Institut fuer Experimentalphysik I
Ruhr-Universitaet Bochum
Tel. +49 (0)7247 825678
ruediger@berlich.de



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET