Dear rooters, I get a memory crash with the following macro. The error is related to the TObjArray *fHLmd pointer, which, for some reason, I'm not able to claer. After some thousands of events, I run out of memory. I tried to look at the tutorials, but I couldn't solve the problem. Any suggestion? thanks, Piergiorgio { gROOT->Reset(); printf("Start lmd_tdc.C Macro\n"); const Int_t kUPDATE = 50; const Int_t kCHECK = 100; const Int_t ndch = 16; Float_t mkrsiz; TFile *p; TFile *f; TTree *ftree; TObjArray *fHLmd = new TObjArray(); Int_t fNHLmd=0; TBranch *bhlmd; TBranch *bnlmd; TFndHLmd *hlmd; TH2F *lmdmaptdc = new TH2F("lmdmaptdc","tdc lmd map",20,10.5,30.5,24,0.5,24.5); TH2F *lmdmaptdc0 = new TH2F("lmdmaptdc0","tdc != 0 lmd map",20,10.5,30.5,24,0.5,24.5); TH2F *lmdmaptdc00 = new TH2F("lmdmaptdc00","tdc L,R != 0 lmd map",20,10.5,30.5,24,0.5,24.5); TH2F *lmdmaptdcl = new TH2F("lmdmaptdcl","tdcl lmd map",20,10.5,30.5,24,0.5,24.5); TH2F *lmdmaptdcr = new TH2F("lmdmaptdcr","tdcr lmd map",20,10.5,30.5,24,0.5,24.5); TH1F *lmdtdcl[ndch]; TH1F *lmdtdcr[ndch]; TH1F *lmdtif[ndch]; TH2F *lmdtdc[ndch]; const char *hname1="lmdtdcl"; const char *hname2="lmdtdcr"; const char *hname3="lmdtdc"; const char *hname4="lmdtif"; Int_t sf; Int_t idx = 0; for(sf=0; sf<ndch; sf++){ char sfc[3]; idx = sf+11; if(sf>=ndch/2) idx = sf+13; sprintf(sfc,"%d",idx); // HISTOGRAMS CREATION char *hhname = ""; strcpy(hhname,hname1); hhname = strcat(hhname,sfc); lmdtdcl[sf] = new TH1F(hhname,"tdcl",205,0,4100); strcpy(hhname,hname2); hhname=strcat(hhname,sfc); lmdtdcr[sf] = new TH1F(hhname,"tdcr",205,0,4100); strcpy(hhname,hname3); hhname=strcat(hhname,sfc); lmdtdc[sf] = new TH2F(hhname,"tdcl vs tdcr",205,0,4100,205,0,4100); strcpy(hhname,hname4); hhname=strcat(hhname,sfc); lmdtif[sf] = new TH1F(hhname,"time",205,0,4100); lmdtdcl[sf]->SetFillColor(6); lmdtdcr[sf]->SetFillColor(7); lmdtdc[sf]->SetFillColor(8); lmdtif[sf]->SetFillColor(9); } char *fpth; printf("Path to the main data directory ?\n"); scanf("%s",&fpth); Int_t nsum = 1; while(nsum != 0) { // OPEN INPUT FILE char *nrun; char *FVMS; printf("Run type ?\n"); scanf("%s",&FVMS); printf("Run number (5 digits)? \n"); scanf("%s",&nrun); const char *fdir = "/HDT/"; const char *sufx = ".hdt"; Char_t *fRAW = new Char_t[strlen(&fpth)+strlen(fdir)+strlen(&FVMS)+strlen(sufx)+strlen(&nrun)]; strcpy(fRAW,&fpth); fRAW = strcat(fRAW,fdir); fRAW = strcat(fRAW,&FVMS); fRAW = strcat(fRAW,&nrun); fRAW = strcat(fRAW,sufx); printf("%s file\n",fRAW); f = new TFile(fRAW); ftree = (TTree*)f->Get("F"); bnlmd = ftree->GetBranch("fNHLmd"); bhlmd = ftree->GetBranch("fHLmd"); Int_t nbr = ftree->GetNbranches(); printf("HDT Tree with %d branches ",nbr); bnlmd->SetAddress(&fNHLmd); bhlmd->SetAddress(&fHLmd); Int_t nevent = (Int_t)bnlmd->GetEntries(); printf("and %d events\n",nevent); Int_t goon; Int_t firstevt=0; Int_t lastevt=0; printf("Type initial event number\n"); scanf("%d",&firstevt); if(firstevt<=0) { firstevt = 0; printf("WARNING: firstevt FORCED to 0\n"); } printf("Type final event number\n"); scanf("%d",&lastevt); if(lastevt>=nevent) { lastevt = nevent-1; printf("WARNING: lastevt FORCED to (nevent-1)\n"); } if(lastevt<firstevt) printf("WARNING: lastevt SMALLER than firstevt\n"); if(firstevt>=0 || firstevt<lastevt && lastevt<nevent) { for (Int_t i=firstevt;i<lastevt;i++) { bhlmd->GetEvent(i); bnlmd->GetEvent(i); // if(!(i%kCHECK)) printf("Event %d, %d lmd hits\n",i,fNHLmd); // FILL HISTOGRAMS for (Int_t j=0; j<fNHLmd; j++) { hlmd = (TFndHLmd*) fHLmd->At(j); Int_t dch = hlmd->GetCham(); Int_t wire = hlmd->GetWire(); Int_t sf=0; if(dch <= 18 && dch >= 11) sf = dch - 11; if(dch <= 28 && dch >=21) sf = dch - 13; lmdmaptdc->Fill((Float_t) dch,(Float_t) wire); Int_t tl = hlmd->GetTdcL(); Int_t tr = hlmd->GetTdcR(); if(tl+tr) lmdmaptdc0->Fill((Float_t) dch,(Float_t) wire); if(tl*tr) lmdmaptdc00->Fill((Float_t) dch,(Float_t) wire); if(tl!=0) lmdmaptdcl->Fill((Float_t) dch,(Float_t) wire); if(tr != 0) lmdmaptdcr->Fill((Float_t) dch,(Float_t) wire); lmdtdcl[sf]->Fill(tl); lmdtdcr[sf]->Fill(tr); lmdtdc[sf]->Fill(tr,tl); lmdtif[sf]->Fill(0.5*(tl+tr)); // delete hlmd; } fHLmd->Clear(); // printf("delete objarray\n"); fHLmd->Delete(); // delete fHLmd; } } printf("new run? "1" yes, "0" no\n"); scanf("%d",&nsum); } // OPEN FILE const char *SUFF = "_lmd_tdc.hist"; Char_t *fhist = new Char_t[strlen(&FVMS)+strlen(&nrun)+strlen(SUFF)]; strcpy(fhist,&FVMS); fhist = strcat(fhist,&nrun); fhist = strcat(fhist,SUFF); printf("write file %s\n",fhist); TFile *fist = new TFile(fhist,"RECREATE","Finuda ROOT histograms"); lmdmaptdc->Write(); lmdmaptdcl->Write(); lmdmaptdcr->Write(); lmdmaptdc0->Write(); lmdmaptdc00->Write(); for(Int_t sf = 0; sf < ndch; sf++){ lmdtdcl[sf]->Write(); lmdtdcr[sf]->Write(); lmdtif[sf]->Write(); lmdtdc[sf]->Write(); } fist->Close(); }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:35 MET