ATLAS Offline Software
Loading...
Searching...
No Matches
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>
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
36
37 std::vector<std::shared_ptr<ZDCWaveformBase> > m_waveformChanPtrs;
38
39public:
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),
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
std::vector< unsigned int > Generate(float amplitude, float T0)
std::vector< unsigned int > Generate(float amplitude)
ZDCWaveformSampler(float freqMHz, float timeMin, unsigned int numSamples, unsigned int nBits, unsigned int pedestal, const std::vector< std::shared_ptr< ZDCWaveformBase > > &waveformPtrVec)
void SetDefaultT0(float T0)
ZDCWaveformSampler(float freqMHz, float timeMin, unsigned int numSamples, unsigned int nBits, unsigned int pedestal, std::shared_ptr< ZDCWaveformBase > waveformPtr)
std::vector< std::shared_ptr< ZDCWaveformBase > > m_waveformChanPtrs