Hi rooters,
this is a feature I have been noticing a lot but everytime I make a workaround and forget about it but it is becoming so anoying that I think it is better to post because it can be something silly that I am doing.
I have a loop in which I declare a temporary TH1D and work like so:
for (int i = 0; i < m_sys_names.size(); ++i)
{
TH1D up("up_var","up_var",nbins,low,high);
TH1D down("down_var","down_var",nbins,low,high);
modifyHistogram(i,up);
modifyHistogram(i,down);
... keep working...
}
where the function modifyHistogram just makes some adjustments to the histograms. The thing is that it seems to remember what the histogram was in the iteration before. The fist one it worked as supposed and after all iterations I get a superposed modifications of all histograms in the loop, even though the up and down histograms are created in each iteration. It is like I am modifiyng the same histogram as the iteration before.
The only way to solve this is to give the histogram a different name in each iteration… which I think is weird since those histogram are crated in each iteration, so it seems like ROOT remembers the names and the object.
Is there a simple way of using this temporary histogram without having to give a different name in each iteration? also, is there any memory issue with the fact that you are declaring new histogram in each iteration?
Thanks a lot in advance!
Juanpe.