|
| 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 | +// This task converts tiny PID tables into full PID tables. |
| 13 | +// It is meant to be used with Run 2 converted data to maintain |
| 14 | +// full compatibility with any task that may subscribe to the Full |
| 15 | +// tables (at the cost of some memory consumption). |
| 16 | +// It is also able to produce very simple QA plots on the stored |
| 17 | +// quantities (optionally disabled for simplicity) |
| 18 | +// |
| 19 | +// Warning: expected resolution is NOT provided. |
| 20 | + |
| 21 | +#include "Framework/runDataProcessing.h" |
| 22 | +#include "Framework/AnalysisTask.h" |
| 23 | +#include "Framework/AnalysisDataModel.h" |
| 24 | +#include "Common/DataModel/PIDResponse.h" |
| 25 | +#include "TableHelper.h" |
| 26 | + |
| 27 | +using namespace o2; |
| 28 | +using namespace o2::framework; |
| 29 | + |
| 30 | +using tinyPidTracks = soa::Join<aod::Tracks, aod::pidTPCFullEl, aod::pidTPCFullMu, aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTPCFullDe, aod::pidTPCFullTr, aod::pidTPCFullHe, aod::pidTPCFullAl>; |
| 31 | + |
| 32 | +static constexpr int nParameters = 1; |
| 33 | +static const std::vector<std::string> tableNames{"Electron", // 0 |
| 34 | + "Muon", // 1 |
| 35 | + "Pion", // 2 |
| 36 | + "Kaon", // 3 |
| 37 | + "Proton", // 4 |
| 38 | + "Deuteron", // 5 |
| 39 | + "Triton", // 6 |
| 40 | + "Helium", // 7 |
| 41 | + "Alpha"}; // 8 |
| 42 | +static const std::vector<std::string> parameterNames{"enable"}; |
| 43 | +static const int defaultParameters[9][nParameters]{{0}, {0}, {1}, {1}, {1}, {0}, {0}, {0}, {0}}; |
| 44 | + |
| 45 | +static constexpr int kPidEl = 0; |
| 46 | +static constexpr int kPidMu = 1; |
| 47 | +static constexpr int kPidPi = 2; |
| 48 | +static constexpr int kPidKa = 3; |
| 49 | +static constexpr int kPidPr = 4; |
| 50 | +static constexpr int kPidDe = 5; |
| 51 | +static constexpr int kPidTr = 6; |
| 52 | +static constexpr int kPidHe = 7; |
| 53 | +static constexpr int kPidAl = 8; |
| 54 | +static constexpr int nTables = 9; |
| 55 | + |
| 56 | +struct TpcPidQa { |
| 57 | + Configurable<LabeledArray<int>> enabledTables{"enabledTables", |
| 58 | + {defaultParameters[0], nTables, nParameters, tableNames, parameterNames}, |
| 59 | + "Produce QA for this species: 0 - no, 1 - yes"}; |
| 60 | + std::vector<int> mEnabledTables; // Vector of enabled tables |
| 61 | + |
| 62 | + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; |
| 63 | + |
| 64 | + ConfigurableAxis axisMomentum{"axisMomentum", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "momentum"}; |
| 65 | + |
| 66 | + ConfigurableAxis axisNSigma{"axisNSigma", {48, -6.0f, 6.0f}, "axisNSigma"}; |
| 67 | + |
| 68 | + void init(InitContext&) |
| 69 | + { |
| 70 | + mEnabledTables.resize(9, 0); |
| 71 | + |
| 72 | + for (int i = 0; i < nTables; i++) { |
| 73 | + int f = enabledTables->get(tableNames[i].c_str(), "enable"); |
| 74 | + if (f == 1) { |
| 75 | + mEnabledTables[i] = 1; |
| 76 | + histos.add(fmt::format("hNSigmaVsPTot{}", tableNames[i]).c_str(), "", kTH2F, {axisMomentum, axisNSigma}); |
| 77 | + } |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + void process(tinyPidTracks const& tracks) |
| 82 | + { |
| 83 | + for (const auto& track : tracks) { |
| 84 | + if (mEnabledTables[kPidEl]) { |
| 85 | + histos.fill(HIST("hNSigmaVsPTotElectron"), track.p(), track.tpcNSigmaEl()); |
| 86 | + } |
| 87 | + if (mEnabledTables[kPidMu]) { |
| 88 | + histos.fill(HIST("hNSigmaVsPTotMuon"), track.p(), track.tpcNSigmaMu()); |
| 89 | + } |
| 90 | + if (mEnabledTables[kPidPi]) { |
| 91 | + histos.fill(HIST("hNSigmaVsPTotPion"), track.p(), track.tpcNSigmaPi()); |
| 92 | + } |
| 93 | + if (mEnabledTables[kPidKa]) { |
| 94 | + histos.fill(HIST("hNSigmaVsPTotKaon"), track.p(), track.tpcNSigmaKa()); |
| 95 | + } |
| 96 | + if (mEnabledTables[kPidPr]) { |
| 97 | + histos.fill(HIST("hNSigmaVsPTotProton"), track.p(), track.tpcNSigmaPr()); |
| 98 | + } |
| 99 | + if (mEnabledTables[kPidDe]) { |
| 100 | + histos.fill(HIST("hNSigmaVsPTotDeuteron"), track.p(), track.tpcNSigmaDe()); |
| 101 | + } |
| 102 | + if (mEnabledTables[kPidTr]) { |
| 103 | + histos.fill(HIST("hNSigmaVsPTotTriton"), track.p(), track.tpcNSigmaTr()); |
| 104 | + } |
| 105 | + if (mEnabledTables[kPidHe]) { |
| 106 | + histos.fill(HIST("hNSigmaVsPTotHelium"), track.p(), track.tpcNSigmaHe()); |
| 107 | + } |
| 108 | + if (mEnabledTables[kPidAl]) { |
| 109 | + histos.fill(HIST("hNSigmaVsPTotAlpha"), track.p(), track.tpcNSigmaAl()); |
| 110 | + } |
| 111 | + } |
| 112 | + } |
| 113 | +}; |
| 114 | + |
| 115 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 116 | +{ |
| 117 | + return WorkflowSpec{ |
| 118 | + adaptAnalysisTask<TpcPidQa>(cfgc)}; |
| 119 | +} |
0 commit comments