|
| 1 | +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +/// \file pccQa.cxx |
| 13 | +/// \brief Task producing DCA distributions with and without particle-composition correction. |
| 14 | +/// \author Mario Krüger <mario.kruger@cern.ch> |
| 15 | + |
| 16 | +#include "PWGLF/DataModel/particleCompositionCorrectionTable.h" |
| 17 | + |
| 18 | +#include "Common/Core/TrackSelection.h" |
| 19 | +#include "Common/Core/TrackSelectionDefaults.h" |
| 20 | +#include "Common/DataModel/EventSelection.h" |
| 21 | +#include "Common/DataModel/TrackSelectionTables.h" |
| 22 | + |
| 23 | +#include <Framework/AnalysisTask.h> |
| 24 | +#include <Framework/HistogramRegistry.h> |
| 25 | +#include <Framework/O2DatabasePDGPlugin.h> |
| 26 | +#include <Framework/runDataProcessing.h> |
| 27 | + |
| 28 | +#include <TMCProcess.h> |
| 29 | + |
| 30 | +#include <vector> |
| 31 | + |
| 32 | +using namespace o2; |
| 33 | +using namespace o2::framework; |
| 34 | +using aod::track::TrackSelectionFlags; |
| 35 | + |
| 36 | +struct PccQa { |
| 37 | + HistogramRegistry histos; |
| 38 | + Service<o2::framework::O2DatabasePDG> pdg; |
| 39 | + |
| 40 | + static constexpr float MaxVtxZ = 10.f; |
| 41 | + |
| 42 | + void init(InitContext const&); |
| 43 | + |
| 44 | + template <bool IS_MC, typename C, typename T> |
| 45 | + void processMeas(const C& collision, const T& tracks); |
| 46 | + |
| 47 | + using CollisionTableData = soa::Join<aod::Collisions, aod::EvSels>; |
| 48 | + using TrackTableData = soa::Join<aod::FullTracks, aod::TracksDCA, aod::TrackSelection>; |
| 49 | + void processData(CollisionTableData::iterator const& collision, TrackTableData const& tracks); |
| 50 | + PROCESS_SWITCH(PccQa, processData, "process data", false); |
| 51 | + |
| 52 | + using CollisionTableMCTrue = aod::McCollisions; |
| 53 | + using CollisionTableMC = soa::SmallGroups<soa::Join<aod::McCollisionLabels, aod::Collisions, aod::EvSels>>; |
| 54 | + using TrackTableMC = soa::Join<aod::FullTracks, aod::TracksDCA, aod::TrackSelection, aod::McTrackLabels>; |
| 55 | + using ParticleTableMC = soa::Join<aod::McParticles, aod::ParticleCompositionCorrection>; |
| 56 | + Preslice<TrackTableMC> perCollision = aod::track::collisionId; |
| 57 | + void processMC(CollisionTableMCTrue::iterator const& mcCollision, TrackTableMC const& tracks, CollisionTableMC const& collisions, ParticleTableMC const&); |
| 58 | + PROCESS_SWITCH(PccQa, processMC, "process mc", true); |
| 59 | +}; |
| 60 | + |
| 61 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 62 | +{ |
| 63 | + return WorkflowSpec{adaptAnalysisTask<PccQa>(cfgc)}; |
| 64 | +} |
| 65 | + |
| 66 | +void PccQa::init(InitContext const&) |
| 67 | +{ |
| 68 | + histos.add("eventCounter", "", kTH1D, {{1, 0.5, 1.5}}); |
| 69 | + const AxisSpec dcaAxis = {1000, -1., 1., "#it{DCA}_{xy}", "dca"}; |
| 70 | + std::vector<double> ptBinEdges = {0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0}; |
| 71 | + const AxisSpec ptAxis{ptBinEdges, "#it{p}_{T} (GeV/#it{c})", "pt"}; |
| 72 | + |
| 73 | + histos.add("DCAxyVsPt", "", kTH2D, {ptAxis, dcaAxis}); |
| 74 | + |
| 75 | + if (doprocessMC) { |
| 76 | + histos.add("DCAxyVsPt_weighted", "", kTH2D, {ptAxis, dcaAxis}); |
| 77 | + histos.add("prim/DCAxyVsPt", "", kTH2D, {ptAxis, dcaAxis}); |
| 78 | + histos.add("prim/DCAxyVsPt_weighted", "", kTH2D, {ptAxis, dcaAxis}); |
| 79 | + histos.add("sec/DCAxyVsPt", "", kTH2D, {ptAxis, dcaAxis}); |
| 80 | + histos.add("sec/DCAxyVsPt_weighted", "", kTH2D, {ptAxis, dcaAxis}); |
| 81 | + histos.add("sec/dec/DCAxyVsPt", "", kTH2D, {ptAxis, dcaAxis}); |
| 82 | + histos.add("sec/dec/DCAxyVsPt_weighted", "", kTH2D, {ptAxis, dcaAxis}); |
| 83 | + histos.add("sec/mat/DCAxyVsPt", "", kTH2D, {ptAxis, dcaAxis}); |
| 84 | + histos.add("sec/mat/DCAxyVsPt_weighted", "", kTH2D, {ptAxis, dcaAxis}); |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +void PccQa::processData(CollisionTableData::iterator const& collision, TrackTableData const& tracks) |
| 89 | +{ |
| 90 | + processMeas<false>(collision, tracks); |
| 91 | +} |
| 92 | +void PccQa::processMC(CollisionTableMCTrue::iterator const&, TrackTableMC const& tracks, CollisionTableMC const& collisions, ParticleTableMC const&) |
| 93 | +{ |
| 94 | + for (const auto& collision : collisions) { |
| 95 | + auto curTracks = tracks.sliceBy(perCollision, collision.globalIndex()); |
| 96 | + processMeas<true>(collision, curTracks); |
| 97 | + break; |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +template <bool IS_MC, typename C, typename T> |
| 102 | +void PccQa::processMeas(const C& collision, const T& tracks) |
| 103 | +{ |
| 104 | + if ((std::abs(collision.posZ()) > MaxVtxZ) || !collision.sel8()) { |
| 105 | + return; |
| 106 | + } |
| 107 | + histos.fill(HIST("eventCounter"), 1); |
| 108 | + |
| 109 | + for (const auto& track : tracks) { |
| 110 | + if (!TrackSelectionFlags::checkFlag(track.trackCutFlag(), TrackSelectionFlags::kGlobalTrackWoDCA)) { |
| 111 | + continue; |
| 112 | + } |
| 113 | + histos.fill(HIST("DCAxyVsPt"), track.pt(), track.dcaXY()); |
| 114 | + |
| 115 | + if constexpr (IS_MC) { |
| 116 | + if (!track.has_mcParticle()) { |
| 117 | + continue; |
| 118 | + } |
| 119 | + const auto& particle = track.template mcParticle_as<ParticleTableMC>(); |
| 120 | + |
| 121 | + histos.fill(HIST("DCAxyVsPt_weighted"), track.pt(), track.dcaXY(), particle.pccWeight()); |
| 122 | + |
| 123 | + if (particle.isPhysicalPrimary()) { |
| 124 | + histos.fill(HIST("prim/DCAxyVsPt"), track.pt(), track.dcaXY()); |
| 125 | + histos.fill(HIST("prim/DCAxyVsPt_weighted"), track.pt(), track.dcaXY(), particle.pccWeight()); |
| 126 | + } else { |
| 127 | + histos.fill(HIST("sec/DCAxyVsPt"), track.pt(), track.dcaXY()); |
| 128 | + histos.fill(HIST("sec/DCAxyVsPt_weighted"), track.pt(), track.dcaXY(), particle.pccWeight()); |
| 129 | + if (particle.getProcess() == TMCProcess::kPDecay) { |
| 130 | + histos.fill(HIST("sec/dec/DCAxyVsPt"), track.pt(), track.dcaXY()); |
| 131 | + histos.fill(HIST("sec/dec/DCAxyVsPt_weighted"), track.pt(), track.dcaXY(), particle.pccWeight()); |
| 132 | + } else if (particle.getProcess() == TMCProcess::kPHInhelastic || particle.getProcess() == TMCProcess::kPHadronic || particle.getProcess() == TMCProcess::kPHElastic) { |
| 133 | + histos.fill(HIST("sec/mat/DCAxyVsPt"), track.pt(), track.dcaXY()); |
| 134 | + histos.fill(HIST("sec/mat/DCAxyVsPt_weighted"), track.pt(), track.dcaXY(), particle.pccWeight()); |
| 135 | + } |
| 136 | + } |
| 137 | + } |
| 138 | + } |
| 139 | +} |
0 commit comments