Histogram stack + individual stats

Hi all,
I’m using THStack to plot several histograms together. I wanted to show them stacked visually, but not at the stat level. That’s: I go with the default (that’s without nostack option) so as to have one histogram over another, and then I set the things to show also the stats of each individual histogram, what I see is that the stats take into account previous histograms: what I expected was to see that, say, “the number of entries of histogram 2” are exactly that and not being affected by the entries of a previous histogram.

I attach a sample script and its (visually rearranged, so as to show the stats) output.

Cheers, and thanks a lot for your help with this issue.

Rodolfo.
test_stack.C (443 Bytes)

The " sames" option is not meant to be used for that purpose. I modified your macro. I think it is correct now:

{
  THStack *hs = new THStack("hs", "test");
  TH1I *h1 = new TH1I("h1","h1", 3, 1, 4);
  TH1I *h2 = new TH1I("h2","h2", 3, 1, 4);

  h1->Fill(2);
  h2->Fill(2);

  h1->Draw(); 
  gPad->Update();  
  TPaveStats *ps1 = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats"); 
  ps1->SetX1NDC(0.1);
  ps1->SetX2NDC(0.3);
  h2->Draw();
  gPad->Update();
   
  h1->SetFillColor(kRed);
  h1->SetMarkerStyle(21);
  h1->SetMarkerColor(kRed);

  h2->SetFillColor(kBlue);
  h2->SetMarkerStyle(21);
  h2->SetMarkerColor(kBlue);

  hs->Add(h1);
  hs->Add(h2);  

  hs->Draw();
}

Thanks. It worked as expected.