Help with filling Histogram

ROOT Version: 6.24/08
Platform: linuxx8664gcc
Compiler: c++ (GCC) 4.8.5 20150623


Hello all im having trouble filling some histograms, they only fill with a couple events not nearly the amount that should be there. I believe the way I am filling them might be flawed but don’t know for sure.

for (int z = 0 ; z < ADC_enteries ; z++)
{
for (int i = 0 ; i < 2 ; i++)
{ 
for (int j = 0 ; j < 3 ; j++)
{  
for (int k = 0 ; k < 16 ; k++)
{
for (int q = 0 ; q < 10 ; q++)
{
input_ADC->GetEntry(z);
ts_histo_ADC[i][j][k][q] = new TH1F(Form("ts%i_%i_%i_%i_%i_ADC", q, i, j, k, z),"",100,0,10);
ts_histo_ADC[i][j][k][q]->Fill(ZDC_ADC[i][j][k][q]);
}
}
}  
}
}

Supposing input_ADC is a tree, you should only do GetEntry(z) every time z changes, not at every iteration of the other nested loops (unless you are somehow changing the value of z in those loops, but this is not the case in the code you showed). Also, you probably don’t want to create a new hiistogram (ts_histo_ADC[i][j][k][q] = new TH1F...) for every new entry of the tree, so it seems that your problem is in your logic, rather than in ROOT.

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