\errorcontextlines=100
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphics}
\usepackage{listingsutf8}
\usepackage[colorlinks=true,urlcolor=blue,linkcolor=black,linktoc=all]{hyperref}
\def\Bi207{\ensuremath{^{207}\mathrm{Bi}}}
\DeclareUnicodeCharacter{00B1}{\ensuremath{\pm}}
\DeclareUnicodeCharacter{00B2}{\ensuremath{^2}}
\DeclareUnicodeCharacter{00B5}{\ensuremath{\mu}}
\DeclareUnicodeCharacter{00B0}{\ensuremath{^\circ}}
\DeclareUnicodeCharacter{00AF}{\ensuremath{^-}}
\DeclareUnicodeCharacter{03C3}{\ensuremath{\sigma}}
\DeclareUnicodeCharacter{00D7}{\ensuremath{\times}}
\def\d{\mathrm d}
\def\tablecaption{\belowcaptionskip=\abovecaptionskip
  \abovecaptionskip=0pt\relax\caption}
\makeatletter
\DeclareRobustCommand\nLA{\ifbf{}{\@ifstar\@@nLA\@nLA}}
\def\@nLA#1{\textsc{\lowercase{#1}}}
\def\@@nLA#1{\textsc{\@@@nLA#1\@@@nLA}}
\def\@@@nLA#1#2\@@@nLA{#1\lowercase{#2}}
\def\firstchar#1{\expandafter\@firstchar#1\firstchar}
\def\@firstchar#1#2\firstchar{#1}
\def\ifbf{\if b\firstchar\f@series\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
\def\erf{\mathop{\operator@font erf}\nolimits}
\makeatother
\def\units{\,\mathrm}
\def\keV{\units{keV}}
\def\MeV{\units{MeV}}
\def\c{{\cdot}}
\def\Rev$#1:#2 ${#2}
\def\us{\units{\mu s}}
\def\degC{\units{^\circ C}}
\def\fn{\expandafter\verb\space}
\def\var{\mathtt}

\def\calibfigure#1#2#3#4{\begin{figure}[t!]
    \centering~\hskip-0.1\textwidth
    \resizebox{1.2\textwidth}{!}{\includegraphics{#1-tvcal_pages/#1-tvcal-#2}}
    \caption{#3}\label{fig:#4}
\end{figure}}
\def\fmonefigure#1#2{\calibfigure{2016-10-05-fm1}{#1}{#2}{fm1-#1}}
\def\fmtwofigure#1#2{\calibfigure{2016-10-10-fm2}{#1}{#2}{fm2-#1}}
\def\tablecaption{\belowcaptionskip=\abovecaptionskip
  \abovecaptionskip=0pt\relax\caption}


\title{             Calibration of HET/EPT Flight Models
\\                 using data obtained in thermal Vacuum
}
\author{                   Stephan I. Böttcher
}
\date{                        2018-08-23, 
                    Revision \Rev$Revision: 6951 $
}

\begin{document}
\maketitle
\begin{figure}[h]
  \centering
  \resizebox{\textwidth}{!}{\includegraphics{2016-10-05-fm1-tvcal_pages/2016-10-05-fm1-tvcal-19}}
  \caption{\nLA{FM1} channel \nLA{C1H} summary.}
\label{fig:fm1-19}
\end{figure}
\clearpage
\tableofcontents
\listoffigures
\listoftables
\clearpage

\section{The Instrument}

This document describes the pre launch calibration of the \emph{High
  Energy Telescope} and \emph{Electron Proton Telescope} flight models
for the \emph{Energetic Particle Detector} suite on the Solar Orbiter
spacecraft (\nLA{EPD HET/EPT}).


\begin{table}[tp]
  \centering
  \tablecaption{\nLA{HET} channels}
  \label{tab:het-channels}
  \begin{tabular}{cccc}
    Name & \nLA{PA} gain & shaper gain & channel \\[5pt]
    \nLA{A11H} & $1/10\units{pF}$ & $\times 15$ &  6 \\
    \nLA{A11L} &                  & $\times  1$ &  8 \\
    \nLA{A12H} & $1/10\units{pF}$ & $\times 15$ & 21 \\
    \nLA{A12L} &                  & $\times  1$ &  9 \\
    \nLA{B11H} & $1/10\units{pF}$ & $\times 15$ &  1 \\
    \nLA{B11L} &                  & $\times  1$ &  0 \\
    \nLA{B12H} & $1/10\units{pF}$ & $\times 15$ &  2 \\
    \nLA{B12L} &                  & $\times  1$ &  3 \\
    \nLA{B13G} & $1/1\units{pF}$  & $\times 2.4$&  7 \\
    \nLA{C1H}  & $1/1\units{pF}$  & $\times 15$ &  5 \\
    \nLA{C1L}  &                  & $\times  1$ &  4 \\
    \nLA{C2H}  & $1/1\units{pF}$  & $\times 15$ & 18 \\
    \nLA{C2L}  &                  & $\times  1$ & 20 \\
    \nLA{B21H} & $1/10\units{pF}$ & $\times 15$ & 11 \\
    \nLA{B21L} &                  & $\times  1$ & 10 \\
    \nLA{B22H} & $1/10\units{pF}$ & $\times 15$ & 13 \\
    \nLA{B22L} &                  & $\times  1$ & 12 \\
    \nLA{B23G} & $1/1\units{pF}$  & $\times 2.4$& 19 \\
    \nLA{A21H} & $1/10\units{pF}$ & $\times 15$ & 16 \\
    \nLA{A21L} &                  & $\times  1$ & 17 \\
    \nLA{A22H} & $1/10\units{pF}$ & $\times 15$ & 15 \\
    \nLA{A22L} &                  & $\times  1$ & 14 \\
  \end{tabular}
\end{table}

\begin{table}[tp]
  \centering
  \tablecaption{\nLA{EPT} channels}
  \label{tab:ept-channels}
  \begin{tabular}{ccccl}
    Name     & \nLA{PA} gain & shaper gain    & channel & view\\[5pt]
    \nLA{C1} & $1/1\units{pF}$ & $\times 2.2$ &  28 & magnet $-x$\\
    \nLA{A1} &                 &              &  29 & \\
    \nLA{C2} &                 &              &  26 & foil $+x$ \\
    \nLA{A2} &                 &              &  27 & \\
    \nLA{C3} &                 &              &  24 & foil $-x$ \\
    \nLA{A3} &                 &              &  25 & \\
    \nLA{C4} &                 &              &  22 & magnet $+x$\\
    \nLA{A4} &                 &              &  23 & \\
  \end{tabular}
\end{table}

\subsection{High Energy Telescope}

\nLA*{HET} consists of four silicon \emph{Solid State Detectors}
(\nLA{SSD}) with two or three segments each, and a \emph{Bismuth
  Germanium Oxide} (\nLA{BGO}) scintillator, which is read out via two
silicon photodiodes from Hamamatsu.  The \nLA{SSD} are labeled
\nLA{A1, B1, B2}, and~\nLA{A2}.

The \nLA{A}~detectors have two segments each, \nLA{A11, A12, A21},
and~\nLA{A22}.  The \nLA{B}~detectors have in addition a third
segment, \nLA{B13} and~\nLA{B23}.  The \nLA{BGO} scintillator is
positioned between the \nLA{B}~detectors, with readout channels
\nLA{C1} and~\nLA{C2}.

All but the outermost \nLA{B}~detector segments are read out with two
gain channels, where the shaper gain differs by about a factor
of~$15$.  The full complement of readout channels is listed in
table~\ref{tab:het-channels}.

The light output of \nLA{BGO} is known to be temperature dependent,
with variations of order factor~2 over the expected temperature range.

\subsection{Electron Proton Telescope}

\nLA*{EPT} contains four \nLA{SSD} with two segments each, with single
gain readout.  The center segments are named~\nLA{C}, the outer
segments~\nLA{A}, for \emph{Anticoincidence}.
Table~\ref{tab:ept-channels} also gives the view directions.

\subsection{Readout}

The detector signals are pulses of charge emitted from silicon
detectors within a few nanoseconds.  \emph{Charge Sensitice
  Preamplifiers} (\nLA{CSA}) convert the charge pulse into a voltage
step.  The gain is defined by the inverse of the feedback capacitance.
The feedback capacitance discharges with the time constant
of~$100\us$.  Simple, single pole shapers with partial pole-zero
correction convert the voltage steps into unipolar pulses.  The shapers
provide additional gain.  Most \nLA{HET} detectors are read out with
two shapers to support a pulse height dynamic range of 16~bit.  The
shaper outputs are sampled directly by \emph{Analog to Digital
  Converters} (\nLA{ADC}) at 1 Million samples per second.  A linear
combination~$A=\sum a_is_i$ of the last 15 samples provides a digital
measure for the pulse height in every microsecond.  The coefficients
can take values from $-3\dots+3$.  The sum of the coefficients must be
is zero.  A seconds linear combination $B$ provides a measure for the
phase of the pulse with respect to the \nLA{ADC} clock.  The
coefficients used for Solar Orbiter are
\begin{eqnarray}
  \label{eq:ab-coeff}
  a_i &=& \{0, 0, 0, -3, -3, -3, -3,  1,  1,  2,  2,  3,  2,  1,  0\}, \\
  b_i &=& \{0, 0, 0,  0,  0,  0,  0, -2, -3, -1,  0,  2,  2,  1,  1\}.
\end{eqnarray}
These coefficients can be changed in flight, but there is only one set
for all channels. Any change may invalidate all previous calibration
measurements.

The electronics gain depends on the value of discrete resistors and
capacitors, the resulting time constants and pulse shapes.  Some
capacitors in the \nLA{HET} high gain channels with \nLA{X7R}
dialectric may be more temperature dependent.

\begin{table}[tp]
  \centering
  \tablecaption{Temperature ranges}
  \label{tab:temps}
  \begin{tabular}{cccc}
    Model & Filename & Temperature & Hits \\[5pt]
    \nLA{FM1} & \fn 2016-10-05-fm1-tvcal-x_-17°C & $ -17.4012\degC ± 0.0016\degC $ & 2473809 \\
    \nLA{FM1} & \fn 2016-10-05-fm1-tvcal-x_-9°C  & $  -9.0130\degC ± 0.0038\degC $ & 2799529 \\
    \nLA{FM1} & \fn 2016-10-05-fm1-tvcal-x_+6°C  & $   6.7925\degC ± 0.0034\degC $ & 3734941 \\
    \nLA{FM1} & \fn 2016-10-05-fm1-tvcal-x_19°C  & $  19.3059\degC ± 0.0032\degC $ & 3927941 \\
    \nLA{FM1} & \fn 2016-10-05-fm1-tvcal-x_30°C  & $  30.1066\degC ± 0.0029\degC $ & 3739628 \\
    \nLA{FM1} & \fn 2016-10-05-fm1-tvcal-x_41°C  & $  41.6630\degC ± 0.0020\degC $ & 5507440 \\
    \nLA{FM1} & \fn 2016-10-05-fm1-tvcal-x_46°C  & $  45.3719\degC ± 0.0094\degC $ & 1244188 \\[5pt]
    \nLA{FM2} & \fn 2016-10-13-fm2-tvcal-x_-7°C  & $  -6.9397\degC ± 0.0037\degC $ & 4524871 \\
    \nLA{FM2} & \fn 2016-10-13-fm2-tvcal-x_+7°C  & $   6.7503\degC ± 0.0026\degC $ & 4722178 \\
    \nLA{FM2} & \fn 2016-10-13-fm2-tvcal-x_+19°C & $  19.3848\degC ± 0.0035\degC $ & 5088157 \\
    \nLA{FM2} & \fn 2016-10-13-fm2-tvcal-x_+33°C & $  33.3770\degC ± 0.0024\degC $ & 6072383 \\
    \nLA{FM2} & \fn 2016-10-13-fm2-tvcal-x_+42°C & $  41.8192\degC ± 0.0032\degC $ & 3196976 \\
    \nLA{FM2} & \fn 2016-10-13-fm2-tvcal-x_+44°C & $  45.0423\degC ± 0.0021\degC $ & 5956144 \\
  \end{tabular}
\end{table}

\subsection{Thermal Vacuum Test}

Streaming mode data was obtained during calibration runs of both
flight models in thermal vacuum, with temperatures measured near the
\nLA{BGO} detector between $-17\degC$ and~$+46\degC$.  In this mode,
each particle hit detected by the sensor unit is recorded in a
\emph{Pulse Height Analysis} (\nLA{PHA}) record.  These records were
streamed together with general housekeeping data (\nLA{HK}) via the
\emph{Electronic Ground Support Equipment} (\nLA{EGSE}) into a disk
file.

The data stream was split into files covering separate temperature
ranges.  The average temperature range was computed for each
range. The full list is provided in table~\ref{tab:temps}, with the
number of particle hits recorded in each file.

\subsection{Source}

While the sensor units were tested in thermal vacuum they were
stimulated by a radioktive source of the isotope \Bi207.  The source
was placed between the \nLA{EPT} and~\nLA{HET} sensor heads.  The
prominent emission lines listed by \nLA{NuDat\,2} are summarized in
table~\ref{tab:nudat}. Electrons from the source were not able to
penetrate the housing walls and reach the detectors.  We observed the
photoeffect of the x-rays around $75\keV$, and the Compton effect of
the $\gamma$-line at $570\keV$.  Signals in the \nLA{BGO} from the
source could not be observed.

The sensor units were mounted in the chamber with vertically
orientented viewing directions.  This allowed to record the hits from
cosmic muons penetrating the \nLA{HET} detector stack including the
\nLA{BGO}.

\begin{table}[ht!]
  \centering
  \tablecaption{\Bi207 emission lines, from \nLA{NuDat2}.}
  \label{tab:nudat}
  \begin{tabular}{llrr}
    Process & Particle & Energy & Intensity \\[8pt]
    Auger K & $e^-$    & $56.7\keV$     & $2.9\,\%$   \\[3pt]
    CE K 	& $e^-$    & $481.6935\keV$ & $1.515\,\%$ \\
    CE L 	& $e^-$    & $553.8372\keV$ & $0.438\,\%$ \\
    CE M 	& $e^-$    & $565.8473\keV$ & $0.147\,\%$ \\[3pt]
    CE K 	& $e^-$    & $975.651\keV$  & $7.03\,\%$  \\ 
    CE L 	& $e^-$    & $1047.795\keV$ & $1.84\,\%$  \\ 
    CE M 	& $e^-$    & $1059.805\keV$ & $0.54\,\%$  \\[5pt] 

    XR  	& $\gamma$ & $10.6\keV$     & $33.2\,\%$  \\[3pt]
    XR  	& $\gamma$ & $72.805\keV$   & $21.4\,\%$  \\ 
    XR  	& $\gamma$ & $74.969\keV$   & $35.7\,\%$  \\[3pt]
    XR  	& $\gamma$ & $84.45\keV$    & $4.31\,\%$  \\ 
    XR  	& $\gamma$ & $84.938\keV$   & $8.27\,\%$  \\  
    XR  	& $\gamma$ & $87.3\keV$     & $3.02\,\%$  \\[5pt]

    & $\gamma$ & $569.698\keV$  & $97.76\,\%$ \\
    & $\gamma$ & $1063.656\keV$ & $74.6\,\%$  \\ 
    & $\gamma$ & $1770.228\keV$ & $6.87\,\%$
  \end{tabular}
\end{table}

\section{Calibration Fits}

For the analysis of the x-ray and Compton spectra the \nLA{PHA} data
were filtered by selecting all records where exactly one detector
segment has seen energy above a noise threshold.  These signals were
accumulated into differential spectra with linear constant binning.
The bin width was selected to cover the differential nonlinearity
resulting from the \nLA{ADC} resolution.

The scale on the pulse height axis is~$\units{mV}$, an aproximation of
the shaper output pulse heigth.  The data records yield pulse height
in units of~$A$.  Folding the nominal pulse shape with the $a_i$
coefficients yields $A=7.873$ for a unit height input pulse.  The
\nLA{ADC} resolution is $3.3\units{V}/2^{12}$.  This combines to the
$\units{mV}$ scale
\begin{equation}
  \label{eq:mV}
  7.873 \times \frac {4096}{3300\units{mV}} = 9.772 \frac A{\units{mV}}.
\end{equation}
Models for the spectral shapes were fitted to the histograms, yielding
among other parameters the calibration factors~$\var e$ in units
$[\var e] = 1\units{mV/keV}$ for the respective detector channel
and temperature.

Similar analysis of the \nLA{BGO} signals is described below in
section~\ref{sec:bgo}.

\subsection{Gnuplot}

The fitting of spectral models was done with Gnuplot version~5.3.  For
each flight model a large script with more than 1000 lines of code was
written.  Functions for the models were defined, channel names and
numbers defined, filenames and temperature ranges, initial values for
all parameters, plots, fits and text output.  Fit results are appended
to a results file, which is read at the next invocation of the script.
Commandline parameters are parsed to control what the invocation of
the script shall perform.

\subsubsection{Invocation}

Without parameters, the script will just print a calibration file
using the data from the current results file.  The first argument may
be \texttt{print}, \texttt{plot}, \texttt{pause}, or \texttt{fit}.
The commands \texttt{print} and \texttt{plot} accept a second argument
for the output filename.  \texttt{print} will print the calibration
file.  \texttt{plot} will draw all plots, optionally into a file.
\texttt{pause} will draw on the screen, pausing after each plot.
\texttt{fit} implies \texttt{plot} and will perform all fits with the
results drawn to the screen.

The printed calibration files are in a format that can be included
into the \nLA{L3}-Trigger code.  They are appended in sections
\ref{sec:fm1-calib} and~\ref{sec:fm2-calib}.

\subsubsection{Fit}

Gnuplot uses the nonlinear least-squares Marquardt-Levenberg
algorithm.  We used the options
\begin{quote}
  \texttt{set fit errorvar noerrorscaling}.
\end{quote}
The bin data is assumed to be Poisson distributed.  The fit can assume
that the provided errors are real, and do not need to be scaled by the
reduced~$\chi^2$ to calculate the errors.  The resulting errors in the
parameters were also saved in the results file.

\subsection{Spectral Models}

This section describes the Gnuplot functions that model the shape of
the spectra.

\subsubsection{X-rays}

X-ray lines in the spectra were modeled with a Gauss distribution
\begin{equation}
  \label{eq:pk(x)}
  f_\mathrm{pk}(\var a, \var e, \var s, \ x) = \var a \,\exp(-\frac{(x - \var e)^2}{2\var s^2}).
\end{equation}
The group of five x-ray lines was modeled as the sum of five such
peaks with a common set of three scaled parameters
\begin{equation}
  \label{eq:xray-model}
  \begin{array}{rcl}
  f_\mathrm{xray}(\var{a_x}, \var{e_x}, \var{s_x}, \ x)
  &=& \sum_{i=1}^5 f_\mathrm{pk}(S_iI_i\,\var{a_x}, E_i\,\var{e_x}, \var{s_x}, \ x) \\
  &=& f_\mathrm{pk}(1 \times 35.7\times\var{a_x}, 74.969\times\var{e_x}, \var{s_x}, \ x) \\
  &+& f_\mathrm{pk}(1 \times 23.7\times\var{a_x}, 72.805\times\var{e_x}, \var{s_x}, \ x) \\
  &+& f_\mathrm{pk}(0.65 \times 8.27\times\var{a_x},  84.938\times\var{e_x}, \var{s_x}, \ x) \\
  &+& f_\mathrm{pk}(0.65 \times 4.31\times\var{a_x},  84.45\times\var{e_x}, \var{s_x}, \ x) \\
  &+& f_\mathrm{pk}(0.65 \times 3.02\times\var{a_x},  87.3\times\var{e_x}, \var{s_x}, \ x),
  \end{array}
\end{equation}
where the intensities $I_i$ for the higher energy peaks
$E_i \approx 85\units{keV}$ are scaled with the relative photo
crossection~$S_i$.

Two background terms are added to the spectrum.  The gamma Compton
background is modeled with an exponential slope.  These are mostly
high energy Compton electrons that leak out of the detector.
\begin{equation}
  \label{eq:bg(x)}
  f_\mathrm{bg}(\var a, \var e, \var s, \ x) = \var a \,\exp(-\frac{x - \var e}{\var s}).
\end{equation}
At about
$58\keV$ we observed a peak from Compton backscatter.  This appears
when there is matter downstream from the source behind the detector.
It is the photoeffect peak of $75\keV$ x-rays that were scattered
back into the detector by $180^\circ$.
\begin{equation}
  \label{eq:xray-spec}
  \begin{array}{rcl}
    \multicolumn{3}{l}{
  f_\mathrm{spectrum}(\var{a_x}, \var{e_x}, \var{s_x}, \ \var{a_b},
    \var{e_b}, \var{s_b}, \ \var{b_a}, \var{b_s}, \ x)} \\
    \qquad\qquad 
  &=& f_\mathrm{xray}(\var{a_x}, \var{e_x}, \var{s_x}, \ x) \\
  &+& f_\mathrm{bg}(\var{b_a}, 74.969\times\var{e_x}, \var{b_s}, \ x) \\
  &+& f_\mathrm{pk}(35.7\times\var{a_b}, 74.969\times\var{e_b}, \var{s_b}, \ x) \\
  &+& f_\mathrm{pk}(23.7\times\var{a_b}, 72.805\times\var{e_b}, \var{s_b}, \ x).
  \end{array}
\end{equation}

\fmonefigure{01}{\nLA{FM1} \nLA{EPT} channel \nLA{C1} x-rays fits.}
\fmonefigure{09}{\nLA{FM1} \nLA{EPT} channel \nLA{C1} compton fits.}
\fmonefigure{17}{\nLA{FM1} \nLA{EPT} channel calibration versus temperature fits.}
\fmonefigure{18}{\nLA{FM1} \nLA{EPT} global calibration versus temperature fit.}
\fmonefigure{48}{\nLA{FM1 HET} channel \nLA{A11} high to low gain ratio.}
\fmonefigure{57}{\nLA{FM1 HET} channel high to low gain ratio temperature coefficient.}
\fmonefigure{21}{\nLA{FM1 HET BGO} landau fits of \nLA{B1--B2} coincidence spectra.}
\fmonefigure{22}{\nLA{FM1 HET BGO} \nLA{B1--B2} coincidence temperature dependence.}
\fmonefigure{23}{\nLA{FM1 HET BGO} landau fit of the $0\degC$ \nLA{A1--B1--B2--A2} coincidence spectrum.}
\fmonefigure{24}{\nLA{FM1 HET C1H} silocon hit to light ratio.}
\fmonefigure{27}{\nLA{FM1 HET C2L} low gain to high gain ratio.}
\fmonefigure{28}{\nLA{FM1 HET BGA} high gain to low gain ratio temperature dependence.}

\subsubsection{Compton Edges}

Two gamma lines produce measurable Compton spectra.  We only used
the line at $E_\gamma = 569.698 \keV$.  The Compton edge energy is
$E = 393.306\keV$.  These Compton electrons have significant
probability to leave the detector with unseen energy.  In some
geometries, background from leaking electrons is suppressed by the
anticoincidence condition applied during filtering.  The higher
energy gammas provide additional background.

The Compton edge model is a constant plus error function,
multiplied with an exponential background slope
\begin{equation}
  \label{eq:compton-spec}
  \begin{array}{rcl}
    \multicolumn{3}{l}{
    f_\mathrm{compton}(\var{a_c}, \var{e_c}, \var{s_c}, \ \var{b_a}, \var{b_s}, \ x)} \\
    \qquad\qquad 
    &=& \displaystyle
        \left( 1 + \frac{\var{a_c}}{2\var{b_a}}\erf\left(-\frac{x -
        393.306\keV\times\var{e_c}}{\var{s_c}}\right) \right) \\
    &\times& f_\mathrm{bg}(\var{b_a}, 393.306\keV\times\var{e_c}, \var{b_s}, \ x).
  \end{array}
\end{equation}

\subsection{\nLA{EPT} calibration}

Figures~\ref{fig:fm1-01} and~\ref{fig:fm1-09} show the x-ray and
compton fits for \nLA{FM1 EPT} channel~\nLA{C1}.  The x-ray fit was
applied with five parameters $\var{a_x}, \var{e_x}, \var{s_x}, \
\var{b_a}, \var{b_s}$.  The backscatter peak was included with scaled
x-rays parameters
\begin{equation}
  \label{eq:ept-xray-fit}
  \begin{array}{rcl}
    \multicolumn{3}{l}{
    f_\mathrm{fit}(\var{a_x}, \var{e_x}, \var{s_x}, \ \var{b_a}, \var{b_s}, \ x)} \\
    \qquad\qquad
    &=& f_\mathrm{spectrum}(\var{a_x}, \var{e_x}, \var{s_x}, \ \var{a_x}/5,
        \var{e_x}\times 1.05, \var{s_x}\times6, \ \var{b_a}, \var{b_s}, \ x). \\
  \end{array}
\end{equation}
The scaling factors were optained from attempts to fit the backscatter
background parameters as well.  When those attempts turned out to
cause very unstable fits, the scaling from a few sucessful fits was
kept fixed.

The Compton edge fit was run with all five parameters of the model function
\begin{equation}
  \label{eq:ept-compton-fit}
  f_\mathrm{compton}(\var{a_c}, \var{e_c}, \var{s_c}, \ \var{b_{ca}}, \var{b_{cs}}, \ x)
\end{equation}
The lines in the results file for this channel at $T=-17\degC$ are
\begin{quote}\footnotesize
\begin{verbatim}
FM1_C1_ax_1  =    20.6854; FM1_C1_ax_err_1  =   0.598123 # -17 °C 1
FM1_C1_ex_1  =  0.0998296; FM1_C1_ex_err_1  = 0.000118248 # -17 °C 1
FM1_C1_sx_1  =   0.278013; FM1_C1_sx_err_1  = 0.00743099 # -17 °C 1
FM1_C1_ba_1  =    287.042; FM1_C1_ba_err_1  =    4.54856 # -17 °C 1
FM1_C1_bs_1  =    8.24689; FM1_C1_bs_err_1  =   0.381411 # -17 °C 1
FM1_C1_bca_1 =    22.2573; FM1_C1_bca_err_1 =   0.793088 # -17 °C 1
FM1_C1_bcs_1 =     18.999; FM1_C1_bcs_err_1 =    1.12095 # -17 °C 1
FM1_C1_ac_1  =    25.3387; FM1_C1_ac_err_1  =    1.77736 # -17 °C 1
FM1_C1_ec_1  =   0.100997; FM1_C1_ec_err_1  = 0.000376188 # -17 °C 1
FM1_C1_sc_1  =   0.688061; FM1_C1_sc_err_1  =   0.284948 # -17 °C 1
\end{verbatim}
\end{quote}
The $\var{e_x}$ and $\var{e_c}$ parameters directly provide the
desired calibration, in units $\units{mV/keV}$.  The parameter
$\var{s_x}$ provides the width~$\sigma_\mathrm x$ of the x-ray peaks
\begin{equation}
  \label{eq:sigma}
  \sigma_\mathrm x = \frac{\var{s_x}}{\var{e_x}}.
\end{equation}
The calibration results seem to have large random uncertainties.  To
further reduce these uncertainties, the calibration factors were
fitted to a polynom of degree~2 in the
temperature~$T$.  Figure~\ref{fig:fm1-17} shows the fits of each
\nLA{EPT} channel, including both the x-ray and Compton factors.
Figure~\ref{fig:fm1-18} shows a global fit of all channels.

For the final calibration of \nLA{EPT} we take the value of the fit
function at $T=0\degC$ for each channel, and multiply the temperature
depended factor from the global fit.  The \nLA{L3}-trigger needs to
convert from $A$-scale to~$\keV$, so we need to provide the inverse of
our calibration parameters scaled back to the $A$-scale
\begin{equation}
  \label{eq:cal-scale}
  \mathrm{calib} = \frac{1}{9.772\times\var e}.
\end{equation}
The calibration file section for \nLA{FM1 EPT} is
\begin{quote}\footnotesize
\begin{verbatim}
FM1_EPT_TC = 1.0 / (1 + T_HET1*(-9.756e-05 +7.456e-06*T_HET1))
FM1_C1_calib = 1.005 * FM1_EPT_TC
FM1_C2_calib = 0.992 * FM1_EPT_TC
FM1_C3_calib = 0.990 * FM1_EPT_TC
FM1_C4_calib = 1.009 * FM1_EPT_TC
FM1_A1_calib = 0.988 * FM1_EPT_TC
FM1_A2_calib = 1.013 * FM1_EPT_TC
FM1_A3_calib = 1.004 * FM1_EPT_TC
FM1_A4_calib = 1.003 * FM1_EPT_TC

FM2_EPT_TC = 1.0 / (1 + T_HET1*(0.0001453 +5.111e-06*T_HET1))
FM2_C1_calib = 0.990 * FM2_EPT_TC
FM2_C2_calib = 1.006 * FM2_EPT_TC
FM2_C3_calib = 0.978 * FM2_EPT_TC
FM2_C4_calib = 0.984 * FM2_EPT_TC
FM2_A1_calib = 1.037 * FM2_EPT_TC
FM2_A2_calib = 0.997 * FM2_EPT_TC
FM2_A3_calib = 0.998 * FM2_EPT_TC
FM2_A4_calib = 0.997 * FM2_EPT_TC
\end{verbatim}
\end{quote}
The variable \verb+T_HET1+ will be initialized to the temperature
expected on the \nLA{BGO} detector in the phase of the orbit where the
resulting unit configuration shall be used.

\subsection{\nLA{HET} calibration of the \nLA{SSD}}

The calibration of the high gain channels of the \nLA{HET SSD}
detectors was done very similar to the \nLA{EPT} calibration.  The
results are:
\begin{quote}\footnotesize
\begin{verbatim}
FM1_HET_HG_TC = 1.0 / (1 + T_HET1*(0.0008845 -1.236e-05*T_HET1))
FM1_A11H_calib = 1.343 * FM1_HET_HG_TC
FM1_A12H_calib = 1.330 * FM1_HET_HG_TC
FM1_A21H_calib = 1.329 * FM1_HET_HG_TC
FM1_A22H_calib = 1.366 * FM1_HET_HG_TC
FM1_B11H_calib = 1.299 * FM1_HET_HG_TC
FM1_B12H_calib = 1.336 * FM1_HET_HG_TC
FM1_B3_TC = 1.0 / (1+0.0001472*T_HET1)
FM1_B13G_calib = 1.132 * FM1_B3_TC
FM1_B23G_calib = 1.170 * FM1_B3_TC

FM2_HET_HG_TC = 1.0 / (1 + T_HET1*(0.0006021 -3.981e-06*T_HET1))
FM2_A11H_calib = 1.349 * FM2_HET_HG_TC
FM2_A12H_calib = 1.329 * FM2_HET_HG_TC
FM2_A21H_calib = 1.493 * FM2_HET_HG_TC
FM2_A22H_calib = 1.344 * FM2_HET_HG_TC
FM2_B11H_calib = 1.304 * FM2_HET_HG_TC
FM2_B12H_calib = 1.406 * FM2_HET_HG_TC
FM2_B3_TC = 1.0 / (1+0.0001075*T_HET1)
FM2_B13G_calib = 1.125 * FM2_B3_TC
FM2_B23G_calib = 1.173 * FM2_B3_TC
\end{verbatim}
\end{quote}
The detectors \nLA{B21} and~\nLA{B22} were not sufficiently
illuminated by the source during thermal vacuum testing, no fits could
be obtained.  For those channels we use a room temperature
calibration and apply the common temperature dependence.
\begin{quote}\footnotesize
\begin{verbatim}
FM1_B21H_calib2 = 1.290 # HET compton pos 1
FM1_B22H_calib2 = 1.291 # HET compton pos 1

FM2_B21H_calib2 = 1.314 # HET compton pos 1
FM2_B22H_calib2 = 1.316 # HET compton pos 1
\end{verbatim}
\end{quote}

\subsubsection{HET Low Gain}

The calibration of the low gain channels is obtained from the weighted
mean of the high to low gain ratio using signals with at least
$500\units{mV}$ in the high gain. Figure~\ref{fig:fm1-48}.  Individual
fits for each channel were used to obtain a ratio at $0\degC$.  A
common fit for all \nLA{SSD} channels yields a temperature dependence
model, Figure~\ref{fig:fm1-57}.  The calibration file section is
\begin{quote}\footnotesize
\begin{verbatim}
FM1_HET_HL_TC = 1.0 / (1 + T_HET1*(0.0009727 -1.988e-05*T_HET1))
FM1_A11L_calib = FM1_A11H_calib * 13.843 * FM1_HET_HL_TC
FM1_A12L_calib = FM1_A12H_calib * 13.797 * FM1_HET_HL_TC
FM1_A21L_calib = FM1_A21H_calib * 13.655 * FM1_HET_HL_TC
FM1_A22L_calib = FM1_A22H_calib * 13.832 * FM1_HET_HL_TC
FM1_B11L_calib = FM1_B11H_calib * 13.866 * FM1_HET_HL_TC
FM1_B12L_calib = FM1_B12H_calib * 13.852 * FM1_HET_HL_TC
FM1_B21L_calib = FM1_B21H_calib * 14.236 * FM1_HET_HL_TC
FM1_B22L_calib = FM1_B22H_calib * 13.804 * FM1_HET_HL_TC

FM2_HET_HL_TC = 1.0 / (1 + T_HET1*(0.0003531 -8.021e-06*T_HET1))
FM2_A11L_calib = FM2_A11H_calib * 13.890 * FM2_HET_HL_TC
FM2_A12L_calib = FM2_A12H_calib * 13.782 * FM2_HET_HL_TC
FM2_A21L_calib = FM2_A21H_calib * 12.763 * FM2_HET_HL_TC
FM2_A22L_calib = FM2_A22H_calib * 13.485 * FM2_HET_HL_TC
FM2_B11L_calib = FM2_B11H_calib * 14.157 * FM2_HET_HL_TC
FM2_B12L_calib = FM2_B12H_calib * 13.466 * FM2_HET_HL_TC
FM2_B21L_calib = FM2_B21H_calib * 13.908 * FM2_HET_HL_TC
FM2_B22L_calib = FM2_B22H_calib * 13.874 * FM2_HET_HL_TC
\end{verbatim}
\end{quote}

\subsection{\nLA{HET} calibration of the \nLA{BGO}}
\label{sec:bgo}

The light yield of the \nLA{BGO} scintillator varies by a factor two
over the calibration temperature range.  The calibration involved two
steps.  The temperature dependence was obtained from muon signals with
a \nLA{B1--B2} coincidence, with a landau model fit to the spectra
of the sum of \nLA{C1H} and \nLA{C2H} for each temperature,
Figure~\ref{fig:fm1-21}.

The function $f_\mathrm{MIPS}$ to model the landau distribution from
muon hits is 
\begin{equation}
  \label{eq:landau-spec}
  \begin{array}{rcl}
    f_\mathrm{MIPS}(\var a, \var e , \var s, \ x)
    &=& \displaystyle \var a \, f_\mathrm{Landau}\left(\frac{x-\var e}{\var s}\right) \\[15pt]
    f_\mathrm{Landau}(x)
    &=& \displaystyle \sqrt{\frac{\exp(-x-\exp(-x))}{2\pi}}
  \end{array}
\end{equation}
The \nLA{B1--B2} temperature curve was used to intercalibrate the
muons hits triggered in \nLA{A1--B1--B2--A2} coincidence and calibrate
all hits to a $0\degC$ value.  The fit of the resulting spectrum was
compared to a Monte Carlo spectrum with the same trigger condition to
obtain an absolute energy calibartion at $0\degC$.  The fit of
$f_\mathrm{MIPS}$ to a Geant4 Monte Carlo muon spectrum predicts the
peak position at $\var e = 18.024\units{MeV}$.

Silicon hits are signals from particle hitting the photodiodes that
read out the \nLA{BGO} light.  The solicon hit calibration of the
\nLA{C1H} channel was obtained in the same way as the \nLA{SSD}
calibrations.  The second diode \nLA{C2H} was shielded from the source
by the \nLA{BGO} crystal.  Fig.~\ref{fig:fm1-24} show the radio of the
silicon hit to light calibration.  (This is not used for inflight data
processing.)

Finally, the high gain to low gain ratio was obtained as for the
\nLA{SSD} channels.  Figures \ref{fig:fm1-27} and~\ref{fig:fm1-28}.
The calibration file sections are:
\begin{quote}\footnotesize
\begin{verbatim}
FM1_C1H_SiH_calib = 0.168 / (1+T_HET1*(0.001139 -2.152e-05*T_HET1))
FM1_BGO_calib = 18.785 / (1 - T_HET1*(0.007869 -1.31e-05*T_HET1))
FM1_BGO_L_calib = FM1_BGO_calib * 13.927 * (1 + T_HET1*(0.000915 -1.823e-05*T_HET1))

FM2_C1H_SiH_calib = 0.166 / (1+T_HET1*(0.000907 -1.598e-05*T_HET1))
FM2_BGO_calib = 17.404 / (1 - T_HET1*(0.007486 +3.396e-05*T_HET1))
FM2_BGO_L_calib = FM2_BGO_calib * 13.854 * (1 + T_HET1*(0.0008645 -1.927e-05*T_HET1))
\end{verbatim}
\end{quote}
We use the same calibration for \nLA{C1} and~\nLA{C2}, since only the
sum is used as a measure of the deposited energy in~\nLA{BGO}.

\clearpage

\section{Gnuplot Scripts and Results}
\label{sec:scripts}

\lstset{literate=
  {±}{{\ensuremath{\pm}}}1
  {²}{{\ensuremath{^2}}}1
  {µ}{{\ensuremath{\mu}}}1
  {°}{{\ensuremath{^\circ}}}1
  {¯}{{\ensuremath{^-}}}1
  {σ}{{\ensuremath{\sigma}}}1
  {×}{{\ensuremath{\times}}}1,
  basicstyle=\tiny,
  breaklines=true, keepspaces=true, showstringspaces=false,
  numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=10pt
}


\subsection{FM1 calibration}
\label{sec:fm1-calib}
\lstinputlisting{2016-10-05-fm1-tvcal-calibration.txt}

\subsection{FM2 calibration}
\label{sec:fm2-calib}
\lstinputlisting{2016-10-13-fm2-tvcal-calibration.txt}

\clearpage
\subsection{FM room temperature calibration}
\label{sec:fm-rt-calib}
\lstinputlisting{hetept_fm_cal_bi207.txt}

\clearpage
\subsection{FM1 results}
\label{sec:fm1-results}
\lstinputlisting{2016-10-05-fm1-tvcal-calibration.results}

\clearpage
\subsection{FM2 results}
\label{sec:fm2-results}
\lstinputlisting{2016-10-13-fm2-tvcal-calibration.results}

\clearpage
\subsection{FM room temperature results}
\label{sec:fm-rt-calib}
\lstinputlisting{hetept_fm_cal_bi207.results}

\clearpage
\subsection{FM1 Script}
\label{sec:fm1-script}
\lstinputlisting[language=Gnuplot]{2016-10-05-fm1-tvcal-calibration.gpt}

\clearpage
\subsection{FM2 Script}
\label{sec:fm2-script}
\lstinputlisting[language=Gnuplot]{2016-10-13-fm2-tvcal-calibration.gpt}

\clearpage
\subsection{FM room temperature Script}
\label{sec:fm-rt-calib}
\lstinputlisting{hetept_fm_cal_bi207.gpt}

\end{document}
