\chapter{Active Correction in MR-CMDS} \label{cha:act}

\begin{dquote}
  Calibrate, \\
  calibrate, \\
  calibrate, \\
  calibrate, \\
  calibrate, \\
  run.

  \dsignature{Long-hanging poster in Wright Group laser lab.}
\end{dquote}  % TODO: verify this quote

\clearpage

\section{Introduction}  % =========================================================================

MR-CMDS is subject to a number of possible artifacts, many of them stemming from the imperfect
nature of the frequency-tunable light sources we currently have.  %
It is self-evidently desirable to correct these artifacts, when possible.  %
Indeed many of these artifacts, such as OPA power, phase mismatch and absorption effects have
regularly been corrected for.  % TODO: link to examples in applications section
These corrections are applied after measurement, typically including information from other sources
(such as absorption spectra, in the case of absorption effect corrections).

A more interesting class of corrections are ``active'' corrections---that is, corrections that must
be actively applied during acquisition and cannot be applied in post processing.  %
These corrections are more insidious, and they are often neglected because the hardware and/or
software does not allow for them.  %

In this chapter I explore some of these active correction strategies that are useful in the context
of MR-CMDS.  %
Some of these strategies have already been implemented, others are partially implemented, and
others are still just ideas.  %
I hope to show that active correction is a particularly useful strategy in MR-CMDS.  %

[SPECTRAL DELAY PARAGRAPH]

[POYNTING CORRECTION PARAGRAPH]

[EXCITATION POWER CORRECTION PARAGRAPH]

[CHOPPING PARAGRAPH]

[FIBRILLATION]

\clearpage
\section{Spectral delay correction}  % ============================================================

As a frequency domain technique, MR-CMDS requires automated tuning of multiple OPAs.  %
These OPAs generate pulses, which are then manipulated and directed into a sample of interest.  %
Crucially, the relative arrival time of each pulse must be carefully controlled in the context of
the MR-CMDS experiment.  %
Unfortunately, changing the output frequency also changes the optical path length, meaning that
there is some unavoidable coupling between delay and frequency axes.  %
Because we have full control over delay through delay stages, we can correct for this phenomenon by
choosing a different zero delay \emph{offset} for each OPA output color.  %
This strategy has been dubbed ``spectral delay correction''.  %

Spectral delay correction (SDC) is certainly the longest running active correction strategy employed
within the Wright Group.  %
SDC was first implemented by Schuyler Kain within his COLORS acquisition software. [CITE]  %
COLORS' implementation was hardcoded for one particular OPA / delay configuration---it wasn't until
PyCMDS that fully arbitrary SDC became possible through the autonomic system (see section ...).  %
Erin Boyle ``backported'' similar functionality into to ps\_control, although her implementation
allowed only for a simple, first order linear correction.  %

Sometimes, spectral delay can be corrected for after-the-fact.  %
Post processed spectral delay correction can only be done if all relevant delays are scanned during
the experiment.  %
A common example is transient absorption, where the single delay axis is typically scanned at each
color coordinate.  %
A special method of \python{Data}, \python{Data.offset} is designed to do the necessary
interpolation for \emph{post hoc} SDC.  %

In many experiments spectral delay must be actively corrected for.  %
Fully coherent experiments do 

It has been found that SDC is necessary for each individual scanned OPA, and for each separate path
when pulses from a single OPA are split.  %
The difference between different paths is typically small, but enough to move pulses a noticeable
amount relative to each-other.  %
For this reason, SDC for split OPAs is a multidimensional problem, which in principle requires a
multi-dimensional acquisition to fully record.  %
In practice, however, these corrections are recorded iteravely.  %

