ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
ZDCWaveformSampler Class Reference

#include <ZDCWaveformSampler.h>

Collaboration diagram for ZDCWaveformSampler:

Public Member Functions

 ZDCWaveformSampler (float freqMHz, float timeMin, unsigned int numSamples, unsigned int nBits, unsigned int pedestal, std::shared_ptr< ZDCWaveformBase > waveformPtr)
 
 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)
 
std::vector< unsigned int > Generate (float amplitude)
 
std::vector< unsigned int > Generate (float amplitude, float T0)
 
std::vector< unsigned int > Generate (unsigned int channel, float amplitude, float T0)
 

Private Attributes

float m_timeMin
 
unsigned int m_numSamples
 
unsigned int m_pedestal
 
unsigned int m_numChannels
 
float m_deltaT
 
float m_maxADC
 
bool m_haveDefaultT0
 
float m_defaultT0
 
std::vector< std::shared_ptr< ZDCWaveformBase > > m_waveformChanPtrs
 

Detailed Description

Definition at line 24 of file ZDCWaveformSampler.h.

Constructor & Destructor Documentation

◆ ZDCWaveformSampler() [1/2]

ZDCWaveformSampler::ZDCWaveformSampler ( float  freqMHz,
float  timeMin,
unsigned int  numSamples,
unsigned int  nBits,
unsigned int  pedestal,
std::shared_ptr< ZDCWaveformBase waveformPtr 
)
inline

Definition at line 41 of file ZDCWaveformSampler.h.

42  :
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  {}

◆ ZDCWaveformSampler() [2/2]

ZDCWaveformSampler::ZDCWaveformSampler ( float  freqMHz,
float  timeMin,
unsigned int  numSamples,
unsigned int  nBits,
unsigned int  pedestal,
const std::vector< std::shared_ptr< ZDCWaveformBase > > &  waveformPtrVec 
)
inline

Definition at line 54 of file ZDCWaveformSampler.h.

55  :
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  {}

Member Function Documentation

◆ Generate() [1/3]

std::vector<unsigned int> ZDCWaveformSampler::Generate ( float  amplitude)
inline

Definition at line 72 of file ZDCWaveformSampler.h.

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  }

◆ Generate() [2/3]

std::vector<unsigned int> ZDCWaveformSampler::Generate ( float  amplitude,
float  T0 
)
inline

Definition at line 79 of file ZDCWaveformSampler.h.

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  }

◆ Generate() [3/3]

std::vector< unsigned int > ZDCWaveformSampler::Generate ( unsigned int  channel,
float  amplitude,
float  T0 
)

Definition at line 8 of file ZDCWaveformSampler.cxx.

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 }

◆ SetDefaultT0()

void ZDCWaveformSampler::SetDefaultT0 ( float  T0)
inline

Definition at line 67 of file ZDCWaveformSampler.h.

67  {
68  m_haveDefaultT0 = true;
69  m_defaultT0 = T0;
70  }

Member Data Documentation

◆ m_defaultT0

float ZDCWaveformSampler::m_defaultT0
private

Definition at line 35 of file ZDCWaveformSampler.h.

◆ m_deltaT

float ZDCWaveformSampler::m_deltaT
private

Definition at line 31 of file ZDCWaveformSampler.h.

◆ m_haveDefaultT0

bool ZDCWaveformSampler::m_haveDefaultT0
private

Definition at line 34 of file ZDCWaveformSampler.h.

◆ m_maxADC

float ZDCWaveformSampler::m_maxADC
private

Definition at line 32 of file ZDCWaveformSampler.h.

◆ m_numChannels

unsigned int ZDCWaveformSampler::m_numChannels
private

Definition at line 29 of file ZDCWaveformSampler.h.

◆ m_numSamples

unsigned int ZDCWaveformSampler::m_numSamples
private

Definition at line 27 of file ZDCWaveformSampler.h.

◆ m_pedestal

unsigned int ZDCWaveformSampler::m_pedestal
private

Definition at line 28 of file ZDCWaveformSampler.h.

◆ m_timeMin

float ZDCWaveformSampler::m_timeMin
private

Definition at line 26 of file ZDCWaveformSampler.h.

◆ m_waveformChanPtrs

std::vector<std::shared_ptr<ZDCWaveformBase> > ZDCWaveformSampler::m_waveformChanPtrs
private

Definition at line 37 of file ZDCWaveformSampler.h.


The documentation for this class was generated from the following files:
ZDCWaveformSampler::m_waveformChanPtrs
std::vector< std::shared_ptr< ZDCWaveformBase > > m_waveformChanPtrs
Definition: ZDCWaveformSampler.h:37
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
athena.value
value
Definition: athena.py:124
ZDCWaveformSampler::m_numChannels
unsigned int m_numChannels
Definition: ZDCWaveformSampler.h:29
ZDCWaveformBase::evaluate
double evaluate(double time) const
Definition: ZDCWaveform.h:81
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
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