|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | +#include "Framework/runDataProcessing.h" |
| 11 | +#include "Framework/AnalysisTask.h" |
| 12 | +#include "Framework/AnalysisDataModel.h" |
| 13 | + |
| 14 | +namespace o2::aod |
| 15 | +{ |
| 16 | +namespace etaphi |
| 17 | +{ |
| 18 | +DECLARE_SOA_COLUMN(Eta, eta, float, "fEta"); |
| 19 | +DECLARE_SOA_COLUMN(Phi, phi, float, "fPhi"); |
| 20 | +} // namespace etaphi |
| 21 | +DECLARE_SOA_TABLE(EtaPhi, "RN2", "ETAPHI", |
| 22 | + etaphi::Eta, etaphi::Phi); |
| 23 | +} // namespace o2::aod |
| 24 | + |
| 25 | +using namespace o2; |
| 26 | +using namespace o2::framework; |
| 27 | + |
| 28 | +// This is a very simple example showing how to iterate over tracks |
| 29 | +// and create a new collection for them. |
| 30 | +// FIXME: this should really inherit from AnalysisTask but |
| 31 | +// we need GCC 7.4+ for that |
| 32 | +struct ATask { |
| 33 | + Produces<aod::EtaPhi> etaphi; |
| 34 | + |
| 35 | + void process(aod::Tracks const& tracks) |
| 36 | + { |
| 37 | + for (auto& track : tracks) { |
| 38 | + auto phi = asin(track.snp()) + track.alpha() + M_PI; |
| 39 | + auto eta = log(tan(0.25 * M_PI - 0.5 * atan(track.tgl()))); |
| 40 | + |
| 41 | + etaphi(phi, eta); |
| 42 | + } |
| 43 | + } |
| 44 | +}; |
| 45 | + |
| 46 | +struct BTask { |
| 47 | + void process(aod::EtaPhi const& etaPhis) |
| 48 | + { |
| 49 | + for (auto& etaPhi : etaPhis) { |
| 50 | + LOGF(ERROR, "(%f, %f)", etaPhi.eta(), etaPhi.phi()); |
| 51 | + } |
| 52 | + } |
| 53 | +}; |
| 54 | + |
| 55 | +WorkflowSpec defineDataProcessing(ConfigContext const&) |
| 56 | +{ |
| 57 | + return WorkflowSpec{ |
| 58 | + adaptAnalysisTask<ATask>("produce-etaphi"), |
| 59 | + adaptAnalysisTask<BTask>("consume-etaphi")}; |
| 60 | +} |
0 commit comments