00001
00002 void FirstContour()
00003 {
00004
00005
00006
00007
00008
00009
00010 TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
00011 dir.ReplaceAll("FirstContour.C","../hsimple.C");
00012 dir.ReplaceAll("/./","/");
00013 if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
00014 TFile *file = (TFile*)gROOT->ProcessLineFast("hsimple(1)");
00015 if (!file) return;
00016 TTree *ntuple = (TTree*)file->Get("ntuple");
00017
00018 TCanvas *c1 = new TCanvas("c1","Contours",10,10,800,600);
00019 gStyle->SetPalette(1);
00020 ntuple->Draw("py:px","px*px+py*py < 20", "contz,list");
00021
00022
00023
00024
00025 c1->Update();
00026
00027 TCanvas *c2 = new TCanvas("c2","First contour",100,100,800,600);
00028
00029
00030 TObjArray *contours =
00031 (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
00032 if (!contours) return;
00033 TList *lcontour1 = (TList*)contours->At(0);
00034 if (!lcontour1) return;
00035 TGraph *gc1 = (TGraph*)lcontour1->First();
00036 if (!gc1) return;
00037 if (gc1->GetN() < 10) return;
00038 gc1->SetMarkerStyle(21);
00039 gc1->Draw("alp");
00040
00041
00042 TCutG *cutg = new TCutG("cutg",gc1->GetN(),gc1->GetX(),gc1->GetY());
00043
00044
00045 const Int_t npmax = 50000;
00046 TPolyMarker *pm = new TPolyMarker(npmax);
00047 Int_t np = 0;
00048 while(1) {
00049 Double_t x = -4 +8*gRandom->Rndm();
00050 Double_t y = -4 +8*gRandom->Rndm();
00051 if (cutg->IsInside(x,y)) {
00052 pm->SetPoint(np,x,y);
00053 np++;
00054 if (np == npmax) break;
00055 }
00056 }
00057 pm->Draw();
00058 }
00059