Updating a histogram in THashList in a root file

Dear rooters,
I would like to modify a histogram in a root file inside a THashList and save it back to the file. So try something like this:

TFile *file = TFile("myFile.root", "update");

TList *list = (TList*)file->Get("myList;1");

THashList *subList = (THashList*)list->FindObject("mySubList");

TH2D *myHisto = (TH2D*)subList->FindObject("myObject");
// Do something to myHisto 
// Write myHisto back to subList

Please guide me how to achieve this.

_ROOT Version: Root 6
_Platform: Ubuntu 18
_Compiler: gcc 7.5.0

Hello ROOTers,
please any help???

Do you have a problem with the piece of code you posted ? it looks a good start. Does it work ?

The problem is I don’t know how to remove the old histogram and write the updated one to the THashList to the root file.

With Remove()