36 std::string
getTree(
const std::string& file_name) {
37 if (!
exists(file_name) && !is_remote(file_name)) {
38 throw std::logic_error(file_name +
" doesn't exist");
40 std::unique_ptr<TFile>
file(TFile::Open(file_name.c_str()));
42 throw std::logic_error(
"can't open " + file_name);
44 std::set<std::string> keys;
45 int n_keys =
file->GetListOfKeys()->GetSize();
47 throw std::logic_error(
"no keys found in file");
49 for (
int keyn = 0; keyn < n_keys; keyn++) {
50 keys.insert(
file->GetListOfKeys()->At(keyn)->GetName());
52 size_t n_unique = keys.size();
54 std::string prob =
"Can't decide which tree to use, choose one of {";
56 for (
const auto& key: keys) {
59 if (uniq_n < n_unique) prob.append(
", ");
61 prob.append(
"} with the --tree-name option");
62 throw std::logic_error(prob);
64 auto* key =
dynamic_cast<TKey*
>(
file->GetListOfKeys()->At(0));
65 std::string name = key->GetName();