void ratioPlots( TCanvas* c1, TH1* h_r, TH1* h_i, string xTitle, string yTitle, string savePath, double fitMin=-100000, double fitMax=100000, bool doubleColFit=0 ){ double xMaximum = h_r->GetXaxis()->GetBinUpEdge(h_r->GetXaxis()->GetLast()); double xMinimum = h_r->GetXaxis()->GetBinLowEdge(h_r->GetXaxis()->GetFirst()); double yMaximum; double yMinimum; h_i->Sumw2(); h_r->Sumw2(); TLine* line1 = new TLine(xMinimum,1,xMaximum,1); line1->SetLineColor(1); line1->SetLineWidth(2); line1->SetLineStyle(7); TF1* fpol1 = new TF1("fpol1", "pol1", fitMin, fitMax); fpol1->SetLineColor(2); fpol1->SetLineWidth(3); fpol1->SetLineStyle(7); TH1* hRatio = (TH1*)h_r->Clone("clone_record"); hRatio->Divide(h_i); yMaximum = hRatio->GetMaximum(); yMinimum = hRatio->GetMinimum(0); hRatio->GetYaxis()->SetRangeUser(yMinimum/2.5,yMaximum+yMaximum/5); hRatio->SetXTitle(xTitle.c_str()); hRatio->SetYTitle(yTitle.c_str()); hRatio->SetLineColor(9); hRatio->SetLineWidth(2); hRatio->SetMarkerStyle(8); hRatio->Draw("e"); hRatio->Fit("fpol1", "L"); line1->Draw("SAME"); if(doubleColFit){ double p0=fpol1->GetParameter(0); double p1=fpol1->GetParameter(1); double endPoint=double(fitMax*p1)+p0; double p1new=(endPoint-1)/(fitMax-fitMin); char fun[100], text[100]; sprintf(fun,"x*(%f)+1",p1new); sprintf(text,"Tangent: %f",p1new); TF1* fnew = new TF1("fnew", fun, fitMin, fitMax); fnew->SetLineColor(2); fnew->SetLineWidth(3); fnew->Draw("SAME"); TText* Title = new TText( fitMax/12, yMinimum, text); Title->SetTextColor(2); Title->SetTextSize(0.035); Title->Draw("SAME"); } c1->SaveAs(savePath.c_str()); c1->cd(); }
void TMainMenu::SetWelcomeName() { if(TSettings::GetInstance()->GetNumUsers() == 0) { TWindow *window = GetChildWindow("welcome", -1); if (window) { window->SetFlags(window->GetFlags() & ~kEnabled); } window = GetChildWindow("changeplayer", -1); if (window) { window->SetFlags(window->GetFlags() & ~kEnabled); } } else { TWindow *window = GetChildWindow("welcome", -1); if (window) { TText *text = window->GetCast<TText>(); text->SetText(TPlatform::GetInstance()->GetStringTable()->GetString("welcome", TSettings::GetInstance()->GetCurrentUserName())); } } }
void printHighPtYield(TH1* ha,TH1* hb) { char buf[20]; TH1* h[2]; h[0]=ha; h[1]=hb; int minBin[2],maxBin[2],count(0); float min,max; float ptBins[]={4,4.5,5,5.5}; int nBin=4; TText* text = new TText; for(int iBin=0;iBin<nBin;iBin++){ count=0; for(int i=0; i<2; i++){ if(!h[i]) break; minBin[i] = h[i]->GetXaxis()->FindBin(ptBins[iBin]); maxBin[i] = h[i]->GetXaxis()->FindBin(ptBins[iBin]); float integral=h[i]->Integral(minBin[i],maxBin[i]); count += integral; if(i==0){ min=h[i]->GetXaxis()->GetBinLowEdge(minBin[i]); max=h[i]->GetXaxis()->GetBinUpEdge(maxBin[i]); } } sprintf(buf,"%.1f<pt<%.1f=%d",min,max,count); text->DrawTextNDC(0.55,0.8-iBin*0.1,buf); } }
void PaintOverflow(TH1 *h) { // This function paint the histogram h with an extra bin for overflows char* name = h->GetName(); char* title = h->GetTitle(); Int_t nx = h->GetNbinsX()+1; Double_t x1 = h->GetBinLowEdge(1); Double_t bw = h->GetBinWidth(nx); Double_t x2 = h->GetBinLowEdge(nx)+bw; // Book a temporary histogram having ab extra bin for overflows TH1F *htmp = new TH1F(name, title, nx, x1, x2); // Fill the new hitogram including the extra bin for overflows for (Int_t i=1; i<=nx; i++) { htmp->Fill(htmp->GetBinCenter(i), h->GetBinContent(i)); } // Fill the underflows htmp->Fill(x1-1, h->GetBinContent(0)); // Restore the number of entries htmp->SetEntries(h->GetEntries()); // Draw the temporary histogram htmp->Draw(); TText *t = new TText(x2-bw/2,h->GetBinContent(nx),"Overflow"); t->SetTextAngle(90); t->SetTextAlign(12); t->SetTextSize(0.03);; t->Draw(); }
void greyscale() { TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500); c->SetBorderMode(0); Int_t n = 200; // tunable parameter Float_t n1 = 1./n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { TBox *b = new TBox(n1*j, n1*(n-1-i), n1*(j+1), n1*(n-i)); Float_t grey = Float_t(i*n+j)/(n*n); b->SetFillColor(TColor::GetColor(grey, grey, grey)); b->Draw(); } } TPad *p = new TPad("p","p",0.3, 0.3, 0.7,0.7); const char *guibackground = gEnv->GetValue("Gui.BackgroundColor", ""); p->SetFillColor(TColor::GetColor(guibackground)); p->Draw(); p->cd(); TText *t = new TText(0.5, 0.5, "GUI Background Color"); t->SetTextAlign(22); t->SetTextSize(.09); t->Draw(); c->SetEditable(kFALSE); }
void highlight1() { TCanvas *ch = new TCanvas("ch", "ch", 0, 0, 700, 500); const Int_t n = 500; Double_t x[n], y[n]; TH1F *h[n]; for (Int_t i = 0; i < n; i++) { h[i] = new TH1F(TString::Format("h_%02d", i), "", 100, -3.0, 3.0); // in practice gaus need reset parameters h[i]->FillRandom("gaus", 1000); h[i]->Fit("gaus", "Q"); h[i]->SetMaximum(250); // for n > 200 x[i] = i; y[i] = h[i]->GetFunction("gaus")->GetParameter(2); } TGraph *g = new TGraph(n, x, y); g->SetMarkerStyle(6); for (Int_t i = 0; i < n; i++) g->AddHighlight(i, h[i]); g->Draw("AP"); g->SetHighlight(); TPad *ph = new TPad("ph", "ph", 0.3, 0.4, 1.0, 1.0); ph->SetFillColor(kBlue - 10); ph->Draw(); ph->cd(); TText *info = new TText(0.5, 0.5, "please move the mouse over the graph"); info->SetTextAlign(22); info->Draw(); ch->cd(); TGraph::SetHighlightPad(ph); }
void Draw_KL_Test(){ TChain* ch = new TChain("Tree"); TChain* ch1 = new TChain("Tree"); TH1D* his = new TH1D("Klong6g","Klong6g",20,450,550); TH1D* his1 = new TH1D("Klong4g","Klong4g",20,450,550); TH1D* his2 = new TH1D("Klong4gAll","Klong4gAll",60,250,550); for( int i = 0; i< 68; i++){ ch->Add(Form("klongRootFile/kl%d.root" ,4162+i)); ch1->Add(Form("klongRootFile/ks%d.root",4162+i)); } ch->Project(his->GetName() ,"KlongMass[0]","CutCondition==0"); ch1->Project(his1->GetName(),"KlongMass[0]","CutCondition==0"); ch1->Project(his2->GetName(),"KlongMass[0]","CutCondition==0"); TF1* func = new TF1("func","gaus(0)+expo(3)",0,550); func->SetParameter(1,498); func->SetParameter(2,5); TF1* func2 = new TF1("func2","gaus(0)",0,550); func2->SetParameter(1,498); func2->SetParameter(2,5); TCanvas* can = new TCanvas("can","",1200,600); can->Divide(2,1); can->cd(1); his2->Fit(func->GetName(),"","",450,550); his2->Draw(); TF1* func1 = new TF1("Test","gaus",450,550); func1->SetParameter(0,func->GetParameter(0)); func1->SetParameter(1,func->GetParameter(1)); func1->SetParameter(2,func->GetParameter(2)); can->cd(2); his1->SetLineColor(2); his->Draw(); his->Fit(func2->GetName(),"","",450,550); func->Draw("same"); his1->Draw("same"); std::cout<< func2->GetParameter(0) << " " << func->GetParameter(0) << " " << func->GetParameter(0)/func2->GetParameter(0)<< std::endl; std::cout<< func2->Integral(450,550) << " " << func1->Integral(450,550) << " " << func1->Integral(450,550)/func2->Integral(450,550) << std::endl; //ch->Draw("KlongPt[0]:KlongMass[0]>>(400,200,600,50,0,20)","(CutCondition&(1|2|4|8))==0","colz"); gPad->SetLogz(); TText* text = new TText(0.5,0.5,""); TText* text1 = new TText(0.5,0.5,""); text->DrawTextNDC(0.5,0.5,Form("Integral:%2.3lf",func1->Integral(450,550))); text1->DrawTextNDC(0.5,0.6,Form("Integral:%2.3lf",func2->Integral(450,550))); }
void s_intersection() { gROOT->GetListOfCanvases()->Delete(); TCanvas *c = new TCanvas("composite shape", "Intersection boolean operation", 700, 1000); c->Divide(1,2,0,0); c->cd(2); gPad->SetPad(0,0,1,0.4); c->cd(1); gPad->SetPad(0,0.4,1,1); if (gGeoManager) delete gGeoManager; new TGeoManager("xtru", "poza12"); TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7); TGeoMedium *med = new TGeoMedium("MED",1,mat); TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100); gGeoManager->SetTopVolume(top); // define shape components with names TGeoBBox *box = new TGeoBBox("bx", 40., 40., 40.); TGeoSphere *sph = new TGeoSphere("sph", 40., 45.); // define named geometrical transformations with names TGeoTranslation *tr = new TGeoTranslation(0., 0., 45.); tr->SetName("tr"); // register all used transformations tr->RegisterYourself(); // create the composite shape based on a Boolean expression TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph:tr * bx"); TGeoVolume *vol = new TGeoVolume("COMP2",cs); top->AddNode(vol,1); gGeoManager->CloseGeometry(); gGeoManager->SetNsegments(100); top->Draw(); MakePicture(); c->cd(2); TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99); pt->SetLineColor(1); TText *text = pt->AddText("TGeoCompositeShape - composite shape class"); text->SetTextColor(2); pt->AddText("----- Here is an example of boolean intersection operation : A * B"); pt->AddText("----- A == sphere (with inner radius non-zero), B == box"); pt->AddText(" "); pt->SetAllWith("-----","color",4); pt->SetAllWith("-----","font",72); pt->SetAllWith("-----","size",0.04); pt->SetTextAlign(12); pt->SetTextSize(0.044); pt->Draw(); c->cd(1); }
void do2DPlots(bool muon, TString variable, TString ytitle){ TString leptonFolder; if(muon == true){ leptonFolder = "MuonMET/"; }else{ leptonFolder = "ElectronMET/"; } setTDRStyle(); gStyle->SetPalette(1); TString dir = "rootFilesV4/central/"; TFile* tt_file = new TFile(dir + sample+"_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root"); cout << "Getting histo: " << "Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET"<<endl; TH2D* tt_2d = (TH2D*) tt_file->Get("Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET_2btags"); TH2D* tt_2d_3b = (TH2D*) tt_file->Get("Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET_3btags"); TH2D* tt_2d_4b = (TH2D*) tt_file->Get("Binning/"+leptonFolder+variable+"/GenMET_vs_RecoMET_4orMoreBtags"); tt_2d->Add(tt_2d_3b); tt_2d->Add(tt_2d_4b); tt_2d->Rebin2D(5,5); tt_2d->GetYaxis()->SetTitle(ytitle); tt_2d->GetXaxis()->SetTitle("Gen MET (GeV)"); tt_2d->GetYaxis()->SetTitleOffset(1.8); tt_2d->GetXaxis()->SetTitleOffset(1.5); TCanvas *c= new TCanvas("c","c",10,10,800,600); tt_2d->Draw("COLZ"); int bin[5] = {25, 45, 70, 100, 150};//MET for(int i = 0; i < 5; i++){ TLine *line = new TLine(bin[i],0,bin[i],300); TLine *liney = new TLine(0,bin[i],300,bin[i]); //TLine *line = new TLine(bin[i],0,bin[i],500); //TLine *liney = new TLine(0,bin[i],500,bin[i]); line->SetLineWidth(2); liney->SetLineWidth(2); liney->Draw(); line->Draw(); } TText* textPrelim = doPrelim(0.2,0.96); textPrelim->Draw(); TString plotName("plots/"+leptonFolder); plotName += sample+"_"+variable; plotName += "_2btags.pdf"; c->SaveAs(plotName); delete c; }
void compareHistos( char *Current, char *Reference=0 ) { TText* te = new TText(); te->SetTextSize(0.1); TFile * curfile = new TFile( TString(Current)+".root" ); TFile * reffile = curfile; if (Reference) reffile = new TFile(TString(Reference)+".root"); char * prefix="DQMData/MixingV/Mixing"; //1-Dimension Histogram TDirectory * refDir=reffile->GetDirectory(prefix); TDirectory * curDir=curfile->GetDirectory(prefix); TList* list = refDir->GetListOfKeys(); TObject* object = list->First(); int iHisto = 0; char title[50]; while (object) { // find histo objects std::cout << " object :" << object->GetName() << std::endl; TProfile * h1 = dynamic_cast<TProfile*>( refDir->Get(object->GetName())); TProfile * h2 = dynamic_cast<TProfile*>( curDir->Get(object->GetName())); bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TProfile"); std::cout << " isHisto = " << isHisto << std::endl; if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) { iHisto++; char title[50]; // draw and compare std::cout << " Start draw and compare" << std::endl; TCanvas c1; TProfile htemp2; h2->Copy(htemp2);// to keep 2 distinct histos h1->SetLineColor(2); htemp2.SetLineColor(3); h1->SetLineStyle(3); h1->SetMarkerColor(3); htemp2.SetLineStyle(5); htemp2.SetMarkerColor(5); TLegend leg(0.1, 0.15, 0.2, 0.25); leg.AddEntry(h1, "Reference", "l"); leg.AddEntry(&htemp2, "New ", "l"); h1->Draw(); htemp2.Draw("Same"); leg.Draw(); sprintf(title,"%s%s", object->GetName(),".gif"); c1.Print(title); } // go to next object object = list->After(object); } }
//______________________________________________________________________________ void DrawPeriod(int runmin, int runmax, int run1, int run2, double ymin, double ymax, const char* label) { if ( run1 < runmin || run1 > runmax || run2 < runmin || run2 > runmax ) return; TBox* b = new TBox(run1,ymin,run2,ymax); b->SetFillColor(5); b->Draw(); TText* text = new TText((run1+run2)/2.0,ymax*0.6,label); text->SetTextAlign(22); text->SetTextSize(0.02); text->Draw(); }
void s_difference() { gROOT->GetListOfCanvases()->Delete(); TCanvas *c = new TCanvas("composite shape", "Difference boolean operation", 700, 1000); c->Divide(1,2,0,0); c->cd(2); gPad->SetPad(0,0,1,0.4); c->cd(1); gPad->SetPad(0,0.4,1,1); if (gGeoManager) delete gGeoManager; new TGeoManager("xtru", "poza12"); TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7); TGeoMedium *med = new TGeoMedium("MED",1,mat); TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100); gGeoManager->SetTopVolume(top); // define shape components with names TGeoTorus *tor = new TGeoTorus("tor", 45., 15., 20., 45., 145.); TGeoSphere *sph = new TGeoSphere("sph", 20., 45., 0., 180., 0., 270.); // create the composite shape based on a Boolean expression TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph - tor"); TGeoVolume *vol = new TGeoVolume("COMP3",cs); top->AddNode(vol,1); gGeoManager->CloseGeometry(); gGeoManager->SetNsegments(60); top->Draw(); MakePicture(); c->cd(2); TPaveText *pt = new TPaveText(.01, .01, .99, .99); pt->SetLineColor(1); TText *text = pt->AddText("TGeoCompositeShape - composite shape class"); text->SetTextColor(2); pt->AddText("----- It's an example of boolean difference: A - B"); pt->AddText("----- A == part of sphere (0-180, 0-270), B == partial torus (45-145)"); pt->AddText(" "); pt->SetAllWith("-----","color",4); pt->SetAllWith("-----","font",72); pt->SetAllWith("-----","size",0.04); pt->SetTextAlign(12); pt->SetTextSize(0.044); pt->Draw(); c->cd(1); }
void DoCompare( char *Current, char *Reference=0 ){ TText* te = new TText(); te->SetTextSize(0.1); gROOT->ProcessLine(".x HistoCompare.C"); HistoCompare * myPV = new HistoCompare(); TFile * curfile = new TFile( TString(Current)+".root" ); TFile * reffile = curfile; if (Reference) reffile = new TFile(TString(Reference)+".root"); char * prefix="DQMData/MixingV/"; //1-Dimension Histogram TDirectory * refDir=reffile->GetDirectory(prefix); TDirectory * curDir=curfile->GetDirectory(prefix); TList* list = refDir->GetListOfKeys(); TObject* object = list->First(); int iHisto = 0; char title[50]; while (object) { // find histo objects TH1F * h1 = dynamic_cast<TH1F*>( refDir->Get(object->GetName())); TH1F * h2 = dynamic_cast<TH1F*>( curDir->Get(object->GetName())); bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TH1F"); if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) { iHisto++; char title[50]; // draw and compare TCanvas c1; TH1F htemp2; h2->Copy(htemp2);// to keep 2 distinct histos h1->SetLineColor(2); htemp2.SetLineColor(3); h1->SetLineStyle(3); htemp2.SetLineStyle(5); TLegend leg(0.1, 0.15, 0.2, 0.25); leg.AddEntry(h1, "Reference", "l"); leg.AddEntry(&htemp2, "New ", "l"); h1->Draw(); htemp2.Draw("Same"); leg.Draw(); myPV->PVCompute(h1,&htemp2, te); sprintf(title,"%s%s", object->GetName(),".eps"); c1.Print(title); } // go to next object object = list->After(object); } }
void test(void){ TCanvas *c = new TCanvas("c","font test"); TH1D *h = new TH1D("h","h",10,0,10); TText *t = new TText(); h->SetTitle("Title"); h->GetXaxis()->SetTitle("X axis daze"); h->GetYaxis()->SetTitle("Y axis yade"); h->Draw(); t->DrawTextNDC(0.4, 0.4 ,"abcdef"); }
//-------------------------------------------------------------------------------------------------- void overlayFrame(TString text, bool align) { // Overlay a linear frame from user coordinates (0 - 1, 0 - 1) and put the frame text // Create new transparent pad for the text TPad *transPad = new TPad("transPad","Transparent Pad",0,0,1,1); transPad->SetFillStyle(4000); transPad->Draw(); transPad->cd(); // Overlay the text in a well defined frame TText *plotText = new TText(); plotText->SetTextColor(kBlue); plotText->SetTextSize(0.04); plotText->SetNDC(); // Draw text at top right if (align) { plotText->SetTextColor(kBlack); plotText->SetTextAlign(33); plotText->DrawText(0.92,0.95,text.Data()); } // Draw text at bottom left else plotText->DrawText(0.01,0.01,text.Data()); return; }
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance) { if (rPerformance){ TLatex *alice = new TLatex(0.65,0.47,"Performance"); alice->SetNDC(); alice->SetTextColor(myDarkRed); alice->SetTextFont(42); alice->SetTextSize(0.05); alice->SetLineWidth(2); alice->Draw(); TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2"); alice2->SetNDC(); alice2->SetTextColor(myDarkRed); alice->SetTextFont(42); alice2->SetTextSize(0.05); alice2->SetLineWidth(2); alice2->Draw(); TText *date = new TText(0.68,0.35,cStamp2); date->SetNDC(); date->SetTextFont(42); date->SetTextSize(0.04); date->Draw(); //Acquire canvas proportions Double_t AliLogo_LowX = 0.67; Double_t AliLogo_LowY = 0.53; Double_t AliLogo_Height = 0.22; //ALICE logo is a png file that is 821x798 pixels->should be wider than a square Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw(); TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height); // myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment ! myPadSetUp(myPadLogo,0,0,0,0); //myPadLogo->SetFixedAspectRatio(1); myPadLogo->Draw(); myPadLogo->cd(); TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png"); myAliceLogo->Draw(); } if (rWrite == 1) c2->SaveAs(Form("%s.png",name)); if (rWrite == 2) c2->SaveAs(Form("%s.eps",name)); }
void fill_with_text(TGraph *real, TGraph *down, TGraph *up, TVirtualPad *can, int scantype, std::string scanx = "") { can->cd(); float xpos_of_text = 0.22; TLegend* this_leg = new TLegend(xpos_of_text,0.6,0.38,0.75); //TLegend* this_leg = new TLegend(xpos_of_text,0.55,0.45,0.75,"n_{jets} #geq 3"); // this was the style of the paper. this_leg->SetFillColor(0); this_leg->SetBorderSize(0); this_leg->SetTextSize(0.035); //this_leg->SetTextSize(0.04); // paper style. if(scantype==PlottingSetup::SMS||scantype==PlottingSetup::GMSB) { //this_leg->AddEntry(real,"#sigma^{prod} = #sigma^{NLO-QCD}" , "l"); //this_leg->AddEntry(up,"#sigma^{prod} = 3 #times #sigma^{NLO-QCD}" , "l"); //this_leg->AddEntry(down,"#sigma^{prod} = 1/3 #times #sigma^{NLO-QCD}" , "l"); this_leg->AddEntry(real,"#sigma^{NLO-QCD}" , "l"); this_leg->AddEntry(up,"3 #times #sigma^{NLO-QCD}" , "l"); this_leg->AddEntry(down,"1/3 #times #sigma^{NLO-QCD}" , "l"); } else { write_warning(__FUNCTION__,"Not implemented yet for mSUGRA"); } this_leg->Draw(); TText *title = write_text(xpos_of_text+0.005,0.52,"JZB"); title->SetTextSize(0.04); title->SetTextAlign(13); title->SetTextFont(62); title->Draw(); write_SMS_text( scantype, scanx, xpos_of_text ); // //string legT5zz="pp #rightarrow #tilde{g} #tilde{g}, #tilde{g} #rightarrow 2j + #chi^{0}_{1}, #chi^{0}_{1} #rightarrow Z + #tilde{G}"; // string legT5zz="pp #rightarrow #tilde{g} #tilde{g}, #tilde{g} #rightarrow 2j + #chi^{0}_{2}, #chi^{0}_{2} #rightarrow Z #chi^{0}_{1}"; // string legT5zzl2="m(#tilde{q}) >> m(#tilde{g}), x = "+scanx; // string legT5zzl3=" GMSB"; // TText *title = write_text(xpos_of_text,0.85,legT5zz); // title->SetTextAlign(11); // title->SetTextSize(0.035); // if(scantype!=PlottingSetup::mSUGRA) title->Draw("same"); // TText *title2 = write_text(xpos_of_text,0.79,legT5zzl2); // title2->SetTextAlign(11); // title2->SetTextSize(0.035); // if(scantype!=PlottingSetup::mSUGRA) title2->Draw("same"); // TText *title3 = write_text(0.40,0.79,legT5zzl3); // title3->SetTextAlign(11); // title3->SetTextSize(0.035); // title3->SetTextColor(kRed); //// if(scantype==PlottingSetup::GMSB) title3->Draw("same"); DrawPrelim(); draw_diagonal_xchange( scantype, scanx ); }
//______________________________________________________________________________ void AddText(TPaveText *pave, const char *datamember, Int_t value, const char *comment) { char line[128]; for (Int_t i=0; i<128; i++) line[i] = ' '; memcpy(&line[0], datamember, strlen(datamember)); line[10] = '='; char number[20]; sprintf(number, "%5i", value); memcpy(&line[12], number, strlen(number)); line[26] = '='; line[27] = '>'; sprintf(&line[30], "%s",comment); TText *text = pave->AddText(line); text->SetTextAlign(12); }
void bexec(TString &dir,const char *macro) { if (gROOT->IsBatch()) printf("Processing benchmark: %s%s\n",dir.Data(),macro); TPaveText *summary = (TPaveText*)bench1->GetPrimitive("TPave"); TText *tmacro = summary->GetLineWith(macro); if (tmacro) tmacro->SetTextColor(4); bench1->Modified(); bench1->Update(); gROOT->Macro(Form("%s%s",dir.Data(),macro)); TPaveText *summary2 = (TPaveText*)bench1->GetPrimitive("TPave"); TText *tmacro2 = summary2->GetLineWith(macro); if (tmacro2) tmacro2->SetTextColor(2); bench1->Modified(); bench1->Update(); }
void table(Float_t x1, Float_t x2, Float_t yrange, TText *t, const char **symbol, Bool_t octal) { Int_t i; Int_t n = 0; for (i=0;i<1000;i++) { if (!strcmp(symbol[i],"END")) break; n++; } Float_t y1 = 2.5; Float_t y2 = yrange - 0.5; Float_t dx = (x2-x1)/5; Float_t dy = (y2 - 1 -y1)/(n+1); Float_t y = y2 - 1 - 0.7*dy; Float_t xc0 = x1 + 0.5*dx; Float_t xc1 = xc0 + dx; Float_t xc2 = xc1 + dx; Float_t xc3 = xc2 + dx; Float_t xc4 = xc3 + dx; TLine *line = new TLine(); line->DrawLine(x1,y1,x1,y2); line->DrawLine(x1,y1,x2,y1); line->DrawLine(x1,y2,x2,y2); line->DrawLine(x2,y1,x2,y2); line->DrawLine(x1,y2-1,x2,y2-1); line->DrawLine(x1+ dx,y1,x1+ dx,y2); line->DrawLine(x1+2*dx,y1,x1+2*dx,y2); line->DrawLine(x1+3*dx,y1,x1+3*dx,y2); line->DrawLine(x1+4*dx,y1,x1+4*dx,y2); TText *tit = new TText(0,0,"a"); tit->SetTextSize(0.015); tit->SetTextFont(72); tit->SetTextAlign(22); tit->DrawText(xc0,y2-0.6,"Input"); tit->DrawText(xc1,y2-0.6,"Roman"); tit->DrawText(xc2,y2-0.6,"Greek"); tit->DrawText(xc3,y2-0.6,"Special"); tit->DrawText(xc4,y2-0.6,"Zapf"); char text[12]; for (i=0;i<n;i++) { if (octal) { unsigned char value = *symbol[i]; sprintf(text,"@\\ %3o",value); } else { strcpy(text,symbol[i]); } t->DrawText(xc0,y,text); sprintf(text,"%s",symbol[i]); t->DrawText(xc1,y,text); sprintf(text,"`%s",symbol[i]); t->DrawText(xc2,y,text); sprintf(text,"'%s",symbol[i]); t->DrawText(xc3,y,text); sprintf(text,"~%s",symbol[i]); t->DrawText(xc4,y,text); y -= dy; } }
TCanvas* pHitSpecDet(const std::string& s) { TCanvas* c = new TCanvas( ("HitSpecDet"+s).c_str(), ("HitSpecDet"+s).c_str(), -2); c->SetLogx(); TH2D* h = (TH2D*)gROOT->FindObject(s.c_str()); h->GetXaxis()->SetRange(4,32); std::stringstream str; str<<h->GetTitle(); TText t; t.SetTextColor(4); t.SetTextAlign(11); t.SetTextSize(0.035); h->DrawCopy("box"); t.DrawTextNDC(0.17,0.2, str.str().c_str()); return c; }
//______________________________________________________________________________ void bexec2(char *macro) { printf("in bexec dir=%s\n",pwd()); if (gROOT->IsBatch()) printf("Processing benchmark: %s\n",macro); TPaveText *summary = (TPaveText*)bench->GetPrimitive("TPave"); TText *tmacro = summary->GetLineWith(macro); if (tmacro) tmacro->SetTextColor(4); bench->Modified(); bench->Update(); gROOT->Macro(macro); TPaveText *summary2 = (TPaveText*)bench->GetPrimitive("TPave"); TText *tmacro2 = summary2->GetLineWith(macro); if (tmacro2) tmacro2->SetTextColor(2); bench->Modified(); bench->Update(); }
void HistoCompare::printRes(TString theName, Double_t thePV, TText * te) { myte->DrawTextNDC(0.1,printresy,theName ); std::cout << "[Compatibility test] " << theName << std::endl; printresy+=-0.04; }
//______________________________________________________________________________ void AddText(TPaveText *pave, TObject *pf, Int_t iaxis) { char line[128]; TGeoPatternFinder *finder = (TGeoPatternFinder*)pf; if (!pave || !pf) return; for (Int_t i=0; i<128; i++) line[i] = ' '; TGeoVolume *volume = finder->GetVolume(); TGeoShape *sh = volume->GetShape(); sprintf(line, "Division of %s on axis %d (%s)", volume->GetName(), iaxis,sh->GetAxisName(iaxis)); TText *text = pave->AddText(line); text->SetTextColor(3); text->SetTextAlign(12); AddText(pave, "fNdiv",finder->GetNdiv(),"number of divisions"); AddText(pave, "fStart",finder->GetStart(),"start divisioning position"); AddText(pave, "fStep",finder->GetStep(),"division step"); }
TH1F* mix(int run=21, int cut=1, int bin1=3, int bin2=1, int plot=1, int method=1, TH1F* mix0=0, TH1F* mix1=0){ readfile(OPT,run); TH1F* h1= (TH1F*)mTFile->Get(Form("phi1_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h2= (TH1F*)mTFile->Get(Form("phi2_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h3= (TH1F*)mTFile->Get(Form("dphi_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h4= (TH1F*)h3->Clone(Form("mix_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h5= (TH1F*)h3->Clone(Form("dphi_corr_%1d%1d_c%d",bin1,bin2,cut)); h4->Reset(); h5->Reset(); mixing(h1,h2,h3,h4,1); h5->Divide(h3,h4); mix0=h4; TH1F* h11= (TH1F*)mTFile->Get(Form("phi0_%1d_c%d",bin1,cut)); TH1F* h12= (TH1F*)mTFile->Get(Form("phi0_%1d_c%d",bin2,cut)); TH1F* h13= (TH1F*)mTFile->Get(Form("dphi_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h14= (TH1F*)h3->Clone(Form("mix2_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h15= (TH1F*)h3->Clone(Form("dphi_corr2_%1d%1d_c%d",bin1,bin2,cut)); h14->Reset(); h15->Reset(); mixing(h11,h12,h13,h14,0); h15->Divide(h13,h14); mix1=h14; if(plot==1){ TText* t; gStyle->SetOptStat(0); c1->Divide(2,2); c1->cd(1); h1->SetMinimum(0); h1->SetLineWidth(2); h1->Draw(); h11->Scale(h1->GetEntries()/h11->GetEntries()); h11->SetLineWidth(2); h11->SetLineColor(6); h11->Draw("same"); t = new TText(0.2, 0.85,Form("%s %s",CBEAM,CCUT[cut])); t->SetNDC(); t->SetTextSize(0.06); t->SetTextColor(1); t->Draw(); c1->cd(2); h2->SetMinimum(0); h2->SetLineWidth(2); h2->Draw(); if(h11!=h12)h12->Scale(h2->GetEntries()/h12->GetEntries()); h12->SetLineWidth(2); h12->SetLineColor(6); h12->Draw("same"); float m4=h4->GetMaximum(); c1->cd(4); h4->SetMinimum(0); h4->SetLineWidth(2); h4->SetMaximum(m4*1.1); h4->Draw(); h14->SetLineWidth(2); h4->SetLineColor(6); h14->Draw("same"); c1->cd(3); h3->Rebin(2); h5->Rebin(2); h15->Rebin(2); float m3=h3->GetBinContent(h3->GetNbinsX()*3/4); h3->SetMinimum(0); h3->SetLineWidth(2); h3->SetMaximum(m3*1.5); h3->SetLineColor(1); h3->Draw(); h5->SetLineWidth(2); h5->SetLineColor(2); h5->Draw("same"); h15->SetLineWidth(2); h15->SetLineColor(6); h15->Draw("same"); t= new TText(0.20, 0.25,"UnCorrected"); t->SetTextSize(0.05); t->SetTextColor(1); t->SetNDC(); t->Draw(); t= new TText(0.20, 0.20,"Corrected"); t->SetTextSize(0.05); t->SetTextColor(2); t->SetNDC(); t->Draw(); t= new TText(0.20, 0.15,"Corrected2"); t->SetTextSize(0.05); t->SetTextColor(6); t->SetNDC(); t->Draw(); c1->SaveAs(Form("plot/mix_%s_%1d%1d_c%d.png",CBEAM,bin1,bin2,cut)); } if(method==0) return h5; else return h15; }
//-------------------------------------------------------------------------------------------------- void overlayFrame(TString text) { // Overlay a linear frame from user coordinates (0 - 1, 0 - 1) and put the frame text // create new transparent pad for the text TPad *transPad = new TPad("transPad","Transparent Pad",0,0,1,1); transPad->SetFillStyle(4000); transPad->Draw(); transPad->cd(); // overlay the text in a well defined frame TText *plotText = new TText(0.01,0.01,text.Data()); plotText->SetTextSize(0.04); plotText->SetTextColor(kBlue); plotText->Draw(); return; }
void CutFlow::standardCutFlowPlot(TH1D* data, THStack *hs, AllSamples samples, Variable variable){ //Style TdrStyle style; style.setTDRStyle(); //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); data->Draw(); hs->Draw("hist"); setBinLabels(hs, data); if(Globals::addHashErrors){ TH1D* hashErrs = hashErrors(samples, variable); hashErrs->Draw("same e2"); } data->Draw("E same"); data->SetMarkerStyle(20); data->SetMarkerSize(0.5); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); hs->GetXaxis()->SetLimits(variable.minX, variable.maxX); hs->GetXaxis()->SetTitle(variable.xTitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); TLegend* leg = legend(samples); leg->Draw(); TText* textChan = doChan(0.12,0.96); textChan->Draw(); TText* textPrelim = doPrelim(0.58,0.96); textPrelim->Draw(); c1->SetLogy(); c1->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+".png"); c1->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+".pdf"); delete c1; delete leg; delete textChan; delete textPrelim; }
void drift_chisq() { int i; events = (TTree*)f.Get("events"); c1.Divide(2, 2, 0.01, 0.02); c2.Divide(2, 2, 0.01, 0.02); i = 0; c1.cd(++i); makehist("t3X", 2); c1.cd(++i); makehist("t4X", 2); c1.cd(++i); makehist("t3Y", 2); c1.cd(++i); makehist("t4Y", 2); i = 0; c2.cd(++i); makehist("t3X", 1); c2.cd(++i); makehist("t4X", 1); c2.cd(++i); makehist("t3Y", 1); c2.cd(++i); makehist("t4Y", 1); TText *t; TTree *info = (TTree*)f.FindObjectAny("info"); TString info_str = get_info_str(info); c1.cd(0); t = new TText(0.005, 0.005, info_str); t->SetTextSize(0.02); t->Draw(); c2.cd(0); t = new TText(0.005, 0.005, info_str); t->SetTextSize(0.02); t->Draw(); c1.Show(); c2.Show(); }
void FitHist(TH1F* hPR, TH1F* hAB, TH1F* hEP){ for(Int_t iC=4; iC<NCENT; iC++){ for(Int_t iY=0; iY<NYo; iY++){ for(Int_t iP=0; iP<NPt; iP++){ //18 chi=0.; if (hAB[iC][iY][iP].Integral(90.,180.) == 0 || hAB[iC][iY][iP].Integral(0.,180.)== 0 ){ chi = 0.; } else { chi = sqrt(-2.*TMath::Log(2.*(hAB[iC][iY][iP].Integral(90.,180.)/hAB[iC][iY][iP].Integral(0.,180.)))); for(Int_t i=0; i<4; i++){ Rv[i][iC] = getCorr(i+1,chi); }} //-global-evet-resolution-- for(Int_t i=0; i<4; i++){ ci[i] = Rv[i][iC]; } ci[4]=1.0; //-temporary-set-to-unity--because-it-is--not-yet-calculated-- ci[5]=1.0; Float_t summ = hPR[iC][iY][iP]->GetSumOfWeights(); Int_t phibins = hPR[iC][iY][iP]->GetXaxis()->GetNbins(); if( summ > 0 ){ hPR[iC][iY][iP]->Fit("flows"); Char_t ds[100]; TText txt; for(Int_t i=0; i<6; i++){ vi[i] = flows->GetParameter(i); ei[i] = flows->GetParError( i); sprintf(ds, "v%i=%+5.4f +/- %5.4f",i+1, vi[i]/ci[i], ei[i]/ci[i]); txt.DrawTextNDC(0.25, 0.36-0.05*i, ds); if(summ>12*100 ){ if(ci[i]>0.000001){ hv[i][iC][iP]->SetBinContent(iY+2, vi[i]/ci[i]); hv[i][iC][iP]->SetBinError( iY+2, ei[i]/ci[i]); vsum[i][iC][iY][iP] = vi[i]/ci[i]; esum[i][iC][iY][iP] = ei[i]/ci[i]; //hs[i][iC][iP]->SetBinContent(iY+2, vi[i]/ci[i]); //hs[i][iC][iP]->SetBinError( iY+2, ei[i]/ci[i]); } } } } } } } }
void drawHistos(TCanvas * C, TString filename, TString category, TTree* Tmine, TTree* Tother,TString var, int nbins, float xmin, float xmax, TString selection, TString myGroup, TString myRootFile, TString group, TString groupRootFile,TString mySel="1",TString groupSel="1"){ TH1F* Hmine = new TH1F(TString("Hmine")+var,"",nbins,xmin,xmax); Hmine->GetYaxis()->SetTitle(category); Hmine->GetXaxis()->SetTitle(var); Hmine->SetLineColor(1); Hmine->SetStats(0); TH1F* Hother = new TH1F(TString("Hother")+var,"",nbins,xmin,xmax); Hother->GetYaxis()->SetTitle(category); Hother->GetXaxis()->SetTitle(var); Hother->SetLineColor(2); Hother->SetStats(0); TText TXmine; TXmine.SetTextColor(1); TXmine.SetTextSize(.04); TText TXother; TXother.SetTextColor(2); TXother.SetTextSize(.04); Tmine->Draw(var+">>"+Hmine->GetName(),selection+"*("+mySel+")"); Tother->Draw(var+">>"+Hother->GetName(),selection+"*("+groupSel+")"); ////Draw one histogram on top of the other C->Clear(); //Hmine->Scale(1./Hmine->Integral()); //Hother->Scale(1./Hother->Integral()); //Hother->Scale(968134./688134.); //GGH e-tau if(Hmine->GetMaximum()>Hother->GetMaximum()) Hmine->GetYaxis()->SetRangeUser(0,Hmine->GetMaximum()*1.1); else Hmine->GetYaxis()->SetRangeUser(0,Hother->GetMaximum()*1.1); Hmine->Draw("hist"); Hother->Draw("histsame"); // ///Draw the difference of the historgrams // TH1F*HDiff=(TH1F*)Hmine->Clone("HDiff"); // HDiff->Add(Hother,-1); // int max= abs(HDiff->GetMaximum())>abs( HDiff->GetMinimum()) ? abs(HDiff->GetMaximum()): abs( HDiff->GetMinimum()); // HDiff->GetYaxis()->SetRangeUser(-2*(max>0?max:1),2*(max>0?max:1)); // HDiff->Draw("hist"); // TLine line; // line.DrawLine(HDiff->GetXaxis()->GetXmin(),0,HDiff->GetXaxis()->GetXmax(),0); //Print the integrals of the histograms a the top //TXmine.DrawTextNDC(.2,.965,myGroup+"_"+myRootFile+": "+(long)(Hmine->Integral(0,Hmine->GetNbinsX()+1))); //TXother.DrawTextNDC(.2,.93,group+"_"+groupRootFile+": "+(long)(Hother->Integral(0,Hother->GetNbinsX()+1))); TXmine.DrawTextNDC(.2,.965,myGroup+" : "+(long)(Hmine->Integral(0,Hmine->GetNbinsX()+1))); TXother.DrawTextNDC(.2,.93,group+": "+(long)(Hother->Integral(0,Hother->GetNbinsX()+1))); C->Print(filename); delete Hmine; delete Hother; }