00001 void fit2d()
00002 {
00003
00004
00005
00006
00007 const Int_t n = 6;
00008 Float_t x[n] = {0.092,0.83,0.94,0.81,0.12,0.1};
00009 Float_t y[n] = {0.71,9.4,9,8,0.3,0.71};
00010 TCutG *cut = new TCutG("cut",n,x,y);
00011 TH2F *h2 = new TH2F("h2","h2",40,0,1,40,0,10);
00012 Float_t u,v;
00013 for (Int_t i=0;i<100000;i++) {
00014 u = gRandom->Rndm();
00015 v = 10*gRandom->Rndm();
00016 if (cut->IsInside(u,v)) h2->Fill(u,v);
00017 }
00018 TCanvas *c1 = new TCanvas("c1","show profile",600,900);
00019 c1->Divide(1,2);
00020 c1->cd(1);
00021 h2->Draw();
00022 c1->cd(2);
00023
00024
00025 TProfile *prof = h2->ProfileX();
00026 prof->Fit("pol1");
00027 }
00028