\hypertarget{EFA_8h}{
\section{EFA.h File Reference}
\label{EFA_8h}\index{EFA.h@{EFA.h}}
}
Defines the functions to a header common to all event-based analysis.  


{\tt \#include $<$EFC/EFA\_\-def.h$>$}\par
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{EFA_8h_9169d36d85d6729344e6fa540af75207}{
typedef struct \hyperlink{struct__EFA}{\_\-EFA} \textbf{EFA}}
\label{EFA_8h_9169d36d85d6729344e6fa540af75207}

\item 
\hypertarget{EFA_8h_8228ecf57524804940aca3eafc555b40}{
typedef struct \hyperlink{struct__EFA__hdr}{\_\-EFA\_\-hdr} \textbf{EFA\_\-hdr}}
\label{EFA_8h_8228ecf57524804940aca3eafc555b40}

\item 
\hypertarget{EFA_8h_03ba1bebc99a2d35f2821dae6be8de2e}{
typedef struct \_\-EDS\_\-cfgInfo \textbf{EDS\_\-cfgInfo}}
\label{EFA_8h_03ba1bebc99a2d35f2821dae6be8de2e}

\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{EFA_8h_d3421702f328408cc00ae610743dc0ab}{EFA\_\-construct} (\hyperlink{struct__EFA}{EFA} $\ast$efa, void $\ast$pool, int enable, const \hyperlink{struct__EFA__services}{EFA\_\-services} $\ast$services, void $\ast$ctx, unsigned int size, unsigned int postCnt, unsigned int recCnt)
\begin{CompactList}\small\item\em Set up the internal data structures of the EFA control structure. \item\end{CompactList}\item 
int \hyperlink{EFA_8h_1a290c646b7063a2397e5f4b7587d587}{EFA\_\-flush} (\hyperlink{struct__EFA}{EFA} $\ast$efa, int reason)
\begin{CompactList}\small\item\em Forces a posting of the current results. \item\end{CompactList}\item 
int \hyperlink{EFA_8h_f237fbf2bf0d3e7ff953abad19ae3ff1}{EFA\_\-notify} (\hyperlink{struct__EFA}{EFA} $\ast$efa, int mode, const EDS\_\-cfgInfo $\ast$cfg)
\begin{CompactList}\small\item\em Callback signature to notify an analyis routine of a mode change. \item\end{CompactList}\item 
int \hyperlink{EFA_8h_3f6410e262cb2aeed991161510f7d7a4}{EFA\_\-resultSizeof} (const \hyperlink{struct__EFA}{EFA} $\ast$efa)
\begin{CompactList}\small\item\em Returns the size, in bytes, of one result vector. \item\end{CompactList}\item 
int \hyperlink{EFA_8h_1cf05169bff197f8e0647359702760cd}{EFA\_\-sizeof} (int result\_\-size, int result\_\-cnt)
\begin{CompactList}\small\item\em Computes the size, in bytes, of the EFA control structure. \item\end{CompactList}\item 
int \hyperlink{EFA_8h_c09bab3943a494aa7073a0acb95e1170}{EFA\_\-enable} (\hyperlink{struct__EFA}{EFA} $\ast$efa, int enable)
\begin{CompactList}\small\item\em Enables/disables EFA. This can only be done outside the context of a run, i.e. the state must be STOPPED. \item\end{CompactList}\item 
int \hyperlink{EFA_8h_3ef15aea0484c48528e64adfddf81de5}{EFA\_\-start} (\hyperlink{struct__EFA}{EFA} $\ast$efa, int reason, int run\_\-id, int startTime, int mode)
\begin{CompactList}\small\item\em Callback signature to start or prepare a posting stream to receive events. \item\end{CompactList}\item 
unsigned int \hyperlink{EFA_8h_94f70093b0539d811949695b5fa41932}{EFA\_\-hdrCompose} (\hyperlink{struct__EFA__hdr}{EFA\_\-hdr} $\ast$hdr, unsigned int relative, unsigned long long seq, unsigned int gemClock, unsigned int gemStrobe)
\begin{CompactList}\small\item\em Composes specified event header. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Defines the functions to a header common to all event-based analysis. 

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


\footnotesize\begin{verbatim}

   CVS $Id: EFA.h,v 1.2 2011/03/27 04:55:29 russell Exp $
\end{verbatim}
\normalsize
 

\subsection{Function Documentation}
\hypertarget{EFA_8h_d3421702f328408cc00ae610743dc0ab}{
\index{EFA.h@{EFA.h}!EFA\_\-construct@{EFA\_\-construct}}
\index{EFA\_\-construct@{EFA\_\-construct}!EFA.h@{EFA.h}}
\subsubsection[{EFA\_\-construct}]{\setlength{\rightskip}{0pt plus 5cm}int EFA\_\-construct ({\bf EFA} $\ast$ {\em efa}, \/  void $\ast$ {\em pool}, \/  int {\em enable}, \/  const {\bf EFA\_\-services} $\ast$ {\em services}, \/  void $\ast$ {\em ctx}, \/  unsigned int {\em size}, \/  unsigned int {\em postCnt}, \/  unsigned int {\em flushCnt})}}
\label{EFA_8h_d3421702f328408cc00ae610743dc0ab}


Set up the internal data structures of the EFA control structure. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0,Success}]\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em efa}]The Event Filter Analysis control structure \item[{\em pool}]The memory pool \item[{\em enable}]1 if start in the enabled state, else start in the disabled state \item[{\em services}]The set of service routines \item[{\em ctx}]Arbitrary user context parameter passed to the user callback routines \item[{\em size}]The size of a result vector. This value should have been obtained by a call to EFA\_\-resultSizeof This routine checks that this value matches that from EFA\_\-resultSizeof. \item[{\em postCnt}]The number of result vectors in a packet. This results in a process flush reason \item[{\em flushCnt}]The number of result vectors before a flush is issued. This results in a process LSF\_\-REASON\_\-CLOSE\_\-K\_\-STOP\_\-CNT flush reason. \end{description}
\end{Desc}


