% 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{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}{data reduction}
\renewcommand{\bvtitle}{\LARGE ProtoDUNE/SP Data Reduction\\Software \& Computing Aspects}
\renewcommand{\bvevent}{Reco\\2017 Feb 22}
\renewcommand{\bvbeamerbackground}{}

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


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

\begin{frame}
  \frametitle{Review of Data Reduction}
  Main idea:

  \begin{enumerate}
  \item Run the required, initial data processing steps:
    \begin{itemize}\footnotesize
    \item[1] ADC mitigation (stuck-codes, non-linearity)
    \item[2] Excess noise filtering (if any, fingers crossed)
    \item[3] Signal processing \\
      (detector response deconvolution and ROI selection)
    \end{itemize}
  \item Remove unnecessary (at this point) oversampling.
  \item Pack and compress data and save to file.
  \end{enumerate}

  $\to$ Then, use reduced files as input the remaining data processing.

  \vfill

  \scriptsize
  Reference:
  \begin{itemize}
  \item  \href{https://indico.fnal.gov/getFile.py/access?contribId=1&resId=0&materialId=slides&confId=13783}{Xin's talk last meeting} 
  \item \href{http://docs.dunescience.org/cgi-bin/ShowDocument?docid=2089}{DocDB 2089 proposal details}
  \end{itemize}

\end{frame}


\begin{frame}
  \frametitle{Performance Conclusions}

  \begin{itemize}
  \item pD/SP can achieve design $4\times$ compression even with MB-like\footnote{  \href{http://docs.dunescience.org/cgi-bin/ShowDocument?docid=2089}{DocDB 2089}:  estimates made using actual reduction algorithms on a  few MicroBooNE events and scaling by number of channels.} excess noise and $6-8\times$ with expected noise levels.
  \item $150\times$ reduction achieved with just signal-ROI selection.
  \item $400\times$ reduction by further reclaiming over-sampling
    \begin{itemize}\footnotesize
    \item using safe rebin-3, can explore more aggressive rebin-4, ...
    \end{itemize}
  \item Relies on saving reduced output data with:
    \begin{itemize}\footnotesize
    \item 32 bit in-memory samples re-digitized to 16 bit \\
      (can optimize with ``dynamic dynamic-range'')
    \item ROOT compression (negligible CPU even at ``level 9'')
    \end{itemize}
  \item Time dominated by signal processing step (required anyways)
    $\to$ 45 seconds / APA / trigger
  \end{itemize}

  \begin{center}
    2.5 PB $\to$ 6.5 \textbf{TB} \hspace{1cm} {\footnotesize (TPC only)}
  \end{center}

\end{frame}


\begin{frame}
  \frametitle{Validation with Simulation}


  \begin{itemize}
  \item Confirm:
    \begin{itemize}\footnotesize
    \item[$\to$]  reduction efficacy, 
    \item[$\to$] CPU performance and
    \item[$\to$] correctness of output.
    \end{itemize}

  \item Use new, realistic simulation:
    \begin{itemize}\footnotesize
    \item Developed as part of the Wire Cell Toolkit.
    \item Proper long-range induction and inter-pitch field variance.
    \item Noise models from MicroBooNE measurements and ``first
      principles'' calculation from Milind that can explore different
      assumptions.
    \end{itemize}

  \item Validate non-effect of reclaiming over-sampling.
    \begin{itemize}\footnotesize
    \item 3-bin sum is safe, 4-bin is on edge.
    \item Already demonstrated with toy Gaussian - try it yourself!
    \item O.w. win Nobel for disproving Nyquist!
    \end{itemize}
  \end{itemize}
  
\end{frame}

\begin{frame}
  \frametitle{Software Parts Needed for Reduction Process}
  \begin{itemize}
  \item Raw``Data Access Library'' (DAL)
    \begin{itemize}\footnotesize
    \item Provided by DAQ ``fragment experts'', used by many.
    \item Fragment \textbf{unpackers} needed for reduction process (among others).
    \item Fragment \textbf{packers} also needed for simulation.
    \end{itemize}
  \item  ``Keep up'' data reduction processing system
    \begin{itemize}\footnotesize
    \item Needs job management system (p3s could work).
    \item Monitoring of jobs needs integration into shift operations.
    \end{itemize}
  \item Actual implementation
    \begin{itemize}\footnotesize
    \item Needed modules: ADC mit., noise filt., sig. proc. and reduced DAL.
    \item Most parts already exist in MB, 35t and Wire Cell.
    \item Won't know real excess noise types/levels until turn-on.
    \item Code needed in reduction process \textbf{and}
      general offline jobs.
    \item Noise filt. and sig. proc. is in Wire Cell Toolkit,
      integration into art/LArSoft is in progress.
    \end{itemize}
  \end{itemize}
\end{frame}


\begin{frame}
  \frametitle{ProtoDUNE Keep Up Processing}
  What does it take to keep up with the protoDUNE data?
  \begin{itemize}
  \item Cycle avg: 10 Hz $\times$ 6 APA $\times$ 45s/APA = 2700 cores
    \begin{itemize}\footnotesize
    \item 6750 cores to keep up during spill (25 Hz)
    \end{itemize}
  \item 20 cores / node $\Rightarrow$ need 135 nodes
    \begin{itemize}\footnotesize
    \item Depending on LArSoft RAM, may need as much as 64GB/node!
    \end{itemize}
  \item Computing environment needs:
    \begin{itemize}\footnotesize
    \item[$\to$] dedicated CPU, but only during actual running.
    \item[$\to$] new jobs triggered by new data.
    \item[$\to$] quick, high b/w access to raw data (EOS is a good source).
    \end{itemize}
  \end{itemize}

  Nominal request: 
  \begin{center}
    \textbf{$\sim$200 nodes of $\sim$20 cores and $\sim$48 GB each}    
  \end{center}
  Can we find this?

  \vfill

  \footnotesize
  N.B: full reco takes $\sim 6\times$ more CPU-time.  Any delay we
  accept for reduction, we accept $6\times$ more delay for final
  result!

\end{frame}

\begin{frame}
  \frametitle{Status and To Do}
  \begin{itemize}
  \item Initial improved detector response simulation in WCT. Next:
    \begin{itemize}\footnotesize
    \item implement correct drift physics statistics
    \item implement noise models
    \item file interface and LArSoft integration
    \end{itemize}
  \item Integrate noise filter and signal processing.  Next:
    \begin{itemize}\footnotesize
    \item Port signal processing from Wire Cell prototype to toolkit
    \item Integrate sig.proc. into LArSoft.
    \item Move both noise filt. and sig. proc. to use Art ``tools''
    \end{itemize}
  \item DALs
    \begin{itemize}\footnotesize
    \item Work with DAQ group on Raw DAL
    \item Develop ``reduced'' DAL
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Possible Opportunities}
  A keep up reduction process opens some possible opportunities:

  \begin{itemize}
  \item Does $400\times$ reduction in TPC data make PDS data 
    dominate data volume?
    \begin{itemize}\footnotesize
    \item Do we need/want to reduce PDS data?
    \end{itemize}
  \item Are there other low-CPU, high-I/O algorithms which are
    convenient to run in coincidence with data reduction?
    \begin{itemize}\footnotesize
    \item Maybe build data indices?
    \item Maybe repack/reformat for faster read-in later?
    \end{itemize}
  \item Merge the out-of-band Beam Information?
    \begin{itemize}\footnotesize
    \item There is a Beam Info data stream latency to worry about.\\
      (I've heard 20-40 minutes)
    \item Will merging/syncing in this job be over-complicated?
    \item Maybe wait and merge BI using data-reduced output?\\
      At 6.5 TB (for TPC only) we can afford a duplicate copy!
    \end{itemize}
  \end{itemize}
\end{frame}

\end{document}

