Filling TBranches/TTree in a loop issue

The code is supposed to read through an already created tree, copy its branch names and record a 0 for entries less than or equal to 0 and a 1 for all other entries. The code copies the branches fine, but when going to fill them with the information it fills each branch will all of the information of all the branches before it. So if a tree had 10 entries and ten branches the tenth branch would have 100 entries, the 9th 90, etc. Below is the full code, the filling is done in the last loop. I don’t know what is going wrong.

#include <vector>
  //Creation and naming scheme
  TString fileName = "binaryTree2.root";//name of file wishing to create.
  TString treeName = "Binary Tree 2";//name of tree wishing to create.
  TFile *file = new TFile(fileName, "RECREATE");
  TTree *bTree = new TTree(treeName,"Binary Tree");
  //Connection scheme
  TString fileNameCopy = "hodoscopehittree7.root";//name of file you will be accessing.
  TString treeNameCopy = "tree";//Name of tree within file you are accessing.
  TFile *filePtr = new TFile(fileNameCopy);//points to file with previously created tree
	TTree *treePtr = (TTree *) filePtr->Get(treeNameCopy);//Ptr to tree within accessed file.
	TObjArray *obj = treePtr->GetListOfBranches();//Ptr to branches.
	int branchNum = obj->GetEntries();//Number of branches in accessed tree.
	//Vector to hold all of the information from the tree.	
	vector<vector<int>> dataHolder;
	int* inHist;//Ptr to become the entry.
	int inVal;
	vector <int> entryVec;//Vector of ints that the branches will rely on.
	TString branchName;
  const int entryNum = treePtr->GetEntries();//Number of entries in each branch.
	//Ths loop creates a branch in the binary tree with the same name as the 
	//branch in the tree being accessed and fills the dataHolder vector with 
	for (int i = 0; i < branchNum; i++)
	  TString temp;
	  temp = "entryVec[";
	  temp += (i);
	  temp += "]/I";
	  branchName = obj -> At(i)-> GetName();
	  bTree -> Branch(branchName, &entryVec[i],temp);
	  vector <int> tempVec;

  //This loop reads the entries of each branch within the accessed tree. If the 
  //value is less than or equal to zero, 0 is added to the dataHolder and  if 
  //not 1 is added to the dataHolder.
	for (int i = 0; i < branchNum; i++)
		branchName = obj-> At(i)-> GetName(); //Gets name of branch at index i
		treePtr -> SetBranchAddress(branchName, &inHist);
		for (int j = 0; j < entryNum; j++)
		  treePtr -> GetEntry(j);
			inVal = inHist;
			if (inVal <= 0)

	//This loop fills the tree. Each inner loop reads the jth element of the 
	//datHolder and inputs that information int the entryVec. The outer loop fills 
	//the tree and then loops over all of the entries. 
	for (int i = 0; i < entryNum; i++)
    for (int j = 0; j < branchNum; j++)
      entryVec[j] = dataHolder[j][i];
    bTree -> Fill();
  file -> Write();
  cout << "Your program has finished; " << treeName << " has been created."; 
  cout << endl;
  filePtr-> Close();
  new TBrowser();

Thank you for your time.

Solution was solved by someone else that I work with. The last part of the branch creation temp should be branchName/I so when changed to:

temp = branchName;
temp += “/I”;

The code works perfectly.