Options for TObject::Write()

Hi there,
I’m saving the histograms that I make in my code by appending them to a TFile, using the lines:
TFile * myfile = new TFile(“file.root”, “UPDATE”);

When the histograms are written to the TFile I want them to overwite any other histograms with the same name. I need this so that when I re-run my code, the histograms in the TFile are replaced. At the moment a new set of histograms is appended to the TFile every time I run the code. I can’t use the “RECREATE” option when opening the TFile because there are other histograms saved there which must be left unchanged.

I’ve seen the TObject::Write() in the reference guide and read that possible options here include “kOverwrite” and “kWriteDelete”, which sound like they do what I want. However, I can’t work out how to implement these options. I tried
hist1->Write(“hist1”, “kOverwrite”);
but that didn’t work. The argument is listed as “Int_t option” but I don’t understand how it can be an integer.
Please explain how I should implement this.
Thank you,

Use TObject::kOverwrite