20#include "TFitResult.h"
28 if (mTotalNevents == 0) {
30 LOG(warning) <<
"RESULT: Empty slot, ignoring";
32 }
else if (mIsReady) {
34 LOG(info) <<
"RESULT: ready";
42 for (
int iCh = 0; iCh < sNCHANNELS; iCh++) {
43 const auto nEntries = mArrEntries[iCh];
46 LOG(info) <<
"RESULT: pending channels";
52 LOG(info) <<
"RESULT: NO pending channels";
57 LOG(info) <<
"RESULT: should be never happen";
72 mHistogram.
add(histView);
74 for (
int iCh = 0; iCh < sNCHANNELS; iCh++) {
75 if (mBitsetGoodChIDs.test(iCh) || mBitsetBadChIDs.test(iCh)) {
79 auto sliceChID = mHistogram.
getSliceY(iCh);
81 for (
auto& en : sliceChID) {
84 mArrEntries[iCh] = nEntries;
85 mTotalNevents += nEntries;
87 mBitsetGoodChIDs.set(iCh);
90 const auto totalNCheckedChIDs = mBitsetGoodChIDs.count() + mBitsetBadChIDs.count();
91 if (totalNCheckedChIDs == sNCHANNELS) {
98 LOG(info) <<
"MERGING";
102 }
else if (mIsFirstTF && !prev->
isFirstTF()) {
108 if (mCurrentSlot == 0) {
110 for (
int iCh = 0; iCh < sNCHANNELS; iCh++) {
113 mBitsetBadChIDs.set(iCh);
123 uint32_t statusBits{};
124 double minFitRange{0};
125 double maxFitRange{0};
132 const float meanHist = hist->GetMean();
133 const float rmsHist = hist->GetRMS();
134 const float stat = hist->Integral();
142 float constantGaus{};
147 TFitResultPtr resultFit = hist->Fit(
"gaus",
"0SQ",
"", minFitRange, maxFitRange);
148 if (((
int)resultFit) == 0) {
149 constantGaus = resultFit->Parameters()[0];
150 meanGaus = resultFit->Parameters()[1];
151 sigmaGaus = resultFit->Parameters()[2];
152 fitChi2 = resultFit->Chi2();
153 statusBits |= (1 << 0);
156 statusBits |= (2 << 0);
157 LOG(
debug) <<
"Bad gaus fit: meanGaus " << meanGaus <<
" sigmaGaus " << sigmaGaus <<
" meanHist " << meanHist <<
" rmsHist " << rmsHist <<
"resultFit " << ((
int)resultFit);
160 if (listHists !=
nullptr) {
161 auto histPtr = hist.release();
163 histPtr->SetName(histName.c_str());
164 listHists->Add(histPtr);
166 return SpectraInfoObject{meanGaus, sigmaGaus, constantGaus, fitChi2, meanHist, rmsHist, stat, statusBits};
171 TList* listHists =
nullptr;
172 bool storeHists{
false};
173 if (extraInfo.size() > 0) {
175 listHists =
new TList();
176 listHists->SetOwner(
true);
177 listHists->SetName(
"output");
180 for (
unsigned int iCh = 0; iCh < sNCHANNELS; ++iCh) {
189 TFile fileHists(
filename.c_str(),
"RECREATE");
190 fileHists.WriteObject(listHists, listHists->GetName(),
"SingleKey");
194 return calibrationObject;
199 LOG(info) <<
"Total entries: " << mHistogram.
getSum();
201 LOG(info) <<
"Number of good channels: " << mBitsetGoodChIDs.count();
202 LOG(info) <<
"Number of bad channels: " << mBitsetBadChIDs.count();
203 LOG(info) <<
"Number of pending channels: " << sNCHANNELS - (mBitsetGoodChIDs.count() + mBitsetBadChIDs.count());
204 LOG(info) <<
"mIsFirstTF " << mIsFirstTF;
205 LOG(info) <<
"mIsReady " << mIsReady;
1D messeageable histo class
static const CalibParam & Instance()
void merge(FT0TimeOffsetSlotContainer *prev)
SpectraInfoObject getSpectraInfoObject(std::size_t channelID, TList *listHists) const
FT0TimeOffsetSlotContainer(std::size_t minEntries)
bool hasEnoughEntries() const
void fill(const gsl::span< const float > &data)
auto getHistogram() const
TimeSpectraInfoObject generateCalibrationObject(long tsStartMS, long tsEndMS, const std::string &pathToHists) const
std::string to_string(gsl::span< T, Size > span)
std::size_t mMaxEntriesThreshold
SpectraInfoObject mSumTimeAC
SpectraInfoObject mDiffTimeCA
std::array< SpectraInfoObject, o2::ft0::Geometry::Nchannels > mTime
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"