Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Framework/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}],
"extendedCheckParameters": {
"physics": {
"PROTON-PROTON": {
"pp": {
"myOwnKey1": "myOwnValue1c"
}
}
Expand Down
6 changes: 2 additions & 4 deletions Framework/include/QualityControl/runnerUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ std::string getFirstCheckName(const std::string& configurationSource);
bool hasChecks(const std::string& configSource);

template <typename T>
requires std::is_arithmetic_v<T>
T computeNumericalActivityField(framework::ServiceRegistryRef services, const std::string& name, T fallbackNumber = 0)
requires std::is_arithmetic_v<T>
T computeNumericalActivityField(framework::ServiceRegistryRef services, const std::string& name, T fallbackNumber = 0)
{
T result = 0;

Expand Down Expand Up @@ -86,8 +86,6 @@ uint64_t getCurrentTimestamp();

void initInfologger(framework::InitContext& iCtx, core::LogDiscardParameters infologgerDiscardParameters, std::string facility, std::string detectorName = "");

std::string translateBeamType(const std::string& pdpBeamType);

} // namespace o2::quality_control::core

#endif // QUALITYCONTROL_RUNNERUTILS_H
82 changes: 82 additions & 0 deletions Framework/script/updatePdpBeam.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

# Default values
PREFIX="o2/"
TMP_DIR="./consul_kv_backups"
mkdir -p "$TMP_DIR"
UPDATE=false

# --- Parse arguments ---
if [[ "$#" -eq 0 ]]; then
echo "Use -h or --help for usage"
exit 0
fi

while [[ "$#" -gt 0 ]]; do
case "$1" in
-u | --update)
UPDATE=true
;;
-p | --prefix)
PREFIX="$2"
shift
;;
-h | --help)
echo "Script to change any occurrence of \"PROTON-PROTON\" -> \"pp\", \"Pb-PROTON\" -> \"pPb\", \"Pb-Pb\" -> \"PbPb\""
echo "Usage: $0 [-p|--prefix <consul_prefix>] [-u|--update]"
echo
echo " -p, --prefix Prefix to search in Consul KV (default: o2/)"
echo " -u, --update Apply changes back to Consul"
exit 0
;;
*)
echo "❌ Unknown option: $1"
echo "Use -h or --help for usage"
exit 1
;;
esac
shift
done

echo "🔍 Using Consul prefix: $PREFIX"
[[ "$UPDATE" == true ]] && echo "🚀 Update mode: ON (values will be written back)" || echo "🔒 Dry-run mode: changes only printed/saved"

# --- Define replacement logic ---
replace() {
sed -e 's/\"PROTON-PROTON\"/"pp"/g' \
-e 's/\"Pb-PROTON\"/"pPb"/g' \
-e 's/\"Pb-Pb\"/"PbPb"/g'
}

# --- Fetch all keys ---
KEYS=$(consul kv get -recurse -keys "$PREFIX")

# --- Process each key ---
while IFS= read -r key; do
VALUE=$(consul kv get "$key")
MODIFIED=$(echo "$VALUE" | replace)

if [[ "$VALUE" != "$MODIFIED" ]]; then
SAFE_NAME=$(echo "$key" | sed 's|/|__|g')

ORIG_FILE="$TMP_DIR/$SAFE_NAME.orig"
NEW_FILE="$TMP_DIR/$SAFE_NAME.new"
DIFF_FILE="$TMP_DIR/$SAFE_NAME.diff"

echo "$VALUE" >"$ORIG_FILE"
echo "$MODIFIED" >"$NEW_FILE"
diff -u "$ORIG_FILE" "$NEW_FILE" >"$DIFF_FILE"

echo "✅ Changed key: $key"
echo " 📄 $ORIG_FILE"
echo " 🆕 $NEW_FILE"
echo " 📑 $DIFF_FILE"

if [[ "$UPDATE" == true ]]; then
echo "$MODIFIED" | consul kv put "$key" -
echo " 🔁 Updated in Consul: $key"
fi

echo "---------------------------------------"
fi
done <<<"$KEYS"
23 changes: 3 additions & 20 deletions Framework/src/runnerUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <boost/property_tree/json_parser.hpp>
#include <CommonUtils/StringUtils.h>
#include <cstdlib>
#include <regex>
#include <Configuration/ConfigurationFactory.h>
#include <Common/Exceptions.h>
Expand All @@ -28,6 +29,8 @@

#include <chrono>
#include <cstdint>
#include <stdexcept>
#include <string_view>
#include <DataFormatsParameters/ECSDataAdapters.h>

namespace o2::quality_control::core
Expand Down Expand Up @@ -91,25 +94,6 @@ std::string computeStringActivityField(framework::ServiceRegistryRef services, c
return property;
}

std::string translateBeamType(const std::string& pdpBeamType)
{
// convert the beam type received from pdp into the format we use in flp/ecs
std::string result = "";
if (pdpBeamType == "pp") {
result = "PROTON-PROTON";
} else if (pdpBeamType == "PbPb") {
result = "Pb-Pb";
} else if (pdpBeamType == "pPb") {
result = "Pb-PROTON";
} else if (pdpBeamType == "cosmic") {
result = "cosmic";
} else {
ILOG(Warning, Ops) << "Failed to convert the pdp beam type ('" << pdpBeamType << "'), returning an empty string" << ENDM;
}
ILOG(Debug, Devel) << "Translated pdp beam type '" << pdpBeamType << "' to '" << result << "'" << ENDM;
return result;
}

Activity computeActivity(framework::ServiceRegistryRef services, const Activity& fallbackActivity)
{
// for a complete list of the properties provided by ECS, see here: https://github.com/AliceO2Group/Control/blob/master/docs/handbook/configuration.md#variables-pushed-to-controlled-tasks
Expand All @@ -122,7 +106,6 @@ Activity computeActivity(framework::ServiceRegistryRef services, const Activity&
auto periodName = computeStringActivityField(services, "lhc_period", fallbackActivity.mPeriodName);
auto fillNumber = computeNumericalActivityField<int>(services, "fill_info_fill_number", fallbackActivity.mFillNumber);
auto beam_type = computeStringActivityField(services, "pdp_beam_type", fallbackActivity.mBeamType);
beam_type = translateBeamType(beam_type);

Activity activity(
runNumber,
Expand Down
40 changes: 20 additions & 20 deletions Framework/test/testCustomParameters.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,23 @@ TEST_CASE("test_at_optional")
TEST_CASE("test_at_optional_activity")
{
Activity activity;
activity.mBeamType = "PROTON-PROTON";
activity.mBeamType = "pp";
activity.mType = "PHYSICS";

CustomParameters cp;
cp.set("aaa", "AAA");
cp.set("bbb", "BBB");
cp.set("aaa", "asdf", "PHYSICS");
cp.set("aaa", "CCC", "PHYSICS", "PROTON-PROTON");
cp.set("aaa", "DDD", "PHYSICS", "Pb-Pb");
cp.set("aaa", "AAA", "TECHNICAL", "PROTON-PROTON");
cp.set("aaa", "CCC", "PHYSICS", "pp");
cp.set("aaa", "DDD", "PHYSICS", "PbPb");
cp.set("aaa", "AAA", "TECHNICAL", "pp");

CHECK(cp.atOptional("aaa", activity).value() == "CCC");
CHECK(cp.atOptional("abc", activity).has_value() == false);
CHECK(cp.atOptional("abc", activity).value_or("bla") == "bla");

Activity activity2;
activity.mBeamType = "Pb-Pb";
activity.mBeamType = "PbPb";
activity.mType = "PHYSICS";
CHECK(cp.atOptional("aaa", activity).value() == "DDD");
}
Expand Down Expand Up @@ -214,21 +214,21 @@ TEST_CASE("test_default_if_not_found_at_optional")
// prepare the CP
cp.set("key", "valueDefaultDefault", "default", "default");
cp.set("key", "valuePhysicsDefault", "PHYSICS", "default");
cp.set("key", "valuePhysicsPbPb", "PHYSICS", "Pb-Pb");
cp.set("key", "valuePhysicsPbPb", "PHYSICS", "PbPb");
cp.set("key", "valueCosmicsDefault", "COSMICS", "default");
cp.set("key", "valueCosmicsDefault", "default", "PROTON-PROTON");
cp.set("key", "valueCosmicsDefault", "default", "pp");

// check the data
CHECK(cp.atOptional("key").value() == "valueDefaultDefault");
CHECK(cp.atOptional("key", "PHYSICS").value() == "valuePhysicsDefault");
CHECK(cp.atOptional("key", "PHYSICS", "Pb-Pb").value() == "valuePhysicsPbPb");
CHECK(cp.atOptional("key", "PHYSICS", "PbPb").value() == "valuePhysicsPbPb");
CHECK(cp.atOptional("key", "COSMICS", "default").value() == "valueCosmicsDefault");
CHECK(cp.atOptional("key", "default", "PROTON-PROTON").value() == "valueCosmicsDefault");
CHECK(cp.atOptional("key", "default", "pp").value() == "valueCosmicsDefault");

// check when something is missing
CHECK(cp.atOptional("key", "PHYSICS", "PROTON-PROTON").value() == "valuePhysicsDefault"); // key is not defined for pp
CHECK(cp.atOptional("key", "TECHNICAL", "STRANGE").value() == "valueDefaultDefault"); // key is not defined for run nor beam
CHECK(cp.atOptional("key", "TECHNICAL", "PROTON-PROTON").value() == "valueCosmicsDefault"); // key is not defined for technical
CHECK(cp.atOptional("key", "PHYSICS", "pp").value() == "valuePhysicsDefault"); // key is not defined for pp
CHECK(cp.atOptional("key", "TECHNICAL", "STRANGE").value() == "valueDefaultDefault"); // key is not defined for run nor beam
CHECK(cp.atOptional("key", "TECHNICAL", "pp").value() == "valueCosmicsDefault"); // key is not defined for technical
}

TEST_CASE("test_default_if_not_found_at")
Expand All @@ -242,26 +242,26 @@ TEST_CASE("test_default_if_not_found_at")
// prepare the CP
cp.set("key", "valueDefaultDefault", "default", "default");
cp.set("key", "valuePhysicsDefault", "PHYSICS", "default");
cp.set("key", "valuePhysicsPbPb", "PHYSICS", "Pb-Pb");
cp.set("key", "valuePhysicsPbPb", "PHYSICS", "PbPb");
cp.set("key", "valueCosmicsDefault", "COSMICS", "default");
cp.set("key", "valueCosmicsDefault", "default", "PROTON-PROTON");
cp.set("key", "valueCosmicsDefault", "default", "pp");

// check the data
CHECK(cp.at("key") == "valueDefaultDefault");
CHECK(cp.at("key", "PHYSICS") == "valuePhysicsDefault");
CHECK(cp.at("key", "PHYSICS", "Pb-Pb") == "valuePhysicsPbPb");
CHECK(cp.at("key", "PHYSICS", "PbPb") == "valuePhysicsPbPb");
CHECK(cp.at("key", "COSMICS", "default") == "valueCosmicsDefault");
CHECK(cp.at("key", "default", "PROTON-PROTON") == "valueCosmicsDefault");
CHECK(cp.at("key", "default", "pp") == "valueCosmicsDefault");

// check when something is missing
CHECK(cp.at("key", "PHYSICS", "PROTON-PROTON") == "valuePhysicsDefault"); // key is not defined for pp
CHECK(cp.at("key", "TECHNICAL", "STRANGE") == "valueDefaultDefault"); // key is not defined for run nor beam
CHECK(cp.at("key", "TECHNICAL", "PROTON-PROTON") == "valueCosmicsDefault"); // key is not defined for technical
CHECK(cp.at("key", "PHYSICS", "pp") == "valuePhysicsDefault"); // key is not defined for pp
CHECK(cp.at("key", "TECHNICAL", "STRANGE") == "valueDefaultDefault"); // key is not defined for run nor beam
CHECK(cp.at("key", "TECHNICAL", "pp") == "valueCosmicsDefault"); // key is not defined for technical
}

TEST_CASE("test_getAllDefaults")
{
CustomParameters cp;
auto result = cp.getAllDefaults();
CHECK(result.size() == 0);
}
}
4 changes: 2 additions & 2 deletions Modules/CTP/src/qc-ctp.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
"MB1inputName" : "MTVX",
"MB2inputName" : "MVBA"
},
"PROTON-PROTON": {
"pp": {
"MBclassName" : "CMTVX-B-NOPF",
"MB1inputName" : "MTVX",
"MB2inputName" : "MTVA"
},
"Pb-Pb": {
"PbPb": {
"MBclassName" : "CMTCE-B-NOPF",
"MB1inputName" : "MTSC",
"MB2inputName" : "MTCE"
Expand Down
2 changes: 1 addition & 1 deletion Modules/Common/etc/reference-comparator-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
},
"PHYSICS": {
"PROTON-PROTON": {
"pp": {
"referenceRun" : "551890"
}
}
Expand Down
6 changes: 3 additions & 3 deletions Modules/ITS/itsCluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Activity": {
"number": "42",
"type": "PHYSICS",
"beamType" : "PbPb", "": "Beam type: `PROTON-PROTON`, `Pb-Pb`, `Pb-PROTON` "
"beamType" : "PbPb", "": "Beam type: `pp`, `PbPb`, `pPb` "
},
"monitoring": {
"url": "infologger:///debug?qc"
Expand Down Expand Up @@ -91,7 +91,7 @@
"maxcluoccL5": "0.2",
"maxcluoccL6": "0.2"
},
"PROTON-PROTON": {
"pp": {
"maxcluoccL0": "5",
"maxcluoccL1": "3",
"maxcluoccL2": "3",
Expand All @@ -100,7 +100,7 @@
"maxcluoccL5": "0.2",
"maxcluoccL6": "0.2"
},
"Pb-Pb": {
"PbPb": {
"maxcluoccL0": "65",
"maxcluoccL1": "35",
"maxcluoccL2": "25",
Expand Down
6 changes: 3 additions & 3 deletions Modules/ITS/itsFee.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Activity": {
"number": "42",
"type": "PHYSICS",
"beamType" : "PbPb", "": "Beam type: `PROTON-PROTON`, `Pb-Pb`, `Pb-PROTON` "
"beamType" : "PbPb", "": "Beam type: `pp`, `PbPb`, `pPb` "
},
"monitoring": {
"url": "infologger:///debug?qc"
Expand Down Expand Up @@ -78,10 +78,10 @@
"default": {
"expectedROFperOrbit": "18"
},
"PROTON-PROTON": {
"pp": {
"expectedROFperOrbit": "18"
},
"Pb-Pb": {
"PbPb": {
"expectedROFperOrbit": "6"
}
},
Expand Down
Loading