Odd behaviour in TFile with TTree

Honestly this is probably arising from incomplete understanding on my part but I am writing here in hopes that someone can give me a hint.

I have multiple runs of data each stored in a separate tree with each tree in a different file. Additionally, due to a quirk of the raw data to ntuples system all the trees are named “h1000” (it makes hbooks with the name "h1000"for a list of ntuples it makes and h2root names the trees the same).

It was my intention to move all these trees to a single file, giving them appropriate names while simultaneously filtering bad events from the trees. To do this I have code that goes like this:

vector<RunData> runs; //read in from a csv
TFile* mainFile = new TFile(combinedRunsFN.c_str(),"RECREATE")
for(unsigned i=0; i<runs.size(); ++i)
	//logic using string streams to make the file name and name of the new tree goes here
	//create the new tree
	mainFile->cd();//take no chances
	TTree* newTree = new TTree(name.c_str(), name.c_str());
	//open the file with the old tree
	TFile* file = new TFile(indivFileName.c_str(),"READ");
	TTree* oldTree = (TTree*)file->Get("h1000");
	cout<<"Starting to process run"<<runs[i].runNumber<<"...";
	//loop through all the branches of the old tree adding them to the new tree
	//in the process set up address so that we can read from one tree into a variable and 
	TObjArray* branchList = (TObjArray*)(oTree->GetListOfBranches()->Clone());
	Long64_t numEnts = (oldTree->GetEntries());
	int numBran = (branchList->GetLast()+1);
	float* vals = new float[numBran];
	for(int j=0; j<numBran; ++j)
		const char* branName = branchList->At(j)->GetName();
		//construct the variable name
		ostringstream varNamer;
		oTree->SetBranchAddress(branName, &(vals[j]));
	Long64_t count = 0;
	for(Long64_t k=0; k<numEnts; ++k)
		//logic to figure out if an event is valid goes here
	cout<<"  processed "<<numEnts<<" nTuples"<<endl;
	delete oldTree;
	delete file;
	file = newTree->GetCurrentFile();
	delete newTree;
	delete[] vals;
//finally close the file with the new trees

The problems come later, when I open the file again. When I do that, I get something like this:

root [0] TFile* file = TFile::Open("snElastic.root")
root [1] file->ls()
TFile**		snElastic.root	
 TFile*		snElastic.root
root [2] .ls
TFile**		snElastic.root	
 TFile*		snElastic.root

The file I created is there on disk, and it is ~430MB so clearly contains something. But asking for a list of its contents gives nothing. What am I doing wrong?

I figured it out. The key names for the trees were being prefixed with a ‘/’ (since I was trying to share the logic for making the file names to import and the logic for making the new tree names). This was causing the trees to not show up in the file.