ROOT and EPICS
The PANDA collaboration software is based on
ROOT. From a DAQ or Online Analysis point of view it may prove necessary to pass results to EPICS or to retrieve parameters, constants or
value from EPICS. This wiki illustrates how this can be done, with one simple example.
EZCA Package
A simple way to communicate with EPICS from C is provided via the EZCA package. Documentation can be found at:
Both the source code and the primer are attached to this wiki. The EZCA package should be downloaded, unpacked and compiled like this:
-bash-3.2$ mkdir $EPICS_BASE/extensions
-bash-3.2$ cd $EPICS_BASE/extensions
-bash-3.2$ tar -zxvf ~/ezca_20070625.tar.gz
-bash-3.2$ mv ezca_20070625 ezca
-bash-3.2$ cd ezca
-bash-3.2$ make
then set your
LD_LIBRARY_PATH
to include the ROOT and EZCA libraries:
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ROOTSYS/lib:$EPICS_BASE/lib/$EPICS_HOST_ARCH
Make sure that
$ROOTSYS
is defined in your environment;
$EPICS_BASE
and
$EPICS_HOST_ARCH
were defined earlier, as explained in
CSSGUIs.
Test macro
This
test macro produces a root file, containing a 'particle mass' spectrum, used as input for the next example.
Communicating with EPICS
Here is simple ROOT macro -
mass_ana.C - that uses EZCA functions and does the following:
- opens a root file and loads a histogram
- analyses this histogram and finds the peak location
- retrieves some info from EPICS
- puts the a peak location result value into EPICS
To use this macro you must compile it using this
Makefile.
Start your
softIoc
with:
-bash-3.2$ softIoc -s -m user=$USER -d Mass.db
You can use the attached root file (
run123456.root) to test it:
-bash-3.2$ ./mass_ana eun123456.root
This should output:
Comment out the
theApp
lines to run this program in batch mode.
Error handling
Error reporting in EZCA is turned on by default. However, by default, an error will not be reported until it has retried 599 times. The number of retries before an error is returned to
stdout
can be set with
ezcaSetRetryCount(n)
. Here is a code snippet illustrating this:
// Setting EZCA to report errors after first try
ezcaSetRetryCount(1);
//Get a description of the variable we are going to set
char desc[100];
int ok = ezcaGet("mass_meas.DESC", ezcaString, 1, desc);
if(ok != EZCA_OK){
printf("ERROR in ezcaGet()\nIs your softIoc on and using the right EPICS record ?\n");
return 1;
}
--
PaulMullen - 28 Jul 2010
imported from nuclear.gla.ac.uk/twiki/bin/view.pl/Main/RootAndEPICS
--
PeterZumbruch - 23 Aug 2012