Skip to content

Commit 5ecec32

Browse files
victorvalenciatorresalcaliva
authored andcommitted
Update for MCH display and bad channel tagging (#12495)
1 parent a3053ec commit 5ecec32

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

Detectors/MUON/MCH/Conditions/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ o2_add_executable(
3434
O2::Framework
3535
O2::MCHMappingImpl4
3636
O2::MCHRawElecMap
37+
O2::MCHGlobalMapping
3738
)
3839

3940
if(BUILD_TESTING)

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "DataFormatsMCH/DsChannelId.h"
2020
#include "MCHRawElecMap/Mapper.h"
2121
#include "MCHMappingInterface/Segmentation.h"
22+
#include "MCHGlobalMapping/DsIndex.h"
2223

2324
namespace po = boost::program_options;
2425

@@ -50,6 +51,7 @@ void uploadBadChannels(const std::string ccdbUrl,
5051
uint64_t startTimestamp,
5152
uint64_t endTimestamp,
5253
std::vector<uint16_t> solarsToReject,
54+
std::vector<uint16_t> dsToReject,
5355
bool makeDefault)
5456
{
5557
BadChannelsVector bv;
@@ -71,12 +73,29 @@ void uploadBadChannels(const std::string ccdbUrl,
7173
}
7274
}
7375

76+
for (auto ds : dsToReject) {
77+
if (ds >= o2::mch::NumberOfDualSampas) {
78+
std::cout << "Error: invalid DS index" << std::endl;
79+
continue;
80+
}
81+
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+
}
90+
}
91+
}
92+
7493
o2::ccdb::CcdbApi api;
7594
api.init(ccdbUrl);
7695
std::map<std::string, std::string> md;
7796
auto dest = ccdbPath(badChannelType);
7897
std::cout << "storing default MCH bad channels (valid from "
79-
<< startTimestamp << "to " << endTimestamp << ") to "
98+
<< startTimestamp << " to " << endTimestamp << ") to "
8099
<< dest << "\n";
81100

82101
if (makeDefault) {
@@ -120,7 +139,8 @@ int main(int argc, char** argv)
120139
("query,q",po::bool_switch(&query),"dump bad channel object from CCDB")
121140
("verbose,v",po::bool_switch(&verbose),"verbose output")
122141
("solar,s",po::value<std::vector<uint16_t>>()->multitoken(),"solar ids to reject")
123-
;
142+
("dsToReject,d", po::value<std::vector<uint16_t>>()->multitoken(), "dual sampas indices to reject")
143+
;
124144
// clang-format on
125145

126146
po::options_description cmdline;
@@ -152,11 +172,15 @@ int main(int argc, char** argv)
152172

153173
if (put) {
154174
std::vector<uint16_t> solarsToReject;
175+
std::vector<uint16_t> dsToReject;
155176
if (vm.count("solar")) {
156177
solarsToReject = vm["solar"].as<std::vector<uint16_t>>();
157178
}
179+
if (vm.count("dsToReject")) {
180+
dsToReject = vm["dsToReject"].as<std::vector<uint16_t>>();
181+
}
158182

159-
uploadBadChannels(ccdbUrl, badChannelType, startTimestamp, endTimestamp, solarsToReject, uploadDefault);
183+
uploadBadChannels(ccdbUrl, badChannelType, startTimestamp, endTimestamp, solarsToReject, dsToReject, uploadDefault);
160184
}
161185
return 0;
162186
}

Detectors/MUON/MCH/Contour/include/MCHContour/SVGWriter.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,29 @@ class SVGWriter
9090
}
9191
}
9292

93+
template <typename T>
94+
void polygon(const o2::mch::contour::Polygon<T>& p, const std::string& fillColor)
95+
{
96+
// modification
97+
mSVGBuffer << R"(<polygon fill=")" << fillColor << R"(" points=")";
98+
auto vertices = getVertices(p);
99+
for (auto j = 0; j < vertices.size(); ++j) {
100+
auto v = vertices[j];
101+
mSVGBuffer << v.x << "," << v.y << ' ';
102+
}
103+
mSVGBuffer << R"("/>)"
104+
<< "\n";
105+
}
106+
107+
template <typename T>
108+
void contour(const o2::mch::contour::Contour<T>& c, const std::string& color)
109+
{
110+
111+
for (auto& p : c.getPolygons()) {
112+
polygon(p, color);
113+
}
114+
}
115+
93116
void points(const std::vector<std::pair<double, double>>& pts, double radius = 0.05)
94117
{
95118
for (auto& p : pts) {
@@ -104,8 +127,7 @@ class SVGWriter
104127

105128
void writeSVG(std::ostream& os)
106129
{
107-
os << boost::format(R"(<svg width="%d" height="%d" viewBox="%f %f %f %f">
108-
)") % mWidth %
130+
os << boost::format(R"(<svg width="%d" height="%d" viewBox="%f %f %f %f">)") % mWidth %
109131
mHeight % mViewingBox.xmin() % mViewingBox.ymin() % mViewingBox.width() % mViewingBox.height();
110132

111133
os << mSVGBuffer.str();

0 commit comments

Comments
 (0)