Hi, I'm trying to use root for a simple application but it seems the moment I solve one problem a new one occures... That's not by any means a problem of ROOT, it could be just me. Now after I solved several problems by magic... (for some reason VC++ didn't like 'cout' inside my class) I've run into a new problem. I create a tree and a branch, I fill it and tree->Print() gives a reasonable output, but when I do f->Write(); (f is my TFile) I get: <CustomReAlloc2>: passed oldsize 1032, should be 17694850 Fatal in <CustomReAlloc2>: unreasonable size (17694850) aborting Warning in <TWinNTSystem::StackTrace>: this method must be overridden! Press any key to continue I paste the function below, in case someone has a usefull sugestion. Thanks Dimitris Int_t Global::ReadAscii() { int pixel=0,totpixels_f=0,p=0,cutim=0,rtim=0; float v[300]={0},v0=0,cur[4000]={0}; int nlines = 0; int nic[3000]={0},totic=0; float avi=0.,invavi=0,ic[4000]={0},tic[4000]={0}; int split = 0; int bsize =256000; // ifstream fout,fcur; ifstream *fout = new ifstream; ifstream *fcur = new ifstream; tim=0; // Create a ROOT Tree A *a = new A; TFile *f = new TFile("A.root","recreate"); tree = new TTree("T","An example of ROOT tree"); tree->Branch("aa","A",&a,bsize,split); Float_t rtim_period=Float_t(0.7); int mintim=400000; int maxtim=0; Float_t ti=Float_t(10.003); // FILE *fout=fopen("test.out","r"); // FILE *fcur=fopen("test2.cur","r"); fout->open("test.out", ios::in); fcur->open("test2.cur", ios::in); int i=0; int ncols=0; while (1) { // ncols=fscanf(fcur,"%i %f",&nic[i],&ic[i]); *fcur >> nic[i] >> ic[i]; if (!fcur->good()) break; ic[i]*=1000; avi+=ic[i]; if (ic[i]==0) ic[i]=149.5; invavi+=1/ic[i++]; } totic=i; avi=avi/float(totic); invavi=invavi/float(totic); if (avi==0.) { *logf << "WARNING: No Current Info Available\n" <<endl; } else { *logf << "Average Current= " << avi << '\n' <<endl; tic[0]=ti; ic[0]=avi; for(i=1;i<=totic;i++){ if(ic[i]==0.) ic[i]=avi; tic[i]=(tic[i-1]+(1/ic[i]+1/ic[i-1])/2*avi*ti); } } int pi=1; int tim2=0; pixel=0; a->rv[0]=0; v[0]=0; while (tim<100) { // ncols=fscanf(fout,"%i %f %i",&pixel,&v[pixel+1],&totpixels_f); *fout >> pixel >> v[pixel+1] >> totpixels_f ; if (!fout->good()) break; // if (ncols<0) break; a->rv[pixel+1]=v[pixel+1]; cutim=int(tim/ti+1); if (cutim>totic) { cur[pixel+1]=ic[totic]; } else { cur[pixel+1]=ic[cutim]; } rtim=int((float(tim)-float(cutim)*ti)/ti*(tic[cutim+1]-tic[cutim])+tic[cutim]); a->time=tim; // a->rtime=rtim; if (pi==256) { if (pixel!=255) { *logf << "Mismach in reading file. STOP\n" <<endl; break; } if (tim<mintim || tim>maxtim) { tree->Fill(); tim2++; if (int(tim2/1000.)==tim2/1000.) *logf << ".. " << tim2 <<'\n' <<endl; } tim++; pi=0; if (int(tim/1000.)==tim/1000.) *logf << ".. " << tim2 << '\n' <<endl; } pi++; nlines++; } *logf << " found " << nlines << " points\n" <<endl; tree->Print(); f->Write(); *logf << "here1\n" << endl; *logf << "here2\n" << endl; fout->close(); *logf << "here3\n" << endl; fcur->close(); /// *logf << "here4\n" << endl; f->Close(); *logf << "here5\n" << endl; delete tree; delete a; delete f; // delete fout; // delete fcur; *logf << "END\n" << endl; // logf->close(); return 0; }
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:37 MET