Rootrm: size of file unchanged

Hello,

I have a file with 2 trees. Tree1 is about 90% of the size of the file and Tree2 the 10%.

I use rootrm to delete Tree1 and keep Tree2. It seems to work as when I open the file again Tree1 is gone.

However, the size of the file remains unchanged!!! an example is given below.

Is there a way to effectively remove the tree and obtain a new file with reduced size?

Thanks
Salvador

============= rootrm example with file keeping same size =========================
martis@lxplus763]~/mywork/RMTEST% ls -lh MyTestFile.root            
-rw-r--r--. 1 martis zp 665M May 18 19:36 MyTestFile.root
[martis@lxplus763]~/mywork/RMTEST% root MyTestFile.root             
   ------------------------------------------------------------------
  | Welcome to ROOT 6.28/00                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Feb 03 2023, 14:50:41                 |
  | From tags/v6-28-00@v6-28-00                                      |
  | With g++ (GCC) 11.3.0                                            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] 
Attaching file MyTestFile.root as _file0...
(TFile *) 0x314ebf0
root [1] .ls 
TFile**		MyTestFile.root	
 TFile*		MyTestFile.root	
  KEY: TTree	commonTree;1	Small Tree for Zmumu fits
  KEY: TTree	FourMu;1	Four Muon monitoring
******************************************************************************
*Tree    :commonTree: Small Tree for Zmumu fits                              *
*Entries :  1667187 : Total =      1758136353 bytes  File  Size =  695775711 *
*        :          : Tree compression factor =   2.53                       *
******************************************************************************
*Tree    :FourMu    : Four Muon monitoring                                   *
*Entries :     2089 : Total =         1481378 bytes  File  Size =     657970 *
*        :          : Tree compression factor =   2.19                       *
******************************************************************************
[martis@lxplus763]~/mywork/RMTEST% rootrm MyTestFile.root:commonTree
[martis@lxplus763]~/mywork/RMTEST% ls -lh MyTestFile.root           
-rw-r--r--. 1 martis zp 665M May 18 19:39 MyTestFile.root         ==> same size as before !!!

[martis@lxplus763]~/mywork/RMTEST% root -b MyTestFile.root 
   ------------------------------------------------------------------
  | Welcome to ROOT 6.28/00                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Feb 03 2023, 14:50:41                 |
  | From tags/v6-28-00@v6-28-00                                      |
  | With g++ (GCC) 11.3.0                                            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] 
Attaching file MyTestFile.root as _file0...
(TFile *) 0x34b8630
root [1] .ls
TFile**		MyTestFile.root	
 TFile*		MyTestFile.root	
  KEY: TTree	FourMu;1	Four Muon monitoring    ==> commonTree is gone (as expected)

Copy the tree (that you want to have) to another NEW file.

BTW. @pcanal If I remember well … when “freeing” space in a ROOT file, in the case of a TTree, one additionally needed to manually “release” the space used by “data baskets” … I think I found the old thread with some hints → File size with a CloneTree

Thanks for the tip!

I have a question though: when you mention “Copy the tree (that you want to have) to another NEW file.” which tool should I use?

The point is I tried “rootcp” (see attachment below) and the new file has almost the same size as the original one. Even if the new file contains only the small tree.

Thanks again
Salvador

===== output from rootcp ====

[martis@lxplus7102]~/mywork/RMTEST% root MyTestFile.root 
   ------------------------------------------------------------------
  | Welcome to ROOT 6.28/00                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Feb 03 2023, 14:50:41                 |
  | From tags/v6-28-00@v6-28-00                                      |
  | With g++ (GCC) 11.3.0                                            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------
root [1] .ls
TFile**		MyTestFile.root	
 TFile*		MyTestFile.root	
  KEY: TTree	commonTree;1	Small Tree for Zmumu fits   << contents of the original file
  KEY: TTree	FourMu;1	Four Muon monitoring

[martis@lxplus7102]~/mywork/RMTEST% ls -lh MyTestFile.root 
-rw-r--r--. 1 martis zp 665M May 19 09:15 MyTestFile.root
[martis@lxplus7102]~/mywork/RMTEST% rootcp MyTestFile.root:FourMu newFile.root  << copy the small tree
[martis@lxplus7102]~/mywork/RMTEST% ls -lh MyTestFile.root newFile.root   
-rw-r--r--. 1 martis zp 665M May 19 09:15 MyTestFile.root
-rw-r--r--. 1 martis zp 648K May 19 09:16 newFile.root                << the new file has almost the same size
[martis@lxplus7102]~/mywork/RMTEST% root -b newFile.root 
root [1] .ls
TFile**		newFile.root	
 TFile*		newFile.root	
  KEY: TTree	FourMu;1	Four Muon monitoring    << commonTree (the big one) is gone

Well, if three orders of magnitude difference is “almost the same size” for you, why do you care at all? :mrgreen:

You are indeed right!!! :sweat_smile:

Thanks!!!
Beer++;
Salvador

BTW,

hadd newFile.root MyTestFile.root

works just as well as

rootcp MyTestFile.root:FourMu newFile.root

when you need to free the space.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.