Displaying multiple histograms within same macro

From: Deepak Kar <dkar_at_phys.ufl.edu>
Date: Wed, 20 Feb 2008 08:55:52 -0500


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 - 14:56:02 CET

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