\hypertarget{QASC_8c}{
\section{QASC.c File Reference}
\label{QASC_8c}\index{QASC.c@{QASC.c}}
}
Expand and access routines to the ACD Software Counters. 

{\tt \#include \char`\"{}QEMP/QASC.h\char`\"{}}\par
{\tt \#include \char`\"{}QEMP/QEMP.h\char`\"{}}\par
{\tt \#include \char`\"{}QEMP/QASC\_\-pubdefs.h\char`\"{}}\par
{\tt \#include \char`\"{}QASC\_\-pvtdefs.h\char`\"{}}\par
{\tt \#include \char`\"{}QEMP\_\-pvtdefs.h\char`\"{}}\par
{\tt \#include \char`\"{}QSE/QSE\_\-acd\-Map.h\char`\"{}}\par
{\tt \#include \char`\"{}EMP/ASC\_\-asc\-Ctb.h\char`\"{}}\par
{\tt \#include \char`\"{}EMP/ASC\_\-ids.h\char`\"{}}\par
{\tt \#include \char`\"{}ZLIB/zlib.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/BSWP.h\char`\"{}}\par
{\tt \#include \char`\"{}PBI/Endianness.h\char`\"{}}\par
{\tt \#include \char`\"{}PBI/Check.h\char`\"{}}\par
{\tt \#include \char`\"{}PBI/Ofs.h\char`\"{}}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par


Include dependency graph for QASC.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=212pt]{QASC_8c__incl}
\end{center}
\end{figure}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{QASC_8c_a0}{
\#define {\bf NULL}~((void $\ast$)0)}
\label{QASC_8c_a0}

\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static \hyperlink{QEMP_8h_a1}{QEMP\_\-STATUS} \hyperlink{QASC_8c_a1}{expand\_\-raw0} (\hyperlink{struct__QASC}{QASC} $\ast$qasc, const ASC\_\-asc\-Bdy\_\-Raw0 $\ast$asc, unsigned int size)
\begin{CompactList}\small\item\em Expand the ASC data in the raw format to QASC format. \item\end{CompactList}\item 
static \hyperlink{QEMP_8h_a1}{QEMP\_\-STATUS} \hyperlink{QASC_8c_a2}{expand\_\-gzip0} (\hyperlink{struct__QASC}{QASC} $\ast$qasc, const ASC\_\-asc\-Bdy\_\-Gzip0 $\ast$asc, unsigned int size)
\begin{CompactList}\small\item\em Expand the ASC data in the raw format to QASC format. \item\end{CompactList}\item 
static int \hyperlink{QASC_8c_a3}{do\_\-inflate} (const void $\ast$src, unsigned int src\-Size, void $\ast$dst, unsigned int dst\-Size)
\begin{CompactList}\small\item\em Decompress the source buffer to the destination buffe. \item\end{CompactList}\item 
QEMP\_\-status \hyperlink{QASC_8c_a4}{QASC\_\-expand} (\hyperlink{struct__QASC}{QASC} $\ast$qasc, const LSF\_\-contribution $\ast$ctb)
\begin{CompactList}\small\item\em Routine to check integrity and swap/uncompress input data into a 2nd buffer. \item\end{CompactList}\item 
const \hyperlink{struct__QEMP__hdr}{QEMP\_\-hdr} $\ast$ \hyperlink{QASC_8c_a5}{QASC\_\-qemp\-Hdr\-Locate} (const \hyperlink{struct__QASC}{QASC} $\ast$qasc)
\begin{CompactList}\small\item\em Get pointer to QEMP\_\-hdr structure. \item\end{CompactList}\item 
unsigned int \hyperlink{QASC_8c_a6}{QASC\_\-num\-Processed\-Evts} (const \hyperlink{struct__QASC}{QASC} $\ast$qasc)
\begin{CompactList}\small\item\em Get the number of processed events in sample (after prescale). \item\end{CompactList}\item 
const \hyperlink{struct__QASC__stats}{QASC\_\-stats} $\ast$ \hyperlink{QASC_8c_a7}{QASC\_\-stats\-Locate} (const \hyperlink{struct__QASC}{QASC} $\ast$qasc)
\begin{CompactList}\small\item\em Get a pointer to the QASC performance monitoring statistics. \item\end{CompactList}\item 
const \hyperlink{union__QASC__summary}{QASC\_\-summary} $\ast$ \hyperlink{QASC_8c_a8}{QASC\_\-summary\-Locate} (const \hyperlink{struct__QASC}{QASC} $\ast$qasc)
\begin{CompactList}\small\item\em Get a pointer to the QASC summary structure. \item\end{CompactList}\item 
const \hyperlink{struct__QASC__cnoHistogram}{QASC\_\-cno\-Histogram} $\ast$ \hyperlink{QASC_8c_a9}{QASC\_\-cno\-Histogram\-Locate} (const \hyperlink{struct__QASC}{QASC} $\ast$qasc, unsigned int board\_\-pair)
\begin{CompactList}\small\item\em Returns a pointer to the requested CNO histogram. \item\end{CompactList}\item 
int \hyperlink{QASC_8c_a10}{QASC\_\-idx\-Gem\-Get} (int list, int channel)
\begin{CompactList}\small\item\em Maps an ACD GEM list and channel into a universal index. \item\end{CompactList}\item 
int \hyperlink{QASC_8c_a11}{QASC\_\-idx\-Aem\-Get} (int board, int channel)
\begin{CompactList}\small\item\em Maps an ACD AEM board number and channel into a universal index. \item\end{CompactList}\item 
const \hyperlink{struct__QASC__tileHistogram}{QASC\_\-tile\-Histogram} $\ast$ \hyperlink{QASC_8c_a12}{QASC\_\-tile\-Histogram\-Locate} (const \hyperlink{struct__QASC}{QASC} $\ast$qasc, unsigned int idx)
\begin{CompactList}\small\item\em Returns a pointer to the specified tile histogram. \item\end{CompactList}\item 
static \_\-\_\-inline int \hyperlink{QASC_8c_a13}{inflater} (const void $\ast$src, unsigned int src\-Size, void $\ast$dst, unsigned int dst\-Size)
\begin{CompactList}\small\item\em Decompress the source buffer to the destination buffe. \item\end{CompactList}\item 
static void \_\-\_\-inline \hyperlink{QASC_8c_a14}{stats\_\-transfer} (\hyperlink{struct__QASC__stats}{QASC\_\-stats} $\ast$dst, const ASC\_\-stats $\ast$src, unsigned int nsampled)
\begin{CompactList}\small\item\em Transfers the contents of an ASC\_\-stats structure plus the number of events sampled to a QASC\_\-stats structure. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Expand and access routines to the ACD Software Counters. 

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


\footnotesize\begin{verbatim}   CVS $Id: QASC.c,v 1.1 2006/10/21 00:29:59 russell Exp $
\end{verbatim}
\normalsize


\subsection{Function Documentation}
\hypertarget{QASC_8c_a3}{
\index{QASC.c@{QASC.c}!do_inflate@{do\_\-inflate}}
\index{do_inflate@{do\_\-inflate}!QASC.c@{QASC.c}}
\subsubsection[do\_\-inflate]{\setlength{\rightskip}{0pt plus 5cm}static int do\_\-inflate (const void $\ast$ {\em src}, unsigned int {\em src\-Size}, void $\ast$ {\em dst}, unsigned int {\em dst\-Size})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{QASC_8c_a3}


Decompress the source buffer to the destination buffe. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]Success \item[{\em -1}]Failure\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em src}]The source buffer of compressed data \item[{\em src\-Size}]The size, in bytes, of the source buffer of compressed data \item[{\em dst}]The destination buffer for decompressed data \item[{\em dst\-Size}]The available space, in bytes, of the destination buffer\end{description}
\end{Desc}
\hypertarget{QASC_8c_a2}{
\index{QASC.c@{QASC.c}!expand_gzip0@{expand\_\-gzip0}}
\index{expand_gzip0@{expand\_\-gzip0}!QASC.c@{QASC.c}}
\subsubsection[expand\_\-gzip0]{\setlength{\rightskip}{0pt plus 5cm}static \hyperlink{QEMP_8h_a1}{QEMP\_\-STATUS} expand\_\-gzip0 (\hyperlink{struct__QASC}{QASC} $\ast$ {\em qasc}, const ASC\_\-asc\-Bdy\_\-Gzip0 $\ast$ {\em asc}, unsigned int {\em size})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{QASC_8c_a2}


Expand the ASC data in the raw format to QASC format. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em QEMP\_\-STATUS\_\-SUCCESS,if}]successful (0) \item[{\em QEMP\_\-STATUS\_\-CTB\_\-BAD\_\-LEN32,if}]the contributor length is inconsistent with the data. \item[{\em QEMP\_\-STATUS\_\-CTB\_\-INFLATE\_\-FAIL,indicates}]inflate failed\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qasc}]The data access handle to be filled \item[{\em asc}]The source data \item[{\em size}]The size, in bytes, of the source data.\end{description}
\end{Desc}
\hypertarget{QASC_8c_a1}{
\index{QASC.c@{QASC.c}!expand_raw0@{expand\_\-raw0}}
\index{expand_raw0@{expand\_\-raw0}!QASC.c@{QASC.c}}
\subsubsection[expand\_\-raw0]{\setlength{\rightskip}{0pt plus 5cm}static \hyperlink{QEMP_8h_a1}{QEMP\_\-STATUS} expand\_\-raw0 (\hyperlink{struct__QASC}{QASC} $\ast$ {\em qasc}, const ASC\_\-asc\-Bdy\_\-Raw0 $\ast$ {\em asc}, unsigned int {\em size})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{QASC_8c_a1}


Expand the ASC data in the raw format to QASC format. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em QEMP\_\-STATUS\_\-SUCCESS,if}]successful (0) \item[{\em QEMP\_\-STATUS\_\-CTB\_\-BAD\_\-LEN32,if}]the contributor length is inconsistent with the data.\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qasc}]The data access handle to be filled \item[{\em asc}]The source data \item[{\em size}]The size, in bytes, of the source data.\end{description}
\end{Desc}
\hypertarget{QASC_8c_a13}{
\index{QASC.c@{QASC.c}!inflater@{inflater}}
\index{inflater@{inflater}!QASC.c@{QASC.c}}
\subsubsection[inflater]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline int inflater (const void $\ast$ {\em src}, unsigned int {\em src\-Size}, void $\ast$ {\em dst}, unsigned int {\em dst\-Size})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{QASC_8c_a13}


Decompress the source buffer to the destination buffe. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]Success \item[{\em -1}]Failure\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em src}]The source buffer of compressed data \item[{\em src\-Size}]The size, in bytes, of the source buffer of compressed data \item[{\em dst}]The destination buffer for decompressed data \item[{\em dst\-Size}]The available space, in bytes, of the destination buffer\end{description}
\end{Desc}
\hypertarget{QASC_8c_a9}{
\index{QASC.c@{QASC.c}!QASC_cnoHistogramLocate@{QASC\_\-cnoHistogramLocate}}
\index{QASC_cnoHistogramLocate@{QASC\_\-cnoHistogramLocate}!QASC.c@{QASC.c}}
\subsubsection[QASC\_\-cnoHistogramLocate]{\setlength{\rightskip}{0pt plus 5cm}const \hyperlink{struct__QASC__cnoHistogram}{QASC\_\-cno\-Histogram}$\ast$ QASC\_\-cno\-Histogram\-Locate (const \hyperlink{struct__QASC}{QASC} $\ast$ {\em qasc}, unsigned int {\em board\_\-pair})}}
\label{QASC_8c_a9}


Returns a pointer to the requested CNO histogram. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em Non-NULL,a}]pointer to the requested CNO histogram \item[{\em NULL,the}]{\em board\_\-pair\/} was not within the range 0-5\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qasc}]The access handle \item[{\em board\_\-pair}]board (0-5)\end{description}
\end{Desc}
\hypertarget{QASC_8c_a4}{
\index{QASC.c@{QASC.c}!QASC_expand@{QASC\_\-expand}}
\index{QASC_expand@{QASC\_\-expand}!QASC.c@{QASC.c}}
\subsubsection[QASC\_\-expand]{\setlength{\rightskip}{0pt plus 5cm}QEMP\_\-status QASC\_\-expand (\hyperlink{struct__QASC}{QASC} $\ast$ {\em qasc}, const LSF\_\-contribution $\ast$ {\em ctb})}}
\label{QASC_8c_a4}


Routine to check integrity and swap/uncompress input data into a 2nd buffer. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em QEMP\_\-STATUS\_\-SUCCESS,if}]successful (0) \item[{\em QEMP\_\-STATUS\_\-CTB\_\-BAD\_\-LEN32,if}]the contributor length is inconsistent with the data. \item[{\em QEMP\_\-STATUS\_\-CTB\_\-UNKNOWN\_\-VER,if}]the encoding/data format version is unknown.\item[{\em QEMP\_\-STATUS\_\-CTB\_\-INFLATE\_\-FAIL,for}]compressed formats, indicates the failure to inflate the data\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qasc}]The data access handle to be filled \item[{\em ctb}]Input buffer\end{description}
\end{Desc}
The check routine does integrity checks on the given LSF contributor packet and then decompress/swaps data into the output buffer. THe size of the output buffer is determined by \hyperlink{QEMP_8h_a12}{QEMP\_\-sizeof()}. The output buffer can then be used as input with the QASC\_\-xxxx\-Locate routines.

