File has no keys -- saving histo/file in a wrong way?

Hi PROOFers,

I face some problems when running my analysis on PROOF. I have stripped down my code so right now it only produces one single histogram (or, tries to). I use ROOT v. 5.28.00. My code goes like:

SlaveBegin()

 ProofFile = new TProofOutputFile("/tmp/mkoeff/testfile.root", "M");
 ProofFile->SetOutputFileName( "/tmp/mkoeff/testfile.root" );
 TDirectory *savedir = gDirectory;
 fout = ProofFile->OpenFile("RECREATE");
 savedir->cd();
 h_test = new TH1F("h_test","test histo",10,0,10);
 h_test->SetDirectory(fout);

Process()

Fill histogram

SlaveTerminate()

 TDirectory *savedir = gDirectory;
 savedir->cd();
 h_test->Write();
 ProofFile->Print();
 fOutput->Add( ProofFile );
 h_test->SetDirectory(0);
 gDirectory = savedir;

In the end when PROOF tries to merge the output from the different workers I get the error message(s):

Output file: /tmp/mkoeff/testfile.root workers still sending)
Error in TFile::ReadBuffer: error reading all requested bytes from file //tmp/mkoeff/testfile.root, got 248 of 300
Warning in TFile::Init: file //tmp/mkoeff/testfile.root has no keys
Output file: /tmp/mkoeff/testfile.root workers still sending)
Error in TFile::ReadBuffer: error reading all requested bytes from file //tmp/mkoeff/testfile.root, got 248 of 300
Warning in TFile::Init: file //tmp/mkoeff/testfile.root has no keys
etc.

testfile.root has no keys – what am I doing wrong?

Thanks a bunch!

Hi,

It looks like you are writing the histogram in gDirectory.
Try making ‘fout’ member of the selector and then in SlaveTerminate

fout->cd();
h_test->Write();
ProofFile->Print();
fOutput->Add( ProofFile );
h_test->SetDirectory(0);

G. Ganis