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
5 changes: 4 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 @@ -139,6 +139,7 @@ add_library(O2QualityControl
src/ObjectMetadataHelpers.cxx
src/QCInputsAdapters.cxx
src/QCInputsFactory.cxx
src/UserInputOutput.cxx
)

target_include_directories(
Expand Down Expand Up @@ -276,6 +277,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 All @@ -293,6 +295,7 @@ add_executable(o2-qc-test-core
test/testFlagHelpers.cxx
test/testQualitiesToFlagCollectionConverter.cxx
test/testQCInputs.cxx
test/testUserInputOutput.cxx
)
set_property(TARGET o2-qc-test-core
PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
Expand Down
57 changes: 57 additions & 0 deletions Framework/include/QualityControl/DataHeaderHelpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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.

#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 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 a 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 hashLength == 4 will result in "veryLongNameABCD", where ABCD
/// is the hash create inside the function
///
/// \param name - name which should cut and hashed
/// \param hashLength - number of bytes which will overwrite the end of the name
o2::header::DataDescription createDataDescription(const std::string& name, size_t hashLength);

/// \brief Creates DataDescription from given name for a 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 hashLength == 4 will result in "veryLongNameABCD", where ABCD
/// is the hash create inside the function.
/// This function deduces hash length for the provided data source type.
///
/// \param name - name which should cut and hashed
/// \param type - data source type associated to an actor
o2::header::DataDescription createDataDescription(const std::string& name, DataSourceType type);

} // namespace o2::quality_control::core

#endif
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
37 changes: 0 additions & 37 deletions Framework/include/QualityControl/HashDataDescription.h

This file was deleted.

46 changes: 46 additions & 0 deletions Framework/include/QualityControl/UserInputOutput.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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 UserInputOutput.h
/// \author Piotr Konopka
///

#ifndef QUALITYCONTROL_USERINPUTOUTPUT_H
#define QUALITYCONTROL_USERINPUTOUTPUT_H

#include <string>

#include <Framework/ConcreteDataMatcher.h>
#include <Framework/InputSpec.h>
#include <Framework/OutputSpec.h>

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

namespace o2::quality_control::core
{

/// \brief returns a standard ConcreteDataMatcher for QC inputs and outputs
framework::ConcreteDataMatcher
createUserDataMatcher(DataSourceType dataSourceType, const std::string& detectorName, const std::string& userCodeName);

/// \brief returns a standard InputSpec for QC inputs and outputs
framework::InputSpec
createUserInputSpec(DataSourceType dataSourceType, const std::string& detectorName, const std::string& userCodeName);

/// \brief returns a standard OutputSpec for QC inputs and outputs
framework::OutputSpec
createUserOutputSpec(DataSourceType dataSourceType, const std::string& detectorName, const std::string& userCodeName);

} // namespace o2::quality_control::core

#endif // QUALITYCONTROL_USERINPUTOUTPUT_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 Expand Up @@ -62,4 +100,29 @@ auto createDataDescription(const std::string& name, size_t hashLength) -> o2::he
}
}

constexpr size_t descriptionHashLengthFor(DataSourceType type)
{
size_t hashLength = 0;
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 hash length");
case DataSourceType::Task:
case DataSourceType::TaskMovingWindow:
case DataSourceType::Check:
case DataSourceType::Aggregator:
case DataSourceType::PostProcessingTask:
default:
hashLength = 4;
}
assert(hashLength <= o2::header::DataDescription::size);
return hashLength;
}

auto createDataDescription(const std::string& name, DataSourceType type) -> o2::header::DataDescription
{
return createDataDescription(name, descriptionHashLengthFor(type));
}

} // namespace o2::quality_control::core
1 change: 1 addition & 0 deletions Framework/src/InfrastructureGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "QualityControl/TaskRunner.h"
#include "QualityControl/TaskRunnerFactory.h"
#include "QualityControl/Version.h"
#include "QualityControl/UserInputOutput.h"

#include <Framework/DataProcessorSpec.h>
#include <Framework/DataRefUtils.h>
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
Loading