Skip to content
Draft
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
18 changes: 17 additions & 1 deletion Framework/AODMerger/src/aodMerger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,21 @@ int main(int argc, char* argv[])
}
outputDir->cd();
auto outputTree = inputTree->CloneTree(-1, (fastCopy) ? "fast" : "");
// Validate that all branches have the same number of entries after CloneTree.
// Fast copy from remote (xrootd) sources can silently produce corrupt trees
// if a read fails mid-transfer.
{
auto expectedEntries = outputTree->GetEntries();
TObjArray* clonedBranches = outputTree->GetListOfBranches();
for (int ib = 0; ib < clonedBranches->GetEntriesFast(); ++ib) {
auto* br = (TBranch*)clonedBranches->UncheckedAt(ib);
if (br->GetEntries() != expectedEntries) {
printf(" *** FATAL ***: After CloneTree, branch %s has %lld entries but tree has %lld\n",
br->GetName(), br->GetEntries(), expectedEntries);
exitCode = 7;
}
}
}
currentDirSize += inputTree->GetTotBytes(); // NOTE outputTree->GetTotBytes() is 0, so we use the inputTree here
alreadyCopied = true;
outputTree->SetAutoFlush(0);
Expand All @@ -308,6 +323,7 @@ int main(int argc, char* argv[])
// detect VLA
if (((TLeaf*)br->GetListOfLeaves()->First())->GetLeafCount() != nullptr) {
int maximum = ((TLeaf*)br->GetListOfLeaves()->First())->GetLeafCount()->GetMaximum();
maximum = std::max(maximum, 1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maximum = std::max(maximum, 1);
maximum = std::max(maximum, 1); // Can be 0 if all VLAs are empty but we need a valid buffer below


// get type
static TClass* cls;
Expand Down Expand Up @@ -477,4 +493,4 @@ int main(int argc, char* argv[])
printf("\n");

return exitCode;
}
}