File indexing completed on 2025-09-18 08:17:59
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/EventHeaderCollection.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 <spdlog/common.h>
0016 #include <cmath>
0017 #include <memory>
0018 #include <string>
0019 #include <vector>
0020
0021 #include "algorithms/pid_lut/PIDLookup.h"
0022 #include "algorithms/pid_lut/PIDLookupConfig.h"
0023
0024 using eicrecon::PIDLookup;
0025 using eicrecon::PIDLookupConfig;
0026
0027 TEST_CASE("particles acquire PID", "[PIDLookup]") {
0028 PIDLookup algo("test");
0029
0030 PIDLookupConfig cfg{
0031 .filename = "/dev/null",
0032 .system = "MockTracker_ID",
0033 .pdg_values = {11},
0034 .charge_values = {1},
0035 .momentum_edges = {0., 1., 2.},
0036 .polar_edges = {0., M_PI},
0037 .azimuthal_binning = {0., 2 * M_PI, 2 * M_PI},
0038 .momentum_bin_centers_in_lut = true,
0039 .polar_bin_centers_in_lut = true,
0040 .use_radians = true,
0041 };
0042
0043 SECTION("single hit with couple contributions") {
0044 algo.level(algorithms::LogLevel(spdlog::level::trace));
0045 algo.applyConfig(cfg);
0046 algo.init();
0047
0048 auto headers = std::make_unique<edm4hep::EventHeaderCollection>();
0049 auto header = headers->create(1, 1, 12345678, 1.0);
0050
0051 auto parts_in = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0052 auto assocs_in = std::make_unique<edm4eic::MCRecoParticleAssociationCollection>();
0053 auto mcparts = std::make_unique<edm4hep::MCParticleCollection>();
0054
0055 parts_in->create(0,
0056 0.5,
0057 edm4hep::Vector3f({0.5, 0., 0.}),
0058 edm4hep::Vector3f({0., 0., 0.}),
0059 1.,
0060 0.,
0061 0.,
0062 edm4eic::Cov4f(),
0063 0
0064 );
0065 mcparts->create(11,
0066 0,
0067 0,
0068 0.,
0069 0.,
0070 0.,
0071 edm4hep::Vector3d(),
0072 edm4hep::Vector3d(),
0073 edm4hep::Vector3f(),
0074 edm4hep::Vector3f(),
0075 edm4hep::Vector3f(),
0076 edm4hep::Vector2i()
0077 );
0078
0079 auto assoc_in = assocs_in->create();
0080 assoc_in.setRec((*parts_in)[0]);
0081 assoc_in.setSim((*mcparts)[0]);
0082
0083 auto parts_out = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0084 auto assocs_out = std::make_unique<edm4eic::MCRecoParticleAssociationCollection>();
0085 auto partids_out = std::make_unique<edm4hep::ParticleIDCollection>();
0086 algo.process({headers.get(), parts_in.get(), assocs_in.get()},
0087 {parts_out.get(), assocs_out.get(), partids_out.get()});
0088
0089 REQUIRE((*parts_in).size() == (*parts_out).size());
0090 REQUIRE((*assocs_in).size() == (*assocs_out).size());
0091 REQUIRE((*partids_out).size() == (*partids_out).size());
0092 }
0093 }