I have multiple root files “file1.root”, “file2.root”, “file3.root”, etc… all containing the same TTree (but with different contents).
If I start up root with
root -l file1.root file2.root file3.root
in fact only the last file is loaded into memory.
How do I get all three files loaded and accessible at the same time (I am guessing I have to use a Chain, but is there some easy way to do this?)
if the content is different but the branches are the same, a TChain is the way to go:
or, if you want to load the files separately:
Thank you very much, this works.
Actually, I didn’t look well to what I got using your method. As a matter of fact, neither method works:
root  TChain mychain("…/GAMOS_output_GmSDTTreeUA/Gm*.root");
root  mychain->Print()
This returns nothing. It seems nothing is loaded.
root  TFile file1("…/GAMOS_output_GmSDTTreeUA/GmSDTTreeUA_tree_1000.root")
root  TFile file2("…/GAMOS_output_GmSDTTreeUA/GmSDTTreeUA_tree_1001.root")
root  TFile file3("…/GAMOS_output_GmSDTTreeUA/GmSDTTreeUA_tree_1002.root")
root  TFile file4("…/GAMOS_output_GmSDTTreeUA/GmSDTTreeUA_tree_1003.root")
Now, only file4 is in memory. When I draw a histogram of the Tree, as contained in all 4 files, clearly, only the contents of file4 are drwan, the contents of the first 3 files are not.
apologies! I mixed up the methods. Try
You’re right. I just tested it, and indeed, this does work.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.