ATLAS Offline Software
Loading...
Searching...
No Matches
TrackParticlexAODHelpers.h
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5*/
6
7// $Id: $
8#ifndef XAOD_TRACKPARTICLEXAODHELPERS_H
9#define XAOD_TRACKPARTICLEXAODHELPERS_H
10
12#include "xAODTracking/Vertex.h"
13#include <cmath>
14
15
16namespace xAOD {
17
18 namespace TrackingHelpers {
20 inline
21 double sqr(double a) { return a*a; }
22
27 double d0significance(const xAOD::TrackParticle *tp);
28
34 inline
36 double d0 = tp->d0();
37 // elements in definingParametersCovMatrixDiagVec should be : sigma_d0^2, sigma_z0^2
38 double sigma_d0 = std::sqrt( tp->definingParametersCovMatrixDiagVec()[0] );
39 return d0/sigma_d0;
40 }
41
48 inline
49 double d0UncertaintyBeamSpot2(double track_phi0, double beam_sigma_x,double beam_sigma_y, double beam_sigma_xy) {
50 double sin_phi = sin(track_phi0);
51 double cos_phi = cos(track_phi0);
52 double d0_uncert2= sin_phi * ( sin_phi * sqr(beam_sigma_x)
53 -cos_phi * beam_sigma_xy)
54 +cos_phi * ( cos_phi * sqr(beam_sigma_y)
55 -sin_phi * beam_sigma_xy);
56 return d0_uncert2;
57 }
58
59
67 double d0significance(const xAOD::TrackParticle *tp, double beam_sigma_x, double beam_sigma_y, double beam_sigma_xy);
68
77 // In case beam_sigma_xy is larger than the square of beam_sigma_x and the square of beam_sigma_y the result is undefined.
79 inline
80 double d0significanceUnsafe(const xAOD::TrackParticle *tp, double beam_sigma_x,double beam_sigma_y, double beam_sigma_xy) {
81 double d0 = tp->d0();
82 double sigma_d0 = std::sqrt( tp->definingParametersCovMatrixDiagVec()[0] + d0UncertaintyBeamSpot2(tp->phi(),beam_sigma_x, beam_sigma_y, beam_sigma_xy) );
83 return d0/sigma_d0;
84 }
85
94 double z0significance(const xAOD::TrackParticle *tp, const xAOD::Vertex *vx=NULL);
95
104 double z0sinthetasignificance(const xAOD::TrackParticle *tp, const xAOD::Vertex *vx=NULL);
105
110 inline
112 double z0 = tp->z0() + tp->vz();
113 double sigma_z0 = std::sqrt( tp->definingParametersCovMatrixDiagVec()[1] );
114 return z0/sigma_z0;
115 }
116
126 inline
128 // use z0 relative to the given primary vertex.
129 double z0 = tp->z0() + tp->vz() - vx->z();
130
131 double sigma_z0 = std::sqrt( tp->definingParametersCovMatrixDiagVec()[1] );
132 return z0/sigma_z0;
133 }
134
135
138 bool hasValidCov(const xAOD::TrackParticle *tp);
139
142 inline
144 if (hasValidCov(tp)) {
145 if (tp->definingParametersCovMatrixDiagVec()[0]>0.) {
146 return true;
147 }
148 }
149 return false;
150 }
151
154 inline
156 if (hasValidCov(tp)) {
157 if ( tp->definingParametersCovMatrixDiagVec()[1] > 0. ) {
158 return true;
159 }
160 }
161 return false;
162 }
163
166 inline
168 if (hasValidCov(tp)) {
169 if ( ( tp->definingParametersCovMatrixDiagVec()[0] > 0. )
170 && ( tp->definingParametersCovMatrixDiagVec()[1] > 0. ) ) {
171 return true;
172 }
173 }
174 return false;
175 }
176
177
185 inline
186 bool checkPVReference(const xAOD::TrackParticle *tp, const xAOD::Vertex *vx, const double max_pv_dxy_sqr=0.5*0.5) {
187 if (hasValidCovD0(tp) && vx) {
188 return std::abs( sqr(vx->x())+ sqr(vx->y())) < max_pv_dxy_sqr * tp->definingParametersCovMatrixDiagVec()[0];
189 }
190 return false;
191 }
192
198 inline
199 bool checkBeamSpotSigma(double beam_sigma_x,double beam_sigma_y, double beam_sigma_xy) {
200 return sqr(beam_sigma_x)+sqr(beam_sigma_y)>=2*std::abs(beam_sigma_xy);
201 }
202
206 double pTErr2(const xAOD::TrackParticle *tp);
207
211 inline
212 double pTErr(const xAOD::TrackParticle *tp) {
213 return sqrt( pTErr2(tp) );
214 }
215
216
220 inline
222
223 // / d \2 / d \2 d d
224 // pt_err^2 =| ------ (pt) *sigma_q/p | + | -------- pt * sigma_theta | + ----- pt ------- pt * sigma_theta_qp
225 // \ d q/p / \ d theta / d qp d theta
226
227 // d / d pt 2 d pt \ / d pt \2
228 // = ------ (pt) * | ----- sigma_q/p + ------- * sigma_theta_qp | + | ------- * sigma_theta |
229 // d q/p \ d q/p d theta / \ d theta /
230
231 // d pt
232 // ------ pt = - -------------
233 // d q/p fabs(qOverP)
234
235 // d pt
236 // ------- pt = -----------
237 // d theta tan(theta)
238
239 double pt = tp->pt();
240 double diff_qp = - pt / std::abs(tp->qOverP());
241
242 double diff_theta = pt / tan( tp->theta() );
243
244 // since 1/tan (thata) defined for all floats 0..M_PI, don't have to protect :
245 //
246 // double diff_theta = ( std::abs(tp->theta()-M_PI_2) > std::numeric_limits<float>::epsilon() * 2
247 // ? pt / tan( tp->theta() )
248 // : 0 )
249
250 auto cov = tp->definingParametersCovMatrix();
251 // elements in definingParametersCovMatrix should be : 0: sigma_d0^2,
252 // 1: sigma_d0_z0, sigma_z0^2,
253 // 3: sigma_d0_phi, sigma_z0_phi, sigma_phi^2
254 // 6: sigma_d0_th, sigma_z0_th, sigma_phi_th, sigma_th^2
255 // 10: sigma_d0_qp, sigma_z0_qp, sigma_phi_qp, sigma_th_qp, sigma_qp^2
256
257 double pt_err2 = diff_qp * (diff_qp * cov(4, 4) + diff_theta * cov(3, 4) ) + sqr(diff_theta) * cov(3, 3);
258 return pt_err2;
259 }
260
264 inline
266 return sqrt(pTErr2Unsafe(tp));
267 }
268
271 inline
273 if (hasValidCov(tp)) {
274 if (std::abs(tp->qOverP())>0.) {
275 return true;
276 }
277 }
278 return false;
279 }
280
281 }// TrackParticleHelpers
282
283} // namespace xAOD
284
285#endif // XAOD_TRACKPARTICLEXAODHELPERS_H
static Double_t a
#define sqr(t)
float z() const
Returns the z position.
float y() const
Returns the y position.
float x() const
Returns the x position.
bool hasValidCovZ0(const xAOD::TrackParticle *tp)
Check whether the given track particle is valid and has a valid z0 uncertainty.
double pTErrUnsafe(const xAOD::TrackParticle *tp)
compute the uncertainty of pt.
double z0significance(const xAOD::TrackParticle *tp, const xAOD::Vertex *vx=NULL)
Get the impact parameter significance of a track particle in the z direction.
double d0UncertaintyBeamSpot2(double track_phi0, double beam_sigma_x, double beam_sigma_y, double beam_sigma_xy)
calculate the squared d0 uncertainty component due to the size of the beam spot.
bool checkPVReference(const xAOD::TrackParticle *tp, const xAOD::Vertex *vx, const double max_pv_dxy_sqr=0.5 *0.5)
test whether the given primary vertex has a significant displacement in r-phi wrt.
bool hasValidCovD0andZ0(const xAOD::TrackParticle *tp)
Check whether the given track particle is valid and has a valid d0 and z0 uncertainty.
bool hasValidCovD0(const xAOD::TrackParticle *tp)
Check whether the given track particle is valid and has a valid d0 uncertainty.
double z0significanceUnsafe(const xAOD::TrackParticle *tp)
Unsafe version of z0significance.
double z0sinthetasignificance(const xAOD::TrackParticle *tp, const xAOD::Vertex *vx=NULL)
Get the impact parameter significance of a track particle in the z direction, including the sin(theta...
double sqr(double a)
convenience method to calculate the square of a value.
double pTErr2(const xAOD::TrackParticle *tp)
compute the uncertainty of pt squared.
double pTErr(const xAOD::TrackParticle *tp)
compute the uncertainty of pt.
bool hasValidCovQoverP(const xAOD::TrackParticle *tp)
return true if the covariance matrix of the defining parameters is set, has enough elements and the q...
bool hasValidCov(const xAOD::TrackParticle *tp)
Check whether the given track particle is valid and has a covariance matrix of the defining parameter...
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
bool checkBeamSpotSigma(double beam_sigma_x, double beam_sigma_y, double beam_sigma_xy)
check that the beamspot covariance matrix is valid
double d0significanceUnsafe(const xAOD::TrackParticle *tp)
Unsafe version of d0significance.
double pTErr2Unsafe(const xAOD::TrackParticle *tp)
compute the uncertainty of pt squared.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
setRcore setEtHad setFside pt
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.