% Created 2023-08-28 Mon 13:34
% Intended LaTeX compiler: pdflatex
\documentclass[serif,professionalfont,colorlinks,aspectratio=149]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\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{svg}
\usetheme{default}
\author{Brett Viren}
\date{\today}
\title{WCT version of PR3DCluster}
\subtitle{Providing a \alert{portion} of what is used by WCP}
\title[New PR3DCluster]{WCT version of PR3DCluster}
\hypersetup{
 pdfauthor={Brett Viren},
 pdftitle={WCT version of PR3DCluster},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 27.2 (Org mode 9.5.2)}, 
 pdflang={English}}
\begin{document}

\maketitle

\begin{frame}[label={sec:orgee9e46c},fragile]{Overview}
 \begin{quote}
New \alert{blob} and \alert{cluster} classes for porting WCP pattern recognition to WCT.
\end{quote}

\vfill

And with various questions/unknowns/todos.

\vfill

Currently in the \texttt{apply-pointcloud} branch.

\tiny \url{https://github.com/WireCell/wire-cell-toolkit/blob/apply-pointcloud/util/inc/WireCellUtil/PointCluster.h}
\end{frame}


\begin{frame}[label={sec:orga250ffb}]{Scope (for now)}
For now, focus on \alert{context of single APA-face}.
\begin{itemize}
\item Eventually extend to \alert{two-face} and \alert{multi-APA} contexts (not part of WCP/MicroBooNE model).
\end{itemize}

Also, just \alert{data representation}, \alert{primitive operations} and \alert{collections}.
\begin{itemize}
\item Expect to construct and serialize blob/cluster with other code.
\end{itemize}
\end{frame}


\begin{frame}[label={sec:org88476c9},fragile]{\texttt{PointCloud::Blob}}
 A \alert{pseudo box} in 4, non-orthogonal dimensions: \alert{u,v,w} and \alert{t}.
\begin{itemize}
\item \alert{Discrete dimensions}: counts of \alert{wires} or \alert{ticks} (8 \texttt{int} values)
\item \alert{Half-open intervals} bound blob in each dimension (C++ iterator convention).
\end{itemize}

Primary purposes:

\begin{itemize}
\item Blob-level \alert{geometry operations}:  ``blob connectivity'', ``cluster overlap'', etc.

\item A \alert{constituent} of a \alert{cluster} that can be \alert{associated} with other data.

\item A \alert{value} object to support types/code like:
\begin{description}
\item[{hashable}] \texttt{std::map<Blob,T>}
\item[{copyable}] \texttt{Blob a = b;}
\item[{comparable}] \texttt{if (a == b) \{...\}} (compares intervals)
\item[{ordered}] \texttt{if (a < b) \{...\}} (by ``volume'')
\end{description}
\end{itemize}
\end{frame}

\begin{frame}[label={sec:orgdb24170},fragile]{Blob methods and functions}
 \begin{description}
\item[{\texttt{blob.sizes()}}] vector of sizes of intervals in each dimension (u,v,w,t).
\item[{\texttt{blob.empty()}}] true if any interval is empty
\item[{\texttt{blob.volume()}}] a pseudo-volume: \(dt \times min(du,dv,dw) \times max(du,dv,dw)\)
\item[{\texttt{envelope(blobs)}}] a blob that surrounds a set of blobs
\end{description}
\end{frame}


\begin{frame}[label={sec:org530d01f},fragile]{\texttt{PointCloud::Cluster}}
 Cluster is \alert{set of blobs} plus \alert{blob-derived data}
\begin{itemize}
\item blob-derived: PCs, k-d trees, PCAs, PC-graph (maybe)

\item blob-level PCs are \alert{registered} with a \alert{name}.
\item blobs associate to their named blob-level PCs.
\item cluster-level PC is \alert{concatenation} of blob-level PC of same \alert{name}.
\item blobs have unique ID in cluster (\texttt{IndexedMultiset})
\begin{itemize}
\item cluster provides \alert{context} and \alert{identity} to blobs.
\end{itemize}
\end{itemize}

Questions,
\begin{itemize}
\item Unsure if best to put \alert{point-cloud graphs} inside/outside cluster.
\item Must we support \alert{removal} of blob(s) from cluster?
\end{itemize}
\end{frame}


\begin{frame}[label={sec:orgac0be78},fragile]{Cluster methods and functions}
 \begin{description}
\item[{\texttt{insert(blob)}}] add a \texttt{Blob} to the cluster, returns unique blob index number.
\item[{\texttt{associate(name, index, pc)}}] add a named PC to a blob with index.
\item[{\texttt{envelope()}}] return pseudo \texttt{Blob} representing envelope of blobs.
\item[{\texttt{nearby(other, dist)}}] return set of this cluster's blobs ``near'' the \texttt{other} cluster according to \texttt{dist} (per-dimension intervals).
\item[{\texttt{kdtree(name, coordinates)}}] return a k-d tree query object on (whole cluster) PC of given name and list of coordinate attributes.
\item[{\texttt{pca(name, coordinates)}}] return PCA using listed coordinate attributes in named PC.
\item[{\texttt{overlap(one,two,dist)}}] return blobs from clusters \texttt{one} and \texttt{two} that are mutually within \texttt{dist} of each other.
\begin{itemize}
\item return as set of blobs?  Or two clusters? or some kind of mapping?
\end{itemize}
\end{description}
\end{frame}

\begin{frame}[label={sec:orga9a5b63},fragile]{Global point cloud}
 A cluster is primarily a collection of blobs and so we may use a \alert{global cluster} of \alert{all blobs} to represent a \alert{global point cloud}.

\begin{itemize}
\item A \texttt{Blob} is light weight (8 ints) so copies are cheap'ish.
\begin{itemize}
\item Okay to have same \texttt{Blob} value in more than one cluster.
\end{itemize}

\item But, \alert{full} PCs are ``heavier'' so some memory care is needed.
\begin{itemize}
\item I have some things to try to address this.
\end{itemize}
\end{itemize}
\end{frame}


\begin{frame}[label={sec:org8eef78c},fragile]{Identity and its context}
 \begin{block}{Blob has \texttt{std::hash<Blob>}}
\begin{itemize}
\item This is a global ID by itself (assuming no hash collisions).
\item Enables \alert{index} in the \alert{context of a cluster} (\texttt{IndexedMultiset<Blob>}).
\end{itemize}
\end{block}

\begin{block}{Cluster has no identity}
\begin{itemize}
\item We can hold \texttt{shared\_ptr<Cluster>} and use pointer as an ``identity''.
\item We can add \texttt{std::hash<Cluster>} \emph{eg} as hash of blob hashes.
\begin{itemize}
\item Then can use \texttt{IndexedMultiset<Cluster>}.
\end{itemize}
\end{itemize}
\end{block}

\begin{block}{Is this enough?}
If not, in what context do we assign unique Blob/Cluster IDs?
\end{block}
\end{frame}


\begin{frame}[label={sec:org6a4f0fb},fragile]{The name ``cluster''}
 We have already many things named ``cluster''
\begin{itemize}
\item \texttt{ICluster} and its ``cluster graph'', \texttt{PR3DCluster} and now this new one.
\end{itemize}

Maybe we should avoid ``cluster'' here?
\begin{itemize}
\item \texttt{PointCloud::Blobset} ?
\end{itemize}

Or, though it violates C++ best practices, tack on extra qualifiers

\begin{itemize}
\item \texttt{PointCloud::PCCluster} ?
\end{itemize}
\end{frame}
\end{document}