References \_\-EFA::beg, \_\-EFA::beg\_\-evt\_\-fill, \_\-EFA::ctx, \_\-EFA::cur, EFA\_\-alloc(), EFA\_\-STATE\_\-K\_\-DISABLED, EFA\_\-STATE\_\-K\_\-STOPPED, \_\-EFA::flushLeft, \_\-EFA::flushLimit, \_\-EFA::pool, \_\-EFA::postLeft, \_\-EFA::postLimit, \_\-EFA::services, \_\-EFA::size, and \_\-EFA::state.

Referenced by EFC\_\-stdConstruct().\hypertarget{EFA_8h_c09bab3943a494aa7073a0acb95e1170}{
\index{EFA.h@{EFA.h}!EFA\_\-enable@{EFA\_\-enable}}
\index{EFA\_\-enable@{EFA\_\-enable}!EFA.h@{EFA.h}}
\subsubsection[{EFA\_\-enable}]{\setlength{\rightskip}{0pt plus 5cm}int EFA\_\-enable ({\bf EFA} $\ast$ {\em efa}, \/  int {\em enable})}}
\label{EFA_8h_c09bab3943a494aa7073a0acb95e1170}


Enables/disables EFA. This can only be done outside the context of a run, i.e. the state must be STOPPED. 

\begin{Desc}
\item[Returns:]0, if successful 

-1, on failure.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em efa}]The Event Filter Analysis control handle \item[{\em enable}]If non-zero, enable, if zero, disable \end{description}
\end{Desc}


References EFA\_\-STATE\_\-K\_\-DISABLED, EFA\_\-STATE\_\-K\_\-STOPPED, and \_\-EFA::state.\hypertarget{EFA_8h_1a290c646b7063a2397e5f4b7587d587}{
\index{EFA.h@{EFA.h}!EFA\_\-flush@{EFA\_\-flush}}
\index{EFA\_\-flush@{EFA\_\-flush}!EFA.h@{EFA.h}}
\subsubsection[{EFA\_\-flush}]{\setlength{\rightskip}{0pt plus 5cm}int EFA\_\-flush ({\bf EFA} $\ast$ {\em efa}, \/  int {\em reason})}}
\label{EFA_8h_1a290c646b7063a2397e5f4b7587d587}


