ATLAS Offline Software
ZDCWaveformSampler.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ZDCUTILS_ZDCWAVEFORMSAMPLER_H
6 #define ZDCUTILS_ZDCWAVEFORMSAMPLER_H
7 
8 // Class that provides the ability to "sample" waveforms -- i.e. generate the analog
9 // of Flash ADC samples -- at a specified frequency. The time at which the pulse is generated
10 // can either be fixed or provided "event"-by-event. The amplitude must be provided for each
11 // event as the Waveform has, by construction (pun intended), unity amplitude.
12 //
13 // A valid waveform pointer must be provided at construction, but it can also be changed.
14 //
15 // The sampler can operate with multiple channels, in which case multiple waveform objects
16 // must be provided
17 //
18 //
19 
20 #include <vector>
21 #include <memory>
22 #include "ZdcUtils/ZDCWaveform.h"
23 
25 {
26  float m_timeMin;
27  unsigned int m_numSamples;
28  unsigned int m_pedestal;
29  unsigned int m_numChannels;
30 
31  float m_deltaT;
32  float m_maxADC;
33 
35  float m_defaultT0;
36 
37  std::vector<std::shared_ptr<ZDCWaveformBase> > m_waveformChanPtrs;
38 
39 public:
40 
41  ZDCWaveformSampler(float freqMHz, float timeMin, unsigned int numSamples, unsigned int nBits, unsigned int pedestal,
42  std::shared_ptr<ZDCWaveformBase> waveformPtr) :
43  m_timeMin(timeMin),
44  m_numSamples(numSamples),
45  m_pedestal(pedestal),
46  m_numChannels(1),
47  m_deltaT(1000./freqMHz),
48  m_maxADC((1<<nBits) - 1),
49  m_haveDefaultT0(false),
50  m_defaultT0(0.),
51  m_waveformChanPtrs(1, waveformPtr)
52  {}
53 
54  ZDCWaveformSampler(float freqMHz, float timeMin, unsigned int numSamples, unsigned int nBits, unsigned int pedestal,
55  const std::vector<std::shared_ptr<ZDCWaveformBase> >& waveformPtrVec) :
56  m_timeMin(timeMin),
57  m_numSamples(numSamples),
58  m_pedestal(pedestal),
59  m_numChannels(waveformPtrVec.size()),
60  m_deltaT(1000./freqMHz),
61  m_maxADC((1<<nBits) - 1),
62  m_haveDefaultT0(false),
63  m_defaultT0(0.),
64  m_waveformChanPtrs(waveformPtrVec)
65  {}
66 
67  void SetDefaultT0(float T0) {
68  m_haveDefaultT0 = true;
69  m_defaultT0 = T0;
70  }
71 
72  std::vector<unsigned int> Generate(float amplitude)
73  {
74  if (m_numChannels != 1) throw std::runtime_error("ZDCWaveformSampler::Generate called with one parameter on an object with multiple channels.");
75  if (!m_haveDefaultT0) throw std::runtime_error("ZDCWaveformSampler::Generate called with no default t0.");
76  return Generate(amplitude, m_defaultT0);
77  }
78 
79  std::vector<unsigned int> Generate(float amplitude, float T0)
80  {
81  if (m_numChannels != 1) throw std::runtime_error("ZDCWaveformSampler::Generate called with one parameter on an object with multiple channels.");
82  return Generate(0, amplitude, T0);
83  }
84 
85  std::vector<unsigned int> Generate(unsigned int channel, float amplitude, float T0);
86 };
87 
88 #endif
ZDCWaveform.h
ZDCWaveformSampler::m_waveformChanPtrs
std::vector< std::shared_ptr< ZDCWaveformBase > > m_waveformChanPtrs
Definition: ZDCWaveformSampler.h:37
ZDCWaveformSampler::SetDefaultT0
void SetDefaultT0(float T0)
Definition: ZDCWaveformSampler.h:67
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
ZDCWaveformSampler
Definition: ZDCWaveformSampler.h:25
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
ZDCWaveformSampler::m_numChannels
unsigned int m_numChannels
Definition: ZDCWaveformSampler.h:29
ZDCWaveformSampler::ZDCWaveformSampler
ZDCWaveformSampler(float freqMHz, float timeMin, unsigned int numSamples, unsigned int nBits, unsigned int pedestal, const std::vector< std::shared_ptr< ZDCWaveformBase > > &waveformPtrVec)
Definition: ZDCWaveformSampler.h:54
ZDCWaveformSampler::m_defaultT0
float m_defaultT0
Definition: ZDCWaveformSampler.h:35
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
ZDCWaveformSampler::m_pedestal
unsigned int m_pedestal
Definition: ZDCWaveformSampler.h:28
ZDCWaveformSampler::m_timeMin
float m_timeMin
Definition: ZDCWaveformSampler.h:26
ZDCWaveformSampler::m_haveDefaultT0
bool m_haveDefaultT0
Definition: ZDCWaveformSampler.h:34
ZDCWaveformSampler::m_deltaT
float m_deltaT
Definition: ZDCWaveformSampler.h:31
ZDCWaveformSampler::ZDCWaveformSampler
ZDCWaveformSampler(float freqMHz, float timeMin, unsigned int numSamples, unsigned int nBits, unsigned int pedestal, std::shared_ptr< ZDCWaveformBase > waveformPtr)
Definition: ZDCWaveformSampler.h:41
ZDCWaveformSampler::Generate
std::vector< unsigned int > Generate(float amplitude, float T0)
Definition: ZDCWaveformSampler.h:79