Skip to content

Commit c674fd1

Browse files
dstoccoalcaliva
authored andcommitted
Add possibility to upload and query the MID fake dead list in ccdb
1 parent 5020bf2 commit c674fd1

File tree

1 file changed

+62
-13
lines changed

1 file changed

+62
-13
lines changed

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

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,19 @@ const std::string BadChannelCCDBPath = "MID/Calib/BadChannels";
3333
/// @param ccdbUrl CCDB url
3434
/// @param timestamp Timestamp
3535
/// @param verbose True for verbose output
36-
void queryBadChannels(const char* ccdbUrl, long timestamp, bool verbose)
36+
void queryBadChannels(const char* ccdbUrl, long timestamp, bool verbose, const std::string path)
3737
{
3838
o2::ccdb::CcdbApi api;
3939
api.init(ccdbUrl);
4040
std::map<std::string, std::string> metadata;
41-
auto* badChannels = api.retrieveFromTFileAny<std::vector<o2::mid::ColumnData>>(BadChannelCCDBPath.c_str(), metadata, timestamp);
41+
auto* badChannels = api.retrieveFromTFileAny<std::vector<o2::mid::ColumnData>>(path.c_str(), metadata, timestamp);
4242
if (!badChannels) {
43-
std::cout << "Error: cannot find " << BadChannelCCDBPath << " in " << ccdbUrl << std::endl;
43+
std::cout << "Error: cannot find " << path << " in " << ccdbUrl << std::endl;
4444
return;
4545
}
4646
std::cout << "number of bad channels = " << badChannels->size() << std::endl;
4747
if (verbose) {
48+
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); });
4849
for (const auto& badChannel : *badChannels) {
4950
std::cout << badChannel << "\n";
5051
}
@@ -89,18 +90,19 @@ void writeDCSMasks(const char* ccdbUrl, long timestamp, const char* outFilename
8990
outFile.close();
9091
}
9192

92-
/// @brief Uploads the list of bad channels provided
93+
/// @brief Uploads the list of channels provided
9394
/// @param ccdbUrl CCDB url
9495
/// @param timestamp Timestamp
9596
/// @param badChannels List of bad channels. Default is no bad channel
96-
void uploadBadChannels(const char* ccdbUrl, long timestamp, std::vector<o2::mid::ColumnData> badChannels = {})
97+
/// @param path Calibration object path
98+
void uploadBadChannels(const char* ccdbUrl, long timestamp, const std::string path, std::vector<o2::mid::ColumnData> channels = {})
9799
{
98100
o2::ccdb::CcdbApi api;
99101
api.init(ccdbUrl);
100102
std::map<std::string, std::string> md;
101-
std::cout << "storing default MID bad channels (valid from " << timestamp << ") to " << BadChannelCCDBPath << "\n";
103+
std::cout << "Storing MID problematic channels (valid from " << timestamp << ") to " << path << "\n";
102104

103-
api.storeAsTFileAny(&badChannels, BadChannelCCDBPath, md, timestamp, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP);
105+
api.storeAsTFileAny(&channels, path, md, timestamp, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP);
104106
}
105107

