ATLAS Offline Software
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 
8 std::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 }
ZDCWaveformSampler::m_waveformChanPtrs
std::vector< std::shared_ptr< ZDCWaveformBase > > m_waveformChanPtrs
Definition: ZDCWaveformSampler.h:37
max
#define max(a, b)
Definition: cfImp.cxx:41
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
athena.value
value
Definition: athena.py:124
ZDCWaveformSampler.h
ZDCWaveformBase::evaluate
double evaluate(double time) const
Definition: ZDCWaveform.h:81
ZDCWaveformSampler::m_maxADC
float m_maxADC
Definition: ZDCWaveformSampler.h:32
ZDCWaveformSampler::m_numSamples
unsigned int m_numSamples
Definition: ZDCWaveformSampler.h:27
ZDCWaveformSampler::Generate
std::vector< unsigned int > Generate(float amplitude)
Definition: ZDCWaveformSampler.h:72
min
#define min(a, b)
Definition: cfImp.cxx:40
ZDCWaveformSampler::m_pedestal
unsigned int m_pedestal
Definition: ZDCWaveformSampler.h:28
ZDCWaveformSampler::m_timeMin
float m_timeMin
Definition: ZDCWaveformSampler.h:26
ZDCWaveformBase
Definition: ZDCWaveform.h:31
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ZDCWaveformSampler::m_deltaT
float m_deltaT
Definition: ZDCWaveformSampler.h:31