From 336ed5cdd8427641e024772792958bec83e047d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Wed, 16 Jul 2025 16:56:02 +0200 Subject: [PATCH] A3: Add trk performance --- ALICE3/Tasks/CMakeLists.txt | 7 ++ ALICE3/Tasks/alice3TrackingPerformance.cxx | 94 ++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 ALICE3/Tasks/alice3TrackingPerformance.cxx diff --git a/ALICE3/Tasks/CMakeLists.txt b/ALICE3/Tasks/CMakeLists.txt index 8fb4c79ea12..5da0bd2f7ea 100644 --- a/ALICE3/Tasks/CMakeLists.txt +++ b/ALICE3/Tasks/CMakeLists.txt @@ -68,3 +68,10 @@ o2physics_add_dpl_workflow(alice3-efficiency SOURCES alice3Efficiency.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(alice3-tracking-performance + SOURCES alice3TrackingPerformance.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + + diff --git a/ALICE3/Tasks/alice3TrackingPerformance.cxx b/ALICE3/Tasks/alice3TrackingPerformance.cxx new file mode 100644 index 00000000000..bfb9418bb2c --- /dev/null +++ b/ALICE3/Tasks/alice3TrackingPerformance.cxx @@ -0,0 +1,94 @@ +// 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 alice3TrackingPerformance.cxx +/// +/// \brief This task produces the tracking performance +/// +/// \author Nicolò Jacazio, Universita del Piemonte Orientale (IT) +/// \since May 27, 2025 +/// + +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/ConfigParamRegistry.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include +#include + +using namespace o2; +using namespace o2::framework; +std::map> ptResolutionVsPt; +std::map> invPtResolutionVsPt; +std::map> dcaXyResolutionVsPt; +std::map> dcaZResolutionVsPt; + +struct alice3TrackingPerformance { + Configurable> pdgCodes{"pdgCodes", {211}, "List of PDG codes to consider for efficiency calculation"}; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable> etaRange{"etaRange", {-5.f, 5.f}, "Eta range for efficiency calculation"}; + + void init(o2::framework::InitContext&) + { + const AxisSpec axisPt{100, 0, 10, "p_{T} (GeV/c)"}; + const AxisSpec axisPtDelta{100, -1, 1, "p_{T}^{gen} - p_{T}^{reco} (GeV/c)"}; + const AxisSpec axisInvPtDelta{100, -1, 1, "1./p_{T}^{gen} - 1./p_{T}^{reco} (GeV/c)^{-1}"}; + const AxisSpec axisDcaXy{100, -1, 1, "DCA_{xy} (cm)"}; + const AxisSpec axisDcaZ{100, -1, 1, "DCA_{z} (cm)"}; + for (auto pdg : pdgCodes.value) { + ptResolutionVsPt[pdg] = histos.add(Form("ptResolutionVsPt_%d", pdg), "", kTH2D, {axisPt, axisPtDelta}); + invPtResolutionVsPt[pdg] = histos.add(Form("invPtResolutionVsPt_%d", pdg), "", kTH2D, {axisPt, axisInvPtDelta}); + dcaXyResolutionVsPt[pdg] = histos.add(Form("dcaXyResolutionVsPt_%d", pdg), "", kTH2D, {axisPt, axisDcaXy}); + dcaZResolutionVsPt[pdg] = histos.add(Form("dcaZResolutionVsPt_%d", pdg), "", kTH2D, {axisPt, axisDcaZ}); + } + } + + void process(soa::Join const& tracks, + aod::McParticles const&) + { + auto isParticleSelected = [&](const o2::aod::McParticle& p) { + if (!p.isPhysicalPrimary()) { + return false; + } + if (p.eta() < etaRange.value.first) { + return false; + } + if (p.eta() > etaRange.value.second) { + return false; + } + return true; + }; + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + const auto& mcParticle = track.mcParticle(); + if (!isParticleSelected(mcParticle)) { + continue; + } + if (ptResolutionVsPt.find(mcParticle.pdgCode()) == ptResolutionVsPt.end()) { + continue; + } + ptResolutionVsPt[mcParticle.pdgCode()]->Fill(mcParticle.pt(), mcParticle.pt() - track.pt()); + invPtResolutionVsPt[mcParticle.pdgCode()]->Fill(mcParticle.pt(), 1.f / mcParticle.pt() - 1.f / track.pt()); + dcaXyResolutionVsPt[mcParticle.pdgCode()]->Fill(mcParticle.pt(), track.dcaXY()); + dcaZResolutionVsPt[mcParticle.pdgCode()]->Fill(mcParticle.pt(), track.dcaZ()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& ctx) +{ + return WorkflowSpec{adaptAnalysisTask(ctx)}; +}