I’m trying to delete a histogram inside an existing ROOT file. I’ve read through Deleting a histogram within a root file but was unable to replicate the alleged success reported therein.
The two ``Delete" lines are attempts of achieving the same result. Effectively that directory contains layer_0_time;1, layer_0_time;2 and layer_0_time;3.
I want to have them deleted. Actually, this is done in order to overwrite that histogram — I am able to write one with the same name but ROOT automatically assigns it an index n+1 where n is the existing-hist-with-the-same-name’s index.
Also note that when you write an object you can explicitly overwrite the current cycle rather than create a new one by passing TObject::kOverwrite as an option:
histo.Write(0, TObject::kOverwrite)
(on the other hand namecycles are usually harmless and most ROOT APIs will only take into consideration the highest cycle)