Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions Detectors/MUON/MID/Calibration/macros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
44 changes: 36 additions & 8 deletions Detectors/MUON/MID/Calibration/macros/build_rejectlist.C
Original file line number Diff line number Diff line change
Expand Up @@ -316,25 +316,53 @@
{
// 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;

Check failure on line 332 in Detectors/MUON/MID/Calibration/macros/build_rejectlist.C

View workflow job for this annotation

GitHub Actions / PR formatting / whitespace

Trailing spaces

Remove the trailing spaces at the end of the line.
Comment thread
pillot marked this conversation as resolved.
Outdated
// 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();
Comment thread
pillot marked this conversation as resolved.
Outdated
int endRun = doc["endRun"].GetInt();
Comment thread
pillot marked this conversation as resolved.
Outdated
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();
Comment thread
pillot marked this conversation as resolved.
Outdated
int endRun = doc["endRun"].GetInt();
Comment thread
pillot marked this conversation as resolved.
Outdated
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) {
Expand Down
Loading