Hi Every Body,
I have two .root files including histograms. I got them from AIDA in geant4. For opening these files I need root.
I need to open these two files in one canvas in order to be able to compare them.
I am wondering should I write a c++ code for that or can I do it easily from the browser?
Really thank for your help
What do you have in these root files ? Histograms ? trees ? Canvases ?..
I would say you should create a canvas, divide it using Divide(), do one plot in the first pad and the other in the pad next to it. For instance like in :
root.cern.ch/root/html/tutorials … opt.C.html
root.cern.ch/root/html/tutorials … dom.C.html
I have histograms in those root files that I have to compare them.
No, I think using Divide() just put them close to each other .
I need something like: root.cern.ch/drupal/category/ima … ualization
The first screenshot from the left shows an Exclusion graph in ATLAS. You see there are more than one graphs in one canvas.
You plot the first histogram then the 2nd one using the option SAME.
Can I ask you a very beginner question.
I need to create a script to type those codes, Could you please kindly tell me how I can create a script in root ?
Thank you again
In a file called simple.C you put:
h1->Draw(); // h1 is the first histogram to draw sitting in f1.root
h2->Draw("same"); // h2 is the 2nd histogram to draw sitting in f2.root
Then you enter root and you type “.x simple.C”
I have enclosed my two files,
By looking at the Superimposing Histograms with Different Scales script, I see that I only need to do
So I just combined the C code for two histograms and added the line above.
- I don’t think that I can see the file essai2_2.C in TBrowser
2.I am just wondering that when I change a script, I don’t need to compile it in root! just execute it?
essai1_2.C (15.2 KB)
essai2_2.C (7.6 KB)
I think you should spend a bit of time reading the doc…
What you did cannot work … you cannot combine macros like that …
do you have the root files with the histograms what to plot ? i will try to make a macro …
Thank you for your help
These three root files contain three histograms (1,2,3)
Let’s suppose that I want to compare all histograms number number 2 in these three files.
essai3.root (9.4 KB)
essai2.root (9.74 KB)
essai1.root (10 KB)
Here is the script:
essai.C (286 Bytes)
Thanks a lot for your script. Unfortunately here comes my weakness in pointers and c++.
I get illegal pointer error message by running your script.
Could you pls look at these two specific root files: I tried to replace 2__1 and 2__2 instead of h1 and h2 , but I got:
Again many thanks in advance
essai2_2.root (16.1 KB)
essai1_2.root (16.1 KB)
Have you run the macro I sent you ? it should work if you do not modify it… does it ?
No really sorry…
I opened a new root window. it works…
Could u please also help me with the two recent files , I sent u.
I type the same as your script in my terminal…
TH1D *h1=f1.Get("2__1"); instead
But when I do
h1->SetLineColor(kRed); I receive:
These file contains Canvases not histrograms … You are mixing up many diferents things…
root  TFile f("essai1_2.root")
root  f.ls()
KEY: TCanvas Canvas 1;1 Canvas 1
root  TCanvas *c = f.Get("Canvas 1");
root  c.Draw()
Yes you are right. The problem is that I have sort of limited time and I am sort of stressed unfortunately.
I have enclosed my two files again asking you another question. I will really appreciate if you help me with them.
in essai3.root, the histogram number 2 is sort of noisy, but it is not the case in essai2.root, Nevertheless while superimposing them, the green dots represents a line like y=0 , not the histogram 2 in essai3.root!
I need to have a legend,naming both histograms. I found this link:
slac.stanford.edu/BFROOT/www … ml#compare
in section comparing histograms:
leg_hist = new TLegend(0.5,0.6,0.79,0.79);
in my case i only changed
h3 for my case, and you know that it didn’t work.
I am really thankful if you help me with this as well.
essai2.root (9.74 KB)
essai3.root (9.4 KB)
Could you please kindly run the script as well and see if you get the same result as 1and2and3.root?
1and2and3.root (18.2 KB)
essai3.root (9.66 KB)
essai2.root (9.97 KB)
essai1.root (9.61 KB)
Try the attached macro. It gives the attached picture.