File indexing completed on 2024-06-29 07:06:06
0001
0002
0003
0004
0005 #include <Evaluator/DD4hepUnits.h> // for MeV, mm, keV, ns
0006 #include <catch2/catch_test_macros.hpp> // for AssertionHandler, operator""_catch_sr, StringRef, REQUIRE, operator<, operator==, operator>, TEST_CASE
0007 #include <edm4eic/CalorimeterHitCollection.h> // for CalorimeterHitCollection, MutableCalorimeterHit, CalorimeterHitMutableCollectionIterator
0008 #include <edm4eic/ClusterCollection.h>
0009 #include <edm4eic/MCRecoClusterParticleAssociationCollection.h>
0010 #include <edm4eic/ProtoClusterCollection.h>
0011 #include <edm4hep/SimCalorimeterHitCollection.h>
0012 #include <edm4hep/Vector3f.h> // for Vector3f
0013 #include <math.h>
0014 #include <podio/RelationRange.h>
0015 #include <spdlog/common.h> // for level_enum
0016 #include <spdlog/logger.h> // for logger
0017 #include <spdlog/spdlog.h> // for default_logger
0018 #include <memory> // for allocator, unique_ptr, make_unique, shared_ptr, __shared_ptr_access
0019 #include <tuple>
0020 #include <vector>
0021
0022 #include "algorithms/calorimetry/CalorimeterClusterRecoCoG.h" // for CalorimeterClusterRecoCoG
0023 #include "algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h" // for CalorimeterClusterRecoCoGConfig
0024
0025 using eicrecon::CalorimeterClusterRecoCoG;
0026 using eicrecon::CalorimeterClusterRecoCoGConfig;
0027
0028 using edm4eic::CalorimeterHit;
0029
0030 TEST_CASE( "the calorimeter CoG algorithm runs", "[CalorimeterClusterRecoCoG]" ) {
0031 CalorimeterClusterRecoCoG algo("CalorimeterClusterRecoCoG");
0032
0033 std::shared_ptr<spdlog::logger> logger = spdlog::default_logger()->clone("CalorimeterClusterRecoCoG");
0034 logger->set_level(spdlog::level::trace);
0035
0036 CalorimeterClusterRecoCoGConfig cfg;
0037 cfg.energyWeight = "log";
0038 cfg.sampFrac = 0.0203,
0039 cfg.logWeightBaseCoeffs={5.0,0.65,0.31},
0040 cfg.logWeightBase_Eref=50*dd4hep::GeV,
0041
0042
0043 algo.applyConfig(cfg);
0044 algo.init();
0045
0046 edm4eic::CalorimeterHitCollection hits_coll;
0047 edm4eic::ProtoClusterCollection pclust_coll;
0048 edm4hep::SimCalorimeterHitCollection simhits;
0049 auto assoc = std::make_unique<edm4eic::MCRecoClusterParticleAssociationCollection>();
0050 auto clust_coll = std::make_unique<edm4eic::ClusterCollection>();
0051
0052
0053 auto pclust = pclust_coll.create();
0054 edm4hep::Vector3f position({0,0,0*dd4hep::mm});
0055
0056 auto hit1 = hits_coll.create();
0057 hit1.setCellID(0);
0058 hit1.setEnergy(0.1*dd4hep::GeV);
0059 hit1.setEnergyError(0);
0060 hit1.setTime(0);
0061 hit1.setTimeError(0);
0062 hit1.setPosition(position);
0063 hit1.setDimension({0,0,0});
0064 hit1.setLocal(position);
0065 pclust.addToHits(hit1);
0066
0067 position={0,0, 1*dd4hep::mm};
0068 auto hit2 = hits_coll.create();
0069 hit2.setCellID(0);
0070 hit2.setEnergy(0.1*dd4hep::GeV);
0071 hit2.setEnergyError(0);
0072 hit2.setTime(0);
0073 hit2.setTimeError(0);
0074 hit2.setPosition(position);
0075 hit2.setDimension({0,0,0});
0076 hit2.setLocal(position);
0077 pclust.addToHits(hit2);
0078
0079 position={0,0, 2*dd4hep::mm};
0080 auto hit3 = hits_coll.create();
0081 hit3.setCellID(0);
0082 hit3.setEnergy(0.1*dd4hep::GeV);
0083 hit3.setEnergyError(0);
0084 hit3.setTime(0);
0085 hit3.setTimeError(0);
0086 hit3.setPosition(position);
0087 hit3.setDimension({0,0,0});
0088 hit3.setLocal(position);
0089 pclust.addToHits(hit3);
0090 pclust.addToWeights(1);pclust.addToWeights(1);pclust.addToWeights(1);
0091
0092
0093 auto input = std::make_tuple(&pclust_coll, &simhits);
0094 auto output = std::make_tuple(clust_coll.get(), assoc.get());
0095
0096 algo.process(input, output);
0097
0098
0099 for (auto clust : *clust_coll){
0100
0101 REQUIRE(clust.getShapeParameters()[7] == 0);
0102 REQUIRE(clust.getShapeParameters()[8] == 0);
0103 REQUIRE(abs(clust.getShapeParameters()[9]) == 1);
0104 }
0105
0106
0107 }