Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Framework/AODMerger/src/aodMerger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int main(int argc, char* argv[])
long maxDirSize = 100000000;
bool skipNonExistingFiles = false;
bool skipParentFilesList = false;
bool mergeByName = false;
int verbosity = 2;
int exitCode = 0; // 0: success, >0: failure
int compression = 505;
Expand All @@ -50,6 +51,7 @@ int main(int argc, char* argv[])
{"skip-non-existing-files", no_argument, nullptr, 3},
{"skip-parent-files-list", no_argument, nullptr, 4},
{"compression", required_argument, nullptr, 5},
{"merge-by-name", no_argument, nullptr, 6},
{"verbosity", required_argument, nullptr, 'v'},
{"help", no_argument, nullptr, 'h'},
{nullptr, 0, nullptr, 0}};
Expand All @@ -70,6 +72,8 @@ int main(int argc, char* argv[])
skipParentFilesList = true;
} else if (c == 5) {
compression = atoi(optarg);
} else if (c == 6) {
mergeByName = true;
} else if (c == 'v') {
verbosity = atoi(optarg);
} else if (c == 'h') {
Expand All @@ -80,6 +84,7 @@ int main(int argc, char* argv[])
printf(" --skip-non-existing-files Flag to allow skipping of non-existing files in the input list.\n");
printf(" --skip-parent-files-list Flag to allow skipping the merging of the parent files list.\n");
printf(" --compression <root compression id> Compression algorithm / level to use (default: %d)\n", compression);
printf(" --merge-by-name Only merge TTrees from folders with the same name.\n");
printf(" --verbosity <flag> Verbosity of output (default: %d).\n", verbosity);
return -1;
} else {
Expand All @@ -94,6 +99,9 @@ int main(int argc, char* argv[])
if (skipNonExistingFiles) {
printf(" WARNING: Skipping non-existing files.\n");
}
if (mergeByName) {
printf(" Merging only folders with the same name.\n");
}

std::map<std::string, TTree*> trees;
std::map<std::string, uint64_t> sizeCompressed;
Expand Down Expand Up @@ -182,6 +190,24 @@ int main(int argc, char* argv[])

auto dfName = ((TObjString*)key1)->GetString().Data();

// If merge-by-name is active, flush accumulated trees when the folder name changes
if (mergeByName && outputDir && std::string(outputDir->GetName()) != std::string(dfName)) {
if (verbosity > 0) {
printf("Folder name changed: closing folder %s.\n", outputDir->GetName());
}
for (auto const& tree : trees) {
outputDir->cd();
tree.second->Write();
sizeCompressed[tree.first] += tree.second->GetZipBytes();
sizeUncompressed[tree.first] += tree.second->GetTotBytes();
delete tree.second;
}
outputDir = nullptr;
trees.clear();
offsets.clear();
mergedDFs = 0;
}

if (verbosity > 0) {
printf(" Processing folder %s\n", dfName);
}
Expand Down Expand Up @@ -462,4 +488,4 @@ int main(int argc, char* argv[])
printf("\n");

return exitCode;
}
}
Loading