% TEXINPUTS=.:$HOME/git/bvtex: latexmk  -pdf <main>.tex
\documentclass[xcolor=dvipsnames]{beamer}

\input{defaults}
\input{beamer/preamble}

\setbeamertemplate{navigation symbols}{}
% \setbeamertemplate{background}[grid][step=1cm]

\usepackage{siunitx}
\usepackage{xmpmulti}
\usepackage[export]{adjustbox}
\usepackage{ulem}
\usepackage[outline]{contour}
\usepackage{pdfpages}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{positioning}

\definecolor{bvtitlecolor}{rgb}{0.98, 0.92, 0.84}
\definecolor{bvoutline}{rgb}{0.1, 0.1, 0.1}

\renewcommand{\bvtitleauthor}{Brett Viren}
\renewcommand{\bvtit}{title}
\renewcommand{\bvtitle}{\LARGE TITLE}
\renewcommand{\bvevent}{{\small EVENT -- DATE}}
\renewcommand{\bvdate}{DD Mmm YYYY}
\renewcommand{\bvbeamerbackground}{}

\def\Put(#1,#2)#3{\leavevmode\makebox(0,0){\put(#1,#2){#3}}}

\begin{document}
\input{beamer/title.tex}
\input{beamer/toc.tex}

\section{Trigger Subsystem}


\begin{frame}
  \tableofcontents[currentsection,hideothersubsections]
\end{frame}

\begin{frame}
  \frametitle{Trigger Subsystem Architecture}
  \begin{columns}
    \begin{column}{0.3\textwidth}
      Trigger hierarchy
      \begin{itemize}      \scriptsize 
      \item[1] per channel \textbf{primitive}
      \item[2] cross channel \textbf{candidate}
      \item[3] full module \textbf{command}
      \item EB executes \textbf{commands}
      \item MTL exchange \textbf{candidates} via ETL
      \end{itemize}
      
    \end{column}
    \begin{column}{0.7\textwidth}
      \includegraphics[width=\textwidth]{trig.pdf}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}
  \frametitle{Hardware for Trigger Subsystem}
  
  I don't yet see any major road block here but more work is needed.

  \begin{itemize}
  \item Need to understand what we want to do with primitives beyond
    triggering (eg, Ar39).
  \item Can we run trigger candidate production on FEC?
    \begin{itemize}
    \item[$\to$] We know from SNB MC studies, candidate production is fast.
    \item[$\to$] Novel algorithms may be more costly.
    \item[$\to$] Data rates for trigger primitives may be high.
    \end{itemize}
  \item I guess we need somewhere between 0 and a dozen trigger
    candidate processor computers for SP.
  \item One dedicated MTL host PC per module. 
  \item One dedicated ETL host PC per DUNE FD.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Trigger Subsystem and DAQ Partitioning}

  What is the proper top-level hierarchy pattern given partitioning? 

  \begin{itemize}\footnotesize
  \item In general: $\mathcal{N}_i$ MTLs per detector module $i$.
  \item What inter-- and intra--module trigger candidate exchanges are needed?
  \item How and what external trigger candidates are given?
  \end{itemize}

  \begin{columns}
    \begin{column}{0.5\textwidth}
      \includegraphics[width=\textwidth]{etlpart_oneetl_orphans.pdf}
    \end{column}

    \begin{column}{0.5\textwidth}
      \includegraphics[width=\textwidth]{etlpart_manyetl.pdf}
    \end{column}
  \end{columns}


  \begin{columns}
    \begin{column}[t]{0.5\textwidth}
      Singleton ETL with orphans.
      \begin{itemize} \scriptsize 
      \item Never more than one ETL.
      \item Any ``extra'' MTLs are isolated.
        \begin{itemize}\tiny
        \item[o] What uses does this pattern rule out?
        \item[o] How to deal with external triggers?
        \end{itemize}
      \end{itemize}

    \end{column}

    \begin{column}[t]{0.52\textwidth}
      Completed hierarchy.
      \begin{itemize}\scriptsize 
      \item Every MTL must have an ETL, even if lone.
      \item Another layer needed to connect ETLs?
        \begin{itemize}\tiny
        \item[o] Maybe this is just Run Control?
        \item[o] Are there uses for ETL$\to$ETL comms?
        \end{itemize}
      \end{itemize}
    \end{column}
  \end{columns}

\end{frame}

\section{Egress Subsystem}


\begin{frame}
  \tableofcontents[currentsection,hideothersubsections]
\end{frame}

