% Created 2024-01-02 Tue 09:08
% 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{siunitx}
\usetheme{default}
\author{Brett Viren}
\date{\today}
\title{Splat: True Signal Waveforms}
\subtitle{\texttt{DepoFluxSplat} vs \texttt{DepoTransform + OmnibusSigProc}}
\hypersetup{
 pdfauthor={Brett Viren},
 pdftitle={Splat: True Signal Waveforms},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 28.2 (Org mode 9.4.6)}, 
 pdflang={English}}
\begin{document}

\maketitle

\begin{frame}[label={sec:orgbaa8839}]{Topics}
\begin{itemize}
\item Introduce \alert{splat algorithm} as a ``true'' approximation to ``sim+SP''.
\item Estimate \alert{excess smearing} in ``sim+SP'' using fits to ``morse'' track pattern.
\item Compare \alert{splat and sim+SP} w/out and w/ excess smearing using a ``diagonal'' track.
\end{itemize}
\end{frame}

\begin{frame}[label={sec:orgd840b33},fragile]{Splat}
 \begin{block}{A \alert{splat} is a kind of \alert{true signal frame}.}
\begin{itemize}
\item It closely resembles the \alert{reco signal frame} from SP.
\item Produced simply and directly from depos.
\item Lacks noise, field and electronics response and ADC truncation.
\item No convolution / filter / deconvolution round trip.
\item Allows arbitrary additional Gaussian smearing and time offsets (becoming \(<100\) \%  ``true'').
\end{itemize}
\end{block}

\begin{block}{Mechanically, one can replace the usual subgraph:}
\begin{center}
\texttt{[DepoTransform]} \(\to\) (\texttt{[NoiseFilter]} \(\to\)) \texttt{[OmnibusSigProc]}
\end{center}
\end{block}

\begin{block}{with a singular splat node:}
\begin{center}
\texttt{[DepoFluxSplat]}
\end{center}
\end{block}
\end{frame}



\begin{frame}[label={sec:org4edc032},fragile]{Splat construction}
 Start with the depos drifted to the \alert{response plane} as normal.

\begin{itemize}
\item Drift them on a little further to the \alert{collection plane}.

\item Apply \alert{optional, extra per-plane, per-dimension smearing} to each depo.
\begin{itemize}
\item \(\sigma_{long,tran}^{U,V,W}\) added in quadrature to native depo Gaussian extent.
\end{itemize}

\item Construct \alert{patch of charge} for each depo and each plane
\begin{itemize}
\item Patch aligns to wire plane pitch vs tick grid.
\item Use \texttt{GaussianDiffusion} to do heavy lifting just like full sim.
\end{itemize}

\item Project patch onto each wire's \alert{channel} to make a \alert{trace}.

\item Apply \alert{optional, arbitrary time offsets} to the frame and traces.
\end{itemize}
\end{frame}

\begin{frame}[label={sec:orgf53aaa3}]{Splat smearing}
\begin{block}{Sources of smearing}
\begin{description}
\item[{SP}] \small \alert{depo diffusion}, SP low-pass filter, mismatch between sim/SP FRs, ADC truncation, \ldots{}

\item[{splat}] \small \alert{depo diffusion}, configured \alert{extra} smearing
\end{description}
\end{block}

\begin{block}{When to add extra smearing to make SP ``match'' splat?}
\begin{itemize}
\item Signal efficiency/bias metrics need matching ``numerator'' and ``denominator''.
\item Train DNNROI on ``true ROIs'' that closely resemble what SP would/should produce.
\end{itemize}
\end{block}

\begin{block}{When to not add extra smearing?}
\begin{itemize}
\item Train new DNN to remove SP's additional smearing, make more realistic signals.
\end{itemize}
\end{block}
\end{frame}

\begin{frame}[label={sec:org7399ae0}]{How to match splat and SP signal shapes}
Find values for the smear parameters: \(\sigma_{long,tran}^{U,V,W}\).

\begin{block}{Method: calculation / exclusive}
Assume main source of extra smearing is SP low-pass time and wire filters.
\begin{itemize}
\item Fit filters to Gaussians, use the fit sigmas as smear parameter values.
\item Ignores some sources of smearing (eg sim conv. vs pitch SP decon. binning).
\end{itemize}
\end{block}

\begin{block}{Method: simulate / inclusive}
Place point-depos (no diffusion) at response plane, run sim+SP.
\begin{itemize}
\item Collect output signals, fit to Gaussian, take sigmas.
\item Includes all sources of smearing in sim+SP, no understanding of relative source strengths.
\end{itemize}

