Skip to content

Commit 639b9b2

Browse files
authored
QC-1160 Move to the new names for QC flags (#13073)
Needs new QC release. The documentation will be updated in a separate PR.
1 parent a725161 commit 639b9b2

18 files changed

+461
-563
lines changed

DataFormats/QualityControl/CMakeLists.txt

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,69 +10,65 @@
1010
# or submit itself to any jurisdiction.
1111

1212
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
13-
### Prepare the list of methods in FlagReasonFactory
14-
file(READ "etc/flagReasons.csv" CSV_FLAG_REASONS)
13+
### Prepare the list of methods in FlagTypeFactory
14+
file(READ "etc/flagTypes.csv" CSV_FLAG_TYPES)
1515
# delete the CSV file header
16-
string(REPLACE \"id\",\"method\",\"name\",\"bad\",\"obsolete\" "" CSV_FLAG_REASONS ${CSV_FLAG_REASONS})
16+
string(REPLACE \"id\",\"method\",\"name\",\"bad\",\"obsolete\" "" CSV_FLAG_TYPES ${CSV_FLAG_TYPES})
1717
# detects if there is obsolete flag '1' in the last column, adds [[deprecated]] if so and retains the rest of the string
1818
string(REGEX REPLACE \([0-9]+,\".[^\"]*.\",.[^\"]*.,[0-1]\),1
1919
"[[deprecated]] \\1,1"
20-
CSV_FLAG_REASONS
21-
${CSV_FLAG_REASONS})
20+
CSV_FLAG_TYPES
21+
${CSV_FLAG_TYPES})
2222
# replaces the flag reason entry with a c++ method to create it
2323
string(REGEX REPLACE \([0-9]+\),\"\(.[^\"]*.\)\",\(.[^\"]*.\),\([0-1]\),[0-1]
24-
"static FlagReason \\2\(\) { return { static_cast<uint16_t>\(\\1\), \\3, static_cast<bool>\(\\4\) }; }"
25-
CSV_FLAG_REASONS
26-
${CSV_FLAG_REASONS})
24+
"static FlagType \\2\(\) { return { static_cast<uint16_t>\(\\1\), \\3, static_cast<bool>\(\\4\) }; }"
25+
CSV_FLAG_TYPES
26+
${CSV_FLAG_TYPES})
2727
# put the method lists inside the template
28-
configure_file("include/DataFormatsQualityControl/FlagReasonFactory.h.in"
29-
"${CMAKE_CURRENT_BINARY_DIR}/include/DataFormatsQualityControl/FlagReasonFactory.h"
28+
configure_file("include/DataFormatsQualityControl/FlagTypeFactory.h.in"
29+
"${CMAKE_CURRENT_BINARY_DIR}/include/DataFormatsQualityControl/FlagTypeFactory.h"
3030
@ONLY)
31-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/DataFormatsQualityControl/FlagReasonFactory.h"
31+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/DataFormatsQualityControl/FlagTypeFactory.h"
3232
DESTINATION include/DataFormatsQualityControl)
3333

3434
o2_add_library(DataFormatsQualityControl
35-
SOURCES src/FlagReasons.cxx
36-
src/TimeRangeFlag.cxx
37-
src/TimeRangeFlagCollection.cxx
38-
PUBLIC_LINK_LIBRARIES O2::Headers
39-
O2::FrameworkLogger
35+
SOURCES src/FlagType.cxx
36+
src/QualityControlFlag.cxx
37+
src/QualityControlFlagCollection.cxx
38+
PUBLIC_LINK_LIBRARIES O2::FrameworkLogger
4039
O2::DetectorsCommonDataFormats
4140
PUBLIC_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/include
4241
include
4342
)
4443

4544
o2_target_root_dictionary(DataFormatsQualityControl
4645
HEADERS include/DataFormatsQualityControl/FlagType.h
47-
include/DataFormatsQualityControl/FlagReasons.h
4846
include/DataFormatsQualityControl/QualityControlFlag.h
49-
include/DataFormatsQualityControl/TimeRangeFlag.h
50-
include/DataFormatsQualityControl/TimeRangeFlagCollection.h)
51-
47+
include/DataFormatsQualityControl/QualityControlFlagCollection.h)
5248

5349

5450
if(BUILD_TESTING)
55-
o2_add_test(FlagReasons
56-
SOURCES test/testFlagReasons.cxx
51+
o2_add_test(FlagTypes
52+
SOURCES test/testFlagTypes.cxx
5753
COMPONENT_NAME DataFormatsQualityControl
5854
PUBLIC_LINK_LIBRARIES O2::DataFormatsQualityControl
59-
TARGETVARNAME flagreasons)
55+
TARGETVARNAME flagtypes)
6056

61-
target_include_directories(${flagreasons} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
57+
target_include_directories(${flagtypes} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
6258

63-
o2_add_test(TimeRangeFlag
64-
SOURCES test/testTimeRangeFlag.cxx
59+
o2_add_test(QualityControlFlag
60+
SOURCES test/testQualityControlFlag.cxx
6561
COMPONENT_NAME DataFormatsQualityControl
6662
PUBLIC_LINK_LIBRARIES O2::DataFormatsQualityControl
67-
TARGETVARNAME timerangeflag)
63+
TARGETVARNAME qualitycontrolflag)
6864

69-
target_include_directories(${timerangeflag} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include)
65+
target_include_directories(${qualitycontrolflag} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include)
7066

71-
o2_add_test(TimeRangeFlagCollection
72-
SOURCES test/testTimeRangeFlagCollection.cxx
67+
o2_add_test(QualityControlFlagCollection
68+
SOURCES test/testQualityControlFlagCollection.cxx
7369
COMPONENT_NAME DataFormatsQualityControl
7470
PUBLIC_LINK_LIBRARIES O2::DataFormatsQualityControl
75-
TARGETVARNAME timerangeflagcollection)
71+
TARGETVARNAME qualitycontrolflagcollection)
7672

77-
target_include_directories(${timerangeflagcollection} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include)
73+
target_include_directories(${qualitycontrolflagcollection} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include)
7874
endif()
File renamed without changes.

DataFormats/QualityControl/include/DataFormatsQualityControl/FlagReasons.h

Lines changed: 0 additions & 73 deletions
This file was deleted.

DataFormats/QualityControl/include/DataFormatsQualityControl/FlagType.h

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,53 @@
1212
#ifndef O2_QUALITYCONTROL_FLAGTYPE_H
1313
#define O2_QUALITYCONTROL_FLAGTYPE_H
1414

15-
#include "DataFormatsQualityControl/FlagReasons.h"
15+
// STL
16+
#include <iosfwd>
17+
#include <cstdint>
1618

17-
namespace o2::quality_control
19+
// ROOT includes
20+
#include <Rtypes.h>
21+
22+
namespace o2
23+
{
24+
namespace quality_control
25+
{
26+
27+
class FlagTypeFactory;
28+
class QualityControlFlagCollection;
29+
30+
class FlagType
1831
{
19-
using FlagType = o2::quality_control::FlagReason;
20-
}
32+
private:
33+
uint16_t mId;
34+
std::string mName;
35+
bool mBad; // if true, data should become bad by default
36+
37+
// By making the constructor private and FlagTypes available only in the FlagTypeFactory
38+
// we forbid to declare any flags in the user code. If you need a new FlagType, please add it FlagTypeFactory.
39+
private:
40+
FlagType(uint16_t id, const char* name, bool bad) : mId(id), mName(name), mBad(bad) {}
41+
42+
public:
43+
FlagType();
44+
FlagType& operator=(const FlagType&) = default;
45+
FlagType(const FlagType&) = default;
46+
bool operator==(const FlagType& rhs) const;
47+
bool operator!=(const FlagType& rhs) const;
48+
bool operator<(const FlagType& rhs) const;
49+
bool operator>(const FlagType& rhs) const;
50+
51+
uint16_t getID() const { return mId; }
52+
const std::string& getName() const { return mName; }
53+
bool getBad() const { return mBad; }
54+
55+
friend std::ostream& operator<<(std::ostream& os, FlagType const& me);
56+
friend class FlagTypeFactory;
57+
friend class QualityControlFlagCollection;
58+
59+
ClassDefNV(FlagType, 1);
60+
};
2161

62+
} // namespace quality_control
63+
} // namespace o2
2264
#endif // O2_QUALITYCONTROL_FLAGTYPE_H

DataFormats/QualityControl/include/DataFormatsQualityControl/FlagTypeFactory.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

DataFormats/QualityControl/include/DataFormatsQualityControl/FlagReasonFactory.h.in renamed to DataFormats/QualityControl/include/DataFormatsQualityControl/FlagTypeFactory.h.in

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

12-
/// \file FlagReasonFactory.h
13-
/// \brief A class to create FlagReasons based on the predefined CSV list.
12+
/// \file FlagTypeFactory.h
13+
/// \brief A class to create FlagTypes based on the predefined CSV list.
1414
/// \author Piotr Konopka, piotr.jan.konopka@cern.ch
1515

16-
#ifndef O2_FLAGREASONFACTORY_H
17-
#define O2_FLAGREASONFACTORY_H
16+
#ifndef O2_FLAGTYPEFACTORY_H
17+
#define O2_FLAGTYPEFACTORY_H
1818

19-
#include "DataFormatsQualityControl/FlagReasons.h"
19+
#include "DataFormatsQualityControl/FlagType.h"
2020

2121
namespace o2::quality_control
2222
{
2323

24-
class FlagReasonFactory {
24+
class FlagTypeFactory {
2525
public:
26-
FlagReasonFactory() = delete;
27-
@CSV_FLAG_REASONS@
26+
FlagTypeFactory() = delete;
27+
@CSV_FLAG_TYPES@
2828
};
2929

3030
} // namespace o2::quality_control
31-
#endif // O2_FLAGREASONFACTORY_H
31+
#endif // O2_FLAGTYPEFACTORY_H

DataFormats/QualityControl/include/DataFormatsQualityControl/QualityControlFlag.h

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,76 @@
1212
#ifndef O2_QUALITYCONTROL_QCFLAG_H
1313
#define O2_QUALITYCONTROL_QCFLAG_H
1414

15-
#include "DataFormatsQualityControl/TimeRangeFlag.h"
15+
/// \file QualityControlFlag.h
16+
/// \brief Class to define a flag type with a time range and comments
17+
/// \author Jens Wiechula, jens.wiechula@ikf.uni-frankfurt.de
18+
/// \author Piotr Konopka, piotr.jan.konopka@cern.ch
1619

17-
namespace o2::quality_control
20+
// System includes
21+
#include <iosfwd>
22+
#include <string>
23+
24+
// ROOT includes
25+
#include <Rtypes.h>
26+
27+
#include <MathUtils/detail/Bracket.h>
28+
29+
#include "DataFormatsQualityControl/FlagType.h"
30+
#include "DataFormatsQualityControl/FlagTypeFactory.h"
31+
32+
namespace o2
1833
{
19-
using QualityControlFlag = o2::quality_control::TimeRangeFlag;
20-
}
34+
namespace quality_control
35+
{
36+
37+
/// \class QualityControlFlag
38+
/// A Class for associating a bit mask with a time range
39+
class QualityControlFlag
40+
{
41+
public:
42+
using time_type = uint64_t;
43+
using RangeInterval = o2::math_utils::detail::Bracket<time_type>;
44+
45+
QualityControlFlag() = default;
46+
QualityControlFlag(QualityControlFlag const&) = default;
47+
QualityControlFlag(time_type start, time_type end, FlagType flag, std::string comment = "", std::string source = "Unknown");
48+
49+
time_type getStart() const { return mInterval.getMin(); }
50+
time_type getEnd() const { return mInterval.getMax(); }
51+
RangeInterval& getInterval() { return mInterval; }
52+
FlagType getFlag() const { return mFlag; }
53+
const std::string& getComment() const { return mComment; }
54+
const std::string& getSource() const { return mSource; }
55+
56+
void setStart(time_type start) { mInterval.setMin(start); }
57+
void setEnd(time_type end) { mInterval.setMax(end); }
58+
void setInterval(RangeInterval interval) { mInterval = interval; }
59+
void setFlag(FlagType flag) { mFlag = flag; }
60+
void setComment(const std::string& comment) { mComment = comment; }
61+
void setSource(const std::string& source) { mSource = source; }
62+
63+
/// equal operator
64+
bool operator==(const QualityControlFlag& rhs) const;
65+
66+
/// comparison operators
67+
bool operator<(const QualityControlFlag& rhs) const;
68+
bool operator>(const QualityControlFlag& rhs) const;
69+
70+
/// write data to ostream
71+
void streamTo(std::ostream& output) const;
72+
73+
/// overloading output stream operator
74+
friend std::ostream& operator<<(std::ostream& output, const QualityControlFlag& data);
75+
76+
private:
77+
RangeInterval mInterval = {}; ///< time interval of the masked range
78+
FlagType mFlag; ///< flag reason
79+
std::string mComment = ""; ///< optional comment, which may extend the reason
80+
std::string mSource = "Unknown"; ///< optional (but encouraged) source of the flag (e.g. Qc Check name)
81+
82+
ClassDefNV(QualityControlFlag, 1);
83+
};
2184

85+
} // namespace quality_control
86+
} // namespace o2
2287
#endif // O2_QUALITYCONTROL_QCFLAG_H

0 commit comments

Comments
 (0)