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

Helper class to accumulate calibration triggers. More...

#include <LArCalibTriggerAccumulator.h>

Collaboration diagram for LArCalibTriggerAccumulator:

Public Types

enum  ERRTYPE { NoError =0, WrongNSamples, NumericOverflow }
 

Public Member Functions

 LArCalibTriggerAccumulator ()
 
 LArCalibTriggerAccumulator (const std::vector< uint64_t > &sampleSum, const std::vector< uint64_t > &sample2Sum, uint32_t m_nTrigger)
 
uint32_t nTriggers () const
 return the number of triggers More...
 
size_t nsamples () const
 return number of samples More...
 
const std::vector< uint64_t > & sampleSum () const
 return a reference to a stl vector containing the sample-sums More...
 
const std::vector< uint64_t > & sample2Sum () const
 return a reference to a stl vector containing the sum of the squares of the sample
More...
 
ERRTYPE add (const std::vector< short > &digits)
 accumulated individual set of digits. More...
 
template<class INTTYPE >
ERRTYPE add (const std::vector< INTTYPE > &sampleSum, const std::vector< INTTYPE > &sample2Sum, const uint32_t nTrigger)
 accumulated pre-accumulated digits. More...
 
std::vector< float > mean () const
 Calculates and returns the Mean value of each ADC sample. More...
 
std::vector< float > RMS () const
 Calculates and returns the RMS value of each ADC sample. More...
 
double mean (const size_t i) const
 Calculates and returns the Mean value for one ADC sample. More...
 
double RMS (const size_t i) const
 Calculates and returns the RMS value for one ADC sample. More...
 

Private Attributes

std::vector< uint64_t > m_sampleSum
 sum of samples
More...
 
std::vector< uint64_t > m_sample2Sum
 sum of squares of samples More...
 
uint32_t m_nTrigger
 number of triggers More...
 

Detailed Description

Helper class to accumulate calibration triggers.

Contains sum of ADC counts and the sum of the squares of ADC counts So far only used by the Ramp builder. Could be used for Delay runs

Author
Walter Lampl

Definition at line 30 of file LArCalibTriggerAccumulator.h.

Member Enumeration Documentation

◆ ERRTYPE

Enumerator
NoError 
WrongNSamples 
NumericOverflow 

Definition at line 46 of file LArCalibTriggerAccumulator.h.

46  {
47  NoError=0,
50  };

Constructor & Destructor Documentation

◆ LArCalibTriggerAccumulator() [1/2]

LArCalibTriggerAccumulator::LArCalibTriggerAccumulator ( )

Definition at line 8 of file LArCalibTriggerAccumulator.cxx.

8 : m_nTrigger(0) {}

◆ LArCalibTriggerAccumulator() [2/2]

LArCalibTriggerAccumulator::LArCalibTriggerAccumulator ( const std::vector< uint64_t > &  sampleSum,
const std::vector< uint64_t > &  sample2Sum,
uint32_t  m_nTrigger 
)

Definition at line 10 of file LArCalibTriggerAccumulator.cxx.

12  :

Member Function Documentation

◆ add() [1/2]

template<class INTTYPE >
LArCalibTriggerAccumulator::ERRTYPE LArCalibTriggerAccumulator::add ( const std::vector< INTTYPE > &  sampleSum,
const std::vector< INTTYPE > &  sample2Sum,
const uint32_t  nTrigger 
)

accumulated pre-accumulated digits.

Templated to allow 32 and 64 bit ints as input. Can return an error

Definition at line 97 of file LArCalibTriggerAccumulator.h.

