Re: Displaying multiple histograms within same macro

From: Deepak Kar <dkar_at_phys.ufl.edu>
Date: Wed, 20 Feb 2008 09:31:35 -0500


Thanks, it works. One more quick question, if I just want to draw the fitted function, not the histogram, is there a way to it in here?

On Feb 20, 2008 9:15 AM, Olivier Couet <Olivier.Couet_at_cern.ch> wrote:
> Hi,
>
> Fit() does the plot, like Draw(). Put "same" in Fit() and do not Draw
> the last histo (it will be drawn by Fit())
>
> Ie do:
>
> hist2->Fit("f2","","same",2,150);
>
> instead of:
>
> hist2->Fit("f2","","",2,150);
> f2->Draw("same");
>
> Cheers, O.Couet
>
>
> -----Original Message-----
> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
> On Behalf Of Deepak Kar
> Sent: Wednesday, February 20, 2008 2:56 PM
> To: roottalk_at_root.cern.ch
> Subject: [ROOT] Displaying multiple histograms within same macro
>
> 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
>
>

-- 
Deepak Kar
Graduate Student of Physics
University of Florida
Homepage - www.phys.ufl.edu/~dkar
Blog @ http://dipthought.blogspot.com
Received on Wed Feb 20 2008 - 15:31:40 CET

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