\hypertarget{expand_8c}{
\section{expand.c File Reference}
\label{expand_8c}\index{expand.c@{expand.c}}
}
Reverse a previous compaction. 

{\tt \#include \char`\"{}expand\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}expand.h\char`\"{}}\par
{\tt \#include \char`\"{}decompress.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/APD.h\char`\"{}}\par
{\tt \#include \char`\"{}LSEC/enums.h\char`\"{}}\par
{\tt \#include $<$string.h$>$}\par


Include dependency graph for expand.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=248pt]{expand_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static unsigned char $\ast$ \hyperlink{expand_8c_a0}{add\-Dcm} (\hyperlink{structQSEC__decompression__}{QSEC\_\-decompression} $\ast$$\ast$pdcm, unsigned char $\ast$next, unsigned int nbits, const char $\ast$name)
\begin{CompactList}\small\item\em Construct a decompression structure. \item\end{CompactList}\item 
static const unsigned int $\ast$ \hyperlink{expand_8c_a1}{recover\-User\-Gem} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, const unsigned int $\ast$buf)
\begin{CompactList}\small\item\em Unpack the tables against which the GEM data were encoded. \item\end{CompactList}\item 
static const unsigned int $\ast$ \hyperlink{expand_8c_a2}{recover\-User\-Acd} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, const unsigned int $\ast$buf)
\begin{CompactList}\small\item\em Unpack the tables against which the ACD contributions were encoded. \item\end{CompactList}\item 
static const unsigned int $\ast$ \hyperlink{expand_8c_a3}{recover\-User\-Cal} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, const unsigned int $\ast$buf)
\begin{CompactList}\small\item\em Unpack the tables against which the CAL contributions were encoded. \item\end{CompactList}\item 
static const unsigned int $\ast$ \hyperlink{expand_8c_a4}{recover\-User\-Tkr} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, const unsigned int $\ast$buf)
\begin{CompactList}\small\item\em Unpack the tables against which the TKR contributions were encoded. \item\end{CompactList}\item 
size\_\-t \hyperlink{expand_8c_a5}{QSEC\_\-sizeof\-Expansion} (unsigned cap)
\begin{CompactList}\small\item\em Calculate the size of the memory block required to accomodate the expansion structure. \item\end{CompactList}\item 
\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ \hyperlink{expand_8c_a6}{QSEC\_\-construct\-Expansion} (void $\ast$buffer, unsigned cap)
\begin{CompactList}\small\item\em Construct a QSEC\_\-expansion structure in a buffer. \item\end{CompactList}\item 
\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ \hyperlink{expand_8c_a7}{QSEC\_\-new\-Expansion} (unsigned cap)
\begin{CompactList}\small\item\em Allocate memory for a QSEC\_\-expansion structure and all the substructures. \item\end{CompactList}\item 
void \hyperlink{expand_8c_a8}{QSEC\_\-delete\-Expansion} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp)
\begin{CompactList}\small\item\em Free memory previously allocated with a call to QSEC\_\-new\-Expansion. \item\end{CompactList}\item 
void \hyperlink{expand_8c_a9}{QSEC\_\-clear\-Expansion} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp)
\begin{CompactList}\small\item\em Clear away any context from a previous cycle. \item\end{CompactList}\item 
void \hyperlink{expand_8c_a10}{QSEC\_\-report\-Expansion} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, FILE $\ast$fp)
\begin{CompactList}\small\item\em Report the contents of an expansion. \item\end{CompactList}\item 
void \hyperlink{expand_8c_a11}{QSEC\_\-set\-Mode} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, unsigned mode)
\begin{CompactList}\small\item\em Set the calibration mode of an expansion. \item\end{CompactList}\item 
void \hyperlink{expand_8c_a12}{QSEC\_\-set\-Four\-Range} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, unsigned rng)
\begin{CompactList}\small\item\em Set the range for a calibration expansion. \item\end{CompactList}\item 
unsigned \hyperlink{expand_8c_a13}{QSEC\_\-monitor\-Expansion} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, unsigned mon)
\begin{CompactList}\small\item\em Set the monitoring level for the expansion. \item\end{CompactList}\item 
const unsigned int $\ast$ \hyperlink{expand_8c_a14}{QSEC\_\-recover\-User} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, const unsigned int $\ast$buf)
\begin{CompactList}\small\item\em Unpack the tables against which the events were encoded. \item\end{CompactList}\item 
const unsigned int $\ast$ \hyperlink{expand_8c_a15}{decode\-Cal\-Means} (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$exp, const unsigned int $\ast$buf)
\begin{CompactList}\small\item\em Decompress the calorimeter log mean values. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Reverse a previous compaction. 

\begin{Desc}
\item[Author:]James Swain \& Owen Saxton\end{Desc}
\begin{Desc}
\item[Id]\hyperlink{expand_8c}{expand.c},v 1.7 2007/04/05 23:05:44 saxton Exp \end{Desc}


