Shifting TTree entries

Hello,
I’m writing a function that has to modify a TTree by:
1 - removing some entries;
2 - shifting the entries in some branches with respect to the other branches by a given offset (both branches to be shifted and offset are decided at runtime).
As for point 1 I thought of proceeding as shown in tutorial copytree3.C: create a new TTree with CloneTree(0) and fill it with the good events.
How could I implement point 2? I tried to do it with the Fill method but it turns out not to be a good idea.
The function should also overwrite the original TTree with the modified one. Can I just clone the second TTree back on the first?
Thanks a lot

[quote]The function should also overwrite the original TTree with the modified one. Can I just clone the second TTree back on the first?[/quote]No. Instead create the new TTree into a new file and when all is said and done, rename the new file to the old file’s name.

[quote]How could I implement point 2? I tried to do it with the Fill method but it turns out not to be a good idea.[/quote]You can use branch->Fill() and when you are done filling all the branches, making sure they all have the same amoung of entries, call tree->SetEntries()

Cheers,
Philippe.

PS. Note that using the branch->Fill technique will lead to resulting file where the file layout is sub-optimal. To fix that, you will need to re-clone (not using the fast option) entirely the new file.