I have an eta distribution that I want to convert to a distribution of a new cumulative variable Chi(eta), so that the new distribution becomes flat.
I can’t figure out the block of code that can be used for cumulative functions.
Thank you.
TH1::GetIntegral() implement exactly the above formula.
if fEtaBin1 is your original histogram, you cumulative histogram is obtained as following:
auto ig = fEtaBin1->GetIntegral()
auto cumHist = new TH1D("cumHist","cumulative distribution",fEtaBin1->GetNbinsX(), fEtaBin1->GetXaxis()->GetXmin(),fEtaBin1->GetXaxis()->GetXmax());
for (int i = 1; i <= cumHist->GetNbinsX(); i++)
cumHist->SetBinContent(i, ig[i-1] );
cumHist->Draw();
I don’t think so. The cumulative distribution should be between 0 and 1. I see instead there a uniform distribution at ~ 35E6. Please post the full code, so we can understand what went wrong