Re: Displaying multiple histograms within same macro

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 20 Feb 2008 15:12:10 +0100


Replace

   TFile f(..
by

   TFile *f = new TFile(..
otherwise all objects, histograms belonging to this file will be deleted when leaving the scope of your function.

Rene Brun

Deepak Kar wrote:
> Hi,
>
> I am trying to display 3 different histograms in the same canvas, and
> here is what I'm doing in my macro,
> {
> TCanvas *c1= new TCanvas("c1");
>
> TFile f("../dy_histos/bhel_tlt.root");
> TProfile *hist1=(TProfile*)
> gDirectory->Get("Ana/dyjet/Hist/dyjet_Tnchg5pairpt2");
> //do things with hist1
> hist1->Draw();
> c1->Update();
>
> TFile f("../dy_histos/ze_gen.root");
> TProfile *hist2=(TProfile*)
> gDirectory->Get("Ana/dyjet/Hist/dyjet_Tnchg5pairpt2");
> // Do things with hist2
> hist2->Draw("same");
>
> TF1 *f2 = new TF1("f2","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]/x+[5]/(x*x)",0,1000);
> f2->SetLineColor(kRed);
> hist2->Fit("f2","","",2,150);
> f2->Draw("same");
> }
>
> It does what it is supposed to do with each histogram, and print
> hist1, hist2 and f2 individually. However when I run this macro, I end
> up getting the whatever is drawn last. How can I make it "remember"
> the eariler histograms? Putting Draw("same") does not help!
>
> Thanks so much,
> Deepak
>
>
Received on Wed Feb 20 2008 - 15:09:15 CET

This archive was generated by hypermail 2.2.0 : Wed Feb 20 2008 - 17:50:01 CET