ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkVertexFitter
TrkVKalVrtCore
src
RobTest.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrkVKalVrtCore/RobTest.h
"
6
#include "
TrkVKalVrtCore/TrkVKalVrtCoreBase.h
"
7
#include "
TrkVKalVrtCore/Matrix.h
"
8
#include <cmath>
9
#include <iostream>
10
#include <vector>
11
12
namespace
Trk
{
13
14
void
robtest
(
VKVertex
* vk,
int
ifl,
int
nIteration
/*=10*/
)
15
{
16
long
int
i, j, k, kk, it;
17
double
rob,
res
, c[5], darg, absX, roba[5];
18
19
/* ------------------------------------------------------------ */
20
/* Robustification procedure for weight matrix */
21
/* IROB = 0 - Standard chi^2 */
22
/* = 1 - Geman-McClure function */
23
/* = 2 - Welch function */
24
/* = 3 - Cauchy function */
25
/* = 4 - L1-L2 function */
26
/* = 5 - Fair function */
27
/* = 6 - Huber function */
28
/* = 7 - Modified Huber function */
29
/* (1,2,3) - Zero outliers */
30
/* (4,5,6,7) - Downweight outliers */
31
/* Author: V.Kostyukhin */
32
/* ------------------------------------------------------------ */
33
34
int
NTRK = vk->
TrackList
.size();
35
36
long
int
irob = vk->
vk_fitterControl
->vk_forcft.irob;
37
double
Scl = vk->
vk_fitterControl
->vk_forcft.RobustScale;
//Tuning constant
38
double
C
;
// Breakdown constant
39
40
if
(!vk->
vk_fitterControl
->m_frozenVersionForBTagging)Scl *= (1.+exp(3.-nIteration));
//Annealing
41
42
if
( ifl == 0) {
/* FILLING OF EIGENVALUES AND VECTORS */
43
for
(it = 0; it < NTRK ; ++it) {
/* RESTORE MATRIX */
44
VKTrack
*trk=vk->
TrackList
[it].get();
45
if
(trk->
Id
< 0)
continue
;
// Not a real track
46
vkGetEigVect
(trk->
WgtM
, trk->
e
,&(trk->
v
[0][0]), 5);
47
}
48
return
;
49
}
50
/* -- */
51
double
halfPi=
M_PI
/2.;
52
for
(it = 0; it < NTRK; ++it) {
53
VKTrack
*trk=vk->
TrackList
[it].get();
54
if
(trk->
Id
< 0)
continue
;
// Not a real track
55
c[0]=c[1]=c[2]=c[3]=c[4]=0.;
56
for
( k = 0; k < 5; k++){
57
c[0] += trk->
rmnd
[k] * trk->
v
[0][k];
58
c[1] += trk->
rmnd
[k] * trk->
v
[1][k];
59
c[2] += trk->
rmnd
[k] * trk->
v
[2][k];
60
c[3] += trk->
rmnd
[k] * trk->
v
[3][k];
61
c[4] += trk->
rmnd
[k] * trk->
v
[4][k];
62
}
63
for
(k = 0; k < 5; ++k) {
64
darg = c[k]*c[k]*trk->
e
[k];
65
if
(darg < 1.e-10) darg = 1.e-10;
66
absX = sqrt(darg);
/* Abs(X) == sqrt(X)*/
67
rob = 1.;
C
=1;
68
if
(irob == 1)
C
= 1.58*Scl;
/* Geman-McClure Standard =1 but c^2=2.5 is better(Gem.McC) */
69
if
(irob == 2)
C
= 2.9846*Scl;
/* Welch def c^2=2.9846^2 */
70
if
(irob == 3)
C
= 2.3849*Scl;
/* Cauchy def 2.385^2=5.7 */
71
if
(irob == 4)
C
= 1.;
/* L1-L2 no tuning*/
72
if
(irob == 5)
C
= 1.3998*Scl;
/* Fair (def=1.3998)*/
73
if
(irob == 6)
C
= 1.345 *Scl;
/* Huber (def=1.345)*/
74
if
(irob == 7)
C
= 1.2107 *Scl;
/* Modified Huber (def=1.2107)*/
75
/* Functionals here are divided by (X^2/2)!!!*/
76
double
C2=
C
*
C
;
77
if
(irob == 1)rob = 1. / (darg/C2 + 1.);
/* Geman-McClure */
78
if
(irob == 2)rob = C2*(1. - exp(-darg/C2) )/darg;
/* Welch */
79
if
(irob == 3)rob = C2*log(darg/C2 + 1.)/darg;
/* Cauchy */
80
if
(irob == 4)rob = 4.*(sqrt(darg / 2. + 1.) - 1.)/darg;
/* L1-L2 */
81
if
(irob == 5)rob = 2.*C2*(absX/
C
- log(absX/
C
+ 1.))/darg;
/* Fair */
82
if
(irob == 6)rob =
C
>absX ? 1. : (2*
C
/absX -
C
*
C
/darg) ;
/* Huber */
83
if
(irob == 7)rob = halfPi>(absX/
C
) ? 2*
C
*
C
*(1-cos(absX/
C
))/darg :
84
2*(
C
*absX+
C
*
C
*(1.-halfPi))/darg;
/* Modified Huber */
85
roba[k] = rob;
86
if
(rob>0.99)roba[k] = 1.;
//To improve precision
87
}
88
for
(i = 0; i < 5; ++i)
if
(roba[i]<1.e-3)roba[i]=1.e-3;
89
kk = 0;
90
for
(i = 0; i < 5; ++i) {
91
for
(j = 0; j <= i; ++j) {
92
res
= 0.;
93
for
(k = 0; k < 5; ++k) {
94
res
+= trk->
v
[k][i] * trk->
e
[k] * trk->
v
[k][j]*roba[k];
95
}
96
trk->
WgtM
[kk]=
res
;
97
kk++;
98
}
99
}
100
vk->
vk_fitterControl
->vk_forcft.robres[it] = roba[0] * roba[1] * roba[2] * roba[3] * roba[4];
101
if
(vk->
vk_fitterControl
->vk_forcft.robres[it]>1.)vk->
vk_fitterControl
->vk_forcft.robres[it]=1.;
102
}
103
}
104
105
106
}
/* End of namespace */
107
108
M_PI
#define M_PI
Definition
ActiveFraction.h:14
res
std::pair< std::vector< unsigned int >, bool > res
Definition
JetGroupProductTest.cxx:11
RobTest.h
Matrix.h
TrkVKalVrtCoreBase.h
Trk::VKTrack
Definition
TrkVKalVrtCoreBase.h:63
Trk::VKTrack::rmnd
double rmnd[5]
Definition
TrkVKalVrtCoreBase.h:90
Trk::VKTrack::v
double v[5][5]
Definition
TrkVKalVrtCoreBase.h:92
Trk::VKTrack::Id
long int Id
Definition
TrkVKalVrtCoreBase.h:71
Trk::VKTrack::WgtM
double WgtM[15]
Definition
TrkVKalVrtCoreBase.h:86
Trk::VKTrack::e
double e[5]
Definition
TrkVKalVrtCoreBase.h:91
Trk::VKVertex
Definition
TrkVKalVrtCoreBase.h:127
Trk::VKVertex::TrackList
std::vector< std::unique_ptr< VKTrack > > TrackList
Definition
TrkVKalVrtCoreBase.h:166
Trk::VKVertex::vk_fitterControl
std::unique_ptr< VKalVrtControl > vk_fitterControl
Definition
TrkVKalVrtCoreBase.h:193
C
struct color C
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition
FakeTrackBuilder.h:9
Trk::vkGetEigVect
void vkGetEigVect(const double ci[], double d[], double vect[], int n)
Definition
Tracking/TrkVertexFitter/TrkVKalVrtCore/src/Matrix.cxx:847
Trk::robtest
void robtest(VKVertex *vk, int ifl, int nIteration)
Definition
RobTest.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0