\documentstyle{article}

\setlength{\headheight}{0cm}
\setlength{\textheight}{20cm}

\begin{document}
Let's assume there are source spectral files which you want to
combine, 
$$
S_1\_spec, S_2\_spec,  ,, {\rm and}\; S_n\_spec,
$$
and these files have the EXPOSURE values
$$
X_1, X_2,, \;{\rm and}\, X_n,
$$
and BACKSCAL values
$$
Y_1, Y_2,, \;{\rm and}\, Y_n,
$$
respectively.  These spectral files should have the unit
COUNTS (not COUNTS/sec), as expected being produced with standard
HEASARC software packages.

Corresponding background files are
$$
B_1\_spec, B_2\_spec,, \;{\rm  and}\;  B_n\_spec,
$$
which have the EXPOSURE values
$$
X'_1, X'_2,, \;{\rm and}\; X'_n,
$$
and BACKSCAL values
$$
Y'_1, Y'_2,,  \;{\rm and}\; Y'_n,
$$
respectively.

For each pair of the source and background spectral files,
XSPEC calculates the following quantities to be fitted with  models.
\begin{eqnarray*}
\frac{S_1\_spec}{X_1} - \frac{Y_1}{Y'_1}\frac{B_1\_spec}{X'_1},\\
\frac{S_2\_spec}{X_2} - \frac{Y_2}{Y'_2}\frac{B_2\_spec}{X'_2},\\
...,\\
\frac{S_n\_spec}{X_n} - \frac{Y_n}{Y'_n}\frac{B_n\_spec}{X'_n}.
\end{eqnarray*}

From these quantities,  one can make a single quantity,
$$
\frac{S_1\_spec+S_2\_spec,,+S_n\_spec}{X_1+X_2+,,+X_n}-
$$
\begin{equation}
\frac{1}{X_1+X_2+,,+X_n}\left\{ 
\frac{X_1}{X'_1}\frac{Y_1}{Y'_1}B_1\_spec+
\frac{X_2}{X'_2}\frac{Y_2}{Y'_2}B_2\_spec+
,,+
\frac{X_n}{X'_n}\frac{Y_n}{Y'_n}B_n\_spec 
\right\}.  
\label{a}
\end{equation}
This is the quantity we should make to be fitted with  models.

With {\tt mathpha},
$S_1\_spec, S_2\_spec,  ,, {\rm and}\; S_n\_spec$
can be summed with the option ``exposure=CALC" and ``backscal=NONE"
(or ``backscal=1"), so that the combined spectrum has the EXPOSURE
value $X_1+X_2+,,+X_n$ and the BACKSCAL value unity.

Let's put the weights for the background spectra to combine with
$C_1, C_2,,, C_n$ and the BACKSCAL value for the
combined background spectrum $(BACKSCAL)_{bgd}$.
With the option ``exposure=CALC", the EXPOSURE of the
combined background spectrum will be 
$$C_1 X_1'+C_2 X_2'+,,+C_n X_n'.$$
By properly choosing $C_1, C_2,,, C_n$,
as shown below, this can be made equal to the
desirable EXPOSURE value, $$X_1'+X_2'+,,+X_n'.$$
So we have, 
\begin{equation}
C_1 X_1'+C_2 X_2'+,,+C_n X_n' = X_1'+X_2'+,,+X_n'.
\label{c}
\end{equation}

Consequently if the combined background spectrum thus made
is subtracted from the
combined source spectrum, XSPEC calculates the quantity,
$$
\frac{S_1\_spec+S_2\_spec,,+S_n\_spec}{X_1+X_2+,,+X_n}-
$$
\begin{equation}
\frac{1}{X_1'+X_2'+,,+X_n'}
\frac{1}{(BACKSCAL)_{bgd}}(C_1 B_1\_spec+C_2 B_2\_spec+,,+C_n B_n\_spec).
\label{b}
\end{equation}

The values (\ref{a}) and (\ref{b}) should agree.  Hence we have,
\begin{eqnarray}
C_1 = (BACKSCAL)_{bgd} \left(\frac{X_1'+X_2'+,,X_n'}{X_1+X_2+,,X_n}\right)\left(\frac{X_1}{X_1'}\right)\left(\frac{Y_1}{Y_1'}\right),\nonumber\\
C_2 = (BACKSCAL)_{bgd} \left(\frac{X_1'+X_2'+,,X_n'}{X_1+X_2+,,X_n}\right)\left(\frac{X_2}{X_2'}\right)\left(\frac{Y_2}{Y_2'}\right),\nonumber\\
..., \nonumber\\
C_n = (BACKSCAL)_{bgd} \left(\frac{X_1'+X_2'+,,X_n'}{X_1+X_2+,,X_n}\right)\left(\frac{X_n}{X_n'}\right)\left(\frac{Y_n}{Y_n'}\right)
\label{d}
\end{eqnarray}
Equation (\ref{c}) and equations (\ref{d}) can be solved for $(BACKSCAL)_{bgd}$ and $C_1, C_2,,C_n$.
Then finally, we get,
\begin{eqnarray*}
(BACKSCAL)_{bgd} = \frac{X_1+X_2+,,,+X_n}{X_1(Y_1/Y_1')+X_2(Y_2/Y_2')+,,+X_n(Y_n/Y_n')} \\
C_1 = \frac{X_1'+X_2'+,,,+X_n'}{X_1(Y_1/Y_1')+X_2(Y_2/Y_2')+,,+X_n(Y_n/Y_n')}\left(\frac{X_1}{X_1'}\right)\left(\frac{Y_1}{Y_1'}\right) \\
C_2 = \frac{X_1'+X_2'+,,,+X_n'}{X_1(Y_1/Y_1')+X_2(Y_2/Y_2')+,,+X_n(Y_n/Y_n')}\left(\frac{X_2}{X_2'}\right)\left(\frac{Y_2}{Y_2'}\right) \\
,,, \\
C_n = \frac{X_1'+X_2'+,,,+X_n'}{X_1(Y_1/Y_1')+X_2(Y_2/Y_2')+,,+X_n(Y_n/Y_n')}\left(\frac{X_n}{X_n'}\right)\left(\frac{Y_n}{Y_n'} \right).
\end{eqnarray*}
These are the values you need to ensure the correct amount of background subtraction. 

\end{document}







