Project
Loading...
Searching...
No Matches
test_SimpleDataProcessingDevice01.cxx
Go to the documentation of this file.
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.
17#include <Monitoring/Monitoring.h>
18
19using namespace o2::framework;
20
21struct FakeCluster {
22 float x;
23 float y;
24 float z;
25 float q;
26};
27
28struct Summary {
29 int inputCount;
30 int clustersCount;
31};
32
33// This is how you can define your processing in a declarative way
34std::vector<DataProcessorSpec> defineDataProcessing(ConfigContext const&)
35{
36 return {
38 "simple",
39 Inputs{},
40 {OutputSpec{"TPC", "CLUSTERS"},
41 OutputSpec{"ITS", "CLUSTERS"}},
42 adaptStateless([](DataAllocator& outputs, ControlService& control, RawDeviceService& service) {
43 service.waitFor(1000);
44 // Creates a new message of size 1000 which
45 // has "TPC" as data origin and "CLUSTERS" as data description.
46 auto& tpcClusters = outputs.make<FakeCluster>(Output{"TPC", "CLUSTERS", 0}, 1000);
47 int i = 0;
48
49 for (auto& cluster : tpcClusters) {
50 assert(i < 1000);
51 cluster.x = i;
52 cluster.y = i;
53 cluster.z = i;
54 cluster.q = i;
55 i++;
56 }
57
58 auto& itsClusters = outputs.make<FakeCluster>(Output{"ITS", "CLUSTERS", 0}, 1000);
59 i = 0;
60 for (auto& cluster : itsClusters) {
61 assert(i < 1000);
62 cluster.x = i;
63 cluster.y = i;
64 cluster.z = i;
65 cluster.q = i;
66 i++;
67 }
68 control.readyToQuit(QuitRequest::All);
69 })}};
70}
int32_t i
void readyToQuit(bool all)
Compatibility with old API.
decltype(auto) make(const Output &spec, Args... args)
virtual void waitFor(unsigned int time)=0
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
AlgorithmSpec::ProcessCallback adaptStateless(LAMBDA l)
std::vector< InputSpec > Inputs
std::vector< DataProcessorSpec > defineDataProcessing(ConfigContext const &)
This function hooks up the the workflow specifications into the DPL driver.