ATLAS Offline Software
Loading...
Searching...
No Matches
TrkVKalVrtFitterTestAlg.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3 */
10
12#include "xAODTracking/Vertex.h"
14#include "TrkTrack/Track.h"
16//undef NDEBUG after EDM
17#undef NDEBUG
22#include "GaudiKernel/SystemOfUnits.h"
23#include "TrkVKalVrtFitter/IVKalState.h" //unique_ptr needs the deleter
25
26#include <cassert>
27#include <cmath>
28
29#include "CLHEP/Vector/LorentzVector.h"
30
31using Gaudi::Units::mm;
32using Gaudi::Units::MeV;
33using Gaudi::Units::GeV;
34
35
36namespace {
37
38
39template <class T>
40std::vector<const T*> asVec (const std::vector<std::unique_ptr<T> >& v)
41{
42 std::vector<const T*> ret;
43 ret.reserve(v.size());
44
45 for (const std::unique_ptr<T>& p : v) {
46 ret.push_back (p.get());
47 }
48 return ret;
49}
50
51
52std::vector<const Trk::NeutralParameters*>
53asVec (const std::vector<std::unique_ptr<Trk::NeutralPerigee> >& v)
54{
55 std::vector<const Trk::NeutralParameters*> ret;
56 ret.reserve(v.size());
57
58 for (const std::unique_ptr<Trk::NeutralPerigee>& p : v) {
59 ret.push_back (p.get());
60 }
61 return ret;
62}
63
64
65AmgSymMatrix(5) cov5()
66{
67 AmgSymMatrix(5) m;
68 m.setIdentity();
69 return m;
70}
71
72
73using PerigeeUVec_t = std::vector<std::unique_ptr<Trk::Perigee> >;
74
75using NeutralUVec_t = std::vector<std::unique_ptr<Trk::NeutralPerigee> >;
76NeutralUVec_t makeNeutrals1()
77{
78 Amg::Vector3D pos0 { 0, 0, 0 };
79
80 Amg::Vector3D pos1a { 3*mm, 0.5*mm, -7*mm };
81 Amg::Vector3D mom1a { 1000*MeV, 900*MeV, 2000*MeV };
82 Amg::Vector3D pos1b { -1*mm, 2.5*mm, 1*mm };
83 Amg::Vector3D mom1b { 800*MeV, 1000*MeV, 300*MeV };
84 Amg::Vector3D pos1c { -1.5*mm, 1*mm, -3*mm };
85 Amg::Vector3D mom1c { 500*MeV, 4000*MeV, 800*MeV };
86
87 NeutralUVec_t ret;
88
89 ret.emplace_back (std::make_unique<Trk::NeutralPerigee>(pos1a, mom1a, 1, pos1a, cov5()));
90 ret.emplace_back (std::make_unique<Trk::NeutralPerigee>(pos1b, mom1b, 1, pos1b, cov5()));
91 ret.emplace_back (std::make_unique<Trk::NeutralPerigee>(pos1c, mom1c, 1, pos1c, cov5()));
92
93 return ret;
94}
95
96
97
98
99// Copied from TrackParticleCreatorTool.
100void setDefiningParameters( xAOD::TrackParticle& tp,
101 const Trk::Perigee& perigee )
102{
103 tp.setDefiningParameters(perigee.parameters()[Trk::d0],
104 perigee.parameters()[Trk::z0],
105 perigee.parameters()[Trk::phi0],
106 perigee.parameters()[Trk::theta],
107 perigee.parameters()[Trk::qOverP]);
108 const AmgSymMatrix(5)* covMatrix = perigee.covariance();
109 // see https://its.cern.ch/jira/browse/ATLASRECTS-645 for justification to comment out the following line
110 // assert(covMatrix && covMatrix->rows()==5&& covMatrix->cols()==5);
111 std::vector<float> covMatrixVec;
112 if( !covMatrix ) ;//ATH_MSG_WARNING("Setting Defining parameters without error matrix");
113 else Amg::compress(*covMatrix,covMatrixVec);
114 tp.setDefiningParametersCovMatrixVec(covMatrixVec);
115 const Amg::Vector3D& surfaceCenter = perigee.associatedSurface().center();
116 tp.setParametersOrigin(surfaceCenter.x(), surfaceCenter.y(), surfaceCenter.z() );
117}
118void setDefiningParameters( xAOD::NeutralParticle& tp,
119 const Trk::NeutralPerigee& perigee )
120{
121 tp.setDefiningParameters(perigee.parameters()[Trk::d0],
122 perigee.parameters()[Trk::z0],
123 perigee.parameters()[Trk::phi0],
124 perigee.parameters()[Trk::theta],
125 perigee.parameters()[Trk::qOverP]);
126 const AmgSymMatrix(5)* covMatrix = perigee.covariance();
127 // see https://its.cern.ch/jira/browse/ATLASRECTS-645 for justification to comment out the following line
128 // assert(covMatrix && covMatrix->rows()==5&& covMatrix->cols()==5);
129 std::vector<float> covMatrixVec;
130 if( !covMatrix ) ;//ATH_MSG_WARNING("Setting Defining parameters without error matrix");
131 else Amg::compress(*covMatrix,covMatrixVec);
132 tp.setDefiningParametersCovMatrixVec(covMatrixVec);
133 const Amg::Vector3D& surfaceCenter = perigee.associatedSurface().center();
134 tp.setParametersOrigin(surfaceCenter.x(), surfaceCenter.y(), surfaceCenter.z() );
135}
136
137
138using xAODTPUVec_t = std::vector<std::unique_ptr<xAOD::TrackParticle> >;
139xAODTPUVec_t makexAODTP (PerigeeUVec_t&& perigees)
140{
141 xAODTPUVec_t tracks;
142
143 for (std::unique_ptr<Trk::Perigee>& p : perigees) {
144 auto tp = std::make_unique<xAOD::TrackParticle>();
145 tp->makePrivateStore();
146 setDefiningParameters (*tp, *p);
147 tracks.push_back (std::move (tp));
148 }
149
150 return tracks;
151}
152
153
154using xAODNPUVec_t = std::vector<std::unique_ptr<xAOD::NeutralParticle> >;
155xAODNPUVec_t makexAODNP (NeutralUVec_t&& perigees)
156{
157 xAODNPUVec_t tracks;
158
159 for (std::unique_ptr<Trk::NeutralPerigee>& p : perigees) {
160 auto tp = std::make_unique<xAOD::NeutralParticle>();
161 tp->makePrivateStore();
162 setDefiningParameters (*tp, *p);
163 tracks.push_back (std::move (tp));
164 }
165
166 return tracks;
167}
168
169
170void dumpCovariance (const AmgSymMatrix(5)& m)
171{
172 for (int i=0; i < 5; i++) {
173 for (int j=0; j < 5; j++) {
174 std::cout << m(i,j) << ", ";
175 }
176 }
177}
178
179
180[[maybe_unused]]
181void dumpVertex (const xAOD::Vertex& v)
182{
183 std::cout << "vvv\n";
184 std::cout << v.x() << " " << v.y() << " " << v.z() << "\n";
185 static const SG::ConstAccessor<short> vertexTypeAcc ("vertexType");
186 if (vertexTypeAcc.isAvailable(v)) {
187 std::cout << "vertexType " << v.vertexType() << "\n";
188 }
189 std::cout << "chi2/ndof " << v.chiSquared() << " " << v.numberDoF() << "\n";
190
191 std::cout << "cov ";
192 for (float f : v.covariance()) {
193 std::cout << f << " ";
194 }
195 std::cout << "\n";
196
197 static const SG::ConstAccessor<std::vector<ElementLink<xAOD::TrackParticleContainer> > > trackParticleLinksAcc ("trackParticleLinks");
198 if (trackParticleLinksAcc.isAvailable(v)) {
199 std::cout << "tplinks ";
200 for (const ElementLink< xAOD::TrackParticleContainer >& l : v.trackParticleLinks()) {
201 std::cout << l.dataID() << "/" << l.index() << " ";
202 }
203 std::cout << "\n";
204 }
205
206 static const SG::ConstAccessor<float> trackWeightsAcc ("trackWeights");
207 if (trackWeightsAcc.isAvailable(v)) {
208 std::cout << "wt ";
209 for (float f : v.trackWeights()) {
210 std::cout << f << " ";
211 }
212 std::cout << "\n";
213 }
214
215 static const SG::ConstAccessor<std::vector<ElementLink<xAOD::NeutralParticleContainer> > > neutralParticleLinksAcc ("neutralParticleLinks");
216 if (neutralParticleLinksAcc.isAvailable(v)) {
217 std::cout << "nplinks ";
218 for (const ElementLink< xAOD::NeutralParticleContainer >& l : v.neutralParticleLinks()) {
219 std::cout << l.dataID() << "/" << l.index() << " ";
220 }
221 std::cout << "\n";
222 }
223
224 static const SG::ConstAccessor<float> neutralWeightsAcc ("neutralWeights");
225 if (neutralWeightsAcc.isAvailable(v)) {
226 std::cout << "wt ";
227 for (float f : v.neutralWeights()) {
228 std::cout << f << " ";
229 }
230 std::cout << "\n";
231 }
232
233 std::cout << v.vxTrackAtVertexAvailable() << "\n";
234 for (const Trk::VxTrackAtVertex& vv : v.vxTrackAtVertex()) {
235 vv.dump (std::cout);
236 std::cout << "cov ";
237 if (vv.perigeeAtVertex()) {
238 dumpCovariance (*vv.perigeeAtVertex()->covariance());
239 }
240 else {
241 std::cout << "(null)";
242 }
243 std::cout << "\n";
244 }
245}
246
247
248void assertVec3D (const char* which,
249 const Amg::Vector3D& a,
250 const Amg::Vector3D& b,
251 double thresh = 2e-5)
252{
253 thresh = std::max (thresh, 2e-5);
254 if ( ! Athena_test::isEqual (a.x(), b.x(), thresh) ||
255 ! Athena_test::isEqual (a.y(), b.y(), thresh) ||
256 ! Athena_test::isEqual (a.z(), b.z(), thresh) )
257 {
258 std::cerr << "TrkVKalVrtFitterTestAlg::assertVec3D mismatch " << which
259 << ": ["
260 << a.x() << ", "
261 << a.y() << ", "
262 << a.z() << "] / ["
263 << b.x() << ", "
264 << b.y() << ", "
265 << b.z() << "]\n";
266 std::abort();
267 }
268}
269
270
271void comparePerigee (const Trk::TrackParameters* a,
272 const Trk::TrackParameters* b,
273 double thresh = 2e-5)
274{
275 if (!a && !b) return;
276 if (!a || !b) std::abort();
277 assertVec3D ("perigee pos", a->position(), b->position(), thresh);
278 assertVec3D ("perigee mom", a->momentum(), b->momentum(), thresh);
279 assert (a->charge() == b->charge());
280 assertVec3D ("perigee surf",
281 a->associatedSurface().center(),
282 b->associatedSurface().center(), thresh);
283}
284
285
286void compareVertex (const xAOD::Vertex& a, const xAOD::Vertex& b,
287 double thresh = 2e-5)
288{
289 assertVec3D ("vertex pos", a.position(), b.position(), thresh);
290 assert (Athena_test::isEqual (a.chiSquared(), b.chiSquared(),
291 std::max (5e-5, thresh)) );
292 assert (Athena_test::isEqual (a.numberDoF(), b.numberDoF(), 1e-5) );
293 assert (a.covariance().size() == b.covariance().size());
294 for (unsigned int i = 0; i < a.covariance().size(); i++) {
295 if (std::isinf(a.covariance()[i]) && std::isinf(b.covariance()[i])) continue;
296 assert (Athena_test::isEqual (a.covariance()[i], b.covariance()[i], 2e-2) );
297 }
298
299 assert (a.vxTrackAtVertexAvailable() == b.vxTrackAtVertexAvailable());
300 if (a.vxTrackAtVertexAvailable()) {
301 const std::vector< Trk::VxTrackAtVertex >& avec = a.vxTrackAtVertex();
302 const std::vector< Trk::VxTrackAtVertex >& bvec = b.vxTrackAtVertex();
303 assert (avec.size() == bvec.size());
304 for (unsigned int i = 0; i < avec.size(); i++) {
305 comparePerigee (avec[i].initialPerigee(), bvec[i].initialPerigee(), thresh);
306 comparePerigee (avec[i].perigeeAtVertex(), bvec[i].perigeeAtVertex(), thresh);
307 assert (Athena_test::isEqual (avec[i].trackQuality().chiSquared(),
308 bvec[i].trackQuality().chiSquared(),
309 3e-2));
310 assert (avec[i].trackQuality().numberDoF() ==
311 bvec[i].trackQuality().numberDoF());
312 }
313 }
314}
315
316
317void setRefittedPerigee (xAOD::Vertex& v, unsigned i,
318 float charge,
319 const Amg::Vector3D& mom,
320 const std::vector<float>& c)
321{
322 std::vector< Trk::VxTrackAtVertex >& vec = v.vxTrackAtVertex();
323 if (vec.size() <= i) vec.resize(i+1);
324
325 AmgSymMatrix(5) cov = cov5();
326 for (int ii=0; ii < 5; ii++) {
327 for (int j=0; j < 5; j++) {
328 unsigned ipos = ii*5 + j;
329 (cov)(ii,j) = ipos < c.size() ? c[ipos] : 0;
330 }
331 }
332
333 const Amg::Vector3D& pos = v.position();
334 auto p = std::make_unique<Trk::Perigee> (pos, mom, charge, pos,
335 cov);
336 vec[i].setPerigeeAtVertex (p.release());
337}
338
339
340void setFitQuality (xAOD::Vertex& v, unsigned i, float chi2, int ndof)
341{
342 std::vector< Trk::VxTrackAtVertex >& vec = v.vxTrackAtVertex();
343 if (vec.size() <= i) vec.resize(i+1);
344 vec[i].setTrackQuality (Trk::FitQuality (chi2, ndof));
345}
346
347
348} // anonymous namespace
349
350
351namespace Trk {
352
353
358{
359 ATH_CHECK( m_fitter.retrieve() );
360 return StatusCode::SUCCESS;
361}
362
363
367StatusCode TrkVKalVrtFitterTestAlg::execute(const EventContext& ctx) const
368{
369 ATH_MSG_VERBOSE ("execute");
370
371 ATH_CHECK( test1(ctx) );
372 ATH_CHECK( test2(ctx) );
373 ATH_CHECK( test3(ctx) );
374
375 return StatusCode::SUCCESS;
376}
377
378
379
380// Neutral, no constraint.
381// (Mixed charged+neutral seems not to work.)
382StatusCode TrkVKalVrtFitterTestAlg::test1(const EventContext& ctx) const
383{
384 xAOD::Vertex exp_v0;
385 exp_v0.makePrivateStore();
386 exp_v0.setPosition ({-5.58116, -8.50767, -4.76804});
387 exp_v0.setFitQuality (0.541406, 3);
388 exp_v0.setCovariance(std::vector<float>{
389 259.128, 394.824, 764.131, 144.775, 266.345, 155.231,
390 -30152, -6184.95, -2642.5, 4.60831e+13, 10912.8, -4760.06,
391 6318.67, 1.0494e+14, 2.4226e+14, -12079, -23269.1, -40859.3,
392 2.00894e+13, 4.51754e+13, 9.12659e+12});
393 setFitQuality(exp_v0, 0, 0.311, 2);
394 setFitQuality (exp_v0, 1, 0.138, 2);
395 setFitQuality (exp_v0, 2, 0.082, 2);
396
397 NeutralUVec_t neutrals = makeNeutrals1();
398 std::unique_ptr<xAOD::Vertex> v1 (m_fitter->fit (ctx, std::vector<const Trk::TrackParameters*>(),
399 asVec (neutrals)));
400 compareVertex (*v1, exp_v0);
401
402 return StatusCode::SUCCESS;
403}
404
405
406
407// Neutral + Vector3D constraint
408StatusCode TrkVKalVrtFitterTestAlg::test2(const EventContext& ctx) const
409{
410 xAOD::Vertex exp_v0;
411 exp_v0.makePrivateStore();
412 exp_v0.setPosition ({ 24.131, 38.8186, 13.2978});
413 exp_v0.setFitQuality (0.564942, 3);
414 exp_v0.setCovariance(std::vector<float>{
415 21964.5, 32891.5, 51244.9, 13612.1, 20963.9,
416 9573.41, 816688, 1.09315e+06, 393680, 1.92433e+14,
417 1.10804e+06, 1.87392e+06, 616429, 3.20119e+14, 5.41674e+14,
418 401502, 640572, 338398, 1.97024e+14, 3.42617e+14,
419 2.25906e+14});
420 setFitQuality(exp_v0, 0, 0.306, 2);
421 setFitQuality(exp_v0, 1, 0.00660789, 2);
422 setFitQuality(exp_v0, 2, 0.266975, 2);
423
424 Amg::Vector3D pnt1(5, 6, -3);
425
426 NeutralUVec_t neutrals = makeNeutrals1();
427 std::unique_ptr<xAOD::Vertex> v1 (m_fitter->fit (ctx, std::vector<const Trk::TrackParameters*>(),
428 asVec (neutrals),
429 pnt1));
430 compareVertex (*v1, exp_v0);
431
432 // ??? This gives a different result due to different reference frame
433 // handling in CvtNeutralParameters vs CvtNeutralParticle
434 xAOD::Vertex exp_v1;
435 exp_v1.makePrivateStore();
436 exp_v1.setPosition ({27.7411, 46.5526, 14.3721});
437 exp_v1.setFitQuality (0.537727, 3);
438 exp_v1.setCovariance(std::vector<float>{
439 32598.3, 50372.7, 80773.1, 18537.3, 29396.9,
440 12058.1, 850485, 1.1479e+06, 380180, 1.54295e+14,
441 1.21881e+06, 2.11418e+06, 643860, 2.55981e+14, 4.31589e+14,
442 417309, 683027, 356607, 1.51101e+14, 2.64837e+14,
443 1.77033e+14});
444 setFitQuality(exp_v1, 0, 0.281, 2);
445 setFitQuality(exp_v1, 1, 0.010, 2);
446 setFitQuality(exp_v1, 2, 0.248, 2);
447
448 xAODNPUVec_t xaodnp = makexAODNP(makeNeutrals1());
449 std::unique_ptr<xAOD::Vertex> v2 (m_fitter->fit (ctx, std::vector<const xAOD::TrackParticle*>(),
450 asVec (xaodnp),
451 pnt1));
452 compareVertex (*v2, exp_v1);
453
454 return StatusCode::SUCCESS;
455}
456
457
458// Neutral + Vertex constraint
459StatusCode TrkVKalVrtFitterTestAlg::test3(const EventContext& ctx) const
460{
461 xAOD::Vertex exp_v0;
462 exp_v0.makePrivateStore();
463 exp_v0.setPosition ({5.05085, 6.19647, -2.81445});
464 exp_v0.setFitQuality (2.20220, 6);
465 exp_v0.setCovariance (std::vector<float>
466 { 0.955506, 0.0266418, 0.95407, -0.0110041,
467 -0.0101241, 0.953395, 530.063, -411.644,
468 -325.151, 3.03883e+14, -711.821, 1110.92,
469 -551.227, 2.09286e+14, 2.49946e+14, 123.813,
470 386.78, 892.698, -3.14264e+12, 1.04832e+14,
471 1.10053e+14 });
472 setFitQuality (exp_v0, 0, 0.396, 2);
473 setFitQuality (exp_v0, 1, 0.752, 2);
474 setFitQuality (exp_v0, 2, 1.055, 2);
475
476 Amg::Vector3D pnt1 (5, 6, -3);
477 xAOD::Vertex pnt2;
478 pnt2.makePrivateStore();
479 pnt2.setPosition (pnt1);
480 AmgSymMatrix(3) pnt2covar;
481 pnt2covar.setIdentity();
482 pnt2.setCovariancePosition (pnt2covar);
483
484 NeutralUVec_t neutrals = makeNeutrals1();
485 std::unique_ptr<xAOD::Vertex> v1 (m_fitter->fit (ctx, std::vector<const Trk::TrackParameters*>(),
486 asVec (neutrals),
487 pnt2));
488 compareVertex (*v1, exp_v0);
489
490 // ??? This gives a different result due to different reference frame
491 // handling in CvtNeutralParameters vs CvtNeutralParticle
492 xAOD::Vertex exp_v1;
493 exp_v1.makePrivateStore();
494 exp_v1.setPosition ({5.00912, 6.23591, -2.82707});
495 exp_v1.setFitQuality (2.25019, 6);
496 exp_v1.setCovariance (std::vector<float>
497 { 0.968686, 0.0228402, 0.951705, -0.00910123,
498 -0.0098848, 0.950267, 435.6, -418.438,
499 -276.022, 3.17041e+14, -401.428, 987.01,
500 -336.323, 1.592e+14, 1.35435e+14, 183.46,
501 272.759, 988.474, -1.22294e+13, 5.57451e+13,
502 7.21632e+13 });
503 setFitQuality (exp_v1, 0, 0.313, 2);
504 setFitQuality (exp_v1, 1, 0.692, 2);
505 setFitQuality (exp_v1, 2, 1.246, 2);
506
507 xAODNPUVec_t xaodnp = makexAODNP (makeNeutrals1());
508 std::unique_ptr<xAOD::Vertex> v2 (m_fitter->fit (ctx, std::vector<const xAOD::TrackParticle*>(),
509 asVec (xaodnp),
510 pnt2));
511 compareVertex (*v2, exp_v1);
512
513 return StatusCode::SUCCESS;
514}
515
516
517} // namespace Trk
518
519
520
521namespace {
522
523
524AmgSymMatrix(5) cov5a()
525{
526 AmgSymMatrix(5) m;
527 m.setZero();
528 for (int i=0; i < 5; i++) {
529 (m)(i,i) = 1e-2;
530 }
531 (m)(1,1)=1;
532 return m;
533}
534
535
536using PerigeeUVec_t = std::vector<std::unique_ptr<Trk::Perigee> >;
537PerigeeUVec_t makePerigees2()
538{
539 Amg::Vector3D pos1a { 10*mm, 0*mm, -5*mm };
540 Amg::Vector3D mom1a { 1000*MeV, 0*MeV, 0*MeV };
541 Amg::Vector3D pos1b { 10.5*mm, 0.5*mm, -5.5*mm };
542 Amg::Vector3D mom1b { 800*MeV, 200*MeV, 200*MeV };
543 Amg::Vector3D pos1c { 9.5*mm, -0.5*mm, -4.5*mm };
544 Amg::Vector3D mom1c { 700*MeV, -300*MeV, -200*MeV };
545
546 PerigeeUVec_t ret;
547
548 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1a, mom1a, 1, pos1a, cov5a()));
549 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1b, mom1b, -1, pos1a, cov5a()));
550 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1c, mom1c, -1, pos1a, cov5a()));
551
552 return ret;
553}
554
555
556PerigeeUVec_t makePerigees3()
557{
558 Amg::Vector3D pos1a { 5*mm, 0*mm, -2.5*mm };
559 Amg::Vector3D mom1a { 600*MeV, 400*MeV, 200*MeV };
560 Amg::Vector3D pos1b { 5.1*mm, 0.3*mm, -2.6*mm };
561 Amg::Vector3D mom1b { 700*MeV, -300*MeV, -150*MeV };
562
563 PerigeeUVec_t ret;
564
565 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1a, mom1a, 1, pos1a, cov5a()));
566 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1b, mom1b, -1, pos1a, cov5a()));
567
568 return ret;
569}
570
571
572Amg::Vector3D exp_mom (const double moms[][4], int imom)
573{
574 return {moms[imom][0], moms[imom][1], moms[imom][2]};
575}
576
577
578} // anonymous namespace
579
580
581namespace Trk {
582
583
584// Simple cascade fitter test.
585StatusCode TrkVKalVrtFitterTestAlg::test4(const EventContext& ctx) const
586{
587 const Trk::IVertexCascadeFitter* fitter =
588 dynamic_cast<const Trk::IVertexCascadeFitter*> (m_fitter.get());
589 if (!fitter)[[unlikely]]{
590 ATH_MSG_ERROR("TrkVKalVrtFitterTestAlg::test4: 'fitter' is nullptr");
591 return StatusCode::FAILURE;
592 }
593 xAODTPUVec_t tracks1 = makexAODTP (makePerigees2());
594
595 std::unique_ptr<IVKalState> state (fitter->makeState(ctx));
596 Trk::VertexID v1 = fitter->startVertex (asVec (tracks1),
597 std::vector<double> {100*MeV, 150*MeV, 200*MeV},
598 *state,
599 930*MeV);
600
601 xAODTPUVec_t tracks2 = makexAODTP (makePerigees3());
602
603 fitter->nextVertex (asVec (tracks2),
604 std::vector<double> {130*MeV, 160*MeV},
605 std::vector<Trk::VertexID> {v1},
606 *state,
607 2000*MeV);
608
609 std::unique_ptr<Trk::VxCascadeInfo> info1 (fitter->fitCascade(*state));
610 info1->setSVOwnership (true);
611
612#if 0
613 std::cout << info1->fitChi2() << " " << info1->nDoF() << "\n";
614 for (const std::vector<TLorentzVector>& vv : info1->getParticleMoms()) {
615 std::cout << "===\n";
616 for (const TLorentzVector& vvv : vv) {
617 std::cout << vvv.X() << " " << vvv.Y() << " " << vvv.Z() << " " << vvv.E() << "\n";
618 }
619 }
620 std::cout << "=== vertices\n";
621 for (const xAOD::Vertex* v : info1->vertices()) {
622 dumpVertex (*v);
623 }
624#endif
625
626 // Some of the comparison thresholds here have to be quite large,
627 // because the fit is unstable against small changes in the rounding
628 // of, eg, trig functions. The results we get can vary depending
629 // on the libc version used as well as on the exact hardware used.
630
631 assert (Athena_test::isEqual (info1->fitChi2(), 8.69008, 1e-5));
632 assert (info1->nDoF() == 8);
633
634
635 const double exp_moms0[][4] =
636 {
637 {65.8357, -2.03326, -1.46405, 119.752},
638 {755.228, 239.515, 134.648, 817.537},
639 {900.997, -348.825, -292.857, 1029.19},
640 {1013.68, 681.319, 331.188, 1272.13},
641 {522.571, -222.398, -113.273, 600.81},
642 {1719.34, -112.854, -155.908, 1964.27},
643 };
644 const size_t nmoms0 = std::distance (std::begin(exp_moms0), std::end(exp_moms0));
645 size_t imoms0 = 0;
646 for (const std::vector<TLorentzVector>& vv : info1->getParticleMoms()) {
647 for (const TLorentzVector& vvv : vv) {
648 assert (imoms0 < nmoms0);
649 assert( Athena_test::isEqual (vvv.X(), exp_moms0[imoms0][0], 0.1) );
650 assert( Athena_test::isEqual (vvv.Y(), exp_moms0[imoms0][1], 0.1) );
651 assert( Athena_test::isEqual (vvv.Z(), exp_moms0[imoms0][2], 0.1) );
652 assert( Athena_test::isEqual (vvv.E(), exp_moms0[imoms0][3], 0.1) );
653 ++imoms0;
654 }
655 }
656 assert (imoms0 == nmoms0);
657
658 assert (info1->vertices().size() == 2);
659
660 xAOD::Vertex exp_v0;
661 exp_v0.makePrivateStore();
662 exp_v0.setPosition({ 7.89827, 0.0514449, -4.04121 });
663 exp_v0.setFitQuality(5.34877, 8);
664 exp_v0.setCovariance(std::vector<float>{
665 0.218298, -0.00769266, 0.0194589, -0.0118989, 0.0107223, 0.208922 });
666 setRefittedPerigee(
667 exp_v0,
668 0,
669 1,
670 exp_mom(exp_moms0, 0),
671 { 0.209404, -4.58753, -0.00519457, 0.00377293, 0.00105397,
672 -4.58753, 154483, 32.603, -0.117209, -35.6007,
673 -0.00519457, 32.603, 0.0113951, -0.000116443, -0.00751125,
674 0.00377293, -0.117209, -0.000116443, 0.009643, 2.37152e-05,
675 0.00105397, -35.6007, -0.00751125, 2.37152e-05, 0.0082042 });
676 setFitQuality(exp_v0, 0, 0.926, 2);
677 setRefittedPerigee(
678 exp_v0,
679 1,
680 -1,
681 exp_mom(exp_moms0, 1),
682 { 0.185428, 0.807536, -0.00324979, -0.000237823, 1.99968e-05,
683 0.807536, 154490, 6.26553, -0.238515, 0.168369,
684 -0.00324979, 6.26553, 0.00856011, -0.00036866, -2.23097e-05,
685 -0.000237823, -0.238515, -0.00036866, 0.00933191, 7.51824e-06,
686 1.99968e-05, 0.168369, -2.23097e-05, 7.51824e-06, 3.74483e-07 });
687 setFitQuality(exp_v0, 1, 4.142, 2);
688 setRefittedPerigee(
689 exp_v0,
690 2,
691 -1,
692 exp_mom(exp_moms0, 2),
693 { 0.191446, -9.49834, -0.00495436, -0.00130953, -4.72358e-05,
694 -9.49834, 154476, 5.42258, -0.231539, 0.236084,
695 -0.00495436, 5.42258, 0.00860893, -0.000425575, 3.61158e-05,
696 -0.00130953, -0.231539, -0.000425575, 0.00920703, -5.93187e-06,
697 -4.72358e-05, 0.236084, 3.61158e-05, -5.93187e-06, 4.8944e-07 });
698 setFitQuality(exp_v0, 2, 0.281, 2);
699
700 compareVertex(*info1->vertices()[0], exp_v0, 0.1);
701
702 xAOD::Vertex exp_v1;
703 exp_v1.makePrivateStore();
704 exp_v1.setPosition({ 5.31046, 0.22012, -3.80093 });
705 exp_v1.setFitQuality(3.34131, 8);
706 exp_v1.setCovariance(std::vector<float>{
707 0.0239352, 0.000977903, 0.00708136, 4.16975e-05, 0.00295894, 0.2431 });
708 setRefittedPerigee(
709 exp_v1,
710 0,
711 1,
712 exp_mom(exp_moms0, 3),
713 { 0.166917, -16.9685, -0.000309914, -0.000819924, 1.31935e-05,
714 -16.9685, 6.35682e+08, -139.016, 9.70413, -495.474,
715 -0.000309914, -139.016, 0.0100214, -7.71225e-06, 0.000103046,
716 -0.000819924, 9.70413, -7.71225e-06, 0.00998731, -5.42066e-06,
717 1.31935e-05, -495.474, 0.000103046, -5.42066e-06, 0.000386195 });
718 setFitQuality(exp_v1, 0, 1.986, 2);
719 setRefittedPerigee(
720 exp_v1,
721 1,
722 -1,
723 exp_mom(exp_moms0, 4),
724 { 0.20904, -15.3143, 0.00086181, -0.000463146, -2.83922e-05,
725 -15.3143, 6.35682e+08, 306.365, -3.09595, -2470.81,
726 0.00086181, 306.365, 0.0101467, -2.3178e-06, -0.00116433,
727 -0.000463146, -3.09595, -2.3178e-06, 0.00999678, 8.90989e-07,
728 -2.83922e-05, -2470.81, -0.00116433, 8.90989e-07, 0.00960596 });
729 setFitQuality(exp_v1, 1, 1.356, 2);
730
731 compareVertex (*info1->vertices()[1], exp_v1, 0.1);
732
733 return StatusCode::SUCCESS;
734}
735
736
737} // namespace Trk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
double charge(const T &p)
Definition AtlasPID.h:1003
std::vector< size_t > vec
Helper class to provide constant type-safe access to aux data.
#define AmgSymMatrix(dim)
static const double MeV
Base class for VKal state object.
static Double_t a
size_t size() const
Number of registered mappings.
Algorithm for testing TrkVKalVrtFitter.
Helper class to provide constant type-safe access to aux data.
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition FitQuality.h:97
virtual const S & associatedSurface() const override final
Access to the Surface method.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
StatusCode test2(const EventContext &ctx) const
StatusCode test4(const EventContext &ctx) const
virtual StatusCode initialize() override
Standard Gaudi initialize method.
StatusCode test1(const EventContext &ctx) const
ToolHandle< Trk::IVertexFitter > m_fitter
StatusCode test3(const EventContext &ctx) const
virtual StatusCode execute(const EventContext &ctx) const override
Execute the algorithm.
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
STL class.
void setDefiningParametersCovMatrixVec(const std::vector< float > &cov)
Set the defining parameters covariance matrix using a length 15 vector.
void setDefiningParameters(float d0, float z0, float phi0, float theta, float qOverP)
Set the defining parameters.
void setParametersOrigin(float x, float y, float z)
Set the origin for the parameters.
void setParametersOrigin(float x, float y, float z)
Set the origin for the parameters.
void setDefiningParameters(float d0, float z0, float phi0, float theta, float qOverP)
Set the defining parameters.
void setDefiningParametersCovMatrixVec(const std::vector< float > &cov)
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
void setCovariance(const std::vector< float > &value)
Sets the covariance matrix as a simple vector of values.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
double chi2(TH1 *h0, TH1 *h1)
void compress(const AmgSymMatrix(N) &covMatrix, std::vector< float > &vec)
Eigen::Matrix< double, 3, 1 > Vector3D
bool isEqual(double x1, double x2, double thresh=1e-6)
Definition FLOATassert.h:26
float chiSquared(const U &p)
l
Printing final latex table to .tex output file.
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
Ensure that the ATLAS eigen extensions are properly loaded.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersT< NeutralParametersDim, Neutral, PerigeeSurface > NeutralPerigee
@ v
Definition ParamDefs.h:78
@ phi0
Definition ParamDefs.h:65
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
ParametersBase< TrackParametersDim, Charged > TrackParameters
which(filename, env=os.environ)
UNIX-style which ---------------------------------------------------------—.
Definition unixtools.py:39
STL namespace.
NeutralParticle_v1 NeutralParticle
Reference the current persistent version:
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
#define unlikely(x)