1 #include <framework/io/RootIOUtilities.h>
3 #include <framework/datastore/DataStore.h>
4 #include <framework/dataobjects/FileMetaData.h>
5 #include <framework/logging/Logger.h>
11 #include <TBaseClass.h>
26 const std::vector<std::string>& branches,
27 const std::vector<std::string>& excludeBranches,
int durability,
bool quiet)
29 std::set<std::string> branchSet, excludeBranchSet;
30 for (
const std::string& b : branches) {
31 if (branchesToFilter.count(b) == 0 and not quiet)
32 B2WARNING(
"The branch " << b <<
" given in " <<
c_SteerBranchNames[durability] <<
" does not exist.");
33 if (!branchSet.insert(b).second and not quiet)
36 for (
const std::string& b : excludeBranches) {
39 if (branchesToFilter.count(b) == 0 and not quiet and b !=
"ProcessStatistics")
41 if (!excludeBranchSet.insert(b).second and not quiet)
45 std::set<std::string> out, relations, excluderelations;
46 for (
const std::string& branch : branchesToFilter) {
47 if (excludeBranchSet.count(branch))
49 if (branchSet.empty() or branchSet.count(branch))
52 if (!excludeBranchSet.empty()) {
54 for (
const std::string& from : branchesToFilter) {
55 for (
const std::string& to : branchesToFilter) {
57 if (out.count(branch) == 0)
59 if (excludeBranchSet.count(from) == 0 and excludeBranchSet.count(to) == 0)
61 if (branchSet.count(branch) != 0)
63 excluderelations.insert(branch);
66 for (
const std::string& rel : excluderelations) {
71 for (
const std::string& from : out) {
72 for (
const std::string& to : out) {
74 if (branchesToFilter.count(branch) == 0)
76 if (excludeBranchSet.count(branch))
78 relations.insert(branch);
81 out.insert(relations.begin(), relations.end());
88 std::queue<TBranch*> branches;
89 branches.emplace(branch);
90 while (!branches.empty()) {
92 auto* current = branches.front();
95 if (process) current->ResetBit(kDoNotProcess);
96 else current->SetBit(kDoNotProcess);
98 auto* children = current->GetListOfBranches();
99 const auto nchildren = children->GetEntriesFast();
100 for (
int i = 0; i < nchildren; ++i) {
101 branches.emplace(
dynamic_cast<TBranch*
>(children->UncheckedAt(i)));
109 std::vector<std::string> out;
110 wordexp_t expansions;
111 wordexp(
"", &expansions, 0);
112 for (
const std::string& pattern : filenames) {
113 if (wordexp(pattern.c_str(), &expansions, WRDE_APPEND | WRDE_NOCMD | WRDE_UNDEF) != 0) {
114 B2ERROR(
"Failed to expand pattern '" << pattern <<
"'!");
117 out.resize(expansions.we_wordc);
118 for (
unsigned int i = 0; i < expansions.we_wordc; i++) {
119 out[i] = expansions.we_wordv[i];
121 wordfree(&expansions);
128 const long major = 1000000 * experiment + run;
129 const long minor = event;
131 if (!tree->GetTreeIndex()) {
132 B2DEBUG(100,
"No TTreeIndex found, rebuild it...");
135 long entry = tree->GetEntryNumberWithIndex(major, minor);
139 B2DEBUG(100,
"Couldn't find entry (" << event <<
", " << run <<
", " << experiment <<
") in file! (major index: " << major <<
140 ", minor index: " << minor <<
")");
147 tree->BuildIndex(
"1000000*EventMetaData.m_experiment+EventMetaData.m_run",
"EventMetaData.m_event");
152 if (cl == TObject::Class())
155 if (cl->GetClassVersion() <= 0) {
157 TList* baseClasses =
const_cast<TClass*
>(cl)->GetListOfBases();
158 TIter it(baseClasses);
159 while (
auto* base =
static_cast<TBaseClass*
>(it())) {
174 return cl->TestBit(TClass::kHasCustomStreamerMember);
181 auto now = time(
nullptr);
182 strftime(date, 100,
"%Y-%m-%d %H:%M:%S", gmtime(&now));
183 const char* belle2_site = getenv(
"BELLE2_SITE");
188 gethostname(hostname, 1023);
189 hostname[1023] =
'\0';
192 const char* user = getenv(
"BELLE2_USER");
193 if (!user) user = getenv(
"USER");
194 if (!user) user = getlogin();
195 if (!user) user =
"unknown";
197 metadata.setCreationData(date, site, user, commitid);