From 2e1865a353f4d42bc375da5b07b5f7e92f8be69b Mon Sep 17 00:00:00 2001 From: Diego Stocco Date: Tue, 14 Nov 2023 19:01:25 +0100 Subject: [PATCH] Add possibility to upload and query the MID fake dead list in ccdb --- .../MUON/MID/Calibration/macros/ccdbUtils.C | 75 +++++++++++++++---- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/Detectors/MUON/MID/Calibration/macros/ccdbUtils.C b/Detectors/MUON/MID/Calibration/macros/ccdbUtils.C index 0e3ac4bfbcfa5..92938838cccb8 100644 --- a/Detectors/MUON/MID/Calibration/macros/ccdbUtils.C +++ b/Detectors/MUON/MID/Calibration/macros/ccdbUtils.C @@ -33,18 +33,19 @@ const std::string BadChannelCCDBPath = "MID/Calib/BadChannels"; /// @param ccdbUrl CCDB url /// @param timestamp Timestamp /// @param verbose True for verbose output -void queryBadChannels(const char* ccdbUrl, long timestamp, bool verbose) +void queryBadChannels(const char* ccdbUrl, long timestamp, bool verbose, const std::string path) { o2::ccdb::CcdbApi api; api.init(ccdbUrl); std::map metadata; - auto* badChannels = api.retrieveFromTFileAny>(BadChannelCCDBPath.c_str(), metadata, timestamp); + auto* badChannels = api.retrieveFromTFileAny>(path.c_str(), metadata, timestamp); if (!badChannels) { - std::cout << "Error: cannot find " << BadChannelCCDBPath << " in " << ccdbUrl << std::endl; + std::cout << "Error: cannot find " << path << " in " << ccdbUrl << std::endl; return; } std::cout << "number of bad channels = " << badChannels->size() << std::endl; if (verbose) { + std::sort(badChannels->begin(), badChannels->end(), [](const o2::mid::ColumnData& c1, const o2::mid::ColumnData& c2) { return o2::mid::getColumnDataUniqueId(c1.deId, c1.columnId) < o2::mid::getColumnDataUniqueId(c2.deId, c2.columnId); }); for (const auto& badChannel : *badChannels) { std::cout << badChannel << "\n"; } @@ -89,18 +90,19 @@ void writeDCSMasks(const char* ccdbUrl, long timestamp, const char* outFilename outFile.close(); } -/// @brief Uploads the list of bad channels provided +/// @brief Uploads the list of channels provided /// @param ccdbUrl CCDB url /// @param timestamp Timestamp /// @param badChannels List of bad channels. Default is no bad channel -void uploadBadChannels(const char* ccdbUrl, long timestamp, std::vector badChannels = {}) +/// @param path Calibration object path +void uploadBadChannels(const char* ccdbUrl, long timestamp, const std::string path, std::vector channels = {}) { o2::ccdb::CcdbApi api; api.init(ccdbUrl); std::map md; - std::cout << "storing default MID bad channels (valid from " << timestamp << ") to " << BadChannelCCDBPath << "\n"; + std::cout << "Storing MID problematic channels (valid from " << timestamp << ") to " << path << "\n"; - api.storeAsTFileAny(&badChannels, BadChannelCCDBPath, md, timestamp, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); + api.storeAsTFileAny(&channels, path, md, timestamp, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); } /// @brief Reads the DCS masks from a file @@ -171,7 +173,48 @@ void uploadBadChannelsFromDCSMask(const char* filename, long timestamp, const ch std::cout << col << std::endl; } } - uploadBadChannels(ccdbUrl, timestamp, badChannels); + uploadBadChannels(ccdbUrl, timestamp, BadChannelCCDBPath, badChannels); +} + +/// @brief Generates the list of fake dead channels +/// @return Fake dead channels +std::vector makeFakeDeadChannels() +{ + // In the comments: + // - the fake deads are obtained from special calibration runs with modified FET phase + // - expected refers to the expected fake dead channels obtained by Baptiste + // by comparing the masked channels with the default masks. + std::vector fakeDeads; + // fakeDeads.push_back({0, 3, 0x81, 0x0, 0x0, 0x0, 0x0}); // 40; X1; expected: 0x0; data 10/2023 + fakeDeads.push_back({6, 5, 0x0, 0x2a00, 0x0, 0x0, 0x0}); // 6c; X1; expected: 0x0; data 12/2023: 0x2e00 + fakeDeads.push_back({7, 5, 0x0, 0x6bff, 0x0, 0x0, 0x0}); // 6e; X1; expected: 0x0; data 10/2023: 0x28ff + fakeDeads.push_back({9, 5, 0x0, 0x0, 0x0, 0x0, 0x2}); // 60; Y2; expected: 0x0 + fakeDeads.push_back({10, 2, 0x0, 0x0, 0x0, 0x0, 0xe0}); // 31; Y2; + fakeDeads.push_back({10, 4, 0x805f, 0x0, 0x0, 0x0, 0x0}); // 51; X2; expected: 0x905e; data 12/2023: 0x5f + fakeDeads.push_back({14, 5, 0x0, 0x0, 0x0, 0x0, 0x80}); // 69; Y2; + fakeDeads.push_back({16, 2, 0x0, 0x0, 0x0, 0x0, 0xe0}); // 2c; Y2; expected: 0x80; data 10/2023: 0xa0 + fakeDeads.push_back({16, 3, 0x0, 0xf00, 0x0, 0x0, 0x0}); // 4e; X2; expected: 0x0; data 10/2023: 0x300 + fakeDeads.push_back({25, 1, 0x0, 0x0, 0x0, 0x0, 0x63}); // 24; Y3; expected: 0xa + // fakeDeads.push_back({34, 2, 0x0, 0x0, 0x0, 0x0, 0x20}); // 2c; Y4; expected: 0x0; data 10/2023 + fakeDeads.push_back({42, 5, 0x0, 0x2d00, 0x0, 0x0, 0x0}); // ec; X2; expected: 0x0; data 12/2023: 0x2f00 + fakeDeads.push_back({43, 4, 0x0, 0x0, 0x0, 0x0, 0x20}); // dd; Y1; expected: 0x0 + fakeDeads.push_back({43, 5, 0x0, 0xff, 0x0, 0x0, 0x0}); // ee; X1; expected: 0x0; data 10/2023: 0xf3 + fakeDeads.push_back({44, 3, 0x0, 0x0, 0x0, 0x0, 0x2}); // cf; Y1; expected: 0x0 + fakeDeads.push_back({44, 5, 0x2000, 0x0, 0x0, 0x0, 0x0}); // ef; X1; expected: 0x0 + fakeDeads.push_back({44, 6, 0x0, 0x0, 0x0, 0x0, 0xf}); // f8; Y1; expected: 0x0; data 10/2023: 0x7 + fakeDeads.push_back({46, 1, 0x0, 0x0, 0x0, 0x0, 0xc0}); // 91; Y2; expected: 0xc0; data 12/2023: 0x40 + fakeDeads.push_back({46, 2, 0x0, 0x0, 0x0, 0x0, 0xc0}); // b1; Y2; expected: 0xe0; data 10/2023: 0xe0 + fakeDeads.push_back({46, 3, 0x0, 0x0, 0x0, 0x0, 0xc0}); // c1; Y2; + fakeDeads.push_back({46, 4, 0x0, 0x0, 0x0, 0x0, 0x58}); // d1; Y2; expected: 0xe8; data 10/2023: 0x60 + fakeDeads.push_back({46, 5, 0x0, 0x0, 0x0, 0x0, 0x60}); // e1; Y2; + fakeDeads.push_back({47, 3, 0x1, 0x0, 0x0, 0x0, 0x0}); // c3; X2; expected: 0x9d; data 10/2023: 0x15 + // fakeDeads.push_back({47, 5, 0x1, 0x0, 0x0, 0x0, 0x0}); // e3; X2; 0 (expected only) + fakeDeads.push_back({52, 2, 0x0, 0x0, 0x0, 0x0, 0xf8}); // ac; Y2; expected: 0xb0; data 10/2023: 0xf0 + fakeDeads.push_back({52, 3, 0x0, 0x0, 0x0, 0x0, 0x80}); // cd; Y2; expected: 0x0 + // fakeDeads.push_back({64, 4, 0x0, 0x0, 0x0, 0x0, 0x40}); // d1; Y4; expected: 0x0; data 12/2023 + fakeDeads.push_back({68, 5, 0x0, 0x0, 0x0, 0x0, 0xe2}); // e9; Y4; expected: 0x0; data 10/2023: 0xe0 + + return fakeDeads; } /// @brief Utility to query or upload bad channels and masks from/to the CCDB @@ -185,17 +228,23 @@ void ccdbUtils(const char* what, long timestamp = 0, const char* inFilename = "m timestamp = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); } - std::vector whats = {"querybad", "uploadbad", "querymasks", "writemasks", "uploadbadfrommasks"}; + std::vector whats = {"querybad", "uploadbad", "queryfake", "uploadfake", "querymasks", "writemasks", "uploadbadfrommasks"}; + + const std::string fakeDeadChannelCCDBPath = "MID/Calib/FakeDeadChannels"; if (what == whats[0]) { - queryBadChannels(ccdbUrl, timestamp, verbose); + queryBadChannels(ccdbUrl, timestamp, verbose, BadChannelCCDBPath); } else if (what == whats[1]) { - uploadBadChannels(ccdbUrl, timestamp); + uploadBadChannels(ccdbUrl, timestamp, BadChannelCCDBPath); } else if (what == whats[2]) { - queryDCSMasks(ccdbUrl, timestamp, verbose); + queryBadChannels(ccdbUrl, timestamp, verbose, fakeDeadChannelCCDBPath); } else if (what == whats[3]) { - writeDCSMasks(ccdbUrl, timestamp); + uploadBadChannels(ccdbUrl, timestamp, fakeDeadChannelCCDBPath); } else if (what == whats[4]) { + queryDCSMasks(ccdbUrl, timestamp, verbose); + } else if (what == whats[5]) { + writeDCSMasks(ccdbUrl, timestamp); + } else if (what == whats[6]) { uploadBadChannelsFromDCSMask(inFilename, timestamp, ccdbUrl, verbose); } else { std::cout << "Unimplemented option chosen " << what << std::endl;