Will show an example of this one.
\end{block}
\end{frame}

\begin{frame}[label={sec:orgb9e4136},fragile]{Introduce the ``morse'' depo pattern}
 Legend: P  = 25 pitches, I = 0.1 pitch impact position, ``|'' = wires, ``:'' = depos.

\scriptsize

\begin{verbatim}
0          P+I        2P+2I       3P+3I       4P+4I       5P+5I
|          |          |          |          |          |
|          |          |          |          |          |
:          |:         | :        |  :       |   :      |    :
:          |:         | :        |  :       |   :      |    :
|          |          |          |          |          |
|          |          |          |          |          |
\end{verbatim}


\normalsize
An \alert{array of small tracks} in the response plane ``target'' each wire plane
\begin{itemize}
\item Tracks are \alert{parallel to the wires} of the plane they ``target''.
\item Tracks have \alert{fixed separation} so their FR do not overlap in pitch.
\item Tracks \alert{progressive separation} so each lands on a different FR impact position.
\item Arrays of tracks have \alert{times} so their FR+ER do not overlap in time.
\end{itemize}

\tiny It is named ``morse'' as in ``Morse code''\ldots{}.
\end{frame}


\begin{frame}[label={sec:org69f81be}]{A frame view of ``morse'' pattern.}
\begin{center}
\includegraphics[page=1,height=0.8\textheight]{morse.pdf}
\end{center}
\end{frame}


\begin{frame}[label={sec:orge40a75e},fragile]{Using ``morse'' pattern sim+SP}
 \begin{itemize}
\item Generate depos, run through sim+SP, write out frame.

\item Select \texttt{\{U,V,W\}} patch

\item Form \alert{total waveform} summing patch along channel, find \alert{total peak}.

\item Form \alert{channel waveforms} at tick \alert{total peak}.  Find each \alert{channel peak}.

\item Form \alert{tick waveforms} at each \alert{channel peak}.  Find \alert{tick peak}.

\item Around each \alert{peak} fit a Gaussian model.
\end{itemize}
\end{frame}

\begin{frame}[label={sec:orgbe3dc39}]{}
\includegraphics[width=0.24\textwidth,page=2]{morse.pdf}
\includegraphics[width=0.24\textwidth,page=3]{morse.pdf}
\includegraphics[width=0.24\textwidth,page=4]{morse.pdf}
\includegraphics[width=0.24\textwidth,page=5]{morse.pdf}

\includegraphics[width=0.24\textwidth,page=6]{morse.pdf}
\includegraphics[width=0.24\textwidth,page=7]{morse.pdf}
\includegraphics[width=0.24\textwidth,page=8]{morse.pdf}
\includegraphics[width=0.24\textwidth,page=9]{morse.pdf}

\includegraphics[width=0.24\textwidth,page=10]{morse.pdf}
\includegraphics[width=0.24\textwidth,page=11]{morse.pdf}
\includegraphics[width=0.24\textwidth,page=12]{morse.pdf}
\includegraphics[width=0.24\textwidth,page=13]{morse.pdf}
\end{frame}

\begin{frame}[label={sec:org175037a},fragile]{Summary from ``morse'' analysis}
 The sim+SP apparently adds this amount of additional smearing:

\begin{center}
\begin{center}
\begin{tabular}{lrr}
plane & tick & pitch\\
\hline
U & 2.692 & 0.738\\
V & 2.675 & 0.716\\
Z & 2.714 & 0.140\\
\hline
\end{tabular}
\end{center}
\end{center}

Units are \texttt{[tick]} and \texttt{[pitch]}.

\vfill

To get these numbers as config chunk for \texttt{DepoFluxSplat}:
\scriptsize
\begin{verbatim}
$ wirecell-gen morse-splat -o splat-params.json tmp-morse/peaks.json
\end{verbatim}
\end{frame}

\begin{frame}[label={sec:org8ac1ed7}]{Introduce the ``diagonal'' pattern}
A single, ideal, minimum-ionizing line track running \alert{diagonally} between opposite
corners of one anode plane face's sensitive volume.

\begin{itemize}
\item Run both splat and sim+SP.
\item Check timing, positioning, charge and shape of signals.
\end{itemize}

First look at \alert{unsmeared splat case} then look at \alert{smeared case} using ``morse'' numbers.
\end{frame}

