\hypertarget{compact_8h}{
\section{compact.h File Reference}
\label{compact_8h}\index{compact.h@{compact.h}}
}
The compaction routines reduce the data volume by a combination of selection and compression before writing the data into a buffer. 

{\tt \#include \char`\"{}EDS/EBF\_\-dir.h\char`\"{}}\par


Include dependency graph for compact.h:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=118pt]{compact_8h__incl}
\end{center}
\end{figure}


This graph shows which files directly or indirectly include this file:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=161pt]{compact_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{compact_8h_a0}{
typedef \hyperlink{structLSEC__compaction__}{LSEC\_\-compaction\_\-} \hyperlink{compact_8h_a0}{LSEC\_\-compaction}}
\label{compact_8h_a0}

\begin{CompactList}\small\item\em Declaration of the opaque compaction structure. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ \hyperlink{compact_8h_a1}{LSEC\_\-new\-Compaction} (unsigned cap)
\begin{CompactList}\small\item\em Allocate memory for an LSEC\_\-compaction structure and all the substructures. \item\end{CompactList}\item 
void \hyperlink{compact_8h_a2}{LSEC\_\-delete\-Compaction} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc)
\begin{CompactList}\small\item\em Free memory previously allocated with a call to LSEC\_\-new\-Compaction. \item\end{CompactList}\item 
void \hyperlink{compact_8h_a3}{LSEC\_\-clear\-Compaction} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc)
\begin{CompactList}\small\item\em Clear away any context from a previous cycle. \item\end{CompactList}\item 
void \hyperlink{compact_8h_a4}{LSEC\_\-set\-Mode} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, unsigned mode)
\item 
void \hyperlink{compact_8h_a5}{LSEC\_\-set\-Four\-Range} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, unsigned range)
\item 
unsigned \hyperlink{compact_8h_a6}{LSEC\_\-check\-Compaction} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc)
\begin{CompactList}\small\item\em Check the substructures for errors. \item\end{CompactList}\item 
unsigned \hyperlink{compact_8h_a7}{LSEC\_\-monitor\-Compaction} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, unsigned mon)
\begin{CompactList}\small\item\em Set the monitoring level for the compaction. \item\end{CompactList}\item 
unsigned \hyperlink{compact_8h_a8}{LSEC\_\-encode} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, EBF\_\-dir $\ast$dir)
\begin{CompactList}\small\item\em Encode the next event from the collection. \item\end{CompactList}\item 
unsigned \hyperlink{compact_8h_a9}{LSEC\_\-sizeof\-User32} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc)
\begin{CompactList}\small\item\em Calculate the number of 32 bit words required to hold tables against which the events will be encoded. \item\end{CompactList}\item 
unsigned int $\ast$ \hyperlink{compact_8h_a10}{LSEC\_\-consign\-User} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, unsigned int $\ast$buf)
\begin{CompactList}\small\item\em Pack the tables against which the events will be encoded into the buffer. \item\end{CompactList}\item 
unsigned int $\ast$ \hyperlink{compact_8h_a11}{LSEC\_\-consign\-Evt} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, unsigned int $\ast$buf)
\begin{CompactList}\small\item\em Copy a single encoded event into the datagram. \item\end{CompactList}\item 
void \hyperlink{compact_8h_a12}{LSEC\_\-histogram\-Acd} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, EBF\_\-dir $\ast$dir)
\begin{CompactList}\small\item\em Perform the desired action on the ACD. \item\end{CompactList}\item 
void \hyperlink{compact_8h_a13}{LSEC\_\-histogram\-Cal\-Means} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, EBF\_\-dir $\ast$dir)
\begin{CompactList}\small\item\em Perform the preliminary analysis of the calorimeter log values, to obtain the means. \item\end{CompactList}\item 
void \hyperlink{compact_8h_a14}{LSEC\_\-histogram\-Cal} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, EBF\_\-dir $\ast$dir)
\begin{CompactList}\small\item\em Perform the desired action on the ACD. \item\end{CompactList}\item 
void \hyperlink{compact_8h_a15}{LSEC\_\-histogram\-Tkr} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc, EBF\_\-dir $\ast$dir)
\begin{CompactList}\small\item\em Perform the desired action on the ACD. \item\end{CompactList}\item 
void \hyperlink{compact_8h_a16}{LSEC\_\-calculate\-Cal\-Means} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc)
\begin{CompactList}\small\item\em Caclulate the mean value for each CAL log end. \item\end{CompactList}\item 
unsigned \hyperlink{compact_8h_a17}{LSEC\_\-process\-Acd} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc)
\begin{CompactList}\small\item\em NO-OP. \item\end{CompactList}\item 
unsigned \hyperlink{compact_8h_a18}{LSEC\_\-process\-Cal} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc)
\begin{CompactList}\small\item\em Process the CAL compression structures. \item\end{CompactList}\item 
unsigned \hyperlink{compact_8h_a19}{LSEC\_\-process\-Tkr} (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$cpc)
\begin{CompactList}\small\item\em Process the TKR compression structures. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
The compaction routines reduce the data volume by a combination of selection and compression before writing the data into a buffer. 

