# "Unfill" a histogram

**URL:** <https://root-forum.cern.ch/t/unfill-a-histogram/43665>\
**Category:** Newbie\
**Created:** [February 22, 2021, 11:04pm UTC](https://root-forum.cern.ch/t/unfill-a-histogram/43665 "2021-02-22T23:04:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward\_Finkelstein](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/edward_finkelstein/32/20070_2.png) [@Edward\_Finkelstein](https://root-forum.cern.ch/u/Edward_Finkelstein)\
**Post date:** [February 22, 2021, 11:04pm UTC](https://root-forum.cern.ch/t/unfill-a-histogram/43665/1 "2021-02-22T23:04:42Z")

</div>

Hello,  
I have a histogram of data, and I fill part of it with Gaussian data, shown below:

```auto
TRandom3 *r = new TRandom3();
r->SetSeed(); //time(0)
int zet=10*304;
for (int i=0; i<(zet); i++){cout << hh->Fill(bla.GetRandom(880-(5.0*132),880+(5.0*132),r)) << ",";}

```

Where hh is the TH1 pointer to my histogram of data, and bla is my TF1 object for the Gaussian function.

My question is, is there a way to unfill the histogram, hh, of the data I fill it with in the script above? My intent is to fill hh’s histogram with x number of events, fit it, unfill the histogram of the filled data, fill it again, fit it, etc, so I can automate this process, and push relevant values into a container.

* * *

_ROOT Version:_ 6.23/01

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [February 23, 2021, 7:08am UTC](https://root-forum.cern.ch/t/unfill-a-histogram/43665/2 "2021-02-23T07:08:57Z")

</div>

Maybe [TH1F::Reset( Option\_t \*option="")](https://root.cern.ch/doc/master/classTH1F.html#a94cea4a32fd715f07632863b9c4b6de1)

---

<div class="post-metadata">

**Author:** ![Edward\_Finkelstein](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/edward_finkelstein/32/20070_2.png) [@Edward\_Finkelstein](https://root-forum.cern.ch/u/Edward_Finkelstein)\
**Post date:** [February 23, 2021, 12:24pm UTC](https://root-forum.cern.ch/t/unfill-a-histogram/43665/3 "2021-02-23T12:24:55Z")

</div>

This seems to completely unfill the histogram during the duration of execution. I think what I was looking for was

```auto
delete hh;

```

then to redeclare/define TH1 pointer in the command line interpreter. But I didn’t know about this Reset method, so thank you anyway 🙂
