|
| 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 singleTrackSelectorPIDMaker.cxx |
| 13 | +/// \brief creates dummy tables for PID columns that are not in the derived data |
| 14 | +/// \author Sofia Tomassini, Gleb Romanenko, Nicolò Jacazio |
| 15 | +/// \since 22 January 2025 |
| 16 | + |
| 17 | +#include <boost/variant.hpp> |
| 18 | +#include <fairlogger/Logger.h> |
| 19 | +#include <Framework/AnalysisDataModel.h> |
| 20 | + |
| 21 | +#include "PWGCF/Femto3D/DataModel/singletrackselector.h" |
| 22 | + |
| 23 | +#include "Framework/AnalysisTask.h" |
| 24 | +#include "Framework/runDataProcessing.h" |
| 25 | + |
| 26 | +using namespace o2; |
| 27 | +using namespace o2::framework; |
| 28 | +using namespace o2::framework::expressions; |
| 29 | +using namespace o2::track; |
| 30 | +using namespace o2::aod; |
| 31 | +//::singletrackselector; // the namespace defined in .h |
| 32 | + |
| 33 | +template <typename Tab> |
| 34 | +struct StPid { |
| 35 | + Produces<Tab> table; |
| 36 | + void process(o2::aod::SingleTrackSels const& tracks) |
| 37 | + { |
| 38 | + table.reserve(tracks.size()); |
| 39 | + for (int i = 0; i < tracks.size(); i++) { |
| 40 | + table(singletrackselector::binning::nsigma::underflowBin, |
| 41 | + singletrackselector::binning::nsigma::underflowBin); |
| 42 | + } |
| 43 | + } |
| 44 | +}; |
| 45 | + |
| 46 | +struct StPidEl { |
| 47 | + Produces<o2::aod::SinglePIDEls> table; |
| 48 | + void process(o2::aod::SingleTrackSels const& tracks) |
| 49 | + { |
| 50 | + table.reserve(tracks.size()); |
| 51 | + for (int i = 0; i < tracks.size(); i++) { |
| 52 | + table(singletrackselector::binning::nsigma::underflowBin, |
| 53 | + singletrackselector::binning::nsigma::underflowBin); |
| 54 | + } |
| 55 | + } |
| 56 | +}; |
| 57 | +struct StPidPi { |
| 58 | + Produces<o2::aod::SinglePIDPis> table; |
| 59 | + void process(o2::aod::SingleTrackSels const& tracks) |
| 60 | + { |
| 61 | + table.reserve(tracks.size()); |
| 62 | + for (int i = 0; i < tracks.size(); i++) { |
| 63 | + table(singletrackselector::binning::nsigma::underflowBin, |
| 64 | + singletrackselector::binning::nsigma::underflowBin); |
| 65 | + } |
| 66 | + } |
| 67 | +}; |
| 68 | +struct StPidKa { |
| 69 | + Produces<o2::aod::SinglePIDKas> table; |
| 70 | + void process(o2::aod::SingleTrackSels const& tracks) |
| 71 | + { |
| 72 | + table.reserve(tracks.size()); |
| 73 | + for (int i = 0; i < tracks.size(); i++) { |
| 74 | + table(singletrackselector::binning::nsigma::underflowBin, |
| 75 | + singletrackselector::binning::nsigma::underflowBin); |
| 76 | + } |
| 77 | + } |
| 78 | +}; |
| 79 | +struct StPidPr { |
| 80 | + Produces<o2::aod::SinglePIDPrs> table; |
| 81 | + void process(o2::aod::SingleTrackSels const& tracks) |
| 82 | + { |
| 83 | + table.reserve(tracks.size()); |
| 84 | + for (int i = 0; i < tracks.size(); i++) { |
| 85 | + table(singletrackselector::binning::nsigma::underflowBin, |
| 86 | + singletrackselector::binning::nsigma::underflowBin); |
| 87 | + } |
| 88 | + } |
| 89 | +}; |
| 90 | +struct StPidDe { |
| 91 | + Produces<o2::aod::SinglePIDDes> table; |
| 92 | + void process(o2::aod::SingleTrackSels const& tracks) |
| 93 | + { |
| 94 | + table.reserve(tracks.size()); |
| 95 | + for (int i = 0; i < tracks.size(); i++) { |
| 96 | + table(singletrackselector::binning::nsigma::underflowBin, |
| 97 | + singletrackselector::binning::nsigma::underflowBin); |
| 98 | + } |
| 99 | + } |
| 100 | +}; |
| 101 | +struct StPidHe { |
| 102 | + Produces<o2::aod::SinglePIDHes> table; |
| 103 | + void process(o2::aod::SingleTrackSels const& tracks) |
| 104 | + { |
| 105 | + table.reserve(tracks.size()); |
| 106 | + for (int i = 0; i < tracks.size(); i++) { |
| 107 | + table(singletrackselector::binning::nsigma::underflowBin, |
| 108 | + singletrackselector::binning::nsigma::underflowBin); |
| 109 | + } |
| 110 | + } |
| 111 | +}; |
| 112 | + |
| 113 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 114 | +{ |
| 115 | + auto workflow = WorkflowSpec{}; |
| 116 | + |
| 117 | + // Check if 'aod-metadata-tables' option is available in the config context |
| 118 | + if (cfgc.options().hasOption("aod-metadata-tables")) { |
| 119 | + const std::vector<std::string> tables = cfgc.options().get<std::vector<std::string>>("aod-metadata-tables"); |
| 120 | + |
| 121 | + // Map of table names to their corresponding converter task functions |
| 122 | + std::unordered_map<std::string, std::vector<std::function<void()>>> tableToTasks = { |
| 123 | + {"O2singlepidel", {[&]() { workflow.push_back(adaptAnalysisTask<StPidEl>(cfgc)); }}}, |
| 124 | + {"O2singlepidpi", {[&]() { workflow.push_back(adaptAnalysisTask<StPidPi>(cfgc)); }}}, |
| 125 | + {"O2singlepidka", {[&]() { workflow.push_back(adaptAnalysisTask<StPidKa>(cfgc)); }}}, |
| 126 | + {"O2singlepidpr", {[&]() { workflow.push_back(adaptAnalysisTask<StPidPr>(cfgc)); }}}, |
| 127 | + {"O2singlepidde", {[&]() { workflow.push_back(adaptAnalysisTask<StPidDe>(cfgc)); }}}, |
| 128 | + {"O2singlepidhe", {[&]() { workflow.push_back(adaptAnalysisTask<StPidHe>(cfgc)); }}} |
| 129 | + |
| 130 | + }; |
| 131 | + |
| 132 | + for (auto const& tableInWorkflow : tables) { |
| 133 | + LOG(info) << tableInWorkflow; |
| 134 | + } |
| 135 | + |
| 136 | + // Iterate through the tables and process based on the mapping |
| 137 | + for (auto const& table : tableToTasks) { |
| 138 | + bool foundIt = false; |
| 139 | + for (auto const& tableInWorkflow : tables) { |
| 140 | + if (tableInWorkflow == table.first) { |
| 141 | + foundIt = true; |
| 142 | + break; |
| 143 | + } |
| 144 | + } |
| 145 | + if (foundIt) |
| 146 | + continue; |
| 147 | + for (auto const& task : table.second) { |
| 148 | + LOG(info) << "Adding task " << table.first; |
| 149 | + task(); |
| 150 | + } |
| 151 | + } |
| 152 | + } else { |
| 153 | + LOG(warning) << "AOD converter: No tables found in the meta data"; |
| 154 | + } |
| 155 | + return workflow; |
| 156 | +} |
0 commit comments