#include "canvas/Persistency/Provenance/BranchType.h"
#include "canvas/Persistency/Provenance/rootNames.h"
#include "boost/program_options.hpp"
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include "TBranch.h"
#include "TError.h"
#include "TFile.h"
#include "TTree.h"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 93 of file count_events.cc.
References e.
95 using stringvec = std::vector<std::string>;
97 std::ostringstream descstr;
98 descstr << argv[0] <<
"Usage: count_events [<options>] <filename>+\n";
99 bpo::options_description desc(descstr.str());
100 desc.add_options()(
"hr",
"Human-readable output")(
101 "help,h",
"this help message.")(
"source,s",
102 bpo::value<stringvec>()->composing(),
103 "source data file (multiple OK).");
104 bpo::options_description all_opts(
"All Options.");
108 bpo::positional_options_description pd;
109 pd.add(
"source", -1);
111 bpo::variables_map vm;
113 bpo::store(bpo::command_line_parser(argc, argv)
121 std::cerr <<
"Exception from command line processing in " << argv[0] <<
": " 125 if (vm.count(
"help")) {
126 std::cerr << desc << std::endl;
128 }
else if (vm.count(
"hr")) {
131 if (vm.count(
"source") == 0) {
132 std::cerr <<
"Require at least one source file.\n";
133 std::cerr << desc <<
"\n";
136 auto const& sources = vm[
"source"].as<
stringvec>();
137 auto const expected = sources.size();
138 auto succeeded = std::count_if(sources.cbegin(),
140 std::bind(&count_events,
141 std::placeholders::_1,
143 std::ref(std::cerr)));
144 if (expected == static_cast<size_t>(succeeded)) {
145 std::cout <<
"Counted events successfully for " << expected
146 <<
" specified files." << std::endl;
150 std::cout <<
"Failed to count events for " << expected - succeeded <<
" of " 151 << expected <<
" specified files." << std::endl;
153 return result & 0xff;
std::vector< std::string > stringvec