Delete TH1 from rootfile

Hi, I’m trying to delete a few histograms in my rootfile, to hadd it with another smaller rootfile with the correct histograms, this is what I do:

TFile *f = TFile::Open(“NTUP_PILEUP.pool.root.1”,“update”);

So it’s not complaining but it doesn’t delete the histograms.

I also tried:


TFile *f = TFile::Open("NTUP_PILEUP.pool.root.1", "update");
gDirectory->Delete("pileup_TH1;*"); // all "cycles"
// f->Write();
delete f;

It worked, thanks a lot!

Btw what are these cycles and why do we have to delete “f”?

The “delete f;” will “close” the opened file (and cleanup RAM).

Also the command line tool rootrm might be of some help in that case (surely simpler)

1 Like

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