ROOT Version: 5.34/10 Platform: Ubuntu 18.04 LTS Compiler: Not Provided
Hello,
Is there a way to save all graphs as PNG files by inputting a root file?
My code creates around 100 histograms, and I was able to create PNG files for all of them. However, I run the code 257 times, with different input files (TFile infile(“job_0.root”), TFile infile(“job_2.root”), … ,TFile infile(“job_256.root”)). To combine all the root files from the different input files, I use the command “hadd combinedrootfiles.root /*.root” which combines all the root files into one root file, which superimposes all the graphs.
However, I cannot create PNG files from the combinedrootfile.root that I created. Is there a way to save all 100 graphs from this combinedrootfile.root to PNG files?
Before, I was screenshotting all 100 graphs, twice for different data sets, and it was becoming very annoying and time-consuming.
Thank you very much and I really appreciate any help,
ppajarillo
Maybe the command line tool rootprint can help you.
$ rootprint --help
usage: rootprint [-h] [-d DIRECTORY] [--divide DIVIDE] [-D DRAW] [-f FORMAT]
[-o OUTPUT] [-s SIZE] [-S STYLE] [-v]
FILE [FILE ...]
Print ROOT files contents on ps,pdf or pictures files
positional arguments:
FILE Input file
optional arguments:
-h, --help show this help message and exit
-d DIRECTORY, --directory DIRECTORY
put output files in a subdirectory named DIRECTORY.
--divide DIVIDE divide the canvas ont the format 'x','y' (ex: 2,2)
-D DRAW, --draw DRAW specify draw option
-f FORMAT, --format FORMAT
specify output format (ex: pdf, png).
-o OUTPUT, --output OUTPUT
merge files in a file named OUTPUT (only for ps and
pdf).
-s SIZE, --size SIZE specify canvas size on the format 'width'x'height'
(ex: 600x400)
-S STYLE, --style STYLE
specify a C file name which define a style
-v, --verbose print informations about the running
Examples:
- rootprint example.root:hist
Create a pdf file named 'hist.pdf' which contain the histogram 'hist'.
- rootprint -d histograms example.root:hist
Create a pdf file named 'hist.pdf' which contain the histogram 'hist' and put it in the directory 'histograms' (create it if not already exists).
- rootprint -f png example.root:hist
Create a png file named 'hist.png' which contain the histogram 'hist'.
- rootprint -o histograms.pdf example.root:hist*
Create a pdf file named 'histograms.pdf' which contain all histograms whose name starts with 'hist'. It works also with postscript.
Hello, thank you so much for your help! Unfortunately, this command does not work since I have an older version of ROOT (5.34/10). I created a function to convert the histogram and it works, however, I need to find a way to create an array of the names of the histograms so I can input it to the function. Do you have an idea on how to do this? Thank you very much!