Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-12 08:47:50

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2025 Simon Gardner
0003 //
0004 // Adds noise to a time series pulse
0005 //
0006 
0007 #pragma once
0008 
0009 #include <DDDigi/noise/FalphaNoise.h>
0010 #include <algorithms/algorithm.h>
0011 #include <edm4eic/EDM4eicVersion.h>
0012 #if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1)
0013 #include <edm4eic/SimPulseCollection.h>
0014 #else
0015 #include <edm4hep/TimeSeriesCollection.h>
0016 #endif
0017 #include <random>
0018 #include <string>
0019 #include <string_view>
0020 
0021 #include "algorithms/digi/PulseNoiseConfig.h"
0022 #include "algorithms/interfaces/WithPodConfig.h"
0023 
0024 namespace eicrecon {
0025 
0026 #if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1)
0027 using PulseType = edm4eic::SimPulse;
0028 #else
0029 using PulseType = edm4hep::TimeSeries;
0030 #endif
0031 
0032 using PulseNoiseAlgorithm = algorithms::Algorithm<algorithms::Input<PulseType::collection_type>,
0033                                                   algorithms::Output<PulseType::collection_type>>;
0034 
0035 class PulseNoise : public PulseNoiseAlgorithm, public WithPodConfig<PulseNoiseConfig> {
0036 
0037 public:
0038   PulseNoise(std::string_view name)
0039       : PulseNoiseAlgorithm{name, {"RawHits"}, {"OutputPulses"}, {}} {}
0040   virtual void init() final;
0041   void process(const Input&, const Output&) const;
0042 
0043 private:
0044   mutable std::default_random_engine m_generator; // TODO: need something more appropriate here
0045   mutable dd4hep::detail::FalphaNoise m_noise;    // FalphaNoise::operator() is not const
0046 };
0047 
0048 } // namespace eicrecon