I’m currently trying to write a histogram from a dataframe to a .root files subdirectory. The creation of the directory works and writing of the histogram, but it doesn’t go to the subdirectory. The problem is probably when changing the working directory, so how should it be done?
The code looks like (there’s some minor stuff before this):
makes 'dir_name' the “current” directory (the value of gDirectory)
myFile.WriteObject(hist.GetPtr(), "pT")
explicitly request to (ignore gDirectory and to) write the object in the ‘directory’ myFile (the pointer to the file is also the pointer to the top level directory of the file).