-
Notifications
You must be signed in to change notification settings - Fork 14
Form fix ttree write threading #476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
knoepfel
merged 4 commits into
Framework-R-D:main
from
aolivier23:form_fix_ttree_write_threading
Mar 31, 2026
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2f49029
Proposed fix for weird threading problems with TTree getting saved to
aolivier23 df3b5f6
Removed cout statements that we were using to demonstrate that this
aolivier23 c5b786c
Merge branch 'main' into form_fix_ttree_write_threading
aolivier23 8be135e
Removed comment about changes in this PR.
aolivier23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,7 +16,12 @@ ROOT_TTree_Write_ContainerImp::ROOT_TTree_Write_ContainerImp(std::string const& | |||||
| ROOT_TTree_Write_ContainerImp::~ROOT_TTree_Write_ContainerImp() | ||||||
| { | ||||||
| if (m_tree != nullptr) { | ||||||
| m_tree->Write(); | ||||||
| m_tree->GetDirectory()->WriteTObject(m_tree); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It should already be doing what (and a few more thing) the PR does. (On the other the SetDirectory is probably necessary to ensure that the TTree ends up in the right file). |
||||||
| //m_tree->Write() is not good enough because that writes to the _current_ gDirectory. | ||||||
| //Sometimes gDirectory is getting reset even while m_tfile is still open! We think | ||||||
| //it may have to do with multithreading. | ||||||
| //I'm pretty sure we had a reason why the TFile destructor isn't good enough, | ||||||
| //but I don't remember what it is right now. Maybe recovering partial jobs? | ||||||
| delete m_tree; | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -42,8 +47,8 @@ void ROOT_TTree_Write_ContainerImp::setupWrite(std::type_info const& /* type*/) | |||||
| m_tree = m_tfile->Get<TTree>(name().c_str()); | ||||||
| } | ||||||
| if (m_tree == nullptr) { | ||||||
| TDirectory::TContext context(m_tfile.get()); | ||||||
|
aolivier23 marked this conversation as resolved.
|
||||||
| m_tree = new TTree(name().c_str(), name().c_str()); | ||||||
| m_tree->SetDirectory(m_tfile.get()); //I think this is necessary so other FORM containers for this tree can discover it. But shouldn't Storage take care of that? | ||||||
|
aolivier23 marked this conversation as resolved.
Outdated
|
||||||
| } | ||||||
| if (m_tree == nullptr) { | ||||||
| throw std::runtime_error("ROOT_TTree_Write_ContainerImp::setupWrite no tree created"); | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.