Home | News | Documentation | Download

"Unfill" a histogram

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

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

Maybe TH1F::Reset( Option_t *option="")

1 Like

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

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 :slight_smile:

1 Like