Delete TObject in TFile and use the freed space

Hi,

it is in general good practice to re-create files when processing data, for example after calibration.
I understand that the issue in your case is to carry over the datasets you do not manipulate. For these, TTree “fast cloning” should be the solution:

   TFile myfile ("small.root","recreate");
   oldtree.CloneTree(-1, "fast");

This procedure does not decompress/deserialise/serialise/compress anything, just copies bytes.
If the procedure of manipulating the data could also use a speedup, you can resort to the recommended data processing tool, TDataFrame which allows you to express your operations and parallelise transparently the processing using all of your cores.

Cheers,
Danilo