Dear PROOF experts,
I am using PROOF, root version 5.28.
I experience a singular problem when trying to save histograms using TProofOutputFile.
I have followed the examples in the tutorials and at page:
root.cern.ch/drupal/content/hand … root-files
In the SlaveBegin() method I add the following (ProofFile is a TProofOutputFile* and fout a TFile*, both defined in the private part of the selector):
ProofFile = new TProofOutputFile( "/users2/bertolucci/newskim.root", ProofOutputFile::kMerge );
ProofFile->SetOutputFileName( "/users2/bertolucci/newskim.root" );
TDirectory *savedir = gDirectory;
fout = ProofFile->OpenFile("RECREATE");
savedir->cd();
h_el_n = new TH1F("h_el_n", "Distrib", 15, 0, 15);
h_el_n->SetDirectory( fout );
Inside the Process() method I fill the histogram, and in the SlaveTerminate():
TDirectory *savedir = gDirectory;
savedir->cd();
h_el_n->Write();
ProofFile->Print();
fOutput->Add( ProofFile );
h_el_n->SetDirectory(0);
gDirectory = savedir;
In the Terminate() method:
ProofFile = dynamic_cast<TProofOutputFile*>( fOutput->FindObject( "/users2/bertolucci/newskim.root" ) );
TString outputFile( ProofFile->GetOutputFileName() );
fout = TFile::Open( outputFile );
fout->Write();
Now, reading at the worker logs, I find this:
So I suppose that when calling the Write() method for the h_el_n object it is not able to find the current directory; a file is written, but it is empty. What am I missing?
The second problem arises from the Terminate() method: a get a crash because I cannot retrieve the TProofOutputFile (the FindObject method always return 0, so the program crashes when trying to open the TFile: fout = TFile::Open( outputFile ); ). What is the problem now? I do not understand…
Thank you very much in advance.
Cheers,
Federico