% vim: fdm=marker fmr=<<<,>>>
%\documentclass[notes]{beamer}
\documentclass[]{beamer}


%%%%%%%%%%%%%%%
% Preamble <<<
%%%%%%%%%%%%%%%

\usepackage[british]{babel}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage[backend=bibtex,style=trad-plain]{biblatex}
\usepackage{appendixnumberbeamer}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{xurl}
\usepackage{physics}
\graphicspath{{.}{./figures/}{../../figures/}}
\usepackage{todo}

\addbibresource{../../bibliotheca/bibliography.bib}

% Use arXiv identifier if available
\DeclareCiteCommand{\arxivcite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}
   \newunit
   \clearfield{eprintclass}
   \usebibmacro{eprint}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newcommand{\imagesource}[1]{~\\[0pt]\vspace*{-7pt}\hspace*{10pt}{\tiny#1}}
\newcommand{\imagecredit}[1]{\imagesource{Credit:\thinspace#1}}
\newcommand{\imagecite}[1]{\imagesource{\arxivcite{#1}}}

% Disable Captions
\setbeamertemplate{caption}{\raggedright\small\insertcaption\par}

% no to navigation, yes to frame numbering
\beamertemplatenavigationsymbolsempty
\setbeamerfont{page number in head/foot}{size=\normalsize}
\setbeamertemplate{page number in head/foot}{\insertframenumber/\inserttotalframenumber}
%\setbeamercolor{page number in head/foot}{fg=red}
\setbeamerfont{section in head/foot}{size=\small}
\setbeamercolor{section in head/foot}{fg=gray}
\setbeamertemplate{section in head/foot}{\textit{\insertsectionhead}}
%\setbeamertemplate{footline}[frame number]
\setbeamertemplate{footline}
{%
\leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.7\paperwidth,ht=2.55ex,dp=1ex,leftskip=1em,rightskip=1em,sep=0pt]{title in head/foot}%
    \usebeamertemplate*{section in head/foot}%
    \hfill%
  \end{beamercolorbox}
  \begin{beamercolorbox}[wd=.1\paperwidth,ht=2.55ex,dp=1ex,sep=0pt]{my empty section}
    \hfill%
  \end{beamercolorbox}
  \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.55ex,dp=1ex,leftskip=1em,rightskip=1em,sep=0pt]{page number in head/foot}%
	\hfill%
    \usebeamertemplate*{page number in head/foot}%
  \end{beamercolorbox}}%
}

%% From https://tex.stackexchange.com/a/55849
% Keys to support piece-wise uncovering of elements in TikZ pictures:
% \node[visible on=<2->](foo){Foo}
% \node[visible on=<{2,4}>](bar){Bar}   % put braces around comma expressions
%
% Internally works by setting opacity=0 when invisible, which has the
% adavantage (compared to \node<2->(foo){Foo} that the node is always there, hence
% always consumes space plus that coordinate (foo) is always available.
%
% The actual command that implements the invisibility can be overriden
% by altering the style invisible. For instance \tikzsset{invisible/.style={opacity=0.2}}
% would dim the "invisible" parts. Alternatively, the color might be set to white, if the
% output driver does not support transparencies (e.g., PS)
%
\tikzset{
  invisible/.style={opacity=0},
  visible on/.style={alt={#1{}{invisible}}},
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
  },
}

\hypersetup{pdfpagemode=UseNone} % don't show bookmarks on initial view

% >>> Preamble
%%%%%%%%%%%%%%%
% Meta data <<<
%%%%%%%%%%%%%%%
\def\thesistitle{Enhancing Timing Accuracy\texorpdfstring{\\[0.3cm]}{ }in Air Shower Radio Detectors}
\def\thesissubtitle{}
\def\thesisauthorfirst{E.T.}
\def\thesisauthorsecond{de Boone}
\def\thesisauthoremailraw{ericteunis@deboone.nl}
\def\thesisauthoremail{\href{mailto:\thesisauthoremailraw}{\thesisauthoremailraw}}
\def\thesissupervisorfirst{dr. Harm}
\def\thesissupervisorsecond{Schoorlemmer}
\def\thesissupervisoremailraw{}
\def\thesissupervisoremail{\href{mailto:\thesissupervisoremailraw}{\thesissupervisoremailraw}}

\title[\thesistitle]{\thesistitle}

\date{July, 2023}

\author[\thesisauthorfirst\space\thesisauthorsecond]{%
	\texorpdfstring{\thesisauthorfirst\space\thesisauthorsecond\thanks{e-mail: \thesisauthoremail}\\
	\vspace*{0.5em}
	{Supervisor: \thesissupervisorfirst\space\thesissupervisorsecond }
	}{\thesisauthorfirst\space\thesisauthorsecond<\thesisauthoremailraw>}
	}

% >>> Meta data

\newcommand{\tclock}{\ensuremath{t_\mathrm{clock}}}
\newcommand{\ns}{\ensuremath{\mathrm{ns}}}

\newcommand{\pTrue}{\phi}
\newcommand{\PTrue}{\Phi}
\newcommand{\pMeas}{\varphi}

\newcommand{\pTrueEmit}{\pTrue_0}
\newcommand{\pTrueArriv}{\pTrueArriv'}
\newcommand{\pMeasArriv}{\pMeas_0}
\newcommand{\pProp}{\pTrue_d}
\newcommand{\pClock}{\pTrue_c}

\begin{document}
{ % Titlepage <<<
\setbeamertemplate{background}
{%
	\parbox[c][\paperheight][c]{\paperwidth}{%
		\centering%
		\vfill%
		\includegraphics[width=\textwidth]{beacon/array_setup_gps_transmitter_cows.png}%
		\vspace*{2em}
	}%
}
\setbeamertemplate{footline}{} % no page number here
\frame{	\titlepage }
} % >>>

%%%%%%%%%%%%%%%
% Start of slides <<<
%%%%%%%%%%%%%%%
\section{Cosmic Particle Detection}% <<<<
% Sources, Types, Propagation, Observables
% Flux -> Large instrumentation area
% Detection methods of Auger
%  - FD, SD
% AERA / AugerPrime RD or GRAND
\begin{frame}{Ultra High Energy particles}
\end{frame}

\begin{frame}{Air Showers}
% Observables
\end{frame}

\begin{frame}{UHE particle flux}
\end{frame}

\begin{frame}{Detection methods}
\end{frame}

\begin{frame}{Radio Emission}
\end{frame}


% >>>>
\section{Radio Interferometry}% <<<<
\begin{frame}{Radio Interferometry: Concept}
	Interferometry: Amplitude + Timing information of the $\vec{E}$-field\\
	\vspace*{ 0.8em }
	\begin{columns}
		\begin{column}{0.4\textwidth}
			\begin{figure}
				\includegraphics<1>[width=\textwidth]{radio_interferometry/rit_schematic_base.pdf}%
				\includegraphics<2>[width=\textwidth]{radio_interferometry/rit_schematic_far.pdf}%
				\includegraphics<3>[width=\textwidth]{radio_interferometry/rit_schematic_close.pdf}%
				\includegraphics<4>[width=\textwidth]{radio_interferometry/rit_schematic_true.pdf}%
			\end{figure}
		\end{column}
		\begin{column}{0.6\textwidth}
			\vspace*{\fill}
			\begin{itemize}
				\item<1-> Measure signal $S_i(t)$ at antenna $\vec{a_i}$

				\item<2-> Calculate light travel time \\[5pt]
					\quad $\Delta_i(\vec{x}) = \frac{ \left| \vec{x} - \vec{a_i} \right| }{c} n_{eff}$

				\item<2-> Sum waveforms accounting \\
					for time delay \\[5pt]
					\quad $S(\vec{x}, t) = \sum S_i( t + \Delta_i(\vec{x}) )$
			\end{itemize}
			\vspace*{\fill}
			\begin{figure}% Spatially
				\includegraphics<1>[width=0.8\textwidth]{radio_interferometry/single_trace.png}%
				\includegraphics<2>[width=0.8\textwidth]{radio_interferometry/trace_overlap_bad.png}%
				\includegraphics<3>[width=0.8\textwidth]{radio_interferometry/trace_overlap_medium.png}%
				\includegraphics<4>[width=0.8\textwidth]{radio_interferometry/trace_overlap_best.png}%
			\end{figure}
		\end{column}
	\end{columns}
\end{frame}

\begin{frame}{Radio Interferometry: Image}
	\begin{figure}
		\centering
		\includegraphics[width=0.7\textwidth]{2006.10348/fig01.png}%
		\imagecite{Schoorlemmer:2020low}
	\end{figure}
\end{frame}

% >>>>
\section{Timing in Radio Detectors}% <<<<
% GNSS
% reference system: White Rabbit, AERA beacon, (ADS-B?)
% GRAND setup and measurements
\begin{frame}{Timing in Radio Detectors: GNSS}
% Geometry
	Default Timing mechanism: Global Navigation Satellite Systems\\
	\begin{columns}
		\begin{column}{0.5\textwidth}
			\vfill
			\begin{figure}
				\begin{tikzpicture}[scale=1]
					\clip (2.5 , 0) rectangle ( 6, 2.5);
					\node[anchor=south west, inner sep=0] (image) at (0,0) {\includegraphics[width=\textwidth]{beacon/array_setup_gps_transmitter_cows.png}};
					%\draw[help lines,xstep=1,ystep=1] (0,0) grid (11,5);
				\end{tikzpicture}
				\imagecredit{H. Schoorlemmer}
			\end{figure}
		\end{column}
		\hfill
		\begin{column}{0.45\textwidth}
			In AERA, $ \Delta \tclock \gtrsim 10\ns$
			\\
			\begin{figure}
				\centering
				\includegraphics[width=\textwidth]{gnss/auger/1512.02216.figure3.gnss-time-differences.png}
				\imagecite{PierreAuger:2015aqe}
			\end{figure}
		\end{column}
	\end{columns}
\end{frame}

% >>>>
\section{Beacon Synchronisation}% <<<<
% Geometry
% Pulse method + SNR
% Sine method + SNR
\begin{frame}{Beacon Synchronisation}
% Geometry
	\vspace*{0em}
	{
		{ \color{red} GNSS } 
		+ 
		Extra Timing mechanism: {\color{blue} Beacon}%, {\color{green} ADS-B}
	}
	\\
	\vspace*{2em}
	\begin{figure}
		\hspace*{-2em}
		\begin{tikzpicture}
			[circle/.style={circle, ultra thick, radius=8mm}]
			\node[anchor=south west, inner sep=0] (image) at (0,0) {\includegraphics[width=\textwidth]{beacon/array_setup_gps_transmitter_cows.png}};
			\begin{scope}[x={(image.south east)}, y={(image.north west)}]
				%\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
				%\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
				%\foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
				\node (transmitter) at (0.23, 0.32) {};
				\node (gnss) at (0.85, 0.87) {};
				%\node (aeroplane) at (0.3, 0.67) {\includegraphics[width=1.5cm]{templates/aeroplane.png}};
				%\draw[green, ultra thick, visible on=<{1-}>] (aeroplane.center)    circle[radius=8mm];
				\draw[red,   ultra thick, visible on=<{1-}>] (gnss.center)         circle[radius=8mm];
				\draw[blue,  ultra thick, visible on=<{1-}>] (transmitter.center)  circle[radius=8mm];
			\end{scope}
		\end{tikzpicture}
		\imagecredit{H. Schoorlemmer}
	\end{figure}
\end{frame}

\subsection{Pulse Beacon}
\begin{frame}{Pulse Beacon}
	\begin{figure}
		\includegraphics[width=\textwidth]{pulse/antenna_signals_tdt0.2_zoom.pdf}
	\end{figure}
	\vfill
\end{frame}
\begin{frame}{Pulse Beacon}
	Correlation: similarity between two signals.\\
	\begin{figure}
		\includegraphics[width=\textwidth]{pulse/correlation_tdt0.2_zoom.pdf}
	\end{figure}
\end{frame}
\begin{frame}{Pulse Beacon Timing}
	\begin{figure}
		\includegraphics[width=0.8\textwidth]{pulse/time_res_vs_snr_multiple_dt_small.pdf}
	\end{figure}
\end{frame}

\subsection{Sine Beacon}
\begin{frame}{(Multi)Sine Beacon}
	\begin{equation*}
		\Delta \tclock = \left[ \frac{\varphi}{2\pi} \; + \; k \right] T
	\end{equation*}
	\begin{figure}
		\includegraphics[width=.45\textwidth]{methods/fourier/waveform.pdf}
		\hfill
		\includegraphics[width=.45\textwidth]{methods/fourier/noisy_spectrum.pdf}
	\end{figure}
\end{frame}
\begin{frame}{(Multi)Sine Beacon Timing}
	\begin{figure}
		\includegraphics[width=0.8\textwidth]{beacon/time_res_vs_snr.pdf}
	\end{figure}
	\begin{columns}
		\begin{column}{0.3\textwidth}
		\end{column}
		\begin{column}{0.7\textwidth}
			\tiny\begin{equation*}
	p_\PTrue(\pTrue; s, \sigma) =
		\frac{ e^{-\left(\frac{s^2}{2\sigma^2}\right)} }{ 2 \pi }
		+
		\sqrt{\frac{1}{2\pi}}
		\frac{s}{\sigma}
		e^{-\left( \frac{s^2}{2\sigma^2}\sin^2{\pTrue} \right)}
		\frac{\left(
			1 + \erf{ \frac{s \cos{\pTrue}}{\sqrt{2} \sigma }}
		\right)}{2}
		\cos{\pTrue}
			\end{equation*}
		
		\tiny{Random Phasor Sum: ``Statistical Optics'', J. Goodman}
		\end{column}
	\end{columns}

\end{frame}

% >>>>
\section{Single Sine Synchronisation}% <<<<
% Sine method + Radio Interferometry
\begin{frame}{Single Sine Synchronisation}
	\begin{figure}
		%\centering
		\hspace*{-5em}
		\includegraphics<1>[width=1.3\textwidth]{beacon/08_beacon_sync_timing_outline.pdf}%
		\includegraphics<2>[width=1.3\textwidth]{beacon/08_beacon_sync_synchronised_outline.pdf}%
		\includegraphics<3>[width=1.3\textwidth]{beacon/08_beacon_sync_synchronised_period_alignment.pdf}%
	\end{figure}
\end{frame}

\begin{frame}{Single Sine Synchronisation Simulation}
	Air Shower detected on a grid of 100x100 antennas.

	\begin{columns}
		\begin{column}{0.5\textwidth}
			\begin{itemize}
				\item Add beacon to antenna
				\item Randomise clocks
				\item Measure phase
				\item Repair clocks for small offsets
				\item Iteratively find best $k_{ij}$
			\end{itemize}
		\end{column}
		\hfill
		\begin{column}{0.4\textwidth}
			\begin{figure}
				\includegraphics<1>[width=\textwidth]{ZH_simulation/ba_measure_beacon_phase.py.A74.no_mask.pdf}%
				\includegraphics<2>[width=\textwidth]{ZH_simulation/ba_measure_beacon_phase.py.A74.masked.pdf}%
			\end{figure}
		\end{column}
	\end{columns}
\end{frame}

\begin{frame}{Simulation: Period $k_i$}
	\small{
	Interferometry while allowing to shift by $T = 1/f_\mathrm{beacon}$
	\\
	Iterative process: \\
	\; Scan positions finding the best $\{k_i\}$ set, then zoom in on strongest.
	}

	\only<1-4>{\begin{figure}
	\includegraphics<1>[width=0.8\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.run0.i5.loc8.0-2795.4-7816.0.pdf}
	\includegraphics<2>[width=0.8\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.run0.i99.loc8.0-2795.4-7816.0.pdf}
	\includegraphics<3>[width=0.8\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.maxima.run0.pdf}
	\includegraphics<4>[width=0.8\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.reconstruction.run0.power.pdf}
	\end{figure}}
	\only<5>{\begin{figure}
		\includegraphics[width=0.45\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.maxima.run0.pdf}
		\hfill
		\includegraphics[width=0.45\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.reconstruction.run0.power.pdf}
		\vspace{0.5cm}
		\includegraphics[width=0.45\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.maxima.run1.pdf}
		\hfill
		\includegraphics[width=0.45\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.reconstruction.run1.power.pdf}
	\end{figure}}
\end{frame}


\begin{frame}{Time resolving short period beacon: phase vs full}
	\begin{columns}
		\begin{column}{0.45\textwidth}
			{ Phase reparation }
			\includegraphics[width=\textwidth]{radio_interferometry/trace_overlap/on-axis/dc_grid_power_time_fixes.py.repair_phases.axis.trace_overlap.repair_phases.pdf}%
			\vfill
			\includegraphics[width=\textwidth]{radio_interferometry/dc_grid_power_time_fixes.py.X400.repair_phases.scale4d.pdf}%
			\label{fig:sine:repairments}
		\end{column}
		\hfill
		\begin{column}{0.45\textwidth}
			{ Phase + Period reparation }
			\includegraphics[width=\textwidth]{radio_interferometry/trace_overlap/on-axis/dc_grid_power_time_fixes.py.repair_full.axis.trace_overlap.repair_full.pdf}%
			\vfill
			\includegraphics[width=\textwidth]{radio_interferometry/dc_grid_power_time_fixes.py.X400.repair_all.scale4d.pdf}%
		\end{column}
	\end{columns}
\end{frame}

% >>>>
\section{Conclusion}% <<<<
% Single Sine + Air Shower
% Outlook: Parasitic/Active vs Pulse/Sine table
% Parasitic Single Sine: 67MHz Auger
% Implementation for GRAND?
\begin{frame}{Conclusion and Outlook}
\end{frame}

% >>>>
% >>> End of Slides
%%%%%%%%%%%%%%%
% Backup slides <<<
%%%%%%%%%%%%%%%
\appendix
\begin{frame}[c]
	\centering
	\Large {
		\textcolor{blue} {
	Supplemental material
	}
	}
\end{frame}

\section*{Table of Contents}
\begin{frame}{Table of Contents}
	\tableofcontents
\end{frame}


% >>> End of Backup Slides
%%%%%%%%%%%%%%
% Bibliography <<<
%%%%%%%%%%%%%%
\section*{References}
\begin{frame}[allowframebreaks]
	\frametitle{References}
	\printbibliography
\end{frame}
% >>> Bibliography
\end{document}