\begin{Desc}
\item[Author:]James Swain -- \href{mailto:jswain@slac.stanford.edu}{\tt jswain@slac.stanford.edu}\end{Desc}


\subsection{Function Documentation}
\hypertarget{compact_8h_a16}{
\index{compact.h@{compact.h}!LSEC_calculateCalMeans@{LSEC\_\-calculateCalMeans}}
\index{LSEC_calculateCalMeans@{LSEC\_\-calculateCalMeans}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-calculateCalMeans]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-calculate\-Cal\-Means (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc})}}
\label{compact_8h_a16}


Caclulate the mean value for each CAL log end. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to an LSEC\_\-compaction structure\end{description}
\end{Desc}
\hypertarget{compact_8h_a6}{
\index{compact.h@{compact.h}!LSEC_checkCompaction@{LSEC\_\-checkCompaction}}
\index{LSEC_checkCompaction@{LSEC\_\-checkCompaction}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-checkCompaction]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-check\-Compaction (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc})}}
\label{compact_8h_a6}


Check the substructures for errors. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to a compaction object \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The last error from the first substrcture to be found in error or LSEC\_\-SUCCESS if there are no errors\end{Desc}
\hypertarget{compact_8h_a3}{
\index{compact.h@{compact.h}!LSEC_clearCompaction@{LSEC\_\-clearCompaction}}
\index{LSEC_clearCompaction@{LSEC\_\-clearCompaction}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-clearCompaction]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-clear\-Compaction (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc})}}
\label{compact_8h_a3}


Clear away any context from a previous cycle. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to a compaction object\end{description}
\end{Desc}
\hypertarget{compact_8h_a11}{
\index{compact.h@{compact.h}!LSEC_consignEvt@{LSEC\_\-consignEvt}}
\index{LSEC_consignEvt@{LSEC\_\-consignEvt}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-consignEvt]{\setlength{\rightskip}{0pt plus 5cm}unsigned int$\ast$ LSEC\_\-consign\-Evt (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, unsigned int $\ast$ {\em buf})}}
\label{compact_8h_a11}


Copy a single encoded event into the datagram. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to the compaction structure holding the encoded event \item[{\em buf}]Pointer to the location to place the encoded event \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the next output location\end{Desc}
\hypertarget{compact_8h_a10}{
\index{compact.h@{compact.h}!LSEC_consignUser@{LSEC\_\-consignUser}}
\index{LSEC_consignUser@{LSEC\_\-consignUser}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-consignUser]{\setlength{\rightskip}{0pt plus 5cm}unsigned int$\ast$ LSEC\_\-consign\-User (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, unsigned int $\ast$ {\em buf})}}
\label{compact_8h_a10}


Pack the tables against which the events will be encoded into the buffer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]Pointer to the buffer where the context should be placed$\backslash$ \item[{\em cpc}]Pointer to the structure containing the tables (a compaction) \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the next output location to be filled.\end{Desc}
\hypertarget{compact_8h_a2}{
\index{compact.h@{compact.h}!LSEC_deleteCompaction@{LSEC\_\-deleteCompaction}}
\index{LSEC_deleteCompaction@{LSEC\_\-deleteCompaction}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-deleteCompaction]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-delete\-Compaction (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc})}}
\label{compact_8h_a2}


Free memory previously allocated with a call to LSEC\_\-new\-Compaction. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to a compaction structure previously created by a call to LSEC\_\-new\-Compaction\end{description}
\end{Desc}
\hypertarget{compact_8h_a8}{
\index{compact.h@{compact.h}!LSEC_encode@{LSEC\_\-encode}}
\index{LSEC_encode@{LSEC\_\-encode}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-encode (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, EBF\_\-dir $\ast$ {\em dir})}}
\label{compact_8h_a8}


Encode the next event from the collection. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to an LSEC\_\-compaction structure \item[{\em dir}]Pointer to the event to encode \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Size of the compressed event, or 0 if there is an error\end{Desc}
\hypertarget{compact_8h_a12}{
\index{compact.h@{compact.h}!LSEC_histogramAcd@{LSEC\_\-histogramAcd}}
\index{LSEC_histogramAcd@{LSEC\_\-histogramAcd}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-histogramAcd]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-histogram\-Acd (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, EBF\_\-dir $\ast$ {\em dir})}}
\label{compact_8h_a12}


Perform the desired action on the ACD. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Compaction structure \item[{\em dir}]Pointer to a directory of the event\end{description}
\end{Desc}
\hypertarget{compact_8h_a14}{
\index{compact.h@{compact.h}!LSEC_histogramCal@{LSEC\_\-histogramCal}}
\index{LSEC_histogramCal@{LSEC\_\-histogramCal}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-histogramCal]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-histogram\-Cal (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, EBF\_\-dir $\ast$ {\em dir})}}
\label{compact_8h_a14}


