Belle II Software development
ECLAutoCovariance.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
19namespace Belle2 {
27 float sigmaNoiseSq = -1;
28 short int packedCovMat[30] = {};
30 };
31
35 class ECLAutoCovariance: public TObject {
36 public:
37
42
47
49 const PackedAutoCovariance& getPacked(const int cellID) const
50 {
51 if (cellID < 1 || cellID > ECLElementNumbers::c_NCrystals) return m_acov[0];
52 return m_acov[cellID - 1];
53 }
54
56 void getAutoCovariance(const int cellID, double acov[31]) const
57 {
58 if (cellID < 1 || cellID > ECLElementNumbers::c_NCrystals) return;
59 const PackedAutoCovariance& tempPacked = m_acov[cellID - 1];
60 acov[0] = static_cast<double>(tempPacked.sigmaNoiseSq);
61 const double norm = acov[0] * (1.0 / 32767);
62 for (int i = 0; i < 30; i++) acov[i + 1] = norm * static_cast<double>(tempPacked.packedCovMat[i]);
63 }
64
66 void setAutoCovariance(const int cellID, const double acov[31])
67 {
68 if (cellID < 1 || cellID > ECLElementNumbers::c_NCrystals) return;
69 const double norm = 32767 / acov[0];
70 PackedAutoCovariance& tempPacked = m_acov[cellID - 1];
71 tempPacked.sigmaNoiseSq = static_cast<float>(acov[0]);
72 for (int i = 0; i < 30; i++)
73 tempPacked.packedCovMat[i] = static_cast<short int>(std::max(-32767.0, std::min(acov[i + 1] * norm, 32767.0)));
74 }
75
76 private:
79 //Initial Version
81 };
83} // end namespace Belle2
Covariance matrices for offline ECL waveform fit.
void getAutoCovariance(const int cellID, double acov[31]) const
Get auto covariance for a channel.
PackedAutoCovariance m_acov[ECLElementNumbers::c_NCrystals]
Packed autocovariance matrix for each crystal.
ECLAutoCovariance()
Default constructor.
void setAutoCovariance(const int cellID, const double acov[31])
Set auto covariance for a channel.
const PackedAutoCovariance & getPacked(const int cellID) const
Get packed autocovariance.
ClassDef(ECLAutoCovariance, 1)
ClassDef.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.
packed covariance matrix
float sigmaNoiseSq
sigma noise squared in ADC channels
ClassDef(PackedAutoCovariance, 1)
ClassDef to make streamer.
short int packedCovMat[30]
packed covariance, the range [-1.0, 1.0] is mapped to [-32767, 32767]