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

Data class for ADC samples and autocorr preprocessed by the DSP. More...

#include <LArAccumulatedDigit.h>

Collaboration diagram for LArAccumulatedDigit:

Public Member Functions

 LArAccumulatedDigit (HWIdentifier &channel_value, CaloGain::CaloGain gain_value, const std::vector< uint64_t > &sampleSum_value, const std::vector< uint64_t > &sampleSquare_value, uint32_t nTrigger_value)
 Constructor (first type) More...
 
 LArAccumulatedDigit (HWIdentifier &channel_value)
 Constructor (second type) More...
 
 ~LArAccumulatedDigit ()=default
 Destructor. More...
 
 LArAccumulatedDigit ()
 default constructor for persistency More...
 
const HWIdentifierhardwareID () const
 Return HWIdentifier. More...
 
const HWIdentifierchannelID () const
 Return channel ID. More...
 
CaloGain::CaloGain gain () const
 return gain value More...
 
int nsample () const
 return number of samples More...
 
const std::vector< uint64_t > & sampleSum () const
 return the sample-sums More...
 
const std::vector< uint64_t > & sampleSquare () const
 return a reference to a stl vector containing the sum of the squares of the sample
More...
 
unsigned nTrigger () const
 return the number of triggers More...
 
float mean (int n_min=-1, int n_max=-1) const
 Calculates and returns the Mean value of ADC samples. More...
 
float RMS (int n_min=-1, int n_max=-1) const
 Calculates and returns the RMS value of ADC samples
More...
 
void getCov (std::vector< float > &cov, int normalize) const
 Compute the autocorrelation elements. More...
 
bool setAddDigit (const std::vector< short > &digit)
 Accumulate single digit. More...
 
bool setAddSubStep (const CaloGain::CaloGain gain_value, const HWIdentifier chid, const std::vector< uint64_t > &sampleSum, const std::vector< uint64_t > &sampleSquare, const unsigned nTrigger)
 Accumulate new values
More...
 
void setAddSubStep (CaloGain::CaloGain gain_value, const std::vector< uint64_t > &sampleSum, const std::vector< uint64_t > &sampleSquare, unsigned nTrigger)
 
void setAddSubStep (CaloGain::CaloGain gain_value, const std::vector< int64_t > &sampleSum, const std::vector< int64_t > &sampleSquare, unsigned nTrigger, int32_t base)
 
bool setAddSubStep (const LArAccumulatedDigit &ad)
 

Private Attributes

HWIdentifier m_hardwareID
 Online Identifier. More...
 
CaloGain::CaloGain m_gain
 gain More...
 
std::vector< uint64_t > m_sampleSum
 sampleSum over ntrigger*nsamples More...
 
std::vector< uint64_t > m_sampleSquare
 vector(index: j from s_i*s_{i+j}) More...
 
uint32_t m_nTrigger
 number of total triggers More...
 

Detailed Description

Data class for ADC samples and autocorr preprocessed by the DSP.

Contains sum of ADC counts and the sum of the s_i*s_{i+j} adc counts plus gain, number of triggers and samples

Author
Remi Lafaye

Modifications: Walter Lampl, 27 Aug 2009: Remove storage of individual substeps. The class represents now exactly one substep or the sum of many substeps.

Definition at line 32 of file LArAccumulatedDigit.h.

Constructor & Destructor Documentation

◆ LArAccumulatedDigit() [1/3]

LArAccumulatedDigit::LArAccumulatedDigit ( HWIdentifier channel_value,
CaloGain::CaloGain  gain_value,
const std::vector< uint64_t > &  sampleSum_value,
const std::vector< uint64_t > &  sampleSquare_value,
uint32_t  nTrigger_value 
)

Constructor (first type)

Definition at line 14 of file LArAccumulatedDigit.cxx.

18  :
19  m_hardwareID(channel_value), m_gain(gain_value), m_nTrigger(nTrigger_value) {
20 
21  const size_t nS=sampleSum_value.size();
22  m_sampleSum.resize(nS);
23  for (size_t i=0;i<nS;++i)
24  m_sampleSum[i]=(uint64_t)sampleSum_value[i];
25 
26 
27  const size_t nSS=sampleSquare_value.size();
28  m_sampleSquare.resize(nSS);
29  for (size_t i=0;i<nSS;++i)
30  m_sampleSquare[i]=(uint64_t)sampleSquare_value[i];
31 }

