Tiara-Barrel Calibration

Generalised Outline
The Tiara Barrel detector is calibrated using the "CalibrateBarrel.C" script, located in the T40 GitHub repository (/path/to/T40/Barrel/Calibration/).

The main function has 3 input parameters:
 * 1) The path to the triple alpha calibration ROOT file
 * 2) The path to the matchsticks calibration coefficients
 * 3) The path to the FittingBounds file

Within a ROOT session, the calibration script should be run by typing ".x ./path/to/CalibrateBarrel.C+".

The first time the script is ran it produces a new ROOT file containing histograms made from the data in the triple alpha ROOT file, which are subsequently used to find the calibration coefficients. This is explained in more details in section 2 below.

Running CalibrateBarrel.C the first time
This file has a name specified by the plotsFileName variable, and is created with the CreateFileToCalibrate function.

Deriving Ebarrel(Q,P)
The energy deposited by a particle in the Barrel is given by: $$ E_{barrel} = [(aU+b)+(cD+d)](1-e(k^{2}-P(U,D)^{2})) $$ where $$U$$ and $$D$$ are the upstream and downstream channel numbers of the event in question, $$P(U,D)$$ is the relative position of the event along the resistive strip, and the constants $$a$$, $$b$$, $$c$$, $$d$$, $$e$$ and $$k$$ represent the upstream gain, the upstream offset, the downstream gain, the downstream offset, the ballistic deficit correction, and the factor that normalises the ballistic deficit correction, respectively.

However, $$U$$ and $$D$$ is not necessarily the best parametrisation for the analysis of Barrel energies. Instead one can parametrise the energy using the quantities $$P$$ and $$Q$$, defined as follows: $$ Q = U + D \qquad\qquad\qquad P = \frac{U-D}{U+D} = \frac{U-D}{Q} $$ Here, $$Q$$ represents the energy sum and $$P$$ represents the relative position along the strip that the event occurred. These quantities are properties of both upstream and downstream ends of the resistive strip, which is much more useful when considering resistive strips, rather than $$U$$ and $$D$$ which are properties of the individual ends of the resistive strip and, by the nature of the way resistive strips work, don't mean much in isolation.

One can derive a formula for the energy deposited in the Barrel in terms of $$P$$ and $$Q$$ by first defining $$U$$ and $$D$$ in terms of $$P$$ and $$Q$$: $$ PQ = U-D = U-D+D-D = Q-2D $$

$$ \therefore \qquad D = \frac{Q}{2}(1-P) \qquad \& \qquad U = \frac{Q}{2}(1+P) $$ Substituting these formulae for $$U$$ and $$D$$ into the equation for $$E_{barrel}$$ above yields: $$ E_{barrel} = \left [ \left (a\left ( \frac{Q}{2}(1+P)\right ) +b \right )+ \left (c \left ( \frac{Q}{2}(1-P)\right )+d \right ) \right](1-e(k^{2}-P^{2}) $$

$$ \therefore \qquad E_{barrel} = \left [ \left (\frac{aQ}{2} + \frac{aQP}{2} + b + \frac{cQ}{2} - \frac{cQP}{2} + d \right ) \right](1-e(k^{2}-P^{2}) $$

$$ \therefore \qquad E_{barrel} = \frac{Q}{2} (P(a-c)+a+c+b+d)(1-e(k^{2}-P^{2}) $$ With this functional form of $$E_{barrel}$$, one can now rearrange the above formula to find an alternate expression for the energy sum $$Q$$: $$ \therefore \qquad Q = \frac{E}{1-e(k^{2}-P^{2})} \frac{2}{(P(a-c)+a+c+b+d)} $$ It is this formula utilised in the "CalculateEnergySum" function of the Barrel Calibration code, when calculating the total energy sum of an event in the Barrel.

Relation between PMatchstick and PCalibration
In the NPTOOL Barrel analysis the Matchsticked Upstream and Downstream energies (UMS, DMS) are only used as an intermediate calculation to store the final values, i.e. UC, DC, used throughout the analysis. However, these values (UMS, DMS) are the ones used to calculate the PMS vs QMS plane that is primarily used during the calibration to calculate gains offset and Ballistic Deficit Amplitude. In particular, the PMS is used to determine what is the amount of Ballistic Deficit correction that will be applied at the resistive position in question. Since PMS is calculated from UMS and DMS, this leaves us with several choices:
 * Change the code design of the NPTOOL class and store the MS values to use later in the analysis, in other words, add an extra TTiaraBarrelData object.
 * Constructing the PC, QC from (UC, DC) and add another layer of Calibration this time on the new PC vs QC plane.

The first option was chosen. It is the easiest and can be added is a less perturbative way to the code of analysis.