Belle II Software development
b2klm-indexToNumber.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9/* KLM headers. */
10#include <klm/dataobjects/KLMChannelArrayIndex.h>
11
12/* Basf2 headers. */
13#include <framework/logging/Logger.h>
14
15/* C++ headers. */
16#include <cstdlib>
17#include <iostream>
18
19using namespace Belle2;
20
21int main(int argc, char* argv[])
22{
23 /* Print the usage message if --help or -h are used. */
24 if (argc == 1 or std::string(argv[1]) == "--help" or std::string(argv[1]) == "-h") {
25 std::cout << "Usage: " << argv[0] << " [CHANNEL1] [CHANNEL2] ... [CHANNELN]\n\n"
26 " This tool converts the given channel indexes into the corresponding channel numbers.\n"
27 " A basf2 FATAL message is printed if a channel index does not exist.\n";
28 return 0;
29 }
30 /* Print the error messages when needed. */
31 int nChannels = argc - 1;
32 /* cppcheck-suppress knownConditionTrueFalse */
33 if (nChannels == 0) {
34 B2ERROR("There are no channels to convert.");
35 return 0;
36 }
37 /* Convert the channel index into the channel number. */
38 const KLMChannelArrayIndex* channelArrayIndex = &(KLMChannelArrayIndex::Instance());
39 for (int i = 1; i <= nChannels; ++i) {
40 uint16_t index = std::atoi(argv[i]);
41 KLMChannelNumber number = channelArrayIndex->getNumber(index);
42 B2INFO("Channel index: " << index << " ==> Channel number: " << number);
43 }
44 return 0;
45}
KLM channel array index.
static const KLMChannelArrayIndex & Instance()
Instantiation.
uint16_t getNumber(uint16_t index) const
Get element number.
uint16_t KLMChannelNumber
Channel number.
Abstract base class for different kinds of events.