BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
source_id.cxx
Go to the documentation of this file.
1//Dear emacs, this is -*- c++ -*-
2
3/**
4 * @file source_id.cxx
5 * @author <a href="mailto:[email protected]>Andr� Rabello dos
6 * ANJOS</a>
7 * $Author: zhangy $
8 * $Revision: 1.1.1.1 $
9 * $Date: 2009/06/19 07:35:41 $
10 *
11 * @brief Implements a program that uses the eformat library to produce
12 * updated versions of source identifiers.
13 */
14
15#include <cstdlib>
16#include "eformat/eformat.h"
17
18/**
19 * The main application
20 */
21int main (int argc, char** argv)
22{
23 using namespace eformat;
24
25 if ( argc != 2 && argc != 3 ) {
26 std::cerr << "usage: " << argv[0] << " <source-id>" << std::endl;
27 std::cerr << "usage: " << argv[0] << " <subdetector> "
28 << "<module-id>" << std::endl;
29 std::cerr << " 1. The first format transforms from source identifier"
30 << " into components." << std::endl;
31 std::cerr << " 2. The second format transforms from the components into"
32 << " source identifiers." << std::endl;
33 std::exit(1);
34 }
35
36 if ( argc == 2 ) { //from source id into components
37 uint32_t source_id = static_cast<uint32_t>(std::strtoul(argv[1], 0, 0));
38 helper::SourceIdentifier my(source_id);
39 std::cout << "Components for event format v3.0 are:" << std::endl;
40 std::cout << " - SubDetector ID => "
41 << my.subdetector_id() << ", "
42 << HEX(my.subdetector_id())
43 << std::endl;
44 std::cout << " - Module ID => "
45 << HEX(static_cast<unsigned int>(my.module_id()))
46 << std::endl;
47 }
48
49 if ( argc == 3 ) { //from source id into components
50 SubDetector sd = static_cast<SubDetector> (std::strtoul(argv[1], 0, 0));
51 uint16_t id = static_cast<uint16_t>(std::strtoul(argv[2], 0, 0));
52 helper::SourceIdentifier my(sd, id);
53 std::cout << "Source identifier for event format v3.0 is: "
54 << HEX(my.code()) << std::endl;
55 }
56
57 exit(0);
58
59}
60
eformat::SubDetector subdetector_id(void) const
Includes all entities from the Event Format Library (eformat)
int main()
Definition: test_IFile.cxx:11
#define HEX(m)
Definition: util.h:107