From 30bb32b3658191e638b04b7c59c868a43a665783 Mon Sep 17 00:00:00 2001 From: ariffero Date: Mon, 16 Jun 2025 15:12:27 +0200 Subject: [PATCH 1/4] Allow custom timestamps Allow to put custom timestamps in the json used to build the manual reject list. --- .../MUON/MID/Calibration/macros/README.md | 4 ++ .../MID/Calibration/macros/build_rejectlist.C | 44 +++++++++++++++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Detectors/MUON/MID/Calibration/macros/README.md b/Detectors/MUON/MID/Calibration/macros/README.md index 83e88f18ecf48..f2cf2aa8bf78b 100644 --- a/Detectors/MUON/MID/Calibration/macros/README.md +++ b/Detectors/MUON/MID/Calibration/macros/README.md @@ -72,6 +72,8 @@ This can be done with a json file in the form: { "startRun": 557251, "endRun": 557926, + "startTT": 1726300235000, + "endTT": 1726324000000, "rejectList": [ { "deId": 4, @@ -99,6 +101,8 @@ This can be done with a json file in the form: } ``` +Where `startTT` and `endTT` are the timestamps in which the manual reject list will be built. To use the timestamps of start/end of the specified runs set `startTT` and `endTT` to 0 (or do not include them in the json). + The path to the file is then given to the macro with: ```shell diff --git a/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C b/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C index 48391b4460687..a5e461fc06c57 100644 --- a/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C +++ b/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C @@ -316,25 +316,53 @@ RejectListStruct load_from_json(const o2::ccdb::CcdbApi& ccdbApi, const char* fi { // Open the JSON file std::cout << "Reading reject list from file " << filename << std::endl; - RejectListStruct rl; std::ifstream inFile(filename); if (!inFile.is_open()) { std::cerr << "Could not open the file!" << std::endl; - return rl; + return {}; } // Create an IStreamWrapper for file input stream rapidjson::IStreamWrapper isw(inFile); - rapidjson::Document doc; if (doc.ParseStream(isw).HasParseError()) { std::cerr << "Problem parsing " << filename << std::endl; - return rl; + return {}; } - auto startRange = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, doc["startRun"].GetInt()); - auto endRange = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, doc["endRun"].GetInt()); - rl.start = startRange.first; - rl.end = endRange.second; + + // manual-validity interval in ms: + int64_t startTSms = 0; + int64_t endTSms = 0; + + // check if there are non-zero timestamps in the json + bool hasStartTT = doc.HasMember("startTT") && doc["startTT"].IsInt64() && doc["startTT"].GetInt64() != 0; + bool hasEndTT = doc.HasMember("endTT") && doc["endTT"].IsInt64() && doc["endTT"].GetInt64() != 0; + if (hasStartTT && hasEndTT) { + startTSms = doc["startTT"].GetInt64(); + endTSms = doc["endTT"].GetInt64(); + + // sanity check against the run boundaries + int startRun = doc["startRun"].GetInt(); + int endRun = doc["endRun"].GetInt(); + auto runStart = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first; + auto runEnd = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second; + if (startTSms < runStart || endTSms > runEnd) { + std::cout + << "\n\nWarning: manual timestamps [" << startTSms << " - " << endTSms + << "] lie outside run interval [" << runStart << " - " << runEnd << "]\n\n\n"; + } + } else { + // use run start/end if there are no timestamps in the json + int startRun = doc["startRun"].GetInt(); + int endRun = doc["endRun"].GetInt(); + startTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first; + endTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second; + } + + + RejectListStruct rl; + rl.start = startTSms; + rl.end = endTSms; std::cout << "Manual RL validity: " << timeRangeToString(rl.start, rl.end) << std::endl; auto rlArray = doc["rejectList"].GetArray(); for (auto& ar : rlArray) { From 1f3900e484525c4c05db33071ac207d2f29ab7c2 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 16 Jun 2025 13:30:30 +0000 Subject: [PATCH 2/4] Please consider the following formatting changes --- .../MID/Calibration/macros/build_rejectlist.C | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C b/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C index a5e461fc06c57..46f46b3dd99d4 100644 --- a/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C +++ b/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C @@ -329,23 +329,23 @@ RejectListStruct load_from_json(const o2::ccdb::CcdbApi& ccdbApi, const char* fi std::cerr << "Problem parsing " << filename << std::endl; return {}; } - + // manual-validity interval in ms: int64_t startTSms = 0; int64_t endTSms = 0; // check if there are non-zero timestamps in the json bool hasStartTT = doc.HasMember("startTT") && doc["startTT"].IsInt64() && doc["startTT"].GetInt64() != 0; - bool hasEndTT = doc.HasMember("endTT") && doc["endTT"].IsInt64() && doc["endTT"].GetInt64() != 0; + bool hasEndTT = doc.HasMember("endTT") && doc["endTT"].IsInt64() && doc["endTT"].GetInt64() != 0; if (hasStartTT && hasEndTT) { startTSms = doc["startTT"].GetInt64(); - endTSms = doc["endTT"].GetInt64(); + endTSms = doc["endTT"].GetInt64(); // sanity check against the run boundaries - int startRun = doc["startRun"].GetInt(); - int endRun = doc["endRun"].GetInt(); - auto runStart = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first; - auto runEnd = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second; + int startRun = doc["startRun"].GetInt(); + int endRun = doc["endRun"].GetInt(); + auto runStart = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first; + auto runEnd = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second; if (startTSms < runStart || endTSms > runEnd) { std::cout << "\n\nWarning: manual timestamps [" << startTSms << " - " << endTSms @@ -354,15 +354,14 @@ RejectListStruct load_from_json(const o2::ccdb::CcdbApi& ccdbApi, const char* fi } else { // use run start/end if there are no timestamps in the json int startRun = doc["startRun"].GetInt(); - int endRun = doc["endRun"].GetInt(); + int endRun = doc["endRun"].GetInt(); startTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first; - endTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second; + endTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second; } - RejectListStruct rl; rl.start = startTSms; - rl.end = endTSms; + rl.end = endTSms; std::cout << "Manual RL validity: " << timeRangeToString(rl.start, rl.end) << std::endl; auto rlArray = doc["rejectList"].GetArray(); for (auto& ar : rlArray) { From ebf2f92446459110a392c3243122aeeb82dbcd61 Mon Sep 17 00:00:00 2001 From: Andrea Giovanni Riffero Date: Mon, 16 Jun 2025 18:26:17 +0200 Subject: [PATCH 3/4] Minor changes in varaible declaration --- .../MUON/MID/Calibration/macros/build_rejectlist.C | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C b/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C index 46f46b3dd99d4..a57364ba5e3cf 100644 --- a/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C +++ b/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C @@ -334,6 +334,10 @@ RejectListStruct load_from_json(const o2::ccdb::CcdbApi& ccdbApi, const char* fi int64_t startTSms = 0; int64_t endTSms = 0; + //run numbers from the json + int startRun = doc["startRun"].GetInt(); + int endRun = doc["endRun"].GetInt(); + // check if there are non-zero timestamps in the json bool hasStartTT = doc.HasMember("startTT") && doc["startTT"].IsInt64() && doc["startTT"].GetInt64() != 0; bool hasEndTT = doc.HasMember("endTT") && doc["endTT"].IsInt64() && doc["endTT"].GetInt64() != 0; @@ -342,8 +346,6 @@ RejectListStruct load_from_json(const o2::ccdb::CcdbApi& ccdbApi, const char* fi endTSms = doc["endTT"].GetInt64(); // sanity check against the run boundaries - int startRun = doc["startRun"].GetInt(); - int endRun = doc["endRun"].GetInt(); auto runStart = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first; auto runEnd = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second; if (startTSms < runStart || endTSms > runEnd) { @@ -353,8 +355,6 @@ RejectListStruct load_from_json(const o2::ccdb::CcdbApi& ccdbApi, const char* fi } } else { // use run start/end if there are no timestamps in the json - int startRun = doc["startRun"].GetInt(); - int endRun = doc["endRun"].GetInt(); startTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first; endTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second; } @@ -480,4 +480,4 @@ void build_rejectlist(long start, long end, const char* qcdbUrl = "http://ali-qc outCCDBApi.storeAsTFileAny(&rl.rejectList, "MID/Calib/RejectList", metadata, rl.start, rl.end); } } -} \ No newline at end of file +} From 814343ba6ca0ed2743e61b5dca598a5463ac1312 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 16 Jun 2025 16:26:52 +0000 Subject: [PATCH 4/4] Please consider the following formatting changes --- Detectors/MUON/MID/Calibration/macros/build_rejectlist.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C b/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C index a57364ba5e3cf..5cec2c611bcf8 100644 --- a/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C +++ b/Detectors/MUON/MID/Calibration/macros/build_rejectlist.C @@ -334,7 +334,7 @@ RejectListStruct load_from_json(const o2::ccdb::CcdbApi& ccdbApi, const char* fi int64_t startTSms = 0; int64_t endTSms = 0; - //run numbers from the json + // run numbers from the json int startRun = doc["startRun"].GetInt(); int endRun = doc["endRun"].GetInt();