wup.tex 46.5 KB
 vpalladi committed May 13, 2016 1 2 3 \documentclass[10pt]{article} \usepackage{a4} \usepackage{amsmath}  dauncey committed Jun 24, 2018 4 \usepackage{graphicx}  vpalladi committed May 13, 2016 5 6 7 8 9 10 11 12 13 14 15 16  \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  dauncey committed May 25, 2017 17 18 19 \centerline{\large \today} \section{Latency and drain-time limits on signal bandwidth overheads}  dauncey committed Jul 04, 2017 20 21 In addition to the pileup-generated rate of hits (both for DAQ and TPG),  dauncey committed May 25, 2017 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 there are also occasional signal events. Some of these can cause a large number of hits in a small area, such as a motherboard. The bandwidth for data coming from the motherboard must include some overhead above the value needed for the pileup as otherwise these signal events will eventually cause buffer overflows. There are two issues; latency (particularly important for the TPG) and the drain-time'' of the FE buffers. This latter is the time taken to flush out the extra data from the signal event such that the buffers are back at the steady state of handling the average pileup. A long drain-time would mean the buffers are fuller than normal and so there is a risk that another signal event could cause an overflow. The effect of latency is clear but it is harder to put a firm requirement on the drain-time. Let the maximum signal plus pileup data volume for a BX in a panel be $s$ bits and the average pileup data volume per BX be $p$ bits, where clearly $s>p$. The extra'' data due to the signal is obviously $s-p$ bits. A bandwidth $b$ is to be determined, where $b > p$. Clearly $b=s$ would allow any signal event to be read out within one BX but would be more bandwidth that really required. Hence, that the bandwidth is set to be that required for the pileup plus some fraction $f$ of the extra data due to the signal, i.e. b = p+f(s-p) = fs+(1-f)p For this bandwidth then the drain-time $d$ is given by the amount of extra data, $s-p$, divided by the extra bandwidth above the pileup rate, $f(s-p)$, i.e. d = \frac{s-p}{f(s-p)} = \frac{1}{f} The latency $l$ is the time to read out the whole signal event given the total bandwidth, so l = \frac{s}{b} = \frac{s}{fs+(1-f)p} = \frac{1}{f[1-(p/s)]+(p/s)} Note that \frac{l}{d} = \frac{1}{[1-(p/s)]+(p/fs)} = \frac{1}{1+(p/s)(1/f-1)}<1 i.e. the latency is always shorter than the drain-time. The value of the fraction is obviously limited to $0 < f < 1$ so the limits on the latency are $(s/p) > l > 1$. The lower limit, which occurs for $f=1$, is simply adding in enough bandwidth so $b=s$. The upper limit says that even with zero overhead bandwidth, where $b=p$, the latency for reading out the signal event is simply $s/b=s/p$. If this upper latency limit is below the allowable latency, then the drain-time is the only relevant limit. Otherwise, both limits need to be checked to set the value of $f$. Take an example; with a latency limit of 10 BX, a drain-time limit (semi-arbitrarily) of 40 BX (i.e. before the next L1 trigger on average), and a ratio of $s/p = 20$, then the latency limit means the fraction must be f \ge \frac{(1/l)-(p/s)}{1-(p/s)} = \frac{0.1-0.05}{1-0.1} = \frac{1}{19} which is stricter that the drain-time limit $f \ge 1/40$ and so sets the required fraction. The two limits are equivalent for a particular value of $p/s$ which is given by f = \frac{(1/l)-(p/s)}{1-(p/s)} = \frac{1}{d} which gives \frac{p}{s} = \frac{(d/l)-1}{d-1} and for the example here results in \frac{p}{s} = \frac{4-1}{40-1} = \frac{3}{39} = \frac{1}{13} Hence, if $s/p \le 13$, then the drain-time limit is stricter. \section{Hexagonal integer grid} The centres of a regular array of hexagons can be considered to lie on an effective Cartesian grid, with the $y$ axis unit equal to $3/2$ of the hexagon side and the $x$ axis unit equal to $\sqrt{3}/2$ of the hexagonal side, i.e. the ratio of $y/x$ units is $\sqrt{3}$. The centres of the hexagons then lie on integer values of $x$ and $y$, $i_x$ and $i_y$, and occupy a chessboard pattern, here assumed to have the sum of $i_x+i_y$ being even. The centres are 2 units apart along the $x$ axis but are 1 unit apart along the $y$ axis. E.g. the valid wafer along the $x$ axis are at $i_y=0$ and $i_x = \dots, -4, -2, 0, 2, 4, \dots$. The next row up is $i_y=1$ and $i_x = \dots, -3, -1, 1, 3, \dots$, while the next row down is $i_y=-1$ with the same values of $i_x$. The valid wafer centres can also be described by plane polar coordinates, $i_r$ and $i_\phi$, where $i_r \ge 0$ and $i_\phi$ is limited to the range 0 to $6i_r-1$, except the centre $i_x=0$ and $i_y=0$ has $i_r=0$ and $i_\phi=0$. \bigskip \begin{center} \begin{tabular}{c|c} \hline $i_x, i_y$ & $i_r, i_\phi$ \cr\hline $0, 0$ & $0, 0$ \cr\hline $2, 0$ & $1, 0$ \cr $1, 1$ & $1, 1$ \cr $-1, 1$ & $1, 2$ \cr $-2, 0$ & $1, 3$ \cr $-1,-1$ & $1, 4$ \cr $1,-1$ & $1, 5$ \cr\hline $4, 0$ & $2, 0$ \cr $3, 1$ & $2, 1$ \cr $2, 2$ & $2, 2$ \cr $0, 2$ & $2, 3$ \cr $-2, 2$ & $2, 4$ \cr $-3, 1$ & $2, 5$ \cr $-4, 0$ & $2, 6$ \cr $-3,-1$ & $2, 7$ \cr $-2,-2$ & $2, 8$ \cr $0,-2$ & $2, 9$ \cr $2,-2$ & $2,10$ \cr $3,-1$ & $2,11$ \cr \hline \end{tabular} \end{center} A rotation by $\Delta\phi = 60^\circ$ and $-60^\circ \equiv 300^\circ$ in Cartesian coordinates would be \begin{pmatrix} x^\prime \\ y^\prime \end{pmatrix} = \begin{pmatrix} 1/2 & \mp\sqrt{3}/2 \\ \pm\sqrt{3}/2 & 1/2 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} But the units mean $x^{(\prime)} \propto i_x^{(\prime)}$ while $y^{(\prime)} \propto \sqrt{3}i_y^{(\prime)}$ so \begin{pmatrix} i_x^\prime \\ \sqrt{3}i_y^\prime \end{pmatrix} = \begin{pmatrix} 1/2 & \mp\sqrt{3}/2 \\ \pm\sqrt{3}/2 & 1/2 \end{pmatrix} \begin{pmatrix} i_x \\ \sqrt{3}i_y \end{pmatrix} \qquad{\rm so}\qquad \begin{pmatrix} i_x^\prime \\ i_y^\prime \end{pmatrix} = \begin{pmatrix} 1/2 & \mp 3/2 \\ \pm 1/2 & 1/2 \end{pmatrix} \begin{pmatrix} i_x \\ i_y \end{pmatrix} A rotation of $120^\circ$ and $-120^\circ \equiv 240^\circ$ is therefore \begin{pmatrix} i_x^\prime \\ i_y^\prime \end{pmatrix} = \begin{pmatrix} -1/2 & \mp 3/2 \\ \pm 1/2 & -1/2 \end{pmatrix} \begin{pmatrix} i_x \\ i_y \end{pmatrix} while a rotation of $180^\circ$ is simply \begin{pmatrix} i_x^\prime \\ i_y^\prime \end{pmatrix} = \begin{pmatrix} -1 & 0 \\ 0 & -1 \end{pmatrix} \begin{pmatrix} i_x \\ i_y \end{pmatrix}  vpalladi committed May 13, 2016 199   dauncey committed Oct 05, 2017 200 \newpage  dauncey committed Jun 02, 2016 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 \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  dauncey committed Jun 24, 2018 220 221 222 223 224 225 226 227 228 Alternatively, we could optimise for $\Delta E/E$, i.e. \mathrm{RMS}^2 = \frac{1}{N} \sum_e \left(\frac{E_e - T_e}{T_e}\right)^2 = \frac{1}{N} \sum_e \left(\frac{\sum_i a_i d_{e,i} - T_e}{T_e}\right)^2 = \frac{1}{N} \sum_e \left(\sum_i a_i d_{e,i}^\prime - 1\right)^2 where $d_{e,i}^\prime = d_{e,i}/T_e$. Hence, this method will be identical in form in the following, but replacing $T_e$ by 1 and $d_{e,i}$ by $d_{e,i}^\prime$.  dauncey committed Jun 02, 2016 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 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$.  dauncey committed Jun 07, 2016 256 257 258 259 260 261 262 263 264 265 266 267 268 269 The resulting RMS using the best fit values is given by \begin{eqnarray*} \mathrm{RMS}^2_\mathrm{min} &=& \frac{1}{N} \sum_e \left[ \left(\sum_i a_i d_{e,i} \right)^2 - 2 T_e \sum_i a_i d_{e,i} + T_e^2 \right] \\ &=& \frac{1}{N} \sum_j \sum_i a_j a_i \sum_e d_{e,j} d_{e,i} - \frac{2}{N} \sum_i a_i \sum_e T_e d_{e,i} + \frac{1}{N} \sum_e T_e^2 \\ &=& \sum_j \sum_i a_j a_i M_{ji} - 2 \sum_i a_i v_i + \frac{1}{N} \sum_e T_e^2 = a^T M a - 2 a^T v + \frac{1}{N} \sum_e T_e^2 \end{eqnarray*} But since the solution is defined by $Ma=v$, then $a^T M a = a^T v$. Hence  dauncey committed Aug 16, 2016 270 271 272 \mathrm{RMS}^2_\mathrm{min} = \frac{1}{N} \left(\sum_e T_e^2\right) - a^T M a = \frac{1}{N} \left(\sum_e T_e^2\right) - v^T M^{-1} v = \frac{1}{N} \left(\sum_e T_e^2\right) - a^T v  dauncey committed Jun 07, 2016 273   dauncey committed Jun 17, 2016 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 The above can be extended slightly, which may improve the energy response linearity as well as the RMS. The energy estimation for the event (i.e. the first equation in this section) can be generally considered to be a polynomial in the $d_{e,i}$, but with the quadratic and higher terms neglected. However, it also neglects any constant term. A more general expression would then be to add another coefficient $b$ to give E_e = b + \sum_i a_i d_{e,i} The easiest way to handle this is to allow the index $i$ to go one higher than previously, specifically change from $i=0,27$ to $i=0,28$ and then define $a_{28}=b$ and $d_{e,28}=1$. This means the expression simplifies to E_e = \sum_{i=0}^{28} a_i d_{e,i} and so an identical calculation to previously holds, simply with the index running over a larger range. Explicitly, the matrix $M$ is now $29\times 29$ with the extra elements being M_{i,28} = M_{28,i} = \frac{1}{N} \sum_e d_{e,28}d_{e,i} = \frac{1}{N} \sum_e d_{e,i} and M_{28,28} = \frac{1}{N} \sum_e d_{e,28}d_{e,28} = 1 while the extra element in $v$ is v_{28} = \frac{1}{N} \sum_e T_e d_{e,28} = \frac{1}{N} \sum_e T_e  dauncey committed Jun 02, 2016 306   vpalladi committed May 13, 2016 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 \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  dauncey committed Nov 14, 2016 369 370 data are calculated to a large number of bits, typically 16-18. On the links, they need to be represented in a small number of bits $n$,  vpalladi committed May 13, 2016 371 typically $\sim 8$.  dauncey committed Nov 14, 2016 372 373 374 This could be linear or logarithmic or floating. \subsection{Linear representation}  vpalladi committed May 13, 2016 375 376 377 378 379 380 381 382 383 384 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}  dauncey committed Nov 14, 2016 385 386  \subsection{Logarithmic representation}  vpalladi committed May 13, 2016 387 For logarithmic, the general case would be $y=a\log(x)+b$ but with  dauncey committed Nov 14, 2016 388 $c=b/a$ and $x_\mathrm{min}=e^{-c}$, then  vpalladi committed May 13, 2016 389 390 391 392 393 394 395 396 397 398 399 400 401  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)}  dauncey committed Jun 16, 2017 402 \newpage  dauncey committed Nov 14, 2016 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 \subsection{Float representation} Here, the $2^n$ values are split into an exponent of $E$ bits and a mantissa of $M$ bits. The naive approach is simply to take the actual value as the mantissa shifted up by $E$ bits. For example, for $E=2$ and $M=2$, then the 16 possible values would give the table below. \bigskip \begin{center} \begin{tabular}{c|c|c|c} \hline Representation & Exponent & Mantissa & Value \cr\hline 0 & 0b00 & 0b00 & 0b00000 = \phantom{2}0\cr 1 & 0b00 & 0b01 & 0b00001 = \phantom{2}1\cr 2 & 0b00 & 0b10 & 0b00010 = \phantom{2}2\cr 3 & 0b00 & 0b11 & 0b00011 = \phantom{2}3\cr 4 & 0b01 & 0b00 & 0b00000 = \phantom{2}0\cr 5 & 0b01 & 0b01 & 0b00100 = \phantom{2}2\cr 6 & 0b01 & 0b10 & 0b01000 = \phantom{2}4\cr 7 & 0b01 & 0b11 & 0b01100 = \phantom{2}6\cr 8 & 0b10 & 0b00 & 0b00000 = \phantom{2}0\cr 9 & 0b10 & 0b01 & 0b00100 = \phantom{2}4\cr 10 & 0b10 & 0b10 & 0b01000 = \phantom{2}8\cr 11 & 0b10 & 0b11 & 0b01100 = 12 \cr 12 & 0b11 & 0b00 & 0b00000 = \phantom{2}0\cr 13 & 0b11 & 0b01 & 0b01000 = \phantom{2}8\cr 14 & 0b11 & 0b10 & 0b10000 = 16 \cr 15 & 0b11 & 0b11 & 0b11000 = 24 \cr \hline \end{tabular} \end{center} It is clear this is neither monotonic nor efficient, as the same values appear for several representations. A better representation is made by realising that for all but the lowest exponent representations, there is always a leading bit. Hence, this does not have to be stored explicitly. This means this leading bit must be added to the mantissa before the bit shift, and since this increments the length by one bit, then the shift up needed is only $E-1$. The table below shows this improved representation. It is monotonic, there are no duplicates, and the lowest two exponent ranges give an exact representation. \bigskip \begin{center} \begin{tabular}{c|c|c|c} \hline Representation & Exponent & Mantissa & Value \cr\hline 0 & 0b00 & 0b00 & 0b00000 = \phantom{2}0\cr 1 & 0b00 & 0b01 & 0b00001 = \phantom{2}1\cr 2 & 0b00 & 0b10 & 0b00010 = \phantom{2}2\cr 3 & 0b00 & 0b11 & 0b00011 = \phantom{2}3\cr 4 & 0b01 & 0b00 & 0b00100 = \phantom{2}4\cr 5 & 0b01 & 0b01 & 0b00101 = \phantom{2}5\cr 6 & 0b01 & 0b10 & 0b00110 = \phantom{2}6\cr 7 & 0b01 & 0b11 & 0b00111 = \phantom{2}7\cr 8 & 0b10 & 0b00 & 0b01000 = \phantom{2}8\cr 9 & 0b10 & 0b01 & 0b01010 = 10 \cr 10 & 0b10 & 0b10 & 0b01100 = 12 \cr 11 & 0b10 & 0b11 & 0b01110 = 14 \cr 12 & 0b11 & 0b00 & 0b10000 = 16 \cr 13 & 0b11 & 0b01 & 0b10100 = 20 \cr 14 & 0b11 & 0b10 & 0b11000 = 24 \cr 15 & 0b11 & 0b11 & 0b11100 = 28 \cr \hline \end{tabular} \end{center} In this improved representation, the mantissa has $M+1$ bits (except in the lowest exponent range). The exponent can represent numbers up to $2^E-1$ and hence will bit shift by a maximum of $2^E-2$ bits. Hence, the number of bits in the representation is $M+E$ bits, while the maximum number represented has $M+1+2^E-2 = M+2^E-1$ bits, i.e. is is less than $2^{M+2^E-1}$. The reduction is $2^E-E-1$ bits. For the example of $M=2$, $E=2$ in the table above, this gives $2-1+4=5$ bits, i.e. numbers up to $2^5=32$ as shown and the reduction is 1 bit.  dauncey committed Jun 24, 2018 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 The maximum bit lengths of the value, i.e. $M+2^E-1$, for various values of $M$ and $E$ are shown in the table below. \bigskip \begin{center} \begin{tabular}{r||c|c|c|c|c|c|c|c|c} \hline $M=$ & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \cr\hline $E=0$ & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \cr 1 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \cr 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \cr 3 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 \cr 4 & 15 & 16 & 17 & 18 & 19 & 20 & 21 & 22 & 23 \cr 5 & 31 & 32 & 33 & 34 & 35 & 36 & 37 & 38 & 39 \cr 6 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 \cr 7 & 127 & 128 & 129 & 130 & 131 & 132 & 133 & 134 & 135 \cr 8 & 255 & 256 & 257 & 258 & 259 & 260 & 261 & 262 & 263 \cr \hline \end{tabular} \end{center} %\newpage  dauncey committed Nov 14, 2016 502 503 504 505 506 507 508 509 510 511 512 For the extreme values of $E$, then $E=0$ and $E=1$ both give an exact representation as they only use the lowest range or two lowest ranges, respectively. The reduction is $2^0-0-1=0$ and $2^1-1-1=0$ bits in both cases. Explicitly, for $E=0$, then the representation has $M$ bits while the value represented has $M$ bits also, i.e. the reduction is 0 bits. For $E=1$, the representation has $M+1$ bits, while the value represented has $M+1$ bits also, again with a reduction of 0 bits. For the extreme value of $M=0$, then the representation is just the number of bits in the input word. E.g. for $M=0$, $E=4$, then the  dauncey committed Jun 16, 2017 513 table is given below. The value range is less than $2^{15}=32768$.  dauncey committed Nov 14, 2016 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539  \bigskip \begin{center} \begin{tabular}{c|c|c|c} \hline Representation & Exponent & Mantissa & Value \cr\hline 0 & 0b0000 & 0 & 0b000000000000000 = \phantom{1222}0\cr 1 & 0b0001 & 0 & 0b000000000000001 = \phantom{1222}1\cr 2 & 0b0010 & 0 & 0b000000000000010 = \phantom{1222}2\cr 3 & 0b0011 & 0 & 0b000000000000100 = \phantom{1222}4\cr 4 & 0b0100 & 0 & 0b000000000001000 = \phantom{1222}8\cr 5 & 0b0101 & 0 & 0b000000000010000 = \phantom{122}16\cr 6 & 0b0110 & 0 & 0b000000000100000 = \phantom{122}32\cr 7 & 0b0111 & 0 & 0b000000001000000 = \phantom{122}64\cr 8 & 0b1000 & 0 & 0b000000010000000 = \phantom{12}128\cr 9 & 0b1001 & 0 & 0b000000100000000 = \phantom{12}256 \cr 10 & 0b1010 & 0 & 0b000001000000000 = \phantom{12}512 \cr 11 & 0b1011 & 0 & 0b000010000000000 = \phantom{1}1024 \cr 12 & 0b1100 & 0 & 0b000100000000000 = \phantom{1}2048 \cr 13 & 0b1101 & 0 & 0b001000000000000 = \phantom{1}4096 \cr 14 & 0b1110 & 0 & 0b010000000000000 = \phantom{1}8192 \cr 15 & 0b1111 & 0 & 0b100000000000000 = 16384 \cr \hline \end{tabular} \end{center}  vpalladi committed May 13, 2016 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 \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.  dauncey committed Jun 24, 2018 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 \section{Cartesian coordinates and pseudorapidity} As above, take $\rho = \sqrt{x^2+y^2}$ and define the arc length $s=\rho\phi$. In terms of scaled coordinates $x_s=x/z$ and $y_s=y/z$, then equivalently $\rho_s = \rho/z$ and $s_s = (\rho/z)\phi = \rho_s\phi$. Note, $\rho_s = \tan\theta$ and so $x_s = \tan\theta\cos\phi$ and $y_s = \tan\theta\sin\phi$. Generally $\sinh\eta = z/\rho = 1/\rho_s$, so $\rho_s = 1/\sinh\eta$ and $s_s = \phi/\sinh\eta$. To convert from $E$ to $E_T$ requires a factor of $\sin\theta$, which is given by \sin\theta = \sin\left(\tan^{-1}\rho_s\right) = \sin\left[\tan^{-1}\left(\frac{1}{\sinh\eta}\right)\right] % \begin{figure}[ht!] \begin{center} \includegraphics[width=9cm]{SinThetaVsEta.pdf} %\caption{ % Left: Active rotation by $30^\circ$ % of an object in a fixed coordinate system. % Right: Passive rotation by $30^\circ$ % of the coordinate system around a fixed object. %} \label{fig:rotations} \end{center} \end{figure} Comparing areas in $\Delta \rho_s \Delta s_s$ and $\Delta \eta \Delta \phi$ requires the Jacobian. From above \frac{\partial \rho_s}{\partial \eta} = - \frac{\cosh\eta}{\sinh^2\eta},\qquad \frac{\partial \rho_s}{\partial \phi} = 0 while \frac{\partial s_s}{\partial \eta} = - \frac{\phi\cosh\eta}{\sinh^2\eta},\qquad \frac{\partial s_s}{\partial \phi} = \frac{1}{\sinh\eta} Hence the Jacobian is J = \left|\frac{\partial \rho_s}{\partial \eta}\frac{\partial s_s}{\partial \phi} - \frac{\partial \rho_s}{\partial \phi}\frac{\partial s_s}{\partial \eta}\right| = \left|\frac{\cosh\eta}{\sinh^2\eta}\times\frac{1}{\sinh\eta}\right| = \left|\frac{\cosh\eta}{\sinh^3\eta}\right| Hence \Delta \rho_s \Delta s_s = \left|\frac{\cosh\eta}{\sinh^3\eta}\right| \Delta \eta \Delta \phi Cross-check the other way around, using \eta = \sinh^{-1}\left(\frac{1}{\rho_s}\right),\qquad \phi = \frac{s_s}{\rho_s} then \frac{\partial \eta}{\partial \rho_s} = - \frac{\sinh^2\eta}{\cosh\eta} = -\frac{1}{\rho_s^2\sqrt{1+1/\rho_s^2}} = -\frac{1}{\rho_s\sqrt{1+\rho_s^2}},\qquad \frac{\partial \eta}{\partial s_s} = 0 and \frac{\partial \phi}{\partial \rho_s} = - \frac{s_s}{\rho_s^2},\qquad \frac{\partial \phi}{\partial s_s} = \frac{1}{\rho_s} Hence the inverse Jacobian to the above is \frac{1}{J} = \left|\frac{\partial \eta}{\partial \rho_s}\frac{\partial \phi}{\partial s_s} -\frac{\partial \phi}{\partial \rho_s}\frac{\partial \eta}{\partial s_s}\right| = \left|\frac{1}{\rho_s\sqrt{1+\rho_s^2}}\times\frac{1}{\rho_s}\right| = \left|\frac{1}{\rho_s^2\sqrt{1+\rho_s^2}}\right| In terms of $\eta$, this is \frac{1}{J} = \left|\frac{1/\rho_s^3}{\sqrt{1+1/\rho_s^2}}\right| = \left|\frac{\sinh^3\eta}{\cosh\eta}\right| and so is consistent. The derivatives are shown below, showing that they are very similar in size, so that a circle in $\rho_s,s_s$ coordinates is also circular to a good approximation in $\eta,\phi$. At the innermost edge of the HGCAL, i.e. $\eta=3$, the derivatives are around 10, so for example $\Delta\rho_s=\Delta s_s=0.02$ is approximately equivalent to $\Delta\eta=\Delta\phi = 0.2$. % \begin{figure}[ht!] \begin{center} \includegraphics[width=7cm]{DerivativesVsEtaA.pdf} \hspace{1cm} \includegraphics[width=7cm]{DerivativesVsEtaB.pdf} %\caption{ % Left: Active rotation by $30^\circ$ % of an object in a fixed coordinate system. % Right: Passive rotation by $30^\circ$ % of the coordinate system around a fixed object. %} \label{fig:derivatives} \end{center} \end{figure} The size of the inverse Jacobian is shown below, which gives the factor for converting areas. Specifically, with a pileup transverse energy density at PU 200 of around 140\,GeV per unit area in $\Delta\eta\Delta\phi$, then the average transverse energy in GeV in a circle of $\Delta\rho_s=\Delta s_s=0.02$ is approximately equivalent to E_T = \frac{140}{J} 0.02^2 \pi At $\eta=1.4$, this is around 0.5\,GeV, while at $\eta=3.0$, this is around 18\,GeV. % \begin{figure}[ht!] \begin{center} \includegraphics[width=9cm]{JacobianVsEta.pdf} %\caption{ % Left: Active rotation by $30^\circ$ % of an object in a fixed coordinate system. % Right: Passive rotation by $30^\circ$ % of the coordinate system around a fixed object. %} \label{fig:jacobian} \end{center} \end{figure}  vpalladi committed May 13, 2016 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 \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}  dauncey committed Dec 02, 2018 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 \section{2D interpolation} Using eight nearest neighbours around a central bin, then the coefficients of a Taylor expansion to second order (which has six coefficients) can be found using a fit. Specifically \begin{eqnarray} E(x,y) &=& E(0,0) + \left.\frac{\partial E}{\partial x}\right|_{00} x + \left.\frac{\partial E}{\partial y}\right|_{00} y + \left.\frac{\partial^2 E}{\partial x^2}\right|_{00} \frac{x^2}{2} + \left.\frac{\partial^2 E}{\partial x\partial y}\right|_{00} xy + \left.\frac{\partial^2 E}{\partial y^2}\right|_{00} \frac{y^2}{2}\\ &=& E_0 + E_x x + E_y y + E_{xx} x^2 + E_{xy} xy + E_{yy} y^2 \end{eqnarray} The values in the eight bins at $x$ and $y$ within $\pm 1$ of the central bin are \begin{eqnarray} e(-1, 1) = e_1 &=& E_0 - E_x + E_y + E_{xx} - E_{xy} + E_{yy}\\ e( 0, 1) = e_2 &=& E_0 + E_y + E_{yy}\\ e( 1, 1) = e_3 &=& E_0 + E_x + E_y + E_{xx} + E_{xy} + E_{yy}\\ e(-1, 0) = e_4 &=& E_0 - E_x + E_{xx}\\ e( 1, 0) = e_5 &=& E_0 + E_x + E_{xx}\\ e(-1,-1) = e_6 &=& E_0 - E_x - E_y + E_{xx} + E_{xy} + E_{yy}\\ e( 0,-1) = e_7 &=& E_0 - E_y + E_{yy}\\ e( 1,-1) = e_8 &=& E_0 + E_x - E_y + E_{xx} - E_{xy} + E_{yy} \end{eqnarray} so \begin{eqnarray} \begin{pmatrix} e_1 \\ e_2 \\ e_3 \\ e_4 \\ e_5 \\ e_6 \\ e_7 \\ e_8 \end{pmatrix} = \begin{pmatrix} \phantom{-}1 & -1 &\phantom{-}1 &\phantom{-}1 & -1 &\phantom{-}1\\ \phantom{-}1 &\phantom{-}0 &\phantom{-}1 &\phantom{-}0 &\phantom{-}0 &\phantom{-}1\\ \phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1\\ \phantom{-}1 & -1 &\phantom{-}0 &\phantom{-}1 &\phantom{-}0 &\phantom{-}0\\ \phantom{-}1 & \phantom{-}1 &\phantom{-}0 &\phantom{-}1 &\phantom{-}0 &\phantom{-}0\\ \phantom{-}1 & -1 & -1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1\\ \phantom{-}1 & \phantom{-}0 & -1 &\phantom{-}0 &\phantom{-}0 & \phantom{-}1\\ \phantom{-}1 & \phantom{-}1 & -1 &\phantom{-}1 & -1 &\phantom{-}1 \end{pmatrix} \begin{pmatrix} E_0 \\ E_x \\ E_y \\ E_{xx} \\ E_{xy} \\ E_{yy} \end{pmatrix} \end{eqnarray} or $\underline{e}=\underline{\underline{a}}\underline{E}$. The problem is then to find $\underline{E}$ given $\underline{e}$. This is an overconstrained problem so a fit is required. Forming \begin{eqnarray} \chi^2 = \sum_{k=1}^8 \left(e_k - \sum_{j=1}^6 a_{kj}E_j\right)^2 \end{eqnarray} then \begin{eqnarray} \frac{\partial \chi^2}{\partial E_i} = \sum_{k=1}^8 - 2\left(e_k - \sum_{j=1}^6 a_{kj} E_j \right) a_{ki} \end{eqnarray} and so for the minimum $\chi^2$ \begin{eqnarray} \sum_{j=1}^6 \sum_{k=1}^8 a_{ki} a_{kj} E_j = \sum_{k=1}^8 e_k a_{ki} \qquad\mbox{or}\qquad \underline{\underline{a}}^T \underline{\underline{a}} \underline{E} = \underline{\underline{a}}^T \underline{e} \end{eqnarray} With $\underline{\underline{M}}=\underline{\underline{a}}^T \underline{\underline{a}}$, then \begin{eqnarray} \underline{E} = \underline{\underline{M}}^{-1} \underline{\underline{a}}^T \underline{e} \end{eqnarray} gives the required solution. Using $\underline{\underline{a}}$ above, then \begin{eqnarray} \underline{\underline{M}} &=& \begin{pmatrix} \phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1 & \phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1\\ -1 &\phantom{-}0 &\phantom{-}1 & -1 &\phantom{-}1 & -1 &\phantom{-}0 &\phantom{-}1\\ \phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}0 &\phantom{-}0 & -1 & -1 & -1 \\ \phantom{-}1 & \phantom{-}0 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1 & \phantom{-}1 & \phantom{-}0 &\phantom{-}1\\ -1 &\phantom{-}0 &\phantom{-}1 & \phantom{-}0 &\phantom{-}0 & \phantom{-}1 &\phantom{-}0 & -1\\ \phantom{-}1 &\phantom{-}1 &\phantom{-}1 & \phantom{-}0 &\phantom{-}0 &\phantom{-}1 & \phantom{-}1 &\phantom{-}1 \end{pmatrix} \begin{pmatrix} \phantom{-}1 & -1 &\phantom{-}1 &\phantom{-}1 & -1 &\phantom{-}1\\ \phantom{-}1 &\phantom{-}0 &\phantom{-}1 &\phantom{-}0 &\phantom{-}0 &\phantom{-}1\\ \phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1\\ \phantom{-}1 & -1 &\phantom{-}0 &\phantom{-}1 &\phantom{-}0 &\phantom{-}0\\ \phantom{-}1 & \phantom{-}1 &\phantom{-}0 &\phantom{-}1 &\phantom{-}0 &\phantom{-}0\\ \phantom{-}1 & -1 & -1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1\\ \phantom{-}1 & \phantom{-}0 & -1 &\phantom{-}0 &\phantom{-}0 & \phantom{-}1\\ \phantom{-}1 & \phantom{-}1 & -1 &\phantom{-}1 & -1 &\phantom{-}1 \end{pmatrix}\\ &=& \begin{pmatrix} \phantom{-}8 &\phantom{-}0 &\phantom{-}0 &\phantom{-}6 &\phantom{-}0 &\phantom{-}6\\ \phantom{-}0 &\phantom{-}6 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0\\ \phantom{-}0 &\phantom{-}0 &\phantom{-}6 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0\\ \phantom{-}6 &\phantom{-}0 &\phantom{-}0 &\phantom{-}6 &\phantom{-}0 &\phantom{-}4\\ \phantom{-}0 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0 &\phantom{-}4 &\phantom{-}0\\ \phantom{-}6 &\phantom{-}0 &\phantom{-}0 &\phantom{-}4 &\phantom{-}0 &\phantom{-}6 \end{pmatrix} \end{eqnarray} for which \begin{eqnarray} \underline{\underline{M}}^{-1} &=& \begin{pmatrix} \phantom{-}5/4 &\phantom{-}0 &\phantom{-}0 & -3/4 &\phantom{-}0 & -3/4\\ \phantom{-}0 &\phantom{-}1/6 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0\\ \phantom{-}0 &\phantom{-}0 &\phantom{-}1/6 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0\\ -3/4 &\phantom{-}0 &\phantom{-}0 &\phantom{-}3/4 &\phantom{-}0 &\phantom{-}1/4\\ \phantom{-}0 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0 &\phantom{-}1/4 &\phantom{-}0\\ -3/4 &\phantom{-}0 &\phantom{-}0 &\phantom{-}1/4 &\phantom{-}0 &\phantom{-}3/4 \end{pmatrix} \end{eqnarray} Hence \begin{eqnarray} \underline{\underline{M}}^{-1}\underline{\underline{a}}^T &=& \begin{pmatrix} \phantom{-}5/4 &\phantom{-}0 &\phantom{-}0 & -3/4 &\phantom{-}0 & -3/4\\ \phantom{-}0 &\phantom{-}1/6 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0\\ \phantom{-}0 &\phantom{-}0 &\phantom{-}1/6 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0\\ -3/4 &\phantom{-}0 &\phantom{-}0 &\phantom{-}3/4 &\phantom{-}0 &\phantom{-}1/4\\ \phantom{-}0 &\phantom{-}0 &\phantom{-}0 &\phantom{-}0 &\phantom{-}1/4 &\phantom{-}0\\ -3/4 &\phantom{-}0 &\phantom{-}0 &\phantom{-}1/4 &\phantom{-}0 &\phantom{-}3/4 \end{pmatrix} \begin{pmatrix} \phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1 & \phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1\\ -1 &\phantom{-}0 &\phantom{-}1 & -1 &\phantom{-}1 & -1 &\phantom{-}0 &\phantom{-}1\\ \phantom{-}1 &\phantom{-}1 &\phantom{-}1 &\phantom{-}0 &\phantom{-}0 & -1 & -1 & -1 \\ \phantom{-}1 & \phantom{-}0 &\phantom{-}1 &\phantom{-}1 &\phantom{-}1 & \phantom{-}1 & \phantom{-}0 &\phantom{-}1\\ -1 &\phantom{-}0 &\phantom{-}1 & \phantom{-}0 &\phantom{-}0 & \phantom{-}1 &\phantom{-}0 & -1\\ \phantom{-}1 &\phantom{-}1 &\phantom{-}1 & \phantom{-}0 &\phantom{-}0 &\phantom{-}1 & \phantom{-}1 &\phantom{-}1 \end{pmatrix}\nonumber\\ &=& \begin{pmatrix} -1/4 &\phantom{-}1/2 & -1/4 & \phantom{-}1/2 & \phantom{-}1/2 & -1/4 & \phantom{-}1/2 & -1/4\\ -1/6 &\phantom{-}0 & \phantom{-}1/6 & -1/6 & \phantom{-}1/6 & -1/6 & \phantom{-}0 & \phantom{-}1/6\\ \phantom{-}1/6 &\phantom{-}1/6 & \phantom{-}1/6 &\phantom{-}0 & \phantom{-}0 & -1/6 & -1/6 & -1/6\\ \phantom{-}1/4 & -1/2 & \phantom{-}1/4 &\phantom{-}0 & \phantom{-}0 & \phantom{-}1/4 & -1/2 & \phantom{-}1/4\\ -1/4 & \phantom{-}0 & \phantom{-}1/4 &\phantom{-}0 & \phantom{-}0 & \phantom{-}1/4 & \phantom{-}0 & -1/4\\ \phantom{-}1/4 & \phantom{-}0 & \phantom{-}1/4 & -1/2 & -1/2 & \phantom{-}1/4 & \phantom{-}0 & \phantom{-}1/4 \end{pmatrix} \end{eqnarray} Hence, the interpolation to the central bin is simply done by the first line of the above, i.e. \begin{eqnarray} E_0 = \frac{e_2+e_4+e_5+e_7}{2} - \frac{e_1+e_3+e_6+e_8}{4} \end{eqnarray} where the first group are the horizonal and vertical nearest neighbours and the second group are the diagonal nearest neighbours. \section{Trigger rates} Consider a target fraction of BXs which trigger of $1/r$, so $r$ is the average number of BX between triggers. The fat BX period is $f$ and the time multiplex period is $m$. For current assumptions, $1/r = 750/40000 = 0.01875$ so $r = 53.33$, while $f=107$ and $m=18$. With a fat event prescale $s$, then for finite $s$ the target fraction must be maintained. Let $p=1/a$ be the probability of a non-fat BX triggering. Within one fat BX period, there is one fat BX and $f-1$ non-fat BXs. The fat BX can trigger due to the usual L1Accept or due to prescaling. The total probability of it triggering is \begin{eqnarray} 1 - (1- p)\left(1- \frac{1}{s}\right) = p + \frac{1}{s} - \frac{p}{s} \end{eqnarray} Hence the fraction of BXs which trigger is \begin{eqnarray} p\frac{(f-1)}{f} + \left(p + \frac{1}{s} - \frac{p}{s}\right)\frac{1}{f} = p + \frac{1-p}{sf} \end{eqnarray} which must be $1/r$. Hence \begin{eqnarray} \frac{f}{r} = p\left[f - \frac{1}{s}\right]+ \frac{1}{s} \end{eqnarray} and so \begin{eqnarray} p = \frac{1}{a} = \frac{f/r - 1/s}{f - 1/s} \end{eqnarray} Clearly for $s = \infty$ then $p = 1/a = 1/r$ as expected. Note, this requires $f > r$ for values of the prescale down to $s=1$; i.e. the fat BX period must not be less than the average number of BXs between triggers for a prescale of one. Note also that the above is independent of any time multiplexing. Considering time multiplexing, the assuming the fat BX period is a prime, then the repetition period is $mf$ BXs long. Within this time, there are $m$ fat BXs and $f$ time multiplex BXs. Of these, one BX is both fat and time multiplexed, so there are $m-1$ fat BXs which are not time multiplexed and $f-1$ time multiplexed BXs which are not fat. The remainder, which is \begin{eqnarray} mf -(m-1)-(f-1)-1 = mf-m-f+1 = m(f-1)-(f-1) = (m-1)(f-1) \end{eqnarray} are normal BXs. The number of the $mf$ BXs which trigger is \begin{eqnarray} (p + 1/s - p/s)\frac{1}{mf},\quad (p + 1/s - p/s)\frac{m-1}{mf},\quad p\frac{f-1}{mf},\quad p\frac{(m-1)(f-1)}{mf} \end{eqnarray} On a TPG time multiplexing board which handles all L1Accepts but only saves non-trivial data for time multiplexed BXs, then the second and fourth categories are treated as normal L1Accepts, with a total fraction of \begin{eqnarray} F_0 &=& (p + 1/s - p/s)\frac{m-1}{mf}+ p\frac{(m-1)(f-1)}{mf} = p \frac{(m-1)+(m-1)(f-1)}{mf} + \frac{(1-p)}{s}\frac{(m-1)}{mf}\\ &=& p \frac{(m-1)f}{mf} + \frac{(1-p)}{s}\frac{(m-1)}{mf} = p \frac{m-1}{m} + \frac{(1-p)}{s}\frac{(m-1)}{mf} \end{eqnarray} The time multiplexed events have a fraction \begin{eqnarray} F_1 = p\frac{f-1}{mf} \end{eqnarray} and the fat time multiplexed events have a fraction \begin{eqnarray} F_2 = (p + 1/s - p/s)\frac{1}{mf} \end{eqnarray} To check, the total fraction is \begin{eqnarray} F_0+F_1+F_2 &=& p \frac{m-1}{m} + \frac{(1-p)}{s}\frac{(m-1)}{mf} +p\frac{f-1}{mf} +(p + 1/s - p/s)\frac{1}{mf}\\ &=& \frac{1}{mf}\left[pf(m-1)+ \frac{(1-p)(m-1)}{s} + p(f-1) + p + \frac{1}{s} - \frac{p}{s}\right]\\ &=& \frac{1}{mf}\left[pfm + \frac{1}{s}\left(1+(1-p)(m-1) - p\right)\right]\\ &=& p + \frac{m(1-p)}{smf} = p + \frac{(1-p)}{sf} \end{eqnarray} as shown above. For the assumption numbers gives previously and $s=1$, then \begin{eqnarray} p = 0.009493,\quad F_0 = 0.01771\quad F_1 = 0.0005225,\quad F_2 = 0.0005192 \end{eqnarray} which in terms of rate in kHz are \begin{eqnarray} R_0 = 708.333,\quad R_1 = 20.898,\quad R_2 = 20.768 \end{eqnarray}  vpalladi committed May 13, 2016 1192 \end{document}