◆ LArAccumulatedDigit() [2/3]

LArAccumulatedDigit::LArAccumulatedDigit ( HWIdentifier channel_value)

Constructor (second type)

Definition at line 34 of file LArAccumulatedDigit.cxx.

35  : m_hardwareID (channel_value),
37  m_nTrigger (0)
38 {
39 }

◆ ~LArAccumulatedDigit()

LArAccumulatedDigit::~LArAccumulatedDigit ( )
default

Destructor.

◆ LArAccumulatedDigit() [3/3]

LArAccumulatedDigit::LArAccumulatedDigit ( )

default constructor for persistency

Definition at line 10 of file LArAccumulatedDigit.cxx.

10  :
12 {}

Member Function Documentation

◆ channelID()

const HWIdentifier& LArAccumulatedDigit::channelID ( ) const
inline

Return channel ID.

Definition at line 73 of file LArAccumulatedDigit.h.

73 { return m_hardwareID; }

◆ gain()

CaloGain::CaloGain LArAccumulatedDigit::gain ( ) const
inline

return gain value

Definition at line 76 of file LArAccumulatedDigit.h.

76 { return m_gain; }

◆ getCov()

void LArAccumulatedDigit::getCov ( std::vector< float > &  cov,
int  normalize 
) const

Compute the autocorrelation elements.

Definition at line 232 of file LArAccumulatedDigit.cxx.

233 {
234  cov.clear();
235  const double n = m_nTrigger;
236  const size_t nS=m_sampleSum.size();
237  if(n<=0) return;
238  if(m_sampleSquare.size()!=nS) return;
239 
240  std::vector<double> mean2;
241  mean2.resize(nS);
242  for(size_t i=1;i<nS;i++) {
243  for(size_t j=i;j<nS;j++) {
244  mean2[i] += m_sampleSum[j-i]*m_sampleSum[j];
245  }
246  mean2[i]/=n*n*(nS-i);
247  }
248  uint64_t temp_mean = 0;
249  double mean;
250  for(uint32_t i=0;i<nS;i++)
251  temp_mean += m_sampleSum[i];
252  mean = temp_mean/((double) n*nS);
253 
254  if(normalize!=1) { // No mormalization send as is
255  for(size_t i=1;i<nS;i++)
256  cov.push_back( m_sampleSquare[i]/(n*(nS-i)) - mean2[i] );
257  mean2.clear();
258  return;
259  }
260 
261  //Normalize covariance elements if required
262  const double norm = m_sampleSquare[0]/(n*nS)-mean*mean;
263  //norm = sqrt(norm*norm);
264  if (norm==0.0)
265  cov.assign(nS-1,0.0);
266  else {
267  const double inv_norm = 1. / norm;
268  for(uint32_t i=1;i<nS;i++) {
269  cov.push_back((m_sampleSquare[i]/(n*(nS-i)) - mean2[i])*inv_norm);
270  }
271  }
272 
273  mean2.clear();
274 }

◆ hardwareID()

const HWIdentifier& LArAccumulatedDigit::hardwareID ( ) const
inline

Return HWIdentifier.

Definition at line 70 of file LArAccumulatedDigit.h.

70 {return m_hardwareID; }

◆ mean()

float LArAccumulatedDigit::mean ( int  n_min = -1,
int  n_max = -1 
) const

Calculates and returns the Mean value of ADC samples.

Definition at line 41 of file LArAccumulatedDigit.cxx.

