ATLAS Offline Software
Loading...
Searching...
No Matches
ZDCWaveformSampler.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <algorithm>
7
8std::vector<unsigned int> ZDCWaveformSampler::Generate(unsigned int channel, float amplitude, float T0)
9{
10 std::vector<unsigned int> samples;
11 const ZDCWaveformBase* waveformPtr = m_waveformChanPtrs.at(channel).get();
12
13 //
14 // We loop over the requested number of samples
15 //
16 float time = m_timeMin;
17
18 for (unsigned int isample = 0; isample < m_numSamples; isample++) {
19 //
20 // The waveform generates a shape with unit amplitude with maximum at t = 0
21 // we shift the evaluation to account for the actual T0
22 //
23 float valueUnitNorm = waveformPtr->evaluate(time - T0);
24
25 // Now we scale up by the amplitue
26 //
27 float value = std::floor(valueUnitNorm*amplitude);
28
29 // We apply the pedestal shift and force value > 0
30 //
31 value = std::max(value + m_pedestal, float(0.));
32
33 // Now we truncate at the maximum ADC value
34 //
35 unsigned int valueIntTrunc = std::min(value, m_maxADC);
36 samples.push_back(valueIntTrunc);
37
38 time += m_deltaT;
39 }
40
41 return samples;
42}
double evaluate(double time) const
Definition ZDCWaveform.h:81
std::vector< unsigned int > Generate(float amplitude)
std::vector< std::shared_ptr< ZDCWaveformBase > > m_waveformChanPtrs