How to copy the some events from one tree to another tree;

I have two old trees, both trees have same format. Because the varaibles in the tree are too complicate, also it will change at any moment. So I would not like to put the variables name in my code.
Now what I want to do is random sample both old tree, get a event from both old tree( I mean that some time I get a event from tree A, some time from tree B), and copy this events to an new tree. Are there easy way to do it?

Next is my code to do this;

getVariableSpecs(fCurrentTree[index]); //get the branch name and title from the old tree,
//and put them in the vector bnamesand
// btitles;
fOutputTree= new TTree(“h3333”," Atlas pseudo data"); //defind the new tree;
for (int i=0; i<bnames.size(); i++) {
fOutputTree->Branch(bnames[i].c_str(), NULL ,btitles[i].c_str());

for(int ievent=0; i<…)

for(int i=0; i<bnames.size(); i++) {
TBranch *b = fCurrentTree[index]->GetBranch(bnames[i].c_str()); //get the branch;
When I write out the new tree, I found the varaibles value are 0, also
I checked for the cod , it see that b->GetAddress() will return zero.

any one know what Is wrong?
thanks a lot

To copy the address from one tree to the other, you can simply call:orig->CopyAddresses(copy);where orig is the tree with the addresses that you want to copy.