\begin{frame}
  \frametitle{Data Egress}

  \vspace{-10mm}

  \begin{columns}
    \begin{column}{0.5\textwidth}
      \scriptsize      
      \begin{itemize}
      \item Diagram limited to 2 DAQ fragments (FEC$_i$ and FEC$_j$) for simplicity.
      \item Shows concurrent event building driven by two consecutive
        \textbf{trigger commands}.
      \item Per-trigger files produced asynchronously and out-of-order.
        \begin{itemize}\tiny
        \item[o] file size w/comp: SP: 1.5 GB, DP: 0.3 GB
        \end{itemize}
      \end{itemize}

    \end{column}
    \begin{column}{0.5\textwidth}
      \includegraphics[width=\textwidth]{eb-datsel.pdf}
    \end{column}
  \end{columns}


  Event Builder - Data Selector interaction.
  \begin{enumerate}\footnotesize
  \item Egress subsys accepts ordered \textbf{trigger commands} specifying
    a \textbf{time range} and a \textbf{collection of target DAQ
      fragements} (list of FEC addresses)
  \item \textbf{Event Builder} spawned for each \textbf{trigger command}.
  \item EB queries \textbf{Data Selector} of each referenced FEC for time range.
  \item DS looks up time range its \textbf{primary buffer}, returns data or error.
  \item EB aggregates all returns and writes to file.
  \end{enumerate}
\end{frame}

\section{Run Control}

\begin{frame}
  \tableofcontents[currentsection,hideothersubsections]
\end{frame}


\begin{frame}
  \frametitle{DAQ as a Graph with Partitions}
  \begin{center}
      \includegraphics[width=\textwidth]{messier.pdf}

      \scriptsize
      2 detector modules, 4 DAQ partitions: 2 isolated and 2 sharing triggers, eg:
      nominal full FD data taking minus some calibration in each
      module.

  \end{center}
  
  A partition can be considered centered on or \textbf{defined by
    its MTL} which sits at the top of the trigger/readout hierarchy.  \\

  {\footnotesize (Should rename it PTL: ``Partition Trigger Logic unit''?)}


\end{frame}

\begin{frame}
  \frametitle{Run Control Architecture}
  \begin{center}
    RC must compose the DAQ graph.
  \end{center}
  \begin{columns}
    \begin{column}{0.5\textwidth}
      \footnotesize

      \begin{itemize}
      \item Organization strategy: Hierarchical vs Participatory.\\
        {\scriptsize Or better: ``Static vs Dynamic''?}\\
        {\tiny (graph is directed so some hierarchy is intrinsic)}
      \item How to define a DAQ graph, configure the nodes to hook up
        their edges?
      \item How to evolve the graph in order to leave portions of it
        untouched and their partitions running?
      \end{itemize}
    \end{column}
    \begin{column}{0.5\textwidth}
    \includegraphics[width=\textwidth]{20180126_DUNE_run_control_slide3.pdf}        

    {\scriptsize Giovannas slide from \href{https://indico.fnal.gov/event/15969/}{Oxford WS}}
    \end{column}
  \end{columns}

  \begin{center}
    Still much more to think about here.
  \end{center}

%  https://indico.fnal.gov/event/15969/contribution/29/material/slides/

\end{frame}


\begin{frame}
  \frametitle{Summary}
  \begin{itemize}

  \item Much of the front-end and all of the backend design is
    independent of these variants.
  \item We are just now turning our eyes to the back end especially
    how to ``partition'' the DAQ via run control.
    
  \end{itemize}
\end{frame}

\begin{frame}
  \begin{center}
    \Large $\mathcal{FIN}$
  \end{center}
\end{frame}

\begin{frame}
  \frametitle{Some DAQ Partitioning Ideas}
  \scriptsize
  \begin{itemize}
  \item Edges have fixed constraints (TP connects to TC, EB to DS, some don't cross module boundaries).
  \item Given a set of nodes and fixed constraints the graph may be constructed automatically.
  \item To define a partition is thus to define its set of nodes.
  \item Nodes can publish attributes (``I'm alive'', ``I'm a Data Selector'', ``I'm in module 1'', ``My DAQ Frag ID is XXX'')
  \item Construct set of nodes based on desired set of attributes.  
  \item If nodes already in a existing fragments, fail new fragments or shutdown old ones.
  \item Build new fragment.
  \end{itemize}
  Fragments could have overlap
  \begin{itemize}
  \item Nominally, one ``main'' fragment in each module must share the same ETL.
  \item Fragments in the same module may share an output disk.
  \item Egress subsystem could be shared since a unique EB instance is spawned to handle each trigger command.
  \item Different MTLs could share the same TC stream.
  \item Different partitions could target the same DSes - although
    this would violate guarantee of non-overlapping data requests
    which will complicate SNB dump (but maybe okay for normal data
    selection).
  \item TC processors could share same TP streams.
  \end{itemize}
\end{frame}



\end{document}


%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
