ATLAS Offline Software
Loading...
Searching...
No Matches
treeCopyOpts.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "treeCopyOpts.h"
6#include <iostream>
7
8#include <boost/program_options.hpp>
9
10namespace H5Utils {
11
12 AppOpts getTreeCopyOpts(int argc, char* argv[])
13 {
14 namespace po = boost::program_options;
15 AppOpts app;
16 std::string usage = "usage: " + std::string(argv[0]) + " <files>..."
17 + " -o <output> [-h] [opts...]\n";
18 po::options_description opt(usage + "\nConvert a root tree to HDF5");
19 opt.add_options()
20 ("in-file",
21 po::value(&app.file.in)->required()->multitoken(),
22 "input file name")
23 ("out-file,o",
24 po::value(&app.file.out)->required(),
25 "output file name")
26 ("tree-name,t",
27 po::value(&app.file.tree)->default_value("", "found"),
28 "tree to use, use whatever is there by default (or crash if multiple)")
29 ("help,h", "Print help messages")
30 ("branch-regex,r",
31 po::value(&app.tree.branch_regex)->default_value(""),
32 "regex to filter branches")
33 ("vector-lengths,l",
34 po::value(&app.tree.vector_lengths)->multitoken()->value_name("args..."),
35 "max size of vectors to write")
36 ("verbose,v",
37 po::bool_switch(&app.tree.verbose),
38 "print branches copied")
39 ("n-entries,n",
40 po::value(&app.tree.n_entries)->default_value(0, "all")->implicit_value(1),
41 "number of entries to copy")
42 ("chunk-size,c",
43 po::value(&app.tree.chunk_size)->default_value(CHUNK_SIZE),
44 "chunk size in HDF5 file")
45 ("selection,s",
46 po::value(&app.tree.selection)->default_value(""),
47 "selection string applied to ntuples")
48 ("print-interval,p",
49 po::value(&app.tree.print_interval)->default_value(0, "never")->implicit_value(-1, "1%"),
50 "print progress")
51
52 ;
53 po::positional_options_description pos_opts;
54 pos_opts.add("in-file", -1);
55
56 po::variables_map vm;
57 try {
58 po::store(po::command_line_parser(argc, argv).options(opt)
59 .positional(pos_opts).run(), vm);
60 if ( vm.count("help") ) {
61 std::cout << opt << std::endl;
62 app.exit_code = 1;
63 }
64 po::notify(vm);
65 } catch (po::error& err) {
66 std::cerr << usage << "ERROR: " << err.what() << std::endl;
67 app.exit_code = 1;
68 }
69 return app;
70 }
71
72}
int usage(std::ostream &s, int, char **argv, int status=-1)
Definition hcg.cxx:1035
HDF5 Tuple Writer.
Definition common.h:20
AppOpts getTreeCopyOpts(int argc, char *argv[])
const size_t CHUNK_SIZE
Definition run.py:1
TreeCopyOpts tree
std::string tree
std::vector< std::string > in
std::string out
std::string branch_regex
std::vector< size_t > vector_lengths