% Created 2023-11-17 Fri 10:07
% Intended LaTeX compiler: pdflatex
\documentclass[colorlinks,aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{color}
\usepackage{listings}
\usepackage{pdfpages}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{xspace}
\usepackage{libertine}
\usepackage{fontawesome}
\mode<beamer>{\usetheme{Boadilla}}
\setbeamertemplate{navigation symbols}{}
\setbeamerfont{alerted text}{series=\bfseries}
\setbeamercolor{alerted text}{fg=blue}
\usecolortheme{default}
\usefonttheme{serif}
\usefonttheme{professionalfonts}
\lstloadlanguages{[ISO]C++}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.50,0,0.82}
\definecolor{codeorange}{rgb}{0.95,0.3,0.1}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
commentstyle=\color{codegreen},
keywordstyle=\color{codeorange},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
\usepackage{multirow}
\usepackage{siunitx}
\usetheme{default}
\author{Brett Viren, Lino Gerlach, Wenqiang Gu, Nitish Nayak, Xin Qian}
\date{\today}
\title{Offline Resampling of VD ADC Waveforms}
\hypersetup{
 pdfauthor={Brett Viren, Lino Gerlach, Wenqiang Gu, Nitish Nayak, Xin Qian},
 pdftitle={Offline Resampling of VD ADC Waveforms},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 28.2 (Org mode 9.4.6)}, 
 pdflang={English}}
\begin{document}

\maketitle

\begin{frame}[label={sec:orgb15cc8a}]{}
These slides are updated to reflect discussion.  Updates are in \textcolor{red}{red}.
\end{frame}

\begin{frame}[label={sec:org2a4394c}]{Sampling as described in the VD TDR}
\begin{block}{Top Detector Electronics (TDE)}
\begin{quote}
\ldots{}sampling can be performed either at \alert{2.5 MSPS} or at \alert{2.0 MSPS}\ldots{}

\ldots{}when operating in the \alert{2.5 MSPS} sampling mode, data are acquired
at a sampling rate a factor of \alert{eight higher, then down-sampled} in the FPGA to
\alert{2.5 MHz}\ldots{}

\ldots{}configuration planned for \alert{FD2-VD} operation is simpler; it is based on a \alert{2.0
MSPS} final sampling rate, 12 bit dynamics\ldots{}

\ldots{}WRclock (\alert{125 MHz})\ldots{}
\end{quote}
\end{block}


\begin{block}{Bottom Detector Electronics (BDE)}
\begin{quote}
\ldots{}DUNE will use a \alert{62.5 MHz} master clock, so the digitization frequency will be
\alert{1.953 MHz} (1 / \alert{512 ns}).  For \alert{convenience}, the digitization clock is referred to
as 2 MHz and the master clock as 64 MHz\ldots{}.
\end{quote}
\end{block}

\begin{block}{}
\tiny
Editorial:
rounding of sampling numbers is not at all convenient to this human!
\end{block}
\end{frame}

\begin{frame}[label={sec:org5bd3307}]{What are the actual, exact samplings?}
Assumption: ADC sampling must be a multiple of the base clock. (Right?)


\textcolor{red}{In discussion: TDE is \textbf{exact} 2.0 MSPS and the clock multiplier argument does not apply.}

\begin{center}
\begin{tabular}{|r|r|r|c|r|l|c|}

\hline
det  & \multicolumn{2}{c|}{clock } & mult       & \multicolumn{2}{c|}{ADC} & TDR \\
half & (MHz)                & (ns) & ($\times$) & (ns) & (MHz) & quote \\
\hline
\multirow{4}{*}{TDE}  & \multirow{4}{*}{125}  & \multirow{4}{*}{8}  & 50 & 400 & 2.5 & \multirow{4}{*}{"2.0 MSPS"} \\
                                                            &   &   & 62 & 496 & 2.016129 & \\
                                                            &   &   & 63 & 504 & 1.984127 & \\
                                                            &   &   & 64 & 512 & 1.953125 & \\
\hline
\multirow{3}{*}{BDE}  & \multirow{3}{*}{62.5}  & \multirow{3}{*}{16}  & 25 & 400 & 2.5 & \multirow{3}{*}{"1.953 MHz"}\\
                                                          &      &    & 31 & 496 & 2.016129 &\\
                                                          &      &    & 32 & 512 & 1.953125 & \\
\hline
\end{tabular}
\end{center}
\end{frame}


\begin{frame}[label={sec:org29064c9}]{Questions for detector electronics experts}
\vspace{-1cm}


\tiny (who \sout{are likely not} \textcolor{red}{were} at this meeting)


\normalsize

\vfill

