Memory Problem in TH1 3D array

Hello,

I have a memory issue when I go from 2D TH1 array to 3D TH1 array.
Could you please help me to figure out this?

 int i_theta_bins = 4;
    int n_p = 6;
    int sectors=6;

TH1F h_pimMX2array[i_theta_bins][n_p][sectors];
    char histName[64];
 for (int isec=1; isec<=sectors; sectors++) {
    for (int ith=0; ith<i_theta_bins; ith++) {
        for (int ippim=0; ippim<n_p; ippim++) {
  
            sprintf(histName,"h_pimMX2array_p%03d_th%03d_sec%03d",ippim,ith,sectors);
            h_pimMX2array[ith][ippim][isec] = new TH1F(histName,"3fold and 4fold Missing pimMassSq",300,-0.5,0.5);
            h_pimMX2array[ith][ippim][isec]->SetTitle(Form("P bin %d / th bin %d /sec %d  ",ippim,ith,isec));
                
            }
        }
    }
    

This code was working fine with 2D array when I add “for (int isec=0; isec<=sectors; sectors++)”,the code went to the memory problem.

Any help would be greatly appreciated.

Thanks
Dil

for (int isec=0; isec<sectors; isec++)

Thank you Wile,
Stupid mistake.I didn’t notice that.Thanks again.

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