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> noiseMatrix00Vector;
45 std::vector<double> totalCountsVector;
46 std::vector<double> invertAttempts;
50 auto CovarianceMatrixInfoVsCrysID = getObjectPtr<TH2F>(
"CovarianceMatrixInfoVsCrysID");
56 double 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) = double(CovarianceMatrixInfoVsCrysID->GetBinContent(CovarianceMatrixInfoVsCrysID->GetBin(ID + 1,
79 NoiseMatrixReduced(i, j) = (NoiseMatrix(0, abs(i - j)));
83 bool invert_successful = 0;
84 int invert_attempt = 0;
88 while (invert_successful == 0) {
96 NoiseMatrix_check(i, j) = buf[abs(i - j)];
100 TDecompChol dc(NoiseMatrix_check);
101 invert_successful = dc.Invert(NoiseMatrix_check);
102 if (invert_successful == 0) {
104 if (invert_attempt > 4) {
105 B2INFO(
"eclAutocovarianceCalibrationC3Algorithm iD " << ID <<
" invert_attempt limit reached " << invert_attempt);
106 B2INFO(
"eclAutocovarianceCalibrationC3Algorithm setting m_u2 to zero");
110 B2INFO(
"eclAutocovarianceCalibrationC3Algorithm iD " << ID <<
" invert_attempt " << invert_attempt);
112 for (
int i = 0; i <
m_numberofADCPoints; i++) B2INFO(
"old[" << i <<
"] = " << tempAutoCov[i]);
114 for (
int i = 0; i <
m_numberofADCPoints; i++) B2INFO(
"new[" << i <<
"] = " << tempAutoCov[i]);
120 cryIDs.push_back(ID + 1);
121 noiseMatrix00Vector.push_back(tempAutoCov[0]);
122 totalCountsVector.push_back(totalCounts);
123 invertAttempts.push_back(invert_attempt);
131 auto gnoiseMatrix00Vector =
new TGraph(cryIDs.size(), cryIDs.data(), noiseMatrix00Vector.data());
132 gnoiseMatrix00Vector->SetName(
"gnoiseMatrix00Vector");
133 gnoiseMatrix00Vector->SetMarkerStyle(20);
134 auto gtotalCountsVector =
new TGraph(cryIDs.size(), cryIDs.data(), totalCountsVector.data());
135 gtotalCountsVector->SetName(
"gtotalCountsVector");
136 gtotalCountsVector->SetMarkerStyle(20);
137 auto ginvertAttempts =
new TGraph(cryIDs.size(), cryIDs.data(), invertAttempts.data());
138 ginvertAttempts->SetName(
"ginvertAttempts");
139 ginvertAttempts->SetMarkerStyle(20);
143 TDirectory::TContext context;
144 TFile* histfile =
new TFile(fName,
"recreate");
146 gnoiseMatrix00Vector->Write();
147 gtotalCountsVector->Write();
148 ginvertAttempts->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 successfuly =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
double m_u2
Regularization Function Parameter 2.
double m_u0
Regularization Function Parameter 0.
std::string m_outputName
file name for histogram output
const int m_numberofADCPoints
length of ECLDsp waveform
double m_u1
Regularization Function Parameter 1.
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.