From 6985a74546215acc46f2685b78c84ecf65b9fe65 Mon Sep 17 00:00:00 2001 From: SCHOTTER Romain <47983209+romainschotter@users.noreply.github.com> Date: Mon, 26 Jan 2026 23:07:50 +0100 Subject: [PATCH 1/2] Add option to prevent crash on null CCDB objects Added a configurable option to prevent crashes when CCDB objects are missing, allowing for dummy values to be filled instead. Initialized histogram pointers to nullptr. --- PWGLF/TableProducer/Common/mcCentrality.cxx | 28 +++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/PWGLF/TableProducer/Common/mcCentrality.cxx b/PWGLF/TableProducer/Common/mcCentrality.cxx index 1dec9b7fb28..68670c1f11a 100644 --- a/PWGLF/TableProducer/Common/mcCentrality.cxx +++ b/PWGLF/TableProducer/Common/mcCentrality.cxx @@ -66,12 +66,13 @@ struct McCentrality { ConfigurableAxis binsMultiplicity{"binsMultiplicity", {1000, 0, 5000}, "Binning of the multiplicity axis"}; Configurable fillFt0A{"fillFt0A", false, "Fills the FT0A histogram"}; Configurable fillFt0C{"fillFt0C", false, "Fills the FT0C histogram"}; + Configurable doNotCrashOnNull{"doNotCrashOnNull", false, "If ccdb object does not exist, fill with dummy values"}; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - TH1F* h1dFT0M; - TH1F* h1dFT0A; - TH1F* h1dFT0C; + TH1F* h1dFT0M = nullptr; + TH1F* h1dFT0A = nullptr; + TH1F* h1dFT0C = nullptr; // TH1F* h1dFDD; // TH1F* h1dNTP; @@ -99,13 +100,17 @@ struct McCentrality { histos.add("FT0C/percentilevsMult", "FT0C percentile.", HistType::kTH2D, {{binsPercentile, "FT0C percentile"}, {binsMultiplicity, "FT0C mult."}}); } - TList* lOfInput; + TList* lOfInput = nullptr; if (path.value.rfind("ccdb://", 0) == 0) { // Getting post calib. from CCDB path.value.replace(0, 7, ""); lOfInput = ccdb->get(path); if (!lOfInput) { - LOG(fatal) << "Could not find the calibration TList from CCDB in path " << path; - return; + if (doNotCrashOnNull) { + LOG(info) << "Could not find the calibration TList from CCDB in path " << path << ", will fill tables with dummy values"; + } else { + LOG(fatal) << "Could not find the calibration TList from CCDB in path " << path; + return; + } } } else { // Getting post calib. from file TFile* f = TFile::Open(path.value.c_str(), "READ"); @@ -121,11 +126,18 @@ struct McCentrality { LOG(fatal) << "The input file " << path.value << " does not contain the TList ccdb_object"; } } - auto getHist = [lOfInput](const char* name) -> TH1F* { + auto getHist = [this, lOfInput](const char* name) -> TH1F* { + if (!lOfInput) { + return nullptr; + } auto hist = static_cast(lOfInput->FindObject(name)); if (!hist) { lOfInput->ls(); - LOG(fatal) << "Could not open histogram " << name << " from TList"; + if (this->doNotCrashOnNull) { + LOG(info) << "Could not open histogram " << name << " from TList, will fill tables with dummy values"; + } else { + LOG(fatal) << "Could not open histogram " << name << " from TList"; + } } return hist; }; From 09ec1be4978a5db6d20360005e2ef718dacbff03 Mon Sep 17 00:00:00 2001 From: SCHOTTER Romain <47983209+romainschotter@users.noreply.github.com> Date: Mon, 26 Jan 2026 23:13:34 +0100 Subject: [PATCH 2/2] Fill with dummy values - fill with dummy values - Switch h1dFT0M to h1dFT0A and h1dFT0C when requiring to fill h1dFT0A and h1dFT0C histograms --- PWGLF/TableProducer/Common/mcCentrality.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/PWGLF/TableProducer/Common/mcCentrality.cxx b/PWGLF/TableProducer/Common/mcCentrality.cxx index 68670c1f11a..8eaaf6fd768 100644 --- a/PWGLF/TableProducer/Common/mcCentrality.cxx +++ b/PWGLF/TableProducer/Common/mcCentrality.cxx @@ -159,13 +159,19 @@ struct McCentrality { const float nFT0M = nFT0A + nFT0C; // const float nFV0A = mCounter.countFV0A(mcParticles); - const float valueCentFT0M = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFT0M)); + float valueCentFT0M = 105.0f; + if (h1dFT0M) + valueCentFT0M = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFT0M)); if (fillFt0A) { - const float valueCentFT0A = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFT0A)); + float valueCentFT0A = 105.0f; + if (h1dFT0A) + valueCentFT0A = h1dFT0A->GetBinContent(h1dFT0A->FindBin(nFT0A)); centFT0A(valueCentFT0A); } if (fillFt0C) { - const float valueCentFT0C = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFT0C)); + float valueCentFT0C = 105.0f; + if (h1dFT0C) + valueCentFT0C = h1dFT0C->GetBinContent(h1dFT0C->FindBin(nFT0C)); centFT0C(valueCentFT0C); } // const float valueCentFV0A = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFV0A));