9#include <framework/logging/Logger.h>
10#include <framework/core/FileCatalog.h>
11#include <framework/dataobjects/FileMetaData.h>
17#include <boost/program_options.hpp>
23namespace prog = boost::program_options;
25int main(
int argc,
char* argv[])
28 prog::options_description options(
"Options");
30 (
"help,h",
"print all available options")
31 (
"file,f", prog::value<string>(),
"local file name")
34 prog::positional_options_description posOptDesc;
35 posOptDesc.add(
"file", -1);
37 prog::variables_map varMap;
38 prog::store(prog::command_line_parser(argc, argv).
39 options(options).positional(posOptDesc).run(), varMap);
43 if (varMap.count(
"help")) {
44 cout <<
"Usage: " << argv[0] <<
" [OPTIONS] [FILE]\n";
45 cout <<
"Add the given file to the file catalog (e.g. so it can be found as a parent file).\n\n";
46 cout << options << endl;
51 if (!varMap.count(
"file")) {
52 B2ERROR(
"No file name given");
55 string fileName = varMap[
"file"].as<
string>();
58 gErrorIgnoreLevel = kError;
59 TFile* file = TFile::Open(fileName.c_str(),
"READ");
60 if (!file || !file->IsOpen()) {
61 B2ERROR(
"Couldn't open file " << fileName);
64 auto* tree = (TTree*) file->Get(
"persistent");
66 B2ERROR(
"No tree persistent found in " << fileName);
69 TBranch* branch = tree->GetBranch(
"FileMetaData");
71 B2ERROR(
"No meta data found in " << fileName);
75 branch->SetAddress(&metaData);
80 B2ERROR(
"Registration of file " << fileName <<
" failed");
static FileCatalog & Instance()
Static method to get a reference to the FileCatalog instance.
Abstract base class for different kinds of events.