10#include <ecl/calibration/eclAutocovarianceCalibrationC3Algorithm.h>
13#include <ecl/dataobjects/ECLElementNumbers.h>
14#include <ecl/dbobjects/ECLAutoCovariance.h>
20#include"TMatrixDSym.h"
21#include"TDecompChol.h"
31 "Computes the covariance matrix for each crystal"
43 std::vector<double> cryIDs;
44 std::vector<double> invertStatusVector;
45 std::vector<double> noiseMatrix00Vector;
46 std::vector<double> totalCountsVector;
50 auto CovarianceMatrixInfoVsCrysID = getObjectPtr<TH2F>(
"CovarianceMatrixInfoVsCrysID");
56 float totalCounts = CovarianceMatrixInfoVsCrysID->GetBinContent(CovarianceMatrixInfoVsCrysID->GetBin(ID + 1,
60 B2INFO(
"eclAutocovarianceCalibrationC3Algorithm: warning total entries for cell ID " << ID + 1 <<
" is only: " << totalCounts <<
66 TMatrixDSym NoiseMatrix;
70 int index = abs(i - j);
71 NoiseMatrix(i, j) = float(CovarianceMatrixInfoVsCrysID->GetBinContent(CovarianceMatrixInfoVsCrysID->GetBin(ID + 1,
79 TDecompChol dc(NoiseMatrix);
80 bool InvertStatus = dc.Invert(NoiseMatrix);
81 if (InvertStatus ==
false && ID > 0) {
82 B2INFO(
"eclAutocovarianceCalibrationC3Algorithm iD InvertStatus [0][0] totalCounts: " << ID <<
" " << InvertStatus <<
" " <<
83 NoiseMatrix(0, 0) <<
" " << totalCounts);
84 B2INFO(
"eclAutocovarianceCalibrationC3Algorithm Setting ID " << ID <<
" Autocovariance to Autocovariance from ID " << ID - 1);
85 B2INFO(
"eclAutocovarianceCalibrationC3Algorithm B: " << tempAutoCov[0]);
87 B2INFO(
"eclAutocovarianceCalibrationC3Algorithm A: " << tempAutoCov[0]);
92 cryIDs.push_back(ID + 1);
93 invertStatusVector.push_back(InvertStatus);
94 noiseMatrix00Vector.push_back(NoiseMatrix(0, 0));
95 totalCountsVector.push_back(totalCounts);
103 auto ginvertStatusVector =
new TGraph(cryIDs.size(), cryIDs.data(), invertStatusVector.data());
104 ginvertStatusVector->SetName(
"ginvertStatusVector");
105 ginvertStatusVector->SetMarkerStyle(20);
106 auto gnoiseMatrix00Vector =
new TGraph(cryIDs.size(), cryIDs.data(), noiseMatrix00Vector.data());
107 gnoiseMatrix00Vector->SetName(
"gnoiseMatrix00Vector");
108 gnoiseMatrix00Vector->SetMarkerStyle(20);
109 auto gtotalCountsVector =
new TGraph(cryIDs.size(), cryIDs.data(), totalCountsVector.data());
110 gtotalCountsVector->SetName(
"gtotalCountsVector");
111 gtotalCountsVector->SetMarkerStyle(20);
115 TDirectory::TContext context;
116 TFile* histfile =
new TFile(fName,
"recreate");
118 ginvertStatusVector->Write();
119 gnoiseMatrix00Vector->Write();
120 gtotalCountsVector->Write();
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
Covariance matrices for offline ECL waveform fit.
void getAutoCovariance(const int cellID, double acov[31]) const
Get auto covariance for a channel.
void setAutoCovariance(const int cellID, const double acov[31])
Set auto covariance for a channel.
eclAutocovarianceCalibrationC3Algorithm()
..Constructor
std::string m_outputName
file name for histogram output
const int m_numberofADCPoints
length of ECLDsp waveform
int m_TotalCountsThreshold
min number of counts needed to compute calibration
virtual EResult calibrate() override
..Run algorithm on events
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.