Project
Loading...
Searching...
No Matches
cli.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
13#include <iostream>
14#include <fmt/format.h>
15#include <boost/program_options.hpp>
16#include <stdexcept>
17
18namespace po = boost::program_options;
19
21{
22 std::cout << fmt::format("DE {:4d} DS {:4d} CH {:2d} PADID {:6d} X {:7.2f} Y {:7.2f} SX{:7.2f} SY {:7.2f}\n",
23 seg.detElemId(),
24 seg.padDualSampaId(padId),
26 padId,
27 seg.padPositionX(padId),
28 seg.padPositionY(padId),
29 seg.padSizeX(padId),
30 seg.padSizeY(padId));
31}
32
33void dumpPad(const o2::mch::mapping::Segmentation& seg, int dsId, int dsCh)
34{
35 auto padId = seg.findPadByFEE(dsId, dsCh);
36 if (seg.isValid(padId)) {
37 dumpPad(seg, padId);
38 } else {
39 std::cout << fmt::format("DE {:4d} DS {:4d} CH {:2d} PADID {:6d} (channel not connected to an actual pad)\n",
40 seg.detElemId(), dsId, dsCh, padId);
41 }
42}
43
45{
46 bool existingDualSampa{false};
47 seg.forEachDualSampa([&existingDualSampa, dualSampaId](int dsId) {
48 if (dsId == dualSampaId) {
49 existingDualSampa = true;
50 }
51 });
52
53 if (!existingDualSampa) {
54 std::cout << fmt::format("DE {:4d} DS {:4d} does not exist\n",
55 seg.detElemId(), dualSampaId);
56 return;
57 }
58
59 for (auto ch = 0; ch < 64; ch++) {
60 dumpPad(seg, dualSampaId, ch);
61 }
62}
63
65{
66 seg.forEachDualSampa([&](int dualSampaId) {
67 dumpDualSampa(seg, dualSampaId);
68 });
69}
70
71int main(int argc, char** argv)
72{
73 int deId;
74 int dsId;
75 int dsCh;
76 int padId;
77 po::variables_map vm;
78 po::options_description generic("Generic options");
79
80 // clang-format off
81 generic.add_options()
82 ("help,h", "produce help message")
83 ("de,d",po::value<int>(&deId)->required(),"detection element id")
84 ("ds,s",po::value<int>(&dsId),"dual sampa id")
85 ("ch,c",po::value<int>(&dsCh),"dual sampa ch")
86 ("padid,p",po::value<int>(&padId),"padid")
87 ;
88 // clang-format on
89
90 po::options_description cmdline;
91 cmdline.add(generic);
92
93 po::store(po::command_line_parser(argc, argv).options(cmdline).run(), vm);
94
95 if (vm.count("help")) {
96 std::cout << "This program printout MCH basic mapping information.\n";
97 std::cout << " --de # : for a full detection element\n";
98 std::cout << " --de # --ds # : for one dual sampa of a detection element\n";
99 std::cout << " --de # --ds # --ch # : for one channel of a one dual sampa of a detection element\n";
100 std::cout << " --de # --padid # : for one pad of a one dual sampa of a detection element\n";
101 std::cout << "Pad sizes and positions are reported in centimeters\n";
102 std::cout << generic << "\n";
103 return 2;
104 }
105
106 try {
107 po::notify(vm);
108 } catch (boost::program_options::error& e) {
109 std::cout << "Error: " << e.what() << "\n";
110 exit(1);
111 }
112
114
115 if (vm.count("padid")) {
116 dumpPad(seg, padId);
117 return 0;
118 }
119
120 if (vm.count("ds") && vm.count("ch")) {
121 dumpPad(seg, dsId, dsCh);
122 return 0;
123 }
124
125 if (vm.count("ds")) {
126 dumpDualSampa(seg, dsId);
127 return 0;
128 }
129
131
132 return 0;
133}
o2::mch::mapping::CathodeSegmentation seg
void dumpDetectionElement(const o2::mch::mapping::Segmentation &seg)
Definition cli.cxx:64
void dumpDualSampa(const o2::mch::mapping::Segmentation &seg, int dualSampaId)
Definition cli.cxx:44
void dumpPad(const o2::mch::mapping::Segmentation &seg, int padId)
Definition cli.cxx:20
double padSizeY(int catPadIndex) const
double padSizeX(int catPadIndex) const
int padDualSampaChannel(int catPadIndex) const
int padDualSampaId(int catPadIndex) const
void forEachDualSampa(std::function< void(int dualSampaId)> func) const
Loop over dual sampas of this detection element.
double padPositionY(int catPadIndex) const
int findPadByFEE(int dualSampaId, int dualSampaChannel) const
double padPositionX(int catPadIndex) const
bool isValid(int catPadIndex) const
Not every integer is a valid catPadIndex. This method will tell if catPadIndex is a valid one.
A Segmentation lets you find pads of a detection element and then inspect those pads.
#define main