Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ add_library(O2QualityControl
src/InfrastructureSpecReader.cxx
src/Check.cxx
src/Aggregator.cxx
src/HashDataDescription.cxx
src/DataHeaderHelpers.cxx
src/Triggers.cxx
src/TriggerHelpers.cxx
src/PostProcessingRunner.cxx
Expand Down Expand Up @@ -276,6 +276,7 @@ add_executable(o2-qc-test-core
test/testCheckInterface.cxx
test/testCheckRunner.cxx
test/testCustomParameters.cxx
test/testDataHeaderHelpers.cxx
test/testInfrastructureGenerator.cxx
test/testMonitorObject.cxx
test/testPolicyManager.cxx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,34 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef QC_HASH_DATA_DESCRIPTION_H
#define QC_HASH_DATA_DESCRIPTION_H
#ifndef QC_DATA_HEADER_HELPERS_H
#define QC_DATA_HEADER_HELPERS_H

#include <cstddef>
#include <string>

#include <Headers/DataHeader.h>

#include "QualityControl/DataSourceType.h"

namespace o2::quality_control::core
{

/// \brief Creates DataDescription from given name.
/// \brief Creates DataOrigin for a QC Actor.
///
/// Creates DataOrigin for a data source and detector code
header::DataOrigin createDataOrigin(DataSourceType, const std::string& detectorCode);

/// \brief Creates DataDescription from given name for any QC actor
///
/// If the length of the name is <= 16 (hardcoded in DataDescription) it creates DataDescription from the original name.
/// However, if the length of the name is > 16, it will create hash of the whole name and replace ending hashLength of bytes
/// of the name with hexa representation of computed hash.
/// eg.: name == "veryLongNameThatIsLongerThan16B" with hashLengh == 4 will result in "veryLongNameABCD", where ABCD
/// eg.: name == "veryLongNameThatIsLongerThan16B" with hashLength == 4 will result in "veryLongNameABCD", where ABCD
/// is the hash create inside the function
///
/// \param name - name which should cut and hashed
/// \param hashLenght - number of bytes which will overwrite the end of the name
/// \param hashLength - number of bytes which will overwrite the end of the name
o2::header::DataDescription createDataDescription(const std::string& name, size_t hashLength);

} // namespace o2::quality_control::core
Expand Down
14 changes: 2 additions & 12 deletions Framework/include/QualityControl/DataSourceSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,11 @@
#include <Framework/InputSpec.h>
#include <type_traits>

#include "QualityControl/DataSourceType.h"

namespace o2::quality_control::core
{

enum class DataSourceType {
DataSamplingPolicy,
Direct,
Task,
TaskMovingWindow,
Check,
Aggregator,
PostProcessingTask,
ExternalTask,
Invalid
};

// this should allow us to represent all data sources which come from DPL (and maybe CCDB).
struct DataSourceSpec {
explicit DataSourceSpec(DataSourceType type = DataSourceType::Invalid);
Expand Down
37 changes: 37 additions & 0 deletions Framework/include/QualityControl/DataSourceType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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 DataSourceType.h
/// \author Piotr Konopka
///

#ifndef QUALITYCONTROL_DATASOURCETYPE_H
#define QUALITYCONTROL_DATASOURCETYPE_H

namespace o2::quality_control::core
{

enum class DataSourceType {
DataSamplingPolicy,
Direct,
Task,
TaskMovingWindow,
Check,
Aggregator,
PostProcessingTask,
ExternalTask,
Invalid
};

}

#endif // QUALITYCONTROL_DATASOURCETYPE_H
2 changes: 1 addition & 1 deletion Framework/src/Aggregator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "QualityControl/Activity.h"
#include <Common/Exceptions.h>
#include "QualityControl/CommonSpec.h"
#include "QualityControl/HashDataDescription.h"
#include "QualityControl/DataHeaderHelpers.h"

#include <utility>
#include <algorithm>
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/AggregatorRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "QualityControl/ConfigParamGlo.h"
#include "QualityControl/Bookkeeping.h"
#include "QualityControl/WorkflowType.h"
#include "QualityControl/HashDataDescription.h"
#include "QualityControl/DataHeaderHelpers.h"

using namespace AliceO2::Common;
using namespace AliceO2::InfoLogger;
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/Check.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "QualityControl/RootClassFactory.h"
#include "QualityControl/QcInfoLogger.h"
#include "QualityControl/Quality.h"
#include "QualityControl/HashDataDescription.h"
#include "QualityControl/DataHeaderHelpers.h"
#include "QualityControl/ObjectMetadataHelpers.h"

#include <QualityControl/AggregatorRunner.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,50 @@
#include <iomanip>
#include <sstream>

#include "QualityControl/HashDataDescription.h"
#include "QualityControl/DataHeaderHelpers.h"
#include "QualityControl/QcInfoLogger.h"

namespace o2::quality_control::core
{

constexpr char CharIdFrom(DataSourceType type)
{
switch (type) {
case DataSourceType::DataSamplingPolicy:
case DataSourceType::Direct:
case DataSourceType::ExternalTask:
throw std::invalid_argument("Provided data source type is not generated by QC, cannot provide a corresponding character");
case DataSourceType::Task:
return 'Q';
case DataSourceType::TaskMovingWindow:
return 'W';
case DataSourceType::Check:
return 'C';
case DataSourceType::Aggregator:
return 'A';
case DataSourceType::PostProcessingTask:
return 'P';
default:
throw std::invalid_argument("Unrecognized data source type");
}
}

header::DataOrigin createDataOrigin(DataSourceType dataSourceType, const std::string& detectorCode)
{
std::string originStr{ CharIdFrom(dataSourceType) };
if (detectorCode.empty()) {
throw std::invalid_argument{ "empty detector code for a data source origin" };
} else if (detectorCode.size() > 3) {
ILOG(Warning, Support) << "too long detector code for a task data origin: " + detectorCode + ", trying to survive with: " + detectorCode.substr(0, 3) << ENDM;
originStr += detectorCode.substr(0, 3);
} else {
originStr += detectorCode;
}
o2::header::DataOrigin origin;
origin.runtimeInit(originStr.c_str());
return origin;
}

namespace hash
{

Expand Down
2 changes: 1 addition & 1 deletion Framework/src/PostProcessingDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "QualityControl/PostProcessingInterface.h"
#include "QualityControl/PostProcessingRunnerConfig.h"
#include "QualityControl/QcInfoLogger.h"
#include "QualityControl/HashDataDescription.h"
#include "QualityControl/DataHeaderHelpers.h"
#include "QualityControl/runnerUtils.h"

#include <Common/Exceptions.h>
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/TaskRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "QualityControl/TimekeeperFactory.h"
#include "QualityControl/ActivityHelpers.h"
#include "QualityControl/WorkflowType.h"
#include "QualityControl/HashDataDescription.h"
#include "QualityControl/DataHeaderHelpers.h"
#include "QualityControl/runnerUtils.h"

#include <string>
Expand Down
47 changes: 47 additions & 0 deletions Framework/test/testDataHeaderHelpers.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2019-2024 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 testDataHeaderHelpers.h
/// \author Piotr Konopka
///

#include <catch_amalgamated.hpp>

#include <Headers/DataHeader.h>

#include "QualityControl/DataHeaderHelpers.h"
#include "QualityControl/DataSourceType.h"

using namespace o2::quality_control::core;
using namespace o2::header;

TEST_CASE("DataOrigin")
{
CHECK_THROWS(createDataOrigin(DataSourceType::Direct, "TST")); // non-QC data source
CHECK_THROWS(createDataOrigin(DataSourceType::Task, "")); // empty detector is wrong

CHECK(createDataOrigin(DataSourceType::Task, "TST") == DataOrigin{ "QTST" });
CHECK(createDataOrigin(DataSourceType::TaskMovingWindow, "TST") == DataOrigin{ "WTST" });

CHECK(createDataOrigin(DataSourceType::Task, "TOO_LONG") == DataOrigin{ "QTOO" });
CHECK(createDataOrigin(DataSourceType::Task, "X") == DataOrigin{ "QX" });
}

TEST_CASE("DataDescription")
{
CHECK(createDataDescription("", 10) == DataDescription(""));
CHECK(createDataDescription("ABC", 10) == DataDescription("ABC"));
CHECK(createDataDescription("ABCDEABCDEABCDEA", 10) == DataDescription("ABCDEABCDEABCDEA"));
CHECK(createDataDescription("LOOOOOOOOOOOOOOONG", 4) != DataDescription("LOOOOOOOOOOOOOON"));

CHECK_THROWS(createDataDescription("LOOOOOOOOOOOOOOONG", DataDescription::size + 50));
}