71 {
"dataTPC", {
"TPC",
"CLUSTERS"}},
72 {
"dataITS", {
"ITS",
"CLUSTERS"}}},
74 {{
"TPC",
"CLUSTERS_P"}},
75 {{
"ITS",
"CLUSTERS_P"}}},
82 {
"dataTPC-proc", {
"TPC",
"CLUSTERS_P"}},
83 {
"dataITS-proc", {
"ITS",
"CLUSTERS_P"}}},
92 {
"TPC_CLUSTERS_S", {
"DS",
"simpleQcTask0"}},
93 {
"TPC_CLUSTERS_P_S", {
"DS",
"simpleQcTask1"}}
98 auto inputDataTpc =
reinterpret_cast<const FakeCluster*
>(ctx.
inputs().
get(
"TPC_CLUSTERS_S").payload);
100 "TPC_CLUSTERS_P_S").payload);
103 const auto* dataHeader = DataRefUtils::getHeader<DataHeader*>(
ref);
105 bool dataGood =
true;
107 float diff = std::abs(-inputDataTpc[
j].
x - inputDataTpcProcessed[
j].
x) +
108 std::abs(2 * inputDataTpc[
j].
y - inputDataTpcProcessed[
j].
y) +
109 std::abs(inputDataTpc[
j].
z * inputDataTpc[
j].q - inputDataTpcProcessed[
j].
z) +
110 std::abs(inputDataTpc[
j].q - inputDataTpcProcessed[
j].q);
117 LOG(info) <<
"qcTaskTPC - received data is " << (dataGood ?
"correct" :
"wrong");
119 const auto* dsHeader = DataRefUtils::getHeader<DataSamplingHeader*>(
ref);
121 LOG(info) <<
"Matching messages seen by Dispatcher: " << dsHeader->totalEvaluatedMessages
122 <<
", accepted: " << dsHeader->totalAcceptedMessages
123 <<
", sample time: " << dsHeader->sampleTimeUs
124 <<
", device ID: " << dsHeader->deviceID.str;
126 LOG(error) <<
"DataSamplingHeader missing!";
137 OutputSpec{
"TST",
"HISTOS", 0, Lifetime::Timeframe },
138 OutputSpec{
"TST",
"STRING", 0, Lifetime::Timeframe }
142 std::this_thread::sleep_for(std::chrono::seconds(1));
144 auto& singleHisto = ctx.outputs().make<TH1F>(
Output{
"TST",
"HISTOS", 0 },
"h1",
"test", 100, -10., 10.);
145 auto& aString = ctx.outputs().make<TObjString>(
Output{
"TST",
"STRING", 0 },
"foo");
146 singleHisto.FillRandom(
"gaus", 1000);
148 singleHisto.GetStats(stats);
149 LOG(info) <<
"sumw" << stats[0] <<
"\n"
150 <<
"sumw2" << stats[1] <<
"\n"
151 <<
"sumwx" << stats[2] <<
"\n"
152 <<
"sumwx2" << stats[3] <<
"\n";
160 InputSpec{
"histos",
"TST",
"HISTOS", 0, Lifetime::Timeframe },
161 InputSpec{
"string",
"TST",
"STRING", 0, Lifetime::Timeframe },
166 auto h = ctx.inputs().get<TH1F*>(
"histos");
167 if (
h.get() ==
nullptr) {
168 throw std::runtime_error(
"Missing output");
172 LOG(info) <<
"sumw" << stats[0] <<
"\n"
173 <<
"sumw2" << stats[1] <<
"\n"
174 <<
"sumwx" << stats[2] <<
"\n"
175 <<
"sumwx2" << stats[3] <<
"\n";
176 auto s = ctx.inputs().get<TObjString*>(
"string");
178 LOG(info) <<
"String is " << s->GetString().Data();
185 InputSpec{
"TST_HISTOS_S", {
"DS",
"rootQcTask0"}},
186 InputSpec{
"TST_STRING_S", {
"DS",
"rootQcTask1"}},
191 auto h = ctx.inputs().get<TH1F*>(
"TST_HISTOS_S");
192 if (
h.get() ==
nullptr) {
193 throw std::runtime_error(
"Missing TST_HISTOS_S");
197 LOG(info) <<
"sumw" << stats[0] <<
"\n"
198 <<
"sumw2" << stats[1] <<
"\n"
199 <<
"sumwx" << stats[2] <<
"\n"
200 <<
"sumwx2" << stats[3] <<
"\n";
201 auto s = ctx.inputs().get<TObjString*>(
"TST_STRING_S");
203 LOG(info) <<
"qcTaskTst: TObjString is " << (std::string(
"foo") == s->GetString().Data() ?
"correct" :
"wrong");
219 const char* o2Root = getenv(
"O2_ROOT");
220 if (o2Root ==
nullptr) {
221 throw std::runtime_error(
"The O2_ROOT environment variable is not set, probably the O2 environment has not been loaded.");
223 std::string configurationSource = std::string(
"json:/") + o2Root +
"/share/etc/exampleDataSamplingConfig.json";
224 LOG(info) <<
"Using config source: " << configurationSource;
264 auto processedTpcClusters =
266 auto processedItsClusters =
270 for (
auto& cluster : processedTpcClusters) {
272 cluster.x = -inputDataTpc[
i].
x;
273 cluster.y = 2 * inputDataTpc[
i].
y;
274 cluster.z = inputDataTpc[
i].
z * inputDataTpc[
i].
q;
275 cluster.q = inputDataTpc[
i].
q;
280 for (
auto& cluster : processedItsClusters) {
282 cluster.x = -inputDataIts[
i].
x;
283 cluster.y = 2 * inputDataIts[
i].
y;
284 cluster.z = inputDataIts[
i].
z * inputDataIts[
i].
q;
285 cluster.q = inputDataIts[
i].
q;
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
static void GenerateInfrastructure(framework::WorkflowSpec &workflow, const std::string &policiesSource, size_t threads=1, const std::string &host="")
Generates data sampling infrastructure.