41  {
42  //float mean;
43  unsigned imin=0;
44  const size_t nS=m_sampleSum.size();
45  if(nS==0) return 0.;
46  if(n_min>0 && (unsigned)n_min<nS) imin=n_min;
47  unsigned imax=nS-1;
48  if(n_max>0 && n_max>n_min && (unsigned)n_max<nS) imax=n_max;
49 
50  const double n = (imax-imin+1)*m_nTrigger;
51  if(n<=0) return 0;
52  uint64_t x=0;
53  for(size_t i=imin;i<=imax;i++) {
54  //std::cout << "Computing mean: " << x << " += " << m_sampleSum[i] << " [" << i << "] ";
55  x += m_sampleSum[i];
56  //std::cout << " = " << x << std::endl;
57  }
58  //std::cout << x << " /= " << n << std::endl;
59  //mean = x/n;
60  //std::cout << " = " << mean << std::endl;
61  return x/n;
62 }

◆ nsample()

int LArAccumulatedDigit::nsample ( ) const
inline

return number of samples

Definition at line 79 of file LArAccumulatedDigit.h.

79 { return m_sampleSquare.size(); }

◆ nTrigger()

unsigned LArAccumulatedDigit::nTrigger ( ) const
inline

return the number of triggers

Definition at line 88 of file LArAccumulatedDigit.h.

88 {return m_nTrigger;}

◆ RMS()

float LArAccumulatedDigit::RMS ( int  n_min = -1,
int  n_max = -1 
) const

Calculates and returns the RMS value of ADC samples

Definition at line 64 of file LArAccumulatedDigit.cxx.

65 {
66  unsigned imin=0;
67  const size_t nS=m_sampleSum.size();
68  if(nS==0) return 0.;
69  if(n_min>0 && (unsigned)n_min<nS) imin=n_min;
70  unsigned imax=nS-1;
71  if(n_max>0 && n_max>n_min && (unsigned)n_max<nS) imax=n_max;
72 
73  const double n = (imax-imin+1)*m_nTrigger;
74  if(n<=0) return 0;
75  if(m_sampleSquare.empty()) return 0;
76 
77  uint64_t x=0;
78  for(size_t i=imin;i<=imax;i++)
79  x += m_sampleSum[i];
80  const double inv_n = 1. / n;
81  double mean2 = x * inv_n;
82  mean2=mean2*mean2;
83  const double rms2=m_sampleSquare[0]*inv_n - mean2;
84  if (rms2<0.0) { //W.L 2010-12-07 protect against FPE due to rounding error
85  //std::cout << "ERROR negative squareroot:" << rms2 << std::endl;
86  return 0.0;
87  }
88  float rms = sqrt(rms2);
89  return rms;
90 }

◆ sampleSquare()

const std::vector< uint64_t >& LArAccumulatedDigit::sampleSquare ( ) const
inline

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

Definition at line 85 of file LArAccumulatedDigit.h.

85 { return m_sampleSquare; }

◆ sampleSum()

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

return the sample-sums

Definition at line 82 of file LArAccumulatedDigit.h.

82 { return m_sampleSum; };

◆ setAddDigit()

bool LArAccumulatedDigit::setAddDigit ( const std::vector< short > &  digit)

Accumulate single digit.

Definition at line 92 of file LArAccumulatedDigit.cxx.

92  {
93  const size_t nS=digit.size();
94  if(nS!=m_sampleSum.size() || nS!=m_sampleSquare.size()) {
95  if (!m_nTrigger)
96  return false;
97  m_sampleSquare.resize(nS,0);
98  m_sampleSum.resize(nS,0);
99  }// end if object empty
100 
101 
102  for (size_t i=0;i<nS;++i) {
103  m_sampleSum[i]+=digit[i];
104  for (size_t j=i;j<nS;++j)
105  m_sampleSquare[j]+=digit[i]*digit[j];
106  }
107  ++m_nTrigger;
108  return true;
109 }

◆ setAddSubStep() [1/4]

void LArAccumulatedDigit::setAddSubStep ( CaloGain::CaloGain  gain_value,
const std::vector< int64_t > &  sampleSum,
const std::vector< int64_t > &  sampleSquare,
unsigned  nTrigger,
int32_t  base 
)

Definition at line 188 of file LArAccumulatedDigit.cxx.

