Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-29 07:06:06

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2023, Dmitry Kalinkin
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}, // lower, upper, step
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, // std::int32_t type
0051       0.5, // float energy
0052       edm4hep::Vector3f({0.5, 0., 0.}), // edm4hep::Vector3f momentum
0053       edm4hep::Vector3f({0., 0., 0.}), // edm4hep::Vector3f referencePoint
0054       1., // float charge
0055       0., // float mass
0056       0., // float goodnessOfPID
0057       edm4eic::Cov4f(), // edm4eic::Cov4f covMatrix
0058       0 // std::int32_t PDG
0059     );
0060     mcparts->create(
0061       11, // std::int32_t PDG
0062       0, // std::int32_t generatorStatus
0063       0, // std::int32_t simulatorStatus
0064       0., // float charge
0065       0., // float time
0066       0., // double mass
0067       edm4hep::Vector3d(), // edm4hep::Vector3d vertex
0068       edm4hep::Vector3d(), // edm4hep::Vector3d endpoint
0069       edm4hep::Vector3f(), // edm4hep::Vector3f momentum
0070       edm4hep::Vector3f(), // edm4hep::Vector3f momentumAtEndpoint
0071       edm4hep::Vector3f(), // edm4hep::Vector3f spin
0072       edm4hep::Vector2i() // edm4hep::Vector2i colorFlow
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 }