File indexing completed on 2024-09-27 07:03:08
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/MCParticleCollection.h>
0010 #include <edm4hep/ParticleIDCollection.h>
0011 #include <edm4hep/Vector2i.h>
0012 #include <edm4hep/Vector3d.h>
0013 #include <edm4hep/Vector3f.h>
0014 #include <math.h>
0015 #include <spdlog/common.h>
0016 #include <memory>
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=0xFF,
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(
0050 0,
0051 0.5,
0052 edm4hep::Vector3f({0.5, 0., 0.}),
0053 edm4hep::Vector3f({0., 0., 0.}),
0054 1.,
0055 0.,
0056 0.,
0057 edm4eic::Cov4f(),
0058 0
0059 );
0060 mcparts->create(
0061 11,
0062 0,
0063 0,
0064 0.,
0065 0.,
0066 0.,
0067 edm4hep::Vector3d(),
0068 edm4hep::Vector3d(),
0069 edm4hep::Vector3f(),
0070 edm4hep::Vector3f(),
0071 edm4hep::Vector3f(),
0072 edm4hep::Vector2i()
0073 );
0074
0075 auto assoc_in = assocs_in->create();
0076 assoc_in.setRec((*parts_in)[0]);
0077 assoc_in.setSim((*mcparts)[0]);
0078
0079 auto parts_out = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0080 auto assocs_out = std::make_unique<edm4eic::MCRecoParticleAssociationCollection>();
0081 auto partids_out = std::make_unique<edm4hep::ParticleIDCollection>();
0082 algo.process({parts_in.get(), assocs_in.get()}, {parts_out.get(), assocs_out.get(), partids_out.get()});
0083
0084 REQUIRE( (*parts_in).size() == (*parts_out).size() );
0085 REQUIRE( (*assocs_in).size() == (*assocs_out).size() );
0086 REQUIRE( (*partids_out).size() == (*partids_out).size() );
0087 }
0088 }