Merging TTree's

Hello,
I am using root 5.34/01 on Windows platform. I am trying to merge two (or more) TTrees into a single one - I can do this using the TTree::Merge() - and that works just fine, However, some of the leaves in the 2nd (and subsequent) TTree’s need to be modified - this is where I am having trouble… This is what I am trying and it is not working:

TFile *f = new TFile("firstFile.root");
TTree *nt = (TTree*)f->Get("nt");
nt->SetBranchStatus("*",1);
TFile *fOut = new TFile("MergedFile.root","RECREATE");
TTree *ntMerge = nt->CloneTree(0);
ntMerge->CopyEntries(pt);		// so far so good
// now
float elapsedTime,elapsedTimeOffset;
nt->GetBranchAddress("elapsedTime",&elapsedTime);
nt->GetEntry(nt->GetEntries()-1);
elapsedTimeOffset = elapsedTime;
fOut->Write();
delete nt;
delete f; 

//  now mere with a second file - this time, modify elapsedTime

f = new TFile("SecondFile.root");
nt = (TTree *)f->Get("nt");
nt->CopyAddresses(ntMerge);
nt->SetBranchAddress("elapsedTime",&elapsedTime);
for(Long64_t i=0;i<nt->GetEntries();i++)
{
    nt->GetEntry(i);
    elapsedTime += elapsedTimeOffset;
    ntMerge->Fill();
}

All the branches OTHER than elapsedTime look fine; the elapsedTime branch looks fine for the records in the first TTree, but are unchanging garbage for the second TTree’s records.

I am clearly breaking some rule… I tried using GetBranch(“elapsedTime”)->GetAddress() at various points instead of the SetBranchAddress(“elapsedTime”,&elapsedTime), but the former always returned zero…

Thanks you
Ed

Figured it out: For the merge operation, I needed to do

after the