Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-04 08:02:14

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 #include <podio/RelationRange.h>
0008 #include <gsl/pointers>
0009 
0010 #include "PulseNoise.h"
0011 
0012 namespace eicrecon {
0013 
0014 void PulseNoise::init() {
0015     m_noise    = dd4hep::detail::FalphaNoise(m_cfg.poles, m_cfg.variance, m_cfg.alpha);
0016 }
0017 
0018 void PulseNoise::process(const PulseNoise::Input& input,
0019                          const PulseNoise::Output& output) {
0020   const auto [inPulses] = input;
0021   auto [outPulses]     = output;
0022 
0023   for (const auto& pulse : *inPulses) {
0024 
0025     //Clone input pulse to a mutable output pulse
0026     auto out_pulse = outPulses->create();
0027     out_pulse.setCellID  (pulse.getCellID());
0028     out_pulse.setInterval(pulse.getInterval());
0029     out_pulse.setTime    (pulse.getTime());
0030 
0031     //Add noise to the pulse
0032     for (int i = 0; i < pulse.getAmplitude().size(); i++) {
0033       double noise = m_noise(generator)*m_cfg.scale;
0034       out_pulse.addToAmplitude(pulse.getAmplitude()[i] + noise);
0035     }
0036 
0037   }
0038 
0039 } // PulseNoise:process
0040 } // namespace eicrecon