#include "func.C" #include void plot_kOptimization(){ // plot histogram cout<<"plotting hist...\n"; // root file, for optimisation use 1 file!! vector vinput { //"hist_DYJetsToLLM50_all.root", //"hist_GluGluHToTauTauM125_all.root", //"hist_SUSYGluGluToHToTauTauM200_all.root", "hist_SUSYGluGluToHToTauTauM300_all.root", //"hist_SUSYGluGluToHToTauTauM500_all.root", //"hist_SUSYGluGluToHToTauTauM800_all.root", //"hist_SUSYGluGluToHToTauTauM1200_all.root", //"hist_SUSYGluGluToHToTauTauM1800_all.root", //"hist_SUSYGluGluToHToTauTauM2600_all.root", }; func(); string mass{"Higgs 300 GeV to "}; TH1D *haxis = new TH1D("", "", 100, 0, 1200); haxis->SetStats(false); haxis->GetXaxis()->SetRangeUser(0, 2000); haxis->GetYaxis()->SetRangeUser(0.0001, 0.5); haxis->GetXaxis()->SetTitleOffset(1.); haxis->GetYaxis()->SetTitleOffset(1.4); haxis->GetXaxis()->SetTitle("m[GeV]"); haxis->GetYaxis()->SetTitle("1/dm[1/GeV]"); vectorvdir{"hadhad" ,"muhad", "emu"}; vectorvdirleg{"#tau_{h}#tau_{h}" ,"#mu#tau_{h}", "e#mu"}; vectorvlegendGen{"gen_tf_k0", "gen_tf_k1", "gen_tf_k2", "gen_tf_k3", "gen_tf_k4", "gen_tf_k5", "gen_tf_k6", "gen_tf_k7", "gen_tf_k8",}; vectorvlegendSme{"sme_tf_k0", "sme_tf_k1", "sme_tf_k2", "sme_tf_k3", "sme_tf_k4", "sme_tf_k5", "sme_tf_k6", "sme_tf_k7", "sme_tf_k8"}; int ndir{static_cast(vdir.size())}; // TLegend *legend[ndir]; for(int i=0; iSetTextSize(0.034); } // TCanvas *canvas[ndir]; for(int i=0; iDivide(2, 1); //canvas[i]->cd(1); //haxis->Draw(); canvas[i]->cd(2); gPad->SetLogx(); gPad->SetLogy(); //haxis->Draw(); } vector vh; int nhist{27}; // 9(log)*3(dir) TPaveStats *paveStat[nhist]; int npaveStat{0}; gStyle->SetOptStat("rm"); TPaveStats *ps[nhist]; TList *list[nhist]; TLatex *myt [nhist]; for(int i=0; iGetListOfKeys()); TKey* histKey(0); while ((histKey=(TKey*)nextHist())) { if (strcmp(histKey->GetClassName(),"TH1D")!=0) continue; TH1D* hmass = (TH1D*)histKey->ReadObj(); string histname(hmass->GetName()); if(histname.find(vdir[i])==std::string::npos) continue; // hadhad, muhad, emu if(histname.find("_svfitmemtfk")==std::string::npos) continue; cout<<"histname: "<Clone()); vh.back()->SetStats(kTRUE); vh.back()->SetLineWidth(2); vh.back()->Rebin(10); vh.back()->GetYaxis()->SetRangeUser(0.0001, 0.12); vh.back()->GetXaxis()->SetRangeUser(10, 800); legend[i]->SetHeader(vdirleg[i].c_str()); if(histname.find("_lin_svfitmemtfk0")!=std::string::npos){vh.back()->SetLineColor(kBlack); legend[i]->AddEntry(vh.back(), "sme_tf_k0", "l");} if(histname.find("_lin_svfitmemtfk1")!=std::string::npos){vh.back()->SetLineColor(kBlue); legend[i]->AddEntry(vh.back(), "sme_tf_k1", "l");} if(histname.find("_lin_svfitmemtfk2")!=std::string::npos){vh.back()->SetLineColor(kGreen); legend[i]->AddEntry(vh.back(), "sme_tf_k2", "l");} if(histname.find("_lin_svfitmemtfk3")!=std::string::npos){vh.back()->SetLineColor(kOrange);legend[i]->AddEntry(vh.back(), "sme_tf_k3", "l");} if(histname.find("_lin_svfitmemtfk4")!=std::string::npos){vh.back()->SetLineColor(kRed+2); legend[i]->AddEntry(vh.back(), "sme_tf_k4", "l");} if(histname.find("_lin_svfitmemtfk5")!=std::string::npos){vh.back()->SetLineColor(kCyan); legend[i]->AddEntry(vh.back(), "sme_tf_k5", "l");} if(histname.find("_lin_svfitmemtfk6")!=std::string::npos){vh.back()->SetLineColor(kGray); legend[i]->AddEntry(vh.back(), "sme_tf_k6", "l");} if(histname.find("_lin_svfitmemtfk7")!=std::string::npos){vh.back()->SetLineColor(kViolet);legend[i]->AddEntry(vh.back(), "sme_tf_k7", "l");} if(histname.find("_lin_svfitmemtfk8")!=std::string::npos){vh.back()->SetLineColor(kRed); legend[i]->AddEntry(vh.back(), "sme_tf_k8", "l");} if(histname.find("_log_svfitmemtfk0")!=std::string::npos){vh.back()->SetLineColor(kBlack);} if(histname.find("_log_svfitmemtfk1")!=std::string::npos){vh.back()->SetLineColor(kBlue);} if(histname.find("_log_svfitmemtfk2")!=std::string::npos){vh.back()->SetLineColor(kGreen);} if(histname.find("_log_svfitmemtfk3")!=std::string::npos){vh.back()->SetLineColor(kOrange);} if(histname.find("_log_svfitmemtfk4")!=std::string::npos){vh.back()->SetLineColor(kPink);} if(histname.find("_log_svfitmemtfk5")!=std::string::npos){vh.back()->SetLineColor(kCyan);} if(histname.find("_log_svfitmemtfk6")!=std::string::npos){vh.back()->SetLineColor(kGray);} if(histname.find("_log_svfitmemtfk7")!=std::string::npos){vh.back()->SetLineColor(kViolet);} if(histname.find("_log_svfitmemtfk8")!=std::string::npos){vh.back()->SetLineColor(kRed);} // canvas array [for each sample] if (histname.find("_lin_")!=std::string::npos){ canvas[i]->cd(1); vh.back()->Draw("hist&sames"); legend[i]->Draw("sames"); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn paveStat[npaveStat]=(TPaveStats*)vh.back()->FindObject("stats"); paveStat[npaveStat]->SetName("mystats"); // you MUST rename "stats" // paveStat[npaveStat]->SetName(TString::Format("mystats_%d", npaveStat)); // you MUST rename "stats" paveStat[npaveStat]->Draw(); // why does one need to draw it manually? vh.back()->SetStats(0); paveStat[npaveStat]->SetLineColor(vh.back()->GetLineColor()); paveStat[npaveStat]->SetLineStyle(vh.back()->GetLineStyle()); paveStat[npaveStat]->SetLineWidth(vh.back()->GetLineWidth()); paveStat[npaveStat]->SetTextSize(0.025); paveStat[npaveStat]->SetY1NDC(0.89); // Y1=lower bound if(npaveStat!=0 && npaveStat!=9 && npaveStat!=18 ){ double delta{paveStat[npaveStat-1]->GetY2NDC()-paveStat[npaveStat-1]->GetY1NDC()}; paveStat[npaveStat]->SetY2NDC(paveStat[npaveStat-1]->GetY1NDC()); paveStat[npaveStat]->SetY1NDC(paveStat[npaveStat-1]->GetY1NDC()-delta); } // Add a new line in the stat box. list[npaveStat] = paveStat[npaveStat]->GetListOfLines(); myt[npaveStat] = new TLatex(0,0,"Test = 10"); // "=" is a control character myt[npaveStat] ->SetTextFont(42); myt[npaveStat] ->SetTextSize(0.04); myt[npaveStat] ->SetTextColor(kRed); list[npaveStat]->Add(myt[npaveStat]); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn npaveStat++; } else { canvas[i]->cd(2); vh.back()->Draw("hist&sames"); } } // hist } // sample } // dir string savePath {"/home/calpas/svfitMEM/CMSSW_8_0_0/src/TauAnalysis/SVfitPerformanceStudies/test/plot/"}; //string savePath {"/afs/cern.ch/user/c/calpas/www/"}; for(int i=0; icd(j+1); gPad->Modified(); gPad->Update(); } //save canvas string image {savePath+"plot_"+vdir[i]+".png"}; canvas[i]->Print(image.c_str()); } }