This routine assumes the contributor has been byte-swapped.\hypertarget{QASC_8c_a11}{
\index{QASC.c@{QASC.c}!QASC_idxAemGet@{QASC\_\-idxAemGet}}
\index{QASC_idxAemGet@{QASC\_\-idxAemGet}!QASC.c@{QASC.c}}
\subsubsection[QASC\_\-idxAemGet]{\setlength{\rightskip}{0pt plus 5cm}int QASC\_\-idx\-Aem\-Get (int {\em board}, int {\em channel})}}
\label{QASC_8c_a11}


Maps an ACD AEM board number and channel into a universal index. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em $>$=0,The}]universal index for the specifed ACD AEM board and channel \item[{\em $<$}]0, Invalid board or channel number\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em board}]This is a value between 0 and 11 corresponding to the the 12 AEM FREE board/cable numbers\begin{itemize}
\item 0 1LA, 1 1RB\item 2 2LA, 3 2LB\item 4 2RA, 5 2RB\item 6 3LA, 7 3RB\item 8 4LA, 9 4LB\item 9 4RA, 10 4RB\end{itemize}
\item[{\em channel}]The channel, 0-18, within each FREE board/cable.\end{description}
\end{Desc}
\hypertarget{QASC_8c_a10}{
\index{QASC.c@{QASC.c}!QASC_idxGemGet@{QASC\_\-idxGemGet}}
\index{QASC_idxGemGet@{QASC\_\-idxGemGet}!QASC.c@{QASC.c}}
\subsubsection[QASC\_\-idxGemGet]{\setlength{\rightskip}{0pt plus 5cm}int QASC\_\-idx\-Gem\-Get (int {\em list}, int {\em channel})}}
\label{QASC_8c_a10}