191 {
192  int64_t tmpBase;
193  std::vector<uint64_t> tmpSum;
194  std::vector<uint64_t> tmpSquare;
195  unsigned i,n;
196  const size_t nS=m_sampleSum.size();
197  if(gain_value!=m_gain) {
198  if(m_nTrigger!=0)
199  return;
200  m_gain=gain_value;
201  }
202  n = sampleSquare.size();
203  if(n!=sampleSum.size())
204  return; // Can not accumulate if nsamples differs
205  if(n!=nS) {
206  if(m_nTrigger!=0)
207  return; // Can not accumulate if nsamples differs
208  m_sampleSquare.resize(n,0);
209  m_sampleSum.resize(n,0);
210  }
211  tmpBase = base;
212  tmpSum.resize(n,0);
213  for(i=0;i<n;i++) {
214  tmpSum[i] = (uint64_t) (sampleSum[i]+tmpBase);
215  m_sampleSum[i] += tmpSum[i];
216  }
217 
218  tmpBase = static_cast<int64_t>(base)*base;
219  tmpSquare.resize(n,0);
220  for(i=0;i<n;i++) {
221  tmpSquare[i] = (uint64_t) (sampleSquare[i]+tmpBase);
222  m_sampleSquare[i] += tmpSquare[i];
223  }
224 
225  m_nTrigger += nTrigger;
226 
227  tmpSum.clear();
228  tmpSquare.clear();
229 }

◆ setAddSubStep() [2/4]

void LArAccumulatedDigit::setAddSubStep ( CaloGain::CaloGain  gain_value,
const std::vector< uint64_t > &  sampleSum,
const std::vector< uint64_t > &  sampleSquare,
unsigned  nTrigger 
)

Definition at line 149 of file LArAccumulatedDigit.cxx.

151 {
152  std::vector<uint64_t> tmpSum;
153  std::vector<uint64_t> tmpSquare;
154  unsigned i,n;
155  const size_t nS=m_sampleSum.size();
156  if(gain_value!=m_gain) {
157  if(m_nTrigger!=0)
158  return;
159  m_gain=gain_value;
160  }
161  n = sampleSquare.size();
162  if(n!=sampleSum.size())
163  return; // Can not accumulate if nsamples differs
164  if(n!=nS) {
165  if(m_nTrigger!=0)
166  return; // Can not accumulate if nsamples differs
167  m_sampleSquare.resize(n,0);
168  m_sampleSum.resize(n,0);
169  }
170 
171  tmpSum.resize(n,0);
172  for(i=0;i<n;i++) {
173  tmpSum[i] = sampleSum[i];
174  m_sampleSum[i] += sampleSum[i];
175  }
176 
177  tmpSquare.resize(n,0);
178  for(i=0;i<n;i++) {
179  tmpSquare[i] = sampleSquare[i];
181  }
182 
183  m_nTrigger += nTrigger;
184  tmpSum.clear();
185  tmpSquare.clear();
186 }

◆ setAddSubStep() [3/4]

bool LArAccumulatedDigit::setAddSubStep ( const CaloGain::CaloGain  gain_value,
const HWIdentifier  chid,
const std::vector< uint64_t > &  sampleSum,
const std::vector< uint64_t > &  sampleSquare,
const unsigned  nTrigger 
)

Accumulate new values

Definition at line 113 of file LArAccumulatedDigit.cxx.

118 {
119  size_t i;
120 
121  if(gain_value!=m_gain || chid!=m_hardwareID) {
122  if(m_nTrigger!=0)
123  return false;
124  m_gain=gain_value;
125  m_hardwareID=chid;
126  }
127 
128 
129  const size_t n = sampleSquare.size();
130  if(n!=sampleSum.size())
131  return false; // Can not accumulate if nsamples differs
132  if(n!=m_sampleSum.size() || n!=m_sampleSquare.size()) {
133  if(m_nTrigger!=0)
134  return false; // Can not accumulate if nsamples differs
135  m_sampleSquare.resize(n,0);
136  m_sampleSum.resize(n,0);
137  }
138  for(i=0;i<n;++i)
139  m_sampleSum[i] += sampleSum[i];
140 
141  for(i=0;i<n;i++)
143 
144  m_nTrigger += nTrigger;
145  return true;
146 }

◆ setAddSubStep() [4/4]