98  {
99  const size_t nS=sampleSum.size();
100  if (m_sampleSum.size()==0 && m_sample2Sum.size()==0) {
101  m_sampleSum.resize(nS);
102  m_sample2Sum.resize(nS);
103  }
104  else if (m_sampleSum.size()!=nS || m_sample2Sum.size()!=nS || sample2Sum.size()!=nS)
105  return WrongNSamples; //ERROR: Inconsistent number of samples
106 
107  for (size_t i=0;i<nS;++i) {
109  //ERROR: Numeric overflow!
110  //Roll back changes:
111  for (size_t j=0;j<i;++j) {
112  m_sampleSum[j]-=sampleSum[j];
113  m_sample2Sum[j]-=sample2Sum[j];
114  }
115  return NumericOverflow;
116  }
119  }
120  m_nTrigger+=nTrigger;
121 
122  return NoError;
123 }

◆ add() [2/2]

LArCalibTriggerAccumulator::ERRTYPE LArCalibTriggerAccumulator::add ( const std::vector< short > &  digits)

accumulated individual set of digits.

Can return an error

Definition at line 17 of file LArCalibTriggerAccumulator.cxx.

17  {
18  const size_t nS=digits.size();
19  if (nS==0) return WrongNSamples;
20 
21  if (m_sampleSum.empty() && m_sample2Sum.empty()) {
22  m_sampleSum.resize(nS);
23  m_sample2Sum.resize(nS);
24  }
25  else if (m_sampleSum.size()!=nS || m_sample2Sum.size()!=nS)
26  return WrongNSamples; //Inconsistent number of samples
27 
28  for (size_t i=0;i<nS;++i) {
29  const uint32_t& dg=digits[i];
31  //ERROR: Numeric overflow
32  //Roll back changes:
33  for (size_t j=0;j<i;++j) {
34  m_sampleSum[j]-=digits[j];
35  m_sample2Sum[j]-=digits[j]*digits[j];
36  }
37  return NumericOverflow;
38  }
39 
40  m_sampleSum[i]+=dg;
41  m_sample2Sum[i]+=dg*dg;
42  }
43  ++m_nTrigger;
44  return NoError;
45 }

◆ mean() [1/2]

std::vector< float > LArCalibTriggerAccumulator::mean ( ) const

Calculates and returns the Mean value of each ADC sample.

Definition at line 68 of file LArCalibTriggerAccumulator.cxx.

68  {
69 
70  const size_t nS=m_sampleSum.size();
71  std::vector<float> mean;
72  if (m_nTrigger==0)
73  return mean;
74  else {
75  mean.resize(nS,0.0);
76  for (size_t i=0;i<nS;++i)
77  mean[i]=((double)m_sampleSum[i])/((double)m_nTrigger);
78  return mean;
79  }
80 }

◆ mean() [2/2]

double LArCalibTriggerAccumulator::mean ( const size_t  i) const

Calculates and returns the Mean value for one ADC sample.

Definition at line 49 of file LArCalibTriggerAccumulator.cxx.

49  {
50 
51  if (i<m_sampleSum.size() && i<m_sample2Sum.size() && m_nTrigger>0)
52  return ((double)m_sampleSum[i])/((double)m_nTrigger);
53  else
54  return 0.0;
55 }

◆ nsamples()

size_t LArCalibTriggerAccumulator::nsamples ( ) const
inline

return number of samples

Definition at line 63 of file LArCalibTriggerAccumulator.h.

63 {return m_sampleSum.size();}

◆ nTriggers()

uint32_t LArCalibTriggerAccumulator::nTriggers ( ) const
inline

return the number of triggers

Definition at line 60 of file LArCalibTriggerAccumulator.h.

60 {return m_nTrigger;}

◆ RMS() [1/2]

std::vector< float > LArCalibTriggerAccumulator::RMS ( ) const

Calculates and returns the RMS value of each ADC sample.

Definition at line 82 of file LArCalibTriggerAccumulator.cxx.

