Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Detectors/ITSMFT/common/workflow/src/DigitWriterSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ DataProcessorSpec getDigitWriterSpec(bool mctruth, o2::header::DataOrigin detOri
LOG(INFO) << "WRITING " << labels.getNElements() << " LABELS ";

o2::dataformats::IOMCTruthContainerView outputcontainer;
auto br = framework::RootTreeWriter::remapBranch(branch, &outputcontainer);
auto ptr = &outputcontainer;
auto br = framework::RootTreeWriter::remapBranch(branch, &ptr);
outputcontainer.adopt(labelbuffer);
br->Fill();
br->ResetAddress();
Expand Down
3 changes: 2 additions & 1 deletion Detectors/TPC/workflow/src/RecoWorkflow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ framework::WorkflowSpec getWorkflow(CompletionPolicyData* policyData, std::vecto
auto fillLabels = [](TBranch& branch, std::vector<char> const& labelbuffer, DataRef const& /*ref*/) {
o2::dataformats::ConstMCTruthContainerView<o2::MCCompLabel> labels(labelbuffer);
o2::dataformats::IOMCTruthContainerView outputcontainer;
auto br = framework::RootTreeWriter::remapBranch(branch, &outputcontainer);
auto ptr = &outputcontainer;
auto br = framework::RootTreeWriter::remapBranch(branch, &ptr);
outputcontainer.adopt(labelbuffer);
br->Fill();
br->ResetAddress();
Expand Down
3 changes: 2 additions & 1 deletion Detectors/TRD/workflow/src/TRDDigitWriterSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ o2::framework::DataProcessorSpec getTRDDigitWriterSpec(bool mctruth)
// make the actual output object by adopting/casting the buffer
// into a split format
o2::dataformats::IOMCTruthContainerView outputcontainer(labeldata);
auto br = framework::RootTreeWriter::remapBranch(branch, &outputcontainer);
auto ptr = &outputcontainer;
auto br = framework::RootTreeWriter::remapBranch(branch, &ptr);
br->Fill();
br->ResetAddress();
};
Expand Down
20 changes: 13 additions & 7 deletions Framework/Utils/include/DPLUtils/RootTreeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,20 @@ class RootTreeWriter
/// The function needs to be used with care. The user should ensure that "branch" is no longer used
/// after a call to this function.
template <typename T>
static TBranch* remapBranch(TBranch& branch, T* newdata)
static TBranch* remapBranch(TBranch& branchRef, T** newdata)
{
auto name = branch.GetName();
auto branchleaves = branch.GetListOfLeaves();
auto tree = branch.GetTree();
branch.DropBaskets("all");
branch.DeleteBaskets("all");
tree->GetListOfBranches()->Remove(&branch);
auto tree = branchRef.GetTree();
auto name = branchRef.GetName();
auto branch = tree->GetBranch(name); // the input branch might actually no belong to the tree but to TreeWriter cache
assert(branch);
if (branch->GetEntries()) { // if it has entries, then it was already remapped/filled at prevous event
branch->SetAddress(newdata);
return branch;
}
auto branchleaves = branch->GetListOfLeaves();
branch->DropBaskets("all");
branch->DeleteBaskets("all");
tree->GetListOfBranches()->Remove(branch);
for (auto entry : *branchleaves) {
tree->GetListOfLeaves()->Remove(entry);
}
Expand Down
3 changes: 2 additions & 1 deletion Steer/DigitizerWorkflow/src/FDDDigitWriterSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ o2::framework::DataProcessorSpec getFDDDigitWriterSpec(bool mctruth = true)
// make the actual output object by adopting/casting the buffer
// into a split format
o2::dataformats::IOMCTruthContainerView outputcontainer(labeldata);
auto br = framework::RootTreeWriter::remapBranch(branch, &outputcontainer);
auto ptr = &outputcontainer;
auto br = framework::RootTreeWriter::remapBranch(branch, &ptr);
br->Fill();
br->ResetAddress();
};
Expand Down
3 changes: 2 additions & 1 deletion Steer/DigitizerWorkflow/src/TPCDigitRootWriterSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ DataProcessorSpec getTPCDigitRootWriterSpec(std::vector<int> const& laneConfigur
// first of all redefine the output format (special to labels)
auto tree = branch.GetTree();
auto sector = extractSector(ref);
auto br = framework::RootTreeWriter::remapBranch(branch, &outputcontainer);
auto ptr = &outputcontainer;
auto br = framework::RootTreeWriter::remapBranch(branch, &ptr);

auto const* dh = DataRefUtils::getHeader<DataHeader*>(ref);
LOG(INFO) << "HAVE LABEL DATA FOR SECTOR " << sector << " ON CHANNEL " << dh->subSpecification;
Expand Down