File indexing completed on 2026-04-17 07:50:43
0001
0002
0003
0004 #include <catch2/catch_test_macros.hpp>
0005 #include <edm4eic/EDM4eicVersion.h>
0006 #include <podio/RelationRange.h>
0007 #include <stdint.h>
0008 #include <cstddef>
0009 #include <memory>
0010
0011 #if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 7)
0012 #include <edm4eic/RawCALOROCHitCollection.h>
0013 #include <edm4eic/CALOROC1ASample.h>
0014 #include <edm4eic/SimPulseCollection.h>
0015 #include <edm4eic/unit_system.h>
0016 #include <tuple>
0017
0018 #include "algorithms/digi/CALOROCDigitization.h"
0019 #include "algorithms/digi/CALOROCDigitizationConfig.h"
0020
0021 TEST_CASE("Test TOA calculation", "[CALOROCDigitization][TOACalculation]") {
0022
0023
0024
0025
0026
0027 eicrecon::CALOROCDigitization algo("CALOROCDigitization");
0028 eicrecon::CALOROCDigitizationConfig cfg;
0029
0030 cfg.n_samples = 2;
0031 cfg.time_window = 25 * edm4eic::unit::ns;
0032 cfg.adc_phase = 0 * edm4eic::unit::ns;
0033 cfg.toa_thres = 1.;
0034 cfg.tot_thres = 1.;
0035
0036 cfg.capADC = 25;
0037 cfg.dyRangeSingleGainADC = 25.;
0038 cfg.dyRangeHighGainADC = 25.;
0039 cfg.dyRangeLowGainADC = 25.;
0040 cfg.capTOA = 25.;
0041 cfg.dyRangeTOA = 25;
0042 cfg.capTOT = 25.;
0043 cfg.dyRangeTOT = 25;
0044
0045 algo.applyConfig(cfg);
0046 algo.init();
0047
0048 const std::size_t n_tests = 23;
0049 const std::size_t n_amps = 3;
0050 const double pulse_dt = 1.;
0051
0052 for (std::size_t i = 0; i < n_tests; i++) {
0053 uint16_t TOA_expected = 23 - i;
0054
0055 edm4eic::SimPulseCollection pulses;
0056 auto pulse = pulses.create();
0057 for (std::size_t j = 0; j < n_amps; j++) {
0058 pulse.addToAmplitude(j);
0059 }
0060 pulse.setCellID(12345);
0061 pulse.setTime(i + 1);
0062 pulse.setInterval(pulse_dt);
0063 pulse.setIntegral(2);
0064
0065 auto digi_hits = std::make_unique<edm4eic::RawCALOROCHitCollection>();
0066
0067 auto input = std::make_tuple(&pulses);
0068 auto output = std::make_tuple(digi_hits.get());
0069
0070 algo.process(input, output);
0071
0072 REQUIRE(digi_hits->size() == 1);
0073 auto a_samples = (*digi_hits)[0].getASamples();
0074 REQUIRE(a_samples[0].timeOfArrival == TOA_expected);
0075 }
0076 }
0077 #endif