\hypertarget{DFC_8c}{
\section{DFC.c File Reference}
\label{DFC_8c}\index{DFC.c@{DFC.c}}
}
Diagnostic Filter Code.  


{\tt \#include $<$EFC/EDM.h$>$}\par
{\tt \#include $<$EFC/EFC\_\-edsFw.h$>$}\par
{\tt \#include $<$EFC/EFC.h$>$}\par
{\tt \#include $<$XFC/DFC.h$>$}\par
{\tt \#include $<$XFC/DFC\_\-cfg.h$>$}\par
{\tt \#include $<$XFC/DFC\_\-status.h$>$}\par
{\tt \#include $<$DFC\_\-def.h$>$}\par
{\tt \#include $<$DFC\_\-resultDef.h$>$}\par
{\tt \#include $<$EDS/EDS\_\-fw.h$>$}\par
{\tt \#include $<$EDS/EBF\_\-gem.h$>$}\par
{\tt \#include $<$EDS/EBF\_\-gemLocate.h$>$}\par
{\tt \#include $<$CDM/CDM\_\-pubdefs.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$string.h$>$}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{DFC_8c_6fb91b294ccf8965bc88949a4e33d503}{
\#define \textbf{\_\-code}~EDM\_\-CODE}
\label{DFC_8c_6fb91b294ccf8965bc88949a4e33d503}

\item 
\hypertarget{DFC_8c_d5eb6fd7f4ead21c6957592c4ab3c0de}{
\#define \textbf{\_\-info}(...)}
\label{DFC_8c_d5eb6fd7f4ead21c6957592c4ab3c0de}

\item 
\hypertarget{DFC_8c_51bd585db625919309b0488c30f8f331}{
\#define \textbf{\_\-debug}(...)}
\label{DFC_8c_51bd585db625919309b0488c30f8f331}

\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static \_\-\_\-inline int \hyperlink{DFC_8c_41c39220eb2b5d52c8cfe57706d196d0}{isVetoed} (unsigned int status, unsigned int vetoes)
\begin{CompactList}\small\item\em Checks whether any of the veto bits are up. \item\end{CompactList}\item 
static \_\-\_\-inline int \hyperlink{DFC_8c_0e81a3ec341338c242fbcaf2026babb4}{dfcFilter} (\hyperlink{struct__DFC}{DFC} $\ast$dfc, unsigned int pktBytes, EBF\_\-pkt $\ast$pkt, EBF\_\-siv siv, EDS\_\-fwIxb $\ast$ixb, unsigned int vetoes, \hyperlink{struct__DFC__result}{DFC\_\-result} $\ast$result)
\begin{CompactList}\small\item\em Determines the fate of 1 event. \item\end{CompactList}\item 
static int \hyperlink{DFC_8c_6db71724b21a4d1fb46cd86c0a7576e7}{compileCfgPrms} (\hyperlink{struct__DfcCfgPrms}{DfcCfgPrms} $\ast$cfg, const DFC\_\-DB\_\-prms $\ast$prms)
\begin{CompactList}\small\item\em Compiles/commits the set of user defined parameters into the the configuration block. \item\end{CompactList}\item 
int \hyperlink{DFC_8c_9a76b5b994a06e943f104733c7903e8a}{DFC\_\-sizeof} (int cnt)
\begin{CompactList}\small\item\em Sizes the diagnostic filtering control structure. \item\end{CompactList}\item 
int \hyperlink{DFC_8c_51b01df8bf43a9c57c14523b37401a05}{DFC\_\-cfgSizeof} (void)
\begin{CompactList}\small\item\em Sizes the diagnostic filtering configuration as it is used in the actual filtering progam. \item\end{CompactList}\item 
int \hyperlink{DFC_8c_1ba156bbc229f6b37411324e5a1206fe}{DFC\_\-resultSizeof} (const \hyperlink{struct__DFC}{DFC} $\ast$dfc)
\begin{CompactList}\small\item\em Returns the size, in bytes, of one result vector. \item\end{CompactList}\item 
int \hyperlink{DFC_8c_5bc12d53a55c58f4ee384af84e5f0bb2}{DFC\_\-cfgCompile} (\hyperlink{struct__DFC__cfg}{DFC\_\-cfg} $\ast$cfg, const DFC\_\-DB\_\-prms $\ast$prms)
\begin{CompactList}\small\item\em Implements the transformation of the configuration parameters as specified by the user, {\em cfg\/}, into the internal form, {\em ctlCfg\/}. \item\end{CompactList}\item 
int \hyperlink{DFC_8c_7fc1eba2817aae884fc8dc938257fb03}{DFC\_\-cfgSchemaCompile} (\hyperlink{struct__DFC__cfg}{DFC\_\-cfg} $\ast$cfg, const DFC\_\-DB\_\-schema $\ast$schema)
\begin{CompactList}\small\item\em Implements the transformation of the configuration parameters as specified by the user, {\em cfg\/}, into the internal form, {\em ctlCfg\/}. \item\end{CompactList}\item 
const \hyperlink{struct__DFC__cfg}{DFC\_\-cfg} $\ast$ \hyperlink{DFC_8c_ba2cf22e5b785ac6013154070e1c0003}{DFC\_\-cfgSet} (\hyperlink{struct__DFC}{DFC} $\ast$dfc, \hyperlink{struct__DFC__cfg}{DFC\_\-cfg} $\ast$cfg)
\begin{CompactList}\small\item\em Makes the specified internal representation of the configuration parameters the current active one. \item\end{CompactList}\item 
int \hyperlink{DFC_8c_8b3dafbd9f4af27ca7203f7467a3069f}{DFC\_\-filter} (\hyperlink{struct__DFC}{DFC} $\ast$dfc, unsigned int pktBytes, EBF\_\-pkt $\ast$pkt, EBF\_\-siv siv, EDS\_\-fwIxb $\ast$ixb, unsigned int vetoes, \hyperlink{struct__DFC__result}{DFC\_\-result} $\ast$result)
\begin{CompactList}\small\item\em Determines the fate of 1 event. \item\end{CompactList}\item 
unsigned int \hyperlink{DFC_8c_d7f7b2bce33714a44ec440f70d6704dc}{DFC\_\-fwNeeds} (void)
\begin{CompactList}\small\item\em Returns a bit mask of the EDS\_\-fw needs. \item\end{CompactList}\item 
unsigned int \hyperlink{DFC_8c_66ef32ca6769892bd2526a207559a265}{DFC\_\-fwObjects} (void)
\begin{CompactList}\small\item\em Returns a bit mask of the EDS\_\-fw objects used by the heavy ion filter. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Diagnostic Filter Code. 

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


\footnotesize\begin{verbatim}
   CVS $Id: DFC.c,v 1.4 2012/01/04 20:36:41 russell Exp $
\end{verbatim}
\normalsize
 

\subsection{Function Documentation}
\hypertarget{DFC_8c_6db71724b21a4d1fb46cd86c0a7576e7}{
\index{DFC.c@{DFC.c}!compileCfgPrms@{compileCfgPrms}}
\index{compileCfgPrms@{compileCfgPrms}!DFC.c@{DFC.c}}
\subsubsection[{compileCfgPrms}]{\setlength{\rightskip}{0pt plus 5cm}static int compileCfgPrms ({\bf DfcCfgPrms} $\ast$ {\em cfg}, \/  const DFC\_\-DB\_\-prms $\ast$ {\em prms})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{DFC_8c_6db71724b21a4d1fb46cd86c0a7576e7}


Compiles/commits the set of user defined parameters into the the configuration block. 

\begin{Desc}
\item[Returns:]0 is success, -1 if failure\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cfg}]The destination parameter configuration block \item[{\em prms}]The set of user configuration parameters \end{description}
\end{Desc}


References \_\-DfcCfgPrms::gem, and \_\-DfcCfgGem::map.

Referenced by DFC\_\-cfgCompile().\hypertarget{DFC_8c_5bc12d53a55c58f4ee384af84e5f0bb2}{
\index{DFC.c@{DFC.c}!DFC\_\-cfgCompile@{DFC\_\-cfgCompile}}
\index{DFC\_\-cfgCompile@{DFC\_\-cfgCompile}!DFC.c@{DFC.c}}
\subsubsection[{DFC\_\-cfgCompile}]{\setlength{\rightskip}{0pt plus 5cm}int DFC\_\-cfgCompile ({\bf DFC\_\-cfg} $\ast$ {\em cfg}, \/  const DFC\_\-DB\_\-prms $\ast$ {\em prms})}}
\label{DFC_8c_5bc12d53a55c58f4ee384af84e5f0bb2}


Implements the transformation of the configuration parameters as specified by the user, {\em cfg\/}, into the internal form, {\em ctlCfg\/}. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]Successful \item[{\em -1}]Unrecognized or non-backwardly compatiable user configuration version number.\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cfg}]Filled in with the internal form of the configuration parameters \item[{\em prms}]The user form of the configuration parameters \end{description}
\end{Desc}


References compileCfgPrms(), \_\-DFC\_\-cfg::prms, and \_\-DFC\_\-cfg::titles.

Referenced by DFC\_\-cfgSchemaCompile().\hypertarget{DFC_8c_7fc1eba2817aae884fc8dc938257fb03}{
\index{DFC.c@{DFC.c}!DFC\_\-cfgSchemaCompile@{DFC\_\-cfgSchemaCompile}}
\index{DFC\_\-cfgSchemaCompile@{DFC\_\-cfgSchemaCompile}!DFC.c@{DFC.c}}
\subsubsection[{DFC\_\-cfgSchemaCompile}]{\setlength{\rightskip}{0pt plus 5cm}int DFC\_\-cfgSchemaCompile ({\bf DFC\_\-cfg} $\ast$ {\em cfg}, \/  const DFC\_\-DB\_\-schema $\ast$ {\em schema})}}
\label{DFC_8c_7fc1eba2817aae884fc8dc938257fb03}


Implements the transformation of the configuration parameters as specified by the user, {\em cfg\/}, into the internal form, {\em ctlCfg\/}. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]Successful \item[{\em -1}]Unrecognized or non-backwardly compatiable user configuration version number.\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cfg}]Filled in with the internal form of the configuration parameters \item[{\em schema}]The user form of the configuration schema \end{description}
\end{Desc}


References DFC\_\-cfgCompile(), and \_\-DFC\_\-cfg::prms.\hypertarget{DFC_8c_ba2cf22e5b785ac6013154070e1c0003}{
\index{DFC.c@{DFC.c}!DFC\_\-cfgSet@{DFC\_\-cfgSet}}
\index{DFC\_\-cfgSet@{DFC\_\-cfgSet}!DFC.c@{DFC.c}}
\subsubsection[{DFC\_\-cfgSet}]{\setlength{\rightskip}{0pt plus 5cm}const {\bf DFC\_\-cfg} $\ast$ DFC\_\-cfgSet ({\bf DFC} $\ast$ {\em dfc}, \/  {\bf DFC\_\-cfg} $\ast$ {\em cfg})}}
\label{DFC_8c_ba2cf22e5b785ac6013154070e1c0003}


Makes the specified internal representation of the configuration parameters the current active one. 

\begin{Desc}
\item[Returns:]Pointer to the current control configuration parameters\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dfc}]The diagnostic filter control structure \item[{\em cfg}]The internal representation of the configuration constants \end{description}
\end{Desc}


References \_\-DFC::cfg.\hypertarget{DFC_8c_51b01df8bf43a9c57c14523b37401a05}{
\index{DFC.c@{DFC.c}!DFC\_\-cfgSizeof@{DFC\_\-cfgSizeof}}
\index{DFC\_\-cfgSizeof@{DFC\_\-cfgSizeof}!DFC.c@{DFC.c}}
\subsubsection[{DFC\_\-cfgSizeof}]{\setlength{\rightskip}{0pt plus 5cm}int DFC\_\-cfgSizeof (void)}}
\label{DFC_8c_51b01df8bf43a9c57c14523b37401a05}


Sizes the diagnostic filtering configuration as it is used in the actual filtering progam. 

\begin{Desc}
\item[Returns:]Returns the size of the heavy ion filtering configuration control structure\end{Desc}
\begin{Desc}
\item[]There are two different breeds of the filtering configuration structure. There are two reasons for this. The more familar is the configuration structure that the user fills in. This structure is meant to be convenient for the user, but not for the program. Some of the information in the user structure is transformed into data that the program will find more accessible.\end{Desc}
\begin{Desc}
\item[]The second reason is that by having a user configuration and an internal configuration, the two can evolve separately. If more parameters are added to the filter, they will find a home in the internal structure. At some time they may be exposed to the user. The correct course of action is to define a new version of the user configuration block. Since the version number is carried along with the configuration constants, the routine transforming the user configuration to its internal representation can evolve and can be made to handle older versions of the user configuration parameters with some degree of grace, at least giving some hope to backward compatibility.\end{Desc}
\begin{Desc}
\item[]The correct usage model is 

\begin{Code}\begin{verbatim}       ctlCfg = malloc (DFC_cfgSizeof ());
       status = DFC_cfgCompile (cfg, usrPrms);
       DFC_cfgSet (dfc, cfg);
\end{verbatim}
\end{Code}

\end{Desc}
\begin{Desc}
\item[Note:]Because the 'set routine just seeds a pointer to the user configuration, in the control structure. the user is free to swap it out with any other pre-prepared configuration. \end{Desc}
\hypertarget{DFC_8c_8b3dafbd9f4af27ca7203f7467a3069f}{
\index{DFC.c@{DFC.c}!DFC\_\-filter@{DFC\_\-filter}}
\index{DFC\_\-filter@{DFC\_\-filter}!DFC.c@{DFC.c}}
\subsubsection[{DFC\_\-filter}]{\setlength{\rightskip}{0pt plus 5cm}int DFC\_\-filter ({\bf DFC} $\ast$ {\em dfc}, \/  unsigned int {\em pktBytes}, \/  EBF\_\-pkt $\ast$ {\em pkt}, \/  EBF\_\-siv {\em siv}, \/  EDS\_\-fwIxb $\ast$ {\em ixb}, \/  unsigned int {\em vetoes}, \/  {\bf DFC\_\-result} $\ast$ {\em result})}}
\label{DFC_8c_8b3dafbd9f4af27ca7203f7467a3069f}


Determines the fate of 1 event. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em $<$}]0, rejected \item[{\em ==0,undecided}]\item[{\em $>$}]0, accepted\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dfc}]The diagnostic filter control structure \item[{\em pktBytes}]The number of bytes in {\em pkt\/}, includes the packet header \item[{\em pkt}]The event data packet \item[{\em siv}]The packet's state information vector \item[{\em ixb}]The information exchange block \item[{\em vetoes}]The active vetoes \item[{\em result}]The filter result vector\end{description}
\end{Desc}
\begin{Desc}
\item[Overview]This acts as a wrapper of the actual filter. This is were the sampling logic is implemented by the use prescalers. A prescaler is defined by a pair of integers; one giving the current countdown value and the other giving the refresh value. When the countdown value reaches 0, the prescaler is said to expire.\end{Desc}
\begin{Desc}
\item[Types of prescaling]There are two kinds of samplings allow.\end{Desc}
\begin{enumerate}
\item Pass-thru sampling\item Individual veto sampling\end{enumerate}


\begin{Desc}
\item[Pass-Thru Sampling]Conceptually this is the easiest to understand. When the pass-thru prescaler expires, instead of using the normal veto mask, a 0 is used, effectively causing the filter to evaluate all its cuts but not allowing an cut to veto the event. While easy to understand, the event sample leaked through by this technique will be dominated by events that would normally have been rejected by the very early cuts.\end{Desc}
\begin{Desc}
\item[Individual Veto Sampling]This prescaler type allows to ignore the reject decision of each veto bit. While a bit harder to understand than the Pass-Thru Sampling, this technique allows one to tap a predetermined percentage of events failing at each cut. The hope is that one will be a statisitically meaningful sample of events that would have normally failed some of the later cuts in the filter. \end{Desc}


References dfcFilter().\hypertarget{DFC_8c_d7f7b2bce33714a44ec440f70d6704dc}{
\index{DFC.c@{DFC.c}!DFC\_\-fwNeeds@{DFC\_\-fwNeeds}}
\index{DFC\_\-fwNeeds@{DFC\_\-fwNeeds}!DFC.c@{DFC.c}}
\subsubsection[{DFC\_\-fwNeeds}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int DFC\_\-fwNeeds (void)}}
\label{DFC_8c_d7f7b2bce33714a44ec440f70d6704dc}


Returns a bit mask of the EDS\_\-fw needs. 

\begin{Desc}
\item[Returns:]A bit mask of the EDS\_\-fw needs\end{Desc}
\begin{Desc}
\item[Use]This value should be passed to EDS\_\-fwRegister when registering the filter. \end{Desc}


Referenced by dfc\_\-construct().\hypertarget{DFC_8c_66ef32ca6769892bd2526a207559a265}{
\index{DFC.c@{DFC.c}!DFC\_\-fwObjects@{DFC\_\-fwObjects}}
\index{DFC\_\-fwObjects@{DFC\_\-fwObjects}!DFC.c@{DFC.c}}
\subsubsection[{DFC\_\-fwObjects}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int DFC\_\-fwObjects (void)}}
\label{DFC_8c_66ef32ca6769892bd2526a207559a265}


Returns a bit mask of the EDS\_\-fw objects used by the heavy ion filter. 

\begin{Desc}
\item[Returns:]A bit mask of the EDS\_\-fw needs\end{Desc}
\begin{Desc}
\item[Use]This value should be passed to EDS\_\-fwRegister when registering the filter. \end{Desc}


Referenced by dfc\_\-construct().\hypertarget{DFC_8c_1ba156bbc229f6b37411324e5a1206fe}{
\index{DFC.c@{DFC.c}!DFC\_\-resultSizeof@{DFC\_\-resultSizeof}}
\index{DFC\_\-resultSizeof@{DFC\_\-resultSizeof}!DFC.c@{DFC.c}}
\subsubsection[{DFC\_\-resultSizeof}]{\setlength{\rightskip}{0pt plus 5cm}int DFC\_\-resultSizeof (const {\bf DFC} $\ast$ {\em dfc})}}
\label{DFC_8c_1ba156bbc229f6b37411324e5a1206fe}


Returns the size, in bytes, of one result vector. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em The}]size, in bytes, of one result vector\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dfc}]The configuration control structure \end{description}
\end{Desc}
\hypertarget{DFC_8c_9a76b5b994a06e943f104733c7903e8a}{
\index{DFC.c@{DFC.c}!DFC\_\-sizeof@{DFC\_\-sizeof}}
\index{DFC\_\-sizeof@{DFC\_\-sizeof}!DFC.c@{DFC.c}}
\subsubsection[{DFC\_\-sizeof}]{\setlength{\rightskip}{0pt plus 5cm}int DFC\_\-sizeof (int {\em cnt})}}
\label{DFC_8c_9a76b5b994a06e943f104733c7903e8a}


