Root-files can be the source of various problems. Usually they are caused by hidden changes in the internal state of ROOT. ROOT stores the active directory and uses this to create new objects and look for existing ones. The active directory is changed when a new file is opened. This can lead to unexpected behaviours and hard to trace bugs.
When you get an an empty ROOT-file, check the right order of the files. Don't do
TFile* outputFile = new TFile("myOutputFile.root", "RECREATE"); TFile* inputFile = TFile::Open("myInputFile.root"); // your code outputFile->Write();
but instead do:
TFile* inputFile = TFile::Open("myInputFile.root"); TFile* outputFile = new TFile("myOutputFile.root", "RECREATE"); // your code outputFile->Write();