Looping error with n larger than 10,000

Dear All
I need an help to plot the result of geant4 output in root.
My code below have no process if I put n = 100,000. but when I set it to be 10,000 will be okay.
TFile f1(“HeliumOutPut.root”);
TH1F* helium = new TH1F("", “”, 3000, 0, 300);
double n = 100000;
double p = 10000000;

for (Int_t i=0;i<n;i++)
helium->SetBinContent(i, (totaldose->GetBinContent(i)/p));

//plot helium

TFile f2(“ProtonOutPut.root”);
TH1F* proton = new TH1F("", “”, 3000, 0, 300);

for (Int_t j=0;j<n;j++)
proton->SetBinContent(j, (totaldoseproton->GetBinContent(j)/p));

//plot proton


note: I use root version 6.22 but it seems okay in root version 5.34

Hi @M_Arif_Efendi

You creating histogram with 3000 bins, but try to set bin content with index 100000 - it cannot work.
Maximal bin number which can be used is 3001.
See documentation about binning indices.


1 Like

Hi Sergey,

Thank you so much for your answer.
It really helps.

M. Arif Efendi

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.