Hi Gabi,
You must call
c1->Update();
after the line
h2->Draw("list cont");
see Users Guide Chapter 9, section "Updating the pad"
Rene Brun
Gabriel Tabacaru wrote:
>
> Hi everbody!
>
> I have a 2-d histogram and I'd like to get the graphs corresponding to
> the contour lines. According to the documentation , making
> h2->Draw("cont list") should save me these objects (contours) into
> Specials.
> The browser can see the Specials "contours" but double click on one of the
> graphs break(Segmentation violation) the root.
> Trying to get the graphs objects via macro look like impossible for the
> moment. Does anybody have a solution for this ?
>
> I think that this problem was reported before but I can't figure out a
> good answer. I have root 4.00/02 CVS on PC Pentium 4 RedHat 9.
>
> Regards,
> Gabi
> --
> ===============================================
> Dr. Gabriel Tabacaru =
> Cyclotron Institute - Texas A&M University =
> Univ. Drive =
> MS 3366, College Station, Texas 77843-3366 =
> USA =
> Tel. : ++ 979 845 1411 =
> e-mail: tabacaru@comp.tamu.edu =
> tabacaru@tamu.edu =
> ===============================================
> =================================================================
> MACRO test_contour.C
> {
> gROOT->Reset();
>
> TH2F *h2=new TH2F("h2","h2",30,-0.5,0.5,30,-0.5,0.5);
> for(Int_t i=0;i<1000;i++){
> Float_t x=gRandom->Gaus(0,0.2);
> Float_t y=gRandom->Gaus(0.2,0.2);
> h2->Fill(x,y);
> }
> TCanvas *c1=new TCanvas("c1","c1",600,600);
> h2->Draw("list cont");
>
> TObjArray *contours=
> (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
> Int_t nc=contours->GetSize();
> cout<<nc<<endl;
> //TList *list=(TList*)contours->At(3);
> //TGraph *gr1=(TGraph*)list->First();
> }
> root [0] .x test_contour.C
> Processing test_contour.C...
> Error: illegal pointer to class object contours 0x0 85 FILE:test_contour.C
> LINE:16
> *** Interpreter error recovered ***
> root [1] TBrowser b
> Double click on root->Specials->Contours->TList->Graph
> root [2]
> *** Break *** segmentation violation
> Generating stack trace...
> 0x41275054 in TRootBrowser::ProcessMessage(long, long, long) + 0xe66 from
> /opt/root/root/lib/libGui.so
> 0x412065a0 in TGFrame::HandleClientMessage(Event_t*) + 0x36 from
> /opt/root/root/lib/libGui.so
> 0x4120914e in TGMainFrame::HandleClientMessage(Event_t*) + 0x22 from
> /opt/root/root/lib/libGui.so
> 0x41206331 in TGFrame::HandleEvent(Event_t*) + 0x1fd from
> /opt/root/root/lib/libGui.so
> 0x411eddd3 in TGClient::HandleEvent(Event_t*) + 0xd1 from
> /opt/root/root/lib/libGui.so
> 0x411edac7 in TGClient::ProcessOneEvent() + 0x71 from
> /opt/root/root/lib/libGui.so
> 0x411edb59 in TGClient::HandleInput() + 0x2d from
> /opt/root/root/lib/libGui.so
> 0x411ec65a in TGInputHandler::Notify() + 0x1e from
> /opt/root/root/lib/libGui.so 0x401c6909 in
> TUnixSystem::DispatchOneEvent(bool) + 0x3b from
> /opt/root/root/lib/libCore.so
> 0x4013553c in TSystem::InnerLoop() + 0x18 from
> /opt/root/root/lib/libCore.so
> 0x401354e1 in TSystem::Run() + 0x6f from /opt/root/root/lib/libCore.so
> 0x400e630d in TApplication::Run(bool) + 0x2d from
> /opt/root/root/lib/libCore.so 0x40dd9697 in TRint::Run(bool) + 0x31d from
> /opt/root/root/lib/libRint.so
> 0x08048861 in main + 0x71 from /opt/root/root/bin/root.exe
> 0x42015574 in __libc_start_main + 0xe4 from /lib/tls/libc.so.6
> 0x08048761 in _Unwind_Resume + 0x31 from /opt/root/root/bin/root.exe
> Root >
> *** Break *** segmentation violation
> Generating stack trace...
> 0x412065a0 in TGFrame::HandleClientMessage(Event_t*) + 0x36 from
> /opt/root/root/lib/libGui.so
> 0x4120914e in TGMainFrame::HandleClientMessage(Event_t*) + 0x22 from
> /opt/root/root/lib/libGui.so
> 0x41206331 in TGFrame::HandleEvent(Event_t*) + 0x1fd from
> /opt/root/root/lib/libGui.so
> 0x411eddd3 in TGClient::HandleEvent(Event_t*) + 0xd1 from
> /opt/root/root/lib/libGui.so
> 0x411edac7 in TGClient::ProcessOneEvent() + 0x71 from
> /opt/root/root/lib/libGui.so
> 0x411edb59 in TGClient::HandleInput() + 0x2d from
> /opt/root/root/lib/libGui.so
> 0x411ec65a in TGInputHandler::Notify() + 0x1e from
> /opt/root/root/lib/libGui.so 0x401c6909 in
> TUnixSystem::DispatchOneEvent(bool) + 0x3b from
> /opt/root/root/lib/libCore.so
> 0x4013553c in TSystem::InnerLoop() + 0x18 from
> /opt/root/root/lib/libCore.so
> 0x401354e1 in TSystem::Run() + 0x6f from /opt/root/root/lib/libCore.so
> 0x400e630d in TApplication::Run(bool) + 0x2d from
> /opt/root/root/lib/libCore.so 0x40dd9697 in TRint::Run(bool) + 0x31d from
> /opt/root/root/lib/libRint.so
> 0x08048861 in main + 0x71 from /opt/root/root/bin/root.exe
> 0x42015574 in __libc_start_main + 0xe4 from /lib/tls/libc.so.6
> 0x08048761 in _Unwind_Resume + 0x31 from /opt/root/root/bin/root.exe
> Root >
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET