File indexing completed on 2026-09-14 08:25:34
0001
0002
0003
0004 #include <algorithms/logger.h>
0005 #include <catch2/catch_test_macros.hpp>
0006 #include <edm4eic/Cov4f.h>
0007 #include <edm4eic/MCRecoParticleAssociationCollection.h>
0008 #include <edm4eic/MCRecoParticleLinkCollection.h>
0009 #include <edm4eic/ReconstructedParticleCollection.h>
0010 #include <edm4hep/EventHeaderCollection.h>
0011 #include <edm4hep/MCParticleCollection.h>
0012 #include <edm4hep/ParticleIDCollection.h>
0013 #include <edm4hep/Vector3d.h>
0014 #include <edm4hep/Vector3f.h>
0015 #include <podio/detail/Link.h>
0016 #include <spdlog/common.h>
0017 #include <cmath>
0018 #include <cstddef>
0019 #include <deque>
0020 #include <memory>
0021 #include <string>
0022 #include <vector>
0023
0024 #include "algorithms/pid_lut/PIDLookup.h"
0025 #include "algorithms/pid_lut/PIDLookupConfig.h"
0026
0027 using eicrecon::PIDLookup;
0028 using eicrecon::PIDLookupConfig;
0029
0030 TEST_CASE("particles acquire PID", "[PIDLookup]") {
0031 PIDLookup algo("test");
0032
0033 PIDLookupConfig cfg{
0034 .filename = "/dev/null",
0035 .system = "MockTracker_ID",
0036 .pdg_values = {11},
0037 .charge_values = {1},
0038 .momentum_edges = {0., 1., 2.},
0039 .polar_edges = {0., M_PI},
0040 .azimuthal_binning = {0., 2 * M_PI, 2 * M_PI},
0041 .momentum_bin_centers_in_lut = true,
0042 .polar_bin_centers_in_lut = true,
0043 .use_radians = true,
0044 };
0045
0046 SECTION("single hit with couple contributions") {
0047 algo.level(algorithms::LogLevel(spdlog::level::trace));
0048 algo.applyConfig(cfg);
0049 algo.init();
0050
0051 auto headers = std::make_unique<edm4hep::EventHeaderCollection>();
0052 auto header = headers->create(1, 1, 12345678, 1.0);
0053
0054 auto parts_in = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0055 auto mcparts = std::make_unique<edm4hep::MCParticleCollection>();
0056 edm4eic::MCRecoParticleLinkCollection links_in;
0057
0058 parts_in->create(0,
0059 0.5,
0060 edm4hep::Vector3f({0.5, 0., 0.}),
0061 edm4hep::Vector3f({0., 0., 0.}),
0062 1.,
0063 0.,
0064 0.,
0065 edm4eic::Cov4f(),
0066 0
0067 );
0068 mcparts->create(11,
0069 0,
0070 0,
0071 0.,
0072 0.,
0073 0.,
0074 edm4hep::Vector3d(),
0075 edm4hep::Vector3d(),
0076 edm4hep::Vector3d(),
0077 edm4hep::Vector3d(),
0078 9
0079 );
0080
0081 auto link_in = links_in.create();
0082 link_in.setFrom((*parts_in)[0]);
0083 link_in.setTo((*mcparts)[0]);
0084 link_in.setWeight(0.F);
0085
0086 auto parts_out = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0087 auto assocs_out = std::make_unique<edm4eic::MCRecoParticleAssociationCollection>();
0088 auto partids_out = std::make_unique<edm4hep::ParticleIDCollection>();
0089 edm4eic::MCRecoParticleLinkCollection links_out;
0090 algo.process({headers.get(), parts_in.get(), &links_in},
0091 {parts_out.get(), &links_out, assocs_out.get(), partids_out.get()});
0092
0093 REQUIRE((*parts_in).size() == (*parts_out).size());
0094 REQUIRE(links_in.size() == (*assocs_out).size());
0095 REQUIRE(
0096 (*partids_out).empty());
0097
0098
0099 REQUIRE(links_out.size() == (*assocs_out).size());
0100 for (size_t i = 0; i < links_out.size(); ++i) {
0101 REQUIRE(links_out[i].getFrom() == (*assocs_out)[i].getRec());
0102 REQUIRE(links_out[i].getTo() == (*assocs_out)[i].getSim());
0103 REQUIRE(links_out[i].getWeight() == (*assocs_out)[i].getWeight());
0104 }
0105 }
0106 }