Skip to content

Commit 79f1117

Browse files
authored
[MID] Improve the macro for the reject list (#14411)
Allow to put custom timestamps in the json used to build the manual reject list.
1 parent ace4b6b commit 79f1117

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
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 & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,25 +316,52 @@ 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+
// run numbers from the json
338+
int startRun = doc["startRun"].GetInt();
339+
int endRun = doc["endRun"].GetInt();
340+
341+
// check if there are non-zero timestamps in the json
342+
bool hasStartTT = doc.HasMember("startTT") && doc["startTT"].IsInt64() && doc["startTT"].GetInt64() != 0;
343+
bool hasEndTT = doc.HasMember("endTT") && doc["endTT"].IsInt64() && doc["endTT"].GetInt64() != 0;
344+
if (hasStartTT && hasEndTT) {
345+
startTSms = doc["startTT"].GetInt64();
346+
endTSms = doc["endTT"].GetInt64();
347+
348+
// sanity check against the run boundaries
349+
auto runStart = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first;
350+
auto runEnd = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second;
351+
if (startTSms < runStart || endTSms > runEnd) {
352+
std::cout
353+
<< "\n\nWarning: manual timestamps [" << startTSms << " - " << endTSms
354+
<< "] lie outside run interval [" << runStart << " - " << runEnd << "]\n\n\n";
355+
}
356+
} else {
357+
// use run start/end if there are no timestamps in the json
358+
startTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, startRun).first;
359+
endTSms = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, endRun).second;
360+
}
361+
362+
RejectListStruct rl;
363+
rl.start = startTSms;
364+
rl.end = endTSms;
338365
std::cout << "Manual RL validity: " << timeRangeToString(rl.start, rl.end) << std::endl;
339366
auto rlArray = doc["rejectList"].GetArray();
340367
for (auto& ar : rlArray) {
@@ -453,4 +480,4 @@ void build_rejectlist(long start, long end, const char* qcdbUrl = "http://ali-qc
453480
outCCDBApi.storeAsTFileAny(&rl.rejectList, "MID/Calib/RejectList", metadata, rl.start, rl.end);
454481
}
455482
}
456-
}
483+
}

0 commit comments

Comments
 (0)