Update an existing histogram

I have a situation where I need to pass histograms based on a condition and have it updated.

h1->UpdateHist(doSomething(h1)); // UpdateHist - a fictitious method I am looking for.

TH1D* doSomething(TH1D *h){

return h;


In the above case, h1 just gets overwritten instead of an update. Is there a method to update with new contents onto an old histogram ?

Update : // WORKS
Is Add the answer here ?