ATLAS Offline Software
Loading...
Searching...
No Matches
T2TrackBSLLPoly.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2019, 2025 CERN for the benefit of the ATLAS collaboration
3*/
4#include "T2TrackBSLLPoly.h"
5#include "idx.h"
6
7#include <cmath>
8#include <cstdint>
9
10
11
12
13using namespace PESA;
14
15
16
17void
18T2TrackBSLLPoly::update(double z0, double d0, double phi, double var_d0, std::vector<double>& coeff)
19{
20 if (coeff.empty()) {
21 coeff.resize(nbins, 0.);
22 }
23
24 double cos_phi = std::cos(phi);
25 double sin_phi = std::sin(phi);
26 double var_b = m_beam_size*m_beam_size;
27 double var_bd = var_d0 + var_b;
28 double pow_cos_phi[7]{};
29 double pow_sin_phi[7]{};
30 double pow_var_bd[4]{};
31 for (size_t i=2; i<7; ++i) {
32 pow_cos_phi[i] = std::pow(cos_phi, i);
33 pow_sin_phi[i] = std::pow(sin_phi, i);
34 }
35 for (size_t i=2; i<4; ++i) {
36 pow_var_bd[i] = std::pow(var_bd, i);
37 }
38 double pow2_d0 = std::pow(d0, 2);
39 double pow2_z0 = std::pow(z0, 2);
40
41 // z0 and its square
42 coeff[g_size*g_size2] += z0;
43 coeff[g_size*g_size2+1] += pow2_z0;
44
45 // store number of tracks and beam_size*n_tracks in last two bins
46 coeff[g_size*g_size2+2] += 1;
47 coeff[g_size*g_size2+3] += m_beam_size;
48
49 coeff[idx<0, 0, 0, 0, 0, 0>()] += -pow2_d0/(2*var_bd);
50 coeff[idx<0, 0, 0, 0, 0, 1>()] += pow_cos_phi[2]*pow2_d0/(2*pow_var_bd[2]);
51 coeff[idx<0, 0, 0, 0, 0, 2>()] += -pow_cos_phi[4]*pow2_d0/(2*pow_var_bd[3]);
52 coeff[idx<0, 0, 0, 0, 1, 0>()] += pow2_d0*pow_sin_phi[2]/(2*pow_var_bd[2]);
53 coeff[idx<0, 0, 0, 0, 1, 1>()] += -pow_cos_phi[2]*pow2_d0*pow_sin_phi[2]/pow_var_bd[3];
54 coeff[idx<0, 0, 0, 0, 2, 0>()] += -pow2_d0*pow_sin_phi[4]/(2*pow_var_bd[3]);
55 coeff[idx<0, 0, 0, 1, 0, 0>()] += cos_phi*d0*z0/var_bd;
56 coeff[idx<0, 0, 0, 1, 0, 1>()] += -pow_cos_phi[3]*d0*z0/pow_var_bd[2];
57 coeff[idx<0, 0, 0, 1, 0, 2>()] += pow_cos_phi[5]*d0*z0/pow_var_bd[3];
58 coeff[idx<0, 0, 0, 1, 1, 0>()] += -cos_phi*d0*pow_sin_phi[2]*z0/pow_var_bd[2];
59 coeff[idx<0, 0, 0, 1, 1, 1>()] += 2*pow_cos_phi[3]*d0*pow_sin_phi[2]*z0/pow_var_bd[3];
60 coeff[idx<0, 0, 0, 1, 2, 0>()] += cos_phi*d0*pow_sin_phi[4]*z0/pow_var_bd[3];
61 coeff[idx<0, 0, 0, 2, 0, 0>()] += -pow_cos_phi[2]*pow2_z0/(2*var_bd);
62 coeff[idx<0, 0, 0, 2, 0, 1>()] += pow_cos_phi[4]*pow2_z0/(2*pow_var_bd[2]);
63 coeff[idx<0, 0, 0, 2, 0, 2>()] += -pow_cos_phi[6]*pow2_z0/(2*pow_var_bd[3]);
64 coeff[idx<0, 0, 0, 2, 1, 0>()] += pow_cos_phi[2]*pow_sin_phi[2]*pow2_z0/(2*pow_var_bd[2]);
65 coeff[idx<0, 0, 0, 2, 1, 1>()] += -pow_cos_phi[4]*pow_sin_phi[2]*pow2_z0/pow_var_bd[3];
66 coeff[idx<0, 0, 0, 2, 2, 0>()] += -pow_cos_phi[2]*pow_sin_phi[4]*pow2_z0/(2*pow_var_bd[3]);
67 coeff[idx<0, 0, 1, 0, 0, 0>()] += -d0*sin_phi*z0/var_bd;
68 coeff[idx<0, 0, 1, 0, 0, 1>()] += pow_cos_phi[2]*d0*sin_phi*z0/pow_var_bd[2];
69 coeff[idx<0, 0, 1, 0, 0, 2>()] += -pow_cos_phi[4]*d0*sin_phi*z0/pow_var_bd[3];
70 coeff[idx<0, 0, 1, 0, 1, 0>()] += d0*pow_sin_phi[3]*z0/pow_var_bd[2];
71 coeff[idx<0, 0, 1, 0, 1, 1>()] += -2*pow_cos_phi[2]*d0*pow_sin_phi[3]*z0/pow_var_bd[3];
72 coeff[idx<0, 0, 1, 0, 2, 0>()] += -d0*pow_sin_phi[5]*z0/pow_var_bd[3];
73 coeff[idx<0, 0, 1, 1, 0, 0>()] += cos_phi*sin_phi*pow2_z0/var_bd;
74 coeff[idx<0, 0, 1, 1, 0, 1>()] += -pow_cos_phi[3]*sin_phi*pow2_z0/pow_var_bd[2];
75 coeff[idx<0, 0, 1, 1, 0, 2>()] += pow_cos_phi[5]*sin_phi*pow2_z0/pow_var_bd[3];
76 coeff[idx<0, 0, 1, 1, 1, 0>()] += -cos_phi*pow_sin_phi[3]*pow2_z0/pow_var_bd[2];
77 coeff[idx<0, 0, 1, 1, 1, 1>()] += 2*pow_cos_phi[3]*pow_sin_phi[3]*pow2_z0/pow_var_bd[3];
78 coeff[idx<0, 0, 1, 1, 2, 0>()] += cos_phi*pow_sin_phi[5]*pow2_z0/pow_var_bd[3];
79 coeff[idx<0, 0, 2, 0, 0, 0>()] += -pow_sin_phi[2]*pow2_z0/(2*var_bd);
80 coeff[idx<0, 0, 2, 0, 0, 1>()] += pow_cos_phi[2]*pow_sin_phi[2]*pow2_z0/(2*pow_var_bd[2]);
81 coeff[idx<0, 0, 2, 0, 0, 2>()] += -pow_cos_phi[4]*pow_sin_phi[2]*pow2_z0/(2*pow_var_bd[3]);
82 coeff[idx<0, 0, 2, 0, 1, 0>()] += pow_sin_phi[4]*pow2_z0/(2*pow_var_bd[2]);
83 coeff[idx<0, 0, 2, 0, 1, 1>()] += -pow_cos_phi[2]*pow_sin_phi[4]*pow2_z0/pow_var_bd[3];
84 coeff[idx<0, 0, 2, 0, 2, 0>()] += -pow_sin_phi[6]*pow2_z0/(2*pow_var_bd[3]);
85 coeff[idx<0, 1, 0, 0, 0, 0>()] += cos_phi*d0/var_bd;
86 coeff[idx<0, 1, 0, 0, 0, 1>()] += -pow_cos_phi[3]*d0/pow_var_bd[2];
87 coeff[idx<0, 1, 0, 0, 0, 2>()] += pow_cos_phi[5]*d0/pow_var_bd[3];
88 coeff[idx<0, 1, 0, 0, 1, 0>()] += -cos_phi*d0*pow_sin_phi[2]/pow_var_bd[2];
89 coeff[idx<0, 1, 0, 0, 1, 1>()] += 2*pow_cos_phi[3]*d0*pow_sin_phi[2]/pow_var_bd[3];
90 coeff[idx<0, 1, 0, 0, 2, 0>()] += cos_phi*d0*pow_sin_phi[4]/pow_var_bd[3];
91 coeff[idx<0, 1, 0, 1, 0, 0>()] += -pow_cos_phi[2]*z0/var_bd;
92 coeff[idx<0, 1, 0, 1, 0, 1>()] += pow_cos_phi[4]*z0/pow_var_bd[2];
93 coeff[idx<0, 1, 0, 1, 0, 2>()] += -pow_cos_phi[6]*z0/pow_var_bd[3];
94 coeff[idx<0, 1, 0, 1, 1, 0>()] += pow_cos_phi[2]*pow_sin_phi[2]*z0/pow_var_bd[2];
95 coeff[idx<0, 1, 0, 1, 1, 1>()] += -2*pow_cos_phi[4]*pow_sin_phi[2]*z0/pow_var_bd[3];
96 coeff[idx<0, 1, 0, 1, 2, 0>()] += -pow_cos_phi[2]*pow_sin_phi[4]*z0/pow_var_bd[3];
97 coeff[idx<0, 1, 1, 0, 0, 0>()] += cos_phi*sin_phi*z0/var_bd;
98 coeff[idx<0, 1, 1, 0, 0, 1>()] += -pow_cos_phi[3]*sin_phi*z0/pow_var_bd[2];
99 coeff[idx<0, 1, 1, 0, 0, 2>()] += pow_cos_phi[5]*sin_phi*z0/pow_var_bd[3];
100 coeff[idx<0, 1, 1, 0, 1, 0>()] += -cos_phi*pow_sin_phi[3]*z0/pow_var_bd[2];
101 coeff[idx<0, 1, 1, 0, 1, 1>()] += 2*pow_cos_phi[3]*pow_sin_phi[3]*z0/pow_var_bd[3];
102 coeff[idx<0, 1, 1, 0, 2, 0>()] += cos_phi*pow_sin_phi[5]*z0/pow_var_bd[3];
103 coeff[idx<0, 2, 0, 0, 0, 0>()] += -pow_cos_phi[2]/(2*var_bd);
104 coeff[idx<0, 2, 0, 0, 0, 1>()] += pow_cos_phi[4]/(2*pow_var_bd[2]);
105 coeff[idx<0, 2, 0, 0, 0, 2>()] += -pow_cos_phi[6]/(2*pow_var_bd[3]);
106 coeff[idx<0, 2, 0, 0, 1, 0>()] += pow_cos_phi[2]*pow_sin_phi[2]/(2*pow_var_bd[2]);
107 coeff[idx<0, 2, 0, 0, 1, 1>()] += -pow_cos_phi[4]*pow_sin_phi[2]/pow_var_bd[3];
108 coeff[idx<0, 2, 0, 0, 2, 0>()] += -pow_cos_phi[2]*pow_sin_phi[4]/(2*pow_var_bd[3]);
109 coeff[idx<1, 0, 0, 0, 0, 0>()] += -d0*sin_phi/var_bd;
110 coeff[idx<1, 0, 0, 0, 0, 1>()] += pow_cos_phi[2]*d0*sin_phi/pow_var_bd[2];
111 coeff[idx<1, 0, 0, 0, 0, 2>()] += -pow_cos_phi[4]*d0*sin_phi/pow_var_bd[3];
112 coeff[idx<1, 0, 0, 0, 1, 0>()] += d0*pow_sin_phi[3]/pow_var_bd[2];
113 coeff[idx<1, 0, 0, 0, 1, 1>()] += -2*pow_cos_phi[2]*d0*pow_sin_phi[3]/pow_var_bd[3];
114 coeff[idx<1, 0, 0, 0, 2, 0>()] += -d0*pow_sin_phi[5]/pow_var_bd[3];
115 coeff[idx<1, 0, 0, 1, 0, 0>()] += cos_phi*sin_phi*z0/var_bd;
116 coeff[idx<1, 0, 0, 1, 0, 1>()] += -pow_cos_phi[3]*sin_phi*z0/pow_var_bd[2];
117 coeff[idx<1, 0, 0, 1, 0, 2>()] += pow_cos_phi[5]*sin_phi*z0/pow_var_bd[3];
118 coeff[idx<1, 0, 0, 1, 1, 0>()] += -cos_phi*pow_sin_phi[3]*z0/pow_var_bd[2];
119 coeff[idx<1, 0, 0, 1, 1, 1>()] += 2*pow_cos_phi[3]*pow_sin_phi[3]*z0/pow_var_bd[3];
120 coeff[idx<1, 0, 0, 1, 2, 0>()] += cos_phi*pow_sin_phi[5]*z0/pow_var_bd[3];
121 coeff[idx<1, 0, 1, 0, 0, 0>()] += -pow_sin_phi[2]*z0/var_bd;
122 coeff[idx<1, 0, 1, 0, 0, 1>()] += pow_cos_phi[2]*pow_sin_phi[2]*z0/pow_var_bd[2];
123 coeff[idx<1, 0, 1, 0, 0, 2>()] += -pow_cos_phi[4]*pow_sin_phi[2]*z0/pow_var_bd[3];
124 coeff[idx<1, 0, 1, 0, 1, 0>()] += pow_sin_phi[4]*z0/pow_var_bd[2];
125 coeff[idx<1, 0, 1, 0, 1, 1>()] += -2*pow_cos_phi[2]*pow_sin_phi[4]*z0/pow_var_bd[3];
126 coeff[idx<1, 0, 1, 0, 2, 0>()] += -pow_sin_phi[6]*z0/pow_var_bd[3];
127 coeff[idx<1, 1, 0, 0, 0, 0>()] += cos_phi*sin_phi/var_bd;
128 coeff[idx<1, 1, 0, 0, 0, 1>()] += -pow_cos_phi[3]*sin_phi/pow_var_bd[2];
129 coeff[idx<1, 1, 0, 0, 0, 2>()] += pow_cos_phi[5]*sin_phi/pow_var_bd[3];
130 coeff[idx<1, 1, 0, 0, 1, 0>()] += -cos_phi*pow_sin_phi[3]/pow_var_bd[2];
131 coeff[idx<1, 1, 0, 0, 1, 1>()] += 2*pow_cos_phi[3]*pow_sin_phi[3]/pow_var_bd[3];
132 coeff[idx<1, 1, 0, 0, 2, 0>()] += cos_phi*pow_sin_phi[5]/pow_var_bd[3];
133 coeff[idx<2, 0, 0, 0, 0, 0>()] += -pow_sin_phi[2]/(2*var_bd);
134 coeff[idx<2, 0, 0, 0, 0, 1>()] += pow_cos_phi[2]*pow_sin_phi[2]/(2*pow_var_bd[2]);
135 coeff[idx<2, 0, 0, 0, 0, 2>()] += -pow_cos_phi[4]*pow_sin_phi[2]/(2*pow_var_bd[3]);
136 coeff[idx<2, 0, 0, 0, 1, 0>()] += pow_sin_phi[4]/(2*pow_var_bd[2]);
137 coeff[idx<2, 0, 0, 0, 1, 1>()] += -pow_cos_phi[2]*pow_sin_phi[4]/pow_var_bd[3];
138 coeff[idx<2, 0, 0, 0, 2, 0>()] += -pow_sin_phi[6]/(2*pow_var_bd[3]);
139 coeff[idx<0, 0, 0, 0, 0, 0>() +90] += -std::log(var_bd)/2;
140 coeff[idx<0, 0, 0, 0, 0, 1>() +90] += -pow_cos_phi[2]/(2*var_bd);
141 coeff[idx<0, 0, 0, 0, 0, 2>() +90] += pow_cos_phi[4]/(4*pow_var_bd[2]);
142 coeff[idx<0, 0, 0, 0, 1, 0>() +90] += -pow_sin_phi[2]/(2*var_bd);
143 coeff[idx<0, 0, 0, 0, 1, 1>() +90] += pow_cos_phi[2]*pow_sin_phi[2]/(2*pow_var_bd[2]);
144 coeff[idx<0, 0, 0, 0, 2, 0>() +90] += pow_sin_phi[4]/(4*pow_var_bd[2]);
145}
Scalar phi() const
phi method
void update(double z0, double d0, double phi0, double d0_var, std::vector< double > &coeff)
Update polynomial coefficients with track data.
Local tools.
Definition idx.h:9
constexpr unsigned g_size
Definition idx.h:60
constexpr unsigned nbins
Definition idx.h:73
consteval int idx()
Definition idx.h:85
constexpr unsigned g_size2
Definition idx.h:71