Ratio of histogram from array

I have an array of histogram hpT[i] read from a root file and another one hpT_MB. Now I want to divide each histogram in the array by hpT_MB. Below is the relevant part of the code:

TCanvas *jetptratio = new TCanvas("jetptratio", "jetptratio",600,500);
  for(Int_t i=0; i<4; i++){ 
     TH1D *ratio[i] = hpT[i]->Clone(Form("ratio%d_%d",cent_min[i],cent_max[i]));  // hpT[i] is the array of the histogram I read from root file
      ratio[i]->Divide(hpT_MB); // hpT_MB is the divisor
      ratio[i]->Draw((i ? "P E SAME" : "P E"));

However, I got the following error:
Error: Non-static-const variable in array dimension hpTratio.C:192:
(cint allows this only in interactive command and special form macro which
is special extension. It is not allowed in source code. Please ignore
subsequent errors.)
*** Interpreter error recovered ***
Any suggestion?

ROOT Version: 5
Platform: Ubuntu 18
Compiler: Not Provided

Replace “ratio[i]” with just “h”.
Or, if you define the “ratio” array outside of the “for” loop, use:

ratio[i] = ((TH1D*)(hpT[i]->Clone(Form("ratio%d_%d",cent_min[i],cent_max[i]))));

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