Problem with the stacking/scaling(?) histogram output after peak matching

Hi all, I’m trying to match six histogram peaks with a reference histogram (i=2) and try to plot them in the same frame with THStack.
the scaling factor is calculated in this way,

for (int i = 0; i < 6; i++) {
    if (i == 2) { // reference histogram  
      factor[i] = 1;
      continue;
    }
    int maxBin = hist[i]->GetMaximumBin();
    factor[i] = hist[2]->GetBinContent(maxBin) / hist[i]->GetBinContent(maxBin);
    hist[i]->Scale(factor[i]);
  }

this part works well as well as the rest of the plotting routine. However, in the stacked output, only the reference histogram is coming with ‘------’ rest are kind of discrete/point ‘+’ like markers although, in the legend box, it shows a line with a dot for ALL SIX histo. (figure attached for reference). I have tried to vary the bin number etc. but the problem still persists.

Any suggestions to fix this? Thanks!

When you scale them, their draw style defaults to showing errors. So draw them with the “hist” option to avoid that; e.g. h->Draw("hist").
https://root.cern/doc/master/classTHistPainter.html#HP01a

1 Like