Forces a posting of the current results. 

\begin{Desc}
\item[Returns:]Status\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em efa}]The event filter analysis control structure \item[{\em reason}]The reason flush is being called.\end{description}
\end{Desc}
\begin{Desc}
\item[]This routine is meant to flush any remaining result vectors, such as at the end of a run. There is no interlocking. If result vectors are still being accumulated, the caller must arrange such an interlocking mechanism. \end{Desc}


References efa\_\-compose\_\-end\_\-hdr(), efa\_\-flush(), EFA\_\-FLUSH\_\-REASON\_\-K\_\-RECORD\_\-PROCESS, efa\_\-get\_\-new\_\-packet(), EFA\_\-STATE\_\-K\_\-PAUSED, EFA\_\-STATE\_\-K\_\-STOPPED, PAUSED, \_\-EFA::state, and STOPPED.

Referenced by EFA\_\-notify(), EFA\_\-postprocess(), and efc\_\-flush().\hypertarget{EFA_8h_94f70093b0539d811949695b5fa41932}{
\index{EFA.h@{EFA.h}!EFA\_\-hdrCompose@{EFA\_\-hdrCompose}}
\index{EFA\_\-hdrCompose@{EFA\_\-hdrCompose}!EFA.h@{EFA.h}}
\subsubsection[{EFA\_\-hdrCompose}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int EFA\_\-hdrCompose ({\bf EFA\_\-hdr} $\ast$ {\em hdr}, \/  unsigned int {\em relative}, \/  unsigned long long {\em seq}, \/  unsigned int {\em gemClock}, \/  unsigned int {\em gemStrobe})}}
\label{EFA_8h_94f70093b0539d811949695b5fa41932}


Composes specified event header. 

\begin{Desc}
\item[Returns:]The timetone's status flag word\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hdr}]Pointer to the target EFA\_\-hdr \item[{\em relative}]The relative (to the beginning of the buffer) event number (1 = first event) \item[{\em seq}]Extended seqence number of the event \item[{\em gemClock}]Event clock register read from GEM contributor of event \item[{\em gemStrobe}]Event PPS cock register read from GEM contributor of event\end{description}
\end{Desc}
This is convenience routine to fill in event info that is stored in a EFA\_\-hdr structure within an LSF packet for eventual output as science data on the SSR. 

References \_\-EFA\_\-hdrTimetones::cur, EFA\_\-\_\-hdrSeqSet(), EFC\_\-\_\-timetonesGet(), \_\-EFA\_\-hdrTimetone::flags, \_\-EFA\_\-hdr::gemClock, \_\-EFA\_\-hdrTimetone::gemStrobe, \_\-EFA\_\-hdrTimetones::prv, \_\-EFA\_\-hdr::relative, \_\-EFA\_\-hdrTimetone::secs, \_\-EFA\_\-hdr::seq, and \_\-EFA\_\-hdr::timetones.

Referenced by EFA\_\-\_\-preprocess(), and efa\_\-compose\_\-end\_\-hdr().\hypertarget{EFA_8h_f237fbf2bf0d3e7ff953abad19ae3ff1}{
\index{EFA.h@{EFA.h}!EFA\_\-notify@{EFA\_\-notify}}
\index{EFA\_\-notify@{EFA\_\-notify}!EFA.h@{EFA.h}}
\subsubsection[{EFA\_\-notify}]{\setlength{\rightskip}{0pt plus 5cm}int EFA\_\-notify ({\bf EFA} $\ast$ {\em efa}, \/  int {\em mode}, \/  const EDS\_\-cfgInfo $\ast$ {\em cfg})}}
\label{EFA_8h_f237fbf2bf0d3e7ff953abad19ae3ff1}


Callback signature to notify an analyis routine of a mode change. 

\begin{Desc}
\item[Returns:]0 is successful, non-zero otherwise\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em efa}]The Event Filter Analysis control handle \item[{\em mode}]The new running mode. \item[{\em cfg}]The new configuration information \end{description}
\end{Desc}


