Hi,
yes, you are right!
Inside the SlaveBegin() method ( ProofFile is a TProofOutputFile* and fout a TFile* ):
ProofFile = new TProofOutputFile( SaveName.c_str(), TProofOutputFile::kMerge);
ProofFile->SetOutputFileName( name.c_str() );
TDirectory *savedir = gDirectory;
// Workaround for the TProofOutputFile bug
string tname;
tname.clear();
tname = SaveDir;
tname.append( "/<ord>/" );
tname.append( SaveName );
TString fn( tname.c_str() );
TProofServ::ResolveKeywords(fn);
TString dirord = gSystem->DirName(fn);
if (gSystem->AccessPathName(dirord)) gSystem->mkdir(dirord, kTRUE);
fout = TFile::Open(fn, "RECREATE");
if (fout && fout->IsZombie()) SafeDelete(fout);
if (fout) ProofFile->AdoptFile(fout);
cout << "\n\t---> file pointer: " << fout << endl << endl;
fout->mkdir( "myDirectory" );
fout->ls();
savedir->cd();
h_test = new TH1F("h_test", "Test histogram", 100, 0, 1);
h_beta = new TH1F("h_beta", "Distribution of #beta for first electron", 100, 0.95, 1);
h_beta->SetDirectory(0);
dir = (TDirectory*)fout->Get("myDirectory");
h_beta->SetDirectory( dir );
the workaround is discussed in this post, if you remember:
https://root-forum.cern.ch/t/cannot-write-object-to-file-with-tproofoutputfile/12160/1
because of a TProofOutputFile “bug” when accessing files via gpfs.
as you can see, I create 2 histograms and a TDirectory inside the output file.
The file, the directory and the histograms are correctly created, merged and saved, but the h_beta histogram is in the same root directory h_test is, and not inside “myDirectory” as I expected.
The result is invariant if you create the TH1Fs before or after the TProofOutputFile is created.
Thank you very much.
Cheers,
federico