Hi all,
when running the following macro, after 6 successfully created output files it shows errors and stops.
{
ifstream fin(“testbeam_RecPoints_1GeV.list”);
char filename[200];
char filename2[200];
char treename[200];
char rootfilename[200];
while (fin>>filename2){
//TChain chain("TreeR");
TChain *chain = new TChain("TreeR");
sprintf(filename,"/alidata10/alice_u/seibel/cosmicdata/clusterproduction/1GeV/%s",filename2);
TFile *recpoints = TFile::Open(filename);
int nevents=0;
nevents = recpoints->GetNkeys();
cout<<nevents<<endl;
cout <<filename<<endl;
for(int j=0; j<nevents; j++)
{
sprintf(treename,"%s/Event%d/TreeR",filename,j);
cout << filename <<" "<<treename<<endl;
chain.Add(treename);
}
recpoints->Close();
TObjArray *fclarray;
cout<<"test1"<<endl;
chain.SetBranchAddress("TRDcluster",&fclarray);
cout<<"test2"<<endl;
Int_t nEntries = (Int_t) chain.GetEntries();
cout<<"test3"<<endl;
cout<<"nEntries= "<<nEntries<<endl;
signal = new TNtuple("sig","test","ientry:clus:t:q:x:y:z:ctr:det:clusize");
Float_t signtp[10];
for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
chain.GetEvent(iEntry);
cout<<"chain.GetEvent(iEntry)= "<<chain.GetEvent(iEntry)<<endl;
cout <<"fclarray->GetEntriesFast()= "<<fclarray->GetEntriesFast()<<endl;
for (Int_t icl =0; icl<fclarray->GetEntriesFast();icl++){
cout <<"icl= "<<icl<<endl;
AliTRDcluster *cl = (AliTRDcluster*)fclarray->UncheckedAt(icl);
cout<<"cl= "<<cl<<endl;
if (!cl) continue;
Int_t localTimeBin=cl->GetLocalTimeBin();
Float_t charge = cl->GetQ();
Float_t lx = cl->GetX();
Float_t ly = cl->GetY();
Float_t lz = cl->GetZ();
Float_t pcenter = cl->GetCenter();
Int_t Npads = cl->GetNPads();
//if(Npads==6) continue;
printf("charge= %f, lx= %f, ly= %f, lz= %f, pcenter= %f, Npads= %f \n",charge,lx,ly,lz,pcenter,Npads);
signtp[0]=Float_t(iEntry);
signtp[1]=Float_t(icl);
signtp[2]=Float_t(localTimeBin);
signtp[3]=Float_t(charge);
signtp[4]=Float_t(lx);
signtp[5]=Float_t(ly);
signtp[6]=Float_t(lz);
signtp[7]=Float_t(pcenter);
signtp[8]=Float_t(iEntry%540);
signtp[9]=Float_t(Npads);
signal->Fill(signtp);
}
}
sprintf(rootfilename,"clusters_1GeV_%s",filename2);
TFile fclus(rootfilename,"RECREATE");
signal->Write();
fclus.Close();
fclarray->Delete();
delete signal;
//chain->Delete();
delete chain;
}
}
I guess its some kind of memory problem? Where is the bug or is there a possibility to free the memory after each file (while loop run)?
Best regards.