File indexing completed on 2025-04-03 08:49:41
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <DDRec/CellIDPositionConverter.h>
0011 #include <RtypesCore.h>
0012 #include <TMath.h>
0013 #include <algorithms/algorithm.h>
0014 #include <edm4hep/RawTimeSeriesCollection.h>
0015 #include <edm4hep/SimTrackerHitCollection.h>
0016 #include <memory>
0017 #include <string>
0018 #include <string_view>
0019 #include <unordered_map>
0020 #include <vector>
0021
0022 #include "algorithms/digi/LGADPulseGenerationConfig.h"
0023 #include "algorithms/interfaces/WithPodConfig.h"
0024
0025 namespace eicrecon {
0026
0027 using LGADPulseGenerationAlgorithm =
0028 algorithms::Algorithm<algorithms::Input<edm4hep::SimTrackerHitCollection>,
0029 algorithms::Output<edm4hep::RawTimeSeriesCollection>>;
0030
0031 class LGADPulseGeneration : public LGADPulseGenerationAlgorithm,
0032 public WithPodConfig<LGADPulseGenerationConfig> {
0033
0034 typedef std::unordered_map<dd4hep::rec::CellID, std::unordered_map<int, std::vector<double>>> AdcArray;
0035
0036 public:
0037 LGADPulseGeneration(std::string_view name)
0038 : LGADPulseGenerationAlgorithm{name, {"RawHits"}, {"OutputPulses"}, {}} {}
0039 virtual void init() final;
0040 void process(const Input&, const Output&) const final;
0041
0042 private:
0043 class PulseShape {
0044 public:
0045
0046
0047
0048 virtual double Eval(double time, double hit_time, double charge) = 0;
0049 virtual ~PulseShape() {};
0050 };
0051
0052
0053 class LandauPulse : public PulseShape {
0054 public:
0055 LandauPulse(double gain, double Vm, double sigma_analog, double adc_range) {
0056 m_gain = gain;
0057 m_sigma_analog = sigma_analog;
0058
0059
0060
0061
0062 const double x_when_landau_min = -0.22278;
0063 const double landau_min = -gain * TMath::Landau(x_when_landau_min, 0, 1, kTRUE) / m_sigma_analog;
0064 m_scalingFactor = 1. / Vm / landau_min * adc_range;
0065 }
0066 double Eval(double time, double hit_time, double charge) {
0067 return charge * m_gain * TMath::Landau(time, hit_time, m_sigma_analog, kTRUE) * m_scalingFactor;
0068 }
0069 private:
0070 double m_gain;
0071 double m_sigma_analog;
0072 double m_scalingFactor;
0073 };
0074
0075 double _Landau(double amp, double x, double mean, double std) const;
0076 void _FillADCArray(AdcArray& adc_sum, double charge, double mpv_analog,
0077 int n_EICROC_cycle, dd4hep::rec::CellID cellID) const;
0078 std::unique_ptr<PulseShape> m_pulse;
0079 };
0080
0081 }