Skip to content

Commit 220cee7

Browse files
author
Michal Tichák
committed
[Framework] changes necessary to switch beamType to pdpBeamType
1 parent 43c72f0 commit 220cee7

File tree

11 files changed

+121
-62
lines changed

11 files changed

+121
-62
lines changed

Framework/basic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
}],
8585
"extendedCheckParameters": {
8686
"physics": {
87-
"PROTON-PROTON": {
87+
"pp": {
8888
"myOwnKey1": "myOwnValue1c"
8989
}
9090
}

Framework/include/QualityControl/runnerUtils.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ std::string getFirstCheckName(const std::string& configurationSource);
4242
bool hasChecks(const std::string& configSource);
4343

4444
template <typename T>
45-
requires std::is_arithmetic_v<T>
46-
T computeNumericalActivityField(framework::ServiceRegistryRef services, const std::string& name, T fallbackNumber = 0)
45+
requires std::is_arithmetic_v<T>
46+
T computeNumericalActivityField(framework::ServiceRegistryRef services, const std::string& name, T fallbackNumber = 0)
4747
{
4848
T result = 0;
4949

@@ -86,8 +86,6 @@ uint64_t getCurrentTimestamp();
8686

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

89-
std::string translateBeamType(const std::string& pdpBeamType);
90-
9189
} // namespace o2::quality_control::core
9290

9391
#endif // QUALITYCONTROL_RUNNERUTILS_H

Framework/script/updatePdpBeam.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
# Default values
4+
PREFIX="o2/"
5+
TMP_DIR="./consul_kv_backups"
6+
mkdir -p "$TMP_DIR"
7+
UPDATE=false
8+
9+
# --- Parse arguments ---
10+
while [[ "$#" -gt 0 ]]; do
11+
case "$1" in
12+
-u|--update)
13+
UPDATE=true
14+
;;
15+
-p|--prefix)
16+
PREFIX="$2"
17+
shift
18+
;;
19+
-h|--help)
20+
echo "Usage: $0 [-p|--prefix <consul_prefix>] [-u|--update]"
21+
echo
22+
echo " -p, --prefix Prefix to search in Consul KV (default: o2/)"
23+
echo " -u, --update Apply changes back to Consul"
24+
exit 0
25+
;;
26+
*)
27+
echo "❌ Unknown option: $1"
28+
echo "Use -h or --help for usage"
29+
exit 1
30+
;;
31+
esac
32+
shift
33+
done
34+
35+
echo "🔍 Using Consul prefix: $PREFIX"
36+
[[ "$UPDATE" == true ]] && echo "🚀 Update mode: ON (values will be written back)" || echo "🔒 Dry-run mode: changes only printed/saved"
37+
38+
# --- Define replacement logic ---
39+
replace() {
40+
sed -e 's/PROTON-PROTON/pp/g' \
41+
-e 's/Pb-PROTON/pPb/g' \
42+
-e 's/Pb-Pb/PbPb/g'
43+
}
44+
45+
# --- Fetch all keys ---
46+
KEYS=$(consul kv get -recurse -keys "$PREFIX")
47+
48+
# --- Process each key ---
49+
while IFS= read -r key; do
50+
VALUE=$(consul kv get "$key")
51+
MODIFIED=$(echo "$VALUE" | replace)
52+
53+
if [[ "$VALUE" != "$MODIFIED" ]]; then
54+
SAFE_NAME=$(echo "$key" | sed 's|/|__|g')
55+
56+
ORIG_FILE="$TMP_DIR/$SAFE_NAME.orig"
57+
NEW_FILE="$TMP_DIR/$SAFE_NAME.new"
58+
DIFF_FILE="$TMP_DIR/$SAFE_NAME.diff"
59+
60+
echo "$VALUE" > "$ORIG_FILE"
61+
echo "$MODIFIED" > "$NEW_FILE"
62+
diff -u "$ORIG_FILE" "$NEW_FILE" > "$DIFF_FILE"
63+
64+
echo "✅ Changed key: $key"
65+
echo " 📄 $ORIG_FILE"
66+
echo " 🆕 $NEW_FILE"
67+
echo " 📑 $DIFF_FILE"
68+
69+
if [[ "$UPDATE" == true ]]; then
70+
echo "$MODIFIED" | consul kv put "$key" -
71+
echo " 🔁 Updated in Consul: $key"
72+
fi
73+
74+
echo "---------------------------------------"
75+
fi
76+
done <<< "$KEYS"

Framework/src/runnerUtils.cxx

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <boost/property_tree/json_parser.hpp>
2222
#include <CommonUtils/StringUtils.h>
23+
#include <cstdlib>
2324
#include <regex>
2425
#include <Configuration/ConfigurationFactory.h>
2526
#include <Common/Exceptions.h>
@@ -28,6 +29,8 @@
2829

2930
#include <chrono>
3031
#include <cstdint>
32+
#include <stdexcept>
33+
#include <string_view>
3134
#include <DataFormatsParameters/ECSDataAdapters.h>
3235

3336
namespace o2::quality_control::core
@@ -91,25 +94,6 @@ std::string computeStringActivityField(framework::ServiceRegistryRef services, c
9194
return property;
9295
}
9396

94-
std::string translateBeamType(const std::string& pdpBeamType)
95-
{
96-
// convert the beam type received from pdp into the format we use in flp/ecs
97-
std::string result = "";
98-
if (pdpBeamType == "pp") {
99-
result = "PROTON-PROTON";
100-
} else if (pdpBeamType == "PbPb") {
101-
result = "Pb-Pb";
102-
} else if (pdpBeamType == "pPb") {
103-
result = "Pb-PROTON";
104-
} else if (pdpBeamType == "cosmic") {
105-
result = "cosmic";
106-
} else {
107-
ILOG(Warning, Ops) << "Failed to convert the pdp beam type ('" << pdpBeamType << "'), returning an empty string" << ENDM;
108-
}
109-
ILOG(Debug, Devel) << "Translated pdp beam type '" << pdpBeamType << "' to '" << result << "'" << ENDM;
110-
return result;
111-
}
112-
11397
Activity computeActivity(framework::ServiceRegistryRef services, const Activity& fallbackActivity)
11498
{
11599
// 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
@@ -122,7 +106,8 @@ Activity computeActivity(framework::ServiceRegistryRef services, const Activity&
122106
auto periodName = computeStringActivityField(services, "lhc_period", fallbackActivity.mPeriodName);
123107
auto fillNumber = computeNumericalActivityField<int>(services, "fill_info_fill_number", fallbackActivity.mFillNumber);
124108
auto beam_type = computeStringActivityField(services, "pdp_beam_type", fallbackActivity.mBeamType);
125-
beam_type = translateBeamType(beam_type);
109+
110+
// throw std::runtime_error{"blaaaaaaaaallala"};
126111

127112
Activity activity(
128113
runNumber,

Framework/test/testCustomParameters.cxx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,23 @@ TEST_CASE("test_at_optional")
138138
TEST_CASE("test_at_optional_activity")
139139
{
140140
Activity activity;
141-
activity.mBeamType = "PROTON-PROTON";
141+
activity.mBeamType = "pp";
142142
activity.mType = "PHYSICS";
143143

144144
CustomParameters cp;
145145
cp.set("aaa", "AAA");
146146
cp.set("bbb", "BBB");
147147
cp.set("aaa", "asdf", "PHYSICS");
148-
cp.set("aaa", "CCC", "PHYSICS", "PROTON-PROTON");
149-
cp.set("aaa", "DDD", "PHYSICS", "Pb-Pb");
150-
cp.set("aaa", "AAA", "TECHNICAL", "PROTON-PROTON");
148+
cp.set("aaa", "CCC", "PHYSICS", "pp");
149+
cp.set("aaa", "DDD", "PHYSICS", "PbPb");
150+
cp.set("aaa", "AAA", "TECHNICAL", "pp");
151151

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

156156
Activity activity2;
157-
activity.mBeamType = "Pb-Pb";
157+
activity.mBeamType = "PbPb";
158158
activity.mType = "PHYSICS";
159159
CHECK(cp.atOptional("aaa", activity).value() == "DDD");
160160
}
@@ -214,21 +214,21 @@ TEST_CASE("test_default_if_not_found_at_optional")
214214
// prepare the CP
215215
cp.set("key", "valueDefaultDefault", "default", "default");
216216
cp.set("key", "valuePhysicsDefault", "PHYSICS", "default");
217-
cp.set("key", "valuePhysicsPbPb", "PHYSICS", "Pb-Pb");
217+
cp.set("key", "valuePhysicsPbPb", "PHYSICS", "PbPb");
218218
cp.set("key", "valueCosmicsDefault", "COSMICS", "default");
219-
cp.set("key", "valueCosmicsDefault", "default", "PROTON-PROTON");
219+
cp.set("key", "valueCosmicsDefault", "default", "pp");
220220

221221
// check the data
222222
CHECK(cp.atOptional("key").value() == "valueDefaultDefault");
223223
CHECK(cp.atOptional("key", "PHYSICS").value() == "valuePhysicsDefault");
224-
CHECK(cp.atOptional("key", "PHYSICS", "Pb-Pb").value() == "valuePhysicsPbPb");
224+
CHECK(cp.atOptional("key", "PHYSICS", "PbPb").value() == "valuePhysicsPbPb");
225225
CHECK(cp.atOptional("key", "COSMICS", "default").value() == "valueCosmicsDefault");
226-
CHECK(cp.atOptional("key", "default", "PROTON-PROTON").value() == "valueCosmicsDefault");
226+
CHECK(cp.atOptional("key", "default", "pp").value() == "valueCosmicsDefault");
227227

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

234234
TEST_CASE("test_default_if_not_found_at")
@@ -242,26 +242,26 @@ TEST_CASE("test_default_if_not_found_at")
242242
// prepare the CP
243243
cp.set("key", "valueDefaultDefault", "default", "default");
244244
cp.set("key", "valuePhysicsDefault", "PHYSICS", "default");
245-
cp.set("key", "valuePhysicsPbPb", "PHYSICS", "Pb-Pb");
245+
cp.set("key", "valuePhysicsPbPb", "PHYSICS", "PbPb");
246246
cp.set("key", "valueCosmicsDefault", "COSMICS", "default");
247-
cp.set("key", "valueCosmicsDefault", "default", "PROTON-PROTON");
247+
cp.set("key", "valueCosmicsDefault", "default", "pp");
248248

249249
// check the data
250250
CHECK(cp.at("key") == "valueDefaultDefault");
251251
CHECK(cp.at("key", "PHYSICS") == "valuePhysicsDefault");
252-
CHECK(cp.at("key", "PHYSICS", "Pb-Pb") == "valuePhysicsPbPb");
252+
CHECK(cp.at("key", "PHYSICS", "PbPb") == "valuePhysicsPbPb");
253253
CHECK(cp.at("key", "COSMICS", "default") == "valueCosmicsDefault");
254-
CHECK(cp.at("key", "default", "PROTON-PROTON") == "valueCosmicsDefault");
254+
CHECK(cp.at("key", "default", "pp") == "valueCosmicsDefault");
255255

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

262262
TEST_CASE("test_getAllDefaults")
263263
{
264264
CustomParameters cp;
265265
auto result = cp.getAllDefaults();
266266
CHECK(result.size() == 0);
267-
}
267+
}

Modules/CTP/src/qc-ctp.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@
5858
"MB1inputName" : "MTVX",
5959
"MB2inputName" : "MVBA"
6060
},
61-
"PROTON-PROTON": {
61+
"pp": {
6262
"MBclassName" : "CMTVX-B-NOPF",
6363
"MB1inputName" : "MTVX",
6464
"MB2inputName" : "MTVA"
6565
},
66-
"Pb-Pb": {
66+
"PbPb": {
6767
"MBclassName" : "CMTCE-B-NOPF",
6868
"MB1inputName" : "MTSC",
6969
"MB2inputName" : "MTCE"

Modules/Common/etc/reference-comparator-example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535
},
3636
"PHYSICS": {
37-
"PROTON-PROTON": {
37+
"pp": {
3838
"referenceRun" : "551890"
3939
}
4040
}

Modules/ITS/itsCluster.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"Activity": {
1212
"number": "42",
1313
"type": "PHYSICS",
14-
"beamType" : "PbPb", "": "Beam type: `PROTON-PROTON`, `Pb-Pb`, `Pb-PROTON` "
14+
"beamType" : "PbPb", "": "Beam type: `pp`, `PbPb`, `pPb` "
1515
},
1616
"monitoring": {
1717
"url": "infologger:///debug?qc"
@@ -91,7 +91,7 @@
9191
"maxcluoccL5": "0.2",
9292
"maxcluoccL6": "0.2"
9393
},
94-
"PROTON-PROTON": {
94+
"pp": {
9595
"maxcluoccL0": "5",
9696
"maxcluoccL1": "3",
9797
"maxcluoccL2": "3",
@@ -100,7 +100,7 @@
100100
"maxcluoccL5": "0.2",
101101
"maxcluoccL6": "0.2"
102102
},
103-
"Pb-Pb": {
103+
"PbPb": {
104104
"maxcluoccL0": "65",
105105
"maxcluoccL1": "35",
106106
"maxcluoccL2": "25",

Modules/ITS/itsFee.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"Activity": {
1212
"number": "42",
1313
"type": "PHYSICS",
14-
"beamType" : "PbPb", "": "Beam type: `PROTON-PROTON`, `Pb-Pb`, `Pb-PROTON` "
14+
"beamType" : "PbPb", "": "Beam type: `pp`, `PbPb`, `pPb` "
1515
},
1616
"monitoring": {
1717
"url": "infologger:///debug?qc"
@@ -78,10 +78,10 @@
7878
"default": {
7979
"expectedROFperOrbit": "18"
8080
},
81-
"PROTON-PROTON": {
81+
"pp": {
8282
"expectedROFperOrbit": "18"
8383
},
84-
"Pb-Pb": {
84+
"PbPb": {
8585
"expectedROFperOrbit": "6"
8686
}
8787
},

doc/Advanced.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,10 @@ The new syntax is
12951295
"myOwnKey1": "myOwnValue1b",
12961296
"myOwnKey2": "myOwnValue2b"
12971297
},
1298-
"PROTON-PROTON": {
1298+
"pp": {
12991299
"myOwnKey1": "myOwnValue1c"
13001300
},
1301-
"Pb-Pb": {
1301+
"PbPb": {
13021302
"myOwnKey1": "myOwnValue1d"
13031303
}
13041304
},
@@ -1310,7 +1310,7 @@ The new syntax is
13101310
```
13111311
It allows to have variations of the parameters depending on the run and beam types. The proper run types can be found here: [ECSDataAdapters.h](https://github.com/AliceO2Group/AliceO2/blob/dev/DataFormats/Parameters/include/DataFormatsParameters/ECSDataAdapters.h#L54). The `default` can be used
13121312
to ignore the run or the beam type.
1313-
The beam type is one of the following: `PROTON-PROTON`, `Pb-Pb`, `Pb-PROTON`, `cosmic`.
1313+
The beam type is one of the following: `pp`, `PbPb`, `pPb`, `cosmic`.
13141314

13151315
The values can be accessed in various ways described in the following sub-sections.
13161316

@@ -1322,9 +1322,9 @@ However, before returning an empty value we try to substitute the runType and th
13221322
```c++
13231323
// returns an Optional<string> if it finds the key `myOwnKey` for the runType and beamType of the provided activity,
13241324
// or if it can find the key with the runType or beamType substituted with "default".
1325-
auto param = mCustomParameters.atOptional("myOwnKey1", activity); // activity is "PHYSICS", "Pb-Pb" , returns "myOwnValue1d"
1325+
auto param = mCustomParameters.atOptional("myOwnKey1", activity); // activity is "PHYSICS", "PbPb" , returns "myOwnValue1d"
13261326
// same but passing directly the run and beam types
1327-
auto param = mCustomParameters.atOptional("myOwnKey1", "PHYSICS", "Pb-Pb"); // returns "myOwnValue1d"
1327+
auto param = mCustomParameters.atOptional("myOwnKey1", "PHYSICS", "PbPb"); // returns "myOwnValue1d"
13281328
// or with only the run type
13291329
auto param = mCustomParameters.atOptional("myOwnKey1", "PHYSICS"); // returns "myOwnValue1b"
13301330
```
@@ -1340,8 +1340,8 @@ mCustomParameters.at("myOwnKey"); // returns `myOwnValue`
13401340
mCustomParameters.at("myOwnKey", "default"); // returns `myOwnValue`
13411341
mCustomParameters.at("myOwnKey", "default", "default"); // returns `myOwnValue`
13421342

1343-
mCustomParameters.at("myOwnKey1", "PHYSICS", "PROTON-PROTON"); // returns `myOwnValue1c`
1344-
mCustomParameters.at("myOwnKey1", "PHYSICS", "Pb-Pb"); // returns `myOwnValue1d`
1343+
mCustomParameters.at("myOwnKey1", "PHYSICS", "pp"); // returns `myOwnValue1c`
1344+
mCustomParameters.at("myOwnKey1", "PHYSICS", "PbPb"); // returns `myOwnValue1d`
13451345
mCustomParameters.at("myOwnKey2", "COSMICS"); // returns `myOwnValue2e`
13461346

13471347
mCustomParameters.at("myOwnKey1", activity); // result will depend on activity
@@ -1434,7 +1434,7 @@ The configuration looks like
14341434
}
14351435
},
14361436
"PHYSICS": {
1437-
"PROTON-PROTON": {
1437+
"pp": {
14381438
"referenceRun" : "551890"
14391439
}
14401440
}
@@ -1540,7 +1540,7 @@ should not be present in real configuration files.
15401540
"provenance": "qc", "": "Provenance - qc or qc_mc depending whether it is normal data or monte carlo data",
15411541
"start" : "0", "": "Activity start time in ms since epoch. One can use it as a filter in post-processing",
15421542
"end" : "1234", "": "Activity end time in ms since epoch. One can use it as a filter in post-processing",
1543-
"beamType" : "PROTON-PROTON", "": "Beam type: `PROTON-PROTON`, `Pb-Pb`, `Pb-PROTON` ",
1543+
"beamType" : "pp", "": "Beam type: `pp`, `PbPb`, `pPb` ",
15441544
"partitionName" : "", "": "Partition name",
15451545
"fillNumber" : "123", "": "Fill Number"
15461546
},

0 commit comments

Comments
 (0)