diff --git a/PWGJE/DataModel/SlimTables.h b/PWGJE/DataModel/SlimTables.h new file mode 100644 index 00000000000..ecbacf68382 --- /dev/null +++ b/PWGJE/DataModel/SlimTables.h @@ -0,0 +1,131 @@ +// 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 "PWGJE/Core/JetDerivedDataUtilities.h" + +#include +#include + +#include + +#include + +namespace o2::aod +{ + +namespace slimcollision +{ +DECLARE_SOA_INDEX_COLUMN(Collision, collision); +DECLARE_SOA_COLUMN(PosZ, posZ, float); +DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); +DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); +DECLARE_SOA_COLUMN(Weight, weight, float); +DECLARE_SOA_COLUMN(EventSel, eventSel, uint16_t); +DECLARE_SOA_COLUMN(TrackOccupancyInTimeRange, trackOccupancyInTimeRange, int); +} // namespace slimcollision + +DECLARE_SOA_TABLE(SlimCollisions, "AOD", "SlimCollisions", + o2::soa::Index<>, + slimcollision::PosZ, + slimcollision::CentFT0C, + slimcollision::CentFT0M, + slimcollision::Weight, + slimcollision::EventSel, + slimcollision::TrackOccupancyInTimeRange); + +namespace slimmccollision +{ +DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); +DECLARE_SOA_COLUMN(PosZ, posZ, float); +DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); +DECLARE_SOA_COLUMN(Weight, weight, float); +DECLARE_SOA_COLUMN(Accepted, accepted, uint64_t); +DECLARE_SOA_COLUMN(PtHard, ptHard, float); +} // namespace slimmccollision + +DECLARE_SOA_TABLE(SlimMcCollisions, "AOD", "SlimMcCollisions", + o2::soa::Index<>, + slimmccollision::PosZ, + slimmccollision::CentFT0M, + slimmccollision::Weight, + slimmccollision::Accepted, + slimmccollision::PtHard); + +namespace slimtracks +{ +DECLARE_SOA_INDEX_COLUMN(Collision, collision); +DECLARE_SOA_INDEX_COLUMN(Track, track); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); +DECLARE_SOA_DYNAMIC_COLUMN(Px, px, + [](float pt, float phi) -> float { return pt * std::cos(phi); }); +DECLARE_SOA_DYNAMIC_COLUMN(Py, py, + [](float pt, float phi) -> float { return pt * std::sin(phi); }); +DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, + [](float pt, float eta) -> float { return pt * std::sinh(eta); }); +DECLARE_SOA_DYNAMIC_COLUMN(Energy, energy, + [](float pt, float eta) -> float { return std::sqrt((pt * std::cosh(eta) * pt * std::cosh(eta)) + (jetderiveddatautilities::mPion * jetderiveddatautilities::mPion)); }); +} // namespace slimtracks +DECLARE_SOA_TABLE(SlimTracks, "AOD", "SlimTracks", + o2::soa::Index<>, + slimtracks::CollisionId, + slimtracks::Pt, + slimtracks::Eta, + slimtracks::Phi, + slimtracks::DcaXY, + slimtracks::Px, + slimtracks::Py, + slimtracks::Pz, + slimtracks::Energy); + +namespace slimparticles +{ +DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); +DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_DYNAMIC_COLUMN(Px, px, + [](float pt, float phi) -> float { return pt * std::cos(phi); }); +DECLARE_SOA_DYNAMIC_COLUMN(Py, py, + [](float pt, float phi) -> float { return pt * std::sin(phi); }); +DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, + [](float pt, float eta) -> float { return pt * std::sinh(eta); }); +DECLARE_SOA_DYNAMIC_COLUMN(Energy, energy, + [](float e) -> float { return e; }); +} // namespace slimparticles + +DECLARE_SOA_TABLE(SlimParticles, "AOD", "SlimParticles", + o2::soa::Index<>, + slimparticles::McCollisionId, + slimparticles::Pt, + slimparticles::Eta, + slimparticles::Phi, + slimparticles::Px, + slimparticles::Py, + slimparticles::Pz, + slimparticles::Energy); + +} // namespace o2::aod + +#endif // PWGJE_DATAMODEL_SLIMTABLES_H_ diff --git a/PWGJE/TableProducer/CMakeLists.txt b/PWGJE/TableProducer/CMakeLists.txt index 60689f07e65..da355ebb430 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) \ No newline at end of file diff --git a/PWGJE/TableProducer/slimTablesProducer.cxx b/PWGJE/TableProducer/slimTablesProducer.cxx new file mode 100644 index 00000000000..895fb3b9dfe --- /dev/null +++ b/PWGJE/TableProducer/slimTablesProducer.cxx @@ -0,0 +1,78 @@ +// 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/DataModel/SlimTables.h" + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisHelpers.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct SlimTablesProducer { + + void init(InitContext&) + { + } + + Produces slimCollisions; + Produces slimMcCollisions; + Produces slimTracks; + Produces slimParticles; + + void processCollision(aod::SlimCollisions const& collisions) + { + for (const auto& coll : collisions) { + slimCollisions(coll.posZ(), coll.centFT0C(), coll.centFT0M(), coll.weight(), coll.eventSel(), coll.trackOccupancyInTimeRange()); + } + } + PROCESS_SWITCH(SlimTablesProducer, processCollision, "Produce slim collision table", true); + + void processMcCollision(aod::SlimMcCollisions const& mccollisions) + { + for (const auto& mccoll : mccollisions) { + slimMcCollisions(mccoll.posZ(), mccoll.centFT0M(), mccoll.weight(), mccoll.accepted(), mccoll.ptHard()); + } + } + PROCESS_SWITCH(SlimTablesProducer, processMcCollision, "Produce slim mc collision table", true); + + void processTracks(aod::SlimTracks const& tracks) + { + for (const auto& trk : tracks) { + slimTracks(trk.collision(), trk.pt(), trk.eta(), trk.phi(), trk.dcaXY()); + } + } + PROCESS_SWITCH(SlimTablesProducer, processTracks, "Produce slim track table", true); + + void processParticles(aod::McParticles const& parts) + { + for (const auto& p : parts) { + slimParticles(p.mcCollision(), p.pt(), p.eta(), p.phi()); + } + } + PROCESS_SWITCH(SlimTablesProducer, processParticles, "Produce slim particles", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +}