\documentclass[10pt]{article} \usepackage{a4} \usepackage{amsmath} \oddsidemargin=0pt % No extra space wasted after first inch. \evensidemargin=0pt % Ditto (for two-sided output). \topmargin=0pt % Same for top of page. \headheight=0pt % Don't waste any space on unused headers. \headsep=0pt \textwidth=16cm % Effectively controls the right margin. \textheight=24cm \begin{document} \centerline{\Large \bf Notes on TPG} \bigskip \centerline{\large May 2016} \section{Optimisation of layer weights} Each event $e$ gives some values $d_{e,i}$ of the deposited energy in layer $i$; these can be in any units, e.g. MIPs. Assume these are to be multiplied by some constant coefficients $a_i$ (which are approximately the integrated dE/dx values if the $d_{e,i}$ are in MIPs) to give the estimate of the incoming EM photon or electron energy. Hence, the energy estimation for event $e$ is $$E_e = \sum_i a_i d_{e,i}$$ To find the optimal coefficients, then we need to know the truth energy per event $T_e$. For a given set of coefficients, the RMS$^2$ of the energy around the truth value is given by $$\mathrm{RMS}^2 = \frac{1}{N} \sum_e (E_e - T_e)^2 = \frac{1}{N} \sum_e \left(\sum_i a_i d_{e,i} - T_e\right)^2$$ This can be thought of as similar to a chi-squared; we want to minimise this expression. If all the $a_i$ are considered as independent parameters (so 28 for the EE only), then explicitly $$\frac{\partial \mathrm{RMS}^2}{\partial a_j} = \frac{1}{N} \sum_e 2d_{e,j} \left(\sum_i a_i d_{e,i} - T_e\right) = \frac{2}{N} \sum_i a_i \left(\sum_e d_{e,j} d_{e,i} \right) - \frac{2}{N} \sum_e d_{e,j} T_e$$ Hence, for the minimum, we require $$\sum_i \frac{\sum_e d_{e,j} d_{e,i}}{N} a_i = \frac{\sum_e d_{e,j} T_e}{N}$$ Writing in matrix notation with $M$ and $v$ defined as $$M_{ji} = \frac{\sum_e d_{e,j} d_{e,i}}{N},\qquad v_j = \frac{\sum_e d_{e,j} T_e}{N}$$ then the requirement is $$M a = v\qquad\mathrm{so}\qquad a = M^{-1}v$$ Inverting the large matrix $M$ is required to give the solution for the optimal $a_i$. Note, $M$ is similar (but not identical) to the error matrix of the $d_i$. \section{Units} Keeping quantities to 16-bit integers. The FE ASIC works in fC with an overall LSB of 0.1\,fC and upper range of 10\,pC $= 10^4$\,fC. This requires 17 bits total (although represented as a 10-bit and a 12-bit pair of values. Reconstructed energy (not deposited energy) with an LSB of 10\,MeV and 16-bit unsigned representation gives a maximum energy of 655\,GeV. These are initially MIPS $\times \int (dE/dx)\,dx$ for each layer until after forming the 3D clusters when the total energy is set more exactly. Position in $x$ and $y$ with an LSB of 100\,$\mu$m and a 16-bit signed representation gives a range of $\pm 328$\,cm (with $\pm 190$\,cm required). If needed, $z$ can be represented in a 16-bit unsigned representation with the same LSB, giving a range up to 655\,cm (with 408\,cm required). Note, the endcaps are handled separately so the negative $z$ endcap can be treated like the positive $z$ one. Sine and cosines can be represented in a 16-bit signed representation where they are multiplied by $2^{15}$. Hence, the result of a multiplication by this value needs to be stored in up to 31 bits and then bitshifted by 15. Note, this does not allow a representation of exactly $+1$, i.e. for angles of 0 or $\pi/2$. Neither of these should occur in the HGC. Similarly, if needed, $\tan(\theta)$ is in the appproximate range $\pm 0.1$ to $\pm 0.5$ and so can be represented in the same way (and hence is similar to $\sin\theta$ for small angles). Hence, the scaled variables $x/z = \tan\theta \cos\phi$ and $y/z = \tan\theta \sin\phi$ can also have the same representation. \section{FE ASIC TOT non-linearity} Modelled as a response $r$ for an input charge $q$ given by $$r = 0\quad\mathrm{for}\ q<100\,\mathrm{fC}, \qquad r = q - \frac{100(100-q_0)}{q-q_0} = q \left[1 - \frac{100(100-q_0)}{q(q-q_0)}\right] \quad \mathrm{otherwise}$$ where value of the parameter is chosen to be $q_0=90$\,fC. For $q(q-q_0) \gg 100(100-q_0)=1000$\,fC$^2$, the non-linear term becomes negligible. E.g. for $q=200$\,fC, then $q(q-q_0) = 22000$ and so is a 5\% correction, while for $q=400$\,fC, then $q(q-q_0) = 124000$ and so is a 0.8\% correction. Inverting the above response function for $q \ge 100$\,fC, then $$r(q-q_0) = q(q-q_0) - 100(100-q_0) \qquad\mathrm{so}\qquad q^2-q(q_0+r)+rq_0 -100(100-q_0)$$ Hence $$q = \frac{1}{2}\left[q_0+r \pm \sqrt{(q_0+r)^2-4rq_0+400(100-q_0)}\right] =\frac{q_0+r}{2} \pm \sqrt{\left(\frac{q_0-r}{2}\right)^2 + 100(100-q_0)}$$ where the positive sign is required for $q>100$\,fC. \section{Link data representation} The selected trigger cell data on the link need to be represented in a small number of bits $n$, typically $\sim 8$. This could be linear or logarithmic. For linear, then in general it can be linear betwen $x_\mathrm{min}$ and $x_\mathrm{max}$ and 0 or $2^n-1$ outside this range. This can be represented within the range by $$y = \frac{(2^n-1)(x-x_\mathrm{min})}{x_\mathrm{max}-x_\mathrm{min}}$$ which can be inverted to give $$x = x_\mathrm{min} + \frac{y(x_\mathrm{max}-x_\mathrm{min})}{2^n-1}$$ For logarithmic, the general case would be $y=a\log(x)+b$ but with $c=b/a$ and $x_\mathrm{min}=e^-c$, then $$y = a\log(x)+b = a\log(x)+ac = a(\log(x)+c) = a(\log(x)-\log(x_\mathrm{min})) = a \log(x/x_\mathrm{min})$$ Therefore $$y = (2^n-1) \frac{\log(x/x_\mathrm{min})}{\log(x_\mathrm{max}/x_\mathrm{min})}$$ This can be inverted to give $$x = x_\mathrm{min}\left(\frac{x_\mathrm{max}}{x_\mathrm{min}}\right)^{y/(2^n-1)}$$ \section{Template fit of energy in depth} Assume a template shape for a photon of $P_l$ per photon energy GeV for layer $l$. The minimum bias gives a template shape of $M_l$ for layer $l$ in some arbitrary units. The total expected per layer will then be $E_l = E_pP_l + E_m M_l$ for a photon energy $E_p$ and some scaling $E_m$ of the minimum bias template. Hence, the chi-squared compared to the observed energy $O_l$ will be $$\chi^2 = \sum_l \frac{(E_p P_l + E_m M_l - O_l)^2}{\sigma_l^2}$$ The $\sigma_l$ are given by the photon and minimum bias shower fluctuations around the average of the template. As such, the errors will depend on $E_p$ and $E_m$. However, expected'' values can be used initially to fix the $\sigma_l$ so that the problem remains linear. It could then be iterated several times with improved values to get a better fit. Minimising the chi-squared requires $$\frac{d\chi^2}{dE_p} = \sum_l \frac{2P_l(E_p P_l + E_m M_l - O_l)}{\sigma_l^2}=0,\qquad \frac{d\chi^2}{dE_m} = \sum_l \frac{2M_l(E_p P_l + E_m M_l - O_l)}{\sigma_l^2}=0$$ such that $$E_p \sum_l \frac{P_l^2}{\sigma_l^2} + E_m\sum_l \frac{P_lM_l}{\sigma_l^2} = \sum_l \frac{O_l P_l}{\sigma_l^2}, \qquad E_p \sum_l \frac{P_l M_l}{\sigma_l^2} + E_m\sum_l \frac{M_l^2}{\sigma_l^2} = \sum_l \frac{O_l M_l}{\sigma_l^2},$$ This can be written as a matrix equation $$\begin{pmatrix} \sum_l \frac{P_l^2}{\sigma_l^2} & \sum_l \frac{P_l M_l}{\sigma_l^2} \\ \sum_l \frac{P_l M_l}{\sigma_l^2} & \sum_l \frac{M_l^2}{\sigma_l^2} \end{pmatrix} \begin{pmatrix} E_p \\ E_m \end{pmatrix} = \begin{pmatrix} \sum_l \frac{O_l P_l}{\sigma_l^2} \\ \sum_l \frac{O_l M_l}{\sigma_l^2} \end{pmatrix}$$ As long as the $P_l$ and $M_l$ are not proportional to each other, the matrix on the left can be inverted to solve for $E_p$ (and $E_m$). This matrix is a constant for all events and so can be precalculated and inverted once, offline. The vector on the right must be calculated per event. However, explicitly the matrix determinant is $$\Delta = \left(\sum_l \frac{P_l^2}{\sigma_l^2}\right) \left(\sum_l \frac{M_l^2}{\sigma_l^2}\right) - \left(\sum_l \frac{P_l M_l}{\sigma_l^2} \right)^2$$ so the inverse is $$\frac{1}{\Delta} \begin{pmatrix} \sum_l \frac{M_l^2}{\sigma_l^2} & -\sum_l \frac{P_l M_l}{\sigma_l^2} \\ -\sum_l \frac{P_l M_l}{\sigma_l^2} & \sum_l \frac{P_l^2}{\sigma_l^2} \end{pmatrix}$$ and hence $$\begin{pmatrix} E_p \\ E_m \end{pmatrix} = \frac{1}{\Delta} \begin{pmatrix} \sum_{l^\prime} \frac{M_{l^\prime}^2}{\sigma_{l^\prime}^2} & -\sum_{l^\prime} \frac{P_{l^\prime} M_{l^\prime}}{\sigma_{l^\prime}^2} \\ -\sum_{l^\prime} \frac{P_{l^\prime} M_{l^\prime}}{\sigma_{l^\prime}^2} & \sum_{l^\prime} \frac{P_{l^\prime}^2}{\sigma_{l^\prime}^2} \end{pmatrix} \begin{pmatrix} \sum_l \frac{O_l P_l}{\sigma_l^2} \\ \sum_l \frac{O_l M_l}{\sigma_l^2} \end{pmatrix}$$ which means $$\begin{pmatrix} E_p \\ E_m \end{pmatrix} = \begin{pmatrix} \sum_l O_l \left[\frac{P_l}{\Delta \sigma_l^2} \left( \sum_{l^\prime} \frac{M_{l^\prime}^2}{\sigma_{l^\prime}^2}\right) - \frac{M_l}{\Delta \sigma_l^2} \left( \sum_{l^\prime} \frac{P_{l^\prime} M_{l^\prime}}{\sigma_{l^\prime}^2}\right) \right]\\ \sum_l O_l \left[\frac{M_l}{\Delta \sigma_l^2} \left(\sum_{l^\prime} \frac{P_{l^\prime}^2}{\sigma_{l^\prime}^2}\right) -\frac{P_l}{\Delta \sigma_l^2} \left(\sum_{l^\prime} \frac{P_{l^\prime} M_{l^\prime}}{\sigma_{l^\prime}^2}\right)\right] \end{pmatrix}$$ Hence $$E_p = \sum_l O_l A_l,\qquad E_m = \sum_l O_l B_l$$ where $A_l$ and $B_l$ correspond to the quantities in the square brackets and can be precalculated, except for any subtleties with the errors. ERROR MATRIX \section{Comparing coordinates in plane polars} On a given layer, then comparing e.g. a track extrapolation to a cluster position requires a difference of the two points in 2D; $x_1$, $y_1$ and $x_2$, $y_2$. This should be done in coordinates which preserve the cylindrical (i.e. plane polar for a layer) geometry. The obvious two are $$\Delta\rho = \rho_2-\rho_1 = \sqrt{x_2^2+y_2^2}-\sqrt{x_1^2+y_1^2}, \qquad \Delta\phi = \phi_2 - \phi_1 = \tan^{-1}(y_2/x_2) - \tan^{-1}(y_1/x_1)$$ However, $\Delta\phi$ has two issues; firstly is that it is not a length variable and so makes comparison with $\Delta\rho$ difficult, and secondly that there is a discontinuity in $\phi$ which needs to be handled. A length variable can be formed using some radius value $\overline{\rho}$ to give $\overline{\rho}\Delta\phi$ but there is an ambiguity about which radius to use; $\rho_1$, $\rho_2$ or some average of these. One desirable property is that the two variables should preserve the total length, i.e. $$\Delta\rho^2 + \overline{\rho}^2\Delta\phi^2 = \Delta x^2 + \Delta y^2 = (x_2-x_1)^2 + (y_2-y_1)^2 = x_2^2+y_2^2+x_1^2+y_1^2 - 2(x_1x_2+y_1y_2)$$ Using the expression for $\Delta\rho$ above, then $$\Delta\rho^2 = x_2^2+y_2^2+x_1^2+y_1^2 - 2\sqrt{x_2^2+y_2^2}\sqrt{x_1^2+y_1^2}$$ so that $$\overline{\rho}^2\Delta\phi^2 =2\sqrt{x_2^2+y_2^2}\sqrt{x_1^2+y_1^2}- 2(x_1x_2+y_1y_2)$$ Expressing the right hand side in plane polars gives $$\overline{\rho}^2\Delta\phi^2 =2\rho_1\rho_2 - 2\rho_1\rho_2 (\cos\phi_1\cos\phi_2 + \sin\phi_1\sin\phi_2) =2\rho_1\rho_2 [1-\cos(\phi_2-\phi_1)]=2\rho_1\rho_2 (1-\cos\Delta\phi)$$ This effectively defines $\overline{\rho}$ and hence the second variable directly. Note there is no issue with the $\phi$ discontinuity as this is handled automatically by the cosine. For small $\Delta\phi$, then the above expression is approximated by $$\overline{\rho}^2\Delta\phi^2 \approx 2\rho_1\rho_2 \frac{\Delta\phi^2}{2} \approx \rho_1\rho_2 \Delta\phi^2$$ so that $\overline{\rho} \approx \sqrt{\rho_1\rho_2}$, i.e. the geometric mean. Note that the sign of the second variable is not defined by the above; it should be the same as the sign of $\Delta\phi$. However, since $$1 - \cos\Delta\phi = 2\sin^2\left(\frac{\Delta\phi}{2}\right)$$ then $$\overline{\rho}^2\Delta\phi^2 =4\rho_1\rho_2 \sin^2\left(\frac{\Delta\phi}{2}\right)$$ and so $$\overline{\rho}\Delta\phi =2\sqrt{\rho_1\rho_2} \sin\left(\frac{\Delta\phi}{2}\right)$$ where the positive sign for the square-root is taken to agree with $\Delta\phi$. Again, for small $\Delta\phi$, then $\overline{\rho}$ clearly approximates to the geometric mean of the two radii, as before. \section{Shower position and direction fit} \section{Motion in a magnetic field} \section{Inverting matrices} A symmetric $3\times 3$ matrix can be written as $$M= \begin{pmatrix} M_{00} & M_{01} & M_{02} \\ M_{01} & M_{11} & M_{12} \\ M_{02} & M_{12} & M_{22} \end{pmatrix}$$ Its determinant is then \begin{eqnarray} \Delta &=& M_{00} \begin{vmatrix} M_{11} & M_{12} \\ M_{12} & M_{22} \end{vmatrix} -M_{01} \begin{vmatrix} M_{01} & M_{12} \\ M_{02} & M_{22} \end{vmatrix} +M_{02} \begin{vmatrix} M_{01} & M_{11} \\ M_{02} & M_{12} \end{vmatrix}\\ &=& M_{00}M_{11}M_{22}-M_{00}M_{12}M_{12} -M_{01}M_{01}M_{22}+M_{01}M_{12}M_{02} +M_{02}M_{01}M_{12}-M_{02}M_{11}M_{02}\\ &=& M_{00}M_{11}M_{22}+2M_{01}M_{12}M_{02} -M_{00}M_{12}^2 -M_{11}M_{02}^2 -M_{22}M_{01}^2 \end{eqnarray} This can be written is several ways \begin{eqnarray} \Delta &=& M_{00}(M_{11}M_{22}-M_{12}^2) +M_{01}(M_{12}M_{02}-M_{22}M_{01}) +M_{02}(M_{01}M_{12}-M_{11}M_{02})\\ &=& M_{01}(M_{12}M_{02}-M_{22}M_{01}) +M_{11}(M_{00}M_{22}-M_{02}^2) +M_{12}(M_{01}M_{02}-M_{00}M_{12})\\ &=&M_{02}(M_{01}M_{12}-M_{11}M_{02}) +M_{12}(M_{01}M_{02}-M_{00}M_{12}) +M_{22}(M_{00}M_{11}-M_{01}^2) \end{eqnarray} which means the inverse must be $$M^{-1}= \frac{1}{\Delta} \begin{pmatrix} M_{11}M_{22}-M_{12}^2 & M_{12}M_{02}-M_{22}M_{01} & M_{01}M_{12}-M_{11}M_{02} \\ M_{12}M_{02}-M_{22}M_{01} & M_{00}M_{22}-M_{02}^2 & M_{01}M_{02}-M_{00}M_{12} \\ M_{01}M_{12}-M_{11}M_{02} & M_{01}M_{02}-M_{00}M_{12} & M_{00}M_{11}-M_{01}^2 \end{pmatrix}$$ Note, if variable 2 becomes uncorrelated with variables 0 and 1, then $M_{02}=M_{12}=0$ so $$\Delta =M_{00}M_{11}M_{22}-M_{22}M_{01}^2= M_{22}(M_{00}M_{11}-M_{01}^2) = M_{22}\Delta_2$$ and $$M^{-1}= \frac{1}{\Delta} \begin{pmatrix} M_{11}M_{22} & -M_{22}M_{01} & 0 \\ -M_{22}M_{01} & M_{00}M_{22} & 0 \\ 0 & 0 & M_{00}M_{11}-M_{01}^2 \end{pmatrix} =\frac{1}{\Delta_2} \begin{pmatrix} M_{11} & -M_{01} & 0 \\ -M_{01} & M_{00} & 0 \\ 0 & 0 & \Delta_2/M_{22} \end{pmatrix} = \begin{pmatrix} M_2^{-1} & 0 \\ 0 & 1/M_{22} \end{pmatrix}$$ as expected. The inverse of the $2\times 2$ matrix is not the submatrix in the inverse of the $3\times 3$ matrix. E.g. for the first element in the inverse of the $2\times 2$ matrix, this is $$M_{00}^{-1} = \frac{M_{11}}{M_{00}M_{11}-M_{01}^2}$$ while in the $3 \times 3$ case, this is \begin{eqnarray} M_{00}^{-1} &=& \frac{M_{11}M_{22}-M_{12}^2}{M_{00}M_{11}M_{22}+2M_{01}M_{12}M_{02} -M_{00}M_{12}^2 -M_{11}M_{02}^2 -M_{22}M_{01}^2}\\ &=& \frac{M_{11}-(M_{12}^2/M_{22})}{M_{00}M_{11}-M_{01}^2 +(2M_{01}M_{12}M_{02} -M_{00}M_{12}^2 -M_{11}M_{02}^2)/M_{22}} \end{eqnarray} \end{document}