A conditions data framework for the I\-L\-C -\/ based on {\tt L\-C\-I\-O}.

Upcoming testbeam efforts will need a way to store and retrieve conditions data, e.\-g. slow control, electronics setup and calibration constants. Typically experiments use a 'conditions database' for this purpose. While a database offers you all the functionality that is required (varying validity time ranges, tags, history, etc.) it also puts some burden on the users as they have to set up and maintain a data base system. \par
 A simpler approach is to store conditions data in L\-C\-I\-O files that are used for the data itself anyhow.\par
 While being straight forward and easy to implement this approach lacks some of the desired features for conditions data like tags, versioning and history. 

L\-C\-C\-D is a toolkit that combines the two options in a transparent way. It is implemented in C++ and uses an Open Source implementation of a conditions database interface developed for the Atlas experiment\-: {\tt Conditions\-D\-B\-My\-S\-Q\-L} {\tt (cvs)} .

\subsection*{Overview}

L\-C\-C\-D is a conditions data toolkit that is based on L\-C\-I\-O. It allows to handle arbitrary conditions data as long as they are expressed in terms of L\-C\-I\-O classes. If you don't need the full database functionality you can use L\-C\-C\-D with plain L\-C\-I\-O only. The main purpose is to provide an easy to use interface to read conditions data in any program that analyzes L\-C\-I\-O data. There are four different uses cases (scenarios) implemented in L\-C\-C\-D\-: 
\begin{DoxyEnumerate}
\item Read conditions data that is valid for the time specified by the time stamp in the current L\-C\-Event on the fly from a data base. Typically one wants to do this for a given tag that is known to reference data with approved quality (e.\-g. calibration, channel mapping, etc.). This is the most general case usually needed in a full reconstruction job. 
\item Read one particular set of conditions data, e.\-g. calibration constants from an L\-C\-I\-O file in a small job. This is the simplest case that can be used to check certain conditions data and distribute it to a group of people. 
\item Read conditions data that occures in the data stream of an L\-C\-I\-O file. This can be used to analyze data that has been created by a D\-A\-Q that writes some slow control information into the data stream online. For example there might be a temerature reading every minute during data taking. This sort of conditions data will simply be valid from the event where it was stored until the next event with a newer version of this particular data is read.  
\item Read conditions data from an L\-C\-I\-O file that has been created in a special way, so that it holds the data for a given time range with consecutive validity intervalls in consecutive events. \doxyref{lccd\-::\-D\-B\-Interface}{p.}{classlccd_1_1DBInterface} provides a method to create such a file from a database folder for a given tag. This can be used to distribute conditions data with validity range information to systems where no data base is available. One scenario where this might be usefull is grid computing where you can't necessarily expect to have access to a database.  
\end{DoxyEnumerate}All four use cases are implemented through the common interface \doxyref{lccd\-::\-I\-Conditions\-Handler}{p.}{classlccd_1_1IConditionsHandler}. This ensures that user code can be writen without making any assumption on how the conditions data is actually provided at run time.

While most users will only be interested in reading the conditions data someone has to actually create the data and make it available. The \doxyref{lccd\-::\-D\-B\-Interface}{p.}{classlccd_1_1DBInterface} provides easy to use methods to store and tag the data in a conditions database. The only requirement is that the data is available in an L\-C\-Collection of L\-C\-Generic\-Object subclasses. The data itself is stored as a B\-L\-O\-B (binary large object) in the database. L\-C\-C\-D provides streamer code for L\-C\-Generic\-Objects that is machine independent (using X\-D\-R). By implementing a suitable \doxyref{lccd\-::\-V\-Collection\-Streamer}{p.}{classlccd_1_1VCollectionStreamer} users can in principle store any data they like in the data base. But they have to keep in mind that as long as there is no corresponding L\-C\-I\-O class they won't be able to use L\-C\-I\-O files transparently.

\subsection*{Conditions Database}

For the conditions database L\-C\-C\-D uses {\tt Conditions\-D\-B\-My\-S\-Q\-L}. This is an open source implementation of the Conditions\-D\-B interface from C\-E\-R\-N that has been developed by the Lisbon A\-T\-L\-A\-S group.\par
 The main features of the database are\-: 
\begin{DoxyItemize}
\item data is stored in folders, similar to directories in a unix file system. 
\item one folder contains one particular type of conditions data for all time intervalls 
\item data can be tagged similar to the tagging mechanism in cvs\-: 
\begin{DoxyItemize}
\item there is always a H\-E\-A\-D version that holds the latest data 
\item if a tag is applied all data in the current H\-E\-A\-D become part of that tag 
\end{DoxyItemize}
\item every new collection of conditions data stored in the folder superseeds all existing data for the given validity time intervall 
\item there is no (easy) way to find out what the H\-E\-A\-D was at a given point in the past, thus one should use tags frequently to mark certain points in time 
\item for a given point in time you can always get all versions of collections that have been stored in the database valid at this point (vertical browsing) 
\end{DoxyItemize}

Conditions\-D\-B provides a rich {\tt A\-P\-I} for storing and retrieving data in/from a database. \par
 However for most users the subset of functionality provided in \doxyref{lccd\-::\-D\-B\-Interface}{p.}{classlccd_1_1DBInterface} should suffice.

\subsubsection*{Time Stamps}

L\-C\-C\-D and L\-C\-I\-O use 64bit time stamps to synchronize data and condtions data. The definition is 
\begin{DoxyItemize}
\item {\bfseries ns since 1.\-1.\-1970 00\-:00\-:00 U\-T\-C }
\end{DoxyItemize}{\itshape Note\-: this is different from the convention used in Simple\-Time of Conditions\-D\-B.\par
 L\-C\-C\-D provides a conversion method \doxyref{lccd\-::from\-Simple\-Time()}{p.}{namespacelccd_a733f4ea8d00a53c6c64332aafc1c6397} in case this is needed.}

\subsection*{Example Code}

L\-C\-C\-D comes with a number of test programs that can be used as examples for your own applications in\par


{\ttfamily source/test}

All examples are simple and should be self explanatory -\/ if not please let now. \par


{\tt frank.\-gaede@desy.\-de} 