BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
source_id.cxx File Reference

Implements a program that uses the eformat library to produce updated versions of source identifiers. More...

#include <cstdlib>
#include "eformat/eformat.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Implements a program that uses the eformat library to produce updated versions of source identifiers.

Author
<a href="Andre.nosp@m..dos.nosp@m..Anjo.nosp@m.s@ce.nosp@m.rn.ch>Andr� Rabello dos ANJOS
Author
zhangy
Revision
1.1.1.1
Date
2009/06/19 07:35:41

Definition in file source_id.cxx.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

The main application

Definition at line 21 of file source_id.cxx.

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}
#define HEX(m)
Definition: util.h:107