```
Double_t g2(Double_t *x, Double_t *par) {
Double_t r1 = Double_t((x[0]-par[1])/par[2]);
Double_t r2 = Double_t((x[1]-par[3])/par[4]);
return par[0]*TMath::Exp(-0.5*(r1*r1+r2*r2));
}
Double_t fun2(Double_t *x, Double_t *par) {
Double_t *p1 = &par[0];
Double_t *p2 = &par[5];
Double_t *p3 = &par[10];
Double_t result = g2(x,p1) + g2(x,p2) + g2(x,p3);
return result;
}
void zoomth2() {
gStyle->SetOptStat(0);
const Int_t npar = 15;
Double_t f2params[npar] =
{100,-3,3,-3,3,160,0,0.8,0,0.9,40,4,0.7,4,0.7};
TF2 *f2 = new TF2("f2",fun2,-10,10,-10,10, npar);
f2->SetParameters(f2params);
//Create an histogram and fill it randomly with f2
TH2F *h2 = new TH2F("h2","TH2 Zoom",100,-40,150,100,-40,150);
Int_t nentries = 1000000;
h2->FillRandom("f2",nentries);
h2->Draw("col");
TBox *b = new TBox(-20,-20,20,20);
b->SetFillStyle(0);
b->SetLineColor(1);
b->Draw();
TLine *l1 = new TLine (-20,20,58.74284,146.25);
l1->Draw();
TLine *l2 = new TLine (20,-20,140.4047,55.75);
l2->Draw();
TPad *p = new TPad("p","p", 0.5,0.5,0.9,0.9);
p->SetLeftMargin(0);
p->SetBottomMargin(0);
p->Draw();
p->cd();
TH2D *h2z = (TH2D *)h2->DrawCopy("col");
TAxis *xa = h2z->GetXaxis();
TAxis *ya = h2z->GetYaxis();
xa->SetRangeUser(-20.,20.);
ya->SetRangeUser(-20.,20.);
xa->SetLabelSize(0.);
xa->SetTickSize(0.);
ya->SetLabelSize(0.);
ya->SetTickSize(0.);
}
```