Which would successfully write the histograms into the correct subdirectories. However doing a similar process to write histograms into sub-sub directories is not working for me.
May I suggest that the bug where TDirectory* subSubD1 = outputFile.mkdir(“SubDir1/SubSubDir1”); correctly produces the subsubdirectory but does not direct to it when doing subSubD1->cd() and instead directs to the upper directory be fixed?
subsubDir1 points to "SubDir1", so it is the same as subDir1 .
So the behaviour that you experience is expected.
Alternative to your solution would be something like:
TDirectory* subD1 = outputFile.mkdir("SubDir1/SubSubDir1");
// Both "SubDir1" and "SubDir1/SubSubDir1" are now created;
// now get a pointer to the subdirectory
TDirectory* subSubD1 = subD1->GetDirectory("SubSubDir1");
Thank you for the message, however this is not behaving as expected, and the documentation you have directed to contradicts itself.
"Create a sub-directory and return a pointer to the created directory."
The sub-directory SubDir1/SubSubDir1 is created, however the pointer is not to the created directory. The documentation then goes on to say that in the case SubDir1/SubSubDir1 it will point to SubDir1, however that is in direct contradiction to the claim in the documentation just before that it will return a pointer to the created directory (and also is not what someone would expect). That the pointer returned points to the created directory is what someone would expect, and is what the documentation claims. That the pointer returned points to an already existing directory that is not at all affected by the mkdir in this case is very contrary to what one would reasonably expect, and contrary to the original claim of the documentation.
I agree that it may not be expected, but it comes form the recursive implementation which leaves access to the top pointer for the return. This was there from the beginning, so it is not possible the change the behaviour.
The first statement of the doc can be be rephrased, though. This will be done asap.
Thanks for reporting.