From f45018bc29ab3ae8d2f22c27fcafeeba315ccf59 Mon Sep 17 00:00:00 2001 From: louisemillot Date: Mon, 23 Feb 2026 20:57:35 +0100 Subject: [PATCH 1/2] adding files for slim tables for futur standalone embedding --- PWGJE/DataModel/SlimTables.h | 80 +++++++++ PWGJE/TableProducer/CMakeLists.txt | 5 + PWGJE/TableProducer/slimTablesProducer.cxx | 191 +++++++++++++++++++++ 3 files changed, 276 insertions(+) create mode 100644 PWGJE/DataModel/SlimTables.h create mode 100644 PWGJE/TableProducer/slimTablesProducer.cxx diff --git a/PWGJE/DataModel/SlimTables.h b/PWGJE/DataModel/SlimTables.h new file mode 100644 index 00000000000..13fa3ea16f4 --- /dev/null +++ b/PWGJE/DataModel/SlimTables.h @@ -0,0 +1,80 @@ +// 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 SlimTables.h +/// \author Millot Louise +/// \since 2024-11-27 +/// \brief Header for the SlimTables task for the analysis of the reduced tables. +/// + +#ifndef PWGJE_DATAMODEL_SLIMTABLES_H_ +#define PWGJE_DATAMODEL_SLIMTABLES_H_ + +#include +#include + +#include + +namespace o2::aod +{ +DECLARE_SOA_TABLE(SlimCollisions, "AOD", "SlimCollisions", + o2::soa::Index<>, + o2::aod::collision::PosZ); +using SlimCollision = SlimCollisions::iterator; +DECLARE_SOA_TABLE(SlMcCollisions, "AOD", "SlMcCollisions", + o2::soa::Index<>, + o2::aod::mccollision::PosZ); +using SlMcCollision = SlMcCollisions::iterator; +namespace slimtracks +{ +DECLARE_SOA_INDEX_COLUMN(SlimCollision, slimCollision); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Px, px, float); +DECLARE_SOA_COLUMN(Py, py, float); +DECLARE_SOA_COLUMN(Pz, pz, float); +DECLARE_SOA_COLUMN(E, e, float); +} // namespace slimtracks +DECLARE_SOA_TABLE(SlimTracks, "AOD", "SlimTracks", + o2::soa::Index<>, + slimtracks::SlimCollisionId, + slimtracks::Pt, + slimtracks::Eta, + slimtracks::Phi, + slimtracks::Px, + slimtracks::Py, + slimtracks::Pz, + slimtracks::E); +using SlimTrack = SlimTracks::iterator; +namespace slimparticles +{ +DECLARE_SOA_INDEX_COLUMN(SlMcCollision, slMcCollision); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Px, px, float); +DECLARE_SOA_COLUMN(Py, py, float); +DECLARE_SOA_COLUMN(Pz, pz, float); +} // namespace slimparticles +DECLARE_SOA_TABLE(SlimParticles, "AOD", "SlimParticles", + o2::soa::Index<>, + slimparticles::SlMcCollisionId, + slimparticles::Pt, + slimparticles::Eta, + slimparticles::Phi, + slimparticles::Px, + slimparticles::Py, + slimparticles::Pz); +using SlimParticle = SlimParticles::iterator; +} // namespace o2::aod +#endif // PWGJE_DATAMODEL_SLIMTABLES_H_ diff --git a/PWGJE/TableProducer/CMakeLists.txt b/PWGJE/TableProducer/CMakeLists.txt index f0d91e9c98b..3e7510f56b9 100644 --- a/PWGJE/TableProducer/CMakeLists.txt +++ b/PWGJE/TableProducer/CMakeLists.txt @@ -105,3 +105,8 @@ o2physics_add_dpl_workflow(emcal-cluster-hadronic-correction-task SOURCES emcalClusterHadronicCorrectionTask.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::EMCALBase O2::EMCALReconstruction COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(slim-tables-producer + SOURCES slimTablesProducer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGJE/TableProducer/slimTablesProducer.cxx b/PWGJE/TableProducer/slimTablesProducer.cxx new file mode 100644 index 00000000000..1f7910ef30a --- /dev/null +++ b/PWGJE/TableProducer/slimTablesProducer.cxx @@ -0,0 +1,191 @@ +// 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 slimTablesProducer.cxx +/// \brief Task to produce a reduced version of Tables for tracks, collisions, mcparticles and mccollisions. +/// \author Millot Louise + +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/SlimTables.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct SlimTablesProducer { + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable checkCentFT0M{"checkCentFT0M", false, "0: centFT0C as default, 1: use centFT0M estimator"}; + Configurable centralityMin{"centralityMin", -999, ""}; + Configurable centralityMax{"centralityMax", 999, ""}; + Configurable minPt{"minPt", 0.15, "min pT to save"}; + Configurable maxPt{"maxPt", 200.0, "max pT to save"}; + Configurable minEta{"minEta", -0.9, "min eta to save"}; + Configurable maxEta{"maxEta", 0.9, "max eta to save"}; + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + Configurable eventSelections{"eventSelections", "sel8", "Event selection"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "flag to choose to reject min. bias gap events; jet-level rejection can also be applied at the jet finder level for jets only, here rejection is applied for collision and track process functions for the first time, and on jets in case it was set to false at the jet finder level"}; + Configurable applyRCTSelections{"applyRCTSelections", true, "decide to apply RCT selections"}; + + std::vector eventSelectionBits; + bool doSumw2 = false; + + void init(InitContext&) + { + doSumw2 = skipMBGapEvents; // true or false : storage of square erros when jet-jet + + AxisSpec centralityAxis = {1200, -10., 110., "Centrality"}; + + histos.add("h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + histos.add("h2_centrality_collisions", "event status vs. centrality;entries;centrality", {HistType::kTH2F, {centralityAxis, {4, 0.0, 4.0}}}, doSumw2); + auto hColl = histos.get(HIST("h_collisions")); + hColl->GetXaxis()->SetBinLabel(1, "All"); + hColl->GetXaxis()->SetBinLabel(2, "eventSelection"); + + histos.add("h_mcCollMCD_counts_weight", "MC event status;event status;weighted entries", {HistType::kTH1F, {{5, 0.0, 5.0}}}); + histos.add("h2_centrality_MCD", "mc event status vs. centrality;entries;centrality", {HistType::kTH2F, {centralityAxis, {4, 0.0, 4.0}}}, doSumw2); + auto hMCD = histos.get(HIST("h_mcCollMCD_counts_weight")); + hMCD->GetXaxis()->SetBinLabel(1, "All"); + hMCD->GetXaxis()->SetBinLabel(2, "Has MC coll + eventSelection "); + + histos.add("h_mcCollMCP_counts_weight", "MC event status;event status;weighted entries", {HistType::kTH1F, {{7, 0.0, 7.0}}}); + histos.add("h2_centrality_MCP", "mc event status vs. centrality;entries;centrality", {HistType::kTH2F, {centralityAxis, {4, 0.0, 4.0}}}, doSumw2); + auto hMCP = histos.get(HIST("h_mcCollMCP_counts_weight")); + hMCP->GetXaxis()->SetBinLabel(1, "All"); + hMCP->GetXaxis()->SetBinLabel(2, "ZVertex"); + hMCP->GetXaxis()->SetBinLabel(3, "Collision size"); + hMCP->GetXaxis()->SetBinLabel(4, "eventSelection"); + hMCP->GetXaxis()->SetBinLabel(5, "eventSelectionMC"); + + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + } + + Produces slimCollisions; + Produces slimMcCollisions; + Produces slimTracks; + Produces slimParticles; + + Filter trackFilter = (aod::jtrack::pt >= minPt && aod::jtrack::pt < maxPt && aod::jtrack::eta > minEta && aod::jtrack::eta < maxEta); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && + (checkCentFT0M ? aod::jcollision::centFT0M : aod::jcollision::centFT0C) >= centralityMin && + (checkCentFT0M ? aod::jcollision::centFT0M : aod::jcollision::centFT0C) < centralityMax); + Filter mcCollisionFilter = (nabs(aod::jmccollision::posZ) < vertexZCut && aod::jmccollision::centFT0M >= centralityMin && aod::jmccollision::centFT0M < centralityMax); // no centFT0C for mccollisions, using centFT0M for both + Filter particleCuts = (aod::jmcparticle::pt >= minPt && aod::jmcparticle::pt < maxPt && aod::jmcparticle::eta > minEta && aod::jmcparticle::eta < maxEta); + + void processData(soa::Filtered::iterator const& collision, + soa::Filtered> const& tracks) + { + histos.fill(HIST("h_collisions"), 0.5); + float centrality = -1.0; + checkCentFT0M ? centrality = collision.centFT0M() : centrality = collision.centFT0C(); + histos.fill(HIST("h2_centrality_collisions"), centrality, 0.5, 1.0); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, false, applyRCTSelections)) { + return; + } + histos.fill(HIST("h_collisions"), 1.5); + + slimCollisions(collision.posZ()); + auto slimCollIndex = slimCollisions.lastIndex(); + for (const auto& track : tracks) { + float mass = jetderiveddatautilities::mPion; + float p = track.pt() * std::cosh(track.eta()); + float energy = std::sqrt(p * p + mass * mass); + slimTracks(slimCollIndex, track.pt(), track.eta(), track.phi(), track.px(), track.py(), track.pz(), energy); + } + } + PROCESS_SWITCH(SlimTablesProducer, processData, "process collisions and tracks for Data and MCD", false); + + void processMCD(soa::Filtered::iterator const& collision, + soa::Join const&, // join the weight + soa::Filtered> const& tracks) + { + float eventWeight = collision.mcCollision_as>().weight(); + histos.fill(HIST("h_mcCollMCD_counts_weight"), 0.5, eventWeight); + + float centrality = -1.0; + checkCentFT0M ? centrality = collision.centFT0M() : centrality = collision.centFT0C(); + histos.fill(HIST("h2_centrality_MCD"), centrality, 0.5, eventWeight); + + if (!collision.has_mcCollision()) { + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents, applyRCTSelections)) { + return; + } + histos.fill(HIST("h_mcCollMCD_counts_weight"), 1.5, eventWeight); + auto slimCollIndex = slimCollisions.lastIndex(); + slimCollisions(collision.posZ()); + for (const auto& track : tracks) { + float mass = jetderiveddatautilities::mPion; + float p = track.pt() * std::cosh(track.eta()); + float energy = std::sqrt(p * p + mass * mass); + slimTracks(slimCollIndex, track.pt(), track.eta(), track.phi(), track.px(), track.py(), track.pz(), energy); + } + } + PROCESS_SWITCH(SlimTablesProducer, processMCD, "process collisions and tracks for MCD", false); + + void processMCP(soa::Filtered::iterator const& mcCollision, + soa::SmallGroups const& collisions, + soa::Filtered const& particles) + { + float eventWeight = mcCollision.weight(); + float centrality = mcCollision.centFT0M(); // checkCentFT0M ? centrality = mccollision.centFT0M() : centrality = mccollision.centFT0C(); + histos.fill(HIST("h_mcCollMCP_counts_weight"), 0.5, eventWeight); + histos.fill(HIST("h2_centrality_MCP"), centrality, 0.5, eventWeight); + if (std::abs(mcCollision.posZ()) > vertexZCut) { + return; + } + histos.fill(HIST("h_mcCollMCP_counts_weight"), 1.5, eventWeight); + if (collisions.size() < 1) { + return; + } + histos.fill(HIST("h_mcCollMCP_counts_weight"), 2.5, eventWeight); + bool hasSel8Coll = false; + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents, applyRCTSelections)) { // look if the rec collision associated to the mc collision passes the event selection + hasSel8Coll = true; + } + } + if (!hasSel8Coll) { + return; + } + histos.fill(HIST("h_mcCollMCP_counts_weight"), 3.5, eventWeight); + if (!jetderiveddatautilities::selectMcCollision(mcCollision, skipMBGapEvents, applyRCTSelections)) { + return; + } + histos.fill(HIST("h_mcCollMCP_counts_weight"), 4.5, eventWeight); + auto slimMcCollIndex = slimMcCollisions.lastIndex(); + slimMcCollisions(mcCollision.posZ()); + for (const auto& particle : particles) { + slimParticles(slimMcCollIndex, particle.pt(), particle.eta(), particle.phi(), particle.px(), particle.py(), particle.pz()); + } + } + PROCESS_SWITCH(SlimTablesProducer, processMCP, "process mccollisions and mcparticles for MCD", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} From ba440d8342becf207f3818bafdf0da2b83a08565 Mon Sep 17 00:00:00 2001 From: louisemillot Date: Wed, 25 Feb 2026 14:26:42 +0100 Subject: [PATCH 2/2] adressing Nimas comment on declaration of tables in task --- PWGJE/DataModel/SlimTables.h | 80 ---------------------- PWGJE/TableProducer/slimTablesProducer.cxx | 57 ++++++++++++++- 2 files changed, 56 insertions(+), 81 deletions(-) delete mode 100644 PWGJE/DataModel/SlimTables.h diff --git a/PWGJE/DataModel/SlimTables.h b/PWGJE/DataModel/SlimTables.h deleted file mode 100644 index 13fa3ea16f4..00000000000 --- a/PWGJE/DataModel/SlimTables.h +++ /dev/null @@ -1,80 +0,0 @@ -// 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 SlimTables.h -/// \author Millot Louise -/// \since 2024-11-27 -/// \brief Header for the SlimTables task for the analysis of the reduced tables. -/// - -#ifndef PWGJE_DATAMODEL_SLIMTABLES_H_ -#define PWGJE_DATAMODEL_SLIMTABLES_H_ - -#include -#include - -#include - -namespace o2::aod -{ -DECLARE_SOA_TABLE(SlimCollisions, "AOD", "SlimCollisions", - o2::soa::Index<>, - o2::aod::collision::PosZ); -using SlimCollision = SlimCollisions::iterator; -DECLARE_SOA_TABLE(SlMcCollisions, "AOD", "SlMcCollisions", - o2::soa::Index<>, - o2::aod::mccollision::PosZ); -using SlMcCollision = SlMcCollisions::iterator; -namespace slimtracks -{ -DECLARE_SOA_INDEX_COLUMN(SlimCollision, slimCollision); -DECLARE_SOA_COLUMN(Pt, pt, float); -DECLARE_SOA_COLUMN(Eta, eta, float); -DECLARE_SOA_COLUMN(Phi, phi, float); -DECLARE_SOA_COLUMN(Px, px, float); -DECLARE_SOA_COLUMN(Py, py, float); -DECLARE_SOA_COLUMN(Pz, pz, float); -DECLARE_SOA_COLUMN(E, e, float); -} // namespace slimtracks -DECLARE_SOA_TABLE(SlimTracks, "AOD", "SlimTracks", - o2::soa::Index<>, - slimtracks::SlimCollisionId, - slimtracks::Pt, - slimtracks::Eta, - slimtracks::Phi, - slimtracks::Px, - slimtracks::Py, - slimtracks::Pz, - slimtracks::E); -using SlimTrack = SlimTracks::iterator; -namespace slimparticles -{ -DECLARE_SOA_INDEX_COLUMN(SlMcCollision, slMcCollision); -DECLARE_SOA_COLUMN(Pt, pt, float); -DECLARE_SOA_COLUMN(Eta, eta, float); -DECLARE_SOA_COLUMN(Phi, phi, float); -DECLARE_SOA_COLUMN(Px, px, float); -DECLARE_SOA_COLUMN(Py, py, float); -DECLARE_SOA_COLUMN(Pz, pz, float); -} // namespace slimparticles -DECLARE_SOA_TABLE(SlimParticles, "AOD", "SlimParticles", - o2::soa::Index<>, - slimparticles::SlMcCollisionId, - slimparticles::Pt, - slimparticles::Eta, - slimparticles::Phi, - slimparticles::Px, - slimparticles::Py, - slimparticles::Pz); -using SlimParticle = SlimParticles::iterator; -} // namespace o2::aod -#endif // PWGJE_DATAMODEL_SLIMTABLES_H_ diff --git a/PWGJE/TableProducer/slimTablesProducer.cxx b/PWGJE/TableProducer/slimTablesProducer.cxx index 1f7910ef30a..9941e23a4e0 100644 --- a/PWGJE/TableProducer/slimTablesProducer.cxx +++ b/PWGJE/TableProducer/slimTablesProducer.cxx @@ -16,7 +16,6 @@ #include "PWGJE/Core/JetDerivedDataUtilities.h" #include "PWGJE/DataModel/Jet.h" #include "PWGJE/DataModel/JetReducedData.h" -#include "PWGJE/DataModel/SlimTables.h" #include #include @@ -26,9 +25,65 @@ #include #include +#include + #include #include +namespace o2::aod +{ +DECLARE_SOA_TABLE(SlimCollisions, "AOD", "SlimCollisions", + o2::soa::Index<>, + o2::aod::collision::PosZ); +using SlimCollision = SlimCollisions::iterator; +DECLARE_SOA_TABLE(SlMcCollisions, "AOD", "SlMcCollisions", + o2::soa::Index<>, + o2::aod::mccollision::PosZ); +using SlMcCollision = SlMcCollisions::iterator; +namespace slimtracks +{ +DECLARE_SOA_INDEX_COLUMN(SlimCollision, slimCollision); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Px, px, float); +DECLARE_SOA_COLUMN(Py, py, float); +DECLARE_SOA_COLUMN(Pz, pz, float); +DECLARE_SOA_COLUMN(E, e, float); +} // namespace slimtracks +DECLARE_SOA_TABLE(SlimTracks, "AOD", "SlimTracks", + o2::soa::Index<>, + slimtracks::SlimCollisionId, + slimtracks::Pt, + slimtracks::Eta, + slimtracks::Phi, + slimtracks::Px, + slimtracks::Py, + slimtracks::Pz, + slimtracks::E); +using SlimTrack = SlimTracks::iterator; +namespace slimparticles +{ +DECLARE_SOA_INDEX_COLUMN(SlMcCollision, slMcCollision); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Px, px, float); +DECLARE_SOA_COLUMN(Py, py, float); +DECLARE_SOA_COLUMN(Pz, pz, float); +} // namespace slimparticles +DECLARE_SOA_TABLE(SlimParticles, "AOD", "SlimParticles", + o2::soa::Index<>, + slimparticles::SlMcCollisionId, + slimparticles::Pt, + slimparticles::Eta, + slimparticles::Phi, + slimparticles::Px, + slimparticles::Py, + slimparticles::Pz); +using SlimParticle = SlimParticles::iterator; +} // namespace o2::aod + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions;