Belle II Software development
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/* ECL headers. */
12#include <ecl/dataobjects/ECLElementNumbers.h>
13
14/* ROOT headers. */
15#include <TObject.h>
16
17/* C++ headers. */
18#include <array>
19#include <cassert>
20#include <utility>
21#include <vector>
22
23namespace Belle2 {
35 class ECLWaveformData : public TObject {
36 public:
37
39 void setMatrixElement(size_t i, float value)
40 {
41 assert(i < c_nElements);
42 m_matrixElement[i] = value;
43 }
45 float getMatrixElement(size_t i) const
46 {
47 assert(i < c_nElements);
48 return m_matrixElement[i];
49 }
50
52 float getMatrixElement(size_t i, size_t j) const
53 {
54 if (i < j) std::swap(i, j);
55 return m_matrixElement[ i * (i + 1) / 2 + j];
56 }
57
59 void getArray(float WF[136]) const {for (int i = 0; i < 136; i++) { WF[i] = (float) m_matrixElement[i];} }
60
62 void getMatrix(float M[16][16]) const
63 {
64 const float* A = m_matrixElement;
65 for (int i = 0; i < 16; i++) {
66 for (int j = 0; j < i; j++) M[i][j] = M[j][i] = *A++;
67 M[i][i] = *A++;
68 }
69 }
70
72 void getMatrix(double M[16][16]) const
73 {
74 const float* A = m_matrixElement;
75 for (int i = 0; i < 16; i++) {
76 for (int j = 0; j < i; j++) M[i][j] = M[j][i] = *A++;
77 M[i][i] = *A++;
78 }
79 }
80
82 void storeMatrix(const std::array<std::array<float, 16>, 16>& M) // using std::array for intel compiler (TF)
83 {
84 float* A = m_matrixElement;
85 for (int i = 0; i < 16; i++) {
86 for (int j = 0; j < i; j++) *A++ = M[i][j];
87 *A++ = M[i][i];
88 }
89 }
90
92 void storeMatrix(const std::array<std::array<double, 16>, 16>& M) // using std::array for intel compiler (TF)
93 {
94 float* A = m_matrixElement;
95 for (int i = 0; i < 16; i++) {
96 for (int j = 0; j < i; j++) *A++ = static_cast<float>(M[i][j]);
97 *A++ = M[i][i];
98 }
99 }
100
102 void setWaveformPar(size_t i, float value)
103 {
104 assert(i < c_nParams);
105 m_waveformPar[i] = value;
106 }
107
108
110 float getWaveformPar(size_t i) const
111 {
112 assert(i < c_nParams);
113 return m_waveformPar[i];
114 }
115
118 void getWaveformParArray(float P[10]) const
119 {
120 for (int i = 0; i < 10; i++)
121 P[i] = (float) m_waveformPar[i];
122 }
123
126 void getWaveformParArray(double P[10]) const
127 {
128 for (int i = 0; i < 10; i++)
129 P[i] = m_waveformPar[i];
130 }
131
133 void print() const;
134
135 static const size_t c_nElements = 136;
136 static const size_t c_nParams = 10;
137 private:
142 };
143
146 class ECLWFAlgoParams : public TObject {
147 public:
148
149 Int_t ka;
150 Int_t kb;
151 Int_t kc;
152 Int_t y0Startr;
153 Int_t chiThresh;
154 Int_t k1Chi;
155 Int_t k2Chi;
156 Int_t hitThresh;
159 int getka() const {return (int) ka;}
160 int getkb() const {return (int) kb;}
161 int getkc() const {return (int) kc;}
162 int gety0s() const {return (int) y0Startr;}
163 int getcT() const {return (int) chiThresh;}
164 int getk1() const {return (int) k1Chi;}
165 int getk2() const {return (int) k2Chi;}
166 int gethT() const {return (int) hitThresh;}
167 int getlAT() const {return (int) lowAmpThresh;}
168 int getsT() const {return (int) skipThresh;}
170 ClassDef(ECLWFAlgoParams, 1)
171 };
172
174 class ECLNoiseData : public TObject {
175 public:
177 void setMatrixElement(size_t i, float value)
178 {
179 assert(i < c_nElements);
180 m_matrixElement[i] = value;
181 }
183 float getMatrixElement(size_t i) const
184 {
185 assert(i < c_nElements);
186 return m_matrixElement[i];
187 }
188
190 void getArray(float NoiseData[496]) const {for (int i = 0; i < 496; i++) { NoiseData[i] = (float) m_matrixElement[i];} }
191
193 void getMatrix(float M[31][31]) const
194 {
195 const float* A = m_matrixElement;
196 for (int i = 0; i < 31; i++) {
197 for (int j = 0; j < 31; j++) {
198 if (j > i) { // fill only the lower triangle
199 M[i][j] = 0.f;
200 } else {
201 M[i][j] = *A++;
202 }
203 }
204 }
205 }
206
208 void generateCorrelatedNoise(const float z[31], float x[31]) const
209 {
210 // z = (z0, ..., z30) is a inpute vector whose components are 31 independent standard normal variates
211 // the output vector x is x0 + A*z, where x0 is 0 at the moment
212 // A*A^T = C where C is a positive definite covariance matrix, A is a lower triangular matrix
213 const float* A = m_matrixElement;
214 for (int i = 0; i < 31; i++) {
215 float sum = 0;
216 for (int j = 0; j <= i; j++) sum += z[j] * (*A++);
217 x[i] = sum;
218 }
219 }
220
221 static const size_t c_nElements = 496;
225 ClassDef(ECLNoiseData, 1)
226 };
227
228
230 class ECLLookupTable : public TObject {
231 public:
233 ECLLookupTable() : m_content(ECLElementNumbers::c_NCrystals, 0) {}
234
236 unsigned int operator[](unsigned int key) const
237 { return m_content[ key - 1 ]; }
239 unsigned int& operator[](unsigned int key)
240 { return m_content[ key - 1 ]; }
241
242 private:
243 std::vector<unsigned int> m_content;
245 };
246
248}
Class for a lookup table.
unsigned int operator[](unsigned int key) const
Array-like access operator.
unsigned int & operator[](unsigned int key)
Array-like access operator.
ClassDef(ECLLookupTable, 1)
ClassDef.
ECLLookupTable()
Constructor.
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.