\subsection{Function Documentation}
\hypertarget{expand_8c_a0}{
\index{expand.c@{expand.c}!addDcm@{addDcm}}
\index{addDcm@{addDcm}!expand.c@{expand.c}}
\subsubsection[addDcm]{\setlength{\rightskip}{0pt plus 5cm}unsigned char $\ast$ add\-Dcm (\hyperlink{structQSEC__decompression__}{QSEC\_\-decompression} $\ast$$\ast$ {\em pdcm}, unsigned char $\ast$ {\em next}, unsigned int {\em nbits}, const char $\ast$ {\em name})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{expand_8c_a0}


Construct a decompression structure. 

Constructs a decompression structure within the memory allocated for the expansion structure and returns a pointer to the location to place the next decompression

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em pdcm}]Pointer to the location to place the pointer to the decompression structure\item[{\em next}]Pointer to the start of the memory to use for this decompression structure\item[{\em nbits}]Number of bits in the symbols handled by this decompression structure\item[{\em name}]String identifying the decompression structure\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the location to place the next decompression structure\end{Desc}
\hypertarget{expand_8c_a15}{
\index{expand.c@{expand.c}!decodeCalMeans@{decodeCalMeans}}
\index{decodeCalMeans@{decodeCalMeans}!expand.c@{expand.c}}
\subsubsection[decodeCalMeans]{\setlength{\rightskip}{0pt plus 5cm}const unsigned int$\ast$ decode\-Cal\-Means (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, const unsigned int $\ast$ {\em buf})}}
\label{expand_8c_a15}


Decompress the calorimeter log mean values. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exp}]Pointer to the expansion structure\item[{\em buf}]Pointer to the compressed data\end{description}
\end{Desc}
\hypertarget{expand_8c_a9}{
\index{expand.c@{expand.c}!QSEC_clearExpansion@{QSEC\_\-clearExpansion}}
\index{QSEC_clearExpansion@{QSEC\_\-clearExpansion}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-clearExpansion]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-clear\-Expansion (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp})}}
\label{expand_8c_a9}


Clear away any context from a previous cycle. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exp}]Pointer to a expansion object\end{description}
\end{Desc}
\hypertarget{expand_8c_a6}{
\index{expand.c@{expand.c}!QSEC_constructExpansion@{QSEC\_\-constructExpansion}}
\index{QSEC_constructExpansion@{QSEC\_\-constructExpansion}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-constructExpansion]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion}$\ast$ QSEC\_\-construct\-Expansion (void $\ast$ {\em buffer}, unsigned {\em cap})}}
\label{expand_8c_a6}


Construct a QSEC\_\-expansion structure in a buffer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cap}]Capacity of the decompression, maximum number of events in a single cycle\item[{\em buffer}]Uninitialised memory large enough to hold the expansion structure\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to an initialised expansion structure\end{Desc}
\hypertarget{expand_8c_a8}{
\index{expand.c@{expand.c}!QSEC_deleteExpansion@{QSEC\_\-deleteExpansion}}
\index{QSEC_deleteExpansion@{QSEC\_\-deleteExpansion}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-deleteExpansion]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-delete\-Expansion (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp})}}
\label{expand_8c_a8}


Free memory previously allocated with a call to QSEC\_\-new\-Expansion. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exp}]Pointer to a expansion structure previously created by a call to QSEC\_\-new\-Expansion\end{description}
\end{Desc}
\hypertarget{expand_8c_a13}{
\index{expand.c@{expand.c}!QSEC_monitorExpansion@{QSEC\_\-monitorExpansion}}
\index{QSEC_monitorExpansion@{QSEC\_\-monitorExpansion}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-monitorExpansion]{\setlength{\rightskip}{0pt plus 5cm}unsigned QSEC\_\-monitor\-Expansion (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, unsigned {\em mon})}}
\label{expand_8c_a13}


Set the monitoring level for the expansion. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exp}]Pointer to an initialised expansion\item[{\em mon}]Monitoring level\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Previous monitoring level\end{Desc}
\hypertarget{expand_8c_a7}{
\index{expand.c@{expand.c}!QSEC_newExpansion@{QSEC\_\-newExpansion}}
\index{QSEC_newExpansion@{QSEC\_\-newExpansion}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-newExpansion]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion}$\ast$ QSEC\_\-new\-Expansion (unsigned {\em cap})}}
\label{expand_8c_a7}


Allocate memory for a QSEC\_\-expansion structure and all the substructures. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cap}]Capacity of the decompression, maximum number of events in a single cycle\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to an allocated, initialise, QSEC\_\-expansion structure\end{Desc}
\hypertarget{expand_8c_a14}{
\index{expand.c@{expand.c}!QSEC_recoverUser@{QSEC\_\-recoverUser}}
\index{QSEC_recoverUser@{QSEC\_\-recoverUser}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-recoverUser]{\setlength{\rightskip}{0pt plus 5cm}const unsigned int$\ast$ QSEC\_\-recover\-User (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, const unsigned int $\ast$ {\em buf})}}
\label{expand_8c_a14}


