TH1 integral, unweighted

Hi all,

I have a TH1 histogram that contains weighted events and I need the number of entries, without weight. GetEntries does not seem to work , it always gives the value one, so I thought I should use the Integral, which gives me a number. However the integral gives me the sum of weights. Is there a way to get just the number of “unweighted” events in the histogram?

Thanks!

Best regards,
Des

Suit yourself: { // TH1::StatOverflows(kTRUE); TH1D *h = new TH1D("h", "h", 100, -1, 1); h->Sumw2(); for (Int_t i = 0; i < 100000; i++) h->Fill(gRandom->Gaus(), gRandom->Rndm()); h->Draw(); std::cout << h->GetEntries() << std::endl; std::cout << h->GetEffectiveEntries() << std::endl; std::cout << h->Integral() << std::endl; std::cout << h->Integral(1, h->GetNbinsX()) << std::endl; std::cout << h->Integral(0, (h->GetNbinsX() + 1)) << std::endl; }

Thank you Pepe Le Pew! That’s what I was looking for!