Warning in <TH1::Build>: Replacing exi .... how to dis

Hi All,

QUESTION: (for those with no time to read the whole description :slight_smile: )

  1. are these warnings worrying or just warnings?
  2. how can I turn them off without renaming all histos?
  3. why did I not get these warnings with TTree?

DESCRIPTION of problem:
since I switched from TTree to TChain (to process more than one file) I get this

Warning in TH1::Build: Replacing existing histogram NAME

for every of my ~200 histograms. The reason is that I have some kind of algorithm class which I call once for the signal events and once for the background input. Inside the class it books histos to be filled.

Of course the histos have the same name for the signal object of the class and the background object - but of course they are different histograms and each object has the pointer to its histos.

I do not want to give different names depending on the input file since this causes huge troubles for me when plotting histos …

Thanks
Andi

Hi Andi,

it just means there is a histogram with the same name in the current directory. You can simply do

TObject* old=gDirectory->GetList()->FindObject(newHistName); gDirectory->GetList()->Remove(old); and then create your new histogram. This will not delet the old onw, but de-register it from the current directory (i.e. it will not get deleted when the current directory gets deleted, e.g. the current file gets closed).
Axel.

Hi,

sorry I was away for a week.
I tried your proposal and it works fine!

Thanks!
Andi