Sizes the diagnostic filtering control structure. 

\begin{Desc}
\item[Returns:]Returns the size of the heavy ion filtering control structure\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cnt}]Number of configurations to accommodate \end{description}
\end{Desc}
\hypertarget{DFC_8c_0e81a3ec341338c242fbcaf2026babb4}{
\index{DFC.c@{DFC.c}!dfcFilter@{dfcFilter}}
\index{dfcFilter@{dfcFilter}!DFC.c@{DFC.c}}
\subsubsection[{dfcFilter}]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline int dfcFilter ({\bf DFC} $\ast$ {\em dfc}, \/  unsigned int {\em pktBytes}, \/  EBF\_\-pkt $\ast$ {\em pkt}, \/  EBF\_\-siv {\em siv}, \/  EDS\_\-fwIxb $\ast$ {\em ixb}, \/  unsigned int {\em vetoes}, \/  {\bf DFC\_\-result} $\ast$ {\em result})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{DFC_8c_0e81a3ec341338c242fbcaf2026babb4}


Determines the fate of 1 event. 

\begin{Desc}
\item[Returns:]Status mask, if the\begin{itemize}
\item $<$ 0, reject\item = 0, no decision\item $>$ 0, accept\end{itemize}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dfc}]The diagnostic filter control structure \item[{\em pktBytes}]The number of bytes in {\em pkt\/}, includes the packet header \item[{\em pkt}]The event data packet \item[{\em siv}]The packet's state information vector \item[{\em ixb}]The information exchange block \item[{\em vetoes}]The list of active vetoes \item[{\em result}]The filter result vector \end{description}
\end{Desc}


