Dear Rooters, with ROOT 3.03/09 i try to manage an array of TGraphs in
order to retrieve the maximum for each of the TGraphs.
So first I get the TClonesArray:
int entries = 100;// number of points for each graph
double *bsua = new double[entries]; // abscisses of the graph
double *aree = new double[entries]; // ordinates "
int nd = 4; // number of TGraphs
TClonesArray g("TGraph",nd);
for (int lo=0;lo<nd;lo++){
for (Int_t ki=0;ki<entries;ki++)
{
aree[ki]=GetOrdinates(lo); // these are two function that gets
the appropriate data
bsua[ki]=GetAbscisses(lo);
}
new(g[lo]) TGraph(entries,bsua,aree);
}
TGraph *gra;
TIter git(&g);
TCanvas *c = new TCanvas("ZoneAree");
c->Draw();
double io;
while(gra = (TGraph*)git.Next())
{
TH1F *h = gra->GetHistogram();
cout<<h->GetMaximum()<<endl;
}
The error I get is:
Error: illegal pointer to class object h 0x0 145
FILE:Analisi_zonearea.C LINE:112
(class G__CINT_ENDL)141368720
*** Interpreter error recovered ***
Note, that if I draw the TGraph, it works!!!!!!
Where do I commit a mistake?
Thank you!!!!!
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET