File indexing completed on 2025-07-15 08:16:24
0001
0002
0003
0004 #include <algorithms/logger.h>
0005 #include <catch2/catch_test_macros.hpp>
0006 #include <cmath>
0007 #include <edm4eic/Cov4f.h>
0008 #include <edm4eic/MCRecoParticleAssociationCollection.h>
0009 #include <edm4eic/ReconstructedParticleCollection.h>
0010 #include <edm4hep/MCParticleCollection.h>
0011 #include <edm4hep/ParticleIDCollection.h>
0012 #include <edm4hep/Vector2i.h>
0013 #include <edm4hep/Vector3d.h>
0014 #include <edm4hep/Vector3f.h>
0015 #include <memory>
0016 #include <spdlog/common.h>
0017
0018 #include "algorithms/pid_lut/PIDLookup.h"
0019 #include "algorithms/pid_lut/PIDLookupConfig.h"
0020
0021 using eicrecon::PIDLookup;
0022 using eicrecon::PIDLookupConfig;
0023
0024 TEST_CASE("particles acquire PID", "[PIDLookup]") {
0025 PIDLookup algo("test");
0026
0027 PIDLookupConfig cfg{
0028 .filename = "/dev/null",
0029 .system = "MockTracker_ID",
0030 .pdg_values = {11},
0031 .charge_values = {1},
0032 .momentum_edges = {0., 1., 2.},
0033 .polar_edges = {0., M_PI},
0034 .azimuthal_binning = {0., 2 * M_PI, 2 * M_PI},
0035 .momentum_bin_centers_in_lut = true,
0036 .polar_bin_centers_in_lut = true,
0037 .use_radians = true,
0038 };
0039
0040 SECTION("single hit with couple contributions") {
0041 algo.level(algorithms::LogLevel(spdlog::level::trace));
0042 algo.applyConfig(cfg);
0043 algo.init();
0044
0045 auto parts_in = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0046 auto assocs_in = std::make_unique<edm4eic::MCRecoParticleAssociationCollection>();
0047 auto mcparts = std::make_unique<edm4hep::MCParticleCollection>();
0048
0049 parts_in->create(0,
0050 0.5,
0051 edm4hep::Vector3f({0.5, 0., 0.}),
0052 edm4hep::Vector3f({0., 0., 0.}),
0053 1.,
0054 0.,
0055 0.,
0056 edm4eic::Cov4f(),
0057 0
0058 );
0059 mcparts->create(11,
0060 0,
0061 0,
0062 0.,
0063 0.,
0064 0.,
0065 edm4hep::Vector3d(),
0066 edm4hep::Vector3d(),
0067 edm4hep::Vector3f(),
0068 edm4hep::Vector3f(),
0069 edm4hep::Vector3f(),
0070 edm4hep::Vector2i()
0071 );
0072
0073 auto assoc_in = assocs_in->create();
0074 assoc_in.setRec((*parts_in)[0]);
0075 assoc_in.setSim((*mcparts)[0]);
0076
0077 auto parts_out = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0078 auto assocs_out = std::make_unique<edm4eic::MCRecoParticleAssociationCollection>();
0079 auto partids_out = std::make_unique<edm4hep::ParticleIDCollection>();
0080 algo.process({parts_in.get(), assocs_in.get()},
0081 {parts_out.get(), assocs_out.get(), partids_out.get()});
0082
0083 REQUIRE((*parts_in).size() == (*parts_out).size());
0084 REQUIRE((*assocs_in).size() == (*assocs_out).size());
0085 REQUIRE((*partids_out).size() == (*partids_out).size());
0086 }
0087 }