void Pick(Int_t canvas_index) { TObject *o; TCanvas* c = ((TCanvas*) gROOT->GetListOfCanvases()->At(canvas_index)); c->cd(); // std::cout << "______PICKED______\n\t" // << c->GetName() << " canvas_index=" << canvas_index << std::endl; // ((TCanvas*) gROOT->GetListOfCanvases()->At(canvas_index))->cd(); TList *ll = toolcanvas->GetListOfPrimitives(); // std::cout << ll->GetEntries() << std::endl; for (Int_t ii=ll->GetEntries()-1; ii>=0; ii--) { o = ll->At(ii); // std::cout << ii << " removing " << ll->At(ii)->GetName() << std::endl; ll->Remove(o); } toolcanvas->cd(); toolcanvas->SetWindowSize(toolw-28, toolh-8); // toolcanvas->SetCanvasSize(toolw, toolh); pt->Draw(); toolcanvas->Modified(); toolcanvas->Update(); canvas = ((TCanvas*) gROOT->GetListOfCanvases()->At(canvas_index)); //Enlarge(); SelectPad(); }
void SelectPad() { notDeleted = kTRUE; toolcanvas->cd(); // Clear buttons from toolcanvas TObject *o; TList *ll = toolcanvas->GetListOfPrimitives(); for (Int_t ii=ll->GetEntries()-1; ii>=0; ii--) { o = ll->At(ii); ll->Remove(o); } Double_t buttonheight = 50; TList *li = canvas->GetListOfPrimitives(); Int_t nentries = li->GetEntries(); if (nentries==1) return; toolcanvas->SetWindowSize(toolw,(nentries+1)*buttonheight); toolcanvas->Modified(); toolcanvas->Update(); pt->SetY1NDC(1.0-1.0/(nentries+1)); pt->Draw(); toolcanvas->Update(); // toolcanvas->cd(); if (b) {delete b;} Int_t count=0; b = new TObjArray(nentries); for (Int_t i=0; i<nentries; i++) { b->Add(new TButton(Form("pad%i",i+1),Form("Enlarge(%i);",i),0,(1-(count+1.)/(nentries+1)),1,(1-(count+2.)/(nentries+1)))); b->At(i)->Draw(); count++; } toolcanvas->Modified(); toolcanvas->Update(); // if (display) {display->Modified(); display->Update();} }
void Enlarge(Int_t i) { // toolcanvas->cd(); TObject *o; TList *ll = toolcanvas->GetListOfPrimitives(); for (Int_t ii=ll->GetEntries()-1; ii>=0; ii--) { o = ll->At(ii); ll->Remove(o); } toolcanvas->SetWindowSize(toolw-28, toolh-8); toolcanvas->cd(); bclose->Draw(); // canvas->cd(); vp = (TPad*)canvas->GetListOfPrimitives()->At(i); if (!vp) return; // else // cout << "selected pad name " << vp->GetName() << endl; TList *alist; if (vp->GetListOfPrimitives()->GetEntries() > 1) { graph0 = (TH1*) vp->GetListOfPrimitives()->At(1); // graph1 = (TH1*) graph0->Clone("graph1"); alist = vp->GetListOfPrimitives(); } else return; Char_t opt[50]; strcpy(opt,graph0->GetDrawOption()); // display->Draw(); display = SafeConstructCanvas("display"); display->Draw(); display->cd(); gROOT->SetSelectedPad(display); // std::cout << "______Drawing Pad______\n\t" // << gPad->GetName() << std::endl; TString option; TH1* anh, *anhh; TObject *oo; for (Int_t i=1; i<alist->GetEntries(); i++) { oo = alist->At(i); if (oo->InheritsFrom(TH1::Class())) { anh = static_cast<TH1*>(oo); option = anh->GetDrawOption(); option += "HE"; if (i>1) option += "same"; if (oo->InheritsFrom(TH2::Class())) anhh = anh->DrawCopy("colz"); else anhh = anh->DrawCopy(option.Data()); anhh->SetFillStyle(0); anhh->SetLineColor(anh->GetLineColor()); cout << anhh->GetName() << " with option=\"" << option.Data() << "\"" << " lcolor=" << anhh->GetLineColor() << " fcolor=" << anhh->GetFillColor() << " fstyle=" << anhh->GetFillStyle() << flush << endl; display->Modified(); display->Update(); // gSystem->Sleep(5000); // anhh->SetFillColor(anh->GetFillColor()); // anhh->SetFillStyle(anh->GetFillStyle()); } else if (i<alist->GetEntries()-1) oo->Draw(); } display->Modified(); display->Update(); }
void plot_efficiencies( TFile* file, Int_t type = 2, TDirectory* BinDir) { // input: - Input file (result from TMVA), // - type = 1 --> plot efficiency(B) versus eff(S) // = 2 --> plot rejection (B) versus efficiency (S) Bool_t __PLOT_LOGO__ = kTRUE; Bool_t __SAVE_IMAGE__ = kTRUE; // the coordinates Float_t x1 = 0; Float_t x2 = 1; Float_t y1 = 0; Float_t y2 = 0.8; // reverse order if "rejection" if (type == 2) { Float_t z = y1; y1 = 1 - y2; y2 = 1 - z; // cout << "--- type==2: plot background rejection versus signal efficiency" << endl; } else { // cout << "--- type==1: plot background efficiency versus signal efficiency" << endl; } // create canvas TCanvas* c = new TCanvas( "c", "the canvas", 200, 0, 650, 500 ); // global style settings c->SetGrid(); c->SetTicks(); // legend Float_t x0L = 0.107, y0H = 0.899; Float_t dxL = 0.457-x0L, dyH = 0.22; if (type == 2) { x0L = 0.15; y0H = 1 - y0H + dyH + 0.07; } TLegend *legend = new TLegend( x0L, y0H-dyH, x0L+dxL, y0H ); legend->SetTextSize( 0.05 ); legend->SetHeader( "MVA Method:" ); legend->SetMargin( 0.4 ); TString xtit = "Signal efficiency"; TString ytit = "Background efficiency"; if (type == 2) ytit = "Background rejection"; TString ftit = ytit + " versus " + xtit; if (TString(BinDir->GetName()).Contains("multicut")){ ftit += " Bin: "; ftit += (BinDir->GetTitle()); } // draw empty frame if(gROOT->FindObject("frame")!=0) gROOT->FindObject("frame")->Delete(); TH2F* frame = new TH2F( "frame", ftit, 500, x1, x2, 500, y1, y2 ); frame->GetXaxis()->SetTitle( xtit ); frame->GetYaxis()->SetTitle( ytit ); TMVAGlob::SetFrameStyle( frame, 1.0 ); frame->Draw(); Int_t color = 1; Int_t nmva = 0; TKey *key, *hkey; TString hNameRef = "effBvsS"; if (type == 2) hNameRef = "rejBvsS"; TList hists; TList methods; UInt_t nm = TMVAGlob::GetListOfMethods( methods ); // TIter next(file->GetListOfKeys()); TIter next(&methods); // loop over all methods while (key = (TKey*)next()) { TDirectory * mDir = (TDirectory*)key->ReadObj(); TList titles; UInt_t ninst = TMVAGlob::GetListOfTitles(mDir,titles); TIter nextTitle(&titles); TKey *titkey; TDirectory *titDir; while ((titkey = TMVAGlob::NextKey(nextTitle,"TDirectory"))) { titDir = (TDirectory *)titkey->ReadObj(); TString methodTitle; TMVAGlob::GetMethodTitle(methodTitle,titDir); TIter nextKey( titDir->GetListOfKeys() ); while ((hkey = TMVAGlob::NextKey(nextKey,"TH1"))) { TH1 *h = (TH1*)hkey->ReadObj(); TString hname = h->GetName(); if (hname.Contains( hNameRef ) && hname.BeginsWith( "MVA_" )) { h->SetLineWidth(3); h->SetLineColor(color); color++; if (color == 5 || color == 10 || color == 11) color++; h->Draw("csame"); hists.Add(h); nmva++; } } } } while (hists.GetSize()) { TListIter hIt(&hists); TH1* hist(0); Double_t largestInt=-1; TH1* histWithLargestInt(0); while ((hist = (TH1*)hIt())!=0) { Double_t integral = hist->Integral(1,hist->FindBin(0.9999)); if (integral>largestInt) { largestInt = integral; histWithLargestInt = hist; } } if (histWithLargestInt == 0) { cout << "ERROR - unknown hist \"histWithLargestInt\" --> serious problem in ROOT file" << endl; break; } legend->AddEntry(histWithLargestInt,TString(histWithLargestInt->GetTitle()).ReplaceAll("MVA_",""),"l"); hists.Remove(histWithLargestInt); } // rescale legend box size // current box size has been tuned for 3 MVAs + 1 title if (type == 1) { dyH *= (1.0 + Float_t(nmva - 3.0)/4.0); legend->SetY1( y0H - dyH ); } else { dyH *= (Float_t(nmva - 3.0)/4.0); legend->SetY2( y0H + dyH); } // redraw axes frame->Draw("sameaxis"); legend->Draw("same"); // ============================================================ if (__PLOT_LOGO__) TMVAGlob::plot_logo(); // ============================================================ c->Update(); TString fname = "plots/" + hNameRef; if (TString(BinDir->GetName()).Contains("multicut")){ TString fprepend(BinDir->GetName()); fprepend.ReplaceAll("multicutMVA_",""); fname = "plots/" + fprepend + "_" + hNameRef; } if (__SAVE_IMAGE__) TMVAGlob::imgconv( c, fname ); return; }
void RemoveChannel(ChatTarget channel) { m_listChannels.Remove(channel); UpdateContents(); }
void q4gep_jan2009() { gROOT->SetStyle("HALLA"); TCanvas *cn = new TCanvas("cn"); cn->Draw(); TH1F *frm = new TH1F("frm","",100,0.,15.); #ifndef DIFF_LAB frm->GetXaxis()->SetTitle("Q^{2} [GeV^{2}]"); #endif #ifdef DIFF_LAB frm->GetXaxis()->SetTitle("Q^{2} in GeV^{2}"); #endif frm->GetXaxis()->CenterTitle(); #ifndef DIFF_LAB frm->GetYaxis()->SetTitle("Q^{4} G_{E}^{p}"); #endif #ifdef DIFF_LAB frm->GetYaxis()->SetTitle("#muG_{Ep}/G_{Mp}"); #endif frm->GetYaxis()->CenterTitle(); frm->SetMinimum(-0.1); frm->SetMaximum(0.4); frm->UseCurrentStyle(); frm->Draw(); TF1 *ff = new TF1("ff",fff,1.,10.,1.); ff->SetLineColor(2); ff->SetLineStyle(2); ff->SetParameter(0,1.); ff->SetParameter(1,.3); // match to Gayou point at 5.54 GeV^2 ff->SetParameter(0,.1035); TMultiGraph* mgrDta = new TMultiGraph("Data","#frac{#mu_{p}G_{E}^{p}}{G_{M}^{p}}"); //TLegend *legDta = new TLegend(.58,.565,.875,.9,"","brNDC"); TLegend *legDta = new TLegend(.648,.682,.945,.900,"","brNDC"); TMultiGraph* wgr = mgrDta; TLegend *wlg = legDta; // the data legDta->SetBorderSize(0); // turn off border legDta->SetFillStyle(0); datafile_t *f = datafiles; TGraph* gr=0; TGraph* ogr=0; while ( f && f->filename ) { ogr=OneGraph(f); if (ogr) { gr = fromGEpGMptoQ4GEp(ogr); gr->SetLineWidth(2); if (f->lnpt) { mgrDta->Add(gr,f->lnpt); legDta->AddEntry(gr,f->label,f->lnpt); } else if (gr->GetMarkerStyle()>=20) { mgrDta->Add(gr,"p"); legDta->AddEntry(gr,f->label,"p"); } else { mgrDta->Add(gr,"l"); legDta->AddEntry(gr,f->label,"l"); } } f++; } mgrDta->Draw("p"); legDta->Draw();// don't draw the data legend TMultiGraph* mgrThry = new TMultiGraph("Theory","#frac{#mu_{p}G_{E}^{p}}{G_{M}^{p}}"); // TLegend *legThry = new TLegend(.585,.6,.9,.9,"","brNDC"); TLegend *legThry = new TLegend(.335,.689,.649,.911,"","brNDC"); wgr = mgrThry; wlg = legThry; // the theory wlg->SetBorderSize(0); // turn off border wlg->SetFillStyle(0); f = theoryfiles1; ogr=0; while ( f && f->filename ) { ogr=OneGraph(f); if (ogr) { gr = fromGEpGMptoQ4GEp(ogr); TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetEYhigh() && egr->GetEYhigh()[0]>0) { gr = toerror_band(egr); gr->SetFillStyle(3000+f->style); } gr->SetLineWidth(2); if (f->lnpt) { wgr->Add(gr,f->lnpt); if( f->label[0] != 'x' ){ wlg->AddEntry(gr,f->label,f->lnpt); } } else if (gr->GetMarkerStyle()>=20) { wgr->Add(gr,"p"); if( f->label[0] != 'x' ){ wlg->AddEntry(gr,f->label,"p"); } } else { wgr->Add(gr,"l"); if( f->label[0] != 'x' ){ wlg->AddEntry(gr,f->label,"l"); } } } f++; } mgrThry->Draw("c"); #ifdef PQCD ff->Draw("same"); legThry->AddEntry(ff,"F2/F1 #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l"); #endif// PQCD legThry->Draw(); cn->Modified(); cn->Update(); TFrame* frame = gPad->GetFrame(); // draw a line at 1 TLine *line1 = new TLine(frame->GetX1(),1.,frame->GetX2(),1.); line1->SetLineStyle(1); line1->Draw(); return; cn->Update(); cn->SaveAs(Form("%s.eps",psfile)); cn->SaveAs(Form("%s.root",psfile)); gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile)); // now an overlay, hopefully matching dimensions // remove everything except the frame cn->Update(); TList *clist = cn->GetListOfPrimitives(); frame = cn->GetFrame(); for (int i=0; i<clist->GetSize(); ) { if (clist->At(i) != frame) { clist->RemoveAt(i); } else i++; } // draw markers in the corners TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2); mkr->Draw(); mkr = new TMarker(frame->GetX2(),frame->GetY1(),2); mkr->Draw(); mkr = new TMarker(frame->GetX1(),frame->GetY2(),2); mkr->Draw(); mkr = new TMarker(frame->GetX2(),frame->GetY2(),2); mkr->Draw(); frame->SetLineColor(10); { datafile_t goeckeler = { "figure_input/Goeckeler/goeckeler.dat","Goeckeler", "[0]","[1]","[1]-[2]","[3]-[1]",0,0,1,4,"F" }; gr = OneGraph(&goeckeler); TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) { gr = toerror_band(egr); gr->SetLineStyle(1); gr->SetFillColor(gr->GetLineColor()); gr->SetFillStyle(3000+goeckeler.style); } gr->Draw("F"); cn->Update(); cn->SaveAs("mup_gep_gmp_goeckeler_Overlay.eps"); cn->SaveAs("mup_gep_gmp_goeckeler_Overlay.root"); // remove Goeckeler curve from plot clist->Remove(gr); } { datafile_t miller = { "figure_input/Miller/lattice.GEp_GMp.rtf","Miller", "[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" }; gr = OneGraph(&miller); TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) { gr = toerror_band(egr); gr->SetLineStyle(1); gr->SetFillColor(gr->GetLineColor()); gr->SetFillStyle(3000+miller.style); } gr->Draw("F"); cn->Update(); cn->SaveAs("mup_gep_gmp_Miller_Overlay.eps"); cn->SaveAs("mup_gep_gmp_Miller_Overlay.root"); clist->Remove(gr); } { datafile_t zanotti = { "figure_input/Zanotti/zanotti_gepgmp.dat","Zanotti", "[0]","[1]","[1]-[2]","[3]-[1]",0,0,1,6,"F" }; gr = OneGraph(&zanotti); TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) { gr = toerror_band(egr); gr->SetLineStyle(1); gr->SetFillColor(gr->GetLineColor()); gr->SetFillStyle(3000+zanotti.style); } gr->Draw("F"); cn->Update(); cn->SaveAs("mup_gep_gmp_Zanotti_Overlay.eps"); cn->SaveAs("mup_gep_gmp_Zanotti_Overlay.root"); clist->Remove(gr); } }
void Window::RemoveKeyboardInputFilter(IKeyboardInput* pkeyboardInput) { g_listKeyboardInputFilters.Remove(pkeyboardInput); }
void q4gmn_jan2009() { gROOT->SetStyle("HALLA"); TCanvas *cn = new TCanvas("cn"); cn->Draw(); // TH1F *frm = new TH1F("frm","",100,0.,5.5); TH1F *frm = new TH1F("frm","",100,0.,20.); frm->GetXaxis()->SetTitle("Q^{2} [GeV^{2}]"); frm->GetXaxis()->CenterTitle(); frm->GetYaxis()->SetTitle("Q^{4} G_{M}^{n}/#mu_{n}"); frm->GetYaxis()->CenterTitle(); frm->SetMinimum(0.0); frm->SetMaximum(0.6); frm->UseCurrentStyle(); frm->Draw(); TMultiGraph* mgrDta = new TMultiGraph("Data","G_{M}^{n}/#mu_{n}G_{D}"); TLegend *legDta = new TLegend(0.5029,.2076,.9095,.3877,"","brNDC"); TMultiGraph* wgr = mgrDta; TLegend *wlg = legDta; // the data legDta->SetBorderSize(0); // turn off border legDta->SetFillStyle(0); datafile_t *f = datafiles; TGraph* gr=0; TGraph* ogr=0; while ( f && f->filename ) { ogr=OneGraph(f); if (ogr) { gr = fromGMnGDtoQ4GMn(ogr); if (f->lnpt) { mgrDta->Add(gr,f->lnpt); legDta->AddEntry(gr,f->label,f->lnpt); } else if (gr->GetMarkerStyle()>=20) { mgrDta->Add(gr,"p"); legDta->AddEntry(gr,f->label,"p"); } else { mgrDta->Add(gr,"l"); legDta->AddEntry(gr,f->label,"l"); } } f++; } mgrDta->Draw("p"); legDta->Draw(); // don't draw the data legend TMultiGraph* mgrThry = new TMultiGraph("Theory",""); TLegend *legThry = new TLegend(0.1868,.1949,.5287,.3432,"","brNDC"); wgr = mgrThry; wlg = legThry; // the theory wlg->SetBorderSize(0); // turn off border wlg->SetFillStyle(0); f = theoryfiles1; ogr=0; while ( f && f->filename ) { ogr=OneGraph(f); if (ogr) { gr = fromGMnGDtoQ4GMn(ogr); TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetEYhigh() && egr->GetEYhigh()[0]>0) { gr = toerror_band(egr); gr->SetFillStyle(3000+f->style); } gr->SetLineWidth(2); if (f->lnpt) { wgr->Add(gr,f->lnpt); wlg->AddEntry(gr,f->label,f->lnpt); } else if (gr->GetMarkerStyle()>=20) { wgr->Add(gr,"p"); wlg->AddEntry(gr,f->label,"p"); } else { wgr->Add(gr,"l"); wlg->AddEntry(gr,f->label,"l"); } } f++; } mgrThry->Draw("c"); legThry->Draw(); // draw a line at 1 cn->Modified(); cn->Update(); TFrame* frame = gPad->GetFrame(); TLine *line1 = new TLine(frame->GetX1(),1.,frame->GetX2(),1.); line1->SetLineStyle(1); line1->Draw(); cn->Update(); cn->SaveAs(Form("%s.eps",psfile)); cn->SaveAs(Form("%s.root",psfile)); gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile)); return; // remove everything but the graph cn->Update(); TList *clist = cn->GetListOfPrimitives(); frame = cn->GetFrame(); for (int i=0; i<clist->GetSize(); ) { if (clist->At(i) != frame) { clist->RemoveAt(i); } else i++; } // draw markers in the corners TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2); mkr->Draw(); mkr = new TMarker(frame->GetX2(),frame->GetY1(),2); mkr->Draw(); mkr = new TMarker(frame->GetX1(),frame->GetY2(),2); mkr->Draw(); mkr = new TMarker(frame->GetX2(),frame->GetY2(),2); mkr->Draw(); frame->SetLineColor(10); cn->Update(); { datafile_t miller = { "figure_input/Miller/lattice.GMn.rtf","Miller", "[0]","[1]/(-1.91)*(1+[0]/.71)*(1+[0]/.71)", "([3]-[1])/(-1.91)*(1+[0]/.71)*(1+[0]/.71)", "([1]-[2])/(-1.91)*(1+[0]/.71)*(1+[0]/.71)", 0,0,1,3,"F" }; gr = OneGraph(&miller); TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) { gr = toerror_band(egr); gr->SetLineStyle(1); gr->SetFillColor(gr->GetLineColor()); gr->SetFillStyle(3000+miller.style); } gr->Draw("F"); cn->Update(); cn->SaveAs("gmngd_Miller_Overlay.eps"); cn->SaveAs("gmngd_Miller_Overlay.root"); clist->Remove(gr); } { datafile_t miller_spl = { "figure_input/Miller/lattice.GMn.spl3","Miller", "[0]","[1]/(-1.91)*(1+[0]/.71)*(1+[0]/.71)", "([3]-[1])/(-1.91)*(1+[0]/.71)*(1+[0]/.71)", "([1]-[2])/(-1.91)*(1+[0]/.71)*(1+[0]/.71)", 0,0,1,3,"F" }; gr = OneGraph(&miller_spl); TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) { gr = toerror_band(egr); gr->SetLineStyle(1); gr->SetFillColor(gr->GetLineColor()); gr->SetFillStyle(3000+miller_spl.style); } gr->Draw("F"); cn->Update(); cn->SaveAs("gmngd_Miller_Overlay_spl.eps"); cn->SaveAs("gmngd_Miller_Overlay_spl.root"); clist->Remove(gr); } }