White light sources are also interesting to consider in the context of spectral delay
correction.  %
White light is typically quite chirped, with lower frequency (redder) colors traveling ahead of
high frequency (bluer) colors.  %
Typically, white light might serve as a ``probe'' that interacts last with the sample.  %
If a scanning monochromator is used, spectral delay correction could be employed such that each
color within the white light pulse arrives at the same delay.  %
If a fully coherent experiment is performed with chirped white light as one of the excitation
pulses, the other pulses will provide a gating effect in time that isolates interaction from one
frequency in the white pulse.  %
This is similar to the gating that is accomplished using ``delay 1'' in the TOPAS-C OPAs (see
section  ...).  %
By gating in this way, a \emph{frequency} axis along the white light dimension could be scanned
using a delay stage.  %
COLORS' has taken this idea to it's logical conclusion, with support for ``OPAs'' that are actually
controlled by delay stages, although the idea has not yet been realized in practice.  %

[DESCRIPTION OF FIGURE]

\begin{figure}
	\includegraphics[width=0.45\textwidth]{"active_correction/sdc_before"}
 	\includegraphics[width=0.45\textwidth]{"active_correction/sdc_after"}
  \caption[CAPTION TODO]{
    CAPTION TODO: SPECTRAL DELAY CORRECTION FIGURE
  }
\end{figure}

\section{Poynting correction}  % ==================================================================

[CONTENT FROM KYLE SUNDEN]

\begin{figure}
	\includegraphics[width=0.45\textwidth]{"active_correction/poynting_correction/intensity"}
  \caption[Poynting Correction curve generation.]{
    A typical example of the output of the Poynting Tune module.
    The top figure shows the curve for the axis designated Theta.
    The thin, solid line is the previous curve, the thick transparent line is the new tuning curve.
    The y-axis is in units of motor steps, the x-axis is in units of wavenumbers.
    The bottom plot shows the intensity of signal measured for the change in Theta vs. setpoint.
    Center of mass of each vertical slice are extracted and linearly interpolated to obtain the new
    calibration curve.
    This figure was automatically generated by PyCMDS on March 28, 2018 using an OPA-800 generating
    1 ps infrared light.
  }
\end{figure}

\section{Excitation power correction}  % ==========================================================

\clearpage
\section{Chopping}  % =============================================================================

\subsection{Scatter}  % ---------------------------------------------------------------------------

Scatter is a complex microscopic process whereby light traveling through a material elastically
changes its propagation direction.  %
In CMDS we use propagation direction to isolate signal.  %
Scattering samples defeat this isolation step and allow some amount of excitation light to reach
the detector.  %
In homodyne-detected 4WM experiments,
\begin{equation}
I_{\mathrm{detected}} = |E_{\mathrm{4WM}} + E_1 + E_2 + E_{2^\prime}|^2
\end{equation}
Where $E$ is the entire time-dependent complex electromagnetic field.  %
When expanded, the intensity will be composed of diagonal and cross terms:
\begin{equation}
\begin{split}
I_{\mathrm{detected}} = \overline{(E_1+E_2)}E_{2^\prime} + (E_1+E_2)\overline{E_{2^\prime}} + |E_1+E_2|^2 + (E_1+E_2)\overline{E_{\mathrm{4WM}}} \\ + (E_1+E_2)\overline{E_{\mathrm{4WM}}} + \overline{E_{2^\prime}}E_{\mathrm{4WM}} + E_{2^\prime}\overline{E_{\mathrm{4WM}}} + |E_{\mathrm{4WM}}|^2
\end{split}
\end{equation}
A similar expression in the case of heterodyne-detected 4WM is derived by
\textcite{BrixnerTobias2004a}.  %
The goal of any `scatter rejection' processing procedure is to isolate $|E_{\mathrm{4WM}}|^2$ from
the other terms.  %

% TODO: verify derivation

\subsubsection{Abandon the Random Phase Approximation}

\subsubsection{Interference Patterns in TrEE}

TrEE is implicitly homodyne-detected.  %
Scatter from excitation fields will interfere on the amplitude level with TrEE signal, causing
interference patterns that beat in delay and frequency space.  %
The pattern of beating will depend on which excitation field(s) reach(es) the detector, and the
parameterization of delay space chosen.  %

First I focus on the interference patterns in 2D delay space where all excitation fields and the
detection field are at the same frequency.  %

\begin{figure}
	\includegraphics[scale=0.5]{"active_correction/scatter/scatter interference in TrEE old"}
	\caption[Simulated interference paterns in old delay parameterization.]{Numerically simulated
    interference patterns between scatter and TrEE for the old delay parametrization. Each column
    has scatter from a single excitation field. The top row shows the measured intensities, the
    bottom row shows the 2D Fourier transform, with the colorbar's dynamic range chosen to show the
    cross peaks.}
  label{fig:scatterinterferenceinTrEEold}
\end{figure}

Here I derive the slopes of constant phase for the old delay space, where
$\mathrm{d1}=\tau_{2^\prime1}$ and $\mathrm{d2}=\tau_{21}$.  %
For simplicity, I take $\tau_1$ to be $0$, so that $\tau_{21}\rightarrow\tau_2$ and
$\tau_{2^\prime1}\rightarrow\tau_{2^\prime}$.  %
The phase of signal is then
\begin{equation}
\Phi_{\mathrm{sig}} = \mathrm{e}^{-\left((\tau_{2^\prime}-\tau_2)\omega\right)}
\end{equation}
The phase of each excitation field can also be written:
\begin{eqnarray}
\Phi_{1} &=& \mathrm{e}^0 \\
\Phi_{2} &=& \mathrm{e}^{-\tau_2\omega} \\
\Phi_{2^\prime} &=& \mathrm{e}^{-\tau_{2^\prime}\omega}
\end{eqnarray}
The cross term between scatter and signal is the product of $\Phi_\mathrm{sig}$ and $\Phi_\mathrm{scatter}$. The cross terms are:
\begin{eqnarray}
\Delta_{1} = \Phi_{\mathrm{sig}} &=& \mathrm{e}^{-\left((\tau_{2^\prime}-\tau_2)\omega\right)} \\
\Delta_{2} = \Phi_{\mathrm{sig}}\mathrm{e}^{-\tau_2\omega} &=&  \mathrm{e}^{-\left((\tau_{2^\prime}-2\tau_2)\omega\right)}\\
\Delta_{2^\prime} = \Phi_{\mathrm{sig}}\mathrm{e}^{-\tau_{2^\prime}\omega} &=& \mathrm{e}^{-\tau_{2}\omega}
\end{eqnarray}
Figure \ref{fig:scatterinterferenceinTrEEold} presents numerical simulations of scatter interference as a visual aid. See Yurs 2011 \cite{YursLenaA2011a}.
% TODO: Yurs 2011 Data

\begin{figure}
	\includegraphics[width=7in]{"active_correction/scatter/scatter interference in TrEE current"}
	\caption[Simulated interference paterns in current delay parameterization.]{Numerically simulated
    interference patterns between scatter and TrEE for the current delay parametrization. Each
    column has scatter from a single excitation field. The top row shows the measured intensities,
    the bottom row shows the 2D Fourier transform, with the colorbar's dynamic range chosen to show
    the cross peaks.}
  \label{fig:scatterinterferenceinTrEEcurrent}
\end{figure}

Here I derive the slopes of constant phase for the current delay space, where $\mathrm{d1}=\tau_{22^\prime}$ and $\mathrm{d2}=\tau_{21}$. I take $\tau_2$ to be $0$, so that $\tau_{22^\prime}\rightarrow\tau_{2^\prime}$ and $\tau_{21}\rightarrow\tau_1$. The phase of the signal is then
\begin{equation}
\Phi_{\mathrm{sig}} = \mathrm{e}^{-\left((\tau_{2^\prime}+\tau_1)\omega\right)}
\end{equation}
The phase of each excitation field can also be written:
\begin{eqnarray}
\Phi_{1} &=& \mathrm{e}^{-\tau_1\omega} \\
\Phi_{2} &=& \mathrm{e}^{0} \\
\Phi_{2^\prime} &=& \mathrm{e}^{-\tau_{2^\prime}\omega}
\end{eqnarray}
The cross term between scatter and signal is the product of $\Phi_\mathrm{sig}$ and $\Phi_\mathrm{scatter}$. The cross terms are:
\begin{eqnarray}
\Delta_{1} = \Phi_{\mathrm{sig}}\mathrm{e}^{-\tau_1\omega} &=& \mathrm{e}^{-\tau_{2^\prime}\omega} \\
\Delta_{2} = \Phi_{\mathrm{sig}} &=& \mathrm{e}^{-\left((\tau_2+\tau_1)\omega\right)} \\
\Delta_{2^\prime} = \Phi_{\mathrm{sig}}\mathrm{e}^{-\tau_{2^\prime}\omega} &=& \mathrm{e}^{-\tau_1\omega}
\end{eqnarray}
Figure \ref{fig:scatterinterferenceinTrEEcurrent} presents numerical simulations of scatter interference for the current delay parameterization.

\subsubsection{Instrumental Removal of Scatter}

The effects of scatter can be entirely removed from CMDS signal by combining two relatively
straight-forward instrumental techniques: \textit{chopping} and \textit{fibrillation}.  %
Conceptually, chopping removes intensity-level offset terms and fibrillation removes
amplitude-level interference terms.  %
Both techniques work by modulating signal and scatter terms differently so that they may be
separated after light collection.  %

\begin{table}[h] \label{tab:phase_shifted_parallel_modulation}
	\begin{center}
		\begin{tabular}{ r | c | c | c | c }
			& A       & B          & C          & D                       \\
			signal    &            &            & \checkmark &            \\
			scatter 1 &            & \checkmark & \checkmark &            \\
			scatter 2 &            &            & \checkmark & \checkmark \\
			other     & \checkmark & \checkmark & \checkmark & \checkmark
		\end{tabular}
	\end{center}
	\caption[Shot-types in phase shifted parallel modulation.]{Four shot-types in a general phase shifted parallel modulation scheme. The `other' category represents anything that doesn't depend on either chopper, including scatter from other excitation sources, background light, detector voltage offsets, etc.}
\end{table}

We use the dual chopping scheme developed by \textcite{FurutaKoichi2012a} called `phase shifted
parallel modulation'.  %
In this scheme, two excitation sources are chopped at 1/4 of the laser repetition rate (two pulses
on, two pulses off).  %
Very similar schemes are discussed by \textcite{AugulisRamunas2011a} and
\textcite{HeislerIsmael2014a} for two-dimensional electronic spectroscopy.  %
The two chop patterns are phase-shifted to make the four-pulse pattern represented in Table
\ref{tab:phase_shifted_parallel_modulation}.  %
In principle this chopping scheme can be achieved with a single judiciously placed mechanical
chopper - this is one of the advantages of Furuta's scheme.  %
Due to practical considerations we have generally used two choppers, one on each OPA.  %
The key to phase shifted parallel modulation is that signal only appears when both of your chopped
beams are passed.  %
It is simple to show how signal can be separated through simple addition and subtraction of the A,
B, C, and D phases shown in Table \ref{tab:phase_shifted_parallel_modulation}.  %
First, the components of each phase:
\begin{eqnarray}
A &=& I_\mathrm{other} \\
B &=& I_\mathrm{1} + I_\mathrm{other} \\
C &=& I_\mathrm{signal} + I_\mathrm{1} + I_\mathrm{2} + I_\mathrm{other} \\
D &=& I_\mathrm{2} + I_\mathrm{other}
\end{eqnarray}
Grouping into difference pairs,
\begin{eqnarray}
A-B &=& -I_\mathrm{1} \\
C-D &=& I_\mathrm{signal} + I_\mathrm{1} 
\end{eqnarray}
So:
\begin{equation} \label{eq:dual_chopping}
A-B+C-D = I_\mathrm{signal}
\end{equation}
I have ignored amplitude-level interference terms in this treatment because they cannot be removed
via any chopping strategy.  %
Interference between signal and an excitation beam will only appear in `C'-type shots, so it will
not be removed in Equation \ref{eq:dual_chopping}.  %
To remove such interference terms, you must \textit{fibrillate} your excitation fields.

An alternative to dual chopping is single-chopping and `leveling'...  %
this technique was used prior to May 2016 in the Wright Group...  %
`leveling' and single-chopping is also used in some early 2DES work...
\cite{BrixnerTobias2004a}.  %

\begin{figure} 
	\includegraphics[scale=0.5]{"active_correction/scatter/TA chopping comparison"}
	\caption[Comparison of single, dual chopping.]{Comparison of single and dual chopping in a
    MoS\textsubscript{2} transient absorption experiment. Note that this data has not been
    processed in any way - the colorbar represents changes in intensity seen by the detector. The
    grey line near 2 eV represents the pump energy. The inset labels are the number of laser shots
    taken and the chopping strategy used.}
  \label{fig:ta-chopping-comparison}
\end{figure}

Figure \ref{fig:ta-chopping-comparison} shows the effects of dual chopping for some representative
MoS\textsubscript{2} TA data.  %
Each subplot is a probe wigner, with the vertical grey line representing the pump energy.  %
Note that the single chopper passes pump scatter, visible as a time-invariant increase in intensity
when the probe and monochromator are near the pump energy.  %
Dual chopping efficiently removes pump scatter, but at the cost of signal to noise for the same
number of laser shots.  %
Taking twice as many laser shots when dual chopping brings the signal to noise to at least as good
as the original single chopping.  %

\subsection{Normalization of dual-chopped self-heterodyned signal}

%\begin{table}[!htb]
%  \centering
%  \renewcommand{\arraystretch}{1.5}
%\begin{array}{r | c | c | c | c }
%  & A           & B & C & D \\ \hline
%  \text{signal}   & S_A=V_A^S   & S_B=R^SC^1I_B^S & S_C=R^S(C^1) & S_D=R^SC^2I_D^S \\ \hline
%  \text{source 1} & M_A^1=V_A^1 & M_B=R^1I_B^1    & M_C^1=R^1I_C^1 & M_D^1=V_D^1 \\ \hline
%  \text{source 2} & M_A^2=V_A^2 & M_B^2=V_B^2     & M_C^2=R^2I_C^2 & M_D^2=R^2I_D^2
%\end{array}
%  \caption{CAPTION}
%\end{table}

Shot-by-shot normalization is not trivial for these experiments.  %
As in table above, with 1 as pump and 2 as probe.  %

Starting with $\Delta I$ from \ref{eq:dual_chopping}, we can normalize by probe intensity to get
the popular $\Delta I / I$ representation.  %
Using the names defined above:
\begin{equation}
  \frac{\Delta I}{I} = \frac{A-B+C-D}{D-A}
\end{equation}
Now consider the presence of excitation intensity monitors, indicated by subscripts PR for probe
and PU for pump.

We can further normalize by the pump intensity by dividing the entire expression by $C_{PU}$:
\begin{equation}
  \frac{\Delta I}{I} = \frac{A-B+C-D}{(D-A)*C_{PU}}
\end{equation}

Now, substituting in BRAZARD formalism:

\begin{eqnarray}
  A &=& constant \\
  B &=& S I_{PU}^B (1+\delta_{PU}^B) \\
  C &=& I_{PR}^C(1+\delta_{PR}^C) + S I_{PU}^C(1+\delta_{PR}^C) \\
  D &=& I_{PR}^D(1+\delta_{PR}^D)
\end{eqnarray}

\begin{equation}
  \frac{\Delta I}{I} = \frac{<A> -
    \frac{<B_{PU}>B}{B_{PU}} +
    \frac{<C_{PU}><C_{PR}C}{C_{PU}C_{PR}} -
    \frac{<D_{PR}>D}{D_{PR}}}{<PR><PU>}
\end{equation}

\section{Fibrillation}  % =========================================================================

Fibrillation is the intentional randomization of excitation phase during an experiment.  %
Because the interference term depends on the phase of the excitation field relative to the signal,
averaging over many shots with random phase will cause the interference term to approach zero.  %
This is a well known strategy for removing unwanted interference terms \cite{SpectorIvanC2015a,
  McClainBrianL2004a}.  %

\section{Conclusions}  % ==========================================================================
