Re: THStack not drawing

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 4 May 2009 07:34:00 +0200


Hi James,

Replace

   THStack hs("hs", "Di-electron");
by

   THStack *hs = new THStack("hs", "Di-electron");

otherwise the object is deleted when the function returns.

Rene Brun

James Jackson wrote:
> Hi,
>
> I am opening a number of files, each with an identicially named
> histogram. I am adding these to a THStack. However, the stack is not
> drawing to the canvas. The following is a very simple example:
>
> void CombinePlots()
> {
> // Get histograms
> TFile *ttjets = TFile::Open("TTJets.root");
> TH1F *h1 = ttjets->Get("ptHist");
> h1->SetFillColor(kBlue);
>
>
>
> // Add to stack and draw
> THStack hs("hs", "Di-electron");
> hs.Add(h1);
>
> // This shows the histogram as added, with correct address
> hs.ls();
>
> // This call leaves an empty canvas
> TCanvas *c1 = new TCanvas();
> hs.Draw();
>
> // This call draws the histogram
> TCanvas *c2 = new TCanvas();
> h1->Draw();
> }
>
> I can't see, from the examples in the manual, what is going wrong
> here. Does anyone have any ideas?
>
> Regards,
> James.
Received on Mon May 04 2009 - 07:34:30 CEST

This archive was generated by hypermail 2.2.0 : Mon May 04 2009 - 17:50:01 CEST