Project
Loading...
Searching...
No Matches
O2DataModelHelpers.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.
11
14
15namespace o2::framework
16{
17void O2DataModelHelpers::updateMissingSporadic(fair::mq::Parts& parts, std::vector<OutputSpec> const& specs, std::vector<bool>& present)
18{
19 // Mark as present anything which is not of Lifetime timeframe.
20 for (size_t i = 0; i < specs.size(); ++i) {
21 if (specs[i].lifetime != Lifetime::Timeframe) {
22 present[i] = true;
23 }
24 }
25
26 auto timeframeDataExists = [&present, &specs](auto const& dh) -> void {
27 for (size_t i = 0; i < specs.size(); ++i) {
28 // We already found this, no need to check again.
29 if (present[i]) {
30 continue;
31 }
32 // The header is not there, we do not care.
33 if (dh == nullptr) {
34 continue;
35 }
36 // The header matcher this output, we mark it as present.
37 if (DataSpecUtils::match(specs[i], ConcreteDataMatcher{dh->dataOrigin, dh->dataDescription, dh->subSpecification})) {
38 present[i] = true;
39 }
40 }
41 };
42 O2DataModelHelpers::for_each_header(parts, timeframeDataExists);
43}
44
45std::string O2DataModelHelpers::describeMissingOutputs(std::vector<OutputSpec> const& specs, std::vector<bool> const& present)
46{
47 assert(specs.size() == present.size());
48 std::string error = "This timeframe has a missing output of lifetime timeframe: ";
49 bool first = true;
50 for (size_t i = 0; i < specs.size(); ++i) {
51 if (present[i] == false) {
52 if (first) {
53 first = false;
54 } else {
55 error += ", ";
56 }
57 error += DataSpecUtils::describe(specs[i]);
58 }
59 }
60 error += ". If this is expected, please change its lifetime to Sporadic / QA.";
61 first = true;
62 for (size_t i = 0; i < specs.size(); ++i) {
63 if (present[i] == true) {
64 if (first) {
65 error += " Present outputs are: ";
66 first = false;
67 } else {
68 error += ", ";
69 }
70 error += DataSpecUtils::describe(specs[i]);
71 }
72 }
73 if (first) {
74 error += " No output was present.";
75 } else {
76 error += ".";
77 }
78 return error;
79}
80} // namespace o2::framework
int32_t i
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
static std::string describe(InputSpec const &spec)
static bool match(InputSpec const &spec, ConcreteDataMatcher const &target)
static void for_each_header(fair::mq::Parts &parts, F &&f)
static void updateMissingSporadic(fair::mq::Parts &parts, std::vector< OutputSpec > const &specs, std::vector< bool > &present)
static std::string describeMissingOutputs(std::vector< OutputSpec > const &specs, std::vector< bool > const &present)