# Opening a file in update mode causes Error in \<TBasket::Streamer\>: The value of fNbytes is incorrect

**URL:** <https://root-forum.cern.ch/t/opening-a-file-in-update-mode-causes-error-in-tbasket-streamer-the-value-of-fnbytes-is-incorrect/43340>\
**Category:** ROOT\
**Tags:** tree\
**Created:** [February 1, 2021, 2:28am UTC](https://root-forum.cern.ch/t/opening-a-file-in-update-mode-causes-error-in-tbasket-streamer-the-value-of-fnbytes-is-incorrect/43340 "2021-02-01T02:28:35Z")\
**Posts on this page:** 1\
**Showing post:** 15

<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:** [February 9, 2021, 10:03pm UTC](https://root-forum.cern.ch/t/opening-a-file-in-update-mode-causes-error-in-tbasket-streamer-the-value-of-fnbytes-is-incorrect/43340/15 "2021-02-09T22:03:26Z")

</div>

Indeed. The geant4 reimplementation has a flaw that makes the file **not** update-able. Instead you need to first copy the file with ROOT (`hadd -f output_updatable.root output_good.root`) then update the copy.

Namely the problem is that TFile meta data record stored by the Geant4 is shorter than expected. Hence when ROOT write the TFile meta data it inadvertently overwrites enough of the data to make the file unusable.

See [https://gitlab.cern.ch/geant4/geant4-dev/-/blob/master/source/analysis/g4tools/include/tools/rroot/directory#L85](https://gitlab.cern.ch/geant4/geant4-dev/-/blob/master/source/analysis/g4tools/include/tools/rroot/directory#L85)  
vs  
[ROOT: TDirectoryFile Class Reference](https://root.cern.ch/doc/v608/classTDirectoryFile.html#a9e028a5172015f554bc3c0beb3cf19f5)

Cheers,  
Philippe.

---

_[View the full topic](https://root-forum.cern.ch/t/opening-a-file-in-update-mode-causes-error-in-tbasket-streamer-the-value-of-fnbytes-is-incorrect/43340)._
