From 48a19f91c84f8fdd22b355fa6d810c8e15bb11b2 Mon Sep 17 00:00:00 2001 From: Youssef El Mard Bouziani Date: Tue, 24 Feb 2026 11:53:03 +0100 Subject: [PATCH 1/3] Add optional PCM material-budget weights in PCMPCM Add a V0 photon material-budget weight table (Omega MB weights) and join it in the PCMPCM pi0/eta workflow. The weights are applied only when the joined column is available, using compile-time guarded access. Introduce a configurable switch (runWithMBWeights) in MaterialBudgetWeights: - false: no CCDB query, write weight=1 - true: require CCDB histogram and abort if missing --- PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h | 21 ++-- PWGEM/PhotonMeson/DataModel/gammaTables.h | 10 ++ .../PhotonMeson/TableProducer/CMakeLists.txt | 4 + .../TableProducer/materialBudgetWeights.cxx | 27 ++++++ .../Tasks/Pi0EtaToGammaGammaPCMPCM.cxx | 4 +- .../PhotonMeson/Utils/MaterialBudgetWeights.h | 95 +++++++++++++++++++ 6 files changed, 154 insertions(+), 7 deletions(-) create mode 100644 PWGEM/PhotonMeson/TableProducer/materialBudgetWeights.cxx create mode 100644 PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h diff --git a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h index 965d88ddcc0..998c6400af2 100644 --- a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h +++ b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h @@ -226,11 +226,11 @@ struct Pi0EtaToGammaGamma { //--------------------------------------------------------------------------- // Preslices and partitions o2::framework::SliceCache cache; - o2::framework::PresliceOptional>> perCollision_pcm = o2::aod::v0photonkf::emphotoneventId; - o2::framework::PresliceOptional> perCollision_emc = o2::aod::emccluster::emphotoneventId; - o2::framework::PresliceOptional> perCollision_phos = o2::aod::phoscluster::emphotoneventId; - o2::framework::PresliceOptional>> perCollision_electron = o2::aod::emprimaryelectronda::emphotoneventId; - + o2::framework::PresliceOptional< + o2::soa::Filtered>> perCollision_pcm = o2::aod::v0photonkf::emeventId; + o2::framework::PresliceOptional> perCollision_emc = o2::aod::emccluster::emeventId; + o2::framework::PresliceOptional> perCollision_phos = o2::aod::phoscluster::emeventId; + o2::framework::PresliceOptional>> perCollision_electron = o2::aod::emprimaryelectron::emeventId; o2::framework::PresliceOptional perEMCClusterMT = o2::aod::trackmatching::emEmcClusterId; o2::framework::PresliceOptional perEMCClusterMS = o2::aod::trackmatching::emEmcClusterId; @@ -879,7 +879,16 @@ struct Pi0EtaToGammaGamma { continue; } - fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), weight); + float wpair = weight; + + if constexpr (requires { g1.omegaMBWeight(); }) { + wpair *= g1.omegaMBWeight(); + } + if constexpr (requires { g2.omegaMBWeight(); }) { + wpair *= g2.omegaMBWeight(); + } + + fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), wpair); if (std::find(used_photonIds_per_col.begin(), used_photonIds_per_col.end(), g1.globalIndex()) == used_photonIds_per_col.end()) { emh1->AddTrackToEventPool(key_df_collision, o2::aod::pwgem::dilepton::utils::EMTrack(g1.pt(), g1.eta(), g1.phi(), 0)); diff --git a/PWGEM/PhotonMeson/DataModel/gammaTables.h b/PWGEM/PhotonMeson/DataModel/gammaTables.h index 9b680aed2c9..51f3cd46c29 100644 --- a/PWGEM/PhotonMeson/DataModel/gammaTables.h +++ b/PWGEM/PhotonMeson/DataModel/gammaTables.h @@ -720,6 +720,16 @@ DECLARE_SOA_TABLE(NonLinV0s, "AOD", "NONLINV0", //! table of non lin corrected v DECLARE_SOA_TABLE(NonLinEmcClusters, "AOD", "NONLINEMCCLUSTER", //! table of non lin corrected values for EMCal Photons (so far only E and pT) nonlin::CorrE, nonlin::CorrPt); //! +namespace v0photonMBweights +{ +DECLARE_SOA_COLUMN(OmegaMBWeight, omegaMBWeight, float); +} + +DECLARE_SOA_TABLE(V0PhotonOmegaMBWeights, "AOD", "V0PHOTONMBW", v0photonMBweights::OmegaMBWeight); // store MB weights. To be joined with V0PhotonsKF table at analysis level. + +using V0PhotonOmegaMBWeight = V0PhotonOmegaMBWeights::iterator; } // namespace o2::aod + + #endif // PWGEM_PHOTONMESON_DATAMODEL_GAMMATABLES_H_ diff --git a/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt b/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt index 20db3ba057e..a77cae30778 100644 --- a/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt +++ b/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt @@ -70,3 +70,7 @@ o2physics_add_dpl_workflow(non-lin-producer SOURCES nonLinProducer.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(material-budget-weights + SOURCES materialBudgetWeights.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::CCDB ROOT::Hist ROOT::Core + COMPONENT_NAME Analysis) diff --git a/PWGEM/PhotonMeson/TableProducer/materialBudgetWeights.cxx b/PWGEM/PhotonMeson/TableProducer/materialBudgetWeights.cxx new file mode 100644 index 00000000000..12a0ea2e6d8 --- /dev/null +++ b/PWGEM/PhotonMeson/TableProducer/materialBudgetWeights.cxx @@ -0,0 +1,27 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +/// +/// \file MaterialBudgetWeights.h +/// +/// \brief This code produces a table to retrieve material budget weights. The table is to be join with V0PhotonKF +/// +/// \author Youssef El Mard (youssef.el.mard.bouziani@cern.ch) + + +#include "PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h" +#include "Framework/runDataProcessing.h" + +using namespace o2::framework; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} \ No newline at end of file diff --git a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx index 6272af75da6..8894b6f3ec8 100644 --- a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx +++ b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx @@ -16,6 +16,7 @@ #include "PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/PhotonMeson/Utils/PairUtilities.h" +#include "PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h" #include #include @@ -26,11 +27,12 @@ using namespace o2::aod; using namespace o2::framework; using namespace o2::aod::pwgem::photonmeson::photonpair; -using MyV0Photons = o2::soa::Filtered>; +using MyV0Photons = o2::soa::Filtered>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ + adaptAnalysisTask(cfgc), adaptAnalysisTask>(cfgc, TaskName{"pi0eta-to-gammagamma-pcmpcm"}), }; } diff --git a/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h b/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h new file mode 100644 index 00000000000..f347bece074 --- /dev/null +++ b/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h @@ -0,0 +1,95 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +/// +/// \file materialBudgetWeights.cxx +/// +/// \brief This code produces a table to retrieve material budget weights. The table is to be join with V0PhotonKF +/// +/// \author Youssef El Mard (youssef.el.mard.bouziani@cern.ch) +/// + +#ifndef PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_ +#define PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_ + +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Logger.h" +#include +#include + + +using namespace o2; +using namespace o2::soa; +using namespace o2::framework; + +using MyV0PhotonsMB = o2::soa::Join; +using MyV0PhotonMB = MyV0PhotonsMB::iterator; + +struct MaterialBudgetWeights { + Produces omegaMBWeight; + + Configurable ccdbUrl{"ccdbUrl", "http://ccdb-test.cern.ch:8080", "CCDB url"}; + Configurable mbWeightsPath{"mbWeightsPath", "Users/y/yelmard/MaterialBudget/OmegaMBWeights", "Path of the mb weights"}; + Configurable runWithMBWeights{"runWithMBWeights", false, "Run task using material-budget weights for PCM photons"}; + + o2::ccdb::CcdbApi ccdbApi; + TH1F* hOmegaMBFromCCDB = nullptr; + + void init(InitContext&) + { + if (!runWithMBWeights) { + LOG(info) << "MaterialBudgetWeights: runWithMBWeights=false -> no CCDB query, will write weight=1"; + return; + } + + ccdbApi.init(ccdbUrl.value); + std::map metadata; + LOG(info) << "MaterialBudgetWeights: loading Omega MB histogram from CCDB at path: " << mbWeightsPath.value; + + hOmegaMBFromCCDB = ccdbApi.retrieveFromTFileAny(mbWeightsPath, metadata, -1); + + if (!hOmegaMBFromCCDB) { + LOG(fatal) << "MaterialBudgetWeights: runWithMBWeights=true but CCDB object is missing. Path=" << mbWeightsPath.value; + } + } + + float computeMBWeight(float v0Rxy) + { + if (!hOmegaMBFromCCDB) { + LOG(fatal) << "MaterialBudgetWeights: internal error: histogram nullptr while runWithMBWeights=true"; + } + + int binMBWeight = hOmegaMBFromCCDB->FindBin(v0Rxy); + if (binMBWeight < 1 || binMBWeight > hOmegaMBFromCCDB->GetNbinsX()) { + LOG(debug) << "MaterialBudgetWeights: v0Rxy out of histogram range, returning 1"; + return 1.f; + } + + return hOmegaMBFromCCDB->GetBinContent(binMBWeight); + } + + void process(MyV0PhotonMB const& v0) + { + if (!runWithMBWeights) { + omegaMBWeight(1.f); + return; + } + + omegaMBWeight(computeMBWeight(v0.v0radius())); + } +}; + + +#endif // PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_ \ No newline at end of file From 947616059a4ae3a47c98efb2a468ac8b54365087 Mon Sep 17 00:00:00 2001 From: Youssef El Mard Bouziani Date: Tue, 24 Feb 2026 13:42:00 +0100 Subject: [PATCH 2/3] Apply formatting fixes --- PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h | 3 ++- PWGEM/PhotonMeson/DataModel/gammaTables.h | 8 +++----- .../TableProducer/materialBudgetWeights.cxx | 4 ++-- PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx | 2 +- PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h | 11 ++++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h index 998c6400af2..bb2bbd88633 100644 --- a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h +++ b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h @@ -227,7 +227,8 @@ struct Pi0EtaToGammaGamma { // Preslices and partitions o2::framework::SliceCache cache; o2::framework::PresliceOptional< - o2::soa::Filtered>> perCollision_pcm = o2::aod::v0photonkf::emeventId; + o2::soa::Filtered>> + perCollision_pcm = o2::aod::v0photonkf::emeventId; o2::framework::PresliceOptional> perCollision_emc = o2::aod::emccluster::emeventId; o2::framework::PresliceOptional> perCollision_phos = o2::aod::phoscluster::emeventId; o2::framework::PresliceOptional>> perCollision_electron = o2::aod::emprimaryelectron::emeventId; diff --git a/PWGEM/PhotonMeson/DataModel/gammaTables.h b/PWGEM/PhotonMeson/DataModel/gammaTables.h index 51f3cd46c29..02b7a1b5fc7 100644 --- a/PWGEM/PhotonMeson/DataModel/gammaTables.h +++ b/PWGEM/PhotonMeson/DataModel/gammaTables.h @@ -433,9 +433,9 @@ using EMPrimaryElectronDaEMEventId = EMPrimaryElectronDaEMEventIds::iterator; namespace v0photonsphivpsi { -DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! +DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! DECLARE_SOA_INDEX_COLUMN(EMPhotonEvent, emphotonevent); //! -DECLARE_SOA_COLUMN(PhiV, phiv, float); //! +DECLARE_SOA_COLUMN(PhiV, phiv, float); //! DECLARE_SOA_COLUMN(PsiPair, psipair, float); } // namespace v0photonsphivpsi DECLARE_SOA_TABLE(V0PhotonsPhiVPsi, "AOD", "V0PHOTONPHIVPSI", //! @@ -727,9 +727,7 @@ DECLARE_SOA_COLUMN(OmegaMBWeight, omegaMBWeight, float); DECLARE_SOA_TABLE(V0PhotonOmegaMBWeights, "AOD", "V0PHOTONMBW", v0photonMBweights::OmegaMBWeight); // store MB weights. To be joined with V0PhotonsKF table at analysis level. -using V0PhotonOmegaMBWeight = V0PhotonOmegaMBWeights::iterator; +using V0PhotonOmegaMBWeight = V0PhotonOmegaMBWeights::iterator; } // namespace o2::aod - - #endif // PWGEM_PHOTONMESON_DATAMODEL_GAMMATABLES_H_ diff --git a/PWGEM/PhotonMeson/TableProducer/materialBudgetWeights.cxx b/PWGEM/PhotonMeson/TableProducer/materialBudgetWeights.cxx index 12a0ea2e6d8..9759d1ec5a1 100644 --- a/PWGEM/PhotonMeson/TableProducer/materialBudgetWeights.cxx +++ b/PWGEM/PhotonMeson/TableProducer/materialBudgetWeights.cxx @@ -15,8 +15,8 @@ /// /// \author Youssef El Mard (youssef.el.mard.bouziani@cern.ch) - #include "PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h" + #include "Framework/runDataProcessing.h" using namespace o2::framework; @@ -24,4 +24,4 @@ using namespace o2::framework; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} \ No newline at end of file +} diff --git a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx index 8894b6f3ec8..8a1c1c9992c 100644 --- a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx +++ b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx @@ -15,8 +15,8 @@ #include "PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" #include "PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" #include #include diff --git a/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h b/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h index f347bece074..16e029d9d61 100644 --- a/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h +++ b/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h @@ -19,23 +19,25 @@ #ifndef PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_ #define PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_ +#include +#include + #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/Logger.h" +#include #include #include - using namespace o2; using namespace o2::soa; using namespace o2::framework; using MyV0PhotonsMB = o2::soa::Join; -using MyV0PhotonMB = MyV0PhotonsMB::iterator; +using MyV0PhotonMB = MyV0PhotonsMB::iterator; struct MaterialBudgetWeights { Produces omegaMBWeight; @@ -91,5 +93,4 @@ struct MaterialBudgetWeights { } }; - -#endif // PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_ \ No newline at end of file +#endif // PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_ From 811cfa007120dc4a7e7342d64028a0c81b38f6de Mon Sep 17 00:00:00 2001 From: Youssef El Mard Bouziani Date: Tue, 24 Feb 2026 14:07:55 +0100 Subject: [PATCH 3/3] Apply clang-format include ordering --- PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h b/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h index 16e029d9d61..2d9e19f081d 100644 --- a/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h +++ b/PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h @@ -19,9 +19,6 @@ #ifndef PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_ #define PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_ -#include -#include - #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "Framework/ASoAHelpers.h" @@ -32,6 +29,9 @@ #include #include +#include +#include + using namespace o2; using namespace o2::soa; using namespace o2::framework;