#include <cstdlib>
#include "eformat/eformat.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
Definition in file source_id.cxx.
int main | ( | int | argc, | |
char ** | argv | |||
) |
The main application
Definition at line 21 of file source_id.cxx.
References HEX.
00022 { 00023 using namespace eformat; 00024 00025 if ( argc != 2 && argc != 3 ) { 00026 std::cerr << "usage: " << argv[0] << " <source-id>" << std::endl; 00027 std::cerr << "usage: " << argv[0] << " <subdetector> " 00028 << "<module-id>" << std::endl; 00029 std::cerr << " 1. The first format transforms from source identifier" 00030 << " into components." << std::endl; 00031 std::cerr << " 2. The second format transforms from the components into" 00032 << " source identifiers." << std::endl; 00033 std::exit(1); 00034 } 00035 00036 if ( argc == 2 ) { //from source id into components 00037 uint32_t source_id = static_cast<uint32_t>(std::strtoul(argv[1], 0, 0)); 00038 helper::SourceIdentifier my(source_id); 00039 std::cout << "Components for event format v3.0 are:" << std::endl; 00040 std::cout << " - SubDetector ID => " 00041 << my.subdetector_id() << ", " 00042 << HEX(my.subdetector_id()) 00043 << std::endl; 00044 std::cout << " - Module ID => " 00045 << HEX(static_cast<unsigned int>(my.module_id())) 00046 << std::endl; 00047 } 00048 00049 if ( argc == 3 ) { //from source id into components 00050 SubDetector sd = static_cast<SubDetector> (std::strtoul(argv[1], 0, 0)); 00051 uint16_t id = static_cast<uint16_t>(std::strtoul(argv[2], 0, 0)); 00052 helper::SourceIdentifier my(sd, id); 00053 std::cout << "Source identifier for event format v3.0 is: " 00054 << HEX(my.code()) << std::endl; 00055 } 00056 00057 exit(0); 00058 00059 }