Deleting histograms in ROOT files

Hi @roy.brener ,
using the full namecycle should work:

gDirectory.Delete("layer_0_time1;1")

For more information about namecycles you can search this forum, e.g. Questions regarding TTree and their NameCycles might be interesting for you.

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)

Cheers,
Enrico