Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
PESA::T2TrackBSLLPoly Class Reference

Class that knows details of LogLikelihood approximation with a polynomial. More...

#include <T2TrackBSLLPoly.h>

Collaboration diagram for PESA::T2TrackBSLLPoly:

Public Member Functions

 T2TrackBSLLPoly (double beam_size)
 
void update (double z0, double d0, double phi0, double d0_var, std::vector< double > &coeff)
 Update polynomial coefficients with track data. More...
 

Static Public Member Functions

static unsigned nbins ()
 Return number of bins in the histogram for all plynomial coefficients (and few other numbers). More...
 
static int idx (unsigned power_Bx, unsigned power_By, unsigned power_tx, unsigned power_ty, unsigned power_omegax, unsigned power_omegay)
 Return bin number (0-based) for a monomial coefficient given the powers of the variables in a monomial. More...
 

Private Attributes

double m_beam_size
 

Detailed Description

Class that knows details of LogLikelihood approximation with a polynomial.

Few particular things that this class handles:

The approximation of the LL function looks like (factorized):

LL = - (d_0 + B_x*sin(phi) - B_y*cos(phi) + t_x*z_0*sin(phi)

(ln(Sigma) + S_prime/Sigma - (S_prime/Sigma)**2/2)/2 var_b = beam_size**2 Sigma = var_d0 + var_b S_prime = omega_x*sin(phi)**2 + omega_y*cos(phi)**2

The variables here are (B_x, B_y, t_x, t_y, omega_x, omega_y), the rest are either track parameters or constants. beam_size is a constant which should be close to actual transverse beam size (typically 0.01 mm). In the expanded representation the polynomial terms have these possible combinations of powers of omega:

omega_x**2, omega_y**2, omega_x*omega_y, omega_x, omega_y, 1

with total of 6 variants and they don't depend on other variables. Four other variables can appear in the polynomial terms in these combinations:

Together with 6 omega combinations this gives (4+4*3/2+4+1)*6 = 90 monomials.

In addition to the 90 coeeficients we also store other information in the monitored variables:

Definition at line 58 of file T2TrackBSLLPoly.h.

Constructor & Destructor Documentation

◆ T2TrackBSLLPoly()

PESA::T2TrackBSLLPoly::T2TrackBSLLPoly ( double  beam_size)
inlineexplicit

Definition at line 61 of file T2TrackBSLLPoly.h.

61 : m_beam_size(beam_size) {}

Member Function Documentation

◆ idx()

int T2TrackBSLLPoly::idx ( unsigned  power_Bx,
unsigned  power_By,
unsigned  power_tx,
unsigned  power_ty,
unsigned  power_omegax,
unsigned  power_omegay 
)
static

Return bin number (0-based) for a monomial coefficient given the powers of the variables in a monomial.

Returns negative number for unexpected input.

Definition at line 93 of file T2TrackBSLLPoly.cxx.

96 {
97  // Previous error condition returned -1, which would be used as an array index in
98  // T2TrackBSLLPoly::update and return nonsense
99  if (power_Bx > 2 or power_By > 2
100  or power_tx > 2 or power_ty > 2
101  or power_omegax > 2 or power_omegay > 2) {
102  throw std::out_of_range("Power>2: Calculated array index is out of range in T2TrackBSLLPoly::idx");
103  }
104 
105  int idx = g_order[power_Bx][power_By][power_tx][power_ty];
106  if (idx < 0) throw std::out_of_range("idx<0: Calculated array index is out of range in T2TrackBSLLPoly::idx");
107 
108  int idx2 = g_order2[power_omegax][power_omegay];
109  if (idx2 < 0) throw std::out_of_range("idx2<0: Calculated array index is out of range in T2TrackBSLLPoly::idx");
110 
111  return idx*g_size2 + idx2;
112 }

◆ nbins()

unsigned T2TrackBSLLPoly::nbins ( )
static

Return number of bins in the histogram for all plynomial coefficients (and few other numbers).

Definition at line 80 of file T2TrackBSLLPoly.cxx.

81 {
82  // two extra bins to count number of tracks and beam_size*n_tracks
83  return
84  g_size*g_size2 // all polynomial coefficients
85  + 1 // Sum(z0)
86  + 1 // Sum(z0**2)
87  + 1 // Sum(1)
88  + 1 // Sum(beam_size)
89  ;
90 }

◆ update()

void T2TrackBSLLPoly::update ( double  z0,
double  d0,
double  phi0,
double  d0_var,
std::vector< double > &  coeff 
)

Update polynomial coefficients with track data.

If vector is empty it is resized to have nbins() size, otherwise it has to be at least nbins() elements in size.

Definition at line 115 of file T2TrackBSLLPoly.cxx.

116 {
117  if (coeff.empty()) {
118  coeff.resize(nbins(), 0.);
119  }
120 
121  double cos_phi = std::cos(phi);
122  double sin_phi = std::sin(phi);
123  double var_b = m_beam_size*m_beam_size;
124  double var_bd = var_d0 + var_b;
125 
126  // z-0 and its square
127  coeff[g_size*g_size2] += z_0;
128  coeff[g_size*g_size2+1] += z_0*z_0;
129 
130  // store number of tracks and beam_size*n_tracks in last two bins
131  coeff[g_size*g_size2+2] += 1;
132  coeff[g_size*g_size2+3] += m_beam_size;
133 
134  // this code is generated by notebook, no point in changing it here
135  // unless performance is a consideration. Example: pow(cos_phi, 2) is calculated
136  // 23 times
137  using std::pow;
138  coeff[idx(0, 0, 0, 0, 0, 0)] += -pow(d_0, 2)/(2*var_bd);
139  coeff[idx(0, 0, 0, 0, 0, 1)] += pow(cos_phi, 2)*pow(d_0, 2)/(2*pow(var_bd, 2));
140  coeff[idx(0, 0, 0, 0, 0, 2)] += -pow(cos_phi, 4)*pow(d_0, 2)/(2*pow(var_bd, 3));
141  coeff[idx(0, 0, 0, 0, 1, 0)] += pow(d_0, 2)*pow(sin_phi, 2)/(2*pow(var_bd, 2));
142  coeff[idx(0, 0, 0, 0, 1, 1)] += -pow(cos_phi, 2)*pow(d_0, 2)*pow(sin_phi, 2)/pow(var_bd, 3);
143  coeff[idx(0, 0, 0, 0, 2, 0)] += -pow(d_0, 2)*pow(sin_phi, 4)/(2*pow(var_bd, 3));
144  coeff[idx(0, 0, 0, 1, 0, 0)] += cos_phi*d_0*z_0/var_bd;
145  coeff[idx(0, 0, 0, 1, 0, 1)] += -pow(cos_phi, 3)*d_0*z_0/pow(var_bd, 2);
146  coeff[idx(0, 0, 0, 1, 0, 2)] += pow(cos_phi, 5)*d_0*z_0/pow(var_bd, 3);
147  coeff[idx(0, 0, 0, 1, 1, 0)] += -cos_phi*d_0*pow(sin_phi, 2)*z_0/pow(var_bd, 2);
148  coeff[idx(0, 0, 0, 1, 1, 1)] += 2*pow(cos_phi, 3)*d_0*pow(sin_phi, 2)*z_0/pow(var_bd, 3);
149  coeff[idx(0, 0, 0, 1, 2, 0)] += cos_phi*d_0*pow(sin_phi, 4)*z_0/pow(var_bd, 3);
150  coeff[idx(0, 0, 0, 2, 0, 0)] += -pow(cos_phi, 2)*pow(z_0, 2)/(2*var_bd);
151  coeff[idx(0, 0, 0, 2, 0, 1)] += pow(cos_phi, 4)*pow(z_0, 2)/(2*pow(var_bd, 2));
152  coeff[idx(0, 0, 0, 2, 0, 2)] += -pow(cos_phi, 6)*pow(z_0, 2)/(2*pow(var_bd, 3));
153  coeff[idx(0, 0, 0, 2, 1, 0)] += pow(cos_phi, 2)*pow(sin_phi, 2)*pow(z_0, 2)/(2*pow(var_bd, 2));
154  coeff[idx(0, 0, 0, 2, 1, 1)] += -pow(cos_phi, 4)*pow(sin_phi, 2)*pow(z_0, 2)/pow(var_bd, 3);
155  coeff[idx(0, 0, 0, 2, 2, 0)] += -pow(cos_phi, 2)*pow(sin_phi, 4)*pow(z_0, 2)/(2*pow(var_bd, 3));
156  coeff[idx(0, 0, 1, 0, 0, 0)] += -d_0*sin_phi*z_0/var_bd;
157  coeff[idx(0, 0, 1, 0, 0, 1)] += pow(cos_phi, 2)*d_0*sin_phi*z_0/pow(var_bd, 2);
158  coeff[idx(0, 0, 1, 0, 0, 2)] += -pow(cos_phi, 4)*d_0*sin_phi*z_0/pow(var_bd, 3);
159  coeff[idx(0, 0, 1, 0, 1, 0)] += d_0*pow(sin_phi, 3)*z_0/pow(var_bd, 2);
160  coeff[idx(0, 0, 1, 0, 1, 1)] += -2*pow(cos_phi, 2)*d_0*pow(sin_phi, 3)*z_0/pow(var_bd, 3);
161  coeff[idx(0, 0, 1, 0, 2, 0)] += -d_0*pow(sin_phi, 5)*z_0/pow(var_bd, 3);
162  coeff[idx(0, 0, 1, 1, 0, 0)] += cos_phi*sin_phi*pow(z_0, 2)/var_bd;
163  coeff[idx(0, 0, 1, 1, 0, 1)] += -pow(cos_phi, 3)*sin_phi*pow(z_0, 2)/pow(var_bd, 2);
164  coeff[idx(0, 0, 1, 1, 0, 2)] += pow(cos_phi, 5)*sin_phi*pow(z_0, 2)/pow(var_bd, 3);
165  coeff[idx(0, 0, 1, 1, 1, 0)] += -cos_phi*pow(sin_phi, 3)*pow(z_0, 2)/pow(var_bd, 2);
166  coeff[idx(0, 0, 1, 1, 1, 1)] += 2*pow(cos_phi, 3)*pow(sin_phi, 3)*pow(z_0, 2)/pow(var_bd, 3);
167  coeff[idx(0, 0, 1, 1, 2, 0)] += cos_phi*pow(sin_phi, 5)*pow(z_0, 2)/pow(var_bd, 3);
168  coeff[idx(0, 0, 2, 0, 0, 0)] += -pow(sin_phi, 2)*pow(z_0, 2)/(2*var_bd);
169  coeff[idx(0, 0, 2, 0, 0, 1)] += pow(cos_phi, 2)*pow(sin_phi, 2)*pow(z_0, 2)/(2*pow(var_bd, 2));
170  coeff[idx(0, 0, 2, 0, 0, 2)] += -pow(cos_phi, 4)*pow(sin_phi, 2)*pow(z_0, 2)/(2*pow(var_bd, 3));
171  coeff[idx(0, 0, 2, 0, 1, 0)] += pow(sin_phi, 4)*pow(z_0, 2)/(2*pow(var_bd, 2));
172  coeff[idx(0, 0, 2, 0, 1, 1)] += -pow(cos_phi, 2)*pow(sin_phi, 4)*pow(z_0, 2)/pow(var_bd, 3);
173  coeff[idx(0, 0, 2, 0, 2, 0)] += -pow(sin_phi, 6)*pow(z_0, 2)/(2*pow(var_bd, 3));
174  coeff[idx(0, 1, 0, 0, 0, 0)] += cos_phi*d_0/var_bd;
175  coeff[idx(0, 1, 0, 0, 0, 1)] += -pow(cos_phi, 3)*d_0/pow(var_bd, 2);
176  coeff[idx(0, 1, 0, 0, 0, 2)] += pow(cos_phi, 5)*d_0/pow(var_bd, 3);
177  coeff[idx(0, 1, 0, 0, 1, 0)] += -cos_phi*d_0*pow(sin_phi, 2)/pow(var_bd, 2);
178  coeff[idx(0, 1, 0, 0, 1, 1)] += 2*pow(cos_phi, 3)*d_0*pow(sin_phi, 2)/pow(var_bd, 3);
179  coeff[idx(0, 1, 0, 0, 2, 0)] += cos_phi*d_0*pow(sin_phi, 4)/pow(var_bd, 3);
180  coeff[idx(0, 1, 0, 1, 0, 0)] += -pow(cos_phi, 2)*z_0/var_bd;
181  coeff[idx(0, 1, 0, 1, 0, 1)] += pow(cos_phi, 4)*z_0/pow(var_bd, 2);
182  coeff[idx(0, 1, 0, 1, 0, 2)] += -pow(cos_phi, 6)*z_0/pow(var_bd, 3);
183  coeff[idx(0, 1, 0, 1, 1, 0)] += pow(cos_phi, 2)*pow(sin_phi, 2)*z_0/pow(var_bd, 2);
184  coeff[idx(0, 1, 0, 1, 1, 1)] += -2*pow(cos_phi, 4)*pow(sin_phi, 2)*z_0/pow(var_bd, 3);
185  coeff[idx(0, 1, 0, 1, 2, 0)] += -pow(cos_phi, 2)*pow(sin_phi, 4)*z_0/pow(var_bd, 3);
186  coeff[idx(0, 1, 1, 0, 0, 0)] += cos_phi*sin_phi*z_0/var_bd;
187  coeff[idx(0, 1, 1, 0, 0, 1)] += -pow(cos_phi, 3)*sin_phi*z_0/pow(var_bd, 2);
188  coeff[idx(0, 1, 1, 0, 0, 2)] += pow(cos_phi, 5)*sin_phi*z_0/pow(var_bd, 3);
189  coeff[idx(0, 1, 1, 0, 1, 0)] += -cos_phi*pow(sin_phi, 3)*z_0/pow(var_bd, 2);
190  coeff[idx(0, 1, 1, 0, 1, 1)] += 2*pow(cos_phi, 3)*pow(sin_phi, 3)*z_0/pow(var_bd, 3);
191  coeff[idx(0, 1, 1, 0, 2, 0)] += cos_phi*pow(sin_phi, 5)*z_0/pow(var_bd, 3);
192  coeff[idx(0, 2, 0, 0, 0, 0)] += -pow(cos_phi, 2)/(2*var_bd);
193  coeff[idx(0, 2, 0, 0, 0, 1)] += pow(cos_phi, 4)/(2*pow(var_bd, 2));
194  coeff[idx(0, 2, 0, 0, 0, 2)] += -pow(cos_phi, 6)/(2*pow(var_bd, 3));
195  coeff[idx(0, 2, 0, 0, 1, 0)] += pow(cos_phi, 2)*pow(sin_phi, 2)/(2*pow(var_bd, 2));
196  coeff[idx(0, 2, 0, 0, 1, 1)] += -pow(cos_phi, 4)*pow(sin_phi, 2)/pow(var_bd, 3);
197  coeff[idx(0, 2, 0, 0, 2, 0)] += -pow(cos_phi, 2)*pow(sin_phi, 4)/(2*pow(var_bd, 3));
198  coeff[idx(1, 0, 0, 0, 0, 0)] += -d_0*sin_phi/var_bd;
199  coeff[idx(1, 0, 0, 0, 0, 1)] += pow(cos_phi, 2)*d_0*sin_phi/pow(var_bd, 2);
200  coeff[idx(1, 0, 0, 0, 0, 2)] += -pow(cos_phi, 4)*d_0*sin_phi/pow(var_bd, 3);
201  coeff[idx(1, 0, 0, 0, 1, 0)] += d_0*pow(sin_phi, 3)/pow(var_bd, 2);
202  coeff[idx(1, 0, 0, 0, 1, 1)] += -2*pow(cos_phi, 2)*d_0*pow(sin_phi, 3)/pow(var_bd, 3);
203  coeff[idx(1, 0, 0, 0, 2, 0)] += -d_0*pow(sin_phi, 5)/pow(var_bd, 3);
204  coeff[idx(1, 0, 0, 1, 0, 0)] += cos_phi*sin_phi*z_0/var_bd;
205  coeff[idx(1, 0, 0, 1, 0, 1)] += -pow(cos_phi, 3)*sin_phi*z_0/pow(var_bd, 2);
206  coeff[idx(1, 0, 0, 1, 0, 2)] += pow(cos_phi, 5)*sin_phi*z_0/pow(var_bd, 3);
207  coeff[idx(1, 0, 0, 1, 1, 0)] += -cos_phi*pow(sin_phi, 3)*z_0/pow(var_bd, 2);
208  coeff[idx(1, 0, 0, 1, 1, 1)] += 2*pow(cos_phi, 3)*pow(sin_phi, 3)*z_0/pow(var_bd, 3);
209  coeff[idx(1, 0, 0, 1, 2, 0)] += cos_phi*pow(sin_phi, 5)*z_0/pow(var_bd, 3);
210  coeff[idx(1, 0, 1, 0, 0, 0)] += -pow(sin_phi, 2)*z_0/var_bd;
211  coeff[idx(1, 0, 1, 0, 0, 1)] += pow(cos_phi, 2)*pow(sin_phi, 2)*z_0/pow(var_bd, 2);
212  coeff[idx(1, 0, 1, 0, 0, 2)] += -pow(cos_phi, 4)*pow(sin_phi, 2)*z_0/pow(var_bd, 3);
213  coeff[idx(1, 0, 1, 0, 1, 0)] += pow(sin_phi, 4)*z_0/pow(var_bd, 2);
214  coeff[idx(1, 0, 1, 0, 1, 1)] += -2*pow(cos_phi, 2)*pow(sin_phi, 4)*z_0/pow(var_bd, 3);
215  coeff[idx(1, 0, 1, 0, 2, 0)] += -pow(sin_phi, 6)*z_0/pow(var_bd, 3);
216  coeff[idx(1, 1, 0, 0, 0, 0)] += cos_phi*sin_phi/var_bd;
217  coeff[idx(1, 1, 0, 0, 0, 1)] += -pow(cos_phi, 3)*sin_phi/pow(var_bd, 2);
218  coeff[idx(1, 1, 0, 0, 0, 2)] += pow(cos_phi, 5)*sin_phi/pow(var_bd, 3);
219  coeff[idx(1, 1, 0, 0, 1, 0)] += -cos_phi*pow(sin_phi, 3)/pow(var_bd, 2);
220  coeff[idx(1, 1, 0, 0, 1, 1)] += 2*pow(cos_phi, 3)*pow(sin_phi, 3)/pow(var_bd, 3);
221  coeff[idx(1, 1, 0, 0, 2, 0)] += cos_phi*pow(sin_phi, 5)/pow(var_bd, 3);
222  coeff[idx(2, 0, 0, 0, 0, 0)] += -pow(sin_phi, 2)/(2*var_bd);
223  coeff[idx(2, 0, 0, 0, 0, 1)] += pow(cos_phi, 2)*pow(sin_phi, 2)/(2*pow(var_bd, 2));
224  coeff[idx(2, 0, 0, 0, 0, 2)] += -pow(cos_phi, 4)*pow(sin_phi, 2)/(2*pow(var_bd, 3));
225  coeff[idx(2, 0, 0, 0, 1, 0)] += pow(sin_phi, 4)/(2*pow(var_bd, 2));
226  coeff[idx(2, 0, 0, 0, 1, 1)] += -pow(cos_phi, 2)*pow(sin_phi, 4)/pow(var_bd, 3);
227  coeff[idx(2, 0, 0, 0, 2, 0)] += -pow(sin_phi, 6)/(2*pow(var_bd, 3));
228  coeff[idx(0, 0, 0, 0, 0, 0)+90] += -log(var_bd)/2;
229  coeff[idx(0, 0, 0, 0, 0, 1)+90] += -pow(cos_phi, 2)/(2*var_bd);
230  coeff[idx(0, 0, 0, 0, 0, 2)+90] += pow(cos_phi, 4)/(4*pow(var_bd, 2));
231  coeff[idx(0, 0, 0, 0, 1, 0)+90] += -pow(sin_phi, 2)/(2*var_bd);
232  coeff[idx(0, 0, 0, 0, 1, 1)+90] += pow(cos_phi, 2)*pow(sin_phi, 2)/(2*pow(var_bd, 2));
233  coeff[idx(0, 0, 0, 0, 2, 0)+90] += pow(sin_phi, 4)/(4*pow(var_bd, 2));
234 }

Member Data Documentation

◆ m_beam_size

double PESA::T2TrackBSLLPoly::m_beam_size
private

Definition at line 88 of file T2TrackBSLLPoly.h.


The documentation for this class was generated from the following files:
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
PESA::T2TrackBSLLPoly::idx
static int idx(unsigned power_Bx, unsigned power_By, unsigned power_tx, unsigned power_ty, unsigned power_omegax, unsigned power_omegay)
Return bin number (0-based) for a monomial coefficient given the powers of the variables in a monomia...
Definition: T2TrackBSLLPoly.cxx:93
PESA::T2TrackBSLLPoly::nbins
static unsigned nbins()
Return number of bins in the histogram for all plynomial coefficients (and few other numbers).
Definition: T2TrackBSLLPoly.cxx:80
MuonCalib::Legendre::coeff
constexpr double coeff(const unsigned l, const unsigned k)
Calculates the n-th coefficient of the legendre polynomial series.
Definition: LegendrePoly.h:92
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
PESA::T2TrackBSLLPoly::m_beam_size
double m_beam_size
Definition: T2TrackBSLLPoly.h:88