Belle II Software
release-08-01-10
b2klm-numberToIndex.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
19
using namespace
Belle2
;
20
21
int
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 numbers into the corresponding channel indexes.\n"
27
" A basf2 FATAL message is printed if a channel number 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 number into the channel index. */
38
const
KLMChannelArrayIndex
* channelArrayIndex = &(
KLMChannelArrayIndex::Instance
());
39
for
(
int
i = 1; i <= nChannels; ++i) {
40
KLMChannelNumber
number = std::atoi(argv[i]);
41
uint16_t index = channelArrayIndex->
getIndex
(number);
42
B2INFO(
"Channel number: "
<< number <<
" ==> Channel index: "
<< index);
43
}
44
return
0;
45
}
Belle2::KLMChannelArrayIndex
KLM channel array index.
Definition:
KLMChannelArrayIndex.h:23
Belle2::KLMChannelArrayIndex::Instance
static const KLMChannelArrayIndex & Instance()
Instantiation.
Definition:
KLMChannelArrayIndex.cc:26
Belle2::KLMElementArrayIndex::getIndex
uint16_t getIndex(uint16_t number) const
Get element index.
Definition:
KLMElementArrayIndex.cc:52
Belle2::KLMChannelNumber
uint16_t KLMChannelNumber
Channel number.
Definition:
KLMElementNumberDefinitions.h:36
Belle2
Abstract base class for different kinds of events.
Definition:
MillepedeAlgorithm.h:17
main
int main(int argc, char **argv)
Run all tests.
Definition:
test_main.cc:91
klm
tools
b2klm-numberToIndex.cc
Generated on Mon Sep 23 2024 14:03:17 for Belle II Software by
1.9.1