Hello,
I’m trying to understand how to use TProofOutputFile to automatically handle the merging of worker output. I have got it working, but my current code is leaving my gDirectory set to 0 and this is preventing me doing various things in the Terminate step, where I might want to make some histograms or something (the constructors all fail…I think it’s because the gDirectory is 0). Could an expert quickly check this over and tell me if this is the correct way to do things…
SlaveBegin:
fProofFile = new TProofOutputFile("dummyFile.root","M"); //'M' means merge the produced files
fProofFile->SetOutputFileName("output.merge.root");
if( !(fFile=fProofFile->OpenFile("RECREATE"))) {
Warning("SlaveBegin","problem opening file: %s/%s",fProofFile->GetDir(),fProofFile->GetFileName());
}
//prepare output TTree
eeTree = new TTree("eeTree","eeTree");
eeTree->Branch("mybranch",&mybranch);
eeTree->SetDirectory(fFile);
eeTree->AutoSave();
eeTree is then filled as part of the Process.
SlaveTerminate:
if(fFile) {
if(eeTree->GetEntries()>0) { //only write the tree if it had entries
fFile->cd();eeTree->Write();fProofFile->Print();fOutput->Add(fProofFile);
}
fFile->Close();
}
Terminate:
if(gDirectory) gDirectory->Print();
else Error("Terminate","No gDirectory?"); //THIS GETS PRINTED!!!??
TTree* myTree = new TTree("myTree","myTree"); //This Crashes
I think I’ve become muddled about what happens to the current directory during all this merging.
Thanks!