Hi all,
Recently I encountered some problems writing multiple TTree’s to one TFile after parallel job submissions. In some Geant4 code I have two TTree’s (per parallel node), ROOTTree and ROOTTreeFoil, with corresponding TChain’s treeChain and treeChainFoil. At the end of the run, I need to collect up all the slave files generated from the parallelization and merge their TTree’s into a final output file. The following code snippet was working up until very recently:
[code]
TChain *treeChain = new TChain(“ROOTTree”);
TChain *treeChainFoil = new TChain(“ROOTTreeFoil”);
std::vector<G4String>::iterator it;
for(it = slaveFileNames.begin(); it != slaveFileNames.end(); it++)
{
treeChain->Add((*it).c_str());
treeChainFoil->Add((*it).c_str());
}
treeChain->Merge(FinalFileName.c_str());
treeChainFoil->Merge(FinalFileName.c_str());
[/code]
However, I can no longer get both TChain’s to write to the TFile. The treeChainFoil->Merge() command seems to overwrite the initial treeChain->Merge(), and treeChain will only show up in the TFile if the second Merge is commented out. So, is there a more robust way of merging the data together, then writing the two final TTree’s to a TFile?