Error in executing TFile::Map()z

Hello Everyone,

I have problem when i execute f.Map(). It gives me this error
SysError in TFile::Seek: cannot seek to position 100 in file demo.root, retpos=-1 (Bad file descriptor)
Warning in TFile::Map: demo.root: failed to read the key data from disk at 100.
0/000000 At:100 N=1 END

the code is:

	char name[10], title[20];
	TObjArray Hlist(0);
	TH1F* h;

	//make and fill 15 histogram and add them to the object array
	for(Int_t i =0; i<15;++i)
		sprintf(title,"histo nr:%d",i);
		h = new TH1F(name,title,100,-4,4);

	//open a file and write the array to the file
	TFile f("demo.root","recreate");

It seems to work for me: I ran your code in a first ROOT session. Then I opened the file with root -l demo.root and called _file0->Map(). Perhaps the problem is with the code that calls Map(), could you post this part, too? Which ROOT version do you use?

after i excute the code .x …, On root prompt i typed f->Map(), and then i got that error

I use root 6.18

I see, you’d need to call f.Map() before the file is closed, i.e. before the call to f.Close().

Note that for the file to be well formed you are missing a calss to f.Write();

	TFile f("demo.root","recreate");

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.