References \_\-EFA\_\-span::cfg\_\-id, \_\-EFA\_\-span::cfg\_\-key, EFA\_\-flush(), \_\-EFA::flushLeft, \_\-EFA::flushLimit, \_\-EFA\_\-span::mode, \_\-EFA::postLeft, \_\-EFA::postLimit, and \_\-EFA::span.

Referenced by EFC\_\-modeSelect().\hypertarget{EFA_8h_3f6410e262cb2aeed991161510f7d7a4}{
\index{EFA.h@{EFA.h}!EFA\_\-resultSizeof@{EFA\_\-resultSizeof}}
\index{EFA\_\-resultSizeof@{EFA\_\-resultSizeof}!EFA.h@{EFA.h}}
\subsubsection[{EFA\_\-resultSizeof}]{\setlength{\rightskip}{0pt plus 5cm}int EFA\_\-resultSizeof (const {\bf EFA} $\ast$ {\em efa})}}
\label{EFA_8h_3f6410e262cb2aeed991161510f7d7a4}


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 efa}]The Event Filter Analysis Control Block \end{description}
\end{Desc}


References \_\-EFA::size.

Referenced by efc\_\-result\_\-sizeof().\hypertarget{EFA_8h_1cf05169bff197f8e0647359702760cd}{
\index{EFA.h@{EFA.h}!EFA\_\-sizeof@{EFA\_\-sizeof}}
\index{EFA\_\-sizeof@{EFA\_\-sizeof}!EFA.h@{EFA.h}}
\subsubsection[{EFA\_\-sizeof}]{\setlength{\rightskip}{0pt plus 5cm}int EFA\_\-sizeof (int {\em result\_\-size}, \/  int {\em result\_\-cnt})}}
\label{EFA_8h_1cf05169bff197f8e0647359702760cd}


Computes the size, in bytes, of the EFA control structure. 

\begin{Desc}
\item[Returns:]The size, in bytes,\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em result\_\-size}]The size, in bytes, of one result vector \item[{\em result\_\-cnt}]The number of result vectors in one packet \end{description}
\end{Desc}


References efa\_\-apb\_\-sizeof().

Referenced by EFC\_\-stdSizeof().\hypertarget{EFA_8h_3ef15aea0484c48528e64adfddf81de5}{
\index{EFA.h@{EFA.h}!EFA\_\-start@{EFA\_\-start}}
\index{EFA\_\-start@{EFA\_\-start}!EFA.h@{EFA.h}}
\subsubsection[{EFA\_\-start}]{\setlength{\rightskip}{0pt plus 5cm}int EFA\_\-start ({\bf EFA} $\ast$ {\em efa}, \/  int {\em reason}, \/  int {\em run\_\-id}, \/  int {\em startTime}, \/  int {\em mode})}}
\label{EFA_8h_3ef15aea0484c48528e64adfddf81de5}


Callback signature to start or prepare a posting stream to receive events. 

\begin{Desc}
\item[Returns:]0 is successful, non-zero otherwise\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em efa}]The Event Filter Analysis control handle \item[{\em reason}]The LSF\_\-REASON\_\-OPEN to indicate why the stream is being started \item[{\em run\_\-id}]Suggested use is to identify the block of events between when EDS\_\-fwHandlerStart is called and EDS\_\-fwHandlerFlush is called with a stop reason \item[{\em startTime}]The run start time rounded to the nearest second \item[{\em mode}]This must be the running mode. \end{description}
\end{Desc}


References \_\-EFA::beg\_\-evt\_\-fill, \_\-EFA::ctx, EFA\_\-STATE\_\-K\_\-DISABLED, EFA\_\-STATE\_\-K\_\-STARTED, EFA\_\-STATE\_\-K\_\-STOPPED, \_\-EFA::flushLeft, \_\-EFA::flushLimit, \_\-EFA::postLeft, \_\-EFA::postLimit, \_\-EFA::services, \_\-EFA\_\-services::start, and \_\-EFA::state.

Referenced by EFC\_\-start().