Unpack the tables against which the events were encoded. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]Pointer to the buffer where the context is held\item[{\em exp}]Pointer to the structure containing the tables (an expansion)\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the next input location to be read or NULL if there was an error during recovery of User data\end{Desc}
\hypertarget{expand_8c_a10}{
\index{expand.c@{expand.c}!QSEC_reportExpansion@{QSEC\_\-reportExpansion}}
\index{QSEC_reportExpansion@{QSEC\_\-reportExpansion}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-reportExpansion]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-report\-Expansion (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, FILE $\ast$ {\em fp})}}
\label{expand_8c_a10}


Report the contents of an expansion. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exp}]Pointer to a expansion object\item[{\em fp}]Pointer to the destination file\end{description}
\end{Desc}
\hypertarget{expand_8c_a12}{
\index{expand.c@{expand.c}!QSEC_setFourRange@{QSEC\_\-setFourRange}}
\index{QSEC_setFourRange@{QSEC\_\-setFourRange}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-setFourRange]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-set\-Four\-Range (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, unsigned {\em rng})}}
\label{expand_8c_a12}


Set the range for a calibration expansion. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exp}]Pointer to a expansion structure\item[{\em rng}]Flag indicating 4-range or auto-range\end{description}
\end{Desc}
\hypertarget{expand_8c_a11}{
\index{expand.c@{expand.c}!QSEC_setMode@{QSEC\_\-setMode}}
\index{QSEC_setMode@{QSEC\_\-setMode}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-setMode]{\setlength{\rightskip}{0pt plus 5cm}void QSEC\_\-set\-Mode (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, unsigned {\em mode})}}
\label{expand_8c_a11}


Set the calibration mode of an expansion. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exp}]Pointer to a expansion structure\item[{\em mode}]Type of calibration\end{description}
\end{Desc}
\hypertarget{expand_8c_a5}{
\index{expand.c@{expand.c}!QSEC_sizeofExpansion@{QSEC\_\-sizeofExpansion}}
\index{QSEC_sizeofExpansion@{QSEC\_\-sizeofExpansion}!expand.c@{expand.c}}
\subsubsection[QSEC\_\-sizeofExpansion]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t QSEC\_\-sizeof\-Expansion (unsigned {\em cap})}}
\label{expand_8c_a5}


Calculate the size of the memory block required to accomodate the expansion structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cap}]Capacity of the decompression, maximum number of events in a single cycle\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Size of the memory block required to accomodate the expansion structure\end{Desc}
\hypertarget{expand_8c_a2}{
\index{expand.c@{expand.c}!recoverUserAcd@{recoverUserAcd}}
\index{recoverUserAcd@{recoverUserAcd}!expand.c@{expand.c}}
\subsubsection[recoverUserAcd]{\setlength{\rightskip}{0pt plus 5cm}const unsigned int $\ast$ recover\-User\-Acd (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, const unsigned int $\ast$ {\em buf})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{expand_8c_a2}


Unpack the tables against which the ACD contributions were encoded. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]Pointer to the buffer where the context is held\item[{\em exp}]Pointer to the structure containing the tables (an expansion)\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the next input location to read or NULL if there is an error in the unpacking.\end{Desc}
\hypertarget{expand_8c_a3}{
\index{expand.c@{expand.c}!recoverUserCal@{recoverUserCal}}
\index{recoverUserCal@{recoverUserCal}!expand.c@{expand.c}}
\subsubsection[recoverUserCal]{\setlength{\rightskip}{0pt plus 5cm}const unsigned int $\ast$ recover\-User\-Cal (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, const unsigned int $\ast$ {\em buf})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{expand_8c_a3}


Unpack the tables against which the CAL contributions were encoded. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]Pointer to the buffer where the context is held\item[{\em exp}]Pointer to the structure containing the tables (an expansion)\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the next input location to read or NULL if there is an error in the unpacking.\end{Desc}
\hypertarget{expand_8c_a1}{
\index{expand.c@{expand.c}!recoverUserGem@{recoverUserGem}}
\index{recoverUserGem@{recoverUserGem}!expand.c@{expand.c}}
\subsubsection[recoverUserGem]{\setlength{\rightskip}{0pt plus 5cm}const unsigned int $\ast$ recover\-User\-Gem (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, const unsigned int $\ast$ {\em buf})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{expand_8c_a1}


Unpack the tables against which the GEM data were encoded. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]Pointer to the buffer where the context is held\item[{\em exp}]Pointer to the structure containing the tables (an expansion)\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the next input location to read or NULL if there is an error in the unpacking\end{Desc}
\hypertarget{expand_8c_a4}{
\index{expand.c@{expand.c}!recoverUserTkr@{recoverUserTkr}}
\index{recoverUserTkr@{recoverUserTkr}!expand.c@{expand.c}}
\subsubsection[recoverUserTkr]{\setlength{\rightskip}{0pt plus 5cm}const unsigned int $\ast$ recover\-User\-Tkr (\hyperlink{structQSEC__expansion__}{QSEC\_\-expansion} $\ast$ {\em exp}, const unsigned int $\ast$ {\em buf})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{expand_8c_a4}


Unpack the tables against which the TKR contributions were encoded. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]Pointer to the buffer where the context is held\item[{\em exp}]Pointer to the structure containing the tables (an expansion)\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the next input location to read or NULL if there is an error in the unpacking.\end{Desc}
