Deleting a histogram within a root file

Hi,

I would like to delete a histogram within a root file. The following didn’t work. Does anyone have a suggestion of what would be the best way to delete the histogram Summary_ClusterWidth_OffTrack_in_TEC ?

Cheers,
Jeff

TFile *f = new TFile(“change70659.root”,“update”);

TH1* h = (TH1*) file->Get(“DQMData/Run70659/SiStrip/Runsummary/MechanicalView/TEC/Summary_ClusterWidth_OffTrack_in_TEC”);

file->Delete(“DQMData/Run 70659/SiStrip/Run summary/MechanicalView/TEC/Summary_ClusterWidth_OffTrack_in_TEC”);

file->Close();

do:

file->Delete("DQMData/Run 70659/SiStrip/Run summary/MechanicalView/TEC/Summary_ClusterWidth_OffTrack_in_TEC;1");
see: root.cern.ch/root/html/TDirector … ile:Delete

Rene

1 Like

Hi Rene,

I tried a number of options, such as ;1 and ;* without success.
From what you are saying, this is the correct method to use?

Thanks for the help.

Cheers,
Jeff

Hi Jeff,

I note that in the code snippets above there is sometimes a space and sometime no spaces between Run and 70659 …

Cheers,
Philippe.

Thanks for the help.
This is the code which ended up working.

TFile* file = new TFile(“change70659.root”, “update”);
file->cd(“DQMData/Run 70659/SiStrip/Run summary/MechanicalView/TEC”);
gDirectory->Delete(“Summary_ClusterNoise_OffTrack_in_TEC;1”);
file->Close();

Cheers,
Jeff

1 Like