Maps an ACD GEM list and channel into a universal index. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em $>$=0,The}]universal index for the specifed ACD list and channel \item[{\em $<$}]0, Invalid list or channel number\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em list}]This is a value between 0 and 3 corresponding to the 4 words in the GEM record -0 XZ plane -1 YZ plane -2 XY plane -3 RU plane \item[{\em channel}]The channel, 0-31, within each list. The bits are numbered from least significant bit to most significant bit\end{description}
\end{Desc}
\hypertarget{QASC_8c_a6}{
\index{QASC.c@{QASC.c}!QASC_numProcessedEvts@{QASC\_\-numProcessedEvts}}
\index{QASC_numProcessedEvts@{QASC\_\-numProcessedEvts}!QASC.c@{QASC.c}}
\subsubsection[QASC\_\-numProcessedEvts]{\setlength{\rightskip}{0pt plus 5cm}unsigned int QASC\_\-num\-Processed\-Evts (const \hyperlink{struct__QASC}{QASC} $\ast$ {\em qasc})}}
\label{QASC_8c_a6}


Get the number of processed events in sample (after prescale). 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em The}]number of processed events (after prescaling)\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qasc}]The access handle\end{description}
\end{Desc}
---------------------------------------------------------------------- \hypertarget{QASC_8c_a5}{
\index{QASC.c@{QASC.c}!QASC_qempHdrLocate@{QASC\_\-qempHdrLocate}}
\index{QASC_qempHdrLocate@{QASC\_\-qempHdrLocate}!QASC.c@{QASC.c}}
\subsubsection[QASC\_\-qempHdrLocate]{\setlength{\rightskip}{0pt plus 5cm}const \hyperlink{struct__QEMP__hdr}{QEMP\_\-hdr}$\ast$ QASC\_\-qemp\-Hdr\-Locate (const \hyperlink{struct__QASC}{QASC} $\ast$ {\em qasc})}}
\label{QASC_8c_a5}


