Belle II Software  release-05-02-19
ECLWaveformData.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Guglielmo De Nardo *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef ECLWAVEFORMDATA_H
12 #define ECLWAVEFORMDATA_H
13 
14 #include <cassert>
15 #include <vector>
16 #include <utility>
17 #include <TObject.h>
18 
19 namespace Belle2 {
31  class ECLWaveformData : public TObject {
32  public:
33 
35  void setMatrixElement(size_t i, float value)
36  {
37  assert(i < c_nElements);
38  m_matrixElement[i] = value;
39  }
41  float getMatrixElement(size_t i) const
42  {
43  assert(i < c_nElements);
44  return m_matrixElement[i];
45  }
46 
48  float getMatrixElement(size_t i, size_t j) const
49  {
50  if (i < j) std::swap(i, j);
51  return m_matrixElement[ i * (i + 1) / 2 + j];
52  }
53 
55  void getArray(float WF[136]) const {for (int i = 0; i < 136; i++) { WF[i] = (float) m_matrixElement[i];} }
56 
58  void getMatrix(float M[16][16]) const
59  {
60  const float* A = m_matrixElement;
61  for (int i = 0; i < 16; i++) {
62  for (int j = 0; j < i; j++) M[i][j] = M[j][i] = *A++;
63  M[i][i] = *A++;
64  }
65  }
66 
68  void getMatrix(double M[16][16]) const
69  {
70  const float* A = m_matrixElement;
71  for (int i = 0; i < 16; i++) {
72  for (int j = 0; j < i; j++) M[i][j] = M[j][i] = *A++;
73  M[i][i] = *A++;
74  }
75  }
76 
78  void storeMatrix(const std::array<std::array<float, 16>, 16>& M) // using std::array for intel compiler (TF)
79  {
80  float* A = m_matrixElement;
81  for (int i = 0; i < 16; i++) {
82  for (int j = 0; j < i; j++) *A++ = M[i][j];
83  *A++ = M[i][i];
84  }
85  }
86 
88  void storeMatrix(const std::array<std::array<double, 16>, 16>& M) // using std::array for intel compiler (TF)
89  {
90  float* A = m_matrixElement;
91  for (int i = 0; i < 16; i++) {
92  for (int j = 0; j < i; j++) *A++ = static_cast<float>(M[i][j]);
93  *A++ = M[i][i];
94  }
95  }
96 
98  void setWaveformPar(size_t i, float value)
99  {
100  assert(i < c_nParams);
101  m_waveformPar[i] = value;
102  }
103 
104 
106  float getWaveformPar(size_t i) const
107  {
108  assert(i < c_nParams);
109  return m_waveformPar[i];
110  }
111 
114  void getWaveformParArray(float P[10]) const
115  {
116  for (int i = 0; i < 10; i++)
117  P[i] = (float) m_waveformPar[i];
118  }
119 
122  void getWaveformParArray(double P[10]) const
123  {
124  for (int i = 0; i < 10; i++)
125  P[i] = m_waveformPar[i];
126  }
127 
129  void print() const;
130 
131  static const size_t c_nElements = 136;
132  static const size_t c_nParams = 10;
133  private:
134  Float_t m_matrixElement[c_nElements];
135  Float_t m_waveformPar[c_nParams];
138  };
139 
142  class ECLWFAlgoParams : public TObject {
143  public:
144 
145  Int_t ka;
146  Int_t kb;
147  Int_t kc;
148  Int_t y0Startr;
149  Int_t chiThresh;
150  Int_t k1Chi;
151  Int_t k2Chi;
152  Int_t hitThresh;
153  Int_t lowAmpThresh;
154  Int_t skipThresh;
155  int getka() const {return (int) ka;}
156  int getkb() const {return (int) kb;}
157  int getkc() const {return (int) kc;}
158  int gety0s() const {return (int) y0Startr;}
159  int getcT() const {return (int) chiThresh;}
160  int getk1() const {return (int) k1Chi;}
161  int getk2() const {return (int) k2Chi;}
162  int gethT() const {return (int) hitThresh;}
163  int getlAT() const {return (int) lowAmpThresh;}
164  int getsT() const {return (int) skipThresh;}
166  ClassDef(ECLWFAlgoParams, 1)
167  };
168 
170  class ECLNoiseData : public TObject {
171  public:
173  void setMatrixElement(size_t i, float value)
174  {
175  assert(i < c_nElements);
176  m_matrixElement[i] = value;
177  }
179  float getMatrixElement(size_t i) const
180  {
181  assert(i < c_nElements);
182  return m_matrixElement[i];
183  }
184 
186  void getArray(float NoiseData[496]) const {for (int i = 0; i < 496; i++) { NoiseData[i] = (float) m_matrixElement[i];} }
187 
189  void getMatrix(float M[31][31]) const
190  {
191  const float* A = m_matrixElement;
192  for (int i = 0; i < 31; i++) {
193  for (int j = 0; j < 31; j++) {
194  if (j > i) { // fill only the lower triangle
195  M[i][j] = 0.f;
196  } else {
197  M[i][j] = *A++;
198  }
199  }
200  }
201  }
202 
204  void generateCorrelatedNoise(const float z[31], float x[31]) const
205  {
206  // z = (z0, ..., z30) is a inpute vector whose components are 31 independent standard normal variates
207  // the output vector x is x0 + A*z, where x0 is 0 at the moment
208  // A*A^T = C where C is a positive definite covariance matrix, A is a lower triangular matrix
209  const float* A = m_matrixElement;
210  for (int i = 0; i < 31; i++) {
211  float sum = 0;
212  for (int j = 0; j <= i; j++) sum += z[j] * (*A++);
213  x[i] = sum;
214  }
215  }
216 
217  static const size_t c_nElements = 496;
219  Float_t m_matrixElement[c_nElements];
221  ClassDef(ECLNoiseData, 1)
222  };
223 
224 
226  class ECLLookupTable : public TObject {
227  public:
229  ECLLookupTable() : m_content(8736, 0) {}
230 
232  unsigned int operator[](unsigned int key) const
233  { return m_content[ key - 1 ]; }
235  unsigned int& operator[](unsigned int key)
236  { return m_content[ key - 1 ]; }
237 
238  private:
239  std::vector<unsigned int> m_content;
241  };
242 
244 }
245 #endif
Belle2::ECLWaveformData::c_nElements
static const size_t c_nElements
number of independent matrix elements
Definition: ECLWaveformData.h:139
Belle2::ECLWFAlgoParams::y0Startr
Int_t y0Startr
start point for pedestal calculation
Definition: ECLWaveformData.h:156
Belle2::ECLWaveformData::ClassDef
ClassDef(ECLWaveformData, 1)
ClassDef.
Belle2::ECLLookupTable::operator[]
unsigned int operator[](unsigned int key) const
Array-like access operator.
Definition: ECLWaveformData.h:240
Belle2::ECLWaveformData::m_waveformPar
Float_t m_waveformPar[c_nParams]
the waveform parameters
Definition: ECLWaveformData.h:143
Belle2::ECLWaveformData::setMatrixElement
void setMatrixElement(size_t i, float value)
Setter method for independent matrix element.
Definition: ECLWaveformData.h:43
Belle2::ECLWaveformData::getWaveformPar
float getWaveformPar(size_t i) const
Getter method for waveform shape parameter.
Definition: ECLWaveformData.h:114
Belle2::ECLWaveformData::storeMatrix
void storeMatrix(const std::array< std::array< float, 16 >, 16 > &M)
Setter for matrix from std::array of floats.
Definition: ECLWaveformData.h:86
Belle2::ECLWFAlgoParams::kc
Int_t kc
multipliers power of 2 for fg33,fg43
Definition: ECLWaveformData.h:155
Belle2::ECLWFAlgoParams::lowAmpThresh
Int_t lowAmpThresh
threshold to calculate time
Definition: ECLWaveformData.h:161
Belle2::ECLWFAlgoParams::k1Chi
Int_t k1Chi
multipliers power of 2 for f
Definition: ECLWaveformData.h:158
Belle2::ECLWaveformData::print
void print() const
print-out function for debugging purpose
Definition: ECLWaveformData.cc:7
Belle2::ECLWFAlgoParams::ka
Int_t ka
multipliers power of 2 for fg31,fg41
Definition: ECLWaveformData.h:153
Belle2::ECLWaveformData::c_nParams
static const size_t c_nParams
number of parameters defining the waveform shape
Definition: ECLWaveformData.h:140
Belle2::ECLNoiseData::getArray
void getArray(float NoiseData[496]) const
Getter method for matrix as one dimentional array.
Definition: ECLWaveformData.h:194
Belle2::ECLWaveformData::m_matrixElement
Float_t m_matrixElement[c_nElements]
the matrix elements
Definition: ECLWaveformData.h:142
Belle2::ECLLookupTable::ClassDef
ClassDef(ECLLookupTable, 1)
ClassDef.
Belle2::ECLWFAlgoParams::kb
Int_t kb
multipliers power of 2 for fg32
Definition: ECLWaveformData.h:154
Belle2::ECLWaveformData::getArray
void getArray(float WF[136]) const
Getter method for all matrix as one dimentional array.
Definition: ECLWaveformData.h:63
Belle2::ECLWaveformData::getWaveformParArray
void getWaveformParArray(float P[10]) const
Getter method for waveform shape parameters as one dimentional array of floats.
Definition: ECLWaveformData.h:122
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECLWaveformData::getMatrixElement
float getMatrixElement(size_t i) const
Getter method for independent matrix element.
Definition: ECLWaveformData.h:49
Belle2::ECLLookupTable
Class for a lookup table.
Definition: ECLWaveformData.h:234
Belle2::ECLLookupTable::m_content
std::vector< unsigned int > m_content
index to index lookup table
Definition: ECLWaveformData.h:247
Belle2::ECLNoiseData::c_nElements
static const size_t c_nElements
number of independent elements
Definition: ECLWaveformData.h:225
Belle2::ECLNoiseData::getMatrixElement
float getMatrixElement(size_t i) const
Getter method for independent matrix element.
Definition: ECLWaveformData.h:187
Belle2::ECLWFAlgoParams::skipThresh
Int_t skipThresh
threshold to send data to collector
Definition: ECLWaveformData.h:162
Belle2::ECLWaveformData
ECLWaveformData - container for inverse covariant matrix and shape parameters for time and amplitude ...
Definition: ECLWaveformData.h:39
Belle2::ECLWFAlgoParams::chiThresh
Int_t chiThresh
chi2 threshold for quality bit
Definition: ECLWaveformData.h:157
Belle2::ECLWaveformData::setWaveformPar
void setWaveformPar(size_t i, float value)
Setter method for waveform shape parameter.
Definition: ECLWaveformData.h:106
Belle2::ECLNoiseData::generateCorrelatedNoise
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...
Definition: ECLWaveformData.h:212
Belle2::ECLNoiseData::setMatrixElement
void setMatrixElement(size_t i, float value)
Setter method for independent matrix element.
Definition: ECLWaveformData.h:181
Belle2::ECLNoiseData::m_matrixElement
Float_t m_matrixElement[c_nElements]
electronic noise matrix
Definition: ECLWaveformData.h:227
Belle2::ECLWaveformData::getMatrix
void getMatrix(float M[16][16]) const
Getter method for all matrix as two dimentional array (floats)
Definition: ECLWaveformData.h:66
Belle2::ECLWFAlgoParams
Container for constant parameters used in waveform fits.
Definition: ECLWaveformData.h:150
Belle2::ECLWFAlgoParams::hitThresh
Int_t hitThresh
hardware threshold(to start digitization)
Definition: ECLWaveformData.h:160
Belle2::ECLLookupTable::ECLLookupTable
ECLLookupTable()
Constructor.
Definition: ECLWaveformData.h:237
Belle2::ECLNoiseData::getMatrix
void getMatrix(float M[31][31]) const
Getter method for matrix as two dimentional array.
Definition: ECLWaveformData.h:197
Belle2::ECLWFAlgoParams::k2Chi
Int_t k2Chi
multipliers power of 2 for chi2 calculation
Definition: ECLWaveformData.h:159