24 #include "GaudiKernel/SystemOfUnits.h"
28 #include "CLHEP/Vector/LorentzVector.h"
50 for (
int i=0;
i < 5;
i++) {
58 using PerigeeUVec_t = std::vector<std::unique_ptr<Trk::Perigee> >;
59 PerigeeUVec_t makePerigees1()
72 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1a, mom1a, 1, pos1a, cov5()).
release());
73 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1b, mom1b, -1, pos1b, cov5()).
release());
74 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1c, mom1c, -1, pos1c, cov5()).
release());
80 using PerigeeUVec_t = std::vector<std::unique_ptr<Trk::Perigee> >;
81 PerigeeUVec_t makePerigees2()
92 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1a, mom1a, 1, pos1a, cov5a()).
release());
93 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1b, mom1b, -1, pos1a, cov5a()).
release());
94 ret.emplace_back (std::make_unique<Trk::Perigee>(pos1c, mom1c, -1, pos1a, cov5a()).
release());
100 using TrackUVec_t = std::vector<std::unique_ptr<Trk::Track> >;
101 TrackUVec_t makeTracks (
const PerigeeUVec_t& perigees)
105 for (
const std::unique_ptr<Trk::Perigee>&
p : perigees) {
107 auto fqual = std::make_unique<Trk::FitQuality> (0, 0);
108 auto tsos = std::make_unique<Trk::TrackStates>();
109 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
111 tsos->push_back(std::make_unique<Trk::TrackStateOnSurface>(
112 nullptr,
p->uniqueClone(),
nullptr, typePattern));
114 std::make_unique<Trk::Track>(
info, std::move(tsos), std::move(fqual)));
123 for (
int i=0;
i < 5;
i++) {
124 for (
int j=0; j < 5; j++) {
125 std::cout <<
m(
i,j) <<
", ";
134 std::cout <<
"vvv\n";
135 std::cout <<
v.x() <<
", " <<
v.y() <<
", " <<
v.z() <<
"\n";
137 if (vertexTypeAcc.isAvailable(
v)) {
138 std::cout <<
"vertexType " <<
v.vertexType() <<
"\n";
140 std::cout <<
"chi2/ndof " <<
v.chiSquared() <<
", " <<
v.numberDoF() <<
"\n";
143 for (
float f :
v.covariance()) {
144 std::cout <<
f <<
", ";
149 if (trackParticleLinksAcc.isAvailable(
v)) {
150 std::cout <<
"tplinks ";
152 std::cout <<
l.dataID() <<
"/" <<
l.index() <<
" ";
158 if (trackWeightsAcc.isAvailable(
v)) {
160 for (
float f :
v.trackWeights()) {
161 std::cout <<
f <<
" ";
167 if (neutralParticleLinksAcc.isAvailable(
v)) {
168 std::cout <<
"nplinks ";
170 std::cout <<
l.dataID() <<
"/" <<
l.index() <<
" ";
176 if (neutralWeightsAcc.isAvailable(
v)) {
178 for (
float f :
v.neutralWeights()) {
179 std::cout <<
f <<
" ";
184 std::cout <<
v.vxTrackAtVertexAvailable() <<
"\n";
188 if (
vv.perigeeAtVertex()) {
189 dumpCovariance (*
vv.perigeeAtVertex()->covariance());
192 std::cout <<
"(null)";
199 void assertVec3D (
const char*
which,
208 std::cerr <<
"TrkVKalVrtFitterTestAlg::assertVec3D mismatch " <<
which
223 assertVec3D (
"vertex pos",
a.position(),
b.position(), 5
e-4);
227 assert (
a.covariance().size() ==
b.covariance().size());
228 for (
unsigned int i = 0;
i <
a.covariance().
size();
i++) {
229 if (std::isinf(
a.covariance()[
i]) && std::isinf(
b.covariance()[
i]))
continue;
237 std::vector< Trk::VxTrackAtVertex >&
vec =
v.vxTrackAtVertex();
238 if (
vec.size() <=
i)
vec.resize(
i+1);
239 vec[
i].setInitialPerigee (
p);
243 void setInitialPerigees (
xAOD::Vertex&
v,
const TrackUVec_t& tracks)
246 for (
const std::unique_ptr<Trk::Track>&
t : tracks) {
247 setInitialPerigee (
v,
i,
t->perigeeParameters());
257 PerigeeUVec_t perigees;
258 std::unique_ptr<Trk::MvfFitInfo>
fi;
259 std::vector<Trk::VxTrackAtVertex*> vtracks;
260 std::vector<Trk::TrackToVtxLink>
links;
264 void initVertex (VertexInfo& vi,
266 PerigeeUVec_t&& perigees)
272 vi.perigees = std::move (perigees);
274 vi.v.makePrivateStore();
275 vi.v.setPosition (
pos);
277 vi.tracks = makeTracks (vi.perigees);
278 setInitialPerigees (vi.v, vi.tracks);
280 auto cv = std::make_unique<xAOD::Vertex>();
281 cv->makePrivateStore();
282 cv->setPosition (
pos);
284 looseConstraintCovariance.setIdentity();
285 looseConstraintCovariance = looseConstraintCovariance * 1
e+5;
286 cv->setCovariancePosition (looseConstraintCovariance);
287 cv->setFitQuality (0, -3);
288 vi.fi = std::make_unique<Trk::MvfFitInfo> (cv.release(),
291 MvfFitInfo(vi.v) = vi.fi.get();
292 isInitialized(vi.v) =
false;
294 vi.links.reserve (vi.perigees.size());
295 for (std::unique_ptr<Trk::Perigee>&
p : vi.perigees) {
296 vi.links.push_back (
new std::vector<xAOD::Vertex*> {&vi.v});
297 auto tav = std::make_unique<Trk::MVFVxTrackAtVertex>(1.5,
p->clone(),
p.get());
298 tav->setLinkToVertices (&vi.links.back());
299 vi.vtracks.push_back (tav.release());
301 VTAV(vi.v) = vi.vtracks;
317 return StatusCode::SUCCESS;
330 return StatusCode::SUCCESS;
337 initVertex (v1, {1.5*
mm, 1.7*
mm, -6*
mm}, makePerigees1());
341 initVertex (
v2, {9.8*
mm, 0.2*
mm, -4.8*
mm}, makePerigees2());
343 std::vector<xAOD::Vertex*> verts {&v1.v, &
v2.v};
351 {730.916, 138.738, 926.494,
352 -7.25401, 46.1613, 66.2963});
356 exp_v2.
setPosition ({7.97405, 0.106089, -4.97332});
359 {0.34849, -0.0194732, 0.0290884,
360 -0.00362668, 0.000706326, 0.445416});
362 compareVertex (v1.v, exp_v1);
363 compareVertex (
v2.v, exp_v2);
365 return StatusCode::SUCCESS;