KID

Back to the DH page

Introduction

KID, or KLOE Integrated Dataflow, is the main interface to the data handling system. Its main advantage is its ease of use; it allows the user to access one or more data sources by means of a one line URI (Uniform Resource Identifier).

Contents

The KID library

The KID library is a generic interface to the KLOE data sources. The base library does not have any predefined access method and relies totally on the plug-ins.

[ The URI paradigm , The C user interface , The FORTRAN user interface and the AC module , The plug-in interface ]

The URI paradigm

The KID library access the KLOE data sources my means of URIs. A URI is a one line text string, composed of a protocol, followed by the protocol specific data.

The KID library splits the given URI between the two parts; the protocol is used to identify the desired plug-in module, while the remaining part is sent untouched to the module functions. From this point on, all the calls to the KID library functions will be redirected to the corresponding functions of the plug-in module.

The C user interface

The end-user-oriented C interface of the KID library is quite similar to the ordinary file access library; the user has to open a data source, read-out the data until it has enough or it gets to the end, and finally it closes the data source. The KID library is a little bit more flexible since it have several open and read functions, but all-in-all the concept is the same. Most of the functions return an error code, with KID_IN_ERROR_OK meaning no error:

An example of use:

char *uri = "spydaq:ALL";
const int maxevents = 10000;
int err;
int buflen;
KID_IN_id kid_in_id;

err=kid_in_open(uri,&kid_in_id);
if (err!=KID_IN_ERROR_OK) return 1; /* error */
for(i=0; i<maxevents; i++)
  {
    int buflen;
    const kevent *buffer;

    do {
     err = kid_in_get_dynamic(kid_in_id,&buffer,&buflen);
     if (err==KID_IN_ERROR_EMPTY) sleep(1);
     else break;
    } while(1);
    if (err==KID_IN_ERROR_CLOSED) break; /* no more events */
    if (err!=KID_IN_ERROR_OK) {
      printf("URL error at %i (%s)\n",i,ErrorGetMessage());
      break;
    }
   /* use the buffer */
   free(buffer);
  }
kid_in_close(kid_in_id);

For more examples, see the function pages.

The FORTRAN user interface and the AC module

The end-user-oriented FORTRAN interface of the KID library has fewer functionalities than the C library, but on the other side, the available functions are more powerful. They are meant to be easy to use rather than extremely flexible:

The FORTRAN interface has been used to create an Analysis Control (AC) input module, named KIDIN. This input module allows to access the KLOE data using the input url AC command, in addition to the usual input file. Here are two examples of use:

input file “../data/myfile.ybos”
input url “spydaq:ALL”

The plug-in interface

To create a new module, the programmer is required to implement a module specific version of all the open, readout and close functions listed in the C user interface section. At this point, the functions must be registered to the KID library, together with the selected protocol string, using the kid_in_module_add function. From that point on, the KID library will redirect the calls to the registered functions every time the specified protocol is present in a URI.

The standard KID modules

While the basic KID library gives a good starting point, without some plug-in modules it is useless. Reallizing that, the KID package comes equipped with a rich set of read-to-use plug-in modules.

The available modules

The standard modules can be divided in:

For more details, see the module specific pages.

Standard modules registration in a C program

Since the standard modules are not part of the base KID library, the programmer must explicitly register them; this is accomplished by a call to the kid_in_stdmodules_init function.

Standard modules registration in a FORTRAN program

Since the standard modules are not part of the base KID library, the programmer must explicitly register them; this is accomplished by a call to the kid_in_f_init function.

The AC input module KIDIN is already configured to register the standard modules, so it can be used as is.

Compiling the KID library

Most of the time, both the basic KID library and the standard plug-in modules are needed, so only this scenario is presented.

Compiling a C program

Include files:

Compile time options:

Link time options:

Link time options with pthreads:

Compiling a FORTRAN program

Include files:

Link time options:

Building an AC executable

The following line must be put in the build_job uic:

The following option must be added to the link_ana opt file:


Send comment to Igor Sfiligoi.