bool LArAccumulatedDigit::setAddSubStep ( const LArAccumulatedDigit ad)
inline

Definition at line 117 of file LArAccumulatedDigit.h.

117  {
118  return setAddSubStep(ad.gain(), ad.channelID(), ad.sampleSum(),ad.sampleSquare(),ad.nTrigger());
119  };

Member Data Documentation

◆ m_gain

CaloGain::CaloGain LArAccumulatedDigit::m_gain
private

gain

Definition at line 40 of file LArAccumulatedDigit.h.

◆ m_hardwareID

HWIdentifier LArAccumulatedDigit::m_hardwareID
private

Online Identifier.

Definition at line 37 of file LArAccumulatedDigit.h.

◆ m_nTrigger

uint32_t LArAccumulatedDigit::m_nTrigger
private

number of total triggers

Definition at line 49 of file LArAccumulatedDigit.h.

◆ m_sampleSquare

std::vector<uint64_t> LArAccumulatedDigit::m_sampleSquare
private

vector(index: j from s_i*s_{i+j})

Definition at line 46 of file LArAccumulatedDigit.h.

◆ m_sampleSum

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

sampleSum over ntrigger*nsamples

Definition at line 43 of file LArAccumulatedDigit.h.


The documentation for this class was generated from the following files:
LArAccumulatedDigit::gain
CaloGain::CaloGain gain() const
return gain value
Definition: LArAccumulatedDigit.h:76
LArAccumulatedDigit::m_hardwareID
HWIdentifier m_hardwareID
Online Identifier.
Definition: LArAccumulatedDigit.h:37
base
std::string base
Definition: hcg.cxx:78
PlotCalibFromCool.norm
norm
Definition: PlotCalibFromCool.py:100
LArAccumulatedDigit::m_gain
CaloGain::CaloGain m_gain
gain
Definition: LArAccumulatedDigit.h:40
LArAccumulatedDigit::setAddSubStep
bool setAddSubStep(const CaloGain::CaloGain gain_value, const HWIdentifier chid, const std::vector< uint64_t > &sampleSum, const std::vector< uint64_t > &sampleSquare, const unsigned nTrigger)
Accumulate new values
Definition: LArAccumulatedDigit.cxx:113
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CaloGain::UNKNOWNGAIN
@ UNKNOWNGAIN
Definition: CaloGain.h:20
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
LArAccumulatedDigit::sampleSquare
const std::vector< uint64_t > & sampleSquare() const
return a reference to a stl vector containing the sum of the squares of the sample
Definition: LArAccumulatedDigit.h:85
LArAccumulatedDigit::mean
float mean(int n_min=-1, int n_max=-1) const
Calculates and returns the Mean value of ADC samples.
Definition: LArAccumulatedDigit.cxx:41
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
x
#define x
normalize
Double_t normalize(TF1 *func, Double_t *rampl=NULL, Double_t from=0., Double_t to=0., Double_t step=1.)
Definition: LArPhysWaveHECTool.cxx:825
LArAccumulatedDigit::m_nTrigger
uint32_t m_nTrigger
number of total triggers
Definition: LArAccumulatedDigit.h:49
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
LArAccumulatedDigit::m_sampleSum
std::vector< uint64_t > m_sampleSum
sampleSum over ntrigger*nsamples
Definition: LArAccumulatedDigit.h:43
imax
int imax(int i, int j)
Definition: TileLaserTimingTool.cxx:33
LArAccumulatedDigit::nTrigger
unsigned nTrigger() const
return the number of triggers
Definition: LArAccumulatedDigit.h:88
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArAccumulatedDigit::sampleSum
const std::vector< uint64_t > & sampleSum() const
return the sample-sums
Definition: LArAccumulatedDigit.h:82
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
LArAccumulatedDigit::m_sampleSquare
std::vector< uint64_t > m_sampleSquare
vector(index: j from s_i*s_{i+j})
Definition: LArAccumulatedDigit.h:46
LArAccumulatedDigit::channelID
const HWIdentifier & channelID() const
Return channel ID.
Definition: LArAccumulatedDigit.h:73