\begin{description}
\item[{TDE}] Which exact sampling would be chosen as ``2 MSPS''?
\begin{itemize}
\item \textcolor{red}{It is exactly 2.0 MSPS.}
\end{itemize}
\item[{BDE}] Why choose ``1/\qty{512}{ns}'' as ``2 MHz'' when ``1/\qty{496}{ns}'' is closer?
\begin{itemize}
\item \textcolor{red}{Easier to divide by 32 than 31.}
\end{itemize}
\item[{both}] Why both TDE and BDE can not use common and ``more round'' 2.5 MHz?
\begin{itemize}
\item \textcolor{red}{"2 MHz" defined by the formal DUNE requirement statements.}
\end{itemize}
\end{description}

\textcolor{red}{(Answers given in discussion.)}
\end{frame}

\begin{frame}[label={sec:orgb1ce5fa},fragile]{Problems if TDE and BDE use different sampling}
 \begin{itemize}
\item Either \alert{same readout time} (\(\approx \qty{4}{ms}\)) \texttt{XOR} \alert{same \#samples} (\(N \approx\) 8k), \alert{can not have both}.
\item Sloppy \alert{stitching} of 3D reco objects across top/bottom boundary.
\item Need separate T/B \alert{field response calculations} despite same CRP design.
\item Complexity of two \texttt{tick} values floating around the configuration.
\end{itemize}
\end{frame}


\begin{frame}[label={sec:orgcabe9c3}]{What can offline do help this situation?}
Just as we may do online, so may we \alert{resample} ADC waveforms in the offline.

\vfill

But, we must be mindful of:
\begin{itemize}
\item Signal processing theory,
\item Computational costs,
\item Introducing more human confusion.
\end{itemize}

\vfill

Nevertheless, let us consider resampling VD \textcolor{red}{BDE} ADC waveforms to \alert{exactly} our old friend:
\[T=\qty{500}{ns},\ F =\qty{2}{MHz}\]
\end{frame}



\begin{frame}[label={sec:orgcf68821}]{Signal resampling \(R \equiv \frac{F'}{F} = \frac{T}{T'} = \frac{N'}{N}\)}
Keep total signal duration (\(NT\)) fixed.

\begin{description}
\item[{upsampling}] \(R>1\) \alert{increases} Nyquist frequency
\begin{itemize}
\item Nyquist/Shannon, ``no worries, this is a lossless transform''.
\item Beware of interpolation \alert{artifacts}.
\end{itemize}

\item[{downsampling}] \(R<1\) \alert{decrease} Nyquist frequency
\begin{itemize}
\item Nyquist/Shannon, ``if signal bandwidth \(> F'_{nyquist}\) then'':
\begin{itemize}
\item You will cause \alert{aliasing} unless a \alert{low-pass filter} is applied.
\item You will lose info regardless.
\end{itemize}
\end{itemize}
\end{description}

Given a choice, prefer \alert{lossless upsampling} so please make ``2 MSPS'' to mean:
\begin{description}
\item[TDE] \sout{1.984127 MHz} (\sout{504 ns}) \textcolor{red}{exactly \qty{2.0}{MHz} (500 ns)},
\item[BDE] \qty{1.953125}{MHZ} (\qty{512}{ns}).
\end{description}
\end{frame}

\begin{frame}[label={sec:orgf7db96d}]{Implementation issues}
Want to \alert{minimize offline exposure} to ``non-\qty{2}{MHz}'' waveforms.
\begin{itemize}
\item Wire-Cell \alert{Noise Filter} is first to ``touch'' decoded ADC so \alert{best home for resampling}.
\item NF must already perform FFTs and so may use \alert{frequency-space} resampling.
\begin{itemize}
\item Generally more spectrally-correct than \alert{interval-space} resampling ``for free''.
\item (There are many details to this topic that I skip here).
\end{itemize}
\item Wire-Cell TPC drift/detector simulation, signal processing and all downstream would continue to run at \qty{2}{MHz}.
\end{itemize}
\end{frame}


\begin{frame}[label={sec:org0c5bb48}]{Proposal}
\begin{itemize}
\item DUNE VD \textcolor{red}{BDE} electronics will target \(F \lesssim \qty{2}{MHz}\) sampling by the ADCs.
\item DUNE \alert{offline will resample VD signals to exactly} \(T=\qty{500}{ns},\ F =\qty{2}{MHz}\).
\begin{itemize}
\item Resampling will be performed early and inside WCT Noise Filter.
\end{itemize}
\end{itemize}
\end{frame}

\begin{frame}[label={sec:org797f953}]{Path to acceptance and implementation}
\begin{itemize}
\item Seek broad input from DUNE collaboration.
\begin{itemize}
\item Especially from VD electronics and offline experts.
\end{itemize}
\item Develop the specific method.
\begin{itemize}
\item An optimized software conceptual design has being developed but too many details for today.
\item Flesh out into technical note.
\item Measure computational costs of the ``bare'' method.
\end{itemize}
\item Integrate into WCT Noise Filter.
\begin{itemize}
\item Observe no measurable computational cost increase.
\item Demonstrate and validate the method on coldbox data and sim.
\end{itemize}
\item Put into production.
\end{itemize}
\end{frame}
\end{document}