-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QC-1214 Updates and improvements to QO -> Flag conversion
The converter has been adapted to the rules below: - **Good QOs with no Flags are not onverted to any Flags** - **Bad and Medium QOs with no Flags are converted to Flag 14 (Unknown)** - **Null QOs with no Flags are converted to Flag 1** - **All QOs with Flags are converted to Flags, while Quality is ignored**. A warning should be printed if a Check associates a GOOD flag to BAD quality, or a BAD flag to GOOD quality. - **Timespans not covered by a given QO are filled with Flag 1 (Unknown Quality)** - **Overlapping or adjacent Flags with the same ID, comment and source (QO) are merged, even if they were associated to different Qualities.** - **Flag 1 (UnknownQuality) gets overwritten by any other Flag**. - **Good and Bad flags do not affect each other, they may coexist**. - **Flags for different QOs do not affect each other, Flag 1 is added separately for each.** - **The order of QO arrival should not matter**. Today, `QualitiesToFlagCollectionConverter` assumes it should receive quality flags in chronological order. However, this may not always be the case in sync QC, where validity start might slightly move to the past due unaligned validities of objects coming from EPNs, being merged in the merger nodes. Additionally the tests were extended and updated.
- Loading branch information
Showing
11 changed files
with
1,195 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
/// | ||
/// \file FlagHelpers.h | ||
/// \author Piotr Konopka | ||
/// | ||
|
||
#ifndef QUALITYCONTROL_FLAGHELPERS_H | ||
#define QUALITYCONTROL_FLAGHELPERS_H | ||
|
||
#include "DataFormatsQualityControl/QualityControlFlag.h" | ||
#include "QualityControl/ValidityInterval.h" | ||
#include <vector> | ||
#include <optional> | ||
|
||
namespace o2::quality_control::core::flag_helpers | ||
{ | ||
|
||
/// \brief returns true if the provided intervals are valid and are overlapping or adjacent | ||
bool intervalsConnect(const ValidityInterval& one, const ValidityInterval& other); | ||
|
||
/// \brief returns true if the provided intervals are valid and are overlapping (there is at least one 1ms common) | ||
bool intervalsOverlap(const ValidityInterval& one, const ValidityInterval& other); | ||
|
||
/// \brief Removes the provided interval from the flag. | ||
/// | ||
/// Removes the provided interval from the flag. A result can be: | ||
/// - an empty vector if the interval fully covers the flag's interval | ||
/// - a vector with one flag if the interval covers the flag's interval on one side | ||
/// - a vector with two flags if the interval is fully contained by the flag's interval | ||
std::vector<QualityControlFlag> excludeInterval(const QualityControlFlag& flag, ValidityInterval interval); | ||
|
||
/// Trims the provided flag to the intersection with the provided interval. | ||
/// If the intersection does not exist, it returns nullopt | ||
std::optional<QualityControlFlag> intersection(const QualityControlFlag& flag, ValidityInterval interval); | ||
|
||
} // namespace o2::quality_control::core::flag_helpers | ||
#endif // QUALITYCONTROL_FLAGHELPERS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
/// | ||
/// \file FlagHelpers.cxx | ||
/// \author Piotr Konopka | ||
/// | ||
|
||
#include "QualityControl/FlagHelpers.h" | ||
|
||
namespace o2::quality_control::core::flag_helpers | ||
{ | ||
|
||
bool intervalsConnect(const ValidityInterval& one, const ValidityInterval& other) | ||
{ | ||
// Object validity in CCDB is a right-open range, which means it includes the beginning and excludes the ending. | ||
// In other words, for the validity [1, 10), 9 is the last integer to be included. | ||
// Thus, ranges [1, 10) and [10, 20) are considered adjacent, while [1, 10) and [11, 20) are already separate | ||
// and should not be merged. | ||
return one.isValid() && other.isValid() && one.getMax() >= other.getMin() && one.getMin() <= other.getMax(); | ||
} | ||
|
||
bool intervalsOverlap(const ValidityInterval& one, const ValidityInterval& other) | ||
{ | ||
return one.isValid() && other.isValid() && one.getMax() > other.getMin() && one.getMin() < other.getMax(); | ||
} | ||
|
||
std::vector<QualityControlFlag> excludeInterval(const QualityControlFlag& flag, ValidityInterval interval) | ||
{ | ||
std::vector<QualityControlFlag> result; | ||
|
||
if (flag.getInterval().isInvalid()) { | ||
return result; | ||
} | ||
|
||
if (auto overlap = flag.getInterval().getOverlap(interval); overlap.isInvalid() || overlap.isZeroLength()) { | ||
result.push_back(flag); | ||
return result; | ||
} | ||
|
||
if (interval.getMin() > flag.getStart()) { | ||
result.emplace_back(flag.getStart(), interval.getMin(), flag.getFlag(), flag.getComment(), flag.getSource()); | ||
} | ||
if (interval.getMax() < flag.getEnd()) { | ||
result.emplace_back(interval.getMax(), flag.getEnd(), flag.getFlag(), flag.getComment(), flag.getSource()); | ||
} | ||
return result; | ||
} | ||
|
||
std::optional<QualityControlFlag> intersection(const QualityControlFlag& flag, ValidityInterval interval) | ||
{ | ||
if (flag.getInterval().isInvalid()) { | ||
return std::nullopt; | ||
} | ||
if (interval.isInvalid()) { | ||
return flag; | ||
} | ||
auto intersection = flag.getInterval().getOverlap(interval); | ||
if (intersection.isInvalid()) { | ||
return std::nullopt; | ||
} | ||
return QualityControlFlag{ intersection.getMin(), intersection.getMax(), flag.getFlag(), flag.getComment(), flag.getSource() }; | ||
} | ||
|
||
} // namespace o2::quality_control::core::flag_helpers |
Oops, something went wrong.