Problem with array of TH1F and new[]

Dear All,

I’m trying to use an array of histograms, but my code gives the output bellow before break:

the relevant parts of the code are:
Diffv02.h:

 27 class Diffv02 : ... {
 28  public:
 29     Diffv02();
 ...
 37  private:
 38     Int_t etabins;
 39     Double_t * fCenters;  //[etabins]
 40     Int_t fNumHist; 

and Diffv02.cxx:

161     etalow =-4.5; etaup = 6.0; etabins = 10.*(etaup-etalow);
162     fFMDaux = new TH1F("fFMDaux","auxiliar hist for Multiplicity_eta of event",etabins,etalow,etaup);
163     fFMDaux->GetXaxis()->SetTitle("#eta");
164     //
165     fHistFMDm = new TH1F*[2];
166     fCenters = new Double_t [etabins]; 
167     // 0 Has V/ESD and pss SPD vertex cut
168     // 1 min bias
169     for (Int_t i=0; i<2; i++) {
170       TString fStrName = TString::Format("fHistFMDm%d",i);
171       fHistFMDm[i] = new TH1F(fStrName,fStrName,etabins,etalow,etaup);
172       fHistFMDm[i]->GetXaxis()->SetTitle("#eta");
173       fHistFMDm[i]->GetYaxis()->SetTitle("Multiplicity");
174       fHistFMDm[i]->Sumw2();
175       fOutput->Add(fHistFMDm[i]);
176     }
177     fHistFMDm[0]->GetCenter(fCenters);

I think this is valid c++. Why is not working in ROOT?

Thanks for your answers.

E-TStreamerInfo::Build: Diffv02, discarding: Double_t* fCenters, illegal [etabins]Is there another ‘etabins’ data member somewhere in the class hierarchy? Try renaming the one in Diffv02.

[quote]I think this is valid c++. Why is not working in ROOT?[/quote]Humm where does it actually crashes? Did you get a stack trace? Can you run in gdb to try to get a stack trace? Did you try running with valgrind to get more information about the cause of the crash?

Philippe.