Re: [ROOT] Seg fault with copy of histogram

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Oct 10 2002 - 09:04:09 MEST


Hi Rich,

The default "htemp" histogram generated by TTree::Draw is marked
"to be deleted" when the pad is cleared. This is to prevent an inflation
of htemp objects in memory.
If you want to keep the histogram, you have two options:
 1-recommended
 TFile f("root/5100/run5152.root")
 ntp1->Draw("bpm31X>>new")
 ntp1->Draw("bpm31Y")
 new->Draw()

 2-Reset the bit declaring the histogram a temporary object
  TFile f("root/5100/run5152.root")
  ntp1->Draw("bpm31X")
  TH1F *new = (TH1F*)htemp->Clone("new")
  new->ResetBit(kCanDelete)
  ntp1->Draw("bpm31Y")
  new->Draw()

Rene Brun

On 9 Oct 2002, Rich Holmes wrote:

> Why does this not work?  I'm using ROOT 3.02/07 under Red Hat Linux
> 7.2.  ntp1 is a tree in the root file.
> 
> root [0] TFile f("root/5100/run5152.root")                       
> root [1] ntp1->Draw("bpm31X")                                    
> <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
> root [2] TH1F *new = (TH1F*)(htemp->Clone())                     
> root [3] new->SetName("new")                                     
> root [4] new->Draw()                                             
> root [5] ntp1->Draw("bpm31Y")                                    
> root [6] new->Draw()                                             
> 
>  *** Break *** segmentation violation
> 
> [new->Draw() works fine, until I use ntp1->Draw(), and then new->Draw()
> seg faults.]
> 
> -- 
> Richard S. Holmes, Research Assistant Professor
> Physics Department, Syracuse University
> Syracuse, NY 13244
> (315) 443-5977
> 



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