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

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

-- PeterZumbruch - 23 Aug 2012
Topic attachments
I Attachment Action Size Date Who Comment
EzcaPrimer.pdfpdf EzcaPrimer.pdf manage 24.9 K 23 Aug 2012 - 11:30 PeterZumbruch E-Z Channel Access Primer
MakefileEXT Makefile manage 1.0 K 23 Aug 2012 - 11:31 PeterZumbruch Makefile for compiling mass_ana.C
Mass.dbdb Mass.db manage 0.1 K 23 Aug 2012 - 11:31 PeterZumbruch mass_meas EPICS record
Mass_ana_Screenshot.pngpng Mass_ana_Screenshot.png manage 27.5 K 23 Aug 2012 - 11:31 PeterZumbruch Screenshot of mass_ana command output and canvas
ezca_20070625.tar.gzgz ezca_20070625.tar.gz manage 28.8 K 23 Aug 2012 - 11:32 PeterZumbruch E-Z Channel Access source tarball
mass_ana.CC mass_ana.C manage 1.7 K 23 Aug 2012 - 11:32 PeterZumbruch Program to get the peak position from a histogram and put it in EPICS
mass_spectrum.CC mass_spectrum.C manage 1.0 K 23 Aug 2012 - 11:33 PeterZumbruch Macro that produces a histogram
run123456.rootroot run123456.root manage 3.9 K 23 Aug 2012 - 11:33 PeterZumbruch Root file containing a mass distribution histogram
Topic revision: r2 - 10 Jan 2018, PeterZumbruch
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding PANDA Wiki? Send feedback
Imprint (in German)
Privacy Policy (in German)