Hi everyone,
I was trying to get a local maximum value (Y Axis) when using THStack,
using the approach suggested in this really old post using SetRange
and then GetMaximum.
However I always get the global maximum. The following script mimics what I tried:
{
Int_t x1[4] = {1,3,5,7};
Int_t x2[4] = {2,4,6,8};
Int_t ya[4] = {5,10,7,3};
Int_t yb[4] = {4,4,5,4};
TH1I *h1 = new TH1I("h1","h1",8,0,8);
TH1I *h2 = new TH1I("h2","h2",8,0,8);
THStack *hs = new THStack();
for (Int_t i =0; i < 4; i++){
h1->Fill(x1[i],ya[i]);
h2->Fill(x2[i],yb[i]);
}
h1->SetFillColor(1);
h2->SetFillColor(2);
hs->Add(h1,"HIST");
hs->Add(h2,"HIST");
hs->Draw();
printf("GlobalMaximum: %f\n",hs->GetMaximum());
hs->GetXaxis()->SetRange(1,4);
printf("LocalMaximum: %f\n",hs->GetMaximum());
hs->GetXaxis()->SetRange(5,8);
printf("LocalMaximum: %f\n",hs->GetMaximum());
hs->GetXaxis()->SetRange(1,8);
}
Do you have any suggestion on how to achieve this?