# Converting root files from old CS compression to newer compression

**URL:** <https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337>\
**Category:** ROOT\
**Created:** [April 8, 2021, 10:13pm UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337 "2021-04-08T22:13:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![austinschneider](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/austinschneider/32/25508_2.png) [@austinschneider](https://root-forum.cern.ch/u/austinschneider)\
**Post date:** [April 8, 2021, 10:13pm UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337/1 "2021-04-08T22:13:15Z")

</div>

I have some old root files created with ROOT 4.04/02 that use the “CS” compression (`fCompress==1`). My goal is to convert them to a newer compression so they can be read with uproot4 as input to some existing statistical analysis.

I’ve found I’m able to create a new file with more modern compression via the `rootmv` command.  
`rootmv -c 5 ./old_compression.root ./new_compression.root`

~~However, this also has the undesirable side effect of merging trees ex. `TreeA;14` , `TreeA;13` become `TreeA;1` in the new file.~~  
However, this change to the compression doesn’t seem to extend to all objects in the file.

I’m wondering if there is a better way to update the compression, ~~and if it is possible to avoid merging trees like this in the process~~ and if it is possible to do this recursively for all object in the file.

* * *

_ROOT Version:_ 6.22/02  
_Platform:_ Ubuntu 20.04.2 LTS  
_Compiler:_ g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

* * *

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [April 8, 2021, 10:55pm UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337/2 "2021-04-08T22:55:36Z")

</div>

Do you really have a non-standard use for cycles? In most use case the lower cycle number are just a backup copy of the TTree meta and ‘TTreeA;14’ point to all the entries pointed to by `TTreeA;13’ plus all the entries added after the ‘13th’ snapshot. Usually the lower cycles are only useful for recovery from a crash in the file writer. I.e. in the standard use, you lose nothing by no having access to the older cycles (but same some space).

All the automatic tools are assuming this usage and thus discard the older cycles, to keep the cycle you will need to code the copy explicitly.

---

<div class="post-metadata">

**Author:** ![austinschneider](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/austinschneider/32/25508_2.png) [@austinschneider](https://root-forum.cern.ch/u/austinschneider)\
**Post date:** [April 9, 2021, 12:12am UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337/3 "2021-04-09T00:12:51Z")

</div>

I haven’t found an explicitly non-standard use of cycles with root files in the codebase that produces these.

I’m a little concerned about it because the processing pipeline that produces them uses a lot of hbook files, and I have seen input of hbook files that references both the first and last cycles. This usage may not exist for root files though, and so this could turn out to be a non-issue in the end.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [April 9, 2021, 12:34am UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337/4 "2021-04-09T00:34:31Z")

</div>

Indeed, this usage (first and last) does not exist in (standard) ROOT usage.

---

<div class="post-metadata">

**Author:** ![austinschneider](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/austinschneider/32/25508_2.png) [@austinschneider](https://root-forum.cern.ch/u/austinschneider)\
**Post date:** [April 9, 2021, 2:10pm UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337/5 "2021-04-09T14:10:51Z")

</div>

Unfortunately it seems the `rootmv` procedure I was using earlier doesn’t actually change the compression for all objects in the file. So the question remains if there is a more robust way to do this.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [April 9, 2021, 3:18pm UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337/6 "2021-04-09T15:18:08Z")

</div>

Try `hadd`

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 9, 2021, 3:34pm UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337/7 "2021-04-09T15:34:21Z")

</div>

Bugs in compression should have been fixed by [these patches](https://root-forum.cern.ch/t/ttree-compression-factor-1-00/31850/16) and @pcanal could probably say in which ROOT version.

---

<div class="post-metadata">

**Author:** ![austinschneider](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/austinschneider/32/25508_2.png) [@austinschneider](https://root-forum.cern.ch/u/austinschneider)\
**Post date:** [April 9, 2021, 5:35pm UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337/8 "2021-04-09T17:35:25Z")

</div>

`hadd -f5 ./new_compression.root ./old_compression.root` works like a charm.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [April 23, 2021, 5:35pm UTC](https://root-forum.cern.ch/t/converting-root-files-from-old-cs-compression-to-newer-compression/44337/9 "2021-04-23T17:35:59Z")

</div>

Closed on April 23, 2021, 5:35pm UTC

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