I have three files (1.root ,2.root ,2.root ) and I want to draw them all in one drawing ?

I have three files (1.root ,2.root ,2.root ) and I want to draw them all in one drawing ?

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


perhaps the right tool to start is the command line tool provided by ROOT hadd.


The problem
I have three files.root and I want to draw all these files in one drawing
Every file has a large number of data I can not put them all in one file
please help

I found the solution thank you
Normal TTree functions can be used
root [ ]chain= new TChain(“tree”);
root [ ]chain->Add (“1.root”);
root [ ]chain->Add (“2.root”);
root [ ]chain->Draw (“x”);

I usually write a new macro to achieve this. Suppose you have 2 root files 1.root and 2.root and they contain the TF1 called “001” and “002” respectively, then you can write a new macro in the following way or somethings like below :

TFile *f1 = new TFile("1.root") ; //read 1.root
TFile *f2 = new TFile("2.root") ; //read 2.root
TF1 *fn1, *fn2 ; //define a new TF1 used in this macro
f1->GetObject("001",fn1) ; //import 001 from 1.root to fn1
f2->GetObject("002",fn2) ; //import 002 from 2.root to fn2
fn1->Draw(); //Draw the first function
fn2->Draw("same"); //Draw the second function on the same Canvas

hope this help…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.