\begin{frame}[label={sec:org9b97fa3}]{Splat and sim+SP overview}
\begin{columns}
\begin{column}{0.7\columnwidth}
\begin{center}
\includegraphics[page=1,height=0.8\textheight]{diag-nominal.pdf}
\end{center}
\end{column}

\begin{column}{0.4\columnwidth}
\scriptsize

\begin{itemize}
\item Top is splat, bottom is sim+SP.
\item channel and tick profiles.
\item Electron absorption reduces charge over time.
\item Good time, position and charge match.
\item Note small splat ``blips'' at \qty{1500}{us}.
\begin{itemize}
\item Wrong wire ID?
\end{itemize}
\end{itemize}
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:org7beaf11}]{Check charge}
\begin{columns}
\begin{column}{0.5\columnwidth}
\begin{center}
\includegraphics[page=2,width=\textwidth]{diag-nominal.pdf}
\end{center}
\end{column}

\begin{column}{0.45\columnwidth}
\scriptsize
\begin{itemize}
\item Depos, splat and sim+SP signals by plane and total.
\item Depo line has artifacts due to beating between steps and tick binnings.
\item The ``U/V splat blip'' at \qty{1500}{us} is seen.
\end{itemize}
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:orgbc4f5ba}]{Unsmeared differences at track ends}
\includegraphics[page=5,width=0.45\textwidth]{diag-nominal.pdf}
\includegraphics[page=6,width=0.45\textwidth]{diag-nominal.pdf}

\begin{itemize}
\item Good position and timing match.

\item Charge is way off.  Splat is more narrow and dense than sim+SP.
\end{itemize}
\end{frame}

\begin{frame}[label={sec:org1a0705e}]{A look at some V-plane channels near track endpoints}
\includegraphics[page=7,width=0.45\textwidth]{diag-nominal.pdf}
\includegraphics[page=8,width=0.45\textwidth]{diag-nominal.pdf}

\begin{itemize}
\item Well aligned in time.
\item Shapes are way off.  Splat is more narrow and dense than sim+SP.
\item Sim+SP has features near the base that will never be in splat. Likely induced by noise.
\end{itemize}
\end{frame}

\begin{frame}[label={sec:org7c5b04c},fragile]{Add extra smearing.}
 \begin{quote}
Now, rerun ``diagonal'' track but configure \texttt{DepoFluxSplat} with the additional
smearing found by the ``morse'' analysis.
\end{quote}
\end{frame}

\begin{frame}[label={sec:org8b8cb51}]{Differences at track ends with extra smearing}
\includegraphics[page=5,width=0.45\textwidth]{diag-smeared.pdf}
\includegraphics[page=6,width=0.45\textwidth]{diag-smeared.pdf}

\begin{itemize}
\item Difference much reduced.
\end{itemize}
\end{frame}

\begin{frame}[label={sec:org47c18f0}]{V-plane channels near track endpoints with extra smearing}
\includegraphics[page=7,width=0.45\textwidth]{diag-smeared.pdf}
\includegraphics[page=8,width=0.45\textwidth]{diag-smeared.pdf}

\begin{itemize}
\item Time alignment retained.  Shapes much closer.
\item Splat sometimes larger/smaller than sim+SP.  Due to fluctuationions?
\end{itemize}
\end{frame}

\begin{frame}[label={sec:org01cb7bf}]{Summary}
\begin{itemize}
\item Splat provides a kind of ``true signal''.
\item With suitable extra smearing we may approximate that added by sim+SP.
\item The ``morse'' depo pattern and software can measure the extra smearing.
\item This allows splat to come close to matching sim+SP.
\item Sim+SP has features unmatched by splat, especially near base (probably noise).
\item What's going on at \qty{1500}{us}
\end{itemize}
\end{frame}


\begin{frame}[label={sec:orgd2a66e5},fragile]{Some entries to the software used to make this presentation}
 \begin{block}{Morse}
\scriptsize
\begin{verbatim}
$ WCT_BATS_TMPDIR=$(pwd)/tmp-morse bats ./test/test/test-morse-pdsp.bats
$ wirecell-gen morse-splat -o splat-params.org tmp-morse/peaks.json
\end{verbatim}
\end{block}

\begin{block}{Diagonal}
\scriptsize
\begin{verbatim}
$ WCT_BATS_TMPDIR=$(pwd)/tmp-diag bats ./test/test/test-ssss-pdsp.bats
\end{verbatim}
\end{block}

\begin{block}{Todo}
Parts of these tests are \alert{pdsp-only}, need to generalize to \alert{uboone}, \alert{sbnd}, etc.
\end{block}
\end{frame}
\end{document}