Belle II Software  release-06-02-00
ECLWaveformData.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <cassert>
12 #include <vector>
13 #include <utility>
14 #include <TObject.h>
15 
16 namespace Belle2 {
28  class ECLWaveformData : public TObject {
29  public:
30 
32  void setMatrixElement(size_t i, float value)
33  {
34  assert(i < c_nElements);
35  m_matrixElement[i] = value;
36  }
38  float getMatrixElement(size_t i) const
39  {
40  assert(i < c_nElements);
41  return m_matrixElement[i];
42  }
43 
45  float getMatrixElement(size_t i, size_t j) const
46  {
47  if (i < j) std::swap(i, j);
48  return m_matrixElement[ i * (i + 1) / 2 + j];
49  }
50 
52  void getArray(float WF[136]) const {for (int i = 0; i < 136; i++) { WF[i] = (float) m_matrixElement[i];} }
53 
55  void getMatrix(float M[16][16]) const
56  {
57  const float* A = m_matrixElement;
58  for (int i = 0; i < 16; i++) {
59  for (int j = 0; j < i; j++) M[i][j] = M[j][i] = *A++;
60  M[i][i] = *A++;
61  }
62  }
63 
65  void getMatrix(double M[16][16]) const
66  {
67  const float* A = m_matrixElement;
68  for (int i = 0; i < 16; i++) {
69  for (int j = 0; j < i; j++) M[i][j] = M[j][i] = *A++;
70  M[i][i] = *A++;
71  }
72  }
73 
75  void storeMatrix(const std::array<std::array<float, 16>, 16>& M) // using std::array for intel compiler (TF)
76  {
77  float* A = m_matrixElement;
78  for (int i = 0; i < 16; i++) {
79  for (int j = 0; j < i; j++) *A++ = M[i][j];
80  *A++ = M[i][i];
81  }
82  }
83 
85  void storeMatrix(const std::array<std::array<double, 16>, 16>& M) // using std::array for intel compiler (TF)
86  {
87  float* A = m_matrixElement;
88  for (int i = 0; i < 16; i++) {
89  for (int j = 0; j < i; j++) *A++ = static_cast<float>(M[i][j]);
90  *A++ = M[i][i];
91  }
92  }
93 
95  void setWaveformPar(size_t i, float value)
96  {
97  assert(i < c_nParams);
98  m_waveformPar[i] = value;
99  }
100 
101 
103  float getWaveformPar(size_t i) const
104  {
105  assert(i < c_nParams);
106  return m_waveformPar[i];
107  }
108 
111  void getWaveformParArray(float P[10]) const
112  {
113  for (int i = 0; i < 10; i++)
114  P[i] = (float) m_waveformPar[i];
115  }
116 
119  void getWaveformParArray(double P[10]) const
120  {
121  for (int i = 0; i < 10; i++)
122  P[i] = m_waveformPar[i];
123  }
124 
126  void print() const;
127 
128  static const size_t c_nElements = 136;
129  static const size_t c_nParams = 10;
130  private:
135  };
136 
139  class ECLWFAlgoParams : public TObject {
140  public:
141 
142  Int_t ka;
143  Int_t kb;
144  Int_t kc;
145  Int_t y0Startr;
146  Int_t chiThresh;
147  Int_t k1Chi;
148  Int_t k2Chi;
149  Int_t hitThresh;
150  Int_t lowAmpThresh;
151  Int_t skipThresh;
152  int getka() const {return (int) ka;}
153  int getkb() const {return (int) kb;}
154  int getkc() const {return (int) kc;}
155  int gety0s() const {return (int) y0Startr;}
156  int getcT() const {return (int) chiThresh;}
157  int getk1() const {return (int) k1Chi;}
158  int getk2() const {return (int) k2Chi;}
159  int gethT() const {return (int) hitThresh;}
160  int getlAT() const {return (int) lowAmpThresh;}
161  int getsT() const {return (int) skipThresh;}
163  ClassDef(ECLWFAlgoParams, 1)
164  };
165 
167  class ECLNoiseData : public TObject {
168  public:
170  void setMatrixElement(size_t i, float value)
171  {
172  assert(i < c_nElements);
173  m_matrixElement[i] = value;
174  }
176  float getMatrixElement(size_t i) const
177  {
178  assert(i < c_nElements);
179  return m_matrixElement[i];
180  }
181 
183  void getArray(float NoiseData[496]) const {for (int i = 0; i < 496; i++) { NoiseData[i] = (float) m_matrixElement[i];} }
184 
186  void getMatrix(float M[31][31]) const
187  {
188  const float* A = m_matrixElement;
189  for (int i = 0; i < 31; i++) {
190  for (int j = 0; j < 31; j++) {
191  if (j > i) { // fill only the lower triangle
192  M[i][j] = 0.f;
193  } else {
194  M[i][j] = *A++;
195  }
196  }
197  }
198  }
199 
201  void generateCorrelatedNoise(const float z[31], float x[31]) const
202  {
203  // z = (z0, ..., z30) is a inpute vector whose components are 31 independent standard normal variates
204  // the output vector x is x0 + A*z, where x0 is 0 at the moment
205  // A*A^T = C where C is a positive definite covariance matrix, A is a lower triangular matrix
206  const float* A = m_matrixElement;
207  for (int i = 0; i < 31; i++) {
208  float sum = 0;
209  for (int j = 0; j <= i; j++) sum += z[j] * (*A++);
210  x[i] = sum;
211  }
212  }
213 
214  static const size_t c_nElements = 496;
218  ClassDef(ECLNoiseData, 1)
219  };
220 
221 
223  class ECLLookupTable : public TObject {
224  public:
226  ECLLookupTable() : m_content(8736, 0) {}
227 
229  unsigned int operator[](unsigned int key) const
230  { return m_content[ key - 1 ]; }
232  unsigned int& operator[](unsigned int key)
233  { return m_content[ key - 1 ]; }
234 
235  private:
236  std::vector<unsigned int> m_content;
238  };
239 
241 }
Class for a lookup table.
unsigned int operator[](unsigned int key) const
Array-like access operator.
ClassDef(ECLLookupTable, 1)
ClassDef.
ECLLookupTable()
Constructor.
unsigned int & operator[](unsigned int key)
Array-like access operator.
std::vector< unsigned int > m_content
index to index lookup table
Container for constant matrix used to generate electronic noise.
Float_t m_matrixElement[c_nElements]
electronic noise matrix
void setMatrixElement(size_t i, float value)
Setter method for independent matrix element.
void getMatrix(float M[31][31]) const
Getter method for matrix as two dimentional array.
static const size_t c_nElements
number of independent elements
float getMatrixElement(size_t i) const
Getter method for independent matrix element.
void generateCorrelatedNoise(const float z[31], float x[31]) const
sampling a random vector x from the 31-dimensional multivariate normal distribution with covariance m...
void getArray(float NoiseData[496]) const
Getter method for matrix as one dimentional array.
Container for constant parameters used in waveform fits.
int getkc() const
getter for multipliers power of 2 for fg33,fg43
int getlAT() const
getter for the threshold to calculate time
int getsT() const
getter for the threshold to send data to collector
Int_t kc
multipliers power of 2 for fg33,fg43
Int_t ka
multipliers power of 2 for fg31,fg41
int getcT() const
getter for the chi2 threshold for quality bit
int getk1() const
getter for the multipliers power of 2 for f
Int_t hitThresh
hardware threshold(to start digitization)
Int_t skipThresh
threshold to send data to collector
Int_t y0Startr
start point for pedestal calculation
int getk2() const
getter for multipliers power of 2 for chi2 calculation
int getkb() const
getter for multipliers power of 2 for fg32
Int_t k1Chi
multipliers power of 2 for f
int gethT() const
getter for the hardware threshold
int gety0s() const
getter for the start point for pedestal calculation
Int_t k2Chi
multipliers power of 2 for chi2 calculation
Int_t lowAmpThresh
threshold to calculate time
Int_t chiThresh
chi2 threshold for quality bit
int getka() const
getter for multipliers power of 2 for fg31 fg41
Int_t kb
multipliers power of 2 for fg32
ECLWaveformData - container for inverse covariant matrix and shape parameters for time and amplitude ...
static const size_t c_nParams
number of parameters defining the waveform shape
Float_t m_waveformPar[c_nParams]
the waveform parameters
void getMatrix(float M[16][16]) const
Getter method for all matrix as two dimentional array (floats)
Float_t m_matrixElement[c_nElements]
the matrix elements
float getMatrixElement(size_t i, size_t j) const
Getter method for independent matrix element.
void setMatrixElement(size_t i, float value)
Setter method for independent matrix element.
void getWaveformParArray(double P[10]) const
Getter method for waveform shape parameters as one dimentional array of doubles.
static const size_t c_nElements
number of independent matrix elements
float getMatrixElement(size_t i) const
Getter method for independent matrix element.
void storeMatrix(const std::array< std::array< double, 16 >, 16 > &M)
Setter for matrix from std::array of doubles.
void getArray(float WF[136]) const
Getter method for all matrix as one dimentional array.
ClassDef(ECLWaveformData, 1)
ClassDef.
float getWaveformPar(size_t i) const
Getter method for waveform shape parameter.
void storeMatrix(const std::array< std::array< float, 16 >, 16 > &M)
Setter for matrix from std::array of floats.
void print() const
print-out function for debugging purpose
void getWaveformParArray(float P[10]) const
Getter method for waveform shape parameters as one dimentional array of floats.
void getMatrix(double M[16][16]) const
Getter method for all matrix as two dimentional array (doubles)
void setWaveformPar(size_t i, float value)
Setter method for waveform shape parameter.
Abstract base class for different kinds of events.