void wait_tcutg() { TH2F* h1 =new TH2F("h1", "h1", 100, -2, 2, 100, -2, 2); for (Int_t i=0; i<1000; i++) { Double_t x = gRandom->Gaus(); Double_t y = gRandom->Gaus(); h1->Fill(x,y); } Double_t xmin = h1->GetXaxis()->GetXmin(); h1->Draw("colz"); gPad->Modified(); // make sure gPad->Update(); // hist is drawn Double_t *x; Int_t cont = 1; Int_t sernr = 0; TString new_name; do { cout << "Please make a TCutG" << endl << "Terminate if a point is below xmin: " << xmin << endl; TCutG* cutg=(TCutG*)gPad->WaitPrimitive("CUTG","CutG"); cont = 1; if (cutg) { cutg->Print(); x = cutg->GetX(); for ( Int_t i=0; i< cutg->GetN(); i++ ) { if (x[i] < xmin) { cont = 0; break; } } // make names unique if ( cont ) { new_name = "mycut_"; new_name += sernr++; cutg->SetName(new_name); } else { // finito delete cutg; } } else { cout << "No cut " << endl; } } while (cont); cout << "Finito" << endl; }