Get pointer to QEMP\_\-hdr structure. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em Pointer}]to the QEMP\_\-hdr structure\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qasc}]Access handle\end{description}
\end{Desc}
\hypertarget{QASC_8c_a7}{
\index{QASC.c@{QASC.c}!QASC_statsLocate@{QASC\_\-statsLocate}}
\index{QASC_statsLocate@{QASC\_\-statsLocate}!QASC.c@{QASC.c}}
\subsubsection[QASC\_\-statsLocate]{\setlength{\rightskip}{0pt plus 5cm}const \hyperlink{struct__QASC__stats}{QASC\_\-stats}$\ast$ QASC\_\-stats\-Locate (const \hyperlink{struct__QASC}{QASC} $\ast$ {\em qasc})}}
\label{QASC_8c_a7}


Get a pointer to the QASC performance monitoring statistics. 

\begin{Desc}
\item[Returns:]A pointer to the QASC performance monitoring statistics\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qasc}]The access handle\end{description}
\end{Desc}
\hypertarget{QASC_8c_a8}{
\index{QASC.c@{QASC.c}!QASC_summaryLocate@{QASC\_\-summaryLocate}}
\index{QASC_summaryLocate@{QASC\_\-summaryLocate}!QASC.c@{QASC.c}}
\subsubsection[QASC\_\-summaryLocate]{\setlength{\rightskip}{0pt plus 5cm}const \hyperlink{union__QASC__summary}{QASC\_\-summary}$\ast$ QASC\_\-summary\-Locate (const \hyperlink{struct__QASC}{QASC} $\ast$ {\em qasc})}}
\label{QASC_8c_a8}


