void cmsFinal(double intLumi=-1, bool wide = false, long int sqrtS = 7) { cmsPrel(intLumi,wide,sqrtS); }
void DrawAllHistos(TString filename,Bool_t isMC,TString format){ // setTDRStyle("logredblue"); std::vector<TH1F*> h1vec; std::vector<TH2F*> h2vec; h1vec.clear(); h2vec.clear(); TFile *file = TFile::Open(filename); // to get the names of the conditions TObjArray *conditions_from_name = filename.Tokenize("_"); TString sa = conditions_from_name->At(1)->GetName(); TString sb = conditions_from_name->At(3)->GetName(); sb.ReplaceAll(".root",""); file->cd(); TDirectory *stardir = gDirectory; TObject *thesourcedir; TIter nextdir(stardir->GetListOfKeys()); while((thesourcedir=nextdir())){ TString dirName = thesourcedir->GetName(); stardir->cd(dirName); TDirectory *current_sourcedir = gDirectory; TH1::AddDirectory(kFALSE); std::cout << "*************************" <<std::endl; std::cout << "Reading Directory: " << dirName <<std::endl; TObject *obj; TIter next(current_sourcedir->GetListOfKeys()); while ((obj=next())) { TString objName =obj->GetName(); if(objName.Contains("pfx")) continue; if (objName.Contains("h2") && !objName.Contains("pfx")) { //std::cout << "Reading: " << obj->GetName() <<std::endl; TH2F* h2 = (TH2F*)file->Get(dirName+"/"+objName); h2->SetName(objName+dirName); h2vec.push_back(h2); TCanvas *c = new TCanvas(h2->GetName(),h2->GetName(),800,600); c->cd(); gPad->SetTopMargin(0.08); gPad->SetRightMargin(0.15); h2->SetStats(kFALSE); h2->Draw("colz"); c->Draw(); c->cd(); TProfile *hpfx_tmp = (TProfile*) h2->ProfileX("_pfx",1,-1,"o"); hpfx_tmp->SetStats(kFALSE); //hpfx_tmp->SetMarkerColor(kBlack); hpfx_tmp->SetMarkerColor(kRed); hpfx_tmp->SetMarkerSize(1.2); hpfx_tmp->SetMarkerStyle(20); hpfx_tmp->Draw("psame"); c->Draw(); cmsPrel(60.,sa,sb, isMC); TString canvName = h2->GetName(); c->cd()->SetLogz(); c->SaveAs(canvName+"."+format); } else { TH1F* h1 = (TH1F*)file->Get(dirName+"/"+objName); h1->SetName(objName+dirName); h1vec.push_back(h1); TCanvas *c = new TCanvas(h1->GetName(),h1->GetName(),600,600); c->cd()->SetLogy(); h1->SetMarkerColor(kBlack); h1->SetMarkerStyle(20); h1->SetLineWidth(1.5); h1->SetFillColor(393); //h1->SetFillStyle(3005); h1->Draw("hist"); h1->Draw("e1same"); c->Draw(); TObject *statObj; TPaveStats *stats; statObj = h1->GetListOfFunctions()->FindObject("stats"); stats= static_cast<TPaveStats*>(statObj); stats->SetFillColor(10); stats->SetLineWidth(1); stats->SetShadowColor(0); stats->SetTextFont(42); stats->SetTextSize(0.025); //stats->SetLineColor(LineColors); //stats->SetTextColor(LineColors); stats->SetX1NDC(0.75); stats->SetY1NDC(0.72); stats->SetX2NDC(0.97); stats->SetY2NDC(0.92); stats->Draw("same"); cmsPrel(60.,sa,sb,isMC); TString canvName = h1->GetName(); c->SaveAs(canvName+"."+format); } } } }
void cmsFinal(double intLumi=-1, bool wide = false) { cmsPrel(intLumi,wide); }
// --------------------------------- // void ClosureTest() { setTDRStyle(); gROOT->ForceStyle(); // input files // TFile* mc_smeared_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_ClosureSecondHalf_v2.root", "READ"); /* TFile* mc_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneEE3C_Flat_herwigpp_final_nominal_v2.root", "READ"); TFile* mc_smeared_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_ClosureFirstHalf_v2.root", "READ");*/ /*TFile* mc_smeared_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneEE3C_Flat_herwigpp_final_nominal_v4.root", "READ"); TFile* mc_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_nominal_v4.root", "READ");*/ //TFile* mc_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final.root", "READ"); TFile* mc_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_ClosureFirstHalf_NotSmeared_v4.root", "READ"); TFile* mc_smeared_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_ClosureSecondHalf_Smeared_v4.root", "READ"); TString suffix = "_PythiaSmearedVsPythia_v4"; // TString suffix = "_HerwigVsPythia"; // TString suffix = "_PythiaVsHerwig_v4"; // define helper histos TH1F *tmp_mcsmeared = new TH1F(); TH1F *tmp_mc = new TH1F(); TH1F *tmp_gensmeared = new TH1F(); TH1F *tmp_gen = new TH1F(); tmp_mcsmeared->Sumw2(); tmp_mc->Sumw2(); tmp_gensmeared->Sumw2(); tmp_gen->Sumw2(); std::vector<float> alpha; alpha.push_back(0.1); alpha.push_back(0.125); alpha.push_back(0.15); alpha.push_back(0.175); alpha.push_back(0.20); alpha.push_back(0.225); alpha.push_back(0.25); float pt_bins[14] = {62, 107, 175, 205, 242, 270, 310, 335, 379, 410, 467, 600, 1000, 2000}; // float eta_bins[6] = {0, 0.5, 1.1, 1.7, 2.3, 5.0}; float eta_bins[8] = {0, 0.5, 1.1, 1.7, 2.3, 2.8, 3.2, 5.0}; TH1F *extrapolated_mcsmeared = new TH1F("extrapolated_mcsmeared", "extrapolated_mcsmeared", 13, pt_bins); TH1F *extrapolated_mc = new TH1F("extrapolated_mc", "extrapolated_mc", 13, pt_bins); TH1F *extrapolated_gen = new TH1F("extrapolated_gen", "extrapolated_gen", 13, pt_bins); TH1F *extrapolated_mcsmeared_with_pli = new TH1F("extrapolated_mcsmeared_with_pli", "extrapolated_mcsmeared", 13, pt_bins); TH1F *extrapolated_mc_with_pli = new TH1F("extrapolated_mc_with_pli", "extrapolated_mc", 13, pt_bins); TH1F* RatioVsEta = new TH1F("RatioVsEta", "", 7, eta_bins); TH1F* RatioVsEta_with_pli = new TH1F("RatioVsEta_with_pli", "", 7, eta_bins); extrapolated_mcsmeared->Sumw2(); extrapolated_mc->Sumw2(); extrapolated_gen->Sumw2(); extrapolated_mcsmeared_with_pli->Sumw2(); extrapolated_mc_with_pli->Sumw2(); RatioVsEta->Sumw2(); RatioVsEta_with_pli->Sumw2(); // how much should be truncated? double yq_IQW[2],xq_IQW[2]; xq_IQW[0] = 0.0; xq_IQW[1] = 0.985; //// get asymmetry histos for(int ieta=0; ieta < 5; ++ieta){ // cout << "eta Bin: " << ieta << endl; extrapolated_mcsmeared->Reset(); extrapolated_mc->Reset(); extrapolated_gen->Reset(); extrapolated_mcsmeared_with_pli->Reset(); extrapolated_mc_with_pli->Reset(); for(int ipt=0; ipt < 13; ++ipt){ // cout << "pt Bin: " << ipt << endl; std::vector<double> x,x_e,MCy,MCy_e,Datay,Datay_e,Geny,Geny_e; for(int ialpha=0; ialpha < 7; ++ialpha){ //for(int ialpha=0; ialpha < 3; ++ialpha){ // cout << "alpha Bin: " << ialpha << endl; TString hname = Form("Pt%i_eta%i_alpha%i", ipt, ieta, ialpha); TString hname_gen = Form("GenAsymm_Pt%i_eta%i_alpha%i", ipt, ieta, ialpha); // cout << "hname: " << hname << endl; mc_file->cd(); tmp_mc = 0; tmp_gen = 0; tmp_mc = (TH1F*) gDirectory->FindObjectAny(hname); tmp_gen = (TH1F*) gDirectory->FindObjectAny(hname_gen); mc_smeared_file->cd(); tmp_mcsmeared = 0; tmp_gensmeared = 0; tmp_mcsmeared = (TH1F*) gDirectory->FindObjectAny(hname); tmp_gensmeared = (TH1F*) gDirectory->FindObjectAny(hname_gen); x.push_back(alpha.at(ialpha)); x_e.push_back(0.); double mc_width = GetAsymmWidth(tmp_mc, xq_IQW, yq_IQW); double mc_width_err = GetAsymmWidth(tmp_mc, xq_IQW, yq_IQW)/(TMath::Sqrt(2*tmp_mc->GetEffectiveEntries())); double data_width = GetAsymmWidth(tmp_mcsmeared, xq_IQW, yq_IQW); double data_width_err = GetAsymmWidth(tmp_mcsmeared, xq_IQW, yq_IQW)/(TMath::Sqrt(2*tmp_mcsmeared->GetEffectiveEntries())); double gen_width = GetAsymmWidth(tmp_gen, xq_IQW, yq_IQW); double gen_width_err = GetAsymmWidth(tmp_gen, xq_IQW, yq_IQW)/(TMath::Sqrt(2*tmp_gen->GetEffectiveEntries())); MCy.push_back( mc_width ); MCy_e.push_back( mc_width_err ); Datay.push_back( data_width ); Datay_e.push_back( data_width_err ); Geny.push_back( gen_width ); Geny_e.push_back( gen_width_err ); tmp_mc->Scale(tmp_mcsmeared->Integral()/tmp_mc->Integral()); tmp_gen->Scale(tmp_gensmeared->Integral()/tmp_gen->Integral()); // draw asymmetry histos TCanvas *c5 = new TCanvas("c5", "", 600, 600); c5->SetLogy(); // tmp_mc->GetYaxis()->SetRangeUser(0.1, 100.*tmp_mc->GetMaximum()); // tmp_mc->GetXaxis()->SetTitle("(p_{T,1} - p_{T,2})/(p_{T,1} + p_{T,2})"); tmp_mc->GetXaxis()->SetTitle("|A|"); tmp_mc->GetYaxis()->SetTitle("Events"); tmp_mc->SetLineColor(30); // tmp_mc->SetFillColor(30); tmp_mc->Rebin(10); tmp_mc->Draw("hist"); // gauss_mc->Draw("same"); tmp_mcsmeared->Rebin(10); tmp_mcsmeared->SetMarkerStyle(20); tmp_mcsmeared->Draw("histsame"); TPaveText *label = util::LabelFactory::createPaveTextWithOffset(3,0.8,0.01); label->AddText("Anti-k_{T} (R=0.5) PFCHS Jets"); label->AddText( Form("%0.1f #leq |#eta| #leq %0.1f, %3.0f #leq p_{T}^{ave} [GeV] #leq %3.0f", eta_bins[ieta], eta_bins[ieta+1], pt_bins[ipt], pt_bins[ipt+1]) ); label->AddText( Form("#alpha #leq %0.3f", alpha.at(ialpha)) ); label->Draw("same"); TLegend* leg1 = util::LabelFactory::createLegendColWithOffset(2,0.65,0.2); leg1->AddEntry(tmp_mcsmeared,"Herwig","L"); leg1->AddEntry(tmp_mc,"Pythia","L"); leg1->Draw(); if(ieta == 0 && ipt == 0 && ialpha == 0 ) c5->Print("ClosureTest/AsymmHistos" + suffix + ".eps("); else if(ieta == 4 && ipt == 12 && ialpha == 6) c5->Print("ClosureTest/AsymmHistos" + suffix + ".eps)"); else c5->Print("ClosureTest/AsymmHistos" + suffix + ".eps"); // draw gen-asymmetry histos TCanvas *c5b = new TCanvas("c5b", "", 600, 600); c5b->SetLogy(); // tmp_gen->GetYaxis()->SetRangeUser(0.1, 100.*tmp_gen->GetMaximum()); // tmp_gen->GetXaxis()->SetTitle("(p_{T,1} - p_{T,2})/(p_{T,1} + p_{T,2})"); tmp_gen->GetXaxis()->SetTitle("|A_{gen}|"); tmp_gen->GetYaxis()->SetTitle("Events"); tmp_gen->SetLineColor(30); // tmp_gen->SetFillColor(30); tmp_gen->Rebin(10); tmp_gen->Draw("hist"); // gauss_gen->Draw("same"); tmp_gensmeared->Rebin(10); tmp_gensmeared->SetMarkerStyle(20); tmp_gensmeared->Draw("histsame"); TPaveText *label2 = util::LabelFactory::createPaveTextWithOffset(3,0.8,0.01); label2->AddText("Anti-k_{T} (R=0.5) PFCHS Jets"); label2->AddText( Form("%0.1f #leq |#eta| #leq %0.1f, %3.0f #leq p_{T}^{ave} [GeV] #leq %3.0f", eta_bins[ieta], eta_bins[ieta+1], pt_bins[ipt], pt_bins[ipt+1]) ); label2->AddText( Form("#alpha #leq %0.3f", alpha.at(ialpha)) ); label2->Draw("same"); TLegend* leg2 = util::LabelFactory::createLegendColWithOffset(2,0.65,0.2); leg2->AddEntry(tmp_gensmeared,"Herwig","L"); leg2->AddEntry(tmp_gen,"Pythia","L"); leg2->Draw(); if(ieta == 0 && ipt == 0 && ialpha == 0 ) c5b->Print("ClosureTest/GenAsymmHistos" + suffix + ".eps("); else if(ieta == 4 && ipt == 12 && ialpha == 6) c5b->Print("ClosureTest/GenAsymmHistos" + suffix + ".eps)"); else c5b->Print("ClosureTest/GenAsymmHistos" + suffix + ".eps"); } // Covariance matrices needed for fitting TMatrixD y_cov_mc; TMatrixD y_cov_data; TMatrixD y_cov_gen; y_cov_mc.ResizeTo(alpha.size(), alpha.size()); y_cov_data.ResizeTo(alpha.size(), alpha.size()); y_cov_gen.ResizeTo(alpha.size(), alpha.size()); // fill covariance matrix for data and mc for(int ialpha=0; ialpha < alpha.size(); ++ialpha){ for (Int_t jalpha =0; jalpha < alpha.size(); jalpha++){ if( ialpha <= jalpha ) { double n1_mc = pow(MCy.at(ialpha),2)/(2*pow(MCy_e.at(ialpha),2)); double n2_mc = pow(MCy.at(jalpha),2)/(2*pow(MCy_e.at(jalpha),2)); double n1_data = pow(Datay.at(ialpha),2)/(2*pow(Datay_e.at(ialpha),2)); double n2_data = pow(Datay.at(jalpha),2)/(2*pow(Datay_e.at(jalpha),2)); double n1_gen = pow(Geny.at(ialpha),2)/(2*pow(Geny_e.at(ialpha),2)); double n2_gen = pow(Geny.at(jalpha),2)/(2*pow(Geny_e.at(jalpha),2)); y_cov_mc(ialpha, jalpha) = pow(MCy_e.at(ialpha),2) * pow((n1_mc/n2_mc),2)* (MCy.at(ialpha)/MCy.at(jalpha)); y_cov_data(ialpha, jalpha) = pow(Datay_e.at(ialpha),2) * pow((n1_data/n2_data),2)* (Datay.at(ialpha)/Datay.at(jalpha)); y_cov_gen(ialpha, jalpha) = pow(Geny_e.at(ialpha),2) * pow((n1_gen/n2_gen),2)* (Geny.at(ialpha)/Geny.at(jalpha)); } else { double n1_mc = pow(MCy.at(jalpha),2)/(2*pow(MCy_e.at(jalpha),2)); double n2_mc = pow(MCy.at(ialpha),2)/(2*pow(MCy_e.at(ialpha),2)); double n1_data = pow(Datay.at(jalpha),2)/(2*pow(Datay_e.at(jalpha),2)); double n2_data = pow(Datay.at(ialpha),2)/(2*pow(Datay_e.at(ialpha),2)); double n1_gen = pow(Geny.at(jalpha),2)/(2*pow(Geny_e.at(jalpha),2)); double n2_gen = pow(Geny.at(ialpha),2)/(2*pow(Geny_e.at(ialpha),2)); y_cov_mc(ialpha, jalpha) = pow(MCy_e.at(jalpha),2) * pow((n1_mc/n2_mc),2)* (MCy.at(jalpha)/MCy.at(ialpha)); y_cov_data(ialpha, jalpha) = pow(Datay_e.at(jalpha),2) * pow((n1_data/n2_data),2)* (Datay.at(jalpha)/Datay.at(ialpha)); y_cov_gen(ialpha, jalpha) = pow(Geny_e.at(jalpha),2) * pow((n1_gen/n2_gen),2)* (Geny.at(jalpha)/Geny.at(ialpha)); } } } //create TGraphErrors from previously defined vectors TGraphErrors *extrapol_MC = new TGraphErrors(alpha.size(),&x[0],&MCy[0],&x_e[0],&MCy_e[0]); TGraphErrors *extrapol_Data = new TGraphErrors(alpha.size(),&x[0],&Datay[0],&x_e[0],&Datay_e[0]); TGraphErrors *extrapol_Gen = new TGraphErrors(alpha.size(),&x[0],&Geny[0],&x_e[0],&Geny_e[0]); // fit linear extrapolation function TF1 *lin_extrapol_mc = new TF1("lin_extrapol_mc","[0]+[1]*x",0,alpha.back()+0.05); TF1 *lin_extrapol_data = new TF1("lin_extrapol_data","[0]+[1]*x",0,alpha.back()+0.05); TF1 *lin_extrapol_gen = new TF1("lin_extrapol_gen","[0]+[1]*x",0,alpha.back()+0.05); //fit extrapolation function to the TGraphErrors for data and MC // extrapol_MC->Fit("lin_extrapol_mc","Q","same",0,alpha.back()+0.05); // extrapol_Data->Fit("lin_extrapol_data","Q","same",0,alpha.back()+0.05); // fit mc data.reset(); data.x_val = x; data.y_val = MCy; data.y_cov.ResizeTo(alpha.size(), alpha.size()); data.y_cov = y_cov_mc; data.CheckPoints(); // choose start values for MC fit double slope = (MCy.at(MCy.size()-1) - MCy.at(MCy.size()-4))/(x.at(x.size()-1) - x.at(x.size()-4)); double d_slope = slope; double offset = MCy.at(MCy.size()-1) - (slope*x.at(x.size()-1)); double d_offset = offset; std::cout << "MC start values: " << "slope: " << slope << " offset: " << offset << std::endl; make_lin_fit(slope, d_slope, offset, d_offset); std::cout << "MC fit values: " << "slope: " << slope << " offset: " << offset << std::endl; lin_extrapol_mc->SetParameter(0, offset); lin_extrapol_mc->SetParError(0, d_offset); lin_extrapol_mc->SetParameter(1, slope); lin_extrapol_mc->SetParError(1, d_slope); extrapol_MC->GetListOfFunctions()->Add(lin_extrapol_mc); data.reset(); // fit data data.x_val = x; data.y_val = Datay; data.y_cov.ResizeTo(alpha.size(), alpha.size()); data.y_cov = y_cov_data; data.CheckPoints(); // choose start values for data fit slope = (Datay.at(Datay.size()-1) - Datay.at(Datay.size()-4))/(x.at(x.size()-1) - x.at(x.size()-4)); d_slope = slope; offset = Datay.at(Datay.size()-1) - (slope*x.at(x.size()-1)); d_offset = offset; std::cout << "Data start values: " << "slope: " << slope << " offset: " << offset << std::endl; make_lin_fit(slope, d_slope, offset, d_offset); std::cout << "Data fit values: " << "slope: " << slope << " offset: " << offset << std::endl; lin_extrapol_data->SetParameter(0, offset); lin_extrapol_data->SetParError(0, d_offset); lin_extrapol_data->SetParameter(1, slope); lin_extrapol_data->SetParError(1, d_slope); extrapol_Data->GetListOfFunctions()->Add(lin_extrapol_data); data.reset(); // fit gen data.x_val = x; data.y_val = Geny; data.y_cov.ResizeTo(alpha.size(), alpha.size()); data.y_cov = y_cov_gen; data.CheckPoints(); // choose start values for gen fit slope = (Geny.at(Geny.size()-1) - Geny.at(Geny.size()-4))/(x.at(x.size()-1) - x.at(x.size()-4)); d_slope = slope; offset = Geny.at(Geny.size()-1) - (slope*x.at(x.size()-1)); d_offset = offset; std::cout << "Gen start values: " << "slope: " << slope << " offset: " << offset << std::endl; make_lin_fit(slope, d_slope, offset, d_offset); std::cout << "Gen fit values: " << "slope: " << slope << " offset: " << offset << std::endl; lin_extrapol_gen->SetParameter(0, offset); lin_extrapol_gen->SetParError(0, d_offset); lin_extrapol_gen->SetParameter(1, slope); lin_extrapol_gen->SetParError(1, d_slope); extrapol_Gen->GetListOfFunctions()->Add(lin_extrapol_gen); data.reset(); // draw extrapolations data + mc TCanvas *c = new TCanvas("c","",600,600); std::pair <float,float> minMaxPair = determineMinMax(extrapol_Data); c->DrawFrame(0,minMaxPair.first*0.5-0.05,alpha.back()+0.05,minMaxPair.second*1.47,(";Threshold #alpha_{max};#sigma_{A}")); extrapol_MC->SetMarkerStyle(20); extrapol_MC->SetMarkerColor(kRed+1); extrapol_MC->SetLineColor(kRed+1); extrapol_MC->Draw("P"); extrapol_Data->SetMarkerStyle(20); extrapol_Data->SetMarkerColor(kBlack); extrapol_Data->SetLineColor(kBlack); extrapol_Data->Draw("Psame"); TF1* MCTemp = new TF1(); TF1* DataTemp = new TF1(); extrapol_MC->GetFunction("lin_extrapol_mc")->SetLineColor(kRed+1); extrapol_MC->GetFunction("lin_extrapol_mc")->SetLineStyle(2); extrapol_Data->GetFunction("lin_extrapol_data")->SetLineColor(kBlack); extrapol_Data->GetFunction("lin_extrapol_data")->SetLineStyle(2); MCTemp=(TF1*) extrapol_MC->GetFunction("lin_extrapol_mc")->Clone(); DataTemp=(TF1*) extrapol_Data->GetFunction("lin_extrapol_data")->Clone(); MCTemp->SetRange(0.1,1); MCTemp->SetLineStyle(1); MCTemp->Draw("same"); DataTemp->SetRange(0.1,1); DataTemp->SetLineStyle(1); DataTemp->Draw("same"); TPaveText *label = util::LabelFactory::createPaveTextWithOffset(2,1.0,0.5); label->AddText("Anti-k_{T} (R=0.5) PFchs Jets"); label->AddText( Form("%0.1f #leq |#eta| #leq %0.1f, %3.0f #leq #bar{ p}_{T} [GeV] #leq %3.0f", eta_bins[ieta], eta_bins[ieta+1], pt_bins[ipt], pt_bins[ipt+1]) ); label->Draw("same"); TLegend* leg1 = util::LabelFactory::createLegendWithOffset(2,0.6); leg1->AddEntry(extrapol_Data,"Extrapolation (MC smeared)","LP"); leg1->AddEntry(extrapol_MC,"Extrapolation (MC)","LP"); leg1->Draw(); cmsPrel(-1, false , 8); TString name; name = Form("ClosureTest/Extrapol_Eta%i_pt%i" + suffix + ".eps", ieta, ipt); c->Print(name); TCanvas *cb = new TCanvas("c","",600,600); std::pair <float,float> minMaxPair2 = determineMinMax(extrapol_Data); cb->DrawFrame(0,minMaxPair2.first*0.5-0.05,alpha.back()+0.05,minMaxPair2.second*1.47,(";Threshold #alpha_{max, gen};#sigma_{A, gen}")); extrapol_Gen->SetMarkerStyle(20); extrapol_Gen->SetMarkerColor(kBlue+1); extrapol_Gen->SetLineColor(kBlue+1); extrapol_Gen->Draw("P"); TF1* GenTemp = new TF1(); extrapol_Gen->GetFunction("lin_extrapol_gen")->SetLineColor(kBlue+1); extrapol_Gen->GetFunction("lin_extrapol_gen")->SetLineStyle(2); GenTemp=(TF1*) extrapol_Gen->GetFunction("lin_extrapol_gen")->Clone(); GenTemp->SetRange(0.1,1); GenTemp->SetLineStyle(1); GenTemp->Draw("same"); TPaveText *label2 = util::LabelFactory::createPaveTextWithOffset(2,1.0,0.05); label2->AddText("Anti-k_{T} (R=0.5) PFchs Jets"); label2->AddText( Form("%0.1f #leq |#eta| #leq %0.1f, %3.0f #leq #bar{ p}_{T} [GeV] #leq %3.0f", eta_bins[ieta], eta_bins[ieta+1], pt_bins[ipt], pt_bins[ipt+1]) ); label2->Draw("same"); TLegend* leg2 = util::LabelFactory::createLegendWithOffset(2,0.15); leg2->AddEntry(extrapol_Gen,"Extrapolation (PLI)","LP"); leg2->Draw(); cmsPrel(-1, false , 8); TString name2; name2 = Form("ClosureTest/Extrapol_Eta%i_pt%i_gen" + suffix + ".eps", ieta, ipt); cb->Print(name2); float par_data = lin_extrapol_data->GetParameter(0); float par_data_err = lin_extrapol_data->GetParError(0); float par_mc = lin_extrapol_mc->GetParameter(0); float par_mc_err = lin_extrapol_mc->GetParError(0); float par_gen = lin_extrapol_gen->GetParameter(0); float par_gen_err = lin_extrapol_gen->GetParError(0); cout << "ieta : " << ieta << " ipt : " << ipt << endl; cout << "Parameter data: " << par_data << endl; cout << "Parameter error data: " << par_data_err << endl; cout << "Parameter mc: " << par_mc << endl; cout << "Parameter error mc: " << par_mc_err << endl; cout << "Parameter gen: " << par_gen << endl; cout << "Parameter error gen: " << par_gen_err << endl; extrapolated_mcsmeared->SetBinContent(ipt+1, par_data); extrapolated_mcsmeared->SetBinError(ipt+1, par_data_err); extrapolated_mc->SetBinContent(ipt+1, par_mc); extrapolated_mc->SetBinError(ipt+1, par_mc_err); extrapolated_gen->SetBinContent(ipt+1, par_gen); extrapolated_gen->SetBinError(ipt+1, par_gen_err); float par_data_pli_corr = 0; float par_data_pli_corr_err = 0; float par_mc_pli_corr = 0; float par_mc_pli_corr_err = 0; if(par_gen > 0 && par_data > 0 && par_mc > 0 && par_data > par_gen && par_mc > par_gen) { par_data_pli_corr = TMath::Sqrt(pow(par_data,2) - pow(par_gen,2)); par_data_pli_corr_err = TMath::Sqrt( pow(par_data,2)/(pow(par_data,2) - pow(par_gen,2)) * pow(par_data_err,2) + pow(par_gen,2)/(pow(par_data,2) - pow(par_gen,2)) * pow(par_gen_err,2)); par_mc_pli_corr = TMath::Sqrt(pow(par_mc,2) - pow(par_gen,2)); par_mc_pli_corr_err = TMath::Sqrt( pow(par_mc,2)/(pow(par_mc,2) - pow(par_gen,2)) * pow(par_mc_err,2) + pow(par_gen,2)/(pow(par_mc,2) - pow(par_gen,2)) * pow(par_gen_err,2)); } extrapolated_mcsmeared_with_pli->SetBinContent(ipt+1, par_data_pli_corr); extrapolated_mcsmeared_with_pli->SetBinError(ipt+1, par_data_pli_corr_err); extrapolated_mc_with_pli->SetBinContent(ipt+1, par_mc_pli_corr); extrapolated_mc_with_pli->SetBinError(ipt+1, par_mc_pli_corr_err); cout << "Parameter data after pli: " << par_data_pli_corr << endl; cout << "Parameter error data after pli: " << par_data_pli_corr_err << endl; cout << "Parameter mc after pli: " << par_mc_pli_corr << endl; cout << "Parameter error mc after pli: " << par_mc_pli_corr_err << endl; } // --------------------------------------- // // calc data/mc ratio and fit with constant TH1F* ratio = new TH1F(*extrapolated_mc); TH1F* ratio_with_pli = new TH1F(*extrapolated_mc); ratio->Divide(extrapolated_mcsmeared, extrapolated_mc, 1, 1); ratio_with_pli->Divide(extrapolated_mcsmeared_with_pli, extrapolated_mc_with_pli, 1, 1); TF1 *fit_const = new TF1("fit_const", "[0]", ratio->GetXaxis()->GetXmin(), ratio->GetXaxis()->GetXmax()); fit_const->SetParameters(0, 1.1); fit_const->SetParName(0, "const"); ratio->Fit("fit_const", "", "same"); ratio->GetXaxis()->SetTitle("#bar{ p}_{T} [GeV]"); ratio->GetYaxis()->SetRangeUser(0.7, 1.4); ratio->GetYaxis()->SetTitle("MC_{smeared}/MC ratio (const fit)"); RatioVsEta->SetBinContent(ieta+1, ratio->GetFunction("fit_const")->GetParameter(0)); RatioVsEta->SetBinError(ieta+1, ratio->GetFunction("fit_const")->GetParError(0)); TCanvas *c3 = new TCanvas("c3","",600,600); c3->SetLogx(); ratio->Draw(); TString name3; name3 = Form("ClosureTest/ExtrapolRatio_Eta%i" + suffix + ".eps", ieta); c3->Print(name3); ratio_with_pli->Fit("fit_const", "", "same"); ratio_with_pli->GetXaxis()->SetTitle("#bar{ p}_{T} [GeV]"); ratio_with_pli->GetYaxis()->SetRangeUser(0.7, 1.4); ratio_with_pli->GetYaxis()->SetTitle("MC_{smeared}/MC ratio (const fit)"); TCanvas *c3b = new TCanvas("c3","",600,600); c3b->SetLogx(); ratio_with_pli->Draw(); TString name4; name4 = Form("ClosureTest/ExtrapolRatio_Eta%i_with_pli" + suffix + ".eps", ieta); c3b->Print(name4); RatioVsEta_with_pli->SetBinContent(ieta+1, ratio_with_pli->GetFunction("fit_const")->GetParameter(0)); RatioVsEta_with_pli->SetBinError(ieta+1, ratio_with_pli->GetFunction("fit_const")->GetParError(0)); } // draw data/mc scaling factors vs. eta TCanvas *c4 = new TCanvas(); RatioVsEta->GetYaxis()->SetRangeUser(0.7, 1.3); RatioVsEta->GetXaxis()->SetTitle("|#eta|"); RatioVsEta->GetYaxis()->SetTitle("MC_{smeared} /MC ratio (const fit)"); RatioVsEta->Draw(); c4->Print("ClosureTest/ScalingFactorsVsEta" + suffix + ".eps"); cout << "//----------------------------------------------//" << endl; cout << "Scaling factors without PLI: " << endl; cout << "Ratio eta1: " << RatioVsEta->GetBinContent(1) << " +- " << RatioVsEta->GetBinError(1) << endl; cout << "Ratio eta2: " << RatioVsEta->GetBinContent(2) << " +- " << RatioVsEta->GetBinError(2) << endl; cout << "Ratio eta3: " << RatioVsEta->GetBinContent(3) << " +- " << RatioVsEta->GetBinError(3) << endl; cout << "Ratio eta4: " << RatioVsEta->GetBinContent(4) << " +- " << RatioVsEta->GetBinError(4) << endl; cout << "Ratio eta5: " << RatioVsEta->GetBinContent(5) << " +- " << RatioVsEta->GetBinError(5) << endl; cout << "Ratio eta6: " << RatioVsEta->GetBinContent(6) << " +- " << RatioVsEta->GetBinError(6) << endl; cout << "Ratio eta7: " << RatioVsEta->GetBinContent(7) << " +- " << RatioVsEta->GetBinError(7) << endl; cout << "//----------------------------------------------//" << endl; TCanvas *c4b = new TCanvas(); RatioVsEta_with_pli->GetYaxis()->SetRangeUser(0.7, 1.4); RatioVsEta_with_pli->GetXaxis()->SetTitle("|#eta|"); RatioVsEta_with_pli->GetYaxis()->SetTitle("MC_{smeared} /MC ratio (const fit)"); RatioVsEta_with_pli->Draw(); c4b->Print("ClosureTest/ScalingFactorsVsEta_with_pli" + suffix + ".eps"); cout << "//----------------------------------------------//" << endl; cout << "Scaling factors with PLI: " << endl; cout << "Ratio eta1: " << RatioVsEta_with_pli->GetBinContent(1) << " +- " << RatioVsEta_with_pli->GetBinError(1) << endl; cout << "Ratio eta2: " << RatioVsEta_with_pli->GetBinContent(2) << " +- " << RatioVsEta_with_pli->GetBinError(2) << endl; cout << "Ratio eta3: " << RatioVsEta_with_pli->GetBinContent(3) << " +- " << RatioVsEta_with_pli->GetBinError(3) << endl; cout << "Ratio eta4: " << RatioVsEta_with_pli->GetBinContent(4) << " +- " << RatioVsEta_with_pli->GetBinError(4) << endl; cout << "Ratio eta5: " << RatioVsEta_with_pli->GetBinContent(5) << " +- " << RatioVsEta_with_pli->GetBinError(5) << endl; cout << "Ratio eta6: " << RatioVsEta_with_pli->GetBinContent(6) << " +- " << RatioVsEta_with_pli->GetBinError(6) << endl; cout << "Ratio eta7: " << RatioVsEta_with_pli->GetBinContent(7) << " +- " << RatioVsEta_with_pli->GetBinError(7) << endl; cout << "//----------------------------------------------//" << endl; }
void compare_kFSR_em(TString dir1, TString dir2, TString algo="PF", TString dir_prefix="KOSTAS_L1_on_pt_plain_", TString label_dir1="", TString label_dir2="",TString binning_select ="kostas"){ setTDRStyle(); TCanvas* c = new TCanvas("c","",600,600); TLatex latex; latex.SetNDC(); latex.SetTextSize(0.05); latex.SetTextAlign(13); //align at top Double_t kFSR_extrapol_ymin=0.95; Double_t kFSR_extrapol_ymax=1.1; TFile *inf_Dir1; inf_Dir1 = new TFile(dir_prefix+dir1+"/"+binning_select+"_use_easy_mean_TuneZ2_TuneZ2_" + algo + "_kFSR_histos.root","OPEN"); // inf_Dir1 = new TFile(dir_prefix+dir1+"/"+binning_select+"_TuneZ2_TuneZ2_" + algo + "_kFSR_histos.root","OPEN"); TFile *inf_Dir2; inf_Dir2 = new TFile(dir_prefix+dir2+"/"+binning_select+"_use_easy_mean_TuneZ2_TuneZ2_" + algo + "_kFSR_histos.root","OPEN"); // inf_Dir2 = new TFile(dir_prefix+dir2+"/"+binning_select+"_TuneZ2_TuneZ2_" + algo + "_kFSR_histos.root","OPEN"); if(label_dir1!="")dir1=label_dir1; if(label_dir2!="")dir2=label_dir2; Double_t chisquared1, ndf1, chisquared2, ndf2; char buffer [50]; import_kFSR_vs_Abseta_histo_res1_Dir1 = (TH1D*)inf_Dir1->Get("kFSR_vs_Abseta_histo_res1"); import_kFSR_vs_Abseta_histo_res1_Dir2 = (TH1D*)inf_Dir2->Get("kFSR_vs_Abseta_histo_res1"); import_kFSR_vs_Abseta_histo_res1_Dir1->SetStats(0); import_kFSR_vs_Abseta_histo_res1_Dir2->SetStats(0); import_kFSR_vs_Abseta_histo_res1_Dir1->GetYaxis()->SetTitle("k_{rad} correction"); import_kFSR_vs_Abseta_histo_res1_Dir2->GetYaxis()->SetTitle("k_{rad} correction"); import_kFSR_vs_Abseta_histo_res1_Dir1->Draw(""); import_kFSR_vs_Abseta_histo_res1_Dir1->GetYaxis()->SetRangeUser(kFSR_extrapol_ymin,kFSR_extrapol_ymax); TF1 *kFSR_fit = new TF1("kFSR_fit","[0]+[1]*cosh(x)/(1+cosh(x)*[2])",import_kFSR_vs_Abseta_histo_res1_Dir1->GetXaxis()->GetXmin(),import_kFSR_vs_Abseta_histo_res1_Dir1->GetXaxis()->GetXmax()); //was used before... import_kFSR_vs_Abseta_histo_res1_Dir1->GetFunction("kFSR_fit")->GetParameters(); kFSR_fit->SetParameters(import_kFSR_vs_Abseta_histo_res1_Dir1->GetFunction("kFSR_fit")->GetParameters()); import_kFSR_vs_Abseta_histo_res1_Dir1->GetFunction("kFSR_fit")->SetLineColor(1); kFSR_fit->SetLineColor(2); kFSR_fit->SetLineWidth(2); TFitResultPtr r = import_kFSR_vs_Abseta_histo_res1_Dir1->Fit(kFSR_fit,"S E"); TMatrixDSym cov = r->GetCovarianceMatrix(); // to access the covariance matrix chisquared1= r->Chi2(); ndf1= r->Ndf(); TGraphErrors* band1= get_error_band(cov, kFSR_fit); band1->SetFillColor(15); // band1->SetFillStyle(3001); band1->Draw("same 3"); import_kFSR_vs_Abseta_histo_res1_Dir1->Draw("e same"); cmsPrel(intLumi=36, false); TLine *line = new TLine(import_kFSR_vs_Abseta_histo_res1_Dir1->GetXaxis()->GetXmin(),1.,import_kFSR_vs_Abseta_histo_res1_Dir1->GetXaxis()->GetXmax(),1.); line->Draw(); line->SetLineStyle(2); line->SetLineColor(1); sprintf (buffer, "Fit uncertainty (#chi^{2}/ndf = %.1f / %d )", chisquared1, ndf1); cout << buffer << endl; TLegend *leg_kFSR1; leg_kFSR1 = new TLegend(0.2,0.70,0.65,0.85); leg_kFSR1->SetFillColor(kWhite); leg_kFSR1->SetTextFont(42); // leg->SetHeader("Legende"); leg_kFSR1->AddEntry(kFSR_fit,"p_{0}+ #frac{p_{1}cosh(|#eta|)}{1+p_{2}cosh(|#eta|)}","l"); leg_kFSR1->AddEntry(band1,buffer,"f"); // leg_kFSR->AddEntry(import_kFSR_vs_Abseta_histo_res1_Dir1,"Data","lep"); leg_kFSR1->Draw(); //"kFSR_comp_"+ cmsPrel(intLumi=36, false); c->SaveAs(GetDateDir()+"/kFSR_comp_"+dir1+"_kFSR_"+ algo +"_em.eps"); import_kFSR_vs_Abseta_histo_res1_Dir2->Draw("e"); import_kFSR_vs_Abseta_histo_res1_Dir2->GetYaxis()->SetRangeUser(kFSR_extrapol_ymin,kFSR_extrapol_ymax); r = import_kFSR_vs_Abseta_histo_res1_Dir2->Fit(kFSR_fit,"S"); cov = r->GetCovarianceMatrix(); // to access the covariance matrix TGraphErrors* band2= get_error_band(cov, kFSR_fit); band2->SetFillColor(15); // band2->SetFillStyle(3001); band2->Draw("same 3"); chisquared2= r->Chi2(); ndf2= r->Ndf(); cout << "CHI2: " << chisquared2 << " ndf: " << ndf2 << endl; import_kFSR_vs_Abseta_histo_res1_Dir2->Draw("e same"); sprintf (buffer, "Fit uncertainty (#chi^{2}/ndf = %.1f / %d )", chisquared2, ndf2); cout << buffer << endl; TLegend *leg_kFSR2; leg_kFSR2 = new TLegend(0.2,0.70,0.65,0.85); leg_kFSR2->SetFillColor(kWhite); leg_kFSR2->SetTextFont(42); // leg->SetHeader("Legende"); leg_kFSR2->AddEntry(kFSR_fit,"p_{0}+ #frac{p_{1}cosh(|#eta|)}{1+p_{2}cosh(|#eta|)}","l"); leg_kFSR2->AddEntry(band2,buffer,"f"); // leg_kFSR->AddEntry(import_kFSR_vs_Abseta_histo_res1_Dir1,"Data","lep"); leg_kFSR2->Draw(); line->Draw(); cmsPrel(intLumi=36, false); c->SaveAs(GetDateDir()+"/kFSR_comp_"+dir2+"_kFSR_"+ algo +"_em.eps"); TLegend *leg_kFSR_comb; leg_kFSR_comb = new TLegend(0.2,0.60,0.65,0.85); leg_kFSR_comb->SetFillColor(kWhite); leg_kFSR_comb->SetTextFont(42); // leg->SetHeader("Legende"); // leg_kFSR_comb->AddEntry(import_kFSR_vs_Abseta_histo_res1_Dir1,"p_{0}+ #frac{p_{1}cosh(|#eta|)}{1+p_{2}cosh(|#eta|)} ("+dir1+")","lp"); // leg_kFSR_comb->AddEntry(band1,"Fit uncertainty ("+dir1+")","f"); // leg_kFSR_comb->AddEntry(import_kFSR_vs_Abseta_histo_res1_Dir2,"p_{0}+ #frac{p_{1}cosh(|#eta|)}{1+p_{2}cosh(|#eta|)} ("+dir2+")","lp"); // leg_kFSR_comb->AddEntry(band2,"Fit uncertainty ("+dir2+")","f"); leg_kFSR_comb->AddEntry(import_kFSR_vs_Abseta_histo_res1_Dir1,dir1,"lp"); // leg_kFSR_comb->AddEntry(band1,"Fit uncertainty","f"); leg_kFSR_comb->AddEntry(import_kFSR_vs_Abseta_histo_res1_Dir2,dir2,"lp"); // leg_kFSR_comb->AddEntry(band2,"Fit uncertainty","f"); import_kFSR_vs_Abseta_histo_res1_Dir2->SetLineColor(2); import_kFSR_vs_Abseta_histo_res1_Dir2->SetMarkerColor(2); import_kFSR_vs_Abseta_histo_res1_Dir2->SetMarkerStyle(21); import_kFSR_vs_Abseta_histo_res1_Dir1->GetFunction("kFSR_fit")->SetLineColor(1); import_kFSR_vs_Abseta_histo_res1_Dir2->GetFunction("kFSR_fit")->SetLineColor(2); // band2->SetLineColor(); // // import_kFSR_vs_Abseta_histo_res1_Dir1->Draw("e"); // band1->Draw("same 3"); // import_kFSR_vs_Abseta_histo_res1_Dir2->Draw("same e"); // band2->SetFillColor(42); // band2->SetFillStyle(3001); // band2->Draw("same 3"); // // import_kFSR_vs_Abseta_histo_res1_Dir1->Draw("e same"); // import_kFSR_vs_Abseta_histo_res1_Dir2->Draw("e same"); // // leg_kFSR_comb->Draw(); // cmsPrel(intLumi=36, false); // import_kFSR_vs_Abseta_histo_res1_Dir1->Draw("hist e"); // band1->Draw("same 3"); import_kFSR_vs_Abseta_histo_res1_Dir2->Draw("hist same e"); band2->SetFillColor(42); band2->SetFillStyle(3001); // band2->Draw("same 3"); import_kFSR_vs_Abseta_histo_res1_Dir1->Draw("hist e same"); import_kFSR_vs_Abseta_histo_res1_Dir2->Draw("hist e same"); leg_kFSR_comb->Draw(); cmsPrel(intLumi=36, false); latex.DrawLatex(.25,.9,algo+" Jets"); c->SaveAs(GetDateDir()+"/kFSR_comp_"+dir1+"_"+dir2+"_kFSR_"+ algo +"_em.eps"); }
void compare_Residuals_em(TString dir1, TString dir2, TString algo="PF", TString dir_prefix="KOSTAS_L1_on_pt_plain_", TString label_dir1="", TString label_dir2="",TString binning_select ="kostas"){ setTDRStyle(); TCanvas* c = new TCanvas("c","",600,600); TFile *inf_Dir1; inf_Dir1 = new TFile(dir_prefix+dir1+"/res_corrections_histos.root","OPEN"); TFile *inf_Dir2; inf_Dir2 = new TFile(dir_prefix+dir2+"/res_corrections_histos.root","OPEN"); if(label_dir1!="")dir1=label_dir1; if(label_dir2!="")dir2=label_dir2; TH1D* import_FSRcorr_residuals_eta_res1_Dir1; TH1D* import_FSRcorr_residuals_eta_res1_Dir2; TH1D* import_FSRcorr_residuals_Abseta_res1_Dir1; TH1D* import_FSRcorr_residuals_Abseta_res1_Dir2; import_FSRcorr_residuals_eta_res1_Dir1 = (TH1D*)inf_Dir1->Get(""+binning_select+"_use_coarse_kFSRAbs_use_easy_mean_TuneZ2_"+algo+"_eta_res_hist"); import_FSRcorr_residuals_eta_res1_Dir2 = (TH1D*)inf_Dir2->Get(""+binning_select+"_use_coarse_kFSRAbs_use_easy_mean_TuneZ2_"+algo+"_eta_res_hist"); import_FSRcorr_residuals_Abseta_res1_Dir1 = (TH1D*)inf_Dir1->Get(""+binning_select+"_use_coarse_kFSRAbs_use_easy_mean_TuneZ2_"+algo+"_Abseta_res_hist"); import_FSRcorr_residuals_Abseta_res1_Dir2 = (TH1D*)inf_Dir2->Get(""+binning_select+"_use_coarse_kFSRAbs_use_easy_mean_TuneZ2_"+algo+"_Abseta_res_hist"); import_FSRcorr_residuals_eta_res1_Dir1->SetStats(0); import_FSRcorr_residuals_eta_res1_Dir2->SetStats(0); import_FSRcorr_residuals_eta_res1_Dir1->GetYaxis()->SetTitle("Residual Correction"); import_FSRcorr_residuals_eta_res1_Dir2->GetYaxis()->SetTitle("Residual Correction"); import_FSRcorr_residuals_eta_res1_Dir1->GetXaxis()->SetTitle("#eta"); import_FSRcorr_residuals_eta_res1_Dir2->GetXaxis()->SetTitle("#eta"); import_FSRcorr_residuals_Abseta_res1_Dir1->SetStats(0); import_FSRcorr_residuals_Abseta_res1_Dir2->SetStats(0); import_FSRcorr_residuals_Abseta_res1_Dir1->GetYaxis()->SetTitle("Residual Correction"); import_FSRcorr_residuals_Abseta_res1_Dir2->GetYaxis()->SetTitle("Residual Correction"); import_FSRcorr_residuals_Abseta_res1_Dir1->GetXaxis()->SetTitle("|#eta|"); import_FSRcorr_residuals_Abseta_res1_Dir2->GetXaxis()->SetTitle("|#eta|"); //ETA import_FSRcorr_residuals_eta_res1_Dir1->SetLineColor(1); import_FSRcorr_residuals_eta_res1_Dir1->SetMarkerColor(1); import_FSRcorr_residuals_eta_res1_Dir1->SetMarkerStyle(24); import_FSRcorr_residuals_eta_res1_Dir1->GetYaxis()->SetRangeUser(0.95,1.25); import_FSRcorr_residuals_eta_res1_Dir1->Draw(""); import_FSRcorr_residuals_eta_res1_Dir2->SetLineColor(2); import_FSRcorr_residuals_eta_res1_Dir2->SetMarkerColor(2); import_FSRcorr_residuals_eta_res1_Dir2->SetMarkerStyle(21); import_FSRcorr_residuals_eta_res1_Dir2->Draw("same"); TLegend *leg_eta_comb; leg_eta_comb = new TLegend(0.2,0.80,0.7,0.9); leg_eta_comb->SetFillColor(kWhite); leg_eta_comb->SetTextFont(42); // leg->SetHeader("Legende"); // leg_eta_comb->AddEntry(import_FSRcorr_residuals_eta_res1_Dir1,"FSR-corrected residuals ("+dir1+")","p"); // leg_eta_comb->AddEntry(import_FSRcorr_residuals_eta_res1_Dir2,"FSR-corrected residuals ("+dir2+")","p"); leg_eta_comb->AddEntry(import_FSRcorr_residuals_eta_res1_Dir1,dir1,"p"); leg_eta_comb->AddEntry(import_FSRcorr_residuals_eta_res1_Dir2,dir2,"p"); leg_eta_comb->Draw(); //"ResComp_"+ cmsPrel(intLumi=36, false); c->SaveAs(GetDateDir()+"/ResComp_"+dir1+"_"+dir2+"_FSRcorr_residuals_eta_"+ algo +"_em.eps"); import_FSRcorr_residuals_eta_res1_Dir1->Divide(import_FSRcorr_residuals_eta_res1_Dir1,import_FSRcorr_residuals_eta_res1_Dir2); import_FSRcorr_residuals_eta_res1_Dir1->Draw(); import_FSRcorr_residuals_eta_res1_Dir1->GetYaxis()->SetRangeUser(0.95,1.05); import_FSRcorr_residuals_eta_res1_Dir1->GetYaxis()->SetTitle("R("+dir1+")/R("+dir2+")"); TLine *line_eta = new TLine(import_FSRcorr_residuals_eta_res1_Dir1->GetXaxis()->GetXmin(),1.,import_FSRcorr_residuals_eta_res1_Dir1->GetXaxis()->GetXmax(),1.); line_eta->Draw(); line_eta->SetLineStyle(2); line_eta->SetLineColor(1); cmsPrel(intLumi=36, false); c->SaveAs(GetDateDir()+"/ResComp_"+dir1+"_"+dir2+"_FSRcorr_residuals_ratio_eta_"+ algo +"_em.eps"); //ABSETA import_FSRcorr_residuals_Abseta_res1_Dir1->SetLineColor(1); import_FSRcorr_residuals_Abseta_res1_Dir1->SetMarkerColor(1); import_FSRcorr_residuals_Abseta_res1_Dir1->SetMarkerStyle(24); import_FSRcorr_residuals_Abseta_res1_Dir1->GetYaxis()->SetRangeUser(0.95,1.25); import_FSRcorr_residuals_Abseta_res1_Dir1->Draw(""); import_FSRcorr_residuals_Abseta_res1_Dir2->SetLineColor(2); import_FSRcorr_residuals_Abseta_res1_Dir2->SetMarkerColor(2); import_FSRcorr_residuals_Abseta_res1_Dir2->SetMarkerStyle(21); import_FSRcorr_residuals_Abseta_res1_Dir2->Draw("same"); TLegend *leg_Abseta_comb; leg_Abseta_comb = new TLegend(0.2,0.80,0.7,0.9); leg_Abseta_comb->SetFillColor(kWhite); leg_Abseta_comb->SetTextFont(42); // leg->SetHeader("Legende"); leg_Abseta_comb->AddEntry(import_FSRcorr_residuals_Abseta_res1_Dir1,"FSR-corrected residuals ("+dir1+")","p"); leg_Abseta_comb->AddEntry(import_FSRcorr_residuals_Abseta_res1_Dir2,"FSR-corrected residuals ("+dir2+")","p"); leg_Abseta_comb->Draw(); cmsPrel(intLumi=36, false); c->SaveAs(GetDateDir()+"/ResComp_"+dir1+"_"+dir2+"_FSRcorr_residuals_Abseta_"+ algo +"_em.eps"); import_FSRcorr_residuals_Abseta_res1_Dir1->Divide(import_FSRcorr_residuals_Abseta_res1_Dir1,import_FSRcorr_residuals_Abseta_res1_Dir2); import_FSRcorr_residuals_Abseta_res1_Dir1->Draw(); import_FSRcorr_residuals_Abseta_res1_Dir1->GetYaxis()->SetRangeUser(0.95,1.05); import_FSRcorr_residuals_Abseta_res1_Dir1->GetYaxis()->SetTitle("R("+dir1+")/R("+dir2+")"); TLine *line_Abseta = new TLine(import_FSRcorr_residuals_Abseta_res1_Dir1->GetXaxis()->GetXmin(),1.,import_FSRcorr_residuals_Abseta_res1_Dir1->GetXaxis()->GetXmax(),1.); line_Abseta->Draw(); line_Abseta->SetLineStyle(2); line_Abseta->SetLineColor(1); cmsPrel(intLumi=36, false); c->SaveAs(GetDateDir()+"/ResComp_"+dir1+"_"+dir2+"_FSRcorr_residuals_ratio_Abseta_"+ algo +"_em.eps"); }
void finalPlotsPt(int type,bool skip3rd=false){ //----- //TString inputFolderName="./setupZ3/"; //TString outputFolderName="./finalPlotsZ3/"; TString xLabel; TString yLabel; TString yLabelResp; TString yLabelErr; double lRange,hRange; TString text1a,text1b,leg1a,leg1b; TString text2a,text2b,leg2a,leg2b; setLabels(type, xLabel,yLabel,yLabelResp,yLabelErr, text1a,text1b,leg1a,leg1b, text2a,text2b,leg2a,leg2b, lRange,hRange); //setStyle(); //---- stringstream stream; stream << type; TString counter = stream.str(); //TString fileName1="./finalPlotsR27th/histos"+counter+".root"; TString fileName1="./finalPlotsR27thSol6/histos"+counter+".root"; //TString fileName1="./finalPlotsR27thSol7/histos"+counter+".root"; TString outputName1="final_type"+counter+".pdf"; TString outputName2="final_type"+counter+".png"; TString outputName3="final_type"+counter+".eps"; TFile* f1 = new TFile(fileName1); TH1F* hData1 = (TH1F*) f1->Get("plotDataFit"); TH1F* hSim1 = (TH1F*) f1->Get("plotSimFit"); //TH1F* hMC1 = (TH1F*) f1->Get("plotReso"); //------ TCanvas* canvas1 = new TCanvas("canvas1","canvas1",0,0,500,500); canvas1->cd(); if(type==5) canvas1->SetLogy(1); hData1->SetMaximum(hRange); hData1->SetMinimum(lRange); hSim1->SetMaximum(hRange); hSim1->SetMinimum(lRange); //MarkersSyle: //20,21,22: bullet,square,triangle //24,25,26: as above, but empty symbols //Colors: //1,2: black, red hData1->SetMarkerStyle(20); hData1->SetMarkerColor(1); hData1->SetMarkerSize(1.5); hSim1->SetMarkerStyle(20); hSim1->SetMarkerColor(2); hSim1->SetMarkerSize(1.5); //setStyle(); hSim1->SetYTitle(yLabel); hSim1->SetXTitle(xLabel); gStyle->SetErrorX(0.5); /* //TF1* finalFit = new TF1("finalFit","sqrt( ([0]/x)*([0]/x)+[1]*[1])",1.0,10); TF1* finalFit = new TF1("finalFit","[0]/x + [1]"); finalFit->SetParameter(0,6); finalFit->SetParameter(1,20); finalFit->SetParName(0,"MultipleScattering term"); finalFit->SetParName(1,"SinglePointResolution term"); finalFit->SetLineColor(4); finalFit->SetLineWidth(2.5); finalFit->SetLineStyle(1); //hSim1->Fit("finalFit","","",1.0,10); //hData1->Fit("finalFit","","",1.0,10); double sA,sB,dA,dB; double sAErr,sBErr,dAErr,dBErr; hSim1->Fit("finalFit","N"); sA = finalFit->GetParameter(0); sB = finalFit->GetParameter(1); hData1->Fit("finalFit"); dA = finalFit->GetParameter(0); dB = finalFit->GetParameter(1); dAErr = finalFit->GetParError(0); dBErr = finalFit->GetParError(1); cout << "sA,sB: " << setiosflags(ios::fixed) << setprecision(1) << sA << " , " << sB << endl; cout << "dA,dB: " << setiosflags(ios::fixed) << setprecision(1) << dA << " , " << dB << endl; cout << "chi2/NDF: " << finalFit->GetChisquare()/finalFit->GetNDF() << endl; TString leb,den; if(type==1 || type==4) { if(type==1) leb="d_{0}"; else leb="d_{0}"; den="p_{T}"; } if(type==7 || type==8) { if(type==7) leb="d_{0}"; else leb="d_{Z}"; den="p"; } stringstream stream2; stream2 << "For Data, #sigma_{" << leb << "} = #left(#frac{" << setiosflags(ios::fixed) << setprecision(1) << dA <<" #pm " << dAErr << "}{" << den << "}"<< " + (" << dB << " #pm " << dBErr << ") #right) #mum"; cout << stream2.str() << endl; stringstream stream3; stream3 << "Sim., #sigma(" << leb << ") = #frac{(" << setiosflags(ios::fixed) << setprecision(1) << sA << den << sB << ") #mum"; cout << stream3.str() << endl; */ TLegend* leg = new TLegend(0.25,0.55,0.85,0.70); leg->AddEntry(hData1,"Data track | #eta | < 0.4","p"); leg->AddEntry(hSim1, "Simulation track | #eta | < 0.4","p"); leg->SetFillColor(0); leg->SetLineColor(0); leg->SetShadowColor(0); leg->SetTextSize(0.04); leg->SetTextAlign(32); hSim1->Draw("E1"); hData1->Draw("sameE1"); leg->Draw(); /* TLatex latex; latex.SetNDC(); latex.SetTextSize(0.03); latex.DrawLatex(0.35,0.60,stream2.str().c_str()); */ cmsPrel(0); gPad->Update(); gPad->Print(outputName1); gPad->Print(outputName2); gPad->Print(outputName3); }