# Removing events in a root file

**URL:** <https://root-forum.cern.ch/t/removing-events-in-a-root-file/52712>\
**Category:** Newbie\
**Created:** [December 9, 2022, 1:18pm UTC](https://root-forum.cern.ch/t/removing-events-in-a-root-file/52712 "2022-12-09T13:18:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![giacomor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/e495f1/32.png) [@giacomor](https://root-forum.cern.ch/u/giacomor)\
**Post date:** [December 9, 2022, 1:18pm UTC](https://root-forum.cern.ch/t/removing-events-in-a-root-file/52712/1 "2022-12-09T13:18:40Z")

</div>

Hi,

I have a root file that contains a tree and some histograms.  
For some reason i want to remove some events.  
Is there a way to just remove events from the file ? Or do I have to copy the tree in a new file after selecting only the events that I don’t want to remove ? And would this also remove the events in the histograms (that are not in the tree, but in the file) ?

Thank you very much for you help

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [December 12, 2022, 4:30pm UTC](https://root-forum.cern.ch/t/removing-events-in-a-root-file/52712/2 "2022-12-12T16:30:31Z")

</div>

Hi and welcome to the forum!

The TTree was maybe used to generate the histograms - you’d need to regenerate them with the updated TTree once you have removed entries.

TTrees are read-only; the way to remove entries is indeed to write the entries you want to keep into a new TTree. See `tutorials/tree/copytree3.C` for how to do that with bare TTree, or even simpler, use `RDataFrame::Snapshot()`.

Cheers, Axel
