#include #include #include #include #include #include #include void test(){ TCanvas *can =new TCanvas("can","",600,600); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gPad->SetLeftMargin(0.15); gPad->SetRightMargin(0.18); can->SetTickx(1); can->SetTicky(1); TFile *file1 = new TFile("1.root"); TFile *file2 = new TFile("2.root"); TFile *file3 = new TFile("3.root"); TH2F *h1 = (TH2F*)file1->Get("SigTimBakEff1"); TH2F *h2 = (TH2F*)file2->Get("SigTimBakEff1"); TH2F *h3 = (TH2F*)file3->Get("SigTimBakEff1"); TH2F* sigbkg1 =(TH2F*) h1->Clone("sigbkg1"); sigbkg1->Add(h2); TH2F* total_sig =(TH2F*) h3->Clone("total_sig"); total_sig->Add(sigbkg1); total_sig->GetXaxis()->SetTitleOffset(1.3); total_sig->GetYaxis()->SetTitleOffset(1.6); total_sig->GetZaxis()->SetTitleOffset(1.5); total_sig->GetYaxis()->SetTitle("Y"); total_sig->GetXaxis()->SetTitle("X"); total_sig->GetZaxis()->SetTitle("#sum Sig"); gStyle->SetPalette(1); gStyle->SetNumberContours(64); //gStyle->SetNumberContours(50); gPad->Modified(); gPad->Update(); total_sig->Draw("CONT1Z"); TPaveText *pt = new TPaveText(0.1665265,0.4421875,0.549201,0.5078125,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(72); pt->Draw(); TLatex *tex = new TLatex(0.7200805,0.5158145,""); tex->SetLineWidth(2); tex->Draw(); int drawxmin = 0; int drawxmax = 0; int drawymin = 0; int drawymax = 0; double maxSig = 0.0; for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { double xlowbin = total_sig->GetXaxis()->GetBinLowEdge(i); double xmaxbin = total_sig->GetXaxis()->GetBinUpEdge(i); double ylowbin = total_sig->GetYaxis()->GetBinLowEdge(j); double ymaxbin = total_sig->GetYaxis()->GetBinUpEdge(j); double bin_content = total_sig->GetBinContent(i,j); if(total_sig->GetBinContent(i,j)==total_sig->GetMaximum()) { cout << " xBin: " << xlowbin << " - " << xmaxbin; cout << ", yBin: " << ylowbin << " - " << ymaxbin; cout << ", content: " <SetMarkerStyle(2); marker1->SetMarkerSize(3.6); marker1->Draw(); TMarker *marker2 = new TMarker(drawxmax,drawymax,2); marker2->SetMarkerStyle(2); marker2->SetMarkerSize(3.6); marker2->Draw(); TString minxy = "("+to_string(drawxmin)+","+to_string(drawymin)+", "+to_string(maxSig)+")"; TString maxxy = "("+to_string(drawxmax)+","+to_string(drawymax)+", "+to_string(maxSig)+")"; cout<SetTextAlign(21); tex->SetTextFont(42); tex->SetTextSize(0.04006969); tex->SetTextAngle(1.218875); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(35.5164,54.79094,maxxy); tex->SetTextFont(42); tex->SetTextSize(0.03832753); tex->SetLineWidth(2); tex->Draw(); can->Modified(); can->cd(); can->SetSelected(can); can->ToggleToolBar(); can->Print("Sum.png"); }