File indexing completed on 2025-09-14 08:15:50
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <algorithms/algorithm.h>
0010 #include <edm4eic/EDM4eicVersion.h>
0011 #include <edm4eic/unit_system.h>
0012 #include <edm4hep/SimCalorimeterHitCollection.h>
0013 #include <edm4hep/SimTrackerHitCollection.h>
0014 #if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1)
0015 #include <edm4eic/SimPulseCollection.h>
0016 #else
0017 #include <edm4hep/TimeSeriesCollection.h>
0018 #endif
0019 #include <memory>
0020 #include <string_view>
0021 #include <tuple>
0022 #include <variant>
0023
0024 #include "algorithms/digi/PulseGenerationConfig.h"
0025 #include "algorithms/interfaces/WithPodConfig.h"
0026
0027 namespace eicrecon {
0028
0029 #if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1)
0030 using PulseType = edm4eic::SimPulse;
0031 using MutablePulseType = edm4eic::MutableSimPulse;
0032 #else
0033 using PulseType = edm4hep::TimeSeries;
0034 using MutablePulseType = edm4hep::MutableTimeSeries;
0035 #endif
0036
0037 template <typename HitT> struct HitAdapter;
0038
0039 template <> struct HitAdapter<edm4hep::SimTrackerHit> {
0040 static std::tuple<double, double> getPulseSources(const edm4hep::SimTrackerHit& hit);
0041 #if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1)
0042 static void addRelations(MutablePulseType& pulse, const edm4hep::SimTrackerHit& hit);
0043 #endif
0044 };
0045
0046 template <> struct HitAdapter<edm4hep::SimCalorimeterHit> {
0047 static std::tuple<double, double> getPulseSources(const edm4hep::SimCalorimeterHit& hit);
0048 #if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1)
0049 static void addRelations(MutablePulseType& pulse, const edm4hep::SimCalorimeterHit& hit);
0050 #endif
0051 };
0052
0053 template <typename HitT>
0054 using PulseGenerationAlgorithm =
0055 algorithms::Algorithm<algorithms::Input<typename HitT::collection_type>,
0056 algorithms::Output<PulseType::collection_type>>;
0057
0058 class SignalPulse;
0059
0060 template <typename HitT>
0061 class PulseGeneration : public PulseGenerationAlgorithm<HitT>,
0062 public WithPodConfig<PulseGenerationConfig> {
0063
0064 public:
0065 PulseGeneration(std::string_view name)
0066 : PulseGenerationAlgorithm<HitT>{name, {"RawHits"}, {"OutputPulses"}, {}} {}
0067 void init() final;
0068 void process(const typename PulseGenerationAlgorithm<HitT>::Input&,
0069 const typename PulseGenerationAlgorithm<HitT>::Output&) const final;
0070
0071 private:
0072 std::shared_ptr<SignalPulse> m_pulse;
0073 float m_min_sampling_time = 0 * edm4eic::unit::ns;
0074 };
0075
0076 }