Project
Loading...
Searching...
No Matches
CathodeSegmentationSVGWriter.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
19#include <ostream>
20
21using namespace o2::mch::contour;
22
23namespace o2
24{
25namespace mch
26{
27namespace mapping
28{
29
31{
32 return R"(
33.pads {
34 fill: #EEEEEE;
35 stroke-width: 0.025px;
36 stroke: #AAAAAA;
37}
38.padchannels {
39 font-size: 0.4px;
40 font-family: arial;
41 fill: blue;
42 text-anchor: middle;
43}
44.dualsampas {
45 fill:none;
46 stroke-width: 0.025px;
47 stroke: #333333;
48}
49.detectionelements {
50 fill:none;
51 stroke-width:0.025px;
52 stroke: #000000;
53}
54.testpoints {
55 fill:red;
56 stroke-width:0.025px;
57 stroke: black;
58 opacity: 0.5;
59}
60)";
61}
62
63void svgCathodeSegmentation(const CathodeSegmentation& seg, SVGWriter& w, bool showdes, bool showdualsampas, bool showpads,
64 bool showpadchannels)
65{
66 std::vector<Contour<double>> dualSampaContours = getDualSampaContours(seg);
67 std::vector<std::vector<Polygon<double>>> dualSampaPads = getPadPolygons(seg);
68 std::vector<std::vector<int>> dualSampaPadChannels = getPadChannels(seg);
69
70 if (dualSampaPadChannels.size() != dualSampaPads.size()) {
71 throw std::runtime_error("gouze");
72 }
73
74 auto deContour = getEnvelop(seg);
75 auto box = getBBox(seg);
76
77 if (showpads) {
78 w.svgGroupStart("pads");
79 for (auto& dsp : dualSampaPads) {
80 for (auto& p : dsp) {
81 w.polygon(p);
82 }
83 }
84 w.svgGroupEnd();
85 }
86
87 if (showpadchannels) {
88 w.svgGroupStart("padchannels");
89 for (auto i = 0; i < dualSampaPads.size(); ++i) {
90 auto& dsp = dualSampaPads[i];
91 auto& dspch = dualSampaPadChannels[i];
92 for (auto j = 0; j < dsp.size(); j++) {
93 auto bbox = getBBox(dsp[j]);
94 w.text(std::to_string(dspch[j]), bbox.xcenter(),
95 bbox.ymax() - 0.05 * bbox.height()); // SVG text y position is the bottom of the text
96 }
97 }
98 w.svgGroupEnd();
99 }
100
101 if (showdualsampas) {
102 w.svgGroupStart("dualsampas");
103 for (auto& dsp : dualSampaContours) {
104 w.contour(dsp);
105 }
106 w.svgGroupEnd();
107 }
108
109 if (showdes) {
110 w.svgGroupStart("detectionelements");
111 w.contour(deContour);
112 }
113}
114
115} // namespace mapping
116} // namespace mch
117} // namespace o2
o2::mch::mapping::CathodeSegmentation seg
int32_t i
uint32_t j
Definition RawData.h:0
A CathodeSegmentation lets you find pads on a given plane (cathode) of a detection element and then i...
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
GLsizei const GLint * box
Definition glcorearb.h:4697
std::string svgCathodeSegmentationDefaultStyle()
std::vector< o2::mch::contour::Contour< double > > getDualSampaContours(const CathodeSegmentation &seg)
void svgCathodeSegmentation(const CathodeSegmentation &seg, o2::mch::contour::SVGWriter &writer, bool showdes, bool showdualsampas, bool showpads, bool showpadchannels)
o2::mch::contour::BBox< double > getBBox(const CathodeSegmentation &seg)
std::vector< std::vector< o2::mch::contour::Polygon< double > > > getPadPolygons(const CathodeSegmentation &seg)
std::vector< std::vector< int > > getPadChannels(const CathodeSegmentation &seg)
o2::mch::contour::Contour< double > getEnvelop(const CathodeSegmentation &seg)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52