Skip to content

Commit 5fa35b2

Browse files
authored
new options to add channels from DE Ids and HV/LV DCS aliases (#13034)
1 parent a7a338d commit 5fa35b2

File tree

2 files changed

+85
-41
lines changed

2 files changed

+85
-41
lines changed

Detectors/MUON/MCH/Conditions/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The BadChannel and RejectList objects can be uploaded, e.g. for debug purposes,
2121

2222
```shell
2323
$ o2-mch-bad-channels-ccdb --help
24-
This program dump MCH bad channels CCDB object
24+
This program get/set MCH bad channels CCDB object
2525
Usage:
2626
-h [ --help ] produce help message
2727
-c [ --ccdb ] arg (=http://localhost:6464)
@@ -37,12 +37,15 @@ Usage:
3737
-q [ --query ] dump bad channel object from CCDB
3838
-v [ --verbose ] verbose output
3939
-s [ --solar ] arg solar ids to reject
40+
-d [ --ds ] arg dual sampas indices to reject
41+
-e [ --de ] arg DE ids to reject
42+
-a [ --alias ] arg DCS alias (HV or LV) to reject
4043

4144
```
4245

4346
For instance, to create a debug RejectList object which declares solar number 32 as bad within a local CCDB, from Tuesday 1 November 2022 00:00:01 UTC to Saturday 31 December 2022 23:59:59, use :
4447

4548
```shell
4649
$ o2-mch-bad-channels-ccdb -p -s 32 -t RejectList --starttimestamp 1667260801000 --endtimestamp 1672531199000
47-
storing default MCH bad channels (valid from 1667260801000to 1672531199000) to MCH/Calib/RejectList
50+
storing default MCH bad channels (valid from 1667260801000 to 1672531199000) to MCH/Calib/RejectList
4851
```

Detectors/MUON/MCH/Conditions/src/bad-channels-ccdb.cxx

Lines changed: 80 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
#include <string>
1818
#include <vector>
1919
#include "DataFormatsMCH/DsChannelId.h"
20-
#include "MCHRawElecMap/Mapper.h"
21-
#include "MCHMappingInterface/Segmentation.h"
20+
#include "MCHConditions/DCSAliases.h"
21+
#include "MCHConstants/DetectionElements.h"
2222
#include "MCHGlobalMapping/DsIndex.h"
23+
#include "MCHGlobalMapping/Mapper.h"
24+
#include "MCHMappingInterface/Segmentation.h"
25+
#include "MCHRawElecMap/Mapper.h"
2326

2427
namespace po = boost::program_options;
2528

@@ -46,50 +49,81 @@ void queryBadChannels(const std::string ccdbUrl,
4649
}
4750
}
4851

49-
void uploadBadChannels(const std::string ccdbUrl,
50-
const std::string badChannelType,
51-
uint64_t startTimestamp,
52-
uint64_t endTimestamp,
53-
std::vector<uint16_t> solarsToReject,
54-
std::vector<uint16_t> dsToReject,
55-
bool makeDefault)
52+
void rejectDS(const o2::mch::raw::DsDetId& dsDetId, BadChannelsVector& bv)
5653
{
57-
BadChannelsVector bv;
58-
59-
auto det2elec = o2::mch::raw::createDet2ElecMapper<o2::mch::raw::ElectronicMapperGenerated>();
54+
static auto det2elec = o2::mch::raw::createDet2ElecMapper<o2::mch::raw::ElectronicMapperGenerated>();
55+
const auto& seg = o2::mch::mapping::segmentation(dsDetId.deId());
56+
auto dsElecId = det2elec(dsDetId);
57+
seg.forEachPadInDualSampa(dsDetId.dsId(), [&](int pad) {
58+
uint8_t channel = seg.padDualSampaChannel(pad);
59+
const auto c = o2::mch::DsChannelId(dsElecId->solarId(), dsElecId->elinkId(), channel);
60+
bv.emplace_back(c);
61+
});
62+
}
6063