Perform the desired action on the ACD. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Compaction structure \item[{\em dir}]Pointer to a directory of the event\end{description}
\end{Desc}
\hypertarget{compact_8h_a13}{
\index{compact.h@{compact.h}!LSEC_histogramCalMeans@{LSEC\_\-histogramCalMeans}}
\index{LSEC_histogramCalMeans@{LSEC\_\-histogramCalMeans}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-histogramCalMeans]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-histogram\-Cal\-Means (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, EBF\_\-dir $\ast$ {\em dir})}}
\label{compact_8h_a13}


Perform the preliminary analysis of the calorimeter log values, to obtain the means. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Compaction structure \item[{\em dir}]Pointer to the event to analyse\end{description}
\end{Desc}
\hypertarget{compact_8h_a15}{
\index{compact.h@{compact.h}!LSEC_histogramTkr@{LSEC\_\-histogramTkr}}
\index{LSEC_histogramTkr@{LSEC\_\-histogramTkr}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-histogramTkr]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-histogram\-Tkr (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, EBF\_\-dir $\ast$ {\em dir})}}
\label{compact_8h_a15}


Perform the desired action on the ACD. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Compaction structure \item[{\em dir}]Pointer to a directory of the event\end{description}
\end{Desc}
\hypertarget{compact_8h_a7}{
\index{compact.h@{compact.h}!LSEC_monitorCompaction@{LSEC\_\-monitorCompaction}}
\index{LSEC_monitorCompaction@{LSEC\_\-monitorCompaction}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-monitorCompaction]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-monitor\-Compaction (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, unsigned {\em mon})}}
\label{compact_8h_a7}


Set the monitoring level for the compaction. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to an initialised compaction \item[{\em mon}]Monitoring level \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Previous monitoring level\end{Desc}
\hypertarget{compact_8h_a1}{
\index{compact.h@{compact.h}!LSEC_newCompaction@{LSEC\_\-newCompaction}}
\index{LSEC_newCompaction@{LSEC\_\-newCompaction}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-newCompaction]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction}$\ast$ LSEC\_\-new\-Compaction (unsigned {\em cap})}}
\label{compact_8h_a1}


Allocate memory for an LSEC\_\-compaction structure and all the substructures. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cap}]Capacity of the calibration task, the maximum number of events that can be collected each cycle \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to an allocated, initialise, LSEC\_\-compaction structure\end{Desc}
\hypertarget{compact_8h_a17}{
\index{compact.h@{compact.h}!LSEC_processAcd@{LSEC\_\-processAcd}}
\index{LSEC_processAcd@{LSEC\_\-processAcd}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-processAcd]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-process\-Acd (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc})}}
\label{compact_8h_a17}


NO-OP. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to an LSEC\_\-compaction structure\end{description}
\end{Desc}
\hypertarget{compact_8h_a18}{
\index{compact.h@{compact.h}!LSEC_processCal@{LSEC\_\-processCal}}
\index{LSEC_processCal@{LSEC\_\-processCal}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-processCal]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-process\-Cal (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc})}}
\label{compact_8h_a18}


Process the CAL compression structures. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to an LSEC\_\-compaction structure\end{description}
\end{Desc}
\hypertarget{compact_8h_a19}{
\index{compact.h@{compact.h}!LSEC_processTkr@{LSEC\_\-processTkr}}
\index{LSEC_processTkr@{LSEC\_\-processTkr}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-processTkr]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-process\-Tkr (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc})}}
\label{compact_8h_a19}


Process the TKR compression structures. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to an LSEC\_\-compaction structure\end{description}
\end{Desc}
\hypertarget{compact_8h_a5}{
\index{compact.h@{compact.h}!LSEC_setFourRange@{LSEC\_\-setFourRange}}
\index{LSEC_setFourRange@{LSEC\_\-setFourRange}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-setFourRange]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-set\-Four\-Range (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, unsigned {\em range})}}
\label{compact_8h_a5}


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to a compaction structure \item[{\em range}]Flag indicating 4-range or auto-range\end{description}
\end{Desc}
\hypertarget{compact_8h_a4}{
\index{compact.h@{compact.h}!LSEC_setMode@{LSEC\_\-setMode}}
\index{LSEC_setMode@{LSEC\_\-setMode}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-setMode]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-set\-Mode (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc}, unsigned {\em mode})}}
\label{compact_8h_a4}


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to a compaction structure \item[{\em mode}]The calibration mode\end{description}
\end{Desc}
\hypertarget{compact_8h_a9}{
\index{compact.h@{compact.h}!LSEC_sizeofUser32@{LSEC\_\-sizeofUser32}}
\index{LSEC_sizeofUser32@{LSEC\_\-sizeofUser32}!compact.h@{compact.h}}
\subsubsection[LSEC\_\-sizeofUser32]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-sizeof\-User32 (\hyperlink{structLSEC__compaction__}{LSEC\_\-compaction} $\ast$ {\em cpc})}}
\label{compact_8h_a9}


Calculate the number of 32 bit words required to hold tables against which the events will be encoded. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpc}]Pointer to the compaction structure \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Number of 32 bit words required to hold the context information\end{Desc}
