ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODTracking
xAODTracking
TrackingDetails.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef XAODTRACKING_TRACKINGDETAILS_H
6
#define XAODTRACKING_TRACKINGDETAILS_H
7
8
#include "
xAODTracking/TrackingPrimitives.h
"
9
#include "Math/Vector4D.h"
10
#include <span>
11
12
namespace
xAOD
13
{
14
namespace
TrackingDetails
15
{
36
38
using
GenVecFourMom_t
= ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> >;
39
40
enum
covMatrixIndex
{
d0_index
=0,
z0_index
=1,
phi_index
=2,
th_index
=3,
qp_index
=4};
41
constexpr
std::size_t
COVMATRIX_OFFDIAG_VEC_COMPR_SIZE
= 6;
42
constexpr
std::array< std::pair<covMatrixIndex,covMatrixIndex>,
COVMATRIX_OFFDIAG_VEC_COMPR_SIZE
>
covMatrixComprIndexPairs
{{
43
{
d0_index
,
phi_index
}, {
z0_index
,
th_index
}, {
d0_index
,
qp_index
},
44
{
z0_index
,
qp_index
}, {
phi_index
,
qp_index
}, {
th_index
,
qp_index
} }};
45
46
47
[[nodiscard]]
inline
float
charge
(
float
qOverP) {
48
return
(qOverP > 0) ? 1 : ((qOverP < 0) ? -1 : 0);
49
}
50
51
52
[[nodiscard]]
inline
GenVecFourMom_t
genvecP4
(
float
qOverP,
float
thetaT,
float
phiT,
double
m) {
53
using namespace
std
;
54
float
p = 10.e6;
// 10 TeV (default value for very high pt muons, with qOverP==0)
55
if
(fabs(qOverP)>0.) p = 1/fabs(qOverP);
56
float
sinTheta= sin(thetaT);
57
float
px = p*sinTheta*cos(phiT);
58
float
py
= p*sinTheta*sin(phiT);
59
float
pz = p*cos(thetaT);
60
return
GenVecFourMom_t
(px,
py
, pz, m);
61
}
62
63
64
65
[[nodiscard]]
inline
bool
definingParametersCovMatrixOffDiagCompr
(std::span< const float > covMatrixOffDiag) {
66
67
bool
flag =
false
;
68
flag = (
static_cast<
int
>
(covMatrixOffDiag.size())==
COVMATRIX_OFFDIAG_VEC_COMPR_SIZE
);
69
return
flag;
70
}
71
72
73
74
[[nodiscard]]
inline
xAOD::ParametersCovMatrix_t
definingParametersCovMatrix
( std::span< const float > covMatrixDiag, std::span< const float > covMatrixOffDiag,
bool
& valid ) {
75
76
// Set up the result matrix.
77
xAOD::ParametersCovMatrix_t cov;
78
cov.setZero();
79
valid =
true
;
80
81
// Set the diagonal elements of the matrix.
82
if
( (
static_cast<
int
>
( covMatrixDiag.size() ) == cov.rows() ) ) {
83
84
// Access the "raw" variable.
85
// Set the diagonal elements using the raw variable.
86
for
(
int
i = 0; i < cov.rows(); ++i ) {
87
cov( i, i ) = covMatrixDiag[ i ];
88
}
89
}
else
{
90
valid =
false
;
91
// If the variable is not available/set, set the matrix to identity.
92
cov.setIdentity();
93
}
94
95
bool
offDiagCompr =
definingParametersCovMatrixOffDiagCompr
(covMatrixOffDiag);
96
97
// Set the off-diagonal elements of the matrix.
98
if
(!offDiagCompr){
99
100
if
( (
static_cast<
int
>
( covMatrixOffDiag.size() ) == ( ( ( cov.rows() - 1 ) * cov.rows() ) / 2 ) ) ) {
101
102
// Set the off-diagonal elements using the raw variable.
103
std::size_t vecIndex = 0;
104
for
(
int
i = 1; i < cov.rows(); ++i ) {
105
for
(
int
j = 0; j < i; ++j, ++vecIndex ) {
106
float
offDiagCoeff = cov(i,i)>0 && cov(j,j)>0 ? covMatrixOffDiag[vecIndex]*sqrt(cov(i,i)*cov(j,j)) : 0;
107
cov.fillSymmetric( i, j, offDiagCoeff );
108
}
109
}
110
}
111
112
else
valid =
false
;
113
114
}
115
116
else
{
//Compressed case
117
118
if
( (
static_cast<
int
>
( covMatrixOffDiag.size() ) ==
COVMATRIX_OFFDIAG_VEC_COMPR_SIZE
) ) {
119
// Set the off-diagonal elements using the raw variable.
120
121
const
auto
& vecPairIndex =
covMatrixComprIndexPairs
;
122
123
for
(
unsigned
int
k=0; k<
COVMATRIX_OFFDIAG_VEC_COMPR_SIZE
; ++k){
124
std::pair<covMatrixIndex,covMatrixIndex> pairIndex = vecPairIndex[k];
125
covMatrixIndex
i = pairIndex.first;
126
covMatrixIndex
j = pairIndex.second;
127
float
offDiagCoeff = cov(i,i)>0 && cov(j,j)>0 ? covMatrixOffDiag[k]*sqrt(cov(i,i)*cov(j,j)) : 0;
128
cov.fillSymmetric( i, j, offDiagCoeff );
129
}
130
131
}
132
133
else
valid =
false
;
134
135
}
136
137
138
// Return the filled matrix.
139
return
cov;
140
141
}
142
}
143
}
144
145
#endif
TrackingPrimitives.h
std
STL namespace.
xAOD::TrackingDetails
Definition
TrackingDetails.h:15
xAOD::TrackingDetails::GenVecFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzM4D< double > > GenVecFourMom_t
Base 4 Momentum type for TrackParticle.
Definition
TrackingDetails.h:38
xAOD::TrackingDetails::covMatrixIndex
covMatrixIndex
Definition
TrackingDetails.h:40
xAOD::TrackingDetails::phi_index
@ phi_index
Definition
TrackingDetails.h:40
xAOD::TrackingDetails::d0_index
@ d0_index
Definition
TrackingDetails.h:40
xAOD::TrackingDetails::z0_index
@ z0_index
Definition
TrackingDetails.h:40
xAOD::TrackingDetails::qp_index
@ qp_index
Definition
TrackingDetails.h:40
xAOD::TrackingDetails::th_index
@ th_index
Definition
TrackingDetails.h:40
xAOD::TrackingDetails::genvecP4
GenVecFourMom_t genvecP4(float qOverP, float thetaT, float phiT, double m)
Definition
TrackingDetails.h:52
xAOD::TrackingDetails::definingParametersCovMatrixOffDiagCompr
bool definingParametersCovMatrixOffDiagCompr(std::span< const float > covMatrixOffDiag)
Definition
TrackingDetails.h:65
xAOD::TrackingDetails::definingParametersCovMatrix
xAOD::ParametersCovMatrix_t definingParametersCovMatrix(std::span< const float > covMatrixDiag, std::span< const float > covMatrixOffDiag, bool &valid)
Definition
TrackingDetails.h:74
xAOD::TrackingDetails::COVMATRIX_OFFDIAG_VEC_COMPR_SIZE
constexpr std::size_t COVMATRIX_OFFDIAG_VEC_COMPR_SIZE
Definition
TrackingDetails.h:41
xAOD::TrackingDetails::covMatrixComprIndexPairs
constexpr std::array< std::pair< covMatrixIndex, covMatrixIndex >, COVMATRIX_OFFDIAG_VEC_COMPR_SIZE > covMatrixComprIndexPairs
Definition
TrackingDetails.h:42
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
xAOD::py
py
Definition
CompositeParticle_v1.cxx:160
xAOD::charge
charge
Definition
TrigElectron_v1.cxx:85
Generated on
for ATLAS Offline Software by
1.17.0