106108
/// @brief Reads the DCS masks from a file
@@ -171,7 +173,48 @@ void uploadBadChannelsFromDCSMask(const char* filename, long timestamp, const ch
171173
std::cout << col << std::endl;
172174
}
173175
}
174-
uploadBadChannels(ccdbUrl, timestamp, badChannels);
176+
uploadBadChannels(ccdbUrl, timestamp, BadChannelCCDBPath, badChannels);
177+
}
178+
179+
/// @brief Generates the list of fake dead channels
180+
/// @return Fake dead channels
181+
std::vector<o2::mid::ColumnData> makeFakeDeadChannels()
182+
{
183+
// In the comments:
184+
// - the fake deads are obtained from special calibration runs with modified FET phase
185+
// - expected refers to the expected fake dead channels obtained by Baptiste
186+
// by comparing the masked channels with the default masks.
187+
std::vector<o2::mid::ColumnData> fakeDeads;
188+
// fakeDeads.push_back({0, 3, 0x81, 0x0, 0x0, 0x0, 0x0}); // 40; X1; expected: 0x0; data 10/2023
189+
fakeDeads.push_back({6, 5, 0x0, 0x2a00, 0x0, 0x0, 0x0}); // 6c; X1; expected: 0x0; data 12/2023: 0x2e00
190+
fakeDeads.push_back({7, 5, 0x0, 0x6bff, 0x0, 0x0, 0x0}); // 6e; X1; expected: 0x0; data 10/2023: 0x28ff
191+
fakeDeads.push_back({9, 5, 0x0, 0x0, 0x0, 0x0, 0x2}); // 60; Y2; expected: 0x0
192+
fakeDeads.push_back({10, 2, 0x0, 0x0, 0x0, 0x0, 0xe0}); // 31; Y2;
193+
fakeDeads.push_back({10, 4, 0x805f, 0x0, 0x0, 0x0, 0x0}); // 51; X2; expected: 0x905e; data 12/2023: 0x5f
194+
fakeDeads.push_back({14, 5, 0x0, 0x0, 0x0, 0x0, 0x80}); // 69; Y2;
195+
fakeDeads.push_back({16, 2, 0x0, 0x0, 0x0, 0x0, 0xe0}); // 2c; Y2; expected: 0x80; data 10/2023: 0xa0
196+
fakeDeads.push_back({16, 3, 0x0, 0xf00, 0x0, 0x0, 0x0}); // 4e; X2; expected: 0x0; data 10/2023: 0x300
197+
fakeDeads.push_back({25, 1, 0x0, 0x0, 0x0, 0x0, 0x63}); // 24; Y3; expected: 0xa
198+
// fakeDeads.push_back({34, 2, 0x0, 0x0, 0x0, 0x0, 0x20}); // 2c; Y4; expected: 0x0; data 10/2023
199+
fakeDeads.push_back({42, 5, 0x0, 0x2d00, 0x0, 0x0, 0x0}); // ec; X2; expected: 0x0; data 12/2023: 0x2f00
200+
fakeDeads.push_back({43, 4, 0x0, 0x0, 0x0, 0x0, 0x20}); // dd; Y1; expected: 0x0
201+
fakeDeads.push_back({43, 5, 0x0, 0xff, 0x0, 0x0, 0x0}); // ee; X1; expected: 0x0; data 10/2023: 0xf3
202+
fakeDeads.push_back({44, 3, 0x0, 0x0, 0x0, 0x0, 0x2}); // cf; Y1; expected: 0x0
203+
fakeDeads.push_back({44, 5, 0x2000, 0x0, 0x0, 0x0, 0x0}); // ef; X1; expected: 0x0
204+
fakeDeads.push_back({44, 6, 0x0, 0x0, 0x0, 0x0, 0xf}); // f8; Y1; expected: 0x0; data 10/2023: 0x7
205+
fakeDeads.push_back({46, 1, 0x0, 0x0, 0x0, 0x0, 0xc0}); // 91; Y2; expected: 0xc0; data 12/2023: 0x40
206+
fakeDeads.push_back({46, 2, 0x0, 0x0, 0x0, 0x0, 0xc0}); // b1; Y2; expected: 0xe0; data 10/2023: 0xe0
207+
fakeDeads.push_back({46, 3, 0x0, 0x0, 0x0, 0x0, 0xc0}); // c1; Y2;
208+
fakeDeads.push_back({46, 4, 0x0, 0x0, 0x0, 0x0, 0x58}); // d1; Y2; expected: 0xe8; data 10/2023: 0x60
209+
fakeDeads.push_back({46, 5, 0x0, 0x0, 0x0, 0x0, 0x60}); // e1; Y2;
210+
fakeDeads.push_back({47, 3, 0x1, 0x0, 0x0, 0x0, 0x0}); // c3; X2; expected: 0x9d; data 10/2023: 0x15
211+
// fakeDeads.push_back({47, 5, 0x1, 0x0, 0x0, 0x0, 0x0}); // e3; X2; 0 (expected only)
212+
fakeDeads.push_back({52, 2, 0x0, 0x0, 0x0, 0x0, 0xf8}); // ac; Y2; expected: 0xb0; data 10/2023: 0xf0
213+
fakeDeads.push_back({52, 3, 0x0, 0x0, 0x0, 0x0, 0x80}); // cd; Y2; expected: 0x0
214+
// fakeDeads.push_back({64, 4, 0x0, 0x0, 0x0, 0x0, 0x40}); // d1; Y4; expected: 0x0; data 12/2023
215+
fakeDeads.push_back({68, 5, 0x0, 0x0, 0x0, 0x0, 0xe2}); // e9; Y4; expected: 0x0; data 10/2023: 0xe0
216+
217+
return fakeDeads;
175218
}
176219

177220
/// @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
185228
timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
186229
}
187230

188-
std::vector<std::string> whats = {"querybad", "uploadbad", "querymasks", "writemasks", "uploadbadfrommasks"};
231+
std::vector<std::string> whats = {"querybad", "uploadbad", "queryfake", "uploadfake", "querymasks", "writemasks", "uploadbadfrommasks"};
232+
233+
const std::string fakeDeadChannelCCDBPath = "MID/Calib/FakeDeadChannels";
189234

190235
if (what == whats[0]) {
191-
queryBadChannels(ccdbUrl, timestamp, verbose);
236+
queryBadChannels(ccdbUrl, timestamp, verbose, BadChannelCCDBPath);
192237
} else if (what == whats[1]) {
193-
uploadBadChannels(ccdbUrl, timestamp);
238+
uploadBadChannels(ccdbUrl, timestamp, BadChannelCCDBPath);
194239
} else if (what == whats[2]) {
195-
queryDCSMasks(ccdbUrl, timestamp, verbose);
240+
queryBadChannels(ccdbUrl, timestamp, verbose, fakeDeadChannelCCDBPath);
196241
} else if (what == whats[3]) {
197-
writeDCSMasks(ccdbUrl, timestamp);
242+
uploadBadChannels(ccdbUrl, timestamp, fakeDeadChannelCCDBPath);
198243
} else if (what == whats[4]) {
244+
queryDCSMasks(ccdbUrl, timestamp, verbose);
245+
} else if (what == whats[5]) {
246+
writeDCSMasks(ccdbUrl, timestamp);
247+
} else if (what == whats[6]) {
199248
uploadBadChannelsFromDCSMask(inFilename, timestamp, ccdbUrl, verbose);
200249
} else {
201250
std::cout << "Unimplemented option chosen " << what << std::endl;

0 commit comments

Comments
 (0)