Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:47:52

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 #include <boost/test/unit_test_suite.hpp>
0011 
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/TrackParametrization.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Vertexing/Vertex.hpp"
0016 #include "ActsPlugins/EDM4hep/EDM4hepUtil.hpp"
0017 
0018 #include <edm4hep/VertexCollection.h>
0019 
0020 using namespace Acts;
0021 using namespace ActsPlugins;
0022 
0023 namespace {
0024 auto gctx = GeometryContext::dangerouslyDefaultConstruct();
0025 }  // namespace
0026 
0027 BOOST_AUTO_TEST_SUITE(EDM4hepVertexWriteTest)
0028 
0029 BOOST_AUTO_TEST_CASE(WriteVertex) {
0030   Vertex vertex;
0031   vertex.setPosition(Vector3(1, 2, 3));
0032   vertex.setTime(42);
0033   SquareMatrix4 covariance;
0034   // clang-format off
0035   covariance << 1, 2, 3, 4,
0036                  2, 5, 6, 7,
0037                  3, 6, 8, 9,
0038                  4, 7, 9, 10;
0039   // clang-format on
0040   vertex.setFullCovariance(covariance);
0041   vertex.setFitQuality(7, 8);
0042 
0043   edm4hep::VertexCollection vertices;
0044   auto to = vertices.create();
0045 
0046   EDM4hepUtil::writeVertex(vertex, to);
0047 
0048   BOOST_CHECK_EQUAL(to.getPosition()[0], 1);
0049   BOOST_CHECK_EQUAL(to.getPosition()[1], 2);
0050   BOOST_CHECK_EQUAL(to.getPosition()[2], 3);
0051 
0052   BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::x,
0053                                                edm4hep::FourMomCoords::x),
0054                     covariance(eFreePos0, eFreePos0));
0055   BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::x,
0056                                                edm4hep::FourMomCoords::y),
0057                     covariance(eFreePos0, eFreePos1));
0058   BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::x,
0059                                                edm4hep::FourMomCoords::z),
0060                     covariance(eFreePos0, eFreePos2));
0061   BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::y,
0062                                                edm4hep::FourMomCoords::x),
0063                     covariance(eFreePos1, eFreePos0));
0064   BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::y,
0065                                                edm4hep::FourMomCoords::y),
0066                     covariance(eFreePos1, eFreePos1));
0067   BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::y,
0068                                                edm4hep::FourMomCoords::z),
0069                     covariance(eFreePos1, eFreePos2));
0070   BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::z,
0071                                                edm4hep::FourMomCoords::x),
0072                     covariance(eFreePos2, eFreePos0));
0073   BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::z,
0074                                                edm4hep::FourMomCoords::y),
0075                     covariance(eFreePos2, eFreePos1));
0076   BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::z,
0077                                                edm4hep::FourMomCoords::z),
0078                     covariance(eFreePos2, eFreePos2));
0079 
0080   if constexpr (EDM4hepUtil::detail::kEdm4hepVertexHasTime) {
0081     BOOST_CHECK_EQUAL(to.getPosition()[3], 42);
0082     BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::t,
0083                                                  edm4hep::FourMomCoords::t),
0084                       covariance(eFreeTime, eFreeTime));
0085     BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::x,
0086                                                  edm4hep::FourMomCoords::t),
0087                       covariance(eFreePos0, eFreeTime));
0088     BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::y,
0089                                                  edm4hep::FourMomCoords::t),
0090                       covariance(eFreePos1, eFreeTime));
0091     BOOST_CHECK_EQUAL(to.getCovMatrix().getValue(edm4hep::FourMomCoords::z,
0092                                                  edm4hep::FourMomCoords::t),
0093                       covariance(eFreePos2, eFreeTime));
0094   }
0095 }
0096 
0097 BOOST_AUTO_TEST_SUITE_END()