Project
Loading...
Searching...
No Matches
SVGSegmentation.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
15#include "boost/program_options.hpp"
20#include <fstream>
21#include <iostream>
22
23using namespace o2::mch::mapping;
24
25namespace po = boost::program_options;
26
27std::pair<double, double> parsePoint(std::string ps)
28{
29 int ix = ps.find_first_of(' ');
30
31 auto first = ps.substr(0, ix);
32 auto second = ps.substr(ix + 1, ps.size() - ix - 1);
33 return std::make_pair(std::stod(first), std::stod(second));
34}
35
36int main(int argc, char* argv[])
37{
38
39 std::string prefix;
40 std::vector<int> detElemIds;
41 using Point = std::pair<double, double>;
42 std::vector<std::string> pointStrings;
43 std::vector<Point> points;
44 po::variables_map vm;
45 po::options_description generic("Generic options");
46
47 generic.add_options()("help", "produce help message")("hidepads", "hide pad outlines")(
48 "hidedualsampas", "hide dualsampa outlines")("hidedes", "hide detection element outline")(
49 "hidepadchannels", "hide pad channel numbering")("de", po::value<std::vector<int>>(&detElemIds),
50 "which detection element to consider")(
51 "prefix", po::value<std::string>(&prefix)->default_value("seg"), "prefix used for outfile filename(s)")(
52 "point", po::value<std::vector<std::string>>(&pointStrings), "points to show")("all", "use all detection elements");
53
54 po::options_description cmdline;
55 cmdline.add(generic);
56
57 po::store(po::command_line_parser(argc, argv).options(cmdline).run(), vm);
58 po::notify(vm);
59
60 if (vm.count("help")) {
61 std::cout << generic << "\n";
62 return 2;
63 }
64
65 if (vm.count("de") && vm.count("all")) {
66 std::cout << "--all and --de options are mutually exclusive. --all will be used\n";
67 detElemIds.clear();
68 }
69
70 if (vm.count("all")) {
72 [&detElemIds](int detElemId) { detElemIds.push_back(detElemId); });
73 }
74
75 if (detElemIds.empty()) {
76 std::cout << "Must give at least one detection element id to work with\n";
77 std::cout << generic << "\n";
78 return 3;
79 }
80
81 for (auto ps : pointStrings) {
82 points.push_back(parsePoint(ps));
83 }
84
85 for (auto& detElemId : detElemIds) {
86 for (auto isBendingPlane : {true, false}) {
87 std::ofstream out(vm["prefix"].as<std::string>() + "-" + std::to_string(detElemId) + "-" +
88 (isBendingPlane ? "B" : "NB") + ".html");
92 svgCathodeSegmentation(seg, w, vm.count("hidedes") == 0, vm.count("hidedualsampas") == 0, vm.count("hidepads") == 0,
93 vm.count("hidepadchannels") == 0);
94 if (!points.empty()) {
95 w.svgGroupStart("testPoints");
96 w.points(points, 0.2);
97 w.svgGroupEnd();
98 }
99 w.writeHTML(out);
100 }
101 }
102
103 return 0;
104}
bool isBendingPlane
o2::mch::mapping::CathodeSegmentation seg
std::pair< double, double > Point
std::pair< double, double > parsePoint(std::string ps)
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
std::string svgCathodeSegmentationDefaultStyle()
void svgCathodeSegmentation(const CathodeSegmentation &seg, o2::mch::contour::SVGWriter &writer, bool showdes, bool showdualsampas, bool showpads, bool showpadchannels)
void forOneDetectionElementOfEachSegmentationType(CALLABLE &&func)
o2::mch::contour::BBox< double > getBBox(const CathodeSegmentation &seg)
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
#define main