-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[HF] Prepare HistFactory for ROOT without implicit ownership #20922
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
base: master
Are you sure you want to change the base?
Conversation
| TFile* file = new TFile("dataDriven.root", "RECREATE"); | ||
|
|
||
| TH1F* FlatHist = new TH1F("FlatHist","FlatHist", 2,0,2); | ||
| FlatHist->SetDirectory(file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it yet 🙂 If you later explicitly write the histograms with file->WriteTObject(histo), why do you need to do SetDirectory(file) before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You indeed don't need it to write, but you do need it to destroy the histogram. Alternatively, you can of course take the ownership "manually".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me do a solution that doesn't need SetDirectory
If implicit object ownership gets in TDirectories gets switched off, the example histograms need to be added to directories or written explicitly.
f5398dd to
4b5962e
Compare
git clang-format applied enough changes to make it worth formatting the entire file.
4b5962e to
f4a8d9b
Compare
guitargeek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! As discussed also in private, I think this PR sets now a good precedent for how to write histogram objects to files.
Test Results 22 files 22 suites 3d 20h 55m 46s ⏱️ Results for commit f4a8d9b. |
makeExample.CtutorialBy making the writes explicit, the tests become independent of gDirectory and whether or not histograms register themselves.