Re: [ROOT] Superimposing histograms

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jan 29 2002 - 14:54:55 MET


Do something like:

TFile *f1 = new TFile("file1.root");
TTree *T1 = (TTree*)f1->Get("t1");
T1->SetLineColor(kRed);
T1->Draw("Evis");
TFile *f1 = new TFile("file2.root");
TTree *T2 = (TTree*)f2->Get("T2");
T2->SetLineColor(kBlue);
T2->Draw("Evis","some cut","same");
etc

By default, the generated histograms has its attrbutes imported from the Tree
attributes. You can also use the >>h1 notation
then do h1->SetLineColor(kRed).

Rene Brun

Dennis C. Arrogancia wrote:
> 
> Dear Rene,
> 
> I'll revise my question. I have 4 different files say "file1.root",
> "file2.root","file3.root", and "file4.root". Suppose each file contains a
> tree "T1". Variables stored in "T1" are Evis, Pt, Pl, etc. I want to
> superimpose each of these variables in a histogram for my
> background analysis. I need it because i'm formulating a selection
> criteria. What i want is for example all the Evis's from each of the 4
> files is superimposed in a histogram, and so on. I want to distinguish
> each of them by putting a line color.
> 
> I hope it is clear now. Thank you for your help.
> 
> Dennis
> 
> On Tue, 29 Jan 2002, Rene Brun wrote:
> 
> > Dennis,
> >
> > It is not completly clear what you want to do. Here is a solution
> > to my interpretation of your question:
> >
> > TChain *MakeChain(const char* name) {
> >    TChain *chain = new TChain(name);
> >    chain->AddFile("file1.root");
> >    chain->AddFile("file2.root");
> >    chain->AddFile("file3.root");
> >    chain->AddFile("file4.root");
> >    return chain;
> > }
> > void test() {
> >    TChain *chain1 = MakeChain("T1");
> >    chain1->Draw("x");
> >    TChain *chain2 = MakeChain("T2");
> >    chain2->Draw("x","","same");
> >    TChain *chain3 = MakeChain("T3");
> >    chain3->Draw("x","","same");
> > }
> >
> > Rene Brun
> >
> > Dennis C. Arrogancia wrote:
> > >
> > > Dear ROOTERS,
> > >
> > > I have 4 different files say f1.root, f2.root, f3.root, and f4.root.
> > > Each file contains three trees, "T1","T2", and "T3". I want to compare it
> > > by superimposing the variables in each of the trees from the 4 files and
> > > draw it in a histogram. How can i do it? Can anyone give me an example?
> > >
> > > dennis
> >



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:40 MET