Warning, file /EICrecon/src/tests/algorithms_test/calorimetry_ImagingTopoCluster.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #include <DD4hep/Detector.h>
0005 #include <DD4hep/IDDescriptor.h>
0006 #include <DD4hep/Readout.h>
0007 #include <Evaluator/DD4hepUnits.h>
0008 #include <algorithms/geo.h>
0009 #include <catch2/catch_test_macros.hpp>
0010 #include <edm4eic/CalorimeterHitCollection.h>
0011 #include <edm4eic/ProtoClusterCollection.h>
0012 #include <edm4hep/Vector3f.h>
0013 #include <spdlog/common.h>
0014 #include <spdlog/logger.h>
0015 #include <spdlog/spdlog.h>
0016 #include <gsl/pointers>
0017 #include <memory>
0018 #include <string>
0019 #include <utility>
0020 #include <variant>
0021 #include <vector>
0022
0023 #include "algorithms/calorimetry/ImagingTopoCluster.h"
0024 #include "algorithms/calorimetry/ImagingTopoClusterConfig.h"
0025
0026 using eicrecon::ImagingTopoCluster;
0027 using eicrecon::ImagingTopoClusterConfig;
0028
0029 TEST_CASE("the clustering algorithm runs", "[ImagingTopoCluster]") {
0030 ImagingTopoCluster algo("ImagingTopoCluster");
0031
0032 std::shared_ptr<spdlog::logger> logger = spdlog::default_logger()->clone("ImagingTopoCluster");
0033 logger->set_level(spdlog::level::trace);
0034
0035 ImagingTopoClusterConfig cfg;
0036 cfg.sameLayerMode = eicrecon::ImagingTopoClusterConfig::ELayerMode::xy;
0037 cfg.minClusterHitEdep = 0. * dd4hep::GeV;
0038 cfg.minClusterCenterEdep = 0. * dd4hep::GeV;
0039 cfg.sameLayerDistXY = {1.0 * dd4hep::mm, 1.0 * dd4hep::mm};
0040 cfg.diffLayerDistXY = {1.0 * dd4hep::mm, 1.0 * dd4hep::mm};
0041 cfg.minClusterEdep = 9 * dd4hep::MeV;
0042
0043 cfg.minClusterNhits = 1;
0044 auto detector = algorithms::GeoSvc::instance().detector();
0045 auto id_desc = detector->readout("MockCalorimeterHits").idSpec();
0046
0047 SECTION("without splitting") {
0048 algo.applyConfig(cfg);
0049 algo.init();
0050
0051 SECTION("on a single cell") {
0052 edm4eic::CalorimeterHitCollection hits_coll;
0053 hits_coll.create(
0054 id_desc.encode(
0055 {{"system", 255}, {"x", 0}, {"y", 0}, {"layer", 0}}),
0056 5.0,
0057 0.0,
0058 0.0,
0059 0.0,
0060 edm4hep::Vector3f(0.0, 0.0, 0.0),
0061 edm4hep::Vector3f(0.0, 0.0, 0.0),
0062 0,
0063 0,
0064 edm4hep::Vector3f(0.0, 0.0, 0.0)
0065 );
0066 auto protoclust_coll = std::make_unique<edm4eic::ProtoClusterCollection>();
0067 algo.process({&hits_coll}, {protoclust_coll.get()});
0068
0069 REQUIRE((*protoclust_coll).size() == 1);
0070 REQUIRE((*protoclust_coll)[0].hits_size() == 1);
0071 REQUIRE((*protoclust_coll)[0].weights_size() == 1);
0072 }
0073
0074 SECTION("on two separated cells") {
0075 edm4eic::CalorimeterHitCollection hits_coll;
0076 hits_coll.create(
0077 id_desc.encode(
0078 {{"system", 255}, {"x", 0}, {"y", 0}, {"layer", 0}}),
0079 5.0,
0080 0.0,
0081 0.0,
0082 0.0,
0083 edm4hep::Vector3f(0.0, 0.0, 0.0),
0084 edm4hep::Vector3f(1.0, 1.0, 0.0),
0085 0,
0086 0,
0087 edm4hep::Vector3f(0.0, 0.0, 0.0)
0088 );
0089 hits_coll.create(
0090 id_desc.encode(
0091 {{"system", 255}, {"x", 2}, {"y", 2}, {"layer", 0}}),
0092 6.0,
0093 0.0,
0094 0.0,
0095 0.0,
0096 edm4hep::Vector3f(1.1, 1.1, 0.0),
0097 edm4hep::Vector3f(1.0, 1.0, 0.0),
0098 0,
0099 0,
0100 edm4hep::Vector3f(1.1 , 1.1 , 0.0)
0101 );
0102 auto protoclust_coll = std::make_unique<edm4eic::ProtoClusterCollection>();
0103 algo.process({&hits_coll}, {protoclust_coll.get()});
0104
0105 REQUIRE((*protoclust_coll).size() == 2);
0106 REQUIRE((*protoclust_coll)[0].hits_size() == 1);
0107 REQUIRE((*protoclust_coll)[0].weights_size() == 1);
0108 REQUIRE((*protoclust_coll)[1].hits_size() == 1);
0109 REQUIRE((*protoclust_coll)[1].weights_size() == 1);
0110 }
0111
0112 SECTION("on two adjacent cells (same layer)") {
0113 edm4eic::CalorimeterHitCollection hits_coll;
0114 hits_coll.create(
0115 id_desc.encode({{"system", 255}, {"x", 0}, {"y", 0}}),
0116 5.0,
0117 0.0,
0118 0.0,
0119 0.0,
0120 edm4hep::Vector3f(0.0, 0.0, 0.0),
0121 edm4hep::Vector3f(1.0, 1.0, 0.0),
0122 0,
0123 0,
0124 edm4hep::Vector3f(0.0, 0.0, 0.0)
0125 );
0126 hits_coll.create(
0127 id_desc.encode({{"system", 255}, {"x", 1}, {"y", 0}}),
0128 6.0,
0129 0.0,
0130 0.0,
0131 0.0,
0132 edm4hep::Vector3f(0.9, 0.9, 0.0),
0133 edm4hep::Vector3f(1.0, 1.0, 0.0),
0134 0,
0135 0,
0136 edm4hep::Vector3f(0.9 , 0.9 , 0.0)
0137 );
0138 auto protoclust_coll = std::make_unique<edm4eic::ProtoClusterCollection>();
0139 algo.process({&hits_coll}, {protoclust_coll.get()});
0140
0141 REQUIRE((*protoclust_coll).size() == 1);
0142 REQUIRE((*protoclust_coll)[0].hits_size() == 2);
0143 REQUIRE((*protoclust_coll)[0].weights_size() == 2);
0144 }
0145 }
0146
0147 SECTION("run on three cells, two of which are on the same layer, and there is a third one on "
0148 "another layer acting as a bridge between them") {
0149
0150 cfg.sameLayerDistXY = {1 * dd4hep::mm, 1 * dd4hep::mm};
0151 algo.applyConfig(cfg);
0152 algo.init();
0153
0154 edm4eic::CalorimeterHitCollection hits_coll;
0155 hits_coll.create(
0156 id_desc.encode(
0157 {{"system", 255}, {"x", 0}, {"y", 0}, {"layer", 0}}),
0158 5.0,
0159 0.0,
0160 0.0,
0161 0.0,
0162 edm4hep::Vector3f(0.0, 0.0, 0.0),
0163 edm4hep::Vector3f(1.0, 1.0, 0.0),
0164 0,
0165 0,
0166 edm4hep::Vector3f(0.0, 0.0, 0.0)
0167 );
0168 hits_coll.create(
0169 id_desc.encode(
0170 {{"system", 255}, {"x", 1}, {"y", 0}, {"layer", 1}}),
0171 1.0,
0172 0.0,
0173 0.0,
0174 0.0,
0175 edm4hep::Vector3f(0.9, 0.9, 0.0),
0176 edm4hep::Vector3f(1.0, 1.0, 0.0),
0177 0,
0178 1,
0179 edm4hep::Vector3f(0.9 , 0.9 , 0.0)
0180 );
0181 hits_coll.create(
0182 id_desc.encode(
0183 {{"system", 255}, {"x", 2}, {"y", 0}, {"layer", 0}}),
0184 6.0,
0185 0.0,
0186 0.0,
0187 0.0,
0188 edm4hep::Vector3f(1.8, 1.8, 0.0),
0189 edm4hep::Vector3f(1.0, 1.0, 0.0),
0190 0,
0191 0,
0192 edm4hep::Vector3f(1.8 , 1.8 , 0.0)
0193 );
0194 auto protoclust_coll = std::make_unique<edm4eic::ProtoClusterCollection>();
0195 algo.process({&hits_coll}, {protoclust_coll.get()});
0196
0197 REQUIRE((*protoclust_coll).size() == 1);
0198 REQUIRE((*protoclust_coll)[0].hits_size() == 3);
0199 REQUIRE((*protoclust_coll)[0].weights_size() == 3);
0200 }
0201 }