82  {
83  std::vector<float> rms;
84  const size_t nS=m_sampleSum.size();
85  if (m_sample2Sum.size()!=nS || m_nTrigger==0)
86  return rms;// ERROR, return emtpy vector
87 
88  double mean;
89  rms.resize(nS,0.0);
90 
91  for (size_t i=0;i<nS;++i) {
93  rms[i]=sqrt(((double)m_sample2Sum[i])/((double)m_nTrigger)-mean*mean);
94  }
95  return rms;
96 }

◆ RMS() [2/2]

double LArCalibTriggerAccumulator::RMS ( const size_t  i) const

Calculates and returns the RMS value for one ADC sample.

Definition at line 57 of file LArCalibTriggerAccumulator.cxx.

57  {
58 
59  if (i<m_sampleSum.size() && i<m_sample2Sum.size() && m_nTrigger>0) {
60  const double mean=((double)m_sampleSum[i])/((double)m_nTrigger);
61  return sqrt(((double)m_sample2Sum[i])/((double)m_nTrigger)-mean*mean);
62  }
63  else
64  return 0.0;
65 }

◆ sample2Sum()

const std::vector< uint64_t >& LArCalibTriggerAccumulator::sample2Sum ( ) const
inline

return a reference to a stl vector containing the sum of the squares of the sample

Definition at line 69 of file LArCalibTriggerAccumulator.h.

69 { return m_sample2Sum; }

◆ sampleSum()

const std::vector< uint64_t >& LArCalibTriggerAccumulator::sampleSum ( ) const
inline

return a reference to a stl vector containing the sample-sums

Definition at line 66 of file LArCalibTriggerAccumulator.h.

66 { return m_sampleSum; }

Member Data Documentation

◆ m_nTrigger

uint32_t LArCalibTriggerAccumulator::m_nTrigger
private

number of triggers

Definition at line 41 of file LArCalibTriggerAccumulator.h.

◆ m_sample2Sum

std::vector<uint64_t> LArCalibTriggerAccumulator::m_sample2Sum
private

sum of squares of samples

Definition at line 38 of file LArCalibTriggerAccumulator.h.

◆ m_sampleSum

std::vector<uint64_t> LArCalibTriggerAccumulator::m_sampleSum
private

sum of samples

Definition at line 35 of file LArCalibTriggerAccumulator.h.


The documentation for this class was generated from the following files:
max
#define max(a, b)
Definition: cfImp.cxx:41
checkCoolLatestUpdate.dg
dg
Definition: checkCoolLatestUpdate.py:9
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
LArCalibTriggerAccumulator::m_sample2Sum
std::vector< uint64_t > m_sample2Sum
sum of squares of samples
Definition: LArCalibTriggerAccumulator.h:38
LArCalibTriggerAccumulator::NumericOverflow
@ NumericOverflow
Definition: LArCalibTriggerAccumulator.h:49
LArCalibTriggerAccumulator::mean
std::vector< float > mean() const
Calculates and returns the Mean value of each ADC sample.
Definition: LArCalibTriggerAccumulator.cxx:68
LArCalibTriggerAccumulator::m_sampleSum
std::vector< uint64_t > m_sampleSum
sum of samples
Definition: LArCalibTriggerAccumulator.h:35
LArCalibTriggerAccumulator::sample2Sum
const std::vector< uint64_t > & sample2Sum() const
return a reference to a stl vector containing the sum of the squares of the sample
Definition: LArCalibTriggerAccumulator.h:69
LArCalibTriggerAccumulator::sampleSum
const std::vector< uint64_t > & sampleSum() const
return a reference to a stl vector containing the sample-sums
Definition: LArCalibTriggerAccumulator.h:66
LArCalibTriggerAccumulator::m_nTrigger
uint32_t m_nTrigger
number of triggers
Definition: LArCalibTriggerAccumulator.h:41
LArCalibTriggerAccumulator::NoError
@ NoError
Definition: LArCalibTriggerAccumulator.h:47
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
LArCalibTriggerAccumulator::WrongNSamples
@ WrongNSamples
Definition: LArCalibTriggerAccumulator.h:48