Skip to content

Commit 6d91a54

Browse files
sawenzelclaude
andcommitted
Write one empty TPC digit entry when a timeframe has no collision
This fixes the TPC digit writer producing a file without a tree when a timeframe holds no collision. - The custom close callback only called TFile::Close inside "if (entries > 0)", and never called TFile::Write, so with nothing to write the tree never reached the file. - The result was a 942 byte file with no o2sim tree, and every reader of it failed on a missing branch rather than on an empty tree. - Each branch is now filled once with the empty default object it is bound to, so the file is an ordinary timeframe that happens to contain no digit and the readers downstream stay on their normal path. - The tree is written explicitly, the way RootTreeWriter's own close does. https://its.cern.ch/jira/browse/O2-7132 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 3d40917 commit 6d91a54

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

Detectors/TPC/simworkflow/src/TPCDigitRootWriterSpec.cxx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,24 @@ DataProcessorSpec getTPCDigitRootWriterSpec(std::vector<int> const& laneConfigur
6969
LOG(warning) << "INCONSISTENT NUMBER OF ENTRIES IN BRANCH " << br->GetName() << ": " << entries << " vs " << brentries;
7070
}
7171
}
72-
if (entries > 0) {
73-
LOG(info) << "Setting entries to " << entries;
74-
outputtree->SetEntries(entries);
75-
// outputtree->Write("", TObject::kOverwrite);
76-
outputfile->Close();
72+
if (entries <= 0) {
73+
// A timeframe holds no collision at all whenever the interaction rate is low enough, and
74+
// then no branch is filled. Write one empty entry in every branch instead of nothing, so
75+
// that the file is an ordinary timeframe that happens to contain no digit and every reader
76+
// downstream stays on its normal path. Each branch is bound to a default constructed object
77+
// of its own type by RootTreeWriter, so Fill() writes exactly that.
78+
LOG(info) << "No branch was filled, writing one empty entry per branch";
79+
for (TObject* entry : *brlist) {
80+
static_cast<TBranch*>(entry)->Fill();
81+
}
82+
entries = 1;
7783
}
84+
LOG(info) << "Setting entries to " << entries;
85+
outputtree->SetEntries(entries);
86+
// write the tree explicitly, the way RootTreeWriter's own close does. Closing the file alone
87+
// leaves an empty tree without a key, so the file comes out with no tree in it at all.
88+
outputfile->Write();
89+
outputfile->Close();
7890
};
7991

8092
// branch definitions for RootTreeWriter spec

0 commit comments

Comments
 (0)