Skip to content

Commit 88838a8

Browse files
authored
Allow for smooth move to the new naming of QC flags (#13053)
1 parent 86578c8 commit 88838a8

File tree

8 files changed

+136
-45
lines changed

8 files changed

+136
-45
lines changed

DataFormats/QualityControl/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ o2_add_library(DataFormatsQualityControl
4343
)
4444
4545
o2_target_root_dictionary(DataFormatsQualityControl
46-
HEADERS include/DataFormatsQualityControl/FlagReasons.h
46+
HEADERS include/DataFormatsQualityControl/FlagType.h
47+
include/DataFormatsQualityControl/FlagReasons.h
48+
include/DataFormatsQualityControl/QualityControlFlag.h
4749
include/DataFormatsQualityControl/TimeRangeFlag.h
4850
include/DataFormatsQualityControl/TimeRangeFlagCollection.h)
4951
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
#ifndef O2_QUALITYCONTROL_FLAGTYPE_H
13+
#define O2_QUALITYCONTROL_FLAGTYPE_H
14+
15+
#include "DataFormatsQualityControl/FlagReasons.h"
16+
17+
namespace o2::quality_control
18+
{
19+
using FlagType = o2::quality_control::FlagReason;
20+
}
21+
22+
#endif // O2_QUALITYCONTROL_FLAGTYPE_H
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
#ifndef O2_QUALITYCONTROL_FLAGTYPEFACTORY_H
13+
#define O2_QUALITYCONTROL_FLAGTYPEFACTORY_H
14+
15+
#include "DataFormatsQualityControl/FlagReasonFactory.h"
16+
17+
namespace o2::quality_control
18+
{
19+
using FlagTypeFactory = o2::quality_control::FlagReasonFactory;
20+
}
21+
22+
#endif // O2_QUALITYCONTROL_FLAGTYPEFACTORY_H
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
#ifndef O2_QUALITYCONTROL_QCFLAG_H
13+
#define O2_QUALITYCONTROL_QCFLAG_H
14+
15+
#include "DataFormatsQualityControl/TimeRangeFlag.h"
16+
17+
namespace o2::quality_control
18+
{
19+
using QualityControlFlag = o2::quality_control::TimeRangeFlag;
20+
}
21+
22+
#endif // O2_QUALITYCONTROL_QCFLAG_H
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
#ifndef O2_QUALITYCONTROL_QCFLAGCOLLECTION_H
13+
#define O2_QUALITYCONTROL_QCFLAGCOLLECTION_H
14+
15+
#include "DataFormatsQualityControl/TimeRangeFlagCollection.h"
16+
17+
namespace o2::quality_control
18+
{
19+
using QualityControlFlagCollection = o2::quality_control::TimeRangeFlagCollection;
20+
}
21+
22+
#endif // O2_QUALITYCONTROL_QCFLAGCOLLECTION_H

DataFormats/QualityControl/test/testFlagReasons.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
#define BOOST_TEST_MODULE Test quality_control FlagReasons class
12+
#define BOOST_TEST_MODULE Test quality_control FlagTypes class
1313
#define BOOST_TEST_MAIN
1414
#define BOOST_TEST_DYN_LINK
1515

@@ -19,20 +19,20 @@
1919
#include <iostream>
2020

2121
// o2 includes
22-
#include "DataFormatsQualityControl/FlagReasons.h"
23-
#include "DataFormatsQualityControl/FlagReasonFactory.h"
22+
#include "DataFormatsQualityControl/FlagType.h"
23+
#include "DataFormatsQualityControl/FlagTypeFactory.h"
2424

2525
using namespace o2::quality_control;
2626

27-
BOOST_AUTO_TEST_CASE(FlagReasons)
27+
BOOST_AUTO_TEST_CASE(FlagTypes)
2828
{
29-
static_assert(std::is_constructible<FlagReason, uint16_t, const char*, bool>::value == false,
30-
"FlagReason should not be constructible outside of its static methods and the factory.");
29+
static_assert(std::is_constructible<FlagType, uint16_t, const char*, bool>::value == false,
30+
"FlagType should not be constructible outside of its static methods and the factory.");
3131

32-
FlagReason rDefault;
33-
BOOST_CHECK_EQUAL(rDefault, FlagReasonFactory::Invalid());
32+
FlagType rDefault;
33+
BOOST_CHECK_EQUAL(rDefault, FlagTypeFactory::Invalid());
3434

35-
auto r1 = FlagReasonFactory::Unknown();
35+
auto r1 = FlagTypeFactory::Unknown();
3636
BOOST_CHECK_EQUAL(r1.getID(), 1);
3737
BOOST_CHECK_EQUAL(r1.getName(), "Unknown");
3838
BOOST_CHECK_EQUAL(r1.getBad(), true);
@@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(FlagReasons)
5050
BOOST_CHECK(!(r1 < r2));
5151
BOOST_CHECK(!(r1 > r2));
5252

53-
auto r3 = FlagReasonFactory::LimitedAcceptance();
53+
auto r3 = FlagTypeFactory::LimitedAcceptance();
5454
BOOST_CHECK(r3 > r1);
5555
BOOST_CHECK(!(r3 < r1));
5656
}

DataFormats/QualityControl/test/testTimeRangeFlag.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
#define BOOST_TEST_MODULE Test quality_control TimeRangeFlag class
12+
#define BOOST_TEST_MODULE Test quality_control QualityControlFlag class
1313
#define BOOST_TEST_MAIN
1414
#define BOOST_TEST_DYN_LINK
1515

1616
// boost includes
1717
#include <boost/test/unit_test.hpp>
1818

1919
// o2 includes
20-
#include "DataFormatsQualityControl/TimeRangeFlag.h"
20+
#include "DataFormatsQualityControl/QualityControlFlag.h"
2121

2222
using namespace o2::quality_control;
2323

24-
BOOST_AUTO_TEST_CASE(test_TimeRangeFlag)
24+
BOOST_AUTO_TEST_CASE(test_QualityControlFlag)
2525
{
26-
TimeRangeFlag trf1{12, 34, FlagReasonFactory::BadTracking(), "comment", "source"};
26+
QualityControlFlag trf1{12, 34, FlagReasonFactory::BadTracking(), "comment", "source"};
2727

2828
BOOST_CHECK_EQUAL(trf1.getStart(), 12);
2929
BOOST_CHECK_EQUAL(trf1.getEnd(), 34);
3030
BOOST_CHECK_EQUAL(trf1.getFlag(), FlagReasonFactory::BadTracking());
3131
BOOST_CHECK_EQUAL(trf1.getComment(), "comment");
3232
BOOST_CHECK_EQUAL(trf1.getSource(), "source");
3333

34-
BOOST_CHECK_THROW((TimeRangeFlag{12, 0, FlagReasonFactory::BadTracking()}), std::runtime_error);
34+
BOOST_CHECK_THROW((QualityControlFlag{12, 0, FlagReasonFactory::BadTracking()}), std::runtime_error);
3535

36-
TimeRangeFlag trf2{10, 34, FlagReasonFactory::BadTracking(), "comment", "source"};
36+
QualityControlFlag trf2{10, 34, FlagReasonFactory::BadTracking(), "comment", "source"};
3737

3838
BOOST_CHECK(trf1 > trf2);
3939
BOOST_CHECK(!(trf1 < trf2));

DataFormats/QualityControl/test/testTimeRangeFlagCollection.cxx

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
#define BOOST_TEST_MODULE Test quality_control TimeRangeFlagCollection class
12+
#define BOOST_TEST_MODULE Test quality_control QualityControlFlagCollection class
1313
#define BOOST_TEST_MAIN
1414
#define BOOST_TEST_DYN_LINK
1515

@@ -18,20 +18,21 @@
1818
// STL
1919
#include <sstream>
2020
// o2 includes
21-
#include "DataFormatsQualityControl/TimeRangeFlagCollection.h"
22-
#include "DataFormatsQualityControl/TimeRangeFlag.h"
21+
#include "DataFormatsQualityControl/QualityControlFlagCollection.h"
22+
#include "DataFormatsQualityControl/QualityControlFlag.h"
23+
#include "DataFormatsQualityControl/FlagTypeFactory.h"
2324

2425
using namespace o2::quality_control;
2526

26-
BOOST_AUTO_TEST_CASE(test_TimeRangeFlagCollection_Methods)
27+
BOOST_AUTO_TEST_CASE(test_QualityControlFlagCollection_Methods)
2728
{
28-
TimeRangeFlag trf1{12, 34, FlagReasonFactory::BadTracking(), "comment", "source"};
29-
TimeRangeFlag trf2{10, 34, FlagReasonFactory::BadTracking(), "comment", "source"};
29+
QualityControlFlag trf1{12, 34, FlagTypeFactory::BadTracking(), "comment", "source"};
30+
QualityControlFlag trf2{10, 34, FlagTypeFactory::BadTracking(), "comment", "source"};
3031

31-
TimeRangeFlagCollection trfc1{"Raw data checks", "TOF", {10, 20000}, 12345, "LHC22k5", "passMC", "qc_mc"};
32+
QualityControlFlagCollection trfc1{"Raw data checks", "TOF", {10, 20000}, 12345, "LHC22k5", "passMC", "qc_mc"};
3233
trfc1.insert(trf1); // by copy
3334
trfc1.insert(trf2);
34-
trfc1.insert({50, 77, FlagReasonFactory::Invalid()}); // by move
35+
trfc1.insert({50, 77, FlagTypeFactory::Invalid()}); // by move
3536
BOOST_CHECK_EQUAL(trfc1.size(), 3);
3637
BOOST_CHECK_EQUAL(trfc1.getName(), "Raw data checks");
3738
BOOST_CHECK_EQUAL(trfc1.getDetector(), "TOF");
@@ -42,31 +43,31 @@ BOOST_AUTO_TEST_CASE(test_TimeRangeFlagCollection_Methods)
4243
BOOST_CHECK_EQUAL(trfc1.getPassName(), "passMC");
4344
BOOST_CHECK_EQUAL(trfc1.getProvenance(), "qc_mc");
4445

45-
TimeRangeFlagCollection trfc2{"Reco checks", "TOF"};
46-
trfc2.insert({50, 77, FlagReasonFactory::Invalid()}); // this is a duplicate to an entry in trfc1
47-
trfc2.insert({51, 77, FlagReasonFactory::Invalid()});
48-
trfc2.insert({1234, 3434, FlagReasonFactory::LimitedAcceptance()});
49-
trfc2.insert({50, 77, FlagReasonFactory::LimitedAcceptance()});
46+
QualityControlFlagCollection trfc2{"Reco checks", "TOF"};
47+
trfc2.insert({50, 77, FlagTypeFactory::Invalid()}); // this is a duplicate to an entry in trfc1
48+
trfc2.insert({51, 77, FlagTypeFactory::Invalid()});
49+
trfc2.insert({1234, 3434, FlagTypeFactory::LimitedAcceptance()});
50+
trfc2.insert({50, 77, FlagTypeFactory::LimitedAcceptance()});
5051
BOOST_CHECK_EQUAL(trfc2.size(), 4);
5152

5253
// Try merging. Duplicate entries should be left in the 'other' objects.
5354
// Notice that we merge the two partial TRFCs into the third, which covers all cases
54-
TimeRangeFlagCollection trfc3{"ALL", "TOF"};
55+
QualityControlFlagCollection trfc3{"ALL", "TOF"};
5556
trfc3.merge(trfc1);
5657
trfc3.merge(trfc2);
5758
BOOST_CHECK_EQUAL(trfc1.size(), 0);
5859
BOOST_CHECK_EQUAL(trfc2.size(), 1);
5960
BOOST_CHECK_EQUAL(trfc3.size(), 6);
6061

6162
// Try const merging. It should copy the elements and keep the 'other' intact.
62-
TimeRangeFlagCollection trfc4{"ALL", "TOF"};
63+
QualityControlFlagCollection trfc4{"ALL", "TOF"};
6364
const auto& constTrfc3 = trfc3;
6465
trfc4.merge(constTrfc3);
6566
BOOST_CHECK_EQUAL(trfc3.size(), 6);
6667
BOOST_CHECK_EQUAL(trfc4.size(), 6);
6768

6869
// Try merging different detectors - it should throw.
69-
TimeRangeFlagCollection trfc5{"ALL", "TPC"};
70+
QualityControlFlagCollection trfc5{"ALL", "TPC"};
7071
BOOST_CHECK_THROW(trfc5.merge(trfc3), std::runtime_error);
7172
BOOST_CHECK_THROW(trfc5.merge(constTrfc3), std::runtime_error);
7273

@@ -79,31 +80,31 @@ BOOST_AUTO_TEST_CASE(test_TimeRangeFlagCollection_Methods)
7980
}
8081
}
8182

82-
BOOST_AUTO_TEST_CASE(test_TimeRangeFlagCollection_IO)
83+
BOOST_AUTO_TEST_CASE(test_QualityControlFlagCollection_IO)
8384
{
8485
{
85-
TimeRangeFlagCollection trfc1{"xyz", "TST"};
86+
QualityControlFlagCollection trfc1{"xyz", "TST"};
8687

8788
std::stringstream store;
8889
trfc1.streamTo(store);
8990

90-
TimeRangeFlagCollection trfc2{"xyz", "TST"};
91+
QualityControlFlagCollection trfc2{"xyz", "TST"};
9192
trfc2.streamFrom(store);
9293

9394
BOOST_CHECK_EQUAL(trfc2.size(), 0);
9495
}
9596
{
96-
TimeRangeFlagCollection trfc1{"xyz", "TST"};
97-
trfc1.insert({50, 77, FlagReasonFactory::Invalid(), "a comment", "a source"});
98-
trfc1.insert({51, 77, FlagReasonFactory::Invalid()});
99-
trfc1.insert({1234, 3434, FlagReasonFactory::LimitedAcceptance()});
100-
trfc1.insert({50, 77, FlagReasonFactory::LimitedAcceptance()});
101-
trfc1.insert({43434, 63421, FlagReasonFactory::NotBadFlagExample()});
97+
QualityControlFlagCollection trfc1{"xyz", "TST"};
98+
trfc1.insert({50, 77, FlagTypeFactory::Invalid(), "a comment", "a source"});
99+
trfc1.insert({51, 77, FlagTypeFactory::Invalid()});
100+
trfc1.insert({1234, 3434, FlagTypeFactory::LimitedAcceptance()});
101+
trfc1.insert({50, 77, FlagTypeFactory::LimitedAcceptance()});
102+
trfc1.insert({43434, 63421, FlagTypeFactory::NotBadFlagExample()});
102103

103104
std::stringstream store;
104105
trfc1.streamTo(store);
105106

106-
TimeRangeFlagCollection trfc2{"xyz", "TST"};
107+
QualityControlFlagCollection trfc2{"xyz", "TST"};
107108
trfc2.streamFrom(store);
108109

109110
BOOST_REQUIRE_EQUAL(trfc1.size(), trfc2.size());
@@ -115,7 +116,7 @@ BOOST_AUTO_TEST_CASE(test_TimeRangeFlagCollection_IO)
115116
std::stringstream store;
116117
store << "start,end,flag_id,invalid,header,format\n";
117118
store << R"(123,345,11,"fdsa",1,"comment","source")";
118-
TimeRangeFlagCollection trfc1{"A", "TST"};
119+
QualityControlFlagCollection trfc1{"A", "TST"};
119120
BOOST_CHECK_THROW(trfc1.streamFrom(store), std::runtime_error);
120121
}
121122
{
@@ -128,7 +129,7 @@ BOOST_AUTO_TEST_CASE(test_TimeRangeFlagCollection_IO)
128129
store << R"(123,345,,"fdsa",1,"comment","source")" << '\n';
129130
store << R"(123,345,11,"",1,"comment","source")" << '\n';
130131
store << R"(123,345,11,"fdsa",,"comment","source")" << '\n';
131-
TimeRangeFlagCollection trfc1{"A", "TST"};
132+
QualityControlFlagCollection trfc1{"A", "TST"};
132133
BOOST_CHECK_NO_THROW(trfc1.streamFrom(store));
133134
BOOST_CHECK_EQUAL(trfc1.size(), 0);
134135
}

0 commit comments

Comments
 (0)