References \_\-DFC\_\-result::beg, \_\-DFC::cfg, DFC\_\-STATUS\_\-M\_\-STAGE\_\-GEM, DFC\_\-STATUS\_\-M\_\-VETOED, \_\-DFC\_\-result::evtNum, \_\-DFC\_\-result::gem, \_\-DfcCfgPrms::gem, ievt\_\-store, isVetoed(), \_\-DfcCfgGem::map, \_\-DFC\_\-cfg::prms, \_\-DFC\_\-result::status, and tmr\_\-store.

Referenced by DFC\_\-filter().\hypertarget{DFC_8c_41c39220eb2b5d52c8cfe57706d196d0}{
\index{DFC.c@{DFC.c}!isVetoed@{isVetoed}}
\index{isVetoed@{isVetoed}!DFC.c@{DFC.c}}
\subsubsection[{isVetoed}]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline int isVetoed (unsigned int {\em status}, \/  unsigned int {\em vetoes})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{DFC_8c_41c39220eb2b5d52c8cfe57706d196d0}


Checks whether any of the veto bits are up. 

\begin{Desc}
\item[Returns:]Non-zero if the {\em status\/} bits contain any of the veto bits.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em status}]The current set of status bits \item[{\em vetoes}]The set of veto bits \end{description}
\end{Desc}


Referenced by dfcFilter().