PROBLEM: TObjArray and *** Break *** segmentation violation

From: Roberta Ferretti <Roberta.Ferretti_at_cern.ch>
Date: Mon, 13 Oct 2008 11:24:14 +0200

Hello!

I have a problem: I am trying to create a Root file and 600 histograms, fill each histogram and write them to the file. Here is the code I am using:

int main(int argc, char **argv) {
  if (argc!=3) {
    printf("Usage: analyzerefScan.exe refDataDir runNr\n");     return -1;
  }

  TString refDataDir = Form("%s",argv[1]);   UInt_t runNr = atoi(argv[2]);   

  char name[50];   

  TObjArray *Hlist = new TObjArray(600);   TH1I *h1[20][6][10];   

  UInt_t step = 0;

  AliITSOnlineSPDscan *scanObj[20];
  for (UInt_t eq=0; eq<20; eq++) {
    TString fileName = Form("%s/%d_SPD_ref_scan_eq_%d",refDataDir.Data(),runNr,eq);     scanObj[eq] = new AliITSOnlineSPDscan(fileName.Data());

    for (UInt_t hs=0; hs<6; hs++) {

      for (UInt_t chip=0; chip<10; chip++) {	
        sprintf(name, "eq %d hs %d chip %d", eq,hs,chip);    
	h1[eq][hs][chip] = new TH1I(name,name,101,0,101);
	Hlist->Add(h1[eq][hs][chip]);
	for (UInt_t col=0; col<32; col++) {
	  for (UInt_t row=0; row<26; row++) {
	    UInt_t nrHits = scanObj[eq]->GetHits(step,hs,chip,col,row);
	    h1[eq][hs][chip]->Fill(nrHits);
	  }
	}
	
      }

    }     

    delete scanObj[eq];
  }   

  TFile hfile("histos.root", "RECREATE");   

  Hlist->Write();
  hfile.Close();

  return 0;
}

When I try to run it, the following message appeared:

Where is the problem? What I have to do?

Thank you very much.

RF Received on Mon Oct 13 2008 - 11:24:25 CEST

This archive was generated by hypermail 2.2.0 : Mon Oct 13 2008 - 17:50:02 CEST