Skip to content

Commit 30bb32b

Browse files
author
ariffero
committed
Allow custom timestamps
Allow to put custom timestamps in the json used to build the manual reject list.
1 parent d449a51 commit 30bb32b

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

Detectors/MUON/MID/Calibration/macros/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ This can be done with a json file in the form:
7272
{
7373
"startRun": 557251,
7474
"endRun": 557926,
75+
"startTT": 1726300235000,
76+
"endTT": 1726324000000,
7577
"rejectList": [
7678
{
7779
"deId": 4,
@@ -99,6 +101,8 @@ This can be done with a json file in the form:
99101
}
100102
```
101103

104+
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).
105+
102106
The path to the file is then given to the macro with:
103107

104108
```shell

Detectors/MUON/MID/Calibration/macros/build_rejectlist.C

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,25 +316,53 @@ RejectListStruct load_from_json(const o2::ccdb::CcdbApi& ccdbApi, const char* fi
316316
{
317317
// Open the JSON file
318318
std::cout << "Reading reject list from file " << filename << std::endl;
319-
RejectListStruct rl;
320319
std::ifstream inFile(filename);
321320
if (!inFile.is_open()) {
322321
std::cerr << "Could not open the file!" << std::endl;
323-
return rl;
322+
return {};
324323
}
325324

326325
// Create an IStreamWrapper for file input stream
327326
rapidjson::IStreamWrapper isw(inFile);
328-
329327
rapidjson::Document doc;
330328
if (doc.ParseStream(isw).HasParseError()) {
331329
std::cerr << "Problem parsing " << filename << std::endl;
332-
return rl;
330+
return {};
333331
}
334-
auto startRange = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, doc["startRun"].GetInt());
335-
auto endRange = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, doc["endRun"].GetInt());
336-
rl.start = startRange.first;
337-
rl.end = endRange.second;
332+
333+
// manual-validity interval in ms:
334+
int64_t startTSms = 0;
335+
int64_t endTSms = 0;
336+
337+
// check if there are non-zero timestamps in the json
338+
bool hasStartTT = doc.HasMember("startTT") && doc["startTT"].IsInt64() && doc["startTT"].GetInt64() != 0;
339+
bool hasEndTT = doc.HasMember("endTT") && doc["endTT"].IsInt64() && doc["endTT"].GetInt64() != 0;
340+
if (hasStartTT && hasEndTT) {
341+
startTSms = doc["startTT"].GetInt64();
342+
endTSms = doc["endTT"].GetInt64();
343+
344+
// sanity check against the run boundaries
345+
int startRun = doc["startRun"].GetInt();
346+
int endRun = doc["endRun"].GetInt();
347+
auto runStart = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first;
348+
auto runEnd = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second;
349+
if (startTSms < runStart || endTSms > runEnd) {
350+
std::cout
351+
<< "\n\nWarning: manual timestamps [" << startTSms << " - " << endTSms
352+
<< "] lie outside run interval [" << runStart << " - " << runEnd << "]\n\n\n";
353+
}
354+
} else {
355+
// use run start/end if there are no timestamps in the json
356+
int startRun = doc["startRun"].GetInt();
357+
int endRun = doc["endRun"].GetInt();
358+
startTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first;
359+
endTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second;
360+
}
361+
362+
363+
RejectListStruct rl;
364+
rl.start = startTSms;
365+
rl.end = endTSms;
338366
std::cout << "Manual RL validity: " << timeRangeToString(rl.start, rl.end) << std::endl;
339367
auto rlArray = doc["rejectList"].GetArray();
340368
for (auto& ar : rlArray) {

0 commit comments

Comments
 (0)