Re: TGraph.DrawGraph() => seg. viol.

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon May 17 1999 - 14:00:23 MEST


Hi Selim,
You are probabli hitting a space problem.
You are creating a TH2F with 2500 x 2500 bins !!
This requires 25 Mbytes of memory.
I can run your macro without problems on my machine.
I suggest you modify your macro to something like:

{
const int s=50 000;

TNtuple *nt = new TNtuple("nt", "", "x:y", 100 000);
for(int i=0; i<s; i++) {
  nt->Fill(i, 3*i);
}
cout << "nt filled" << endl;

TCanvas *c = new TCanvas("c", "");
c->Draw();

TH2C *h  = new TH2C("h",  "", 25, 0, s, 25, 0, 3*s);  
h->Draw();
c->Update();
cout << "hist drawn" << endl;

nt->Draw("y:x", "", "goff,same");
cout << "nt drawn" << endl;

Int_t    selR = nt->GetSelectedRows();
Float_t *xArr = nt->GetV2();
Float_t *yArr = nt->GetV1();
cout << "got args" << endl;

TGraph *g = new TGraph(selR, xArr, yArr);
g->Draw("l");
cout << "graph drawn" << endl;
c->Update();

}

Rene Brun



Selim Issever wrote:
> 
> Hi all,..
> 
> doesn anybody have an idea, why the following script gives me a seg violation?
> It works for small s (I guess 32000 is the real magic border)
> 
> in principal I just wanted to plot 2 ntuple entries against each
> other and have lines drawn between all the points,...
> 
> If somebody has a another but working solution, thats ok with me too;)
> 
> Cheerio,
> Selim
> 
> --- tt.C ------------------------------
> 
> {
> const int s=50 000;
> 
> TNtuple *nt = new TNtuple("nt", "", "x:y", 100 000);
> for(int i=0; i<s; i++) {
>   nt->Fill(i, 3*i);
> }
> cout << "nt filled" << endl;
> 
> TCanvas *c = new TCanvas("c", "");
> c->Draw();
> 
> TH2C *h  = new TH2C("h",  "", 2500, 0, s, 2500, 0, 3*s);
> h->Draw();
> c->Update();
> cout << "hist drawn" << endl;
> 
> TGraph *g = new TGraph(100 000);
> nt->Draw("y:x", "", "goff,same");
> cout << "nt drawn" << endl;
> 
> Int_t    selR = nt->GetSelectedRows();
> Float_t *xArr = nt->GetV2();
> Float_t *yArr = nt->GetV1();
> cout << "got args" << endl;
> 
> g->DrawGraph(selR, xArr, yArr, "l");
> cout << "graph drawn" << endl;
> c->Update();
> 
> }
> ---------------------------------------------
> this is the output:
> 
> root [0] .x tt.C
> nt filled
> hist drawn
> nt drawn
> got args
> 
>  *** Break *** segmentation violation
> 
> --
> Selim Issever | Tel: 040 8998-2843    +- It is nothing; they are only -
> DESY-F15      | Fax: 040 8998-4033    +- killing my husband.      -----
> Notkestr. 85  | selim.issever@desy.de +----- Portuguese Proverb -------
> 22603 Hamburg/Germany   |  http://www.physik.uni-dortmund.de/~issevers



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:33 MET