File indexing completed on 2025-11-07 09:20:13
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/ReconstructedParticleCollection.h>
0009 #include <edm4hep/EDM4hepVersion.h>
0010 #include <edm4hep/EventHeaderCollection.h>
0011 #include <edm4hep/MCParticleCollection.h>
0012 #include <edm4hep/ParticleIDCollection.h>
0013 #if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 2)
0014 #include <edm4hep/Vector2i.h>
0015 #endif
0016 #include <edm4hep/Vector3d.h>
0017 #include <edm4hep/Vector3f.h>
0018 #include <spdlog/common.h>
0019 #include <cmath>
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 assocs_in = std::make_unique<edm4eic::MCRecoParticleAssociationCollection>();
0056 auto mcparts = std::make_unique<edm4hep::MCParticleCollection>();
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::Vector3f(),
0077 edm4hep::Vector3f(),
0078 edm4hep::Vector3f()
0079 #if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 2)
0080 ,
0081 edm4hep::Vector2i()
0082 #endif
0083 );
0084
0085 auto assoc_in = assocs_in->create();
0086 assoc_in.setRec((*parts_in)[0]);
0087 assoc_in.setSim((*mcparts)[0]);
0088
0089 auto parts_out = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0090 auto assocs_out = std::make_unique<edm4eic::MCRecoParticleAssociationCollection>();
0091 auto partids_out = std::make_unique<edm4hep::ParticleIDCollection>();
0092 algo.process({headers.get(), parts_in.get(), assocs_in.get()},
0093 {parts_out.get(), assocs_out.get(), partids_out.get()});
0094
0095 REQUIRE((*parts_in).size() == (*parts_out).size());
0096 REQUIRE((*assocs_in).size() == (*assocs_out).size());
0097 REQUIRE((*partids_out).size() == (*partids_out).size());
0098 }
0099 }