Skip to content

Commit 9ba2f91

Browse files
committed
Validate number of entries of tree vs branches
1 parent 47b6c57 commit 9ba2f91

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

DATA/production/common/readAO2Ds.C

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ int readAO2Ds(const char* filename = "AO2D.root")
3535
std::cout << onameKeyInDir.Data() << std::endl;
3636
}
3737
TTree* t = (TTree*)d->Get(onameKeyInDir.Data());
38+
// Check that every branch has the same number of entries as the tree itself.
39+
// A mismatch indicates a corrupted or truncated write.
40+
long long treeEntries = t->GetEntries();
41+
for (auto* b : *t->GetListOfBranches()) {
42+
auto* br = (TBranch*)b;
43+
if (br->GetEntries() != treeEntries) {
44+
printf("MISMATCH %s/%s branch %s: tree=%lld branch=%lld\n",
45+
onameKeyInFile.Data(), onameKeyInDir.Data(), br->GetName(), treeEntries, br->GetEntries());
46+
retCode |= 4;
47+
}
48+
}
3849
if (onameKeyInDir.BeginsWith("O2track") && !onameKeyInDir.Contains("O2tracked") && !onameKeyInDir.Contains("O2trackqa")) {
3950
vectNEntriesPerTree.push_back({onameKeyInDir.Data(), t->GetEntries()});
4051
}

0 commit comments

Comments
 (0)