22 #include "GaudiKernel/SystemOfUnits.h"
29 #include "CLHEP/Vector/LorentzVector.h"
40 std::vector<const T*> asVec (
const std::vector<std::unique_ptr<T> >&
v)
42 std::vector<const T*> ret;
43 ret.reserve(
v.size());
45 for (
const std::unique_ptr<T>&
p :
v) {
46 ret.push_back (
p.get());
52 std::vector<const Trk::NeutralParameters*>
53 asVec (
const std::vector<std::unique_ptr<Trk::NeutralPerigee> >&
v)
55 std::vector<const Trk::NeutralParameters*> ret;
56 ret.reserve(
v.size());
58 for (
const std::unique_ptr<Trk::NeutralPerigee>&
p :
v) {
59 ret.push_back (
p.get());
73 using PerigeeUVec_t = std::
vector<std::unique_ptr<
Trk::Perigee> >;
76 NeutralUVec_t makeNeutrals1()
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()));
103 tp.setDefiningParameters(perigee.parameters()[
Trk::d0],
111 std::vector<float> covMatrixVec;
114 tp.setDefiningParametersCovMatrixVec(covMatrixVec);
116 tp.setParametersOrigin(surfaceCenter.x(), surfaceCenter.y(), surfaceCenter.z() );
121 tp.setDefiningParameters(perigee.parameters()[
Trk::d0],
129 std::vector<float> covMatrixVec;
132 tp.setDefiningParametersCovMatrixVec(covMatrixVec);
134 tp.setParametersOrigin(surfaceCenter.x(), surfaceCenter.y(), surfaceCenter.z() );
138 using xAODTPUVec_t = std::vector<std::unique_ptr<xAOD::TrackParticle> >;
139 xAODTPUVec_t makexAODTP (PerigeeUVec_t&& perigees)
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));
154 using xAODNPUVec_t = std::vector<std::unique_ptr<xAOD::NeutralParticle> >;
155 xAODNPUVec_t makexAODNP (NeutralUVec_t&& perigees)
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));
172 for (
int i=0;
i < 5;
i++) {
173 for (
int j=0; j < 5; j++) {
174 std::cout <<
m(
i,j) <<
", ";
183 std::cout <<
"vvv\n";
184 std::cout <<
v.x() <<
" " <<
v.y() <<
" " <<
v.z() <<
"\n";
186 if (vertexTypeAcc.isAvailable(
v)) {
187 std::cout <<
"vertexType " <<
v.vertexType() <<
"\n";
189 std::cout <<
"chi2/ndof " <<
v.chiSquared() <<
" " <<
v.numberDoF() <<
"\n";
192 for (
float f :
v.covariance()) {
193 std::cout <<
f <<
" ";
198 if (trackParticleLinksAcc.isAvailable(
v)) {
199 std::cout <<
"tplinks ";
201 std::cout <<
l.dataID() <<
"/" <<
l.index() <<
" ";
207 if (trackWeightsAcc.isAvailable(
v)) {
209 for (
float f :
v.trackWeights()) {
210 std::cout <<
f <<
" ";
216 if (neutralParticleLinksAcc.isAvailable(
v)) {
217 std::cout <<
"nplinks ";
219 std::cout <<
l.dataID() <<
"/" <<
l.index() <<
" ";
225 if (neutralWeightsAcc.isAvailable(
v)) {
227 for (
float f :
v.neutralWeights()) {
228 std::cout <<
f <<
" ";
233 std::cout <<
v.vxTrackAtVertexAvailable() <<
"\n";
237 if (
vv.perigeeAtVertex()) {
238 dumpCovariance (*
vv.perigeeAtVertex()->covariance());
241 std::cout <<
"(null)";
248 void assertVec3D (
const char*
which,
258 std::cerr <<
"TrkVKalVrtFitterTestAlg::assertVec3D mismatch " <<
which
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);
289 assertVec3D (
"vertex pos",
a.position(),
b.position(),
thresh);
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;
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);
310 assert (avec[
i].trackQuality().numberDoF() ==
311 bvec[
i].trackQuality().numberDoF());
320 const std::vector<float>&
c)
322 std::vector< Trk::VxTrackAtVertex >&
vec =
v.vxTrackAtVertex();
323 if (
vec.size() <=
i)
vec.resize(
i+1);
326 for (
int i=0;
i < 5;
i++) {
327 for (
int j=0; j < 5; j++) {
328 unsigned ipos =
i*5 + j;
329 (
cov)(
i,j) = ipos <
c.size() ?
c[ipos] : 0;
336 vec[
i].setPerigeeAtVertex (
p.release());
342 std::vector< Trk::VxTrackAtVertex >&
vec =
v.vxTrackAtVertex();
343 if (
vec.size() <=
i)
vec.resize(
i+1);
360 return StatusCode::SUCCESS;
375 return StatusCode::SUCCESS;
386 exp_v0.
setPosition ({-5.58116, -8.50767, -4.76804});
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);
397 NeutralUVec_t neutrals = makeNeutrals1();
398 std::unique_ptr<xAOD::Vertex> v1 (
m_fitter->fit (std::vector<const Trk::TrackParameters*>(),
400 compareVertex (*v1, exp_v0);
402 return StatusCode::SUCCESS;
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,
420 setFitQuality(exp_v0, 0, 0.306, 2);
421 setFitQuality(exp_v0, 1, 0.00660789, 2);
422 setFitQuality(exp_v0, 2, 0.266975, 2);
426 NeutralUVec_t neutrals = makeNeutrals1();
427 std::unique_ptr<xAOD::Vertex> v1 (
m_fitter->fit (std::vector<const Trk::TrackParameters*>(),
430 compareVertex (*v1, exp_v0);
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,
444 setFitQuality(exp_v1, 0, 0.281, 2);
445 setFitQuality(exp_v1, 1, 0.010, 2);
446 setFitQuality(exp_v1, 2, 0.248, 2);
448 xAODNPUVec_t xaodnp = makexAODNP(makeNeutrals1());
449 std::unique_ptr<xAOD::Vertex>
v2 (
m_fitter->fit (std::vector<const xAOD::TrackParticle*>(),
452 compareVertex (*
v2, exp_v1);
454 return StatusCode::SUCCESS;
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,
472 setFitQuality (exp_v0, 0, 0.396, 2);
473 setFitQuality (exp_v0, 1, 0.752, 2);
474 setFitQuality (exp_v0, 2, 1.055, 2);
481 pnt2covar.setIdentity();
484 NeutralUVec_t neutrals = makeNeutrals1();
485 std::unique_ptr<xAOD::Vertex> v1 (
m_fitter->fit (std::vector<const Trk::TrackParameters*>(),
488 compareVertex (*v1, exp_v0);
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,
503 setFitQuality (exp_v1, 0, 0.313, 2);
504 setFitQuality (exp_v1, 1, 0.692, 2);
505 setFitQuality (exp_v1, 2, 1.246, 2);
507 xAODNPUVec_t xaodnp = makexAODNP (makeNeutrals1());
508 std::unique_ptr<xAOD::Vertex>
v2 (
m_fitter->fit (std::vector<const xAOD::TrackParticle*>(),
511 compareVertex (*
v2, exp_v1);
513 return StatusCode::SUCCESS;
528 for (
int i=0;
i < 5;
i++) {
536 using PerigeeUVec_t = std::vector<std::unique_ptr<Trk::Perigee> >;
537 PerigeeUVec_t makePerigees2()
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()));
556 PerigeeUVec_t makePerigees3()
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()));
574 return {moms[imom][0], moms[imom][1], moms[imom][2]};
590 xAODTPUVec_t tracks1 = makexAODTP (makePerigees2());
592 std::unique_ptr<IVKalState> state (
fitter->makeState());
594 std::vector<double> {100*
MeV, 150*
MeV, 200*
MeV},
598 xAODTPUVec_t tracks2 = makexAODTP (makePerigees3());
600 fitter->nextVertex (asVec (tracks2),
601 std::vector<double> {130*
MeV, 160*
MeV},
602 std::vector<Trk::VertexID> {v1},
606 std::unique_ptr<Trk::VxCascadeInfo> info1 (
fitter->fitCascade(*state));
610 std::cout << info1->
fitChi2() <<
" " << info1->
nDoF() <<
"\n";
612 std::cout <<
"===\n";
613 for (
const TLorentzVector& vvv :
vv) {
614 std::cout << vvv.X() <<
" " << vvv.Y() <<
" " << vvv.Z() <<
" " << vvv.E() <<
"\n";
617 std::cout <<
"=== vertices\n";
629 assert (info1->
nDoF() == 8);
632 const double exp_moms0[][4] =
634 {65.8357, -2.03326, -1.46405, 119.752},
635 {755.228, 239.515, 134.648, 817.537},
636 {900.997, -348.825, -292.857, 1029.19},
637 {1013.68, 681.319, 331.188, 1272.13},
638 {522.571, -222.398, -113.273, 600.81},
639 {1719.34, -112.854, -155.908, 1964.27},
644 for (
const TLorentzVector& vvv :
vv) {
645 assert (imoms0 < nmoms0);
653 assert (imoms0 == nmoms0);
655 assert (info1->
vertices().size() == 2);
659 exp_v0.
setPosition({ 7.89827, 0.0514449, -4.04121 });
662 0.218298, -0.00769266, 0.0194589, -0.0118989, 0.0107223, 0.208922 });
667 exp_mom(exp_moms0, 0),
668 { 0.209404, -4.58753, -0.00519457, 0.00377293, 0.00105397,
669 -4.58753, 154483, 32.603, -0.117209, -35.6007,
670 -0.00519457, 32.603, 0.0113951, -0.000116443, -0.00751125,
671 0.00377293, -0.117209, -0.000116443, 0.009643, 2.37152e-05,
672 0.00105397, -35.6007, -0.00751125, 2.37152e-05, 0.0082042 });
673 setFitQuality(exp_v0, 0, 0.926, 2);
678 exp_mom(exp_moms0, 1),
679 { 0.185428, 0.807536, -0.00324979, -0.000237823, 1.99968e-05,
680 0.807536, 154490, 6.26553, -0.238515, 0.168369,
681 -0.00324979, 6.26553, 0.00856011, -0.00036866, -2.23097e-05,
682 -0.000237823, -0.238515, -0.00036866, 0.00933191, 7.51824e-06,
683 1.99968e-05, 0.168369, -2.23097e-05, 7.51824e-06, 3.74483e-07 });
684 setFitQuality(exp_v0, 1, 4.142, 2);
689 exp_mom(exp_moms0, 2),
690 { 0.191446, -9.49834, -0.00495436, -0.00130953, -4.72358e-05,
691 -9.49834, 154476, 5.42258, -0.231539, 0.236084,
692 -0.00495436, 5.42258, 0.00860893, -0.000425575, 3.61158e-05,
693 -0.00130953, -0.231539, -0.000425575, 0.00920703, -5.93187e-06,
694 -4.72358e-05, 0.236084, 3.61158e-05, -5.93187e-06, 4.8944e-07 });
695 setFitQuality(exp_v0, 2, 0.281, 2);
697 compareVertex(*info1->
vertices()[0], exp_v0, 0.1);
701 exp_v1.
setPosition({ 5.31046, 0.22012, -3.80093 });
704 0.0239352, 0.000977903, 0.00708136, 4.16975e-05, 0.00295894, 0.2431 });
709 exp_mom(exp_moms0, 3),
710 { 0.166917, -16.9685, -0.000309914, -0.000819924, 1.31935e-05,
711 -16.9685, 6.35682e+08, -139.016, 9.70413, -495.474,
712 -0.000309914, -139.016, 0.0100214, -7.71225e-06, 0.000103046,
713 -0.000819924, 9.70413, -7.71225e-06, 0.00998731, -5.42066e-06,
714 1.31935e-05, -495.474, 0.000103046, -5.42066e-06, 0.000386195 });
715 setFitQuality(exp_v1, 0, 1.986, 2);
720 exp_mom(exp_moms0, 4),
721 { 0.20904, -15.3143, 0.00086181, -0.000463146, -2.83922e-05,
722 -15.3143, 6.35682e+08, 306.365, -3.09595, -2470.81,
723 0.00086181, 306.365, 0.0101467, -2.3178e-06, -0.00116433,
724 -0.000463146, -3.09595, -2.3178e-06, 0.00999678, 8.90989e-07,
725 -2.83922e-05, -2470.81, -0.00116433, 8.90989e-07, 0.00960596 });
726 setFitQuality(exp_v1, 1, 1.356, 2);
728 compareVertex (*info1->
vertices()[1], exp_v1, 0.1);
730 return StatusCode::SUCCESS;