Get a pointer to the QASC summary structure. 

\begin{Desc}
\item[Returns:]A pointer to the QASC summary structure\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qasc}]The access handle\end{description}
\end{Desc}
\hypertarget{QASC_8c_a12}{
\index{QASC.c@{QASC.c}!QASC_tileHistogramLocate@{QASC\_\-tileHistogramLocate}}
\index{QASC_tileHistogramLocate@{QASC\_\-tileHistogramLocate}!QASC.c@{QASC.c}}
\subsubsection[QASC\_\-tileHistogramLocate]{\setlength{\rightskip}{0pt plus 5cm}const \hyperlink{struct__QASC__tileHistogram}{QASC\_\-tile\-Histogram}$\ast$ QASC\_\-tile\-Histogram\-Locate (const \hyperlink{struct__QASC}{QASC} $\ast$ {\em qasc}, unsigned int {\em idx})}}
\label{QASC_8c_a12}


Returns a pointer to the specified tile histogram. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em Non-NULL,a}]pointer to the specified histogram \item[{\em NULL,an}]invalid index, {\em geo\_\-idx\/}, was specified. This must be in the range 0-128\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qasc}]The access handle \item[{\em idx}]The index, set QASC\_\-tile\-Histogram\-Geo\-Idx;\end{description}
\end{Desc}
\hypertarget{QASC_8c_a14}{
\index{QASC.c@{QASC.c}!stats_transfer@{stats\_\-transfer}}
\index{stats_transfer@{stats\_\-transfer}!QASC.c@{QASC.c}}
\subsubsection[stats\_\-transfer]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline void stats\_\-transfer (\hyperlink{struct__QASC__stats}{QASC\_\-stats} $\ast$ {\em dst}, const ASC\_\-stats $\ast$ {\em src}, unsigned int {\em nsampled})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{QASC_8c_a14}


Transfers the contents of an ASC\_\-stats structure plus the number of events sampled to a QASC\_\-stats structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dst}]The destination QASC\_\-stats structure \item[{\em src}]The source ASC\_\-stats structure \item[{\em nsampled}]The number of events sampled\end{description}
\end{Desc}
The QASC\_\-stats structure is not a mirror of an ASC\_\-stats, having the number of events sampled as an additional member. Because of this a formalized transfer method is needed.