61-
for (auto solar : solarsToReject) {
64+
void rejectSolars(const std::vector<uint16_t> solarIds, BadChannelsVector& bv)
65+
{
66+
for (auto solar : solarIds) {
6267
auto ds = o2::mch::raw::getDualSampas<o2::mch::raw::ElectronicMapperGenerated>(solar);
6368
for (const auto& dsDetId : ds) {
64-
o2::mch::mapping::Segmentation seg(dsDetId.deId());
65-
for (uint8_t channel = 0; channel < 64; channel++) {
66-
auto dsElecId = det2elec(dsDetId);
67-
auto padId = seg.findPadByFEE(dsDetId.dsId(), channel);
68-
if (seg.isValid(padId)) {
69-
const auto c = o2::mch::DsChannelId(solar, dsElecId->elinkId(), channel);
70-
bv.emplace_back(c);
71-
}
72-
}
69+
rejectDS(dsDetId, bv);
7370
}
7471
}
72+
}
7573

76-
for (auto ds : dsToReject) {
74+
void rejectDSs(const std::vector<uint16_t> dsIdxs, BadChannelsVector& bv)
75+
{
76+
for (auto ds : dsIdxs) {
7777
if (ds >= o2::mch::NumberOfDualSampas) {
78-
std::cout << "Error: invalid DS index" << std::endl;
78+
std::cout << "Error: invalid DS index " << ds << std::endl;
7979
continue;
8080
}
8181
o2::mch::raw::DsDetId dsDetId = o2::mch::getDsDetId(ds);
82-
o2::mch::mapping::Segmentation seg(dsDetId.deId());
83-
for (uint8_t channel = 0; channel < 64; channel++) {
84-
auto dsElecId = det2elec(dsDetId);
85-
auto padId = seg.findPadByFEE(dsDetId.dsId(), channel);
86-
if (seg.isValid(padId)) {
87-
const auto c = o2::mch::DsChannelId(dsElecId->solarId(), dsElecId->elinkId(), channel);
88-
bv.emplace_back(c);
89-
}
82+
rejectDS(dsDetId, bv);
83+
}
84+
}
85+
86+
void rejectHVLVs(const std::vector<std::string> dcsAliases, BadChannelsVector& bv)
87+
{
88+
for (auto alias : dcsAliases) {
89+
if (!o2::mch::dcs::isValid(alias)) {
90+
std::cout << "Error: invalid alias " << alias << std::endl;
91+
continue;
92+
}
93+
for (auto ds : o2::mch::dcs::aliasToDsIndices(alias)) {
94+
o2::mch::raw::DsDetId dsDetId = o2::mch::getDsDetId(ds);
95+
rejectDS(dsDetId, bv);
9096
}
9197
}
98+
}
99+
100+
void rejectDEs(const std::vector<uint16_t> deIds, BadChannelsVector& bv)
101+
{
102+
static auto det2elec = o2::mch::raw::createDet2ElecMapper<o2::mch::raw::ElectronicMapperGenerated>();
103+
for (auto de : deIds) {
104+
if (!o2::mch::constants::isValidDetElemId(de)) {
105+
std::cout << "Error: invalid DE ID " << de << std::endl;
106+
continue;
107+
}
108+
const auto& seg = o2::mch::mapping::segmentation(de);
109+
seg.forEachPad([&](int pad) {
110+
auto ds = seg.padDualSampaId(pad);
111+
o2::mch::raw::DsDetId dsDetId(de, ds);
112+
auto dsElecId = det2elec(dsDetId);
113+
uint8_t channel = seg.padDualSampaChannel(pad);
114+
const auto c = o2::mch::DsChannelId(dsElecId->solarId(), dsElecId->elinkId(), channel);
115+
bv.emplace_back(c);
116+
});
117+
}
118+
}
92119

120+
void uploadBadChannels(const std::string ccdbUrl,
121+
const std::string badChannelType,
122+
uint64_t startTimestamp,
123+
uint64_t endTimestamp,
124+
const BadChannelsVector& bv,
125+
bool makeDefault)
126+
{
93127
o2::ccdb::CcdbApi api;
94128
api.init(ccdbUrl);
95129
std::map<std::string, std::string> md;
@@ -139,7 +173,9 @@ int main(int argc, char** argv)
139173
("query,q",po::bool_switch(&query),"dump bad channel object from CCDB")
140174
("verbose,v",po::bool_switch(&verbose),"verbose output")
141175
("solar,s",po::value<std::vector<uint16_t>>()->multitoken(),"solar ids to reject")
142-
("dsToReject,d", po::value<std::vector<uint16_t>>()->multitoken(), "dual sampas indices to reject")
176+
("ds,d", po::value<std::vector<uint16_t>>()->multitoken(), "dual sampas indices to reject")
177+
("de,e", po::value<std::vector<uint16_t>>()->multitoken(), "DE ids to reject")
178+
("alias,a", po::value<std::vector<std::string>>()->multitoken(), "DCS alias (HV or LV) to reject")
143179
;
144180
// clang-format on
145181

@@ -171,16 +207,21 @@ int main(int argc, char** argv)
171207
}
172208

173209
if (put) {
174-
std::vector<uint16_t> solarsToReject;
175-
std::vector<uint16_t> dsToReject;
210+
BadChannelsVector bv;
176211
if (vm.count("solar")) {
177-
solarsToReject = vm["solar"].as<std::vector<uint16_t>>();
212+
rejectSolars(vm["solar"].as<std::vector<uint16_t>>(), bv);
213+
}
214+
if (vm.count("ds")) {
215+
rejectDSs(vm["ds"].as<std::vector<uint16_t>>(), bv);
216+
}
217+
if (vm.count("de")) {
218+
rejectDEs(vm["de"].as<std::vector<uint16_t>>(), bv);
178219
}
179-
if (vm.count("dsToReject")) {
180-
dsToReject = vm["dsToReject"].as<std::vector<uint16_t>>();
220+
if (vm.count("alias")) {
221+
rejectHVLVs(vm["alias"].as<std::vector<std::string>>(), bv);
181222
}
182223

183-
uploadBadChannels(ccdbUrl, badChannelType, startTimestamp, endTimestamp, solarsToReject, dsToReject, uploadDefault);
224+
uploadBadChannels(ccdbUrl, badChannelType, startTimestamp, endTimestamp, bv, uploadDefault);
184225
}
185226
return 0;
186227
}

0 commit comments

Comments
 (0)