ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkVertexFitter
TrkVKalVrtFitter
src
VKalVrtFitFastSvc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Header include
6
#include "
TrkVKalVrtFitter/TrkVKalVrtFitter.h
"
7
#include "
TrkVKalVrtCore/VKvFast.h
"
8
//-------------------------------------------------
9
//
10
#include "
TrkTrack/TrackInfo.h
"
11
#include <vector>
12
#include <algorithm>
//for nth_element, max_element
13
#include <cmath>
//for abs
14
15
namespace
{
16
double
17
median
(std::vector<double> & v){
//modifies the vector v
18
//assume we don't need to check for empty vector
19
const
auto
n
=
v
.size();
20
const
auto
halfway =
n
/2;
21
//its a contiguous iterator, just use addition
22
std::vector<double>::iterator
it
=
v
.begin() + halfway;
23
std::nth_element(
v
.begin(), it,
v
.end());
24
if
(n & 1){
//it has an odd number of elements
25
return
*
it
;
//so just return the middle element
26
}
else
{
27
const
double
mid2 = *
it
;
28
//the following works because v is partially sorted by std::nth_element
29
const
double
mid1 = *std::max_element(
v
.begin(), it);
30
return
(mid1 + mid2) *0.5;
//return the average of the two neighbouring mid elements
31
}
32
}
33
}
34
35
//
36
//__________________________________________________________________________
37
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
38
39
40
namespace
Trk
{
41
42
//-----------------------------------------------------------------------------------------
43
// Standard (old) code
44
//
45
46
47
StatusCode
TrkVKalVrtFitter::VKalVrtFitFast
(std::span<const xAOD::TrackParticle* const> InpTrk,
48
Amg::Vector3D
&
Vertex
,
49
IVKalState
& istate)
const
50
{
51
double
minDZ=0.;
52
return
VKalVrtFitFast
(InpTrk,
Vertex
,minDZ,istate);
53
}
54
55
56
StatusCode
TrkVKalVrtFitter::VKalVrtFitFast
(std::span<const xAOD::TrackParticle* const> InpTrk,
57
Amg::Vector3D
&
Vertex
,
double
& minDZ,
58
IVKalState
& istate)
const
59
{
60
assert(
dynamic_cast<
State
*
>
(&istate)!=
nullptr
);
61
State
& state =
static_cast<
State
&
>
(istate);
62
//
63
// Convert particles and setup reference frame
64
//
65
int
ntrk=0;
66
StatusCode
sc
=
CvtTrackParticle
(InpTrk,ntrk,state);
67
if
(
sc
.isFailure() || ntrk<1 )
return
StatusCode::FAILURE;
68
double
fx,fy,BMAG_CUR;
69
state.
m_fitField
.
getMagFld
(0.,0.,0.,fx,fy,BMAG_CUR);
70
if
(fabs(BMAG_CUR) < 0.1) BMAG_CUR=0.1;
71
//
72
//------ Variables and arrays needed for fitting kernel
73
//
74
double
out[3];
75
std::vector<double> xx,yy,zz,difz;
76
Vertex
[0]=
Vertex
[1]=
Vertex
[2]=0.;
77
//
78
//
79
double
xyz0[3]={ -state.
m_refFrameX
, -state.
m_refFrameY
, -state.
m_refFrameZ
};
80
if
(ntrk==2){
81
minDZ=
Trk::vkvFastV
(&state.
m_apar
[0][0],&state.
m_apar
[1][0], xyz0, BMAG_CUR, out);
82
}
else
{
83
for
(
int
i=0;i<ntrk-1; i++){
84
for
(
int
j=i+1; j<ntrk; j++){
85
double
dZ=
Trk::vkvFastV
(&state.
m_apar
[i][0],&state.
m_apar
[j][0], xyz0, BMAG_CUR, out);
86
xx.push_back(out[0]);
87
yy.push_back(out[1]);
88
zz.push_back(out[2]);
89
difz.push_back(dZ);
90
}
91
}
92
out[0] = median(xx);
93
out[1] = median(yy);
94
out[2] = median(zz);
95
minDZ = median(difz);
96
}
97
Vertex
[0]= out[0] + state.
m_refFrameX
;
98
Vertex
[1]= out[1] + state.
m_refFrameY
;
99
Vertex
[2]= out[2] + state.
m_refFrameZ
;
100
101
102
return
StatusCode::SUCCESS;
103
}
104
105
106
107
StatusCode
TrkVKalVrtFitter::VKalVrtFitFast
(
const
std::vector<const TrackParameters*>& InpTrk,
108
Amg::Vector3D
&
Vertex
,
109
IVKalState
& istate)
const
110
{
111
assert(
dynamic_cast<
State
*
>
(&istate)!=
nullptr
);
112
State
& state =
static_cast<
State
&
>
(istate);
113
//
114
// Convert particles and setup reference frame
115
//
116
int
ntrk=0;
117
StatusCode
sc
=
CvtTrackParameters
(InpTrk,ntrk,state);
118
if
(
sc
.isFailure() || ntrk<1 )
return
StatusCode::FAILURE;
119
double
fx,fy,BMAG_CUR;
120
state.
m_fitField
.
getMagFld
(0.,0.,0.,fx,fy,BMAG_CUR);
121
if
(fabs(BMAG_CUR) < 0.1) BMAG_CUR=0.1;
122
//
123
//------ Variables and arrays needed for fitting kernel
124
//
125
double
out[3];
126
std::vector<double> xx,yy,zz;
127
Vertex
[0]=
Vertex
[1]=
Vertex
[2]=0.;
128
//
129
//
130
double
xyz0[3]={ -state.
m_refFrameX
, -state.
m_refFrameY
, -state.
m_refFrameZ
};
131
if
(ntrk==2){
132
Trk::vkvFastV
(&state.
m_apar
[0][0],&state.
m_apar
[1][0], xyz0, BMAG_CUR, out);
133
}
else
{
134
for
(
int
i=0;i<ntrk-1; i++){
135
for
(
int
j=i+1; j<ntrk; j++){
136
Trk::vkvFastV
(&state.
m_apar
[i][0],&state.
m_apar
[j][0], xyz0, BMAG_CUR, out);
137
xx.push_back(out[0]);
138
yy.push_back(out[1]);
139
zz.push_back(out[2]);
140
}
141
}
142
out[0] = median(xx);
143
out[1] = median(yy);
144
out[2] = median(zz);
145
146
}
147
Vertex
[0]= out[0] + state.
m_refFrameX
;
148
Vertex
[1]= out[1] + state.
m_refFrameY
;
149
Vertex
[2]= out[2] + state.
m_refFrameZ
;
150
151
152
return
StatusCode::SUCCESS;
153
}
154
155
156
}
157
Vertex
boost::graph_traits< boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS > >::vertex_descriptor Vertex
Definition
FPGATrackSimGNNRoadMakerTool.h:35
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
TrackInfo.h
TrkVKalVrtFitter.h
VKvFast.h
Trk::IVKalState
Definition
IVKalState.h:21
Trk::TrkVKalVrtFitter::State
Definition
TrkVKalVrtFitter.h:395
Trk::TrkVKalVrtFitter::State::m_fitField
VKalAtlasMagFld m_fitField
Definition
TrkVKalVrtFitter.h:414
Trk::TrkVKalVrtFitter::State::m_refFrameZ
double m_refFrameZ
Definition
TrkVKalVrtFitter.h:403
Trk::TrkVKalVrtFitter::State::m_refFrameY
double m_refFrameY
Definition
TrkVKalVrtFitter.h:402
Trk::TrkVKalVrtFitter::State::m_apar
double m_apar[NTrMaxVFit][5]
Definition
TrkVKalVrtFitter.h:409
Trk::TrkVKalVrtFitter::State::m_refFrameX
double m_refFrameX
Definition
TrkVKalVrtFitter.h:401
Trk::TrkVKalVrtFitter::CvtTrackParameters
StatusCode CvtTrackParameters(const std::vector< const TrackParameters * > &InpTrk, int &ntrk, State &state) const
Definition
CvtParametersBase.cxx:23
Trk::TrkVKalVrtFitter::VKalVrtFitFast
virtual StatusCode VKalVrtFitFast(std::span< const xAOD::TrackParticle *const >, Amg::Vector3D &Vertex, double &minDZ, IVKalState &istate) const
Definition
VKalVrtFitFastSvc.cxx:56
Trk::TrkVKalVrtFitter::CvtTrackParticle
StatusCode CvtTrackParticle(std::span< const xAOD::TrackParticle *const > list, int &ntrk, State &state) const
Definition
CvtTrackParticle.cxx:27
Trk::VKalAtlasMagFld::getMagFld
virtual void getMagFld(const double, const double, const double, double &, double &, double &) override
Definition
VKalAtlasMagFld.cxx:61
Trk::Vertex
This class is a simplest representation of a vertex candidate.
Definition
Tracking/TrkEvent/VxVertex/VxVertex/Vertex.h:26
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDet::median
float median(std::vector< float > &Vec)
Definition
BTagVrtSec.cxx:35
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition
FakeTrackBuilder.h:9
Trk::vkvFastV
double vkvFastV(double *p1, double *p2, const double *vRef, double dbmag, double *out)
Definition
VKvFast.cxx:42
beamspotman.n
n
Definition
beamspotman.py:727
python.PyAthena.v
v
Definition
PyAthena.py:153
skel.it
it
Definition
skel.GENtoEVGEN.py:407
Generated on
for ATLAS Offline Software by
1.17.0