\section{PreMonitor\_nD: Store photon rays for possible later detection.}
\index{monitors!PreMonitor}
\mcdoccomp{monitors/PreMonitor_nD.parms}

The first immediate usage of the \textbf{Monitor\_nD} component is when one requires to
identify cross-correlations between some photon parameters, e.g. position and
divergence (\textit{aka} phase-space diagram). This latter monitor would be
merely obtained with:\index{Monitors!Photon parameter correlations,
PreMonitor\_nD}
\begin{verbatim}
options="x dx, auto", bins=30
\end{verbatim}
This example records the correlation between position and divergence of photons at a given instrument location.

It is also possible to search for cross-correlation between two part of the
instrument simulation. One example is the acceptance phase-diagram, which shows
the photon caracteristics at the input required to reach the end of the
simulation. This \emph{spatial} correlation may be revealed using the
\textbf{PreMonitor\_nD} component. This latter stores the photon parameters at
a given instrument location, to be used at an other \textbf{Monitor\_nD} location for
monitoring.

The only parameter of \textbf{PreMonitor\_nD} is the name of the associated
Monitor\_nD instance, which should use the \verb+premonitor+ option, as in the
following example:
\begin{verbatim}
COMPONENT CorrelationLocation = PreMonitor_nD(comp = CorrelationMonitor)
AT (...)

  (... e.g. a bunch of optics )

COMPONENT CorrelationMonitor  = Monitor_nD(
   options="x dx, auto, all bins=30, premonitor")
AT (...)
\end{verbatim}
which performs the same monitoring as the previous example, but with a spatial
correlation constrain. Indeed, it records the position \textit{vs} the
divergence of photons at the correlation location, but only if they reach the
monitoring position. All usual \textbf{Monitor\_nD} variables may be used, except the
user variables. The latter may be defined as described in section
\ref{s:monnd:user} in an EXTEND block.
