Plotting three leafs in one canvas

Hi,
I only recently started using root so I’m currently very confused.
I have three root files, where I want to extract the leaf (?) integral[0] for these three files and then draw them all in one picture.
extracting integral[0] and drawing that for one file is seemingly easy with

TFile *file=new TFile("Documents/Bachelor/1. Messung 3.11.23/1675V_9909_1photonevent_55tune_short.root")
(TFile *) 0x7fe87552dfc0
root [26] resultTree->Draw("integral[0]")

can anyone help me how I do this for three different files (they all have that leaf). I haven’t really found anything on the internet, and chatgpt also couldn’t help me. I would really appreciate the help

ROOT Version: 6.26.11
Platform: Not Provided
Compiler: Not Provided


oh also I use the command line, so each “sentence” of my code is read separately. I don’t know how to change that, because chatgpt has given me codes where there are syntax differences and such and I can’t really compute that…

TChain ch("resultTree");
ch.Add("Documents/Bachelor/1. Messung 3.11.23/1675V_9909_1photonevent_55tune_short.root");
ch.Add("Documents/Bachelor/1. Messung 3.11.23/second_file.root");
ch.Add("Documents/Bachelor/1. Messung 3.11.23/third_file.root");
ch.Draw("integral[0]");

this gave me a result, thank you. however, I’m a bit confused by the result, haha. would it be possible to differentiate between the three files in the canvas? I don’t know if what is shown, is even correct tbh
falsch?.pdf (16.2 KB)

Yes.

TChain ch1("resultTree");
ch1.Add("Documents/Bachelor/1. Messung 3.11.23/1675V_9909_1photonevent_55tune_short.root");
TChain ch2("resultTree");
ch2.Add("Documents/Bachelor/1. Messung 3.11.23/second_file.root");
TChain ch3("resultTree");
ch3.Add("Documents/Bachelor/1. Messung 3.11.23/third_file.root");
ch1.Draw("integral[0]");
ch2.Draw("integral[0]", "", "SAME");
ch3.Draw("integral[0]", "", "SAME");

I don’t know if what is shown, is even correct tbh

Only you or the original author of the file might know that.