|
| 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 | +#include "Framework/runDataProcessing.h" |
| 13 | +#include "Framework/AnalysisTask.h" |
| 14 | + |
| 15 | +#include "tables.h" |
| 16 | + |
| 17 | +using namespace o2; |
| 18 | +using namespace o2::framework; |
| 19 | +using namespace o2::framework::expressions; |
| 20 | + |
| 21 | +struct ProduceDynamicExtensionFunc { |
| 22 | + Produces<aod::ExtTracksIDM> etidm; |
| 23 | + |
| 24 | + std::function<float(float, float, float, float)> callable; |
| 25 | + // bin lower bounds + the rightmost upper bound |
| 26 | + Configurable<std::vector<float>> binning{"binning", {0, o2::constants::math::PIHalf, o2::constants::math::PI, o2::constants::math::PI + o2::constants::math::PIHalf, o2::constants::math::TwoPI}, "Phi binning"}; |
| 27 | + // parameters for the function as a flat array, grouped by parameter |
| 28 | + Configurable<std::vector<float>> parameters{"parameters", {1.0, 1.1, 1.2, 1.3, // par 0 |
| 29 | + 2.0, 2.1, 2.2, 2.3, // par 1 |
| 30 | + 3.0, 3.1, 3.2, 3.3}, // par 2 |
| 31 | + "Function parameters for each phi bin"}; |
| 32 | + |
| 33 | + void init(InitContext&) |
| 34 | + { |
| 35 | + // dummy function for benchmark (equivalent to configurable-expression-column.cxx) |
| 36 | + callable = [binning = (std::vector<float>)binning, parameters = (std::vector<float>)parameters](float phi, float x, float y, float z) -> float { |
| 37 | + if (phi < binning[0]) { |
| 38 | + return -1.f; |
| 39 | + } |
| 40 | + auto n = binning.size() - 1; |
| 41 | + for (auto i = 0U; i < n; ++i) { |
| 42 | + if (phi < binning[i + 1]) { |
| 43 | + return std::sqrt(parameters[0 * n + i] * x * x + // |
| 44 | + parameters[1 * n + i] * y * y + // |
| 45 | + parameters[2 * n + i] * z * z); // |
| 46 | + } |
| 47 | + } |
| 48 | + return -1.f; |
| 49 | + }; |
| 50 | + } |
| 51 | + |
| 52 | + void process(aod::TracksIU const& tracks) |
| 53 | + { |
| 54 | + auto tracksID = soa::Attach<aod::TracksIU, aod::extensions::Indirect<aod::track::Phi, aod::track::X, aod::track::Y, aod::track::Z>>(tracks); |
| 55 | + for (auto& track : tracksID) { |
| 56 | + etidm(track.indirect(callable)); |
| 57 | + } |
| 58 | + } |
| 59 | +}; |
| 60 | + |
| 61 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 62 | +{ |
| 63 | + return {adaptAnalysisTask<ProduceDynamicExtensionFunc>(cfgc)}; |
| 64 | +} |
0 commit comments