Using TH1::kIsNotW

Hi everyone,

I want to include weights (different than 1) in my histograms thus incrementing the bins but I don’t want the sum of the weights squared to be stored. What I understood from the tutorials is that I need to loop over all bins, get bin content using Double_t binContent = h->GetBinContent(bin), then setting the bit h->SetBit(TH1::kIsNotW). This sounds a bit tedious. Is there a better or easier way to do this, given that I have a lot of histograms to plot?
Thanks in advance.

Best,
Amin

After filling your histogram with weights, try:
SomeHistogram->ResetStats();

BTW. I don’t understand what the “sum of the weights squared” has to do with “plotting” of your histograms (maybe you are looking for the “HIST” drawing option).

Hi,

I probably misunderstand, but

TH1F hist("hist", "hist", 10, 0., 1.);
hist.SetBit(TH1::kIsNotW);
hist.Fill(0.42, 17);
assert(hist.GetSumw2N() == 0);

should do what you want?

Cheers, Axel.

Thanks Axel. It works as I wanted it to.

Best,
Amin

Hi Pepe,

I just wanted the weights to be stored but not the sum of the squares of the weights. Pretty much like ROOT 5 used to do.
Axel’s suggestion works for me.
Thanks for the reply.

Best,
Amin