I have a ROOT file which contains several plots. I want to save all of them to separate png files, replicating the directory structure that is within the ROOT file as well. How can I do this? I am trying with rootprint like this:
Inside those two “root folders” there are more “folders” with plots. This is what I want to “extract”. In case I am not expressing myself clearly, this:
It looks to me like rootprint does not know how to handle files where all histograms are located in a top-level “folder”. I have a file without “folder”, for which rootprint successfully produces .png files, and a file with a “folder” - indeed, nothing happens for it.
Is there any workaround? I am not an experienced ROOT user, I just need to be able to explore these plots as individual files. The reason: I am SSHing into the PC where the ROOT files are, and if I want to see the plots as it is now I either transfer the full ROOT file to my local PC, which takes considerable time, or I open ROOT remotely with SSH, which is considerably slow. So I just want to have the plots as normal files.
groot’s root-print (it’s now under go-hep.org/x/hep/groot/cmd/root-print) doesn’t output files in a hierarchical fashion (even though it does walk through the whole internal ROOT file directory structure).
walking the contents of a ROOT file is relatively easy though:
package main
import (
"fmt"
"log"
stdpath "path"
"strings"
"go-hep.org/x/hep/groot/riofs"
"go-hep.org/x/hep/groot/root"
)
func main() {
f, err := riofs.Open("../testdata/dirs-6.14.00.root")
if err != nil {
log.Fatal(err)
}
defer f.Close()
fmt.Printf("visit all ROOT file tree:\n")
err = riofs.Walk(f, func(path string, obj root.Object, err error) error {
fmt.Printf("%s (%s)\n", path, obj.Class())
return nil
})
if err != nil {
log.Fatalf("could not walk through file: %v", err)
}
}