void embcutG(char *rootf) { // Popup the GUI... new MyMainFrame(gClient->GetRoot(), 800, 800,rootf); } /***************************************************************************************************************************************/ class MyMainFrame : public TGMainFrame { RQ_OBJECT("MyMainFrame") private: TGMainFrame *fMain; TRootEmbeddedCanvas *fEcan; TTree *a ; TCanvas *c1; public: MyMainFrame(const TGWindow , UInt_t , UInt_t ); virtual ~MyMainFrame(); void DoExit();void DoCutG();void DoDraw(); char *rootfile; string rootfiles; }; /**********************************************************************************************************************************/ void MyMainFrame::ReadTree() { TFile *f=new TFile(rootfile); cout << rootfile<< endl; f->ls(); a=(TTree *)f->Get("t"); } /**********************************************************************************************************************************/ void MyMainFrame::CreateCanvas(void) { c1=fEcan->GetCanvas(); c1->Divide(2,1); } /*********************************************************************************************************************************/ void MyMainFrame::DoDraw() { // Draw a function Printf("Slot DoDraw()"); gStyle->SetPalette(1); //TKE:A c1->cd(1); TH2F *tkeahistot = new TH2F("tkeahistot","tkeahistot",160,40,200,110,100,210); a->Project("tkeahistot","TKE:A",""); tkeahistot->Draw("COLZ" ); c1->Modified(); c1->Update(); cout << "Re Draw OK" << endl; TCutG *cutg=(TCutG *)gROOT->FindObject("c"); int ad=gROOT->FindObject("c"); if(ad==0) { return; } cout << " cut exist"<cd(2); TH2F *tkeahisto = new TH2F("tkeahisto","tkeahisto",160,40,200,110,100,210); a->Project("tkeahisto","TKE:A","c"); tkeahisto->DrawNormalized("COLZ" ,1); c1->Update(); c1->cd(2)->Modified(); c1->Modified(); c1->Update(); } /*************************************************************************************************************************************/ void MyMainFrame::DoExit() { Printf("Slot DoExit()"); gApplication->Terminate(0); } /********************************************************************************************************************************/ void MyMainFrame::createbutton(char* nameoff,char* functiontc,TGHorizontalFrame *hframe) { TGTextButton *button = new TGTextButton(hframe,nameoff); button->Connect("Clicked()", "MyMainFrame", this,functiontc); hframe->AddFrame(button, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); } /***************************************************************************************************************************************/ void MyMainFrame::DoCutG() { TCutG* cutg; gROOT->SetEditorMode("CutG"); cout << "cut begin" << endl; cutg = (TCutG*)c1->WaitPrimitive("c","CutG"); cout << "cut finished" << endl; DoDraw(); } /**********************************************************************************************************************************/ MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h,char *rootf) { rootfile = rootf; rootfiles=rootf; // Create the main frame fMain = new TGMainFrame(p,w,h); // Create the embedded canvas fEcan = new TRootEmbeddedCanvas(0,fMain,1600,950); Int_t wid = fEcan->GetCanvasWindowId(); TCanvas *myc = new TCanvas("MyCanvas", 10,10,wid); fEcan->AdoptCanvas(myc); // myc->Connect("","MyMainFrame",this, ""); cout << "here 1 " << endl; fMain->AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY,0,0,1,1)); // Create a horizontal frame containing five buttons TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain ,0 ,0); createbutton("&Draw/Reset","DoDraw()",hframe); createbutton("&CutG", "DoCutG()",hframe); createbutton("&Exit ", "DoExit()",hframe); //activate frames fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 5)); // Set a name to the main frame fMain->SetWindowName(rootfile); fMain->MapSubwindows(); // Initialize the layout algorithm via Resize() fMain->Resize(fMain->GetDefaultSize()); // Map main frame fMain->MapWindow(); // launch view ReadTree(); CreateCanvas(); DoDraw(); }