From c1c039e18b807ae4604c7afcea5920ea42886dde Mon Sep 17 00:00:00 2001 From: "se.gorbunov" <se.gorbunov@gsi.de> Date: Mon, 27 Nov 2023 16:40:47 +0000 Subject: [PATCH] qa: fiw warnings in the histogram fit --- core/qa/CbmQaUtil.cxx | 17 ++++++--- reco/detectors/much/qa/CbmMuchHitFinderQa.cxx | 38 ++++++++++++------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/core/qa/CbmQaUtil.cxx b/core/qa/CbmQaUtil.cxx index d2cee90e54..746d067ca8 100644 --- a/core/qa/CbmQaUtil.cxx +++ b/core/qa/CbmQaUtil.cxx @@ -134,19 +134,25 @@ namespace cbm::qa::util // check if the histogram has enough entries excluding underflow and overflow bins double entries = 0.; for (int i = 1; i <= pHist->GetNbinsX(); ++i) { - entries += fabs(pHist->GetBinContent(i)); + if (fabs(pHist->GetBinContent(i)) > 0.) { + entries++; + } } // fit the histogram in quite mode if (entries > 0) { - pHist->Fit(&fit, "Q"); - TF1* f = pHist->GetFunction("FitKaniadakisGaussian"); assert(f); - // calculate the Std Dev - f->SetParameter(1, sqrt(f->CentralMoment(2, xMin, xMax))); + // calculate the Std Dev and put it to parameter [1] + + if (entries > 1) { + f->SetParameter(1, sqrt(f->CentralMoment(2, xMin, xMax))); + } + else { + f->SetParameter(1, f->GetParameter(3)); + } f->SetParError(1, f->GetParError(3)); // fix some parameters to prevent them from showing up in the stat window @@ -154,7 +160,6 @@ namespace cbm::qa::util f->FixParameter(2, f->GetParameter(2)); f->FixParameter(3, f->GetParameter(3)); f->FixParameter(4, f->GetParameter(4)); - retValue = std::tuple(f->GetParameter(0), f->GetParameter(1)); } diff --git a/reco/detectors/much/qa/CbmMuchHitFinderQa.cxx b/reco/detectors/much/qa/CbmMuchHitFinderQa.cxx index f8d104a0d1..7880bded8b 100644 --- a/reco/detectors/much/qa/CbmMuchHitFinderQa.cxx +++ b/reco/detectors/much/qa/CbmMuchHitFinderQa.cxx @@ -28,12 +28,7 @@ #include "CbmMuchPoint.h" #include "CbmQaCanvas.h" #include "CbmTimeSlice.h" - #include "FairRootManager.h" -#include <FairSink.h> -#include <FairTask.h> -#include <Logger.h> - #include "TArrayI.h" #include "TF1.h" #include "TFile.h" @@ -41,6 +36,11 @@ #include "TParameter.h" #include "TPaveStats.h" #include "TStyle.h" + +#include <FairSink.h> +#include <FairTask.h> +#include <Logger.h> + #include <TClonesArray.h> #include <TGenericClassInfo.h> #include <TH1.h> @@ -312,7 +312,9 @@ void CbmMuchHitFinderQa::Exec(Option_t*) void CbmMuchHitFinderQa::FinishTask() { - if (fVerbose > 0) { printf(" CbmMuchHitFinderQa FinishTask\n"); } + if (fVerbose > 0) { + printf(" CbmMuchHitFinderQa FinishTask\n"); + } gStyle->SetPaperSize(20, 20); @@ -333,11 +335,13 @@ void CbmMuchHitFinderQa::FinishTask() for (UInt_t i = 0; i < vResHistos.size(); i++) { TH1D* histo = vResHistos[i]; histo->Sumw2(); - histo->Fit("gaus", "Q"); - auto f = histo->GetFunction("gaus"); - if (f) { - f->SetLineWidth(3); - f->SetLineColor(kRed); + if (histo->GetRMS() > 0.) { + histo->Fit("gaus", "Q"); + auto f = histo->GetFunction("gaus"); + if (f) { + f->SetLineWidth(3); + f->SetLineColor(kRed); + } } // histo->SetStats(kTRUE); } @@ -598,7 +602,9 @@ void CbmMuchHitFinderQa::PullsQa() continue; } - if (verbose) { printf(" file %i event %i pointId %i", link.GetFile(), link.GetEntry(), link.GetIndex()); } + if (verbose) { + printf(" file %i event %i pointId %i", link.GetFile(), link.GetEntry(), link.GetIndex()); + } CbmMuchPoint* point = (CbmMuchPoint*) fPoints->Get(link); Double_t xMC = 0.5 * (point->GetXIn() + point->GetXOut()); @@ -650,7 +656,9 @@ void CbmMuchHitFinderQa::ClusterDeconvQa() for (Int_t iPoint = 0; iPoint < nMuchPoints; iPoint++) { link.SetIndex(iPoint); link.SetWeight(0.); - if (IsSignalPoint(link)) { fSignalPoints.SetVal(fSignalPoints.GetVal() + 1); } + if (IsSignalPoint(link)) { + fSignalPoints.SetVal(fSignalPoints.GetVal() + 1); + } vPoints.push_back(link); } } @@ -678,7 +686,9 @@ void CbmMuchHitFinderQa::ClusterDeconvQa() assert(it != vPoints.end()); if (it->GetWeight() > 0.) continue; it->SetWeight(1.); - if (IsSignalPoint(pointLink)) { fSignalHits.SetVal(fSignalHits.GetVal() + 1); } + if (IsSignalPoint(pointLink)) { + fSignalHits.SetVal(fSignalHits.GetVal() + 1); + } } } } -- GitLab