10#include <framework/core/FileCatalog.h>
11#include <framework/dataobjects/FileMetaData.h>
12#include <framework/io/RootFileInfo.h>
13#include <framework/logging/Logger.h>
23#include <boost/program_options.hpp>
26namespace prog = boost::program_options;
28int main(
int argc,
char* argv[])
31 prog::options_description options(
"Options");
33 (
"help,h",
"print all available options")
34 (
"file,f", prog::value<std::string>(),
"local file name")
35 (
"lfn,l", prog::value<std::string>(),
"logical file name")
36 (
"all,a",
"print all information")
37 (
"json",
"print machine-readable information in JSON format. Implies --all and --steering.")
38 (
"steering,s",
"print steering file contents")
41 prog::positional_options_description posOptDesc;
42 posOptDesc.add(
"file", -1);
44 prog::variables_map varMap;
46 prog::store(prog::command_line_parser(argc, argv).
47 options(options).positional(posOptDesc).run(), varMap);
49 }
catch (std::exception& e) {
50 std::cout <<
"Problem parsing command line: " << e.what() << std::endl;
51 std::cout <<
"Usage: " << argv[0] <<
" [OPTIONS] [FILE]\n";
52 std::cout << options << std::endl;
57 if (varMap.count(
"help") or argc == 1) {
58 std::cout <<
"Usage: " << argv[0] <<
" [OPTIONS] [FILE]\n";
59 std::cout << options << std::endl;
66 if (varMap.count(
"file")) {
67 gErrorIgnoreLevel = kError;
68 std::string fileName = varMap[
"file"].as<std::string>();
72 }
catch (
const std::invalid_argument&) {
73 B2FATAL(
"The input file can not be opened"
74 <<
LogVar(
"File name", fileName));
75 }
catch (
const std::runtime_error& e) {
76 B2FATAL(
"Something went wrong with the input file"
77 <<
LogVar(
"File name", fileName)
78 <<
LogVar(
"Issue", e.what()));
80 }
else if (varMap.count(
"lfn")) {
81 std::string lfn = varMap[
"lfn"].as<std::string>();
83 B2FATAL(
"No FileMetaData found in FileCatalog"
84 <<
LogVar(
"LFN", varMap[
"lfn"].as<int>()));
86 B2FATAL(
"Please specify either a file name or a LFN.");
88 const char* option =
"";
89 if (varMap.count(
"json"))
91 else if (varMap.count(
"all"))
93 metaData.Print(option);
94 if (std::string(option) !=
"json" and varMap.count(
"steering"))
95 metaData.Print(
"steering");
static FileCatalog & Instance()
Static method to get a reference to the FileCatalog instance.
Helper class to factorize some necessary tasks when working with Belle2 output files.
const FileMetaData & getFileMetaData()
Return the event metadata from the file.
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.