void fitcorr(){ setTDRStyle(); TFile *f = new TFile("rootfiles/fitresults_2D_data.root"); TTree *t = (TTree*)f->Get("FitResults"); double mt=0, jsf=0, mcmass=0; t->SetBranchAddress("mt", &mt); t->SetBranchAddress("jesfactor", &jsf); t->SetBranchAddress("mcmass", &mcmass); TH2D *h2D = new TH2D("h2D",";M_{t} [GeV];JSF", 20, 170, 173, 20, 0.99, 1.04 ); TGraph *g = new TGraph(); for( int i=0; i < t->GetEntries(); i++ ){ t->GetEntry(i); //if( mcmass != 172.5 ) continue; h2D->Fill(mt, jsf); g->SetPoint(g->GetN(), mt, jsf); } // uncertainty contour double mean_mt = g->GetMean(1); double mean_jsf = g->GetMean(2); double sigma_mt = g->GetRMS(1); double sigma_jsf = g->GetRMS(2); double rho = g->GetCorrelationFactor(); std::cout << "Mean Mt = " << mean_mt << " +- " << sigma_mt << std::endl; std::cout << "Mean JSF = " << mean_jsf << " +- " << sigma_jsf << std::endl; std::cout << "Correlation = " << rho << std::endl; TMatrixDSym m(2); m(0,0) = sigma_mt*sigma_mt; m(1,1) = sigma_jsf*sigma_jsf; m(0,1) = rho*sigma_mt*sigma_jsf; m(1,0) = rho*sigma_mt*sigma_jsf; TMatrixDSymEigen eigen(m); TVectorD eigenval = eigen.GetEigenValues(); std::cout << eigenval[0] << " " << eigenval[1] << endl; // convert to ellipse tilt and radius //double phi = 0.5*TMath::ATan( (3/0.03)*(2*rho*sigma_mt*sigma_jsf)/(sigma_mt*sigma_mt-sigma_jsf*sigma_jsf) ); double phi = (180.0/TMath::Pi())*0.5*TMath::ATan( (2*rho*sigma_mt*sigma_jsf)/(sigma_mt*sigma_mt-sigma_jsf*sigma_jsf) ); std::cout << "phi = " << phi << std::endl; TEllipse *el = new TEllipse(mean_mt, mean_jsf, sqrt(eigenval[0]), sqrt(eigenval[1]), 0, 360, phi); TEllipse *el2 = new TEllipse(mean_mt, mean_jsf, 2*sqrt(eigenval[0]), 2*sqrt(eigenval[1]), 0, 360, phi); /* TF2* fell = new TF2("fell","pow((x-[1])*cos([0])+(y-[2])*sin([0]),2)/[3] + pow((x-[1])*sin([0])-(y-[2])*cos([0]),2)/[4]",171,174,0.985,1.015); fell->SetParameter(0,phi); fell->SetParameter(1,mean_mt); fell->SetParameter(2,mean_jsf); fell->SetParameter(3,eigenval[0]); fell->SetParameter(4,eigenval[1]); double cont[1] = {1}; fell->SetContour(1, cont); */ const Int_t Number = 2; Double_t Red[Number] = { 0.90, 0.10}; Double_t Green[Number] = { 0.90, 0.10}; Double_t Blue[Number] = { 0.90, 0.10}; Double_t Stops [Number] = {0, 1}; Double_t Length [Number] = {0, 1}; Int_t nb=50; TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb); gStyle->SetPadRightMargin(0.16); gStyle->SetPadTopMargin(0.08); TCanvas *c = new TCanvas("c","c",800,600); h2D->Draw("colzC"); el->SetFillStyle(0); el->SetLineColor(2); el->SetLineWidth(3); el->Draw(); el2->SetFillStyle(0); el2->SetLineColor(2); el2->SetLineWidth(3); el2->Draw(); int iPeriod = 2; int iPos = 33; lumi_sqrtS = "8 TeV"; writeExtraText = false; CMS_lumi( c, iPeriod, iPos ); c->Update(); c->RedrawAxis(); c->GetFrame()->Draw(); TLatex latex; latex.SetNDC(); latex.SetTextSize(0.06); latex.SetTextFont(42); latex.DrawLatex(0.2, 0.84, "2D fit"); c->Print("pdfplots/fitcorr.pdf"); //delete c; return; }
void compareDataMC( vector<TChain*> chmc , vector<char*> labels , TChain* chdata , char* var , TCut sel , TCut weight , int nbins , float xmin , float xmax , char* xtitle , bool overlayData , bool residual , bool drawLegend , bool log , char* flavor ){ TPad* fullpad = new TPad(); TPad* plotpad = new TPad(); TPad* respad = new TPad(); if( residual ){ fullpad = new TPad("fullpad","fullpad",0,0,1,1); fullpad->Draw(); fullpad->cd(); plotpad = new TPad("plotpad","plotpad",0,0,1,0.8); plotpad->Draw(); plotpad->cd(); if( log ) plotpad->SetLogy(); } else{ if( log ) gPad->SetLogy(); } TString tvar(var); tvar.ReplaceAll("()",""); tvar.ReplaceAll(".",""); const char* myvar = tvar; cout << "Plotting var " << myvar << " flavor " << flavor << endl; //int colors[]={6,2,7,4,5,8,9,15,12}; int colors[]={kBlue-6,kRed+2,7,5,5,8,9,15,12}; assert( chmc.size() == labels.size() ); const unsigned int nmc = chmc.size(); THStack* mcstack = new THStack("mcstack","mcstack"); TH1F* mctothist = new TH1F(); TH1F* mchist[nmc]; TH1F* datahist = new TH1F(Form("%s_datahist_%s",myvar,flavor),Form("%s_datahist_%s",myvar,flavor),nbins,xmin,xmax); float trigeff = 1.0; //if ( TString(flavor).Contains("ee") ) trigeff = 1.00; //else if( TString(flavor).Contains("mm") ) trigeff = 0.90; //else if( TString(flavor).Contains("em") ) trigeff = 0.95; //else if( TString(flavor).Contains("all") ) trigeff = 0.95; if ( TString(flavor).Contains("ee") ) sel+="leptype==0"; else if( TString(flavor).Contains("mm") ) sel+="leptype==1"; else if( TString(flavor).Contains("em") ) sel+="leptype==2"; //else if( TString(flavor).Contains("all") ) TCut trigweight(Form("%.2f",trigeff)); for( unsigned int imc = 0 ; imc < nmc ; imc++ ){ //for( int imc = nmc-1 ; imc > -1 ; imc-- ){ mchist[imc] = new TH1F(Form("%s_mc_%i_%s",myvar,imc,flavor),Form("%s_mc_%i_%s",myvar,imc,flavor),nbins,xmin,xmax); mchist[imc]->Sumw2(); chmc.at(imc)->Draw(Form("TMath::Min(%s,%f)>>%s_mc_%i_%s",var,xmax-0.01,myvar,imc,flavor),sel*weight*trigweight); if( TString( labels.at(imc) ).Contains("LM") || TString( labels.at(imc) ).Contains("T2tt") ){ mchist[imc]->SetFillColor( 0 ); mchist[imc]->SetLineStyle(2); }else{ mchist[imc]->SetFillColor( colors[imc] ); } // if( strcmp(labels[imc],"ttfake") == 0 || strcmp(labels[imc],"wjets") == 0 ){ // cout << "Scaling " << labels[imc] << " by 3.8" << endl; // mchist[imc]->Scale(3.8); // } mcstack->Add( mchist[imc] ); if( imc == 0 ) mctothist = (TH1F*) mchist[imc]->Clone(); else mctothist->Add(mchist[imc]); cout << "MC yield " << labels[imc] << " " << Form("%.2f",mchist[imc]->Integral()) << endl; } chdata->Draw(Form("TMath::Min(%s,%f)>>%s_datahist_%s",var,xmax-0.01,myvar,flavor),sel); if( overlayData ){ float max = datahist->GetMaximum() + datahist->GetBinError(datahist->GetMaximumBin()); if( mctothist->GetMaximum() > max ) max = mctothist->GetMaximum(); if( log ) datahist->SetMaximum( 15 * max ); else datahist->SetMaximum( 1.4 * max ); datahist->GetXaxis()->SetTitle(xtitle); datahist->Draw("E1"); mcstack->Draw("samehist"); datahist->Draw("sameE1"); datahist->Draw("sameaxis"); if(!log) datahist->GetYaxis()->SetRangeUser(0.,1.4*max); cout << "data yield " << datahist->Integral() << endl; } else{ mctothist->GetXaxis()->SetTitle(xtitle); mctothist->Draw(); mcstack->Draw("same"); mctothist->Draw("sameaxis"); } if( drawLegend ){ TLegend* myleg = getLegend( chmc , labels , overlayData ); myleg->Draw(); } TLatex *text = new TLatex(); text->SetNDC(); text->SetTextSize(0.05); text->DrawLatex(0.2,0.88,"CMS Preliminary"); //text->DrawLatex(0.2,0.83,"0.98 fb^{-1} at #sqrt{s} = 7 TeV"); text->DrawLatex(0.2,0.83,"#sqrt{s} = 7 TeV, #scale[0.6]{#int}Ldt = 4.3 fb^{-1}"); if ( TString(flavor).Contains("ee") ) text->DrawLatex(0.2,0.78,"Events with ee"); else if( TString(flavor).Contains("mm") ) text->DrawLatex(0.2,0.78,"Events with #mu#mu"); else if( TString(flavor).Contains("em") ) text->DrawLatex(0.2,0.78,"Events with e#mu"); else if( TString(flavor).Contains("all") ) text->DrawLatex(0.2,0.78,"Events with ee/#mu#mu/e#mu"); if( residual ){ fullpad->cd(); respad = new TPad("respad","respad",0,0.8,1,1); respad->Draw(); respad->cd(); gPad->SetGridy(); TH1F* ratio = (TH1F*) datahist->Clone(Form("%s_ratio",datahist->GetName())); ratio->Divide(mctothist); ratio->GetYaxis()->SetTitleOffset(0.3); ratio->GetYaxis()->SetTitleSize(0.2); ratio->GetYaxis()->SetNdivisions(5); ratio->GetYaxis()->SetLabelSize(0.2); //ratio->GetYaxis()->SetRangeUser(0.5,1.5); ratio->GetYaxis()->SetRangeUser(0.,2.); ratio->GetYaxis()->SetTitle("data/MC "); ratio->GetXaxis()->SetLabelSize(0); ratio->GetXaxis()->SetTitleSize(0); ratio->SetMarkerSize(0.7); ratio->Draw(); TLine line; line.SetLineWidth(1); line.DrawLine(datahist->GetXaxis()->GetXmin(),1,datahist->GetXaxis()->GetXmax(),1); } }
void PlotNsjMedian() { gROOT->LoadMacro("$LOCAL/include/TUntilsOpHisto.h"); gROOT->LoadMacro("$LOCAL/include/TUntilsAliFigs.h"); gROOT->LoadMacro("$LOCAL/include/TUntilsPlotStd.h"); SetStyle(); //============================================================================= TFile *file = TFile::Open("data/AnalysisOutputs_Nsj.root", "READ"); TList *listPy8R4S1 = (TList*)file->Get("list_py8_JetR04_SjeR01"); TList *listPy8R4S2 = (TList*)file->Get("list_py8_JetR04_SjeR02"); TList *listPy8R4S3 = (TList*)file->Get("list_py8_JetR04_SjeR03"); TList *listPy8R5S1 = (TList*)file->Get("list_py8_JetR05_SjeR01"); TList *listPy8R5S2 = (TList*)file->Get("list_py8_JetR05_SjeR02"); TList *listPy8R5S3 = (TList*)file->Get("list_py8_JetR05_SjeR03"); TList *listPy8R5S4 = (TList*)file->Get("list_py8_JetR05_SjeR04"); TList *listVacR4S1 = (TList*)file->Get("list_vac_JetR04_SjeR01"); TList *listVacR4S2 = (TList*)file->Get("list_vac_JetR04_SjeR02"); TList *listVacR4S3 = (TList*)file->Get("list_vac_JetR04_SjeR03"); TList *listVacR5S1 = (TList*)file->Get("list_vac_JetR05_SjeR01"); TList *listVacR5S2 = (TList*)file->Get("list_vac_JetR05_SjeR02"); TList *listVacR5S3 = (TList*)file->Get("list_vac_JetR05_SjeR03"); TList *listVacR5S4 = (TList*)file->Get("list_vac_JetR05_SjeR04"); TList *listMedR4S1 = (TList*)file->Get("list_med_JetR04_SjeR01"); TList *listMedR4S2 = (TList*)file->Get("list_med_JetR04_SjeR02"); TList *listMedR4S3 = (TList*)file->Get("list_med_JetR04_SjeR03"); TList *listMedR5S1 = (TList*)file->Get("list_med_JetR05_SjeR01"); TList *listMedR5S2 = (TList*)file->Get("list_med_JetR05_SjeR02"); TList *listMedR5S3 = (TList*)file->Get("list_med_JetR05_SjeR03"); TList *listMedR5S4 = (TList*)file->Get("list_med_JetR05_SjeR04"); file->Close(); TH1D *hPy8R4S1 = (TH1D*)listPy8R4S1->FindObject("hJetNsj_Median"); hPy8R4S1->SetName("hPy8R4S1"); TH1D *hPy8R4S2 = (TH1D*)listPy8R4S2->FindObject("hJetNsj_Median"); hPy8R4S2->SetName("hPy8R4S2"); TH1D *hPy8R4S3 = (TH1D*)listPy8R4S3->FindObject("hJetNsj_Median"); hPy8R4S3->SetName("hPy8R4S3"); TH1D *hPy8R5S1 = (TH1D*)listPy8R5S1->FindObject("hJetNsj_Median"); hPy8R5S1->SetName("hPy8R5S1"); TH1D *hPy8R5S2 = (TH1D*)listPy8R5S2->FindObject("hJetNsj_Median"); hPy8R5S2->SetName("hPy8R5S2"); TH1D *hPy8R5S3 = (TH1D*)listPy8R5S3->FindObject("hJetNsj_Median"); hPy8R5S3->SetName("hPy8R5S3"); TH1D *hPy8R5S4 = (TH1D*)listPy8R5S4->FindObject("hJetNsj_Median"); hPy8R5S4->SetName("hPy8R5S4"); TH1D *hVacR4S1 = (TH1D*)listVacR4S1->FindObject("hJetNsj_Median"); hVacR4S1->SetName("hVacR4S1"); TH1D *hVacR4S2 = (TH1D*)listVacR4S2->FindObject("hJetNsj_Median"); hVacR4S2->SetName("hVacR4S2"); TH1D *hVacR4S3 = (TH1D*)listVacR4S3->FindObject("hJetNsj_Median"); hVacR4S3->SetName("hVacR4S3"); TH1D *hVacR5S1 = (TH1D*)listVacR5S1->FindObject("hJetNsj_Median"); hVacR5S1->SetName("hVacR5S1"); TH1D *hVacR5S2 = (TH1D*)listVacR5S2->FindObject("hJetNsj_Median"); hVacR5S2->SetName("hVacR5S2"); TH1D *hVacR5S3 = (TH1D*)listVacR5S3->FindObject("hJetNsj_Median"); hVacR5S3->SetName("hVacR5S3"); TH1D *hVacR5S4 = (TH1D*)listVacR5S4->FindObject("hJetNsj_Median"); hVacR5S4->SetName("hVacR5S4"); TH1D *hMedR4S1 = (TH1D*)listMedR4S1->FindObject("hJetNsj_Median"); hMedR4S1->SetName("hMedR4S1"); TH1D *hMedR4S2 = (TH1D*)listMedR4S2->FindObject("hJetNsj_Median"); hMedR4S2->SetName("hMedR4S2"); TH1D *hMedR4S3 = (TH1D*)listMedR4S3->FindObject("hJetNsj_Median"); hMedR4S3->SetName("hMedR4S3"); TH1D *hMedR5S1 = (TH1D*)listMedR5S1->FindObject("hJetNsj_Median"); hMedR5S1->SetName("hMedR5S1"); TH1D *hMedR5S2 = (TH1D*)listMedR5S2->FindObject("hJetNsj_Median"); hMedR5S2->SetName("hMedR5S2"); TH1D *hMedR5S3 = (TH1D*)listMedR5S3->FindObject("hJetNsj_Median"); hMedR5S3->SetName("hMedR5S3"); TH1D *hMedR5S4 = (TH1D*)listMedR5S4->FindObject("hJetNsj_Median"); hMedR5S4->SetName("hMedR5S4"); //============================================================================= TH1F *hfm = 0; TCanvas *can = 0; TLegend *leg = 0; TLatex *tex = 0; TLine *line = 0; const Float_t dflx = 0., dfux = 500.; const Float_t dfly = 0., dfuy = 15.; const Float_t dlsx = 0.05, dlsy = 0.05; const Float_t dtsx = 0.06, dtsy = 0.06; const Float_t dtox = 1.10, dtoy = 1.00; const TString stnx = "#it{p}_{T,jet} (GeV/#it{c})"; const TString stny = "Number of sub-jets: median"; TH1D *hSE = new TH1D("hSE", "", 10., 0., 10.); hSE->SetLineWidth(2); hSE->SetLineColor(wcl[0]); hSE->SetMarkerStyle(wmk[0]); hSE->SetMarkerColor(wcl[0]); TH1D *hME = new TH1D("hME", "", 10., 0., 10.); hME->SetLineWidth(2); hME->SetLineColor(wcl[0]); hME->SetMarkerStyle(wmk[2]); hME->SetMarkerColor(wcl[0]); //============================================================================= can = MakeCanvas("NsjPy8R04_Median"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hPy8R4S1, wcl[1], wmk[0], "SAME"); DrawHisto(hPy8R4S2, wcl[3], wmk[0], "SAME"); DrawHisto(hPy8R4S3, wcl[4], wmk[0], "SAME"); leg = new TLegend(0.68, 0.66, 0.98, 0.90); SetupLegend(leg); leg->AddEntry(hPy8R4S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R4S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R4S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA 8, tune 4C, pp #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("NsjPy8R05_Median"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hPy8R5S1, wcl[1], wmk[0], "SAME"); DrawHisto(hPy8R5S2, wcl[3], wmk[0], "SAME"); DrawHisto(hPy8R5S3, wcl[4], wmk[0], "SAME"); DrawHisto(hPy8R5S4, wcl[2], wmk[0], "SAME"); leg = new TLegend(0.58, 0.74, 0.98, 0.90); SetupLegend(leg); leg->SetNColumns(2); leg->AddEntry(hPy8R5S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R5S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R5S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R5S4, "#it{R}_{sub}=0.4", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA 8, tune 4C, pp #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("NsjVacR04_Median"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hVacR4S1, wcl[1], wmk[0], "SAME"); DrawHisto(hVacR4S2, wcl[3], wmk[0], "SAME"); DrawHisto(hVacR4S3, wcl[4], wmk[0], "SAME"); leg = new TLegend(0.68, 0.66, 0.98, 0.90); SetupLegend(leg); leg->AddEntry(hVacR4S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR4S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR4S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, vacuum, #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("NsjVacR05_Median"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hVacR5S1, wcl[1], wmk[0], "SAME"); DrawHisto(hVacR5S2, wcl[3], wmk[0], "SAME"); DrawHisto(hVacR5S3, wcl[4], wmk[0], "SAME"); DrawHisto(hVacR5S4, wcl[2], wmk[0], "SAME"); leg = new TLegend(0.58, 0.74, 0.98, 0.90); SetupLegend(leg); leg->SetNColumns(2); leg->AddEntry(hVacR5S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR5S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR5S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR5S4, "#it{R}_{sub}=0.4", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, vacuum, #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("NsjMedR04_Median"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hMedR4S1, wcl[1], wmk[0], "SAME"); DrawHisto(hMedR4S2, wcl[3], wmk[0], "SAME"); DrawHisto(hMedR4S3, wcl[4], wmk[0], "SAME"); leg = new TLegend(0.68, 0.66, 0.98, 0.90); SetupLegend(leg); leg->AddEntry(hMedR4S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR4S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR4S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, medium, #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("NsjMedR05_Median"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hMedR5S1, wcl[1], wmk[0], "SAME"); DrawHisto(hMedR5S2, wcl[3], wmk[0], "SAME"); DrawHisto(hMedR5S3, wcl[4], wmk[0], "SAME"); DrawHisto(hMedR5S4, wcl[2], wmk[0], "SAME"); leg = new TLegend(0.58, 0.74, 0.98, 0.90); SetupLegend(leg); leg->SetNColumns(2); leg->AddEntry(hMedR5S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR5S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR5S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR5S4, "#it{R}_{sub}=0.4", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, medium, #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= return; }
void eff_pathor_pt(){ gROOT->SetStyle("Plain"); gStyle -> SetErrorX(0); // TFile *fdataeff= new TFile("output_data_iso025.root"); TFile *fdataeff= new TFile("output_mc_dimu_pt.root"); TCanvas *c = new TCanvas("c","The Ntuple canvas",200,10,700,780); c->SetFillColor(10); c->Divide(2,2); gStyle->SetStatW(0.30); gStyle->SetStatH(0.20); gStyle->SetStatColor(42); gStyle->SetOptStat(""); //em gStyle->SetLabelSize(0.048,"xy"); gStyle->SetLabelOffset(0.013,"x"); gStyle->SetLabelOffset(0.013,"y"); gStyle->SetPadBorderMode(0); gStyle->SetFillColor(0); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); TLatex *t = new TLatex(); t->SetNDC(); t->SetTextFont(62); t->SetTextColor(36); t->SetTextSize(0.08); t->SetTextAlign(12); /////////////////////////////////////////// c_1 -> cd(); c->cd(1); gPad->SetTopMargin(0.08); gPad->SetLeftMargin(0.163); gPad->SetBottomMargin(0.16); gPad->SetRightMargin(0.143); fdataeff -> cd(); TGraphAsymmErrors *histo1Da = (TGraphAsymmErrors*) fdataeff->Get("Mu17_IsoTrkVVL_pt_eta_pt_PLOT_Tight2012_pass_&_tag_Mu17_IsoTrkVVL_pass_&_tag_Tight2012_pass"); histo1Da->SetMinimum(0.); histo1Da->SetMaximum(1.); histo1Da ->Draw("ap"); Double_t *yg = histo1Da->GetY(); Double_t *erryg = histo1Da->GetEYhigh() ; //float Bins[5]={0, 0.9, 1.2, 2.1, 2.4}; float Bins[7]= {12, 17, 20, 24, 30, 60, 100}; TH1D *hr1DTot = new TH1D("hr1DTot", "", 6, Bins); for (int i = 0; i<6; i++) { printf("yg[%d] = %g\n", i,yg[i]); printf("erryg[%d] = %g\n", i,erryg[i]); hr1DTot -> SetBinContent(i+1, yg[i]) ; hr1DTot -> SetBinError(i+1, erryg[i]) ; } //////////////////////// c_2 -> cd(); c->cd(2); c_2 ->SetLogy(); c_2 ->SetLogx(); gPad->SetTopMargin(0.08); gPad->SetLeftMargin(0.163); gPad->SetBottomMargin(0.16); gPad->SetRightMargin(0.143); // f -> cd(); //TH1F *hr2DRefRormula = (TH1F*)hr1DTot -> Clone(); //double etabin[5] = {0, 0.9, 1.2, 2.1, 2.4}; double ptbin[7]= {12., 17., 20., 24., 30., 60., 100.}; TH2F *hr2DRefRormula = new TH2F("heta1eta2","", 6, ptbin, 6, ptbin); hr2DRefRormula -> Sumw2(); int nBinsX = hr2DRefRormula->GetNbinsX(); int nBinsY = hr2DRefRormula->GetNbinsY(); double content, error, sigmaA, sigmaB, contA, contB, errorA, errorB; for (int i(1); i <= nBinsY ; i++) { for (int j(1); j <= nBinsX; j++) { content = 1. - (1. - (hr1DTot -> GetBinContent(i)))*(1. - (hr1DTot -> GetBinContent(j))); // sigmaA = hr1DTot -> GetBinError(j)/hr1DTot -> GetBinContent(j); // sigmaB = hr1DTot -> GetBinError(i)/hr1DTot -> GetBinContent(i); // error = content* sqrt( sigmaA*sigmaA + sigmaB*sigmaB ); contA = 1. - hr1DTot -> GetBinContent(i); errorA = hr1DTot -> GetBinError(i) ; contB = 1. - hr1DTot -> GetBinContent(j); errorB = hr1DTot -> GetBinError(j) ; cout << "errorB : " << errorB << "\n"; error= sqrt( contA*contA*errorB*errorB + contB*contB*errorA*errorA ); // error = contA*errorB + contB*errorA; if (i==j) error = 2.*(contA)*errorA; // cout<< "i,j = " << i << ","<< j << " , "<< hr1DLead -> GetBinContent(j) << " , " << hr1DTrail -> GetBinContent(i) << " , content: " << content<< "\n"; cout << "x(1),y(2) = " << j << ","<< i << " , " << content << " , " << error << "\n"; hr2DRefRormula -> SetBinContent(j,i, content); hr2DRefRormula -> SetBinError(j,i, error); } } gStyle->SetPalette(1); hr2DRefRormula->Draw("COLZ"); hr2DRefRormula -> GetXaxis()->SetNdivisions(505); hr2DRefRormula -> GetYaxis()->SetNdivisions(505); hr2DRefRormula-> GetXaxis() -> SetTitleColor(1); hr2DRefRormula-> GetXaxis() -> SetTitleOffset(1.); hr2DRefRormula-> GetXaxis() -> SetTitleSize(0.06); hr2DRefRormula-> GetXaxis() -> SetTitle("#mu p_{T}"); hr2DRefRormula-> GetYaxis() -> SetTitleColor(1); hr2DRefRormula-> GetYaxis() -> SetTitleOffset(1.); hr2DRefRormula-> GetYaxis() -> SetTitleSize(0.06); hr2DRefRormula-> GetYaxis() -> SetTitle("#mu p_{T}"); gStyle->SetPaintTextFormat("3.3f "); //3.4f hr2DRefRormula->SetMarkerSize(1.8); hr2DRefRormula->Draw("TEXT E1 Same"); /* TFile g("reftrigger_data_mu17_pt.root", "RECREATE"); //create file hr2DRefRormula -> SetName("hrEffData"); hr2DRefRormula -> Write(); */ // TH1F *hr2DFor = (TH1F*)hr2DRefRormula -> Clone(); TH1F *hrEffA = (TH1F*)hr2DRefRormula -> Clone(); t->SetTextColor(1); t->SetTextSize(0.04); // t->DrawLatex(0.33,0.95, "1 - (1 -#epsilon_{#mu 17 on #mu_1})*(1 -#epsilon_{#mu 17 on #mu_2}) " ); t->DrawLatex(0.33,0.95, "1 - (1 -#epsilon_{i})*(1 -#epsilon_{k}) ; (MC)" ); ///////////////////////////////////////////////////////// c_3 -> cd(); c->cd(3); c_3 ->SetLogy(); c_3 ->SetLogx(); gPad->SetTopMargin(0.08); gPad->SetLeftMargin(0.163); gPad->SetBottomMargin(0.16); gPad->SetRightMargin(0.143); fdataeff->cd(); fdataeff->ls(); // tag_abseta_bin0 TGraphAsymmErrors *histo1D = (TGraphAsymmErrors*) fdataeff->Get("pathOrMu20_pt_eta_pt_PLOT_tag_pt_bin0_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass"); Double_t *yg = histo1D->GetY(); Double_t *erryg = histo1D->GetEYhigh() ; for (int i = 0; i<6; i++) { printf("yg[%d] = %g\n", i,yg[i]); printf("erryg[%d] = %g\n", i,erryg[i]); } cout << "--------------" << "\n"; // tag_abseta_bin1 TGraphAsymmErrors *histo1Db1 = (TGraphAsymmErrors*) fdataeff->Get("pathOrMu20_pt_eta_pt_PLOT_tag_pt_bin1_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass"); Double_t *ygb1 = histo1Db1->GetY(); Double_t *errygb1 = histo1Db1->GetEYhigh() ; for (int i = 0; i<6; i++) { printf("ygb1[%d] = %g\n", i,ygb1[i]); printf("errygb1[%d] = %g\n", i,errygb1[i]); } cout << "--------------" << "\n"; // tag_abseta_bin2 TGraphAsymmErrors *histo1Db2 = (TGraphAsymmErrors*) fdataeff->Get("pathOrMu20_pt_eta_pt_PLOT_tag_pt_bin2_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass"); Double_t *ygb2 = histo1Db2->GetY(); Double_t *errygb2 = histo1Db2->GetEYhigh() ; for (int i = 0; i<6; i++) { printf("ygb2[%d] = %g\n", i,ygb2[i]); printf("errygb2[%d] = %g\n", i,errygb2[i]); } cout << "--------------" << "\n"; // tag_abseta_bin3 TGraphAsymmErrors *histo1Db3 = (TGraphAsymmErrors*) fdataeff->Get("pathOrMu20_pt_eta_pt_PLOT_tag_pt_bin3_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass"); Double_t *ygb3 = histo1Db3->GetY(); Double_t *errygb3 = histo1Db3->GetEYhigh() ; for (int i = 0; i<6; i++) { printf("ygb3[%d] = %g\n", i,ygb3[i]); printf("errygb3[%d] = %g\n", i,errygb3[i]); } cout << "--------------" << "\n"; // tag_abseta_bin4 TGraphAsymmErrors *histo1Db4 = (TGraphAsymmErrors*) fdataeff->Get("pathOrMu20_pt_eta_pt_PLOT_tag_pt_bin4_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass"); Double_t *ygb4 = histo1Db4->GetY(); Double_t *errygb4 = histo1Db4->GetEYhigh() ; for (int i = 0; i<6; i++) { printf("ygb4[%d] = %g\n", i,ygb4[i]); printf("errygb4[%d] = %g\n", i,errygb4[i]); } cout << "--------------" << "\n"; // tag_abseta_bin5 TGraphAsymmErrors *histo1Db5 = (TGraphAsymmErrors*) fdataeff->Get("pathOrMu20_pt_eta_pt_PLOT_tag_pt_bin5_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass"); Double_t *ygb5 = histo1Db5->GetY(); Double_t *errygb5 = histo1Db5->GetEYhigh() ; for (int i = 0; i<6; i++) { printf("ygb5[%d] = %g\n", i,ygb5[i]); printf("errygb5[%d] = %g\n", i,errygb5[i]); } //double etabin[5] = {0, 0.9, 1.2, 2.1, 2.4}; double ptbin[7]= {12, 17, 20, 24, 30, 60, 100}; TH2F *heta1eta2 = new TH2F("heta1eta2","", 6, ptbin, 6, ptbin); for (int i(1); i <= 6 ; i++) { // y for (int j(1); j <= 6; j++) { // x if(i==1){ heta1eta2 -> SetBinContent(j,i,yg[j-1]); heta1eta2 -> SetBinError(j,i,erryg[j-1]); } if(i==2){ heta1eta2 -> SetBinContent(j,i,ygb1[j-1]); heta1eta2 -> SetBinError(j,i,errygb1[j-1]); } if(i==3){ heta1eta2 -> SetBinContent(j,i,ygb2[j-1]); heta1eta2 -> SetBinError(j,i,errygb2[j-1]); } if(i==4){ heta1eta2 -> SetBinContent(j,i,ygb3[j-1]); heta1eta2 -> SetBinError(j,i,errygb3[j-1]); } if(i==5){ heta1eta2 -> SetBinContent(j,i,ygb4[j-1]); heta1eta2 -> SetBinError(j,i,errygb4[j-1]); } if(i==6){ heta1eta2 -> SetBinContent(j,i,ygb5[j-1]); heta1eta2 -> SetBinError(j,i,errygb5[j-1]); } } } heta1eta2 -> Draw("COLZ"); gStyle->SetPaintTextFormat("3.3f "); heta1eta2->SetMarkerSize(1.8); heta1eta2->Draw("TEXT E1 Same"); heta1eta2 -> GetXaxis()->SetNdivisions(505); heta1eta2 -> GetYaxis()->SetNdivisions(505); heta1eta2-> GetXaxis() -> SetTitleColor(1); heta1eta2-> GetXaxis() -> SetTitleOffset(1.); heta1eta2-> GetXaxis() -> SetTitleSize(0.06); heta1eta2-> GetXaxis() -> SetTitle("p_{T, 1}"); heta1eta2-> GetYaxis() -> SetTitleColor(1); heta1eta2-> GetYaxis() -> SetTitleOffset(1.); heta1eta2-> GetYaxis() -> SetTitleSize(0.06); heta1eta2-> GetYaxis() -> SetTitle("p_{T, 2}"); TH1F *hrEffB = (TH1F*)heta1eta2 -> Clone(); t->SetTextColor(1); t->SetTextSize(0.04); t->DrawLatex(0.02,0.95, "((HLT_Mu17_Mu8||HLT_Mu17_TkMu8) && HLT_Mu17) / HLT_Mu17" ); ////////////////////////////////////////////////// c_4 -> cd(); c->cd(4); c_4 ->SetLogy(); c_4 ->SetLogx(); gPad->SetTopMargin(0.08); gPad->SetLeftMargin(0.163); gPad->SetBottomMargin(0.16); gPad->SetRightMargin(0.143); hrEffA -> Multiply(hrEffB); gStyle->SetPalette(1); hrEffA->Draw("COLZ"); hrEffA -> GetXaxis()->SetNdivisions(505); hrEffA -> GetYaxis()->SetNdivisions(505); hrEffA-> GetXaxis() -> SetTitleColor(1); hrEffA-> GetXaxis() -> SetTitleOffset(1.); hrEffA-> GetXaxis() -> SetTitleSize(0.06); hrEffA-> GetXaxis() -> SetTitle("p_{T, 1}"); hrEffA-> GetYaxis() -> SetTitleColor(1); hrEffA-> GetYaxis() -> SetTitleOffset(1.); hrEffA-> GetYaxis() -> SetTitleSize(0.06); hrEffA-> GetYaxis() -> SetTitle("p_{T, 2}"); gStyle->SetPaintTextFormat("3.3f "); hrEffA->SetMarkerSize(1.8); hrEffA->Draw("TEXT E1 Same"); TH1F *hrEffFinFormula = (TH1F*)hrEffA -> Clone(); /* TFile g("effDatapathOr_pt.root", "RECREATE"); //create file hrEffA -> SetName("hrEffData"); hrEffA -> Write(); */ //TFile* file = new TFile("hrEffFinFormula_2030rew.root", "RECREATE"); //hrEffFinFormula -> SetName("hrEffFinFormula"); //hrEffFinFormula -> Write(); t->SetTextColor(1); t->SetTextSize(0.04); t->DrawLatex(0.1,0.95, "Eff_ref * Eff_soup|ref" ); ///////////////////////////////////////////////////////////// c-> Print("eff_pathOr_mc_pt.pdf"); c->cd(); c->Update(); }
void cmsFinal(double intLumi=-1, bool wide = false) { TLatex *latex = new TLatex(); latex->SetNDC(); latex->SetTextSize(0.045); latex->SetTextAlign(31); // align right latex->DrawLatex(wide ? 0.98 : 0.95, 0.96, "#sqrt{s} = 8 TeV"); if (intLumi > 0.) { latex->SetTextAlign(11); // align left latex->DrawLatex(wide ? 0.06 : 0.15, 0.96, Form("CMS, L = %.2g fb^{-1}",intLumi*0.001)); } else if (intLumi==0) { // simulation latex->SetTextAlign(21); // align left latex->DrawLatex(wide ? 0.06 : 0.15, 0.96, "CMS simulation (Pythia Z2*)"); } else { latex->SetTextAlign(11); // align left latex->DrawLatex(0.06,0.96,"CMS 2012"); } } // cmsPrel
void DrawPerformCompFVTX(){ gStyle->SetErrorX(0); gStyle->SetOptStat(0); TFile *fmb = new TFile("merged_AnaMWGppmb.root","ReadOnly"); TFile *fhmand = new TFile("merged_AnaMWGppfvtxand.root","ReadOnly"); TFile *fhmor = new TFile("merged_AnaMWGppfvtxor.root","ReadOnly"); // TFile *fhmsouth = new TFile("merged_AnaMWGppfvtxsouth.root","ReadOnly"); // TFile *fhmnorth = new TFile("merged_AnaMWGppfvtxnorth.root","ReadOnly"); const int ncav = 2; TCanvas *c1[ncav]; for(int i=0;i<ncav;i++){ c1[i] = new TCanvas(); } TString histoname = "hnfvtxtrkbbc";//"hntracknmpc"; TString varname = "nfvtxtrack"; TString var = "# of fvtx tracks";//"# of central tracks"; bool xory = 1; TH2F* hbbcsbbcn_mb = (TH2F*)fmb->Get(Form("%s",histoname.Data())); TH2F* hbbcsbbcn_hmand = (TH2F*)fhmand->Get(Form("%s",histoname.Data())); TH2F* hbbcsbbcn_hmor = (TH2F*)fhmor->Get(Form("%s",histoname.Data())); // TH2F* hbbcsbbcn_hmsouth = (TH2F*)fhmsouth->Get(Form("%s",histoname.Data())); // TH2F* hbbcsbbcn_hmnorth = (TH2F*)fhmnorth->Get(Form("%s",histoname.Data())); if(xory){ TH1F* hbbc_mb = (TH1F*)hbbcsbbcn_mb->ProjectionX("hbbc_mb",0,-1); TH1F* hbbc_hmand = (TH1F*)hbbcsbbcn_hmand->ProjectionX("hbbc_hmand",0,-1); TH1F* hbbc_hmor = (TH1F*)hbbcsbbcn_hmor->ProjectionX("hbbc_hmor",0,-1); // TH1F* hbbc_hmsouth = (TH1F*)hbbcsbbcn_hmsouth->ProjectionX("hbbc_hmsouth",0,-1); // TH1F* hbbc_hmnorth = (TH1F*)hbbcsbbcn_hmnorth->ProjectionX("hbbc_hmnorth",0,-1); } else{ TH1F* hbbc_mb = (TH1F*)hbbcsbbcn_mb->ProjectionY("hbbc_mb",0,-1); TH1F* hbbc_hmand = (TH1F*)hbbcsbbcn_hmand->ProjectionY("hbbc_hmand",0,-1); TH1F* hbbc_hmor = (TH1F*)hbbcsbbcn_hmor->ProjectionY("hbbc_hmor",0,-1); // TH1F* hbbc_hmsouth = (TH1F*)hbbcsbbcn_hmsouth->ProjectionY("hbbc_hmsouth",0,-1); // TH1F* hbbc_hmnorth = (TH1F*)hbbcsbbcn_hmnorth->ProjectionY("hbbc_hmnorth",0,-1); } //hbbc_mb->GetXaxis()->SetLimits(0,200); //hbbc_mb->Rebin(3); //hbbc_mbcen->Rebin(10); //hbbc_hmand->Rebin(3); //hbbc_hmor->Rebin(3); //hbbc_hmsouth->Rebin(3); //hbbc_hmnorth->Rebin(3); TH1F *hbbc_hmorScale = (TH1F*)hbbc_hmor->Clone("hbbc_hmorScale"); hbbc_hmorScale->Scale(0.06); //hbbc_hm->Scale(1./hbbc_hm->Integral()); c1[0]->cd(); c1[0]->SetLogy(); hbbc_mb->Draw(); SetTitle(*hbbc_mb,Form("%s",var.Data()),"# of events",""); //SetTitle(*hbbc_mb,"nvtx layer 1","# of events",""); SetXRange(*hbbc_mb,0,30); SetYRange(*hbbc_mb,1,5e9); SetXRange(*hbbc_hmand,0,30); SetXRange(*hbbc_hmor,0,30); // SetXRange(*hbbc_hmsouth,0,300); // SetXRange(*hbbc_hmnorth,0,300); SetStyle(*hbbc_mb,1.0,1,20,0,0); SetStyle(*hbbc_hmand,1.0,2,20,0,0); SetStyle(*hbbc_hmor,1.0,4,34,0,0); SetStyle(*hbbc_hmorScale,1.0,2,34,0,0); // SetStyle(*hbbc_hmsouth,0.6,6,29,0,0); // SetStyle(*hbbc_hmnorth,0.6,7,32,0,0); TLegend *leg = new TLegend(0.6,0.75,0.8,0.90); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.045); leg->AddEntry(hbbc_mb,"p+p minbias","pl"); // leg->AddEntry(hbbc_mb_scale,"p+p minbias * 50","pl"); leg->AddEntry(hbbc_hmor,"p+p FVTX OR","pl"); leg->AddEntry(hbbc_hmand,"p+p FVTX AND","pl"); // leg->AddEntry(hbbc_hmorScale,"p+p FVTX OR Scaled * 0.06","pl"); // leg->AddEntry(hbbc_hmand,"MWGpp high-mult AND","pl"); // leg->AddEntry(hbbc_hmor,"MWGpp high-mult OR","pl"); // leg->AddEntry(hbbc_hmsouth,"MWGpp high-mult south","pl"); // leg->AddEntry(hbbc_hmnorth,"MWGpp high-mult north","pl"); leg->Draw("same"); hbbc_hmor->Draw("same"); hbbc_hmand->Draw("same"); // hbbc_hmorScale->Draw("same"); double top5 = 7; TLine *l = new TLine(top5,0,top5,4e8); l->SetLineStyle(2); l->Draw(); // hbbc_hmand->Draw("same"); // hbbc_hmor->Draw("same"); // hbbc_hmsouth->Draw("same"); // hbbc_hmnorth->Draw("same"); TLatex t; t.SetTextSize(0.04); t.SetNDC(); // hbbc_mb->GetXaxis()->SetRange() t.DrawLatex(0.13,0.2,Form("MB mean:%.2f",hbbc_mb->GetMean(1))); t.DrawLatex(0.13,0.25,Form("FVTX OR mean:%.2f",hbbc_hmor->GetMean(1))); t.DrawLatex(0.13,0.30,Form("FVTX AND mean:%.2f",hbbc_hmand->GetMean(1))); t.SetNDC(0); t.DrawLatex(top5-8,5e8,Form("Top 0-5%, fvtx track >= %.1f",top5)); //t.DrawLatex(0.13,0.7,Form("mb mean:%.2f, # of events: %.1fM",hbbc_mb->GetMean(1),hbbcsbbcn_mb->Integral()/1e6)); //t.DrawLatex(0.13,0.75,Form("central mean:%.2f, # of events: %.1fM",hbbc_mbcen->GetMean(1),hbbcsbbcn_mbcen->Integral()/1e6)); //t.DrawLatex(0.13,0.80,Form("hm AND mean:%.2f, # of events: %.1fM",hbbc_hmand->GetMean(1),hbbcsbbcn_hmand->Integral()/1e6)); //t.DrawLatex(0.13,0.85,Form("hm OR mean:%.2f, # of events: %.1fM",hbbc_hmor->GetMean(1),hbbcsbbcn_hmor->Integral()/1e6)); //t.DrawLatex(0.13,0.90,Form("hm south mean:%.2f, # of events: %.1fM",hbbc_hmsouth->GetMean(1),hbbcsbbcn_hmsouth->Integral()/1e6)); //t.DrawLatex(0.13,0.95,Form("hm north mean:%.2f, # of events: %.1fM",hbbc_hmnorth->GetMean(1),hbbcsbbcn_hmnorth->Integral()/1e6)); c1[0]->Print(Form("fig/h%s_comp.png",varname.Data())); c1[1]->cd(); TH1F* hbbc_ratioand = (TH1F*)hbbc_hmand->Clone("hbbc_ratioand"); TH1F* hbbc_ratioor = (TH1F*)hbbc_hmor->Clone("hbbc_ratioor"); // TH1F* hbbc_ratiosouth = (TH1F*)hbbc_hmsouth->Clone("hbbc_ratiosouth"); // TH1F* hbbc_rationorth = (TH1F*)hbbc_hmnorth->Clone("hbbc_rationorth"); hbbc_ratioand->Divide(hbbc_mb); hbbc_ratioor->Divide(hbbc_mb); // hbbc_ratiosouth->Divide(hbbc_mb); // hbbc_rationorth->Divide(hbbc_mb); SetTitle(*hbbc_ratioand,Form("%s",var.Data()),"ratio hm / mb",""); SetTitle(*hbbc_ratioor,Form("%s",var.Data()),"ratio hm / mb",""); SetXRange(*hbbc_ratioand,0,25); SetYRange(*hbbc_ratioand,0,20); hbbc_ratioand->Draw(); hbbc_ratioor->Draw("same"); // hbbc_ratiosouth->Draw("same"); // hbbc_rationorth->Draw("same"); c1[1]->Print(Form("fig/h%s_ratio.png",varname.Data())); /* TH1F* hnvtx = (TH1F*)hbbcnvtx[0]->ProjectionX("hnvtx",0,-1); TH1F* hnvtx_hm = (TH1F*)hbbcnvtx_hm[0]->ProjectionX("hnvtx_hm",0,-1); TH1F* hbbc = (TH1F*)hbbcnvtx[0]->ProjectionX("hbbc",0,-1); TH1F* hbbc_hm = (TH1F*)hbbcnvtx_hm[0]->ProjectionX("hbbc_hm",0,-1); c1[22]->cd(); c1[22]->SetLogy(); hnvtx->Rebin(4); hnvtx_hm->Rebin(4); hnvtx->Scale(1./hnvtx->Integral()); hnvtx_hm->Scale(1./hnvtx_hm->Integral()); SetRange(*hnvtx,0,1e-11,200,10); SetTitle(*hnvtx,"#hits in cluster layer 1","normalized",""); SetStyle(*hnvtx,1.2,1,20,0,0); SetStyle(*hnvtx_hm,1.2,2,24,0,0); hnvtx->Draw("P"); hnvtx_hm->Draw("Psame"); c1[22]->Print("fig/hnvtx.png"); c1[23]->cd(); c1[23]->SetLogy(); SetTitle(*hbbc,"bbc charge sum","normalized",""); hbbc->Rebin(5); hbbc_hm->Rebin(5); hbbc->Scale(1./hbbc->Integral()); hbbc_hm->Scale(1./hbbc_hm->Integral()); SetRange(*hbbc,0,1e-11,200,10); SetStyle(*hbbc,1.2,1,20,0,0); SetStyle(*hbbc_hm,1.2,2,24,0,0); hbbc->Draw("P"); hbbc_hm->Draw("Psame"); c1[23]->Print("fig/hbbc.png"); */ }
//void VHPlotter(string title="", int plot=0) { void VHPlotter(string title="", int plot=0, TCanvas* c1=0 ) { string subdir="0"; string postfix=""; string dirbSel=""; double norm11 = ((Lumi2016_ele * Xsec_dy_amc1) / Ngen_dy_amc1); double norm12 = ((Lumi2016_ele * Xsec_dy_amc2) / Ngen_dy_amc2); double norm13 = ((Lumi2016_ele * Xsec_dy_amc3) / Ngen_dy_amc3); double norm14 = ((Lumi2016_ele * Xsec_dy_amc4) / Ngen_dy_amc4); double norm2 = ((Lumi2016_ele * Xsec_tt) / Ngen_tt); double norm3 = ((Lumi2016_ele * Xsec_zz) / Ngen_zz); double norm4 = ((Lumi2016_ele * Xsec_wz) / Ngen_wz); double norm6 = ((Lumi2016_ele * Xsec_ww) / Ngen_ww); double norm7 = ((Lumi2016_ele * Xsec_zhm) / Ngen_zhm); double norm8 = ((Lumi2016_ele * Xsec_zhp) / Ngen_zhp); //if (ilepton==1) Lumi2016 = Lumi2016_ele; /*double enorm1 = ((Lumi2012 * eXsec_dy) / Ngen_dy); double enorm1_amc = ((Lumi2012 * eXsec_dy_amc) / Ngen_dy_amc); double enorm1_1 = ((Lumi2012 * eXsec_dy_1) / Ngen_dy_1); double enorm1_2=0; double enorm2 = ((Lumi2012 * eXsec_tt) / Ngen_tt); double enorm4 = ((Lumi2012 * eXsec_wz) / Ngen_wz); double enorm5 = ((Lumi2012 * eXsec_qcd) / Ngen_qcd); double enorm6 = ((Lumi2012 * eXsec_ww) / Ngen_ww); double enorm7 = ((Lumi2012 * eXsec_wj) / Ngen_wj); double enorm8 = ((Lumi2012 * eXsec_tS) / Ngen_tS); double enorm9 = ((Lumi2012 * eXsec_tT) / Ngen_tT); double enorm10 = ((Lumi2012 * eXsec_tW) / Ngen_tW); double enorm11 = ((Lumi2012 * eXsec_tSb) / Ngen_tSb); double enorm12 = ((Lumi2012 * eXsec_tTb) / Ngen_tTb); double enorm13 = ((Lumi2012 * eXsec_tWb) / Ngen_tWb); */ TFile* mc11 = TFile::Open((path + "DYJetsToLL_M-50_HT-100to200_13TeV.root").c_str()); TH1F* h_mc11 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc12 = TFile::Open((path + "DYJetsToLL_M-50_HT-200to400_13TeV.root").c_str()); TH1F* h_mc12 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc13 = TFile::Open((path + "DYJetsToLL_M-50_HT-400to600_13TeV.root").c_str()); TH1F* h_mc13 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc14 = TFile::Open((path + "DYJetsToLL_M-50_HT-600toInf_13TeV.root").c_str()); TH1F* h_mc14 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc2 = TFile::Open((path + "TT_TuneCUETP8M1_13TeV.root").c_str()); TH1F* h_mc2 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc3 = TFile::Open((path + "ZZ_TuneCUETP8M1_13TeV.root").c_str()); TH1F* h_mc3 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc4 = TFile::Open((path + "WZ_TuneCUETP8M1_13TeV.root").c_str()); TH1F* h_mc4 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc6 = TFile::Open((path + "WW_TuneCUETP8M1_13TeV.root").c_str()); TH1F* h_mc6 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc7 = TFile::Open((path + "ZH_HToBB_ZToLL_M125_13TeV_amcatnlo.root").c_str()); TH1F* h_mc7 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc8 = TFile::Open((path + "ZH_HToBB_ZToLL_M125_13TeV_powheg.root").c_str()); TH1F* h_mc8 = (TH1F*)gDirectory->Get(title.c_str()); //TFile* data = TFile::Open((path + "SingleMuon-Run2016B-v2.root").c_str()); //TH1F* h_data = (TH1F*)gDirectory->Get(title.c_str()); TFile* data_runB = TFile::Open((path + "SingleMuon-Run2016B-v2.root").c_str()); TH1F* h_data_runB = (TH1F*)gDirectory->Get(title.c_str()); TFile* data_runC = TFile::Open((path + "SingleMuon-Run2016C-v2.root").c_str()); TH1F* h_data_runC = (TH1F*)gDirectory->Get(title.c_str()); TFile* data_runD = TFile::Open((path + "SingleMuon-Run2016D-v2.root").c_str()); TH1F* h_data_runD = (TH1F*)gDirectory->Get(title.c_str()); TH1F* h_data = (TH1F*)h_data_runB ->Clone("h_data"); h_data->Reset(); h_data->Add( h_data_runB ); h_data->Add( h_data_runC ); h_data->Add( h_data_runD ); h_mc2 -> SetLineColor(kBlack); h_mc2 -> SetFillColor(kBlue); //h_mc2 -> SetFillStyle(3004); h_mc3 -> SetLineColor(kBlack); h_mc3 -> SetFillColor(kGray+2); //h_mc3 -> SetFillStyle(3004); //h_mc4 -> SetLineColor(kBlack); //h_mc4 -> SetFillColor(kGray+3); //h_mc4 -> SetFillStyle(3004); //h_mc6 -> SetLineColor(kBlack); //h_mc6 -> SetFillColor(kRed+2); //h_mc6 -> SetFillStyle(3004); h_mc7 -> SetLineColor(kBlack); h_mc7 -> SetFillColor(kMagenta); //h_mc7 -> SetFillStyle(3004); h_mc8 -> SetLineColor(kGreen); //h_mc8 -> SetLineColor(kBlack); //h_mc8 -> SetFillColor(kPink); //h_mc8 -> SetFillStyle(3004); h_mc8 ->SetLineWidth(3); h_mc11->Scale(norm11); h_mc12->Scale(norm12); h_mc13->Scale(norm13); h_mc14->Scale(norm14); h_mc2->Scale(norm2); h_mc3->Scale(norm3); h_mc4->Scale(norm4); h_mc6->Scale(norm6); h_mc7->Scale(norm7); h_mc8->Scale(norm8); TH1F* h_mcDY = (TH1F*)h_mc11->Clone("h_mcDY"); h_mcDY->Reset(); h_mcDY->Add(h_mc14); h_mcDY->Add(h_mc13); h_mcDY->Add(h_mc12); h_mcDY->Add(h_mc11); h_mcDY -> SetLineColor(kBlack); h_mcDY -> SetFillColor(kYellow-4); //h_mcDY -> SetFillStyle(3004); TH1F* h_mcDiboson = (TH1F*)h_mc3->Clone("h_mcDiboson"); h_mcDiboson->Reset(); h_mcDiboson->Add(h_mc3); h_mcDiboson->Add(h_mc4); h_mcDiboson->Add(h_mc6); TH1F *ht = (TH1F*)h_mcDY->Clone("ht"); ht->Reset(); //ht->Add(h_mc8); ht->Add(h_mc7); //ht->Add(h_mc6); //ht->Add(h_mc4); //ht->Add(h_mc3); ht->Add(h_mcDiboson); ht->Add(h_mc2); ht->Add(h_mcDY); THStack *hs = new THStack("hs",""); //hs->Add(h_mc8); // ZH powheg hs->Add(h_mc7); // ZH madgraph //hs->Add(h_mc6); //hs->Add(h_mc4); //hs->Add(h_mc3); hs->Add(h_mcDiboson); hs->Add(h_mc2); hs->Add(h_mcDY); //TCanvas* c1 = 0; //c1 = new TCanvas("c","c",10,10,800,600); c1->cd(); TPad *pad1 = new TPad("pad1","pad1",0.0,0.3,1.0,1.0); pad1->SetBottomMargin(0.001); pad1->Draw(); pad1->cd(); if( title=="FATjetSDmass" || title=="FATjetSDmassCorr" || title=="FATjetPRmass" || title=="FATjetPRmassCorr" || title=="FATnSubjet" || title=="ZHmass" ) {pad1->SetLogy();} hs->Draw("HIST"); hs->GetYaxis()->SetTitle("Events"); hs->GetYaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetLabelSize(0.045); hs->GetYaxis()->SetTitleOffset(1.0);// 0.7 //hs->SetMinimum(8); hs->SetMinimum(0.1); hs->SetMaximum(1.2*hs->GetMaximum()); if (title=="ZHmass") { hs->GetXaxis()->SetRangeUser(0, 3000); } h_mc8->Draw("same hist"); h_data->Draw("EPX0SAMES"); h_data->SetMarkerColor(kBlack); h_data->SetMarkerStyle(20); h_data->SetMarkerSize (1.0); h_data->SetStats(0); TLegend *leg; if (title=="FATjetTau2dvTau1") { leg = new TLegend(0.15, 0.547, 0.41, 0.88); } else { leg = new TLegend(0.65, 0.547, 0.91, 0.88);} //leg = new TLegend(0.65, 0.547, 0.91, 0.88); leg->SetBorderSize(0); leg->SetEntrySeparation(0.01); leg->SetFillColor(0); leg->SetFillStyle(0); leg->AddEntry(h_data,"Data","p"); leg->AddEntry(h_mcDY,"DY","f"); leg->AddEntry(h_mc2,"t#bar{t}","f"); //leg->AddEntry(h_mc3,"ZZ","f"); //leg->AddEntry(h_mc4,"WZ","f"); //leg->AddEntry(h_mc6,"WW","f"); leg->AddEntry(h_mcDiboson,"Diboson","f"); leg->AddEntry(h_mc7,"ZH madgraph","f"); leg->AddEntry(h_mc8,"ZH powheg (not in stack)","f"); leg->Draw(); TLatex *lar = new TLatex(); lar->SetNDC(kTRUE); lar->SetTextSize(0.04); lar->SetLineWidth(5); lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}"); lar->DrawLatex(0.60, 0.94, "L = 12.8 fb^{-1} at #sqrt{s} = 13 TeV"); pad1->Update(); c1->Update(); c1->cd(); TH1F *h_ratio = (TH1F*)h_data->Clone("h_ratio"); TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);// 0.3 pad2->SetTopMargin(0); pad2->SetBottomMargin(0.3); pad2->Draw(); pad2->cd(); h_ratio->SetTitle(""); h_ratio->SetStats(0); if (title=="Zpt") { h_ratio->GetXaxis ()->SetTitle("p_{T}(Z) [GeV/c]"); } else if (title=="Zmass") { h_ratio->GetXaxis ()->SetTitle("M(Z) [GeV/c^{2}]");// } else if (title=="ZRapidity") { h_ratio->GetXaxis ()->SetTitle("y(Z)"); } else if (title=="Zeta") { h_ratio->GetXaxis ()->SetTitle("#eta(Z)"); } else if (title=="nVtx") { h_ratio->GetXaxis ()->SetTitle("Number of Vertices"); } else if (title=="leadElePt") { h_ratio->GetXaxis ()->SetTitle("Leading Electron p_{T} [GeV/c]"); } else if (title=="subleadElePt") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading Electron p_{T} [GeV/c]"); } else if (title=="leadEleEta") { h_ratio->GetXaxis ()->SetTitle("Leading Electron #eta"); } else if (title=="subleadEleEta") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading Electron #eta"); } else if (title=="leadMuPt") { h_ratio->GetXaxis ()->SetTitle("Leading Muon p_{T} [GeV/c]"); } else if (title=="subleadMuPt") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading Muon p_{T} [GeV/c]"); } else if (title=="leadMuEta") { h_ratio->GetXaxis ()->SetTitle("Leading Muon #eta"); } else if (title=="subleadMuEta") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading Muon #eta"); } else if (title=="FATjetPt") { h_ratio->GetXaxis ()->SetTitle("FAT Jet p_{T} [GeV/c]"); } else if (title=="FATjetEta") { h_ratio->GetXaxis ()->SetTitle("FAT Jet #eta"); } else if (title=="FATjetCISVV2") { h_ratio->GetXaxis ()->SetTitle("FAT Jet CSVv2"); } else if (title=="FATjetSDmass") { h_ratio->GetXaxis ()->SetTitle("FAT Jet Soft Drop Mass [GeV/c^{2}]"); } else if (title=="FATjetSDmassCorr") { h_ratio->GetXaxis ()->SetTitle("FAT Jet Corrected Soft Drop Mass [GeV/c^{2}]"); } else if (title=="FATjetPRmass") { h_ratio->GetXaxis ()->SetTitle("FAT Jet Pruned Mass [GeV/c^{2}]"); } else if (title=="FATjetPRmassCorr") { h_ratio->GetXaxis ()->SetTitle("FAT Jet L2L3 Corrected Pruned Mass [GeV/c^{2}]"); } else if (title=="FATjetTau1") { h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{1}"); } else if (title=="FATjetTau2") { h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{2}"); } else if (title=="FATjetTau2dvTau1") { h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{21}"); } else if (title=="FATnSubjet") { h_ratio->GetXaxis ()->SetTitle("Number of Subjets"); } else if (title=="FATsubjetLeadingPt") { h_ratio->GetXaxis ()->SetTitle("Leading SubJet p_{T} [GeV/c]"); } else if (title=="FATsubjetLeadingEta") { h_ratio->GetXaxis ()->SetTitle("Leading SubJet #eta"); } else if (title=="FATsubjetLeadingSDCSV") { h_ratio->GetXaxis ()->SetTitle("Leading SubJet Soft Drop CSV"); } else if (title=="FATsubjetSubLeadingPt") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet p_{T} [GeV/c]"); } else if (title=="FATsubjetSubLeadingEta") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet #eta"); } else if (title=="FATsubjetSubLeadingSDCSV") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet Soft Drop CSV"); } else if (title=="ADDjet_DoubleSV") { h_ratio->GetXaxis ()->SetTitle("ADDjet double b-tagger discriminator"); } else if (title=="ZHmass") { h_ratio->GetXaxis ()->SetTitle("ZH invariant mass [GeV/c^{2}]"); } if (title=="ZHmass") { h_ratio->GetXaxis()->SetRangeUser(0, 3000); } h_ratio->GetXaxis()->SetTitleSize(0.11); h_ratio->GetXaxis()->SetLabelFont(42); h_ratio->GetXaxis()->SetLabelSize(0.10); h_ratio->GetXaxis()->SetTitleFont(42); h_ratio->GetYaxis()->SetTitle("Data/MC"); h_ratio->GetYaxis()->SetNdivisions(505); h_ratio->GetYaxis()->SetTitleSize(0.11); h_ratio->GetYaxis()->SetLabelSize(0.10); h_ratio->GetYaxis()->SetRangeUser(0.2, 2); h_ratio->GetYaxis()->SetTitleOffset(0.33); h_ratio->Divide(ht); h_ratio->SetMarkerStyle(20); h_ratio->Draw("E0PX0"); TLine *OLine = new TLine(h_ratio->GetXaxis()->GetXmin(),1.,h_ratio->GetXaxis()->GetXmax(),1.); OLine->SetLineColor(kRed); OLine->SetLineWidth(2); OLine->Draw(); /* TLatex *lar = new TLatex(); lar->SetNDC(kTRUE); lar->SetTextSize(0.04); lar->SetLineWidth(5); lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}"); lar->DrawLatex(0.60, 0.94, "L = 4.327 fb^{-1} at #sqrt{s} = 13 TeV"); */ c1->cd(); //c1->SaveAs((path + title + ".pdf").c_str()); }
CMS_lumi( TPad* pad, int iPeriod, int iPosX ) { bool outOfFrame = false; if( iPosX/10==0 ) { outOfFrame = true; } int alignY_=3; int alignX_=2; if( iPosX/10==0 ) alignX_=1; if( iPosX==0 ) alignY_=1; if( iPosX/10==1 ) alignX_=1; if( iPosX/10==2 ) alignX_=2; if( iPosX/10==3 ) alignX_=3; int align_ = 10*alignX_ + alignY_; float H = pad->GetWh(); float W = pad->GetWw(); float l = pad->GetLeftMargin(); float t = pad->GetTopMargin(); float r = pad->GetRightMargin(); float b = pad->GetBottomMargin(); float e = 0.025; pad->cd(); TString lumiText; if( iPeriod==1 ) { lumiText += lumi_7TeV; lumiText += " (7 TeV)"; } else if ( iPeriod==2 ) { lumiText += " (8 TeV)"; } else if( iPeriod==3 ) { lumiText = lumi_8TeV; lumiText += " (8 TeV)"; lumiText += " + "; lumiText += lumi_7TeV; lumiText += " (7 TeV)"; } else if ( iPeriod==4 ) { lumiText += lumi_13TeV; lumiText += " (13 TeV)"; } else if ( iPeriod==7 ) { if( outOfFrame ) lumiText += "#scale[0.85]{"; lumiText += lumi_13TeV; lumiText += " (13 TeV)"; lumiText += " + "; lumiText += lumi_8TeV; lumiText += " (8 TeV)"; lumiText += " + "; lumiText += lumi_7TeV; lumiText += " (7 TeV)"; if( outOfFrame) lumiText += "}"; } else if ( iPeriod==12 ) { lumiText += "8 TeV"; } cout << lumiText << endl; TLatex latex; latex.SetNDC(); latex.SetTextAngle(0); latex.SetTextColor(kBlack); float extraTextSize = extraOverCmsTextSize*cmsTextSize; latex.SetTextFont(42); latex.SetTextAlign(31); latex.SetTextSize(lumiTextSize*t); latex.DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); if( outOfFrame ) { latex.SetTextFont(cmsTextFont); latex.SetTextAlign(11); latex.SetTextSize(cmsTextSize*t); latex.DrawLatex(l,1-t+lumiTextOffset*t,cmsText); } pad->cd(); float posX_; if( iPosX%10<=1 ) { posX_ = l + relPosX*(1-l-r); } else if( iPosX%10==2 ) { posX_ = l + 0.5*(1-l-r); } else if( iPosX%10==3 ) { posX_ = 1-r - relPosX*(1-l-r); } float posY_ = 1-t - relPosY*(1-t-b); if( !outOfFrame ) { if( drawLogo ) { posX_ = l + 0.045*(1-l-r)*W/H; posY_ = 1-t - 0.045*(1-t-b); float xl_0 = posX_; float yl_0 = posY_ - 0.15; float xl_1 = posX_ + 0.15*H/W; float yl_1 = posY_; TASImage* CMS_logo = new TASImage("CMS-BW-label.png"); TPad* pad_logo = new TPad("logo","logo", xl_0, yl_0, xl_1, yl_1 ); pad_logo->Draw(); pad_logo->cd(); CMS_logo->Draw("X"); pad_logo->Modified(); pad->cd(); } else { latex.SetTextFont(cmsTextFont); latex.SetTextSize(cmsTextSize*t); latex.SetTextAlign(align_); latex.DrawLatex(posX_, posY_, cmsText); if( writeExtraText ) { latex.SetTextFont(extraTextFont); latex.SetTextAlign(align_); latex.SetTextSize(extraTextSize*t); latex.DrawLatex(posX_, posY_- relExtraDY*cmsTextSize*t, extraText); } } } else if( writeExtraText ) { if( iPosX==0) { posX_ = l + relPosX*(1-l-r); posY_ = 1-t+lumiTextOffset*t; } latex.SetTextFont(extraTextFont); latex.SetTextSize(extraTextSize*t); latex.SetTextAlign(align_); latex.DrawLatex(posX_, posY_, extraText); } return; }
void mergeEff(int iCat_ = 0) { TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName()); dir.ReplaceAll("mergeEff.C",""); dir.ReplaceAll("/./","/"); ifstream in; const int nBinC = 13; // Cent(13), pT(7), y(6) const int nBinP = 7; // Cent(13), pT(7), y(6) const int nBinY = 6; // Cent(13), pT(7), y(6) double eff[100][100] = {0.0}; for(int idir = 1; idir < 101; idir++){ if(iCat_ == 0) in.open(Form("%s../Eff_00%d/eff_HighPt_Cents_default_Bit1_y_0.0_2.4_pT_6.5_30.0_pr.tex",dir.Data(),idir)); if(iCat_ == 1) in.open(Form("%s../Eff_00%d/eff_HighPt_Pts_default_Bit1_y_0.0_2.4_pT_6.5_30.0_pr.tex",dir.Data(),idir)); if(iCat_ == 2) in.open(Form("%s../Eff_00%d/eff_HighPt_Raps_default_Bit1_y_0.0_2.4_pT_6.5_30.0_pr.tex",dir.Data(),idir)); Float_t x[300]; Int_t nlines = 0; int nl = 0; while (1) { in >> x[0] ; eff[nl][idir-1] = x[0]; //cout<<"eff : "<<eff[nl][idir-1]<<endl; if (!in.good()) break; nlines++; nl++; } in.close(); } int nBins = 0; if(iCat_ == 0) nBins = nBinC; if(iCat_ == 1) nBins = nBinP; if(iCat_ == 2) nBins = nBinY; cout<<"nBins : "<<nBins<<endl; TH1F *hDis[13]; string eff_tot[100]; for(int in = 0; in < nBins; in++){ if(iCat_ == 2) hDis[in] = new TH1F(Form("hDis_%d",in),"",150,0.25,0.65); // cent if(iCat_ != 2) hDis[in] = new TH1F(Form("hDis_%d",in),"",120,0.25,0.85); // pT hDis[in]->Sumw2(); hDis[in]->SetMarkerStyle(20); hDis[in]->SetMarkerSize(1.2); puts(""); for(int id = 0; id < 100; id++){ printf("%0.4f ", eff[in][id]); hDis[in]->Fill(eff[in][id]); } } puts(""); const int nCentBins = 13; const int nRapBins = 6; const int nPtBins = 7; double ct_bound[nCentBins+1] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 40}; double pt_bound[nPtBins+1] = {6.5, 7.5, 8.5, 9.5, 11.0, 13.0, 16.0, 30.0}; double rap_bound[nRapBins+1] = {0.0, 0.4, 0.8, 1.2, 1.6, 2.0, 2.4}; char OutTextFile[100]; if(iCat_ == 0) sprintf(OutTextFile,"pbpb_prompt_cent.tex"); if(iCat_ == 1) sprintf(OutTextFile,"pbpb_prompt_pt.tex"); if(iCat_ == 2) sprintf(OutTextFile,"pbpb_prompt_rap.tex"); ofstream dataFile(OutTextFile); TLatex *lt = new TLatex(); lt->SetNDC(); TCanvas *c1 = new TCanvas("c1","",1400,900); c1->Divide(5,3); TCanvas *c2 = new TCanvas("c2","",1400,600); c2->Divide(5,2); for(int ic = 1; ic < nBins+1; ic++){ if(iCat_==0) c1->cd(ic); if(iCat_!=0) c2->cd(ic); hDis[ic-1]->Draw("E"); cout<<"Mean : "<<hDis[ic-1]->GetMean()<<endl; cout<<"RMS : "<<hDis[ic-1]->GetRMS()<<endl; if(iCat_ == 0) dataFile<<"Cent : "<<ct_bound[ic-1]*2.5<<"-"<<ct_bound[ic]*2.5<<endl; if(iCat_ == 1) dataFile<<"pT : "<<pt_bound[ic-1]<<"-"<<pt_bound[ic]<<endl; if(iCat_ == 2) dataFile<<"rap : "<<rap_bound[ic-1]<<"-"<<rap_bound[ic]<<endl; dataFile<<hDis[ic-1]->GetMean()<<" "<<hDis[ic-1]->GetRMS()<<endl; cout<<hDis[ic-1]->GetMean()<<" "<<hDis[ic-1]->GetRMS()<<endl; if(iCat_==0) lt->DrawLatex(0.15,0.95,"PbPb, p_{T} [6.5,30], y [0.0,2.4]"); if(iCat_==0) lt->DrawLatex(0.15,0.85,Form("Cent [%0.0f,%0.0f]",ct_bound[ic-1]*2.5,ct_bound[ic]*2.5)); if(iCat_==1) lt->DrawLatex(0.15,0.95,Form("PbPb, p_{T} [%0.1f,%0.1f], y [0.0,2.4]",pt_bound[ic-1],pt_bound[ic])); if(iCat_==1) lt->DrawLatex(0.15,0.85,"Cent 0-100"); if(iCat_==2) lt->DrawLatex(0.15,0.95,Form("PbPb, p_{T} [6.5,30], y [%0.1f,%0.1f]",rap_bound[ic-1],rap_bound[ic])); if(iCat_==2) lt->DrawLatex(0.15,0.85,"Cent 0-100"); } if(iCat_ == 0) c1->SaveAs("plot_pbpb_eff_STA_pr_dis_cent.png");c1->SaveAs("plot_pbpb_eff_STA_pr_dis_cent.pdf"); if(iCat_ == 1) c2->SaveAs("plot_pbpb_eff_STA_pr_dis_pt.png");c2->SaveAs("plot_pbpb_eff_STA_pr_dis_pt.pdf"); if(iCat_ == 2) c2->SaveAs("plot_pbpb_eff_STA_pr_dis_rap.png");c2->SaveAs("plot_pbpb_eff_STA_pr_dis_rap.pdf"); return; }
void plotV2vstheta(){ TFile *f; int isSum=0; const int ntotbin=5; const int trkpointmin[ntotbin] = {120,150,185,220,260}; const int trkpointmax[ntotbin] = {150,185,220,260,300}; int trkbin=1; int xbin=0; c1 = new TCanvas("c1"," ",1200,700); makeMultiPanelCanvas(c1,3,2,0,0,0.25,0.2,0.03); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetErrorX(0); TH1D *hFrame = new TH1D("","",100,0,2); hFrame->SetTitle(""); hFrame->GetXaxis()->SetTitle("#theta"); hFrame->GetYaxis()->SetTitle("reference V_{2}"); hFrame->GetYaxis()->SetTitleOffset(1.1); hFrame->GetXaxis()->SetTitleSize(0.04); hFrame->GetYaxis()->SetTitleSize(0.04); hFrame->GetXaxis()->SetRangeUser(0,1.5); hFrame->SetMinimum(0.030); hFrame->SetMaximum(0.065); for(int trkbin=0;trkbin<ntotbin; trkbin++){ if(isSum==0){ f = TFile::Open(Form("M%d%d/mergedV_Prod.root",trkpointmax[trkbin],trkpointmin[trkbin])); } else{ f = TFile::Open(Form("M%d%d/mergedV_Sum.root",trkpointmax[trkbin],trkpointmin[trkbin])); } TVectorD* vecVmean = (TVectorD*)f->Get(Form("D_%d/Vmean",xbin)); TVectorD* vecV = (TVectorD*)f->Get(Form("D_%d/D_0/V",xbin)); double Vmean = (*vecVmean)[0]; double *V = vecV->GetMatrixArray(); double theta[ntheta]; for(int itheta=0;itheta<ntheta;itheta++){ theta[itheta]=itheta*TMath::Pi()/ntheta/nn; } int maxper10 = findmaxper(V,ntheta,Vmean); double maxper = (double)(maxper10+1)/10; c1->cd(trkbin+1); hFrame->Draw(); TGraph *gV2theta = new TGraph(ntheta,theta,V); gV2theta->SetMarkerStyle(20); gV2theta->SetMarkerSize(1.3); gV2theta->SetMarkerColor(1); gV2theta->SetLineColor(1); gV2theta->Draw("Psame"); TLine *lup = new TLine(gV2theta->GetXaxis()->GetXmin(),Vmean*(1+maxper), gV2theta->GetXaxis()->GetXmax(),Vmean*(1+maxper)); TLine *ldown = new TLine(gV2theta->GetXaxis()->GetXmin(),Vmean*(1-maxper), gV2theta->GetXaxis()->GetXmax(),Vmean*(1-maxper)); TLine *l = new TLine(hFrame->GetXaxis()->GetXmin(),Vmean, hFrame->GetXaxis()->GetXmax(),Vmean); l->SetLineStyle(2); lup->SetLineStyle(2); ldown->SetLineStyle(2); l->SetLineWidth(1.2); lup->SetLineWidth(1.2); ldown->SetLineWidth(1.2); TLatex *tl = new TLatex(); // tl->SetNDC(); tl->SetTextFont(42); tl->SetTextSize(0.04); // tl->SetBorderStyle(0); tl->DrawLatex(0,Vmean*(1+maxper),Form("mean up %.f%%",maxper*100)); tl->DrawLatex(0,Vmean*(1-maxper),Form("mean down %.f%%",maxper*100)); tl->SetNDC(); tl->DrawLatex(0.7,0.85,Form("Multiplicity %d to %d",trkpointmin[trkbin],trkpointmax[trkbin])); l->Draw("same"); lup->Draw("same"); ldown->Draw("same"); } c1->cd(ntotbin+1); TLatex *tlx0 = new TLatex(0.12,0.3,Form("PF candi, use p_{T} weight")); TLatex *tlx1 = new TLatex(0.12,0.25,Form("%.1f<p_{T}<%.1f (GeV/c)",0.3,6.0)); tlx0->SetNDC(); tlx1->SetNDC(); tlx0->SetTextSize(0.045); tlx1->SetTextSize(0.045); hFrame->Draw(); tlx0->Draw("same"); tlx1->Draw("same"); if(isSum==0)c1->SaveAs("hV2theta_Prod.png"); else c1->SaveAs("hV2theta_Sum.png"); }
void fitX(TString infname="/data/twang/BfinderRun2/DoubleMu/BfinderData_pp_20151202_bPt0jpsiPt0tkPt0p5/finder_pp_merged.root") { TFile *inf = new TFile(infname.Data()); TTree *ntmix = (TTree*) inf->Get("Bfinder/ntmix"); TH1D *h = new TH1D("h","",40,3.6,4); TCut cutTrk = "1"; //original YJ //TCut cutTrk = "Btrk1PixelHit>=2&&Btrk1StripHit>=7&&Btrk1Chi2ndf<5&&Btrk2PixelHit>=2&&Btrk2StripHit>=7&&Btrk2Chi2ndf<5"; TCut cutTotal="Btype==7&&Bpt>10&&abs(Beta)<10&&sqrt((Bmumueta-Btrk1Eta)*(Bmumueta-Btrk1Eta)+(Bmumuphi-Btrk1Phi)*(Bmumuphi-Btrk1Phi))<9999"&&cutTrk; TCanvas *c = new TCanvas("c","",750,600); ntmix->Draw("Bmass>>h",cutTotal); TFile*output=new TFile("histoX.root","recreate"); output->cd(); h->Write(); output->Close(); h->Sumw2(); TF1 *f = new TF1("f","[0]+[1]*x+[2]*x*x+[8]*x*x*x+[9]*x*x*x*x+[3]*Gaus(x,[4],[5])+[6]*Gaus(x,[7],[5])"); f->SetLineColor(4); f->SetParameters(-2.2597e4,1.326e4,-1.727e3,50,3.686,0.00357,1,3.8725,0.0054); f->FixParameter(4,3.686); f->FixParameter(5,0.00357); f->FixParameter(7,3.8725); h->Fit("f","LL"); h->Fit("f",""); h->Fit("f","LL"); h->Fit("f","LL","",3.65,3.94); h->Fit("f","LL","",3.65,3.94); f->ReleaseParameter(4); f->ReleaseParameter(5); f->ReleaseParameter(7); h->Fit("f","LL","",3.65,3.94); h->SetXTitle("m(J/#psi#pi^{+}#pi^{-}) [GeV]"); h->SetYTitle("Entries"); h->SetStats(0); h->SetAxisRange(0,h->GetMaximum()*1.3 ,"Y"); TF1 *f2 = new TF1("f2","[0]+[1]*x+[2]*x*x+0*Gaus(x,[4],[5])+0*Gaus(x,[7],[5])"); f2->SetParameter(0,f->GetParameter(0)); f2->SetParameter(1,f->GetParameter(1)); f2->SetParameter(2,f->GetParameter(2)); TF1 *f3 = new TF1("f3","[3]*Gaus(x,[4],[5])+[6]*Gaus(x,[7],[5])"); f3->SetParameter(3,f->GetParameter(3)); f3->SetParameter(4,f->GetParameter(4)); f3->SetParameter(5,f->GetParameter(5)); f3->SetParameter(6,f->GetParameter(6)); f3->SetParameter(7,f->GetParameter(7)); f3->SetParameter(8,f->GetParameter(8)); f->SetLineColor(4); f2->SetLineColor(4); f3->SetRange(3.65,3.94); f2->SetRange(3.65,3.94); f2->SetLineStyle(2); f3->SetLineStyle(2); f2->Draw("same"); f3->SetLineColor(2); f3->SetFillStyle(3004); f3->SetFillColor(2); f3->Draw("same"); TLatex *l = new TLatex(3.7,70./80*h->GetMaximum(),"#psi(2S)"); l->Draw(); TLatex *l2 = new TLatex(3.875,50./80*h->GetMaximum(),"X(3872)"); l2->Draw(); TLatex *l3 = new TLatex(3.812,70./80*h->GetMaximum(),"CMS Preliminary"); l3->Draw(); TLatex *l4 = new TLatex(3.78,60./80*h->GetMaximum(),"pp #sqrt{s_{NN}}=5.02 TeV"); l4->Draw(); cout<<ntmix->GetEntries()<<endl; TH1D *hProj = (TH1D*)h->Clone("hProj"); hProj->Clear(); f->SetRange(3.6,4); for (int i=0;i<h->GetEntries()*11;i++) { hProj->Fill(f->GetRandom()); } TCanvas *c2 = new TCanvas("c2","",750,600); hProj->SetTitle("Estimated Projection"); hProj->Draw("e"); }
int compare(int centbin, int type, int isjf, const string frun10, const string fout)//frun10:"run10_output_old.lst" { string frun11; if(isjf){ if(type == 0) frun11 = "/direct/phenix+u/hge/offline/AnalysisTrain/Correlation/macros/makejfs_inc_fold_taxi5286.root"; if(type == 1) frun11 = "/direct/phenix+u/hge/offline/AnalysisTrain/Correlation/macros/makejfs_pi0_fold_taxi5286.root"; if(type == 2) frun11 = "/direct/phenix+u/hge/offline/AnalysisTrain/Correlation/macros/makejfs_dec_fold_taxi5286.root"; if(type == 3) frun11 = "/direct/phenix+u/hge/offline/AnalysisTrain/Correlation/macros/makedirs_taxi5286.root"; } else{ if(type == 0) frun11 = "/direct/phenix+u/hge/offline/AnalysisTrain/Correlation/macros/makecfs_inc_fold_taxi5286.root"; if(type == 1) frun11 = "/direct/phenix+u/hge/offline/AnalysisTrain/Correlation/macros/makecfs_pi0_fold_taxi5286.root"; if(type == 2) frun11 = "/direct/phenix+u/hge/offline/AnalysisTrain/Correlation/macros/makecfs_dec_fold_taxi5286.root"; } TFile* f11 = new TFile(frun11.c_str()); vector<string> Run10FileList; char buffer[256]; cout<<"opening run10 input file list: " << frun10.c_str() << endl; ifstream flist(frun10.c_str()); if( !flist.is_open()) return -1; while (flist.getline(buffer, 256, '\n')){ cout<<"in the while loop"<<endl; char this_file[512]; strcpy(this_file, buffer); cout<<"this_file: "<<this_file<<endl; string s (this_file); cout<<"s: "<<s.c_str()<<endl; Run10FileList.push_back(s); } cout << "Done making Run10FileList vector." << endl; const int Nfiles = Run10FileList.size(); cout<<"Nfiles = "<<Nfiles<<endl; TFile* foutput = new TFile(fout.c_str(), "recreate"); foutput->cd(); TH1D *my_corr; TH1D *corr; TH1D *ratio; string file_string; string photon_bin_string; string hadron_bin_string; int photon_bin; int hadron_bin; ostringstream bin; ostringstream cbin; ostringstream cfname; ostringstream jfname; ostringstream dirname; ostringstream can_name; ostringstream latex_name; string ratio_name; cout<<"define canvases."<<endl; TCanvas *can[4]; TCanvas *can_ratio[4]; for(int i=0; i<4; i++){ can_name.str(""); can_name << "can_p"<<i; can[i] = new TCanvas(can_name.str().c_str(),can_name.str().c_str()); can[i]->Divide(3,2); can_name.str(""); can_name << "can_ratio_p"<<i; can_ratio[i] = new TCanvas(can_name.str().c_str(),can_name.str().c_str()); can_ratio[i]->Divide(3,2); } TH1D* ttest_CF = new TH1D("ttest_CF","ttest_CF",50,-5,5); ttest_CF->GetXaxis()->SetTitle("t"); TH1D* tprob_CF = new TH1D("tprob_CF","tprob_CF",50,0,1); tprob_CF->GetXaxis()->SetTitle("prob"); TH1D* chitest_CF = new TH1D("chitest_CF","chitest_CF",50,0,5); chitest_CF->GetXaxis()->SetTitle("#chi^{2}/NDF"); TH1D* chiprob_CF = new TH1D("chiprob_CF","chiprob_CF",50,0,1); chiprob_CF->GetXaxis()->SetTitle("prob"); cout<<"start looping run10 files."<<endl; for(int ifile = 0; ifile < Nfiles; ifile++){ cout<<"Run10FileList ["<<ifile<<"] = "<<Run10FileList[ifile]<<endl; file_string = Run10FileList[ifile]; int p1 = file_string.find_last_of("/"); cout<<"p1 = "<<p1<<endl; photon_bin_string = file_string.substr(p1+6,1); photon_bin = atoi(photon_bin_string.c_str()); int p2 = file_string.find_last_of("."); cout<<"p2 = "<<p2<<endl; hadron_bin_string = file_string.substr(p2-1,1); hadron_bin = atoi(hadron_bin_string.c_str()); cout<<"photon_bin: "<<photon_bin<<" hadron_bin: "<<hadron_bin<<endl; cbin.str(""); cbin << centbin; cfname.str(""); jfname.str(""); dirname.str(""); can_name.str(""); switch(photon_bin){ case 5: cout<<"photon case 5"<<endl; latex_name.str(""); latex_name << "5-7 #times "; switch(hadron_bin){ case 1: latex_name << "0.5-1 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p0_h0"; jfname << "JF_c"<<cbin.str()<<"_p0_h0"; dirname << "DIR_JF_c"<<cbin.str()<<"_p0_h0"; can[0]->cd(1); break; case 2: latex_name << "1-2 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p0_h1"; jfname << "JF_c"<<cbin.str()<<"_p0_h1"; dirname << "DIR_JF_c"<<cbin.str()<<"_p0_h1"; can[0]->cd(2); break; case 3: latex_name << "2-3 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p0_h2"; jfname << "JF_c"<<cbin.str()<<"_p0_h2"; dirname << "DIR_JF_c"<<cbin.str()<<"_p0_h2"; can[0]->cd(3); break; case 5: latex_name << "3-5 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p0_h3"; jfname << "JF_c"<<cbin.str()<<"_p0_h3"; dirname << "DIR_JF_c"<<cbin.str()<<"_p0_h3"; can[0]->cd(4); break; case 0: latex_name << "5-7 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p0_h4"; jfname << "JF_c"<<cbin.str()<<"_p0_h4"; dirname << "DIR_JF_c"<<cbin.str()<<"_p0_h4"; can[0]->cd(5); break; } break; case 7: cout<<"photon case 7"<<endl; latex_name.str(""); latex_name << "7-9 #times "; switch(hadron_bin){ case 1: latex_name << "0.5-1 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p1_h0"; jfname << "JF_c"<<cbin.str()<<"_p1_h0"; dirname << "DIR_JF_c"<<cbin.str()<<"_p1_h0"; can[1]->cd(1); break; case 2: latex_name << "1-2 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p1_h1"; jfname << "JF_c"<<cbin.str()<<"_p1_h1"; dirname << "DIR_JF_c"<<cbin.str()<<"_p1_h1"; can[1]->cd(2); break; case 3: latex_name << "2-3 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p1_h2"; jfname << "JF_c"<<cbin.str()<<"_p1_h2"; dirname << "DIR_JF_c"<<cbin.str()<<"_p1_h2"; can[1]->cd(3); break; case 5: latex_name << "3-5 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p1_h3"; jfname << "JF_c"<<cbin.str()<<"_p1_h3"; dirname << "DIR_JF_c"<<cbin.str()<<"_p1_h3"; can[1]->cd(4); break; case 0: latex_name << "5-7 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p1_h4"; jfname << "JF_c"<<cbin.str()<<"_p1_h4"; dirname << "DIR_JF_c"<<cbin.str()<<"_p1_h4"; can[1]->cd(5); break; } break; case 9: cout<<"photon case 9"<<endl; latex_name.str(""); latex_name << "9-12 #times "; switch(hadron_bin){ case 1: latex_name << "0.5-1 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p2_h0"; jfname << "JF_c"<<cbin.str()<<"_p2_h0"; dirname << "DIR_JF_c"<<cbin.str()<<"_p2_h0"; can[2]->cd(1); break; case 2: latex_name << "1-2 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p2_h1"; jfname << "JF_c"<<cbin.str()<<"_p2_h1"; dirname << "DIR_JF_c"<<cbin.str()<<"_p2_h1"; can[2]->cd(2); break; case 3: latex_name << "2-3 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p2_h2"; jfname << "JF_c"<<cbin.str()<<"_p2_h2"; dirname << "DIR_JF_c"<<cbin.str()<<"_p2_h2"; can[2]->cd(3); break; case 5: latex_name << "3-5 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p2_h3"; jfname << "JF_c"<<cbin.str()<<"_p2_h3"; dirname << "DIR_JF_c"<<cbin.str()<<"_p2_h3"; can[2]->cd(4); break; case 0: latex_name << "5-7 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p2_h4"; jfname << "JF_c"<<cbin.str()<<"_p2_h4"; dirname << "DIR_JF_c"<<cbin.str()<<"_p2_h4"; can[2]->cd(5); break; } break; case 1: cout<<"photon case 12"<<endl; latex_name.str(""); latex_name << "12-15 #times "; switch(hadron_bin){ case 1: latex_name << "0.5-1 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p3_h0"; jfname << "JF_c"<<cbin.str()<<"_p3_h0"; dirname << "DIR_JF_c"<<cbin.str()<<"_p3_h0"; can[3]->cd(1); break; case 2: latex_name << "1-2 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p3_h1"; jfname << "JF_c"<<cbin.str()<<"_p3_h1"; dirname << "DIR_JF_c"<<cbin.str()<<"_p3_h1"; can[3]->cd(2); break; case 3: latex_name << "2-3 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p3_h2"; jfname << "JF_c"<<cbin.str()<<"_p3_h2"; dirname << "DIR_JF_c"<<cbin.str()<<"_p3_h2"; can[3]->cd(3); break; case 5: latex_name << "3-5 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p3_h3"; jfname << "JF_c"<<cbin.str()<<"_p3_h3"; dirname << "DIR_JF_c"<<cbin.str()<<"_p3_h3"; can[3]->cd(4); break; case 0: latex_name << "5-7 GeV/c"; cfname << "CF_c"<<cbin.str()<<"_p3_h4"; jfname << "JF_c"<<cbin.str()<<"_p3_h4"; dirname << "DIR_JF_c"<<cbin.str()<<"_p3_h4"; can[3]->cd(5); break; } break; default: cout << "no such photon bin!" << endl; } TFile* file = new TFile(file_string.c_str()); if (! file->IsOpen() ) { cout << "cannot open file '" << file_string << "'\n"; continue; } cout<<"f11 CF: "<<cfname.str().c_str()<<endl; cout<<"f11 JF: "<<jfname.str().c_str()<<endl; cout<<"f11 DIR: "<<dirname.str().c_str()<<endl; cout<<"f10: "<<file_string.c_str()<<endl; if(isjf){ if(type==3) my_corr = new TH1D (*(TH1D*)f11->Get(dirname.str().c_str())); else my_corr = new TH1D (*(TH1D*)f11->Get(jfname.str().c_str())); if(type == 0) corr = new TH1D (*(TH1D*)file->Get("JF_INC")); if(type == 1) corr = new TH1D (*(TH1D*)file->Get("JF_PI0")); if(type == 2) corr = new TH1D (*(TH1D*)file->Get("JF_DEC")); if(type == 3) corr = new TH1D (*(TH1D*)file->Get("JF_DIR")); } else{ my_corr = new TH1D (*(TH1D*)f11->Get(cfname.str().c_str())); if(type == 0) corr = new TH1D (*(TH1D*)file->Get("hDPHI_INC")); if(type == 1) corr = new TH1D (*(TH1D*)file->Get("hDPHI_PI0")); if(type == 2) corr = new TH1D (*(TH1D*)file->Get("hDPHI_DEC")); } int nReb; if(photon_bin == 5) nReb = 3; else if(photon_bin == 7) nReb = 5; else nReb = 6; corr->Rebin(nReb); my_corr->Rebin(nReb); // if(!isjf){ double my_R = my_corr->Integral("width")/PI; cout<<"my_R = "<<my_R<<endl; my_corr->Scale(1./my_R); double R = corr->Integral("width")/PI; cout<<"R = "<<R<<endl; //corr->Sumw2(); cout<<"my_R/R = "<<my_R/R<<endl; corr->Scale(1./R); // } corr->SetMarkerStyle(20); corr->SetMarkerSize(0.8); my_corr->SetMarkerColor(1); my_corr->SetLineColor(1); if(isjf){ double ymin = corr->GetMinimum(); double ymax = corr->GetMaximum(); if(my_corr->GetMaximum() > ymax) ymax = my_corr->GetMaximum(); if(my_corr->GetMinimum() < ymin) ymin = my_corr->GetMinimum(); corr->SetAxisRange(ymin-0.01, 1.2*ymax,"Y"); } corr->GetYaxis()->SetTitleOffset(1.9); corr->Draw(); my_corr->Draw("same"); TLegend *l1 = new TLegend(0.7,0.7,0.9,0.9,"","brNDC"); l1->AddEntry(my_corr,"Run11","lpf"); l1->AddEntry(corr,"Run10","lpf"); if(hadron_bin==0) l1->Draw("same"); TLatex *la = new TLatex(0.3, 0.75, latex_name.str().c_str()); la->SetNDC(); la->Draw("same"); string pbin_string = cfname.str().substr(7,1); string hbin_string = cfname.str().substr(10,1); if(pbin_string.compare("0") == 0){ if(hbin_string.compare("0") == 0) can_ratio[0]->cd(1); if(hbin_string.compare("1") == 0) can_ratio[0]->cd(2); if(hbin_string.compare("2") == 0) can_ratio[0]->cd(3); if(hbin_string.compare("3") == 0) can_ratio[0]->cd(4); if(hbin_string.compare("4") == 0) can_ratio[0]->cd(5); } if(pbin_string.compare("1") == 0){ if(hbin_string.compare("0") == 0) can_ratio[1]->cd(1); if(hbin_string.compare("1") == 0) can_ratio[1]->cd(2); if(hbin_string.compare("2") == 0) can_ratio[1]->cd(3); if(hbin_string.compare("3") == 0) can_ratio[1]->cd(4); if(hbin_string.compare("4") == 0) can_ratio[1]->cd(5); } if(pbin_string.compare("2") == 0){ if(hbin_string.compare("0") == 0) can_ratio[2]->cd(1); if(hbin_string.compare("1") == 0) can_ratio[2]->cd(2); if(hbin_string.compare("2") == 0) can_ratio[2]->cd(3); if(hbin_string.compare("3") == 0) can_ratio[2]->cd(4); if(hbin_string.compare("4") == 0) can_ratio[2]->cd(5); } if(pbin_string.compare("3") == 0){ if(hbin_string.compare("0") == 0) can_ratio[3]->cd(1); if(hbin_string.compare("1") == 0) can_ratio[3]->cd(2); if(hbin_string.compare("2") == 0) can_ratio[3]->cd(3); if(hbin_string.compare("3") == 0) can_ratio[3]->cd(4); if(hbin_string.compare("4") == 0) can_ratio[3]->cd(5); } if(isjf) ratio_name = "ratio_" + jfname.str(); else ratio_name = "ratio_" + cfname.str(); ratio = new TH1D (*(TH1D*)my_corr); ratio->SetName(ratio_name.c_str()); cout<<"before dividing"<<endl; ratio->Divide(corr); if(isjf) ratio->SetAxisRange(-3.0, 5.0, "Y"); ratio->Draw(); la->Draw("same"); if(isjf){ ratio_name = "ratio_fit_" + jfname.str(); /* ratio_fit = new TF1(ratio_name.c_str(),"pol0(0)"); ratio->Fit(ratio_name.c_str(),"BQ"); double fitconst = Round(ratio_fit->GetParameter(0)); bin.str(""); bin << "ratio #approx "<<fitconst; TLatex *la_const = new TLatex(0.6, 0.25, bin.str().c_str()); la_const->SetNDC(); la_const->Draw("same"); double fit_chi2 = ratio_fit->GetChisquare(); int fit_ndf = ratio_fit->GetNDF(); double chi2 = Round(fit_chi2/fit_ndf); bin.str(""); bin << "#chi^{2} = "<<chi2; TLatex *la_chi2 = new TLatex(0.6, 0.2, bin.str().c_str()); la_chi2->SetNDC(); la_chi2->Draw("same"); */ } // if(!isjf){ //Do a chisquare test for CF comparison. double prob = 0; double t = 0; double chi2 = 0; double nbins = (double)corr->GetNbinsX(); double ncounts1 = my_corr->GetEntries(); double ncounts2 = corr->GetEntries(); double var1 = 0; double var2 = 0; double mean1 = 0; double mean2 = 0; double sumw7 = 0; double sumw10 = 0; my_corr->IntegralAndError(1,nbins,sumw7); my_corr->IntegralAndError(1,nbins,sumw10); for( int ib = 1; ib <= nbins; ib++ ) { double err1 = my_corr->GetBinError(ib); mean1 += my_corr->GetBinContent(ib); double err2 = corr->GetBinError(ib); mean2 += corr->GetBinContent(ib); chi2 += GetChiSquare(my_corr->GetBinContent(ib),corr->GetBinContent(ib),err1,err2); var1 += err1*err1; var2 += err2*err2; } std::cout << std::endl; std::cout << "t-test for " << ncounts1 << "," << ncounts2 << " counts with means of " << mean1/nbins << "," << mean2/nbins << " and uncertainties of " << sqrt(var1) << "," << sqrt(var2) << std::endl; //var1 += pow(JF_INC_run7->GetMeanError(),2); //var2 += pow(JF_INC_run10->GetMeanError(),2); DoTtest(nbins,nbins,mean1/nbins,mean2/nbins,sqrt(var1),sqrt(var2),t,prob); ttest_CF->Fill(t); tprob_CF->Fill(prob); double cprob = GetChiSquareProb(nbins,chi2); double reducedchi2 = chi2/nbins; cout<<"reducedchi2 = "<<reducedchi2<<endl; reducedchi2 = Round(reducedchi2); cout<<reducedchi2<<endl; cprob = Round(cprob); latex_name.str(""); latex_name << "#chi^{2} = "<<reducedchi2; TLatex *la_chi2 = new TLatex(0.6, 0.2, latex_name.str().c_str()); la_chi2->SetNDC(); la_chi2->Draw("same"); latex_name.str(""); latex_name << "p = "<<cprob; TLatex *la_cprob = new TLatex(0.6, 0.15, latex_name.str().c_str()); la_cprob->SetNDC(); la_cprob->Draw("same"); chitest_CF->Fill(chi2/nbins); chiprob_CF->Fill(cprob); // } } foutput->cd(); for(int i=0; i<4; i++){ can[i]->Write(); can_ratio[i]->Write(); } if(!isjf){ ttest_CF->Write(); tprob_CF->Write(); chitest_CF->Write(); chiprob_CF->Write(); } cout<<"finish writing out."<<endl; return 0; }
int do1dfit(RooDataSet *dset_data_axis1,RooDataSet *dset_rcone_axis1,RooDataSet *dset_sideb_axis1,RooDataSet*dset_testbkg,int im, double pu[], double puerr[]){ //reweighting cout << "massbin " << im << endl; dset_data_axis1->Print(); dset_rcone_axis1->Print(); dset_sideb_axis1->Print(); if(debug) dset_testbkg->Print(); // cout << "ratio Entries truth/data weighted " << dset_rcone_axis1->sumEntries()/ dset_data_axis1->sumEntries() << endl; reweight_rhosigma(w_rhor,w_rhoro,w_rhorn,w_rhor2o,w_rhornr,w_rhor2,w_sigmarn,w_sigmar2o,w_sigmarnr,w_sigmar2,&dset_rcone_axis1,dset_data_axis1); reweight_rhosigma(w_rho,w_rhoo,w_rhon,w_rho2o,w_rhonr,w_rho2,w_sigman,w_sigma2o,w_sigmanr,w_sigma2,&dset_sideb_axis1,dset_data_axis1); reweight_eta_1d(w_etar,w_etaro,w_etarn,w_etar2o,w_etarnr,w_etar2,&dset_rcone_axis1,dset_data_axis1,1); reweight_eta_1d(w_eta,w_etao,w_etan,w_eta2o,w_etanr,w_eta2,&dset_sideb_axis1,dset_data_axis1,1); reweight_pt_1d(w_pt,w_pto,w_ptn,w_pt2o,w_ptnr,w_pt2,&dset_sideb_axis1,dset_data_axis1,1); //no reweighting for pt if random cone applied if(truthfit){ reweight_pt_1d(w_ptr,w_ptro,w_ptrn,w_ptr2o,w_ptrnr,w_ptr2,&dset_rcone_axis1,dset_data_axis1,1); reweight_diphotonpt_1d(w_diphoptr,w_diphoptro,w_diphoptrn,w_diphoptr2o,w_diphoptrnr,w_diphoptr2,&dset_rcone_axis1,dset_data_axis1); } reweight_diphotonpt_1d(w_diphopt,w_diphopto,w_diphoptn,w_diphopt2o,w_diphoptnr,w_diphopt2,&dset_sideb_axis1,dset_data_axis1); if(check){ reweight_rhosigma(w_rhor,w_rhoro,w_rhorn,w_rhor2o,w_rhornr,w_rhor2,w_sigmarn,w_sigmar2o,w_sigmarnr,w_sigmar2,&dset_testbkg,dset_data_axis1); reweight_eta_1d(w_etar,w_etaro,w_etarn,w_etar2o,w_etarnr,w_etar2,&dset_testbkg,dset_data_axis1,1); reweight_pt_1d(w_ptr,w_ptro,w_ptrn,w_ptr2o,w_ptrnr,w_ptr2,&dset_testbkg,dset_data_axis1,1); reweight_diphotonpt_1d(w_diphoptr,w_diphoptro,w_diphoptrn,w_diphoptr2o,w_diphoptrnr,w_diphoptr2,&dset_testbkg,dset_data_axis1); RooDataHist *test_side2 = new RooDataHist("test_side2","test_side2",RooArgSet(*roovar1)); test_side2->add(*dset_sideb_axis1); RooDataHist *test_bkg2 = new RooDataHist("test_bkg2","test_bkg2",RooArgSet(*roovar1)); test_bkg2->add(*dset_testbkg); RooHistPdf *test_sidepdf2 = new RooHistPdf("test_sidepdf2","test_sidepdf2",RooArgList(*roovar1),*test_side2); RooHistPdf *test_bkgpdf2 = new RooHistPdf("test_bkgpdf2","test_bkgpdf2",RooArgList(*roovar1),*test_bkg2); TCanvas *c4=new TCanvas("c4","isolation comparison after reweighting"); c4->cd(); c4->SetLogy(); RooPlot *testp2 = roovar1->frame(Title("sideband bkg comparison after reweighting")); test_sidepdf2->plotOn(testp2,LineStyle(kDashed),LineColor(kRed),Name("sideband")); test_bkgpdf2->plotOn(testp2,LineStyle(kDashed),LineColor(kBlack),Name("bkg")); testp2->Draw(); // c4->SaveAs("../plots/sideband_bkg_comparison_reweight.root") ; // c4->SaveAs("../plots/sideband_bkg_comparison_reweight.png") ; c4->SaveAs("../plots/sig_comparison_reweight.root") ; c4->SaveAs("../plots/sig_comparison_reweight.png") ; } if(!massbinned) { TCanvas * c_reweights=new TCanvas("c_reweights","c_reweights"); c_reweights->Divide(3,2); c_reweights->cd(1); w_ptn->Draw("colz"); c_reweights->cd(2); w_pt2o->Draw("colz"); c_reweights->cd(3); w_ptnr->Draw("colz"); c_reweights->cd(4); w_pt2->Draw("colz"); c_reweights->cd(5);w_pt->Draw(); c_reweights->cd(6); w_pto->Draw(); c_reweights->SaveAs("../plots/c_reweights.root");c_reweights->SaveAs("../plots/c_reweights.png"); TCanvas * c_reweights2=new TCanvas("c_reweights2","c_reweights2"); c_reweights2->Divide(3,2); c_reweights2->cd(1); w_diphoptn->Draw("colz"); c_reweights2->cd(2); w_diphopt2o->Draw("colz"); c_reweights2->cd(3); w_diphoptnr->Draw("colz");c_reweights2->cd(4); w_diphopt2->Draw("colz"); c_reweights2->cd(5);w_diphopt->Draw(); c_reweights2->cd(6); w_diphopto->Draw(); c_reweights2->SaveAs("../plots/c_reweights2.root"); c_reweights2->SaveAs("../plots/c_reweights2.png"); TCanvas * c_rhoreweights=new TCanvas("c_rhoreweights","c_rhoreweights"); c_rhoreweights->Divide(3,2); c_rhoreweights->cd(1); w_rhon->Draw("colz"); c_rhoreweights->cd(2); w_rho2o->Draw("colz"); c_rhoreweights->cd(3); w_rhonr->Draw("colz"); c_rhoreweights->cd(4); w_rho2->Draw("colz"); c_rhoreweights->cd(5); w_rho->Draw();c_rhoreweights->cd(6); w_rhoo->Draw(); c_rhoreweights->SaveAs("../plots/c_rhoreweights.root"); c_rhoreweights->SaveAs("../plots/c_rhoreweights.png"); TCanvas * c_sigmareweights=new TCanvas("c_sigmareweights","c_sigmareweights"); c_sigmareweights->Divide(3,2); c_sigmareweights->cd(1); w_sigman->Draw("colz"); c_sigmareweights->cd(2); w_sigma2o->Draw("colz"); c_sigmareweights->cd(3); w_sigmanr->Draw("colz"); c_sigmareweights->cd(4); w_sigma2->Draw("colz"); c_sigmareweights->SaveAs("../plots/c_sigmareweights.root"); c_sigmareweights->SaveAs("../plots/c_sigmareweights.png"); TCanvas * c_etareweights=new TCanvas("c_etareweights","c_etareweights"); c_etareweights->Divide(3,2); c_etareweights->cd(1); w_etan->Draw("colz"); c_etareweights->cd(2); w_eta2o->Draw("colz"); c_etareweights->cd(3); w_etanr->Draw("colz"); c_etareweights->cd(4); w_eta2->Draw("colz"); c_etareweights->cd(5); w_eta->Draw();c_etareweights->cd(6); w_etao->Draw(); c_etareweights->SaveAs("../plots/c_etareweights.root"); c_etareweights->SaveAs("../plots/c_etareweights.png"); } if(check) { cout << "after reweighting" << endl; cout << "sig " << dset_rcone_axis1->sumEntries() << endl; cout << "bkg " << dset_sideb_axis1->sumEntries() << endl; cout << "data " << dset_data_axis1->sumEntries() << endl; cout << "signal+ fakes " << dset_rcone_axis1->sumEntries()+ dset_sideb_axis1->sumEntries()<< endl; cout << "one? " << (dset_rcone_axis1->sumEntries()+ dset_sideb_axis1->sumEntries())/dset_data_axis1->sumEntries()<< endl; cout << "ratio Entries truth/data weighted " << dset_rcone_axis1->sumEntries()/dset_data_axis1->sumEntries() << endl; } if(check){ //debugging reweighting RooDataHist *test_dpt = new RooDataHist("test_dpt","test_dpt",RooArgSet(*roodiphopt)); test_dpt->add(*dset_data_axis1); RooDataHist *test_spt = new RooDataHist("test_spt","test_spt",RooArgSet(*roodiphopt)); test_spt->add(*dset_sideb_axis1); RooHistPdf *test_datapt = new RooHistPdf("test_datapt","test_datapt",RooArgList(*roodiphopt),*test_dpt); RooHistPdf *test_sidept = new RooHistPdf("test_sidept","test_sidept",RooArgList(*roodiphopt),*test_spt); TCanvas *c3=new TCanvas("c3","diphopt after reweighting rho, eta , single pt"); c3->cd(); RooPlot *testpt = roodiphopt->frame(Title("diphopt after reweighting rho, eta , single pt")); test_datapt->plotOn(testpt,LineStyle(kDashed),LineColor(kRed),Name("data")); test_sidept->plotOn(testpt,LineStyle(kDashed),LineColor(kBlack),Name("sideband")); testpt->Draw(); } //fitting cout << "fitting starts" << endl; //first step determine single-photon purities on Iso1 and Iso2 axes //for integral 0-90 GeV, fit should not depend on initial values! //give initial values for purity fraction -j1 overall purity for leg 1 RooRealVar *j1=NULL;RooFormulaVar *fsig1=NULL; j1 = new RooRealVar("j1","j1",0.3,0,1); fsig1 = new RooFormulaVar("fsig1","fsig1","j1",RooArgList(*j1)); //produces binned RooDataHist also when RooRealVar input and weights are unbinned RooArgSet var; if(dohggv){var.add(*roovar1);} else if(dovzero) {var.add(*rooisopv1);} else if(dowv) {var.add(*rooisowv1);} RooDataHist *drconehist_axis1=NULL; RooDataHist *dsidebhist_axis1=NULL; RooHistPdf *drconepdf_axis1 =NULL; RooHistPdf *dsidebpdf_axis1 =NULL; drconehist_axis1 = new RooDataHist("drconehist_axis1","drconehist_axis1",var); drconehist_axis1->add(*dset_rcone_axis1); if(debug){ drconehist_axis1->Print("V"); } dsidebhist_axis1 = new RooDataHist("dsidebhist_axis1","dsidebhist_axis1",var); dsidebhist_axis1->add(*dset_sideb_axis1); if(debug){ dsidebhist_axis1->Print("V"); } drconepdf_axis1 = new RooHistPdf("drconepdf_axis1","drconepdf_axis1",var,*drconehist_axis1); dsidebpdf_axis1 = new RooHistPdf("dsidebpdf_axis1","dsidebpdf_axis1",var,*dsidebhist_axis1); //normalizes histograms over all observables // RooAddPdf is an efficient implementation of a sum of PDFs of the form c_1*PDF_1 + c_2*PDF_2 + ... (1-sum(c_1...c_n-1))*PDF_n //the sum of the coefficients is enforced to be one,and the coefficient of the last PDF is calculated from that condition. //ArgList of coefficients -1 of roohistpdf RooAddPdf *model_axis1=NULL; model_axis1 = new RooAddPdf("model_axis1","model_axis1",RooArgList(*drconepdf_axis1,*dsidebpdf_axis1),RooArgList(*fsig1),kFALSE); //if does not converge take NumCPU strategy 2 RooFitResult *firstpass1; //hesse run by default //SumW2Error takes statistics of MC (weights) into account //firstpass1 = model_axis1->fitTo(*dset_data_axis1, NumCPU(8), Extended(false),SumW2Error(kTRUE),Save(kTRUE)); firstpass1 = model_axis1->fitTo(*dset_data_axis1, NumCPU(8), Extended(false),SumW2Error(kFALSE),Save(kTRUE)); TFile resFile(Form("../plots/fitresult_%s_%s_%u_range_%u_%u.root",(truthfit)? "truth": "rcone_sideb",(EBEB) ? "EBEB": "notEBEB",im,startbin_q,endbin_q),"RECREATE"); firstpass1->Write(); if(massbinned) { pu[im]=fsig1->getVal(); puerr[im]=fsig1->getPropagatedError(*firstpass1); // masserror[im]=0.; } resFile.Write(); resFile.Close(); firstpass1->Print(); TLatex b;b.SetNDC();b.SetTextSize(0.06);b.SetTextColor(kRed); TCanvas *c1 = new TCanvas("c1","c1",1200,800); TLegend *leg = new TLegend(0.15,0.8,0.35,0.9); c1->cd(1); TString title; if(dohggv){ title= Form("1d fit for hgg vertex no SumW2Error, %s, reweighted,%u rangebins: %u - %u",(EBEB)? "EBEB": "notEBEB" ,im, startbin_q, endbin_q); } else if(dovzero){ title= Form("1d fit for vertex[0], %s, reweighted,%u",(EBEB)? "EBEB": "notEBEB" ,im); } else if(dowv){ title= Form("1d fit for worst isolation, %s, reweighted,%u",(EBEB)? "EBEB": "notEBEB" ,im); } //lin plot RooPlot *frame1bla; frame1bla = roovar1->frame(Title(title.Data())); dset_data_axis1->plotOn(frame1bla,Binning(tbins),Name("data")); model_axis1->plotOn(frame1bla,Name("fit")); model_axis1->plotOn(frame1bla,Components("drconepdf_axis1"),LineStyle(kDashed),LineColor(kRed),Name("signal")); model_axis1->plotOn(frame1bla,Components("dsidebpdf_axis1"),LineStyle(kDashed),LineColor(kBlack),Name("background")); frame1bla->Draw(); leg->AddEntry("fit","fit","l"); if(!truthfit){ leg->AddEntry("signal","rcone MC","l"); leg->AddEntry("background","sideband MC","l"); } else if(truthfit){ leg->AddEntry("signal","signal MC","l"); leg->AddEntry("background","background MC","l"); } leg->SetFillColor(kWhite); leg->Draw(); b.DrawLatex(0.55,0.7,"PRELIMINARY"); //log plot TCanvas *c2 = new TCanvas("c2","c2",1200,800); c2->cd(1); gPad->SetLogy(); RooPlot *frame1logbla; frame1logbla = roovar1->frame(Title(title.Data())); dset_data_axis1->plotOn(frame1logbla,Binning(tbins),Name("data")); model_axis1->plotOn(frame1logbla,Name("fit")); model_axis1->plotOn(frame1logbla,Components("drconepdf_axis1"),LineStyle(kDashed),LineColor(kRed),Name("signal")); model_axis1->plotOn(frame1logbla,Components("dsidebpdf_axis1"),LineStyle(kDashed),LineColor(kBlack),Name("background")); frame1logbla->Draw(); leg->Draw(); b.DrawLatex(0.55,0.7,"PRELIMINARY"); model_axis1->Print(); dset_data_axis1->Print(); //save fit plots TString titleout; // if(dohggv) titleout= Form("%s_reweight_%s_hggvtx_noSUMW2_varbinning%u_range%u_%u",(EBEB)? "EBEB": "notEBEB",(truthfit)? "truth": "rcone_sideb",im,startbin_q, endbin_q); if(dohggv) titleout= Form("%s_reweight_%s_hggvtx_noSUMW2_varbinning%u_sigcomp",(EBEB)? "EBEB": "notEBEB",(truthfit)? "truth": "rcone_sideb",im); else if(dovzero) titleout= "nooverflow_reweight_fulletarange_rcone_sideband_vzero"; else if(dowv) titleout= "nooverflow_reweight_fulletarange_rcone_sideband_wv"; const char* outfile=Form("../plots/%s_%s", (isdata)? "data": "mc",titleout.Data()); c1->SaveAs(Form("%s_lin.png",outfile));c1->SaveAs(Form("%s_lin.root",outfile));c1->SaveAs(Form("%s_lin.pdf",outfile)); c2->SaveAs(Form("%s_log.png",outfile));c2->SaveAs(Form("%s_log.root",outfile));c2->SaveAs(Form("%s_log.pdf",outfile)); delete dset_data_axis1; delete dset_rcone_axis1; delete dset_sideb_axis1; delete dset_testbkg; delete drconehist_axis1; delete dsidebhist_axis1; delete drconepdf_axis1; delete dsidebpdf_axis1; /* if(!debug){ delete w_rhornr; delete w_rhor2o; delete w_rhorn; delete w_rhor2; delete w_rhor; delete w_rhoro; delete w_rhonr; delete w_rho2o; delete w_rhon; delete w_rho2; delete w_rho; delete w_rhoo; delete w_sigmarnr; delete w_sigmar2o; delete w_sigmarn; delete w_sigmar2; delete w_sigmanr; delete w_sigma2o; delete w_sigman; delete w_sigma2; delete w_ptrnr; delete w_ptr2o; delete w_ptrn; delete w_ptr2; delete w_ptr; delete w_ptro; delete w_ptnr; delete w_pt2o; delete w_ptn; delete w_pt2; delete w_pt; delete w_pto; delete w_etarnr; delete w_etar2o; delete w_etarn; delete w_etar2; delete w_etar; delete w_etaro; delete w_etanr; delete w_eta2o; delete w_etan; delete w_eta2; delete w_eta; delete w_etao; delete w_diphoptrnr; delete w_diphoptr2o; delete w_diphoptrn; delete w_diphoptr2; delete w_diphoptr; delete w_diphoptro; delete w_diphoptnr; delete w_diphopt2o; delete w_diphoptn; delete w_diphopt2; delete w_diphopt; delete w_diphopto; }*/ print_mem(); return 0; }
//plot to compare two distributions and plot ther ratio void ratioplot(RooDataSet *data_axis1, RooDataSet* truth_axis1,Bool_t logplot){ assert(data_axis1); assert(truth_axis1); TH1F::SetDefaultSumw2(kTRUE); TH1F* EB_data= new TH1F("EB_data","EB_data",100, 0.,9.); for(int i=0;i<(*data_axis1).numEntries();i++) { EB_data->Fill(fabs((*data_axis1).get(i)->getRealValue("roovar1")),(*data_axis1).store()->weight(i)); } TH1F* EB_truth= new TH1F("EB_truth","EB_truth",100, 0.,9.); for(int i=0;i<(*truth_axis1).numEntries();i++) { EB_truth->Fill(fabs((*truth_axis1).get(i)->getRealValue("roovar1")),(*truth_axis1).store()->weight(i)); } TCanvas* c5= new TCanvas("c5","c5"); c5->cd(); EB_data->SetLineColor(kRed);EB_data->SetMarkerSize(20); EB_truth->SetLineColor(kBlue);EB_truth->SetMarkerSize(20); EB_data->Draw(); // ratio plots TH1F *r1 = (TH1F*)EB_truth->Clone("r1"); r1->Divide(EB_data); // r1->SetMarkerStyle(20); r1->SetTitle(""); TCanvas* c6= new TCanvas("c6","c6"); if(logplot){ c6->SetLogy(); } TPad *pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0); pad1->SetBottomMargin(0); // Upper and lower plot are joined pad1->SetGridx(); // Vertical grid pad1->Draw(); // Draw the upper pad: pad1 pad1->cd(); if(logplot){pad1->SetLogy();} // pad1 becomes the current pad r1->GetXaxis()->SetTitle("Charged Iso (GeV)"); EB_data->SetTitle("MC prompt photon comparison reweighted"); // h1->GetXaxis()->SetRangeUser(-100.,1000.); // EB_data->GetYaxis()->SetRangeUser(10,100000); // h1->SetMarkerColor(kBlack); h1->SetMarkerStyle(20);h1->SetLineColor(kBlack); // h2->SetMarkerColor(kRed+1); h2->SetMarkerStyle(20);h2->SetLineColor(kRed+1); // get mean //Double_t err1; //Double_t err2; // Double_t meanh1=EB_data->IntegralAndError(0,EB_data->GetNbinsX(),err1); // Double_t meanh2=EB_truth->IntegralAndError(0,EB_truth->GetNbinsX(),err2); Double_t meanh1=EB_data->Integral(0,EB_data->GetNbinsX()); Double_t meanh2=EB_truth->Integral(0,EB_truth->GetNbinsX()); Double_t ratio=meanh2/meanh1; // Double_t err_ratio= ratio*ratio*pow(((err1/meanh1)*(err1/meanh1)+(err2/meanh2)*(err2/meanh2)),0.5); // Double_t ratio_error= cout << "data " << EB_data->GetNbinsX() <<" truth " << EB_truth->GetNbinsX() << endl; // cout << "meanh1 " << meanh1 << " +/- " << err1 << "meanh2 " << meanh2 << " +/- " <<err2<<"ratio " << ratio << "+/-"<< err_ratio << endl; cout << " meanh1 " << meanh1 << " meanh2 " << meanh2<<" ratio " << ratio << endl; EB_data->Draw(); EB_truth->Draw("SAME"); TLegend* leg = new TLegend(0.55, 0.65, .9, .9); leg->SetFillColor(0); leg->AddEntry(EB_data," data " ,"pl"); leg->AddEntry(EB_truth,"p photon", "pl"); leg->Draw(); TLatex a; a.SetNDC(); //const char * ratio_out= Form("ratio of truth MC to data MC: %f +/-%f",ratio,err_ratio); const char * ratio_out= Form("ratio of truth MC to data MC: %f",ratio); a.DrawLatex(0.55,0.6,ratio_out); c6->cd(); // Go back to the main canvas before defining pad2 TPad *pad2 = new TPad("pad2", "pad2", 0, 0.05, 1, 0.3); // pad2->SetLogy(); gStyle->SetOptStat(0); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.4); pad2->SetTicky(); pad2->SetGridx(); // vertical grid pad2->Draw(); pad2->cd(); TLine *r = new TLine(0.,ratio,9.,ratio); r->SetLineColor(kRed); r1->Draw("ep"); r->Draw("SAME"); // r1->SetMinimum(0.0); // Define Y .. // r1->SetMaximum(10.); // .. range r1->GetYaxis()->SetTitle("MCrew/MC"); r1->GetYaxis()->SetNdivisions(505); r1->GetYaxis()->SetTitleSize(18); r1->GetYaxis()->SetTitleFont(43); r1->GetYaxis()->SetTitleOffset(1.05); r1->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3) r1->GetYaxis()->SetLabelSize(15); // X axis ratio plot settings r1->GetXaxis()->SetTitleSize(20); r1->GetXaxis()->SetTitleFont(43); r1->GetXaxis()->SetTitleOffset(4.); r1->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3) r1->GetXaxis()->SetLabelSize(15); // c2->SaveAs("../plots/d1fit/mc_truth_EBEB.png"); // c2->SaveAs("../plots/d1fit/mc_truth_EBEB.root"); // c2->SaveAs("../plots/d1fit/mc_truth_EBEB.pdf"); }
int multiple_detector_fit() { std::cout << "Beginning : ... " << std::endl; Int_t npoints = 1000; Double_t emin = 0.2; Double_t emax = 3.0; bool use100m = false; bool use470m = true; bool use600m = false; std::vector<int> baselines; std::vector<double> scales; std::vector<std::string> names; std::vector<double> volume; if (use100m) baselines.push_back(100); if (use470m) baselines.push_back(470); if (use600m) baselines.push_back(600); int nL = baselines.size(); double NULLVec[3][20]; double OscVec[3][1001][7][20]; for(int i = 0; i < 20; i++){ NULLVec[0][i] = 0; NULLVec[1][i] = 0; NULLVec[2][i] = 0; } for(int u = 0; u < 1000; u++){ for(int s = 0; s < 7; s++){ for(int i = 0; i < 20; i++){ OscVec[0][u][s][i] = 0; OscVec[1][u][s][i] = 0; OscVec[2][u][s][i] = 0; } } } int nbinsE = 0; int counter = 0; if (use100m){ std::string temp_name = "../MatrixFiles/combined_ntuple_100m_nu_processed_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_100; NULL_100 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_100->GetNbinsX(); std::cout << nbinsE << std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[counter][i-1] = (NULL_100->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_100; TString upoint = Form("%d",u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s); name += upoint; name += name2; name += mul; OSC_100 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[counter][u][s][i-1] = (OSC_100->GetBinContent(i)); // if(OscVec[0][u][s][i-1] != OscVec[0][u][s][i-1]) std::cout << "erm" <<std::endl; } delete OSC_100; } } counter++; delete NULL_100; temp_file.Close(); } if (use470m){ std::string temp_name = "../MatrixFiles/combined_ntuple_470m_nu_processed_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_470; NULL_470 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_470->GetNbinsX(); std::cout << nbinsE<< std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[counter][i-1] = (NULL_470->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_470; TString upoint = Form("%d",u);//std::to_string(u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s);// = std::to_string(s); name += upoint; name += name2; name += mul; OSC_470 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[counter][u][s][i-1] = (OSC_470->GetBinContent(i)); } delete OSC_470; } } counter++; delete NULL_470; temp_file.Close(); } if (use600m){ std::string temp_name = "../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_600; NULL_600 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_600->GetNbinsX(); std::cout << nbinsE<< std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[counter][i-1] = (NULL_600->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_600; TString upoint = Form("%d",u);//std::to_string(u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s);// = std::to_string(s); name += upoint; name += name2; name += mul; OSC_600 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[counter][u][s][i-1] = (OSC_600->GetBinContent(i)); } delete OSC_600; } } counter++; delete NULL_600; temp_file.Close(); } // int nL = 3; int mbins = (nbinsE*nL); TMatrix M6 (mbins,mbins); TMatrix M5 (mbins,mbins); TMatrix M4 (mbins,mbins); TMatrix M3 (mbins,mbins); TMatrix M2 (mbins,mbins); TMatrix M1 (mbins,mbins); TMatrix M0 (mbins,mbins); TMatrix C6 (mbins,mbins); TMatrix C5 (mbins,mbins); TMatrix C4 (mbins,mbins); TMatrix C3 (mbins,mbins); TMatrix C2 (mbins,mbins); TMatrix C1 (mbins,mbins); TMatrix C0 (mbins,mbins); int N = 0; TH1D *Fig6 = new TH1D("Fig6",";;",mbins,0,mbins); TH1D *Fig5 = new TH1D("Fig5",";;",mbins,0,mbins); TH1D *Fig4 = new TH1D("Fig4",";;",mbins,0,mbins); TH1D *Fig3 = new TH1D("Fig3",";;",mbins,0,mbins); TH1D *Fig2 = new TH1D("Fig2",";;",mbins,0,mbins); TH1D *Fig1 = new TH1D("Fig1",";;",mbins,0,mbins); TH1D *Fig0 = new TH1D("Fig0",";;",mbins,0,mbins); int Erri = 0, Errj = 0; std::cout << "Filling Error Matrix..." << std::endl; for(int Lrow = 0; Lrow < nL; Lrow++){ for(int Erow = 0; Erow < nbinsE; Erow++){ Errj = 0; for(int Lcol = 0; Lcol < nL; Lcol++){ for(int Ecol = 0; Ecol < nbinsE; Ecol++){ M6 (Erri,Errj) = 0; M5 (Erri,Errj) = 0; M4 (Erri,Errj) = 0; M3 (Erri,Errj) = 0; M2 (Erri,Errj) = 0; M1 (Erri,Errj) = 0; M0 (Erri,Errj) = 0; N = 0; for(int u = 0; u < npoints; u++){ M6 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][6][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][6][Ecol]); M5 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][5][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][5][Ecol]); M4 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][4][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][4][Ecol]); M3 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][3][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][3][Ecol]); M2 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][2][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][2][Ecol]); M1 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][1][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][1][Ecol]); M0 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][0][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][0][Ecol]); N++; } M6 (Erri,Errj) /= N; M5 (Erri,Errj) /= N; M4 (Erri,Errj) /= N; M3 (Erri,Errj) /= N; M2 (Erri,Errj) /= N; M1 (Erri,Errj) /= N; M0 (Erri,Errj) /= N; M6 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M5 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M4 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M3 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M2 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M1 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M0 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; if(Erri == Errj) Fig6->SetBinContent(Erri+1, sqrt(M6 (Erri,Errj))); if(Erri == Errj) Fig5->SetBinContent(Erri+1, sqrt(M5 (Erri,Errj))); if(Erri == Errj) Fig4->SetBinContent(Erri+1, sqrt(M4 (Erri,Errj))); if(Erri == Errj) Fig3->SetBinContent(Erri+1, sqrt(M3 (Erri,Errj))); if(Erri == Errj) Fig2->SetBinContent(Erri+1, sqrt(M2 (Erri,Errj))); if(Erri == Errj) Fig1->SetBinContent(Erri+1, sqrt(M1 (Erri,Errj))); if(Erri == Errj) Fig0->SetBinContent(Erri+1, sqrt(M0 (Erri,Errj))); Errj++; }} Erri++; }} for(int i = 0; i < Erri; i++){ for(int j = 0; j < Errj; j++){ C6 (i,j) = M6(i,j) / sqrt(M6 (i,i) * M6 (j,j)); C5 (i,j) = M5(i,j) / sqrt(M5 (i,i) * M5 (j,j)); C4 (i,j) = M4(i,j) / sqrt(M4 (i,i) * M4 (j,j)); C3 (i,j) = M3(i,j) / sqrt(M3 (i,i) * M3 (j,j)); C2 (i,j) = M2(i,j) / sqrt(M2 (i,i) * M2 (j,j)); C1 (i,j) = M1(i,j) / sqrt(M1 (i,i) * M1 (j,j)); C0 (i,j) = M0(i,j) / sqrt(M0 (i,i) * M0 (j,j)); } } std::cout << "...Error Matrix Filled" << std::endl; TCanvas* c6 = new TCanvas("c6","",700,700); c6->SetLeftMargin(.1); c6->SetBottomMargin(.1); c6->SetTopMargin(.075); c6->SetRightMargin(.15); c6->cd(); M6.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); // TMatrixFBase->GetZaxis()->SetRangeUser(-0.05,0.4); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Fractional Error Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); add_plot_label(" 0.2 GeV #minus 3.0 GeV ", 0.48,0.07,0.04); TLatex *MD = new TLatex(.3,.01,"MicroBooNE (470m)"); MD->SetNDC(); MD->SetTextFont(62); MD->SetTextSize(0.04); MD->Draw(); TLatex *MD45 = new TLatex(.05,.3,"MicroBooNE (470m)"); MD45->SetNDC(); MD45->SetTextAngle(90); MD45->SetTextFont(62); MD45->SetTextSize(0.04); MD45->Draw(); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); c6->Print("total_1Det_matrix.pdf"); TCanvas* c61 = new TCanvas("c61","",700,700); c61->SetLeftMargin(.1); c61->SetBottomMargin(.1); c61->SetTopMargin(.075); c61->SetRightMargin(.15); c61->cd(); C6.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); add_plot_label(" 0.2 GeV #minus 3.0 GeV ", 0.48,0.07,0.04); MD->Draw(); MD45->Draw(); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); c61->Print("total_1Det_correlation_matrix.pdf"); cout<<"\nEnd of routine.\n"; return 0; }
void Draw_vn(TH1D * vn_cent0to10, TH1D * vn_cent10to30, TH1D * vn_cent30to50, TH1D * vn_cent50to70, TString vnname = "v2_SP", TString Ytitle = "v_{2}{SP}") { TCanvas * cfg_vn_centrality = new TCanvas(Form("cfg_%s_centrality", vnname.Data()), Form("cfg_%s_centrality", vnname.Data())); vn_cent10to30->SetLineColor(4.0); vn_cent10to30->SetMarkerColor(4.0); vn_cent30to50->SetLineColor(2.0); vn_cent30to50->SetMarkerColor(2.0); vn_cent50to70->SetLineColor(8.0); vn_cent50to70->SetMarkerColor(8.0); vn_cent0to10->GetYaxis()->SetTitle(Ytitle); vn_cent0to10->Draw(); vn_cent10to30->Draw("same"); vn_cent30to50->Draw("same"); vn_cent50to70->Draw("same"); TF1 * fun = new TF1("fun", "0.0", 0, 100); fun->SetLineColor(1.0); fun->SetLineStyle(3); fun->SetLineWidth(1); fun->Draw("same"); TLegend * leg = new TLegend(0.45, 0.67, 0.65, 0.90); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->AddEntry( vn_cent0to10, "Cent. 0-10%"); leg->AddEntry( vn_cent10to30, "Cent. 10-30%"); leg->AddEntry( vn_cent30to50, "Cent. 30-50%"); leg->AddEntry( vn_cent50to70, "Cent. 50-70%"); leg->Draw(); TLatex Tl; Tl.SetNDC(); Tl.SetTextAlign(12); Tl.SetTextSize(0.05); Tl.SetTextFont(42); Tl.DrawLatex(0.125,0.965, "#font[61]{CMS} #scale[0.8]{Preliminary}"); Tl.DrawLatex(0.57,0.965, "#scale[0.8]{PbPb #sqrt{s_{NN}} = 5.02 TeV}"); TLatex* tex; tex = new TLatex(0.20,0.83,"|y| < 1.0"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); cfg_vn_centrality->SaveAs(Form("Plots_vn/cfg_%s_centrality.pdf", vnname.Data())); }
void draw_comp_cent(bool isPrompt=true, bool isPair=true, bool isEmbedded=true, bool isBinomial=true, char *dirName = "drawComprm3step") { gROOT->Macro("./JpsiStyle.C"); gStyle->SetPaintTextFormat(".3f"); // for text colz char* ntuple01 = "default 7_4_0"; char* ntuple02 = "3 steps removed"; //char* ntuple02 = "muonSeeded"; double ymin = 0.85; double ymax = 1.15; string strPrompt; string strEmbd; string strPair; if(isPrompt){ strPrompt = "prompt"; } else { strPrompt = "nonprompt"; } if(isEmbedded){ strEmbd = "embd"; } else { strEmbd = "nonembd"; } if(isPair){ strPair = "Pair"; } else { strPair = "Trk"; } cout << "strPrompt = " << strPrompt.c_str() << endl; cout << "strEmbd = " << strEmbd.c_str() << endl; cout << "strPair = " << strPair.c_str() << endl; TFile * refFile01; TFile * refFile02; //refFile01 = new TFile(Form("./eff_74X_setBr_wDetached/Eff_isPtCut0_doWeight0_isEmbedded1_%s_embd_%s.root",strPrompt.c_str(),strPair.c_str())); refFile01 = new TFile(Form("./eff_cent_setBr_goni/Eff_%s_embd_%s.root",strPrompt.c_str(),strPair.c_str())); refFile02 = new TFile(Form("./eff_cent_setBr_rm3step/Eff_%s_embd_%s.root",strPrompt.c_str(),strPair.c_str())); //refFile02 = new TFile(Form("./eff_cent_setBr_muonSeeded/Eff_%s_embd_%s.root",strPrompt.c_str(),strPair.c_str())); TH1D * h1D_EffPt_01 = (TH1D*)refFile01->Get("hEffPt"); TH1D * h1D_EffPt_02 = (TH1D*)refFile02->Get("hEffPt"); TH1D * h1D_EffRap_01 = (TH1D*)refFile01->Get("hEffRap"); TH1D * h1D_EffRap_02 = (TH1D*)refFile02->Get("hEffRap"); TH1D * h1D_EffLxy_01 = (TH1D*)refFile01->Get("hEffLxy"); TH1D * h1D_EffLxy_02 = (TH1D*)refFile02->Get("hEffLxy"); TH1D * h1D_EffCent_01 = (TH1D*)refFile01->Get("hEffCent"); TH1D * h1D_EffCent_02 = (TH1D*)refFile02->Get("hEffCent"); h1D_EffPt_01->SetName("h1D_EffPt_01"); h1D_EffPt_02->SetName("h1D_EffPt_02"); h1D_EffRap_01->SetName("h1D_EffRap_01"); h1D_EffRap_02->SetName("h1D_EffRap_02"); h1D_EffLxy_01->SetName("h1D_EffLxy_01"); h1D_EffLxy_02->SetName("h1D_EffLxy_02"); h1D_EffCent_01->SetName("h1D_EffCent_01"); h1D_EffCent_02->SetName("h1D_EffCent_02"); TH1D* hRatio_EffPt = (TH1D*)h1D_EffPt_02->Clone("hRatio_EffPt"); if (isBinomial) hRatio_EffPt->Divide(h1D_EffPt_02,h1D_EffPt_01,1,1,"B"); else hRatio_EffPt->Divide(h1D_EffPt_01); TH1D* hRatio_EffRap = (TH1D*)h1D_EffRap_02->Clone("hRatio_EffRap"); if (isBinomial) hRatio_EffRap->Divide(h1D_EffRap_02,h1D_EffRap_01,1,1,"B"); else hRatio_EffRap->Divide(h1D_EffRap_01); TH1D* hRatio_EffLxy = (TH1D*)h1D_EffLxy_02->Clone("hRatio_EffLxy"); if (isBinomial) hRatio_EffLxy->Divide(h1D_EffLxy_02,h1D_EffLxy_01,1,1,"B"); else hRatio_EffLxy->Divide(h1D_EffLxy_01); TH1D* hRatio_EffCent = (TH1D*)h1D_EffCent_02->Clone("hRatio_EffCent"); if (isBinomial) hRatio_EffCent->Divide(h1D_EffCent_02,h1D_EffCent_01,1,1,"B"); else hRatio_EffCent->Divide(h1D_EffCent_01); //latex box for beam, rapidity, pT info TLatex* tex = new TLatex(); tex->SetNDC(); tex->SetTextAlign(12); tex->SetTextSize(0.04); //Legend TLegend *legUR = new TLegend(0.56,0.68,0.90,0.90,NULL,"brNDC"); //TLegend *legUL = new TLegend(0.17,0.68,0.51,0.90,NULL,"brNDC"); TLegend *legUL = new TLegend(0.20,0.71,0.51,0.90,NULL,"brNDC"); TLegend *legBM = new TLegend(0.40,0.20,0.75,0.35,NULL,"brNDC"); TLegend *legBR = new TLegend(0.56,0.20,0.90,0.42,NULL,"brNDC"); SetLegendStyle(legUR); SetLegendStyle(legUL); SetLegendStyle(legBM); SetLegendStyle(legBR); ////////////////////////////////////////////////////////////////// // --- Draw histograms TCanvas* c1 = new TCanvas("c1","c1",600,600); ////// 01 Pt c1->cd(); h1D_EffPt_01->GetXaxis()->SetTitle("p_{T} (GeV/c)"); h1D_EffPt_01->GetXaxis()->CenterTitle(); h1D_EffPt_01->GetYaxis()->SetTitle("Efficiency"); //h1D_EffPt_01->GetXaxis()->SetRangeUser(0,16); if (isPrompt) h1D_EffPt_01->GetXaxis()->SetRangeUser(0,12); else h1D_EffPt_01->GetXaxis()->SetRangeUser(0,22); h1D_EffPt_01->SetMinimum(0); h1D_EffPt_01->SetMaximum(1); SetHistStyle(h1D_EffPt_01,3,0); SetHistStyle(h1D_EffPt_02,4,10); h1D_EffPt_01->Draw(""); h1D_EffPt_02->Draw("same"); if (isPair){ legUL->SetHeader(strPrompt.c_str()); legUL->AddEntry(h1D_EffPt_01,ntuple01,"lp"); legUL->AddEntry(h1D_EffPt_02,ntuple02,"lp"); legUL->Draw(); }else{ legBR->SetHeader(strPrompt.c_str()); legBR->AddEntry(h1D_EffPt_01,ntuple01,"lp"); legBR->AddEntry(h1D_EffPt_02,ntuple02,"lp"); legBR->Draw(); } c1->SaveAs(Form("%s/comp_EffPt_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str())); // c1->SaveAs(Form("%s/comp_EffPt_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str())); legUL->Clear(); legBR->Clear(); c1->Clear(); if (isPair) hRatio_EffPt->GetXaxis()->SetTitle("p_{T}^{#mu#mu} (GeV/c)"); else hRatio_EffPt->GetXaxis()->SetTitle("p_{T}^{#mu} (GeV/c)"); hRatio_EffPt->GetXaxis()->CenterTitle(); if (isPrompt) hRatio_EffPt->GetXaxis()->SetRangeUser(0,12); else hRatio_EffPt->GetXaxis()->SetRangeUser(0,22); hRatio_EffPt->GetYaxis()->SetTitle(Form("Ratio = [ %s ]/[ %s ]",ntuple02,ntuple01)); hRatio_EffPt->SetMinimum(ymin); hRatio_EffPt->SetMaximum(ymax); hRatio_EffPt->Draw(); SetHistStyle(hRatio_EffPt,2,0); //dashedLine(0.,1.,16.,1.,1,1); if (isPrompt) dashedLine(0.,1.,12.,1.,1,1); else dashedLine(0.,1.,22.,1.,1,1); c1->SaveAs(Form("%s/compRatio_EffPt_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str())); // c1->SaveAs(Form("%s/compRatio_EffPt_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str())); c1->Clear(); ////// 02 Y c1->cd(); if (isPair) h1D_EffRap_01->GetXaxis()->SetTitle("y"); else h1D_EffRap_01->GetXaxis()->SetTitle("#eta"); h1D_EffRap_01->GetXaxis()->CenterTitle(); h1D_EffRap_01->GetYaxis()->SetTitle("Efficiency"); h1D_EffRap_01->GetXaxis()->SetRangeUser(-2.5,2.5); h1D_EffRap_01->SetMinimum(0); h1D_EffRap_01->SetMaximum(1); SetHistStyle(h1D_EffRap_01,3,0); SetHistStyle(h1D_EffRap_02,4,10); h1D_EffRap_01->Draw(""); h1D_EffRap_02->Draw("same"); if (isPair){ legUL->SetHeader(strPrompt.c_str()); legUL->AddEntry(h1D_EffPt_01,ntuple01,"lp"); legUL->AddEntry(h1D_EffPt_02,ntuple02,"lp"); legUL->Draw(); }else{ legBM->SetHeader(strPrompt.c_str()); legBM->AddEntry(h1D_EffPt_01,ntuple01,"lp"); legBM->AddEntry(h1D_EffPt_02,ntuple02,"lp"); legBM->Draw(); } c1->SaveAs(Form("%s/comp_EffRap_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str())); // c1->SaveAs(Form("%s/comp_EffRap_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str())); legUL->Clear(); legBM->Clear(); c1->Clear(); if (isPair) hRatio_EffRap->GetXaxis()->SetTitle("y"); else hRatio_EffRap->GetXaxis()->SetTitle("#eta"); hRatio_EffRap->GetXaxis()->CenterTitle(); hRatio_EffRap->GetXaxis()->SetRangeUser(-2.5,2.5); hRatio_EffRap->GetYaxis()->SetTitle(Form("Ratio = [ %s ]/[ %s ]",ntuple02,ntuple01)); hRatio_EffRap->SetMinimum(ymin); hRatio_EffRap->SetMaximum(ymax); hRatio_EffRap->Draw(); SetHistStyle(hRatio_EffRap,2,0); dashedLine(-2.5,1.,2.5,1.,1,1); c1->SaveAs(Form("%s/compRatio_EffRap_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str())); // c1->SaveAs(Form("%s/compRatio_EffRap_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str())); c1->Clear(); ////// 03 Lxy c1->cd(); h1D_EffLxy_01->GetXaxis()->SetTitle("L_{xy}"); h1D_EffLxy_01->GetXaxis()->CenterTitle(); h1D_EffLxy_01->GetYaxis()->SetTitle("Efficiency"); h1D_EffLxy_01->GetXaxis()->SetRangeUser(0,1); h1D_EffLxy_01->SetMinimum(0); h1D_EffLxy_01->SetMaximum(1); SetHistStyle(h1D_EffLxy_01,3,0); SetHistStyle(h1D_EffLxy_02,4,10); h1D_EffLxy_01->Draw(""); h1D_EffLxy_02->Draw("same"); if (isPair){ legUL->SetHeader(strPrompt.c_str()); legUL->AddEntry(h1D_EffPt_01,ntuple01,"lp"); legUL->AddEntry(h1D_EffPt_02,ntuple02,"lp"); legUL->Draw(); }else{ legBM->SetHeader(strPrompt.c_str()); legBM->AddEntry(h1D_EffPt_01,ntuple01,"lp"); legBM->AddEntry(h1D_EffPt_02,ntuple02,"lp"); legBM->Draw(); } c1->SaveAs(Form("%s/comp_EffLxy_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str())); // c1->SaveAs(Form("%s/comp_EffLxy_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str())); legUL->Clear(); legBM->Clear(); c1->Clear(); hRatio_EffLxy->GetXaxis()->SetTitle("L_{xy}"); hRatio_EffLxy->GetXaxis()->CenterTitle(); hRatio_EffLxy->GetXaxis()->SetRangeUser(0,1); hRatio_EffLxy->GetYaxis()->SetTitle(Form("Ratio = [ %s ]/[ %s ]",ntuple02,ntuple01)); hRatio_EffLxy->SetMinimum(ymin); hRatio_EffLxy->SetMaximum(ymax); hRatio_EffLxy->Draw(); SetHistStyle(hRatio_EffLxy,2,0); dashedLine(0.,1.,1.,1.,1,1); c1->SaveAs(Form("%s/compRatio_EffLxy_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str())); // c1->SaveAs(Form("%s/compRatio_EffLxy_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str())); c1->Clear(); ////// 04 Cent c1->cd(); h1D_EffCent_01->GetXaxis()->SetTitle("Centrality"); h1D_EffCent_01->GetXaxis()->CenterTitle(); h1D_EffCent_01->GetYaxis()->SetTitle("Efficiency"); h1D_EffCent_01->GetXaxis()->SetRangeUser(0,200); h1D_EffCent_01->SetMinimum(0); h1D_EffCent_01->SetMaximum(1); SetHistStyle(h1D_EffCent_01,3,0); SetHistStyle(h1D_EffCent_02,4,10); h1D_EffCent_01->Draw(""); h1D_EffCent_02->Draw("same"); if (isPair){ legUL->SetHeader(strPrompt.c_str()); legUL->AddEntry(h1D_EffPt_01,ntuple01,"lp"); legUL->AddEntry(h1D_EffPt_02,ntuple02,"lp"); legUL->Draw(); }else{ legBM->SetHeader(strPrompt.c_str()); legBM->AddEntry(h1D_EffPt_01,ntuple01,"lp"); legBM->AddEntry(h1D_EffPt_02,ntuple02,"lp"); legBM->Draw(); } c1->SaveAs(Form("%s/comp_EffCent_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str())); // c1->SaveAs(Form("%s/comp_EffCent_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str())); legUL->Clear(); legBM->Clear(); c1->Clear(); hRatio_EffCent->GetXaxis()->SetTitle("Centrality"); hRatio_EffCent->GetXaxis()->CenterTitle(); hRatio_EffCent->GetXaxis()->SetRangeUser(0,200); hRatio_EffCent->GetYaxis()->SetTitle(Form("Ratio = [ %s ]/[ %s ]",ntuple02,ntuple01)); hRatio_EffCent->SetMinimum(ymin); hRatio_EffCent->SetMaximum(ymax); hRatio_EffCent->Draw(); SetHistStyle(hRatio_EffCent,2,0); dashedLine(0.,1.,200.,1.,1,1); c1->SaveAs(Form("%s/compRatio_EffCent_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str())); // c1->SaveAs(Form("%s/compRatio_EffCent_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str())); c1->Clear(); TFile* outFile = new TFile(Form("%s/compRatio_%s_%s.root",dirName,strPrompt.c_str(),strPair.c_str()), "RECREATE"); outFile->cd(); hRatio_EffPt->Write(); hRatio_EffRap->Write(); hRatio_EffLxy->Write(); hRatio_EffCent->Write(); outFile->Close(); return; }
void plotComparison( TH1F* h_dt , TH1F* h_mc , TH1F *h_extra, char* label, bool dolog, bool drawbkg) { TPad* fullpad = new TPad(); TPad* plotpad = new TPad(); TPad* respad = new TPad(); fullpad = new TPad("fullpad","fullpad",0,0,1,1); fullpad->Draw(); fullpad->cd(); plotpad = new TPad("plotpad","plotpad",0,0,1,0.8); plotpad->Draw(); plotpad->cd(); if (dolog) plotpad->SetLogy(); h_dt->GetYaxis()->SetTitle("Entries"); h_dt->GetXaxis()->SetTitle(Form("%s", label)); h_dt->GetYaxis()->SetTitleSize(0.05); h_dt->GetXaxis()->SetTitleSize(0.05); h_dt->GetYaxis()->SetTitleOffset(1.5); h_dt->GetXaxis()->SetTitleOffset(1.3); if (!dolog) h_dt->GetYaxis()->SetRangeUser(0., 1.4*h_dt->GetMaximum()); h_dt->SetLineColor(kBlack); h_dt->SetMarkerColor(kBlack); h_mc->SetLineColor(kBlue); h_mc->SetMarkerColor(kBlue); h_extra->SetLineColor(kRed); h_extra->SetLineWidth(2); h_mc->SetLineWidth(2); h_dt->Draw(); h_mc->Draw("HISTSAME"); if (drawbkg) h_extra->Draw("HISTSAME"); h_dt->Draw("ESAME"); TLegend *legComp = new TLegend( 0.653, 0.663, 0.944, 0.870); legComp->AddEntry(h_dt, "Data", "lp"); legComp->AddEntry(h_mc, "MC", "l"); if (drawbkg) legComp->AddEntry(h_extra, "MC Bkg", "l"); legComp->SetFillColor(0); legComp->SetBorderSize(0); legComp->Draw(); TLatex *text = new TLatex(); text->SetNDC(); text->SetTextSize(0.04); // float xtex = 0.65; // text->DrawLatex(xtex,0.88,"1 lepton + jets Sample"); fullpad->cd(); respad = new TPad("respad","respad",0,0.8,1,1); respad->Draw(); respad->cd(); //gPad->SetGridy(); TH1F* ratio = (TH1F*) h_dt->Clone("ratio"); ratio->Divide(h_mc); ratio->GetYaxis()->SetTitleOffset(0.3); ratio->GetYaxis()->SetTitleSize(0.2); ratio->GetYaxis()->SetNdivisions(5); ratio->GetYaxis()->SetLabelSize(0.2); if (dolog) ratio->GetYaxis()->SetRangeUser(0.5,1.5); else ratio->GetYaxis()->SetRangeUser(0.7,1.3); ratio->GetYaxis()->SetTitle("Ratio "); ratio->GetXaxis()->SetLabelSize(0); ratio->GetXaxis()->SetTitleSize(0); ratio->SetMarkerSize(1); ratio->SetLineWidth(2); ratio->SetLineColor(kBlue); ratio->SetMarkerColor(kBlue); ratio->SetFillColor(kBlue); ratio->SetFillStyle(3002); ratio->Draw("E2"); TLine line; line.SetLineWidth(2); line.DrawLine(h_dt->GetXaxis()->GetXmin(),1,h_dt->GetXaxis()->GetXmax(),1); }
void uselhcbStyle( Double_t lhcbTSize = 0.06, Double_t lhcbWidth = 2.00, Int_t lhcbFont = 132 ) { //////////////////////////////////////////////////////////////////// // PURPOSE: // // This macro defines a standard style for (black-and-white) // "publication quality" LHCb ROOT plots. // // USAGE: // // Include the lines // gROOT->ProcessLine(".L lhcbstyle.C"); // lhcbStyle(); // at the beginning of your root macro. // // Example usage is given in myPlot.C // // COMMENTS: // // Font: // // The font is chosen to be 132, this is Times New Roman (like the text of // your document) with precision 2. // // "Landscape histograms": // // The style here is designed for more or less square plots. // For longer histograms, or canvas with many pads, adjustements are needed. // For instance, for a canvas with 1x5 histograms: // TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800); // c1->Divide(1,5); // Adaptions like the following will be needed: // gStyle->SetTickLength(0.05,"x"); // gStyle->SetTickLength(0.01,"y"); // gStyle->SetLabelSize(0.15,"x"); // gStyle->SetLabelSize(0.1,"y"); // gStyle->SetStatW(0.15); // gStyle->SetStatH(0.5); // // Authors: Thomas Schietinger, Andrew Powell, Chris Parkes, Niels Tuning // Maintained by Editorial board member (currently Niels) /////////////////////////////////////////////////////////////////// cout << "**********************" << endl << "* ROOT LHCbStyle *" << endl << "**********************" << endl; // Use times new roman, precision 2 //Int_t lhcbFont = 132; // Old LHCb style: 62; // Line thickness //Double_t lhcbWidth = 2.00; // Old LHCb style: 3.00; // Text size //Double_t lhcbTSize = 0.06; // use plain black on white colors gROOT->SetStyle("Plain"); TStyle *lhcbStyle= new TStyle("lhcbStyle","LHCb plots style"); //lhcbStyle->SetErrorX(0); // don't suppress the error bar along X lhcbStyle->SetFillColor(1); lhcbStyle->SetFillStyle(1001); // solid lhcbStyle->SetFrameFillColor(0); lhcbStyle->SetFrameBorderMode(0); lhcbStyle->SetPadBorderMode(0); lhcbStyle->SetPadColor(0); lhcbStyle->SetCanvasBorderMode(0); lhcbStyle->SetCanvasColor(0); lhcbStyle->SetStatColor(0); lhcbStyle->SetLegendBorderSize(0); lhcbStyle->SetLegendFont(132); // If you want the usual gradient palette (blue -> red) lhcbStyle->SetPalette(1); // If you want colors that correspond to gray scale in black and white: int colors[8] = {0,5,7,3,6,2,4,1}; lhcbStyle->SetPalette(8,colors); // set the paper & margin sizes lhcbStyle->SetPaperSize(20,26); lhcbStyle->SetPadTopMargin(0.05); lhcbStyle->SetPadRightMargin(0.05); // increase for colz plots lhcbStyle->SetPadBottomMargin(0.16); lhcbStyle->SetPadLeftMargin(0.14); // use large fonts lhcbStyle->SetTextFont(lhcbFont); lhcbStyle->SetTextSize(lhcbTSize); lhcbStyle->SetLabelFont(lhcbFont,"x"); lhcbStyle->SetLabelFont(lhcbFont,"y"); lhcbStyle->SetLabelFont(lhcbFont,"z"); lhcbStyle->SetLabelSize(lhcbTSize,"x"); lhcbStyle->SetLabelSize(lhcbTSize,"y"); lhcbStyle->SetLabelSize(lhcbTSize,"z"); lhcbStyle->SetTitleFont(lhcbFont); lhcbStyle->SetTitleFont(lhcbFont,"x"); lhcbStyle->SetTitleFont(lhcbFont,"y"); lhcbStyle->SetTitleFont(lhcbFont,"z"); lhcbStyle->SetTitleSize(1.2*lhcbTSize,"x"); lhcbStyle->SetTitleSize(1.2*lhcbTSize,"y"); lhcbStyle->SetTitleSize(1.2*lhcbTSize,"z"); // use medium bold lines and thick markers lhcbStyle->SetLineWidth(lhcbWidth); lhcbStyle->SetFrameLineWidth(lhcbWidth); lhcbStyle->SetHistLineWidth(lhcbWidth); lhcbStyle->SetFuncWidth(lhcbWidth); lhcbStyle->SetGridWidth(lhcbWidth); lhcbStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes lhcbStyle->SetMarkerStyle(20); lhcbStyle->SetMarkerSize(1.0); // label offsets lhcbStyle->SetLabelOffset(0.010,"X"); lhcbStyle->SetLabelOffset(0.010,"Y"); // by default, do not display histogram decorations: lhcbStyle->SetOptStat(0); //lhcbStyle->SetOptStat("emr"); // show only nent -e , mean - m , rms -r // full opts at http://root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat lhcbStyle->SetStatFormat("6.3g"); // specified as c printf options lhcbStyle->SetOptTitle(0); lhcbStyle->SetOptFit(0); //lhcbStyle->SetOptFit(1011); // order is probability, Chi2, errors, parameters //titles lhcbStyle->SetTitleOffset(0.95,"X"); lhcbStyle->SetTitleOffset(0.95,"Y"); lhcbStyle->SetTitleOffset(1.2,"Z"); lhcbStyle->SetTitleFillColor(0); lhcbStyle->SetTitleStyle(0); lhcbStyle->SetTitleBorderSize(0); lhcbStyle->SetTitleFont(lhcbFont,"title"); lhcbStyle->SetTitleX(0.0); lhcbStyle->SetTitleY(1.0); lhcbStyle->SetTitleW(1.0); lhcbStyle->SetTitleH(0.05); // look of the statistics box: lhcbStyle->SetStatBorderSize(0); lhcbStyle->SetStatFont(lhcbFont); lhcbStyle->SetStatFontSize(0.05); lhcbStyle->SetStatX(0.9); lhcbStyle->SetStatY(0.9); lhcbStyle->SetStatW(0.25); lhcbStyle->SetStatH(0.15); // put tick marks on top and RHS of plots lhcbStyle->SetPadTickX(1); lhcbStyle->SetPadTickY(1); // histogram divisions: only 5 in x to avoid label overlaps lhcbStyle->SetNdivisions(505,"x"); lhcbStyle->SetNdivisions(510,"y"); gROOT->SetStyle("lhcbStyle"); gROOT->ForceStyle(); // add LHCb label lhcbName = new TPaveText(gStyle->GetPadLeftMargin() + 0.50, 0.87 - gStyle->GetPadTopMargin(), gStyle->GetPadLeftMargin() + 0.65, 0.95 - gStyle->GetPadTopMargin(), "BRNDC"); lhcbName->AddText("LHCb"); lhcbName->SetFillColor(0); lhcbName->SetTextAlign(12); lhcbName->SetBorderSize(0); TText *lhcbLabel = new TText(); lhcbLabel->SetTextFont(lhcbFont); lhcbLabel->SetTextColor(1); lhcbLabel->SetTextSize(lhcbTSize); lhcbLabel->SetTextAlign(12); TLatex *lhcbLatex = new TLatex(); lhcbLatex->SetTextFont(lhcbFont); lhcbLatex->SetTextColor(1); lhcbLatex->SetTextSize(lhcbTSize); lhcbLatex->SetTextAlign(12); cout << "-------------------------" << endl; cout << "Set LHCb Style - Feb 2012" << endl; cout << "-------------------------" << endl; }
void Draw() { // mh = 20 GeV TFile* file = new TFile("mssm_2tau2b_mH300_histos.root"); // pT b setTDRStyle(0,0,0); TCanvas* c5 = new TCanvas("X","Y",1); scale = 1./ hPtB->Integral(); hPtB->Scale(scale); hPtB->SetTitleSize(0.05, "X"); hPtB->GetXaxis()->SetTitle("p_{T}^{b quark}, GeV"); hPtB->SetMaximum(0.12); hPtB->SetLineStyle(1); hPtB->SetLineWidth(2); hPtB->Draw("hist"); TLatex *tex = new TLatex(0.65,0.96,"CMS Simulation"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.2,0.96,"#sqrt{s} = 14 TeV"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); TLatex *t = new TLatex(); t->SetTextSize(0.045); t->DrawLatex(5.0, 0.1,"gg#rightarrowH, H#rightarrowhh#rightarrow#tau#taubb, m_{H}=300 GeV"); c5->SaveAs("ptb_nmssm_Hhh_tautaubb.pdf"); // eta b setTDRStyle(0,0,0); TCanvas* c6 = new TCanvas("X","Y",1); scale = 1./ hEtaB->Integral(); hEtaB->Scale(scale); hEtaB->SetTitleSize(0.05, "X"); hEtaB->GetXaxis()->SetTitle("#eta^{b-quark}"); hEtaB->SetMaximum(0.08); // hEtaB20->SetMinimum(0.001); hEtaB->SetLineStyle(1); hEtaB->SetLineWidth(2); hEtaB->Draw("hist"); TLatex *tex = new TLatex(0.65,0.96,"CMS Simulation"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.2,0.96,"#sqrt{s} = 14 TeV"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); t->DrawLatex(-4.5, 0.07,"gg#rightarrowH, H#rightarrowhh#rightarrow#tau#taubb, m_{H}=300 GeV"); c6->SaveAs("etab_nmssm_Hhh_tautaubb.pdf"); }
void CombineDiffcheckBump(Display_t dis = kJet) { if(dis==kTrack){ double etaMin = -1.0; double etaMax = 1.0 ; } else { double etaMin = -1.0; double etaMax = 1.0 ; } double etaMinRev = -etaMax; double etaMaxRev = -etaMin; TString algo ="akPu3PF"; //"AkPu3PF" ; // TString residual = "NoResidual"; //"NoResidual" ; // TString shiftType = "hong_2minus_"; TString JetID=""; const int Nfile = 6 ; TFile * f[Nfile] ; TString plotsdir = "/afs/cern.ch/user/h/honi/CMSSW_5_3_8_HI_patch2/RpA/EnergyScale/merge"; const char * kHomeDir = "/home/xuq7/CMSSW_6_2_3_patch1/src/jetRpA/RpA/output/JetTrig/JetID/NoResidual"; f[0] = TFile::Open(Form("%s/DATAPPb_MB%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_mergedMB_pPb_SingleTrack_Full_UsingKKForest_v1.root", kHomeDir,algo.Data()), "readonly"); f[1] = TFile::Open(Form("%s/DATAPPb_Jet20%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_mergedJet20_pPb_Jet20_Full_UsingKKForest_v1.root", kHomeDir, algo.Data()), "readonly"); f[2] = TFile::Open(Form("%s/DATAPPb_Jet40%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_mergedJet40Jet60_pPb_Jet40Jet60_Full_UsingKKForest_v1.root", kHomeDir, algo.Data()), "readonly"); f[3] = TFile::Open(Form("%s/DATAPPb_Jet60%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_mergedJet40Jet60_pPb_Jet40Jet60_Full_UsingKKForest_v1.root", kHomeDir, algo.Data()), "readonly"); f[4] = TFile::Open(Form("%s/DATAPPb_Jet80%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_PA2013_HiForest_PromptReco_JSonPPb_forestv77.root", kHomeDir, algo.Data()), "readonly"); f[5] = TFile::Open(Form("%s/DATAPPb_Jet100%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_PA2013_HiForest_PromptReco_JSonPPb_forestv77.root", kHomeDir, algo.Data()), "readonly"); // f[3] = TFile::Open(Form("%s/%sDATAPPb_Jet60%sJet2013HistIterTrkCorrtest0EtaCut10_mergedJet40Jet60_KK.root", kHomeDir,shiftType.Data(), algo.Data()), "readonly"); // f[4] = TFile::Open(Form("%s/%sDATAPPb_Jet80%sJet2013HistIterTrkCorrtest0EtaCut10_PA2013_HiForest_PromptReco_JSonPPb_forestv77.root", kHomeDir,shiftType.Data(), algo.Data()), "readonly"); // f[5] = TFile::Open(Form("%s/%sDATAPPb_Jet100%sJet2013HistIterTrkCorrtest0EtaCut10_PA2013_HiForest_PromptReco_JSonPPb_forestv77.root", kHomeDir,shiftType.Data(), algo.Data()), "readonly"); // array goes as 0=MB, 1=Trk12, 2=Trk20, 3=Trk30 TH1D * hnevt[6]; TH1D * hnevtNorm[5]; hnevt[0] = (TH1D *) f[0]->Get("Nevents_0-100%"); hnevt[1] = (TH1D *) f[1]->Get("NeventsWithJetAbove40_0-100%"); hnevt[2] = (TH1D *) f[2]->Get("NeventsWithJetAbove60_0-100%"); hnevt[3] = (TH1D *) f[3]->Get("NeventsWithJetAbove75_0-100%"); hnevt[4] = (TH1D *) f[4]->Get("NeventsWithJetAbove95_0-100%"); hnevt[5] = (TH1D *) f[5]->Get("NeventsWithJetAbove120_0-100%"); hnevtNorm[0] = (TH1D *) f[0]->Get("NeventsWithJetAbove40_0-100%"); hnevtNorm[1] = (TH1D *) f[1]->Get("NeventsWithJetAbove60_0-100%"); hnevtNorm[2] = (TH1D *) f[2]->Get("NeventsWithJetAbove75_0-100%"); hnevtNorm[3] = (TH1D *) f[3]->Get("NeventsWithJetAbove95_0-100%"); hnevtNorm[4] = (TH1D *) f[4]->Get("NeventsWithJetAbove120_0-100%"); // Calculate Nevt for each sample double nevt[6]; // Adding the nevent histogram nevt[0] = hnevt[0]->Integral(); nevt[1] = nevt[0] * hnevt[1]->Integral()/hnevtNorm[0]->Integral(); nevt[2] = nevt[1] * hnevt[2]->Integral()/hnevtNorm[1]->Integral(); nevt[3] = nevt[2] * hnevt[3]->Integral()/hnevtNorm[2]->Integral(); nevt[4] = nevt[3] * hnevt[4]->Integral()/hnevtNorm[3]->Integral(); nevt[5] = nevt[4] * hnevt[5]->Integral()/hnevtNorm[4]->Integral(); for(int ifile=0;ifile<Nfile;ifile++){ if(ifile!=Nfile-1){ cout<<ifile<<":"<<hnevt[ifile]->Integral()<<'\t'<<hnevtNorm[ifile]->Integral()<<'\t'<<nevt[ifile]<<endl; cout<<ifile<<":"<<hnevt[ifile]->GetEntries()<<'\t'<<hnevtNorm[ifile]->GetEntries()<<'\t'<<nevt[ifile]<<endl; } else{ cout<<ifile<<":"<<hnevt[ifile]->Integral()<<'\t'<<nevt[ifile]<<endl; cout<<ifile<<":"<<hnevt[ifile]->GetEntries()<<'\t'<<nevt[ifile]<<endl; } } TList * list[Nfile] ; int N ; for(int ifile=0; ifile<Nfile; ifile++){ list[ifile] =(TList*)f[ifile]->GetListOfKeys(); if(ifile==0){ N = list[ifile]->GetEntries(); } } const int Nhist = N ; TH1 * h[Nfile][Nhist]; TH1 * htot[Nhist]; for(int ifile=0; ifile<Nfile; ifile++){ for(int ihist = 0 ; ihist < Nhist ; ihist++){ h[ifile][ihist] = (TH1*)f[ifile]->Get(list[ifile]->At(ihist)->GetName()) ; // h[ifile][ihist]->Sumw2(); h[ifile][ihist]->Scale(1./nevt[ifile]); } } TString outname ; outname =Form("%sCombinedJetTrig%scheckBump.root",JetID.Data(), algo.Data()); TFile * outf = new TFile(Form("%s/%s", kHomeDir, outname.Data()), "RECREATE"); for(int ihist = 0 ; ihist < Nhist ; ihist++){ for(int ifile=0; ifile<Nfile; ifile++){ if(ifile==0) htot[ihist] = (TH1*)h[ifile][ihist]->Clone(Form("%s",list[ifile]->At(ihist)->GetName())); else htot[ihist]->Add(h[ifile][ihist]); } if(htot[ihist]->GetEntries()>0){ htot[ihist]->Write(); } } outf->Close() ; TH1F *hTrk[6]; switch(dis){ case kJet: if(TMath::Abs(etaMin)==1.){ hTrk[0] = (TH1F*)f[0]->Get("jetpt_0-100%"); hTrk[1] = (TH1F*)f[1]->Get("jetpt_0-100%"); hTrk[2] = (TH1F*)f[2]->Get("jetpt_0-100%"); hTrk[3] = (TH1F*)f[3]->Get("jetpt_0-100%"); hTrk[4] = (TH1F*)f[4]->Get("jetpt_0-100%"); hTrk[5] = (TH1F*)f[5]->Get("jetpt_0-100%"); } else { hTrk[0] = (TH1F*)f[0]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[1] = (TH1F*)f[1]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[2] = (TH1F*)f[2]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[3] = (TH1F*)f[3]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[4] = (TH1F*)f[4]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[5] = (TH1F*)f[5]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); } break; case kTrack : if(TMath::Abs(etaMin)==TMath::Abs(etaMax)){ hTrk[0] = (TH1F*)f[0]->Get("inclusivetrackptInEtaM1P1_0-100%"); hTrk[1] = (TH1F*)f[1]->Get("inclusivetrackptInEtaM1P1_0-100%"); hTrk[2] = (TH1F*)f[2]->Get("inclusivetrackptInEtaM1P1_0-100%"); hTrk[3] = (TH1F*)f[3]->Get("inclusivetrackptInEtaM1P1_0-100%"); hTrk[4] = (TH1F*)f[4]->Get("inclusivetrackptInEtaM1P1_0-100%"); hTrk[5] = (TH1F*)f[5]->Get("inclusivetrackptInEtaM1P1_0-100%"); } else { hTrk[0] = (TH1F*)f[0]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[1] = (TH1F*)f[1]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[2] = (TH1F*)f[2]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[3] = (TH1F*)f[3]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[4] = (TH1F*)f[4]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); hTrk[5] = (TH1F*)f[5]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10)); } break ; } for( int i = 0; i<6; i++){ normalizeByBinWidth(hTrk[i]); // hTrk[i]->Scale(1./(etaMax-etaMin)); } ///////////////////////////////////////////////////////////////////////////// // Select Jet-Et Range // create 1D histos TH1F * hTrkPt[6]; for( int i = 0; i<6; i++) { hTrkPt[i] = (TH1F*)hTrk[i]->Clone(Form("jetPt%d_%dInEtaBin%.f_%.f",trigRes[i],trigRes[i+1], etaMin*10, etaMax*10)); // hTrkPt[i]->Scale(1./nevt[i]); } // add together spectra TH1F * hCombined ; for( int i = 0; i<6; i++) { if(i==0) hCombined = (TH1F*)hTrkPt[i]->Clone(Form("CombinedSpectraInEtaBin%.f_%.f", etaMin*10, etaMax*10)); else hCombined->Add(hTrkPt[i]); } // hCombined->Scale(2.);// // convertToInvYield(hCombined);// //////////////////////////////////////////////////////////// hCombined->SetMarkerStyle(20); TCanvas *c1 = new TCanvas("c1a", "c1",0,0,600,600); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c1->Range(0,0,1,1); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); //c1->SetLogy(); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.13); c1->SetRightMargin(0.06); c1->SetTopMargin(0.05); c1->SetBottomMargin(0.16); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); //c1->Divide(1,2,0,0); c1->cd(); c1->SetLogy(); if(dis==kTrack) c1->SetLogx(); // c1->SetLogy(); // c1->SetLogx(); if(dis==kTrack) TH1F * hDum = new TH1F("hhdum","",10,1.,210.); else TH1F * hDum = new TH1F("hhdum","",10,20.,320.); if(dis==kTrack) { hDum->SetMinimum(1e-12); hDum->SetMaximum(100); } else { hDum->SetMinimum(1e-11); hDum->SetMaximum(1.); } hDum->GetXaxis()->SetTitle("p_{T} [GeV/c]"); hDum->GetXaxis()->SetTitleSize(0.035); hDum->GetXaxis()->SetTitleOffset(1.5); hDum->GetXaxis()->SetLabelSize(0.035); hDum->GetYaxis()->SetTitle("1/N_{evt} dN_{ch}/dp_{T}");//just normalize by binwidth // hDum->GetYaxis()->SetTitle("1/N_{evt} d^{2}N_{ch}/d_p{T}d#eta"); // hhdum->GetYaxis()->SetTitle("1/N_{ev} 1/(2#pip_{T}) d^{2}N/dp_{T}d#eta");//invariant yield hDum->GetYaxis()->SetTitleSize(0.035); hDum->GetYaxis()->SetLabelSize(0.035); hDum->GetYaxis()->SetTitleOffset(1.5); hhdum->GetXaxis()->CenterTitle(); hhdum->GetYaxis()->CenterTitle(); hDum->Draw(); hCombined->SetMarkerStyle(24); hCombined->SetMarkerColor(1); hCombined->SetMarkerSize(1.5); hCombined->SetLineColor(1); hCombined->DrawCopy("same"); for( int i = 0; i<6; i++){ hTrkPt[i]->SetMarkerStyle(20);//29 set by yaxian hTrkPt[i]->SetMarkerColor(1+i); hTrkPt[i]->SetLineColor(1+i); hTrkPt[i]->DrawCopy("same"); } /* //---do interplate check------ TFile checkfile("CombinedJetTrigAkPu3PFJetAllHist.root"); TH1F *hcheck = (TH1F*)checkfile.Get("jetpt_0-100%;1"); hcheck->SetMarkerStyle(29); hcheck->SetMarkerSize(2); hcheck->SetMarkerColor(kRed); hcheck->Scale(1./10); hcheck->DrawCopy("same"); //-------------------------------- */ if(TMath::Abs(etaMin)==TMath::Abs(etaMax)) TLatex * tex = new TLatex(60.5,1.0e-9,Form("| #eta_{CM} | < %.1f", etaMax)); else TLatex * tex = new TLatex(60.5,1.0e-9,Form("%.1f < #eta_{CM} < %.1f", etaMin, etaMax)); // TLatex * tex = new TLatex(1.5,1.0e-7,Form("| #eta_{lab} |< 1.0")); //TLatex * tex = new TLatex(2.6,1.05,Form(|#eta_{COM}| < 1.0"); tex->SetTextSize(0.04); tex->Draw(); TLegend * leg = new TLegend(0.5,0.63,0.9,0.9); leg->SetBorderSize(0); leg->AddEntry(hCombined,"pPb Combined","lp"); // leg->AddEntry(hCombined_CombpPbPbp_TrackTriggered_EtaCM_P13_P18_copy1,"12-017","lp"); leg->AddEntry(hTrkPt[0],"Minimum Bias","lp"); for( int i = 1; i<6; i++) leg->AddEntry(hTrkPt[i],Form("Jet%d",trigThres[i-1]),"lp"); // leg->AddEntry(hTrkPtRev[0],"Corrected Tracks Pbp","lp"); leg->SetFillColor(kWhite); leg->Draw(); if(SavePlot)c1->Print(Form("%s/%sCombinedJetTrig%sJetPt.gif",plotsdir.Data(),shiftType.Data(),algo.Data())); //----------do the ratio for interplate check------- /* TCanvas *c2 = new TCanvas("c2a", "c2",0,0,600,600); c2->cd(); hCombined->Clone("hratio"); hratio->Divide(hcheck); hratio->DrawCopy(); */ }
void findtruthPbPb(int binMin, int binMax) { TFile *fmc = new TFile(config.getFileName_djt("mcPbbfa")); buildNamesuffix = TString::Format("_bin_%d_%d",binMin, binMax); // buildTitlesuffix = TString::Format("%d-%d %%",binMin/2, binMax/2); seth(10,0,1); auto hmcPbPbxJTrue = geth("hmcPbPbxJTrue","PbPb true;x_{J};Event fractions"); auto hmcPbPbxJTrueTag = geth("hmcPbPbxJTrueTag","PbPb true tagged;x_{J};Event fractions"); auto hmcPbPbxJTrueTagCorr = geth("hmcPbPbxJTrueTagCorr","PbPb true tagged corrected;x_{J};Event fractions"); auto hmcPbPbxJTrueTagCorrPt = geth("hmcPbPbxJTrueTagCorrPt","PbPb true tagged corrected pt;x_{J};Event fractions"); auto hmcPbPbxJTrueTagCorrEta = geth("hmcPbPbxJTrueTagCorrEta","PbPb true tagged corrected eta;x_{J};Event fractions"); auto hmcPbPbxJTrueTagCorrBin = geth("hmcPbPbxJTrueTagCorrBin","PbPb true tagged corrected bin;x_{J};Event fractions"); seth(12,20,140);//10,40,100); auto hpt2true = geth("hpt2true","true;p_{T,2} GeV"); auto hpt2truetag = geth("hpt2truetag","true tagged;p_{T,2} GeV"); auto hpt2truetagovertrue = geth("hpt2truetagovertrue","true tagged/true;p_{T,2} GeV"); auto hpt2truetagcorr = geth("hpt2truetagcorr","true tagged corrected;p_{T,2} GeV"); auto hpt2truetagcorrovertrue = geth("hpt2truetagcorrovertrue","true tagged corrected/true;p_{T,2} GeV"); seth(10,100,200); auto hpt1true = geth("hpt1true","true;p_{T,1} GeV"); auto hpt1truetag = geth("hpt1truetag","true tagged;p_{T,1} GeV"); auto hpt1truetagovertrue = geth("hpt1truetagovertrue","true tagged/true;p_{T,1} GeV"); auto hpt1truetagcorr = geth("hpt1truetagcorr","true tagged corrected;p_{T,1} GeV"); auto hpt1truetagcorrovertrue = geth("hpt1truetagcorrovertrue","true tagged corrected/true;p_{T,1} GeV"); seth(10,0,200); auto hbintrue = geth("hbintrue","true;bin"); auto hbintruetag = geth("hbintruetag","true tagged;bin"); auto hbintruetagovertrue = geth("hbintruetagovertrue","true tagged/true;bin"); auto hbintruetagcorr = geth("hbintruetagcorr","true tagged corrected;bin"); auto hbintruetagcorrovertrue = geth("hbintruetagcorrovertrue","true tagged corrected/true;bin"); seth(20,-2,2); auto heta2true = geth("heta2true","true;#eta_{2}"); auto heta2truetag = geth("heta2truetag","true tagged;#eta_{2}"); auto heta2truetagovertrue = geth("heta2truetagovertrue","true tagged/true;#eta_{2}"); auto heta2truetagcorr = geth("heta2truetagcorr","true tagged corrected;#eta_{2}"); auto heta2truetagcorrovertrue = geth("heta2truetagcorrovertrue","true tagged corrected/true;#eta_{2}"); auto heta1true = geth("heta1true","true;#eta_{1}"); auto heta1truetag = geth("heta1truetag","true tagged;#eta_{1}"); auto heta1truetagovertrue = geth("heta1truetagovertrue","true tagged/true;#eta_{1}"); auto heta1truetagcorr = geth("heta1truetagcorr","true tagged corrected;#eta_{1}"); auto heta1truetagcorrovertrue = geth("heta1truetagcorrovertrue","true tagged corrected/true;#eta_{1}"); unordered_set<int> eventstodiscard = {1805770,1116573,1084397};//, // 5755734,1599758,395810, // 1363321,211625,3195128}; // Fill(fmc,[&] (dict &m) { if (m["bin"]<binMin || m["bin"]>=binMax) return; if (m["pthat"]<pthatcut) return; if (m[pairCodeSB1]!=0) return; // if (m["bProdCode"]>1) return; if (eventstodiscard.find(m["event"])!=eventstodiscard.end()) return; //kill large-weight GSP event float w = m["weight"]*processweight((int)m["bProdCode"]); //because we have only b-dijets float corr = tageffcorrectionPbPb(m["jtpt1"],m["jteta1"],m[jtptSB],m[jtetaSB],m["bin"]); // float corrpt = getPbPbcorrectionPt(m["jtpt1"],m[jtptSB]); // float correta = getPbPbcorrectionEta(m["jteta1"],m[jtetaSB]); // float corrbin = getPbPbcorrectionBin(m["bin"]); float wb = w*corr; if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[refptSB]>20 && m[dphiSB1]>PI23) { hmcPbPbxJTrue->Fill(m[jtptSB]/m["jtpt1"],w); hpt2true->Fill(m[jtptSB],w); hpt1true->Fill(m["jtpt1"],w); heta2true->Fill(m[jtetaSB],w); heta1true->Fill(m["jteta1"],w); hbintrue->Fill(m["bin"],w); } if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[refptSB]>20 && m[dphiSB1]>PI23 && m["discr_csvV1_1"]>0.9 && m[discr_csvV1_SB]>0.9) { // //corrpt *= m[jtptSB] < 60 ? 1./0.7 : 1; //wb *= m[jtptSB] < 60 ? 1./0.7 : 1; hmcPbPbxJTrueTag->Fill(m[jtptSB]/m["jtpt1"],w); hmcPbPbxJTrueTagCorr->Fill(m[jtptSB]/m["jtpt1"],wb); // hmcPbPbxJTrueTagCorrPt->Fill(m[jtptSB]/m["jtpt1"],w*corrpt); // hmcPbPbxJTrueTagCorrEta->Fill(m[jtptSB]/m["jtpt1"],w*corrpt*correta); // hmcPbPbxJTrueTagCorrBin->Fill(m[jtptSB]/m["jtpt1"],w*corrpt*correta*corrbin); hpt2truetag->Fill(m[jtptSB],w); hpt1truetag->Fill(m["jtpt1"],w); heta2truetag->Fill(m[jtetaSB],w); heta1truetag->Fill(m["jteta1"],w); hbintruetag->Fill(m["bin"],w); hpt2truetagcorr->Fill(m[jtptSB],wb); hpt1truetagcorr->Fill(m["jtpt1"],wb); heta2truetagcorr->Fill(m[jtetaSB],wb); heta1truetagcorr->Fill(m["jteta1"],wb); hbintruetagcorr->Fill(m["bin"],wb); } }); NormalizeAllHists(); //plotymax = 9999; aktstring = TString::Format("PbPb %d-%d %%",binMin/2, binMax/2);//TString::Format("PbPb#Delta#phi>2/3#pi %d-%d %%",binMin/2, binMax/2); SetMC({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr}); SetData({hmcPbPbxJTrue}); hmcPbPbxJTrue->SetMinimum(0); hmcPbPbxJTrue->SetMaximum(0.3); hmcPbPbxJTrue->SetLineWidth(2); hmcPbPbxJTrue->SetMarkerStyle(kNone); hmcPbPbxJTrue->SetFillStyle(0); hmcPbPbxJTrueTag->SetMarkerStyle(kOpenCircle); hmcPbPbxJTrueTagCorr->SetMarkerStyle(kOpenSquare); plotymax = 0.3; Draw({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr}); SetB({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr}); float xjtrue = hmcPbPbxJTrue->GetMean(); float xjtruetag = hmcPbPbxJTrueTag->GetMean(); float xjtruetagcorr = hmcPbPbxJTrueTagCorr->GetMean(); float exjtrue = hmcPbPbxJTrue->GetMeanError(); float exjtruetag = hmcPbPbxJTrueTag->GetMeanError(); float exjtruetagcorr = hmcPbPbxJTrueTagCorr->GetMeanError(); auto c = getc(); hmcPbPbxJTrue->Draw("hist"); hmcPbPbxJTrueTag->Draw("E1,same"); hmcPbPbxJTrueTagCorr->Draw("E1,same"); plotlegendpos = TopLeft; auto l = getLegend(); l->AddEntry(hmcPbPbxJTrue,Form("b-dijets, #LTx_{J}#GT=%.3f#pm%.3f",xjtrue,exjtrue),"L"); l->AddEntry(hmcPbPbxJTrueTag,Form("uncorrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetag,exjtruetag),"P"); l->AddEntry(hmcPbPbxJTrueTagCorr,Form("corrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetagcorr,exjtruetagcorr),"P"); l->Draw(); TLatex *Tl = new TLatex(); Tl->DrawLatexNDC(0.2, 0.8, aktstring); SavePlot(c,Form("closure%d%d",binMin,binMax)); // //if (binMin==0 && binMax==200) { // Draw({hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorrPt,hmcPbPbxJTrueTagCorrEta,hmcPbPbxJTrueTagCorrBin}); // SetMC({hpt2truetag,hpt1truetag,heta2truetag,heta1truetag,hbintruetag}); // plotputmean = false; // plotymax = 0.2; // Draw({hpt2true,hpt2truetag,hpt2truetagcorr}); // plotymax = 0.3; // Draw({hpt1true,hpt1truetag,hpt1truetagcorr}); // plotymax = 0.2; // Draw({heta2true,heta2truetag,heta2truetagcorr}); // Draw({heta1true,heta1truetag,heta1truetagcorr}); // plotymax = 1; // Draw({hbintrue,hbintruetag,hbintruetagcorr}); plotymin = 0; plotymax = 0.2; Draw({hpt2truetag,hpt2true}); Draw({hpt2truetagcorr,hpt2true}); hpt2truetagovertrue->Divide(hpt2truetag,hpt2true,1,1); //"B" hpt1truetagovertrue->Divide(hpt1truetag,hpt1true,1,1); //"B" heta2truetagovertrue->Divide(heta2truetag,heta2true,1,1); //"B" heta1truetagovertrue->Divide(heta1truetag,heta1true,1,1); //"B" hbintruetagovertrue->Divide(hbintruetag,hbintrue,1,1); //"B" hpt2truetagcorrovertrue->Divide(hpt2truetagcorr,hpt2true,1,1); //"B" hpt1truetagcorrovertrue->Divide(hpt1truetagcorr,hpt1true,1,1); //"B" heta2truetagcorrovertrue->Divide(heta2truetagcorr,heta2true,1,1); //"B" heta1truetagcorrovertrue->Divide(heta1truetagcorr,heta1true,1,1); //"B" hbintruetagcorrovertrue->Divide(hbintruetagcorr,hbintrue,1,1); //"B" NormalizeAllHists(); Draw({hpt2truetagovertrue,hpt2truetagcorrovertrue}); Draw({hpt1truetagovertrue,hpt1truetagcorrovertrue}); Draw({heta2truetagovertrue,heta2truetagcorrovertrue}); Draw({heta1truetagovertrue,heta1truetagcorrovertrue}); Draw({hbintruetagovertrue,hbintruetagcorrovertrue}); // } }
void pythiaFinal(double intLumi=-1, bool wide = false) { TLatex *latex = new TLatex(); latex->SetNDC(); latex->SetTextSize(0.045); latex->SetTextAlign(31); // align right latex->DrawLatex(wide ? 0.98 : 0.98, 0.96, "#sqrt{s} = 14 TeV"); if (intLumi > 0.) { latex->SetTextAlign(11); // align left latex->DrawLatex(wide ? 0.06 : 0.15, 0.96, Form("CMS preliminary, L = %.3g fb^{-1}",intLumi*0.001)); } else if (intLumi==0) { // simulation latex->SetTextAlign(11); // align left latex->DrawLatex(wide ? 0.06 : 0.15, 0.96, "CMS simulation (Summer12)"); } else { latex->SetTextAlign(11); // align left latex->DrawLatex(0.13,0.96,"Pythia 8 simulation"); } } // cmsPrel
void findtruthpp() { seth(10,0,1); auto hmcppxJTrue = geth("hmcppxJTrue","true;x_{J};Event fractions"); auto hmcppxJTrueTag = geth("hmcppxJTrueTag","true tagged;x_{J};Event fractions"); auto hmcppxJTrueTagCorr = geth("hmcppxJTrueTagCorr","true tagged corrected;x_{J};Event fractions"); TFile *fmcpp = new TFile(config.getFileName_djt("mcppbfa")); Fill(fmcpp,[&] (dict &m) { if (m["pthat"]<pthatcut) return; if (m[pairCodeSB1]!=0) return; // if (m["pthat"]<80) return; // if (m["bProdCode"]!=1) return; float w = m["weight"]*processweight((int)m["bProdCode"]); // float w = m["weight"]; // if (m["bProdCode"]==2) return; float corr = tageffcorrectionpp(m["jtpt1"],m["jteta1"],m[jtptSB],m[jtetaSB]); float wb = w*corr; if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23) hmcppxJTrue->Fill(m[jtptSB]/m["jtpt1"],w); if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23 && m["discr_csvV1_1"]>0.9 && m[discr_csvV1_SB]>0.9) { hmcppxJTrueTag->Fill(m[jtptSB]/m["jtpt1"],w); hmcppxJTrueTagCorr->Fill(m[jtptSB]/m["jtpt1"],wb); } }); NormalizeAllHists(); plotputmean = true; plotytitle = "Event fractions"; plotdivide = false; // aktstring += "R=0.4 |#eta|<2.0"; // plotsecondline = Form("p_{T,1}>%d GeV, p_{T,2}>%d GeV", (int)pt1cut, (int)pt2cut); // plotthirdline = "#Delta#phi>2/3#pi"; plottextposy = 0.8; plottextposx = 0.2; plotmeanposy = 0.43; plotymax = 0.2; plotymin = 0; plotlegendpos = BottomRight;//TopLeft; aktstring = "pp"; SetMC({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr}); SetData({hmcppxJTrue}); Draw({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr}); hmcppxJTrue->SetMinimum(0); hmcppxJTrue->SetMaximum(0.3); hmcppxJTrue->SetLineWidth(2); hmcppxJTrue->SetMarkerStyle(kNone); hmcppxJTrue->SetFillStyle(0); hmcppxJTrueTag->SetMarkerStyle(kOpenCircle); hmcppxJTrueTagCorr->SetMarkerStyle(kOpenSquare); plotymax = 0.3; SetB({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr}); float xjtrue = hmcppxJTrue->GetMean(); float xjtruetag = hmcppxJTrueTag->GetMean(); float xjtruetagcorr = hmcppxJTrueTagCorr->GetMean(); float exjtrue = hmcppxJTrue->GetMeanError(); float exjtruetag = hmcppxJTrueTag->GetMeanError(); float exjtruetagcorr = hmcppxJTrueTagCorr->GetMeanError(); auto c = getc(); hmcppxJTrue->Draw("hist"); hmcppxJTrueTag->Draw("E1,same"); hmcppxJTrueTagCorr->Draw("E1,same"); plotlegendpos = TopLeft; auto l = getLegend(); l->AddEntry(hmcppxJTrue,Form("b-dijets, #LTx_{J}#GT=%.3f#pm%.3f",xjtrue,exjtrue),"L"); l->AddEntry(hmcppxJTrueTag,Form("uncorrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetag,exjtruetag),"P"); l->AddEntry(hmcppxJTrueTagCorr,Form("corrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetagcorr,exjtruetagcorr),"P"); l->Draw(); TLatex *Tl = new TLatex(); Tl->DrawLatexNDC(0.2, 0.8, aktstring); SavePlot(c,"closurepp"); }
void plot_lj1lj2_pT() { gStyle -> SetStripDecimals(kFALSE); gStyle -> SetPadTickX(1); gStyle -> SetPadTickY(1); gStyle -> SetOptTitle(0); gStyle -> SetOptStat(0); float y1=0. , y2=50000; float y1=0. , y3=50000; float x1=0, x2=1500.; Double_t t1=0.4395973,t2=0.8; Double_t t3=t1, t4=0.7302697; TFile *data = new TFile("/Users/asifsaddique/CMS_BH/QCD_13TeV/output_qcd/QCD_madgraph.root", "READ"); TH1F *lj1_pT50 = (TH1F*)gDirectory -> Get("general/LJ1_pT50"); TH1F *lj2_pT50 = (TH1F*)gDirectory -> Get("general/LJ2_pT50"); lj1_pT50 ->GetSumw2()->Set(0); lj2_pT50->GetSumw2()->Set(0); lj1_pT50->Scale(1000); lj2_pT50->Scale(1000); TCanvas *c1 = new TCanvas("c1","c1",600,600); c1->SetLeftMargin(0.1442953); TCanvas *c2 = new TCanvas("c2","c2",600,600); c2->SetLeftMargin(0.1442953); c1->cd(); lj1_pT50 -> GetYaxis()->SetTitle("# Entries"); lj1_pT50 -> GetXaxis()->SetTitle("1st Leading Jet p_{T}"); lj1_pT50 -> GetYaxis()->SetTitleSize(0.04); lj1_pT50 -> GetXaxis()->SetTitleSize(0.04); lj1_pT50 -> GetXaxis()->SetTitleOffset(1.1); lj1_pT50 -> GetYaxis()->SetTitleOffset(1.75); lj1_pT50 -> SetLineWidth(2); lj1_pT50 -> GetXaxis()->SetRangeUser(x1,x2); lj1_pT50 -> GetYaxis()->SetRangeUser(y1,y3); lj1_pT50 -> Draw(""); float tsize = 0.04; tex = new TLatex(t1,t2,"#sqrt[]{s} = 13 TeV, #intLdt = 1000 pb^{-1}"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(tsize); tex->SetLineWidth(2); tex->Draw(); TLatex * tex = new TLatex(t3,t4,"Jets: p_{T} > 20 GeV, |#eta| < 2.4"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(tsize); tex->SetLineWidth(2); tex->Draw(); c2->cd(); lj2_pT50 -> GetYaxis()->SetTitle("# Entries"); lj2_pT50 -> GetXaxis()->SetTitle("Second Leading Jet p_{T} "); lj2_pT50 -> GetYaxis()->SetTitleSize(0.04); lj2_pT50 -> GetXaxis()->SetTitleSize(0.04); lj2_pT50 -> GetXaxis()->SetTitleOffset(1.1); lj2_pT50 -> GetYaxis()->SetTitleOffset(1.75); lj2_pT50 -> SetLineWidth(2); lj2_pT50 -> GetXaxis()->SetRangeUser(x1,x2); lj2_pT50 -> GetYaxis()->SetRangeUser(y1,y2); lj2_pT50 -> Draw(""); tex = new TLatex(t1,t2,"#sqrt[]{s} = 13 TeV, #intLdt = 1000 pb^{-1}"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(tsize); tex->SetLineWidth(2); tex->Draw(); TLatex * tex = new TLatex(t3,t4,"Jets: p_{T} > 50 GeV, |#eta| < 2.4"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(tsize); tex->SetLineWidth(2); tex->Draw(); c1->SaveAs("/Users/asifsaddique/CMS_BH/QCD_13TeV/Macros/bh_plots/pTeT/lj1_pT50.eps"); c2->SaveAs("/Users/asifsaddique/CMS_BH/QCD_13TeV/Macros/bh_plots/pTeT/lj2_pT50.eps"); }
void DrawPerform(){ gStyle->SetErrorX(0); TFile *fmb = new TFile("testppminbias.root","ReadOnly"); TFile *fhm = new TFile("testppfvtx.root","ReadOnly"); const int ncav = 26; TCanvas *c1[ncav]; for(int i=0;i<ncav;i++){ c1[i] = new TCanvas(); } //Tracks TH2F *hcntetaphi = (TH2F*)fmb->Get("hcntetaphi"); c1[0]->cd(); hcntetaphi->Draw("colz"); c1[0]->Print("fig/hcntetaphi.png"); TH1F *hcntpt = (TH1F*)fmb->Get("hcntpt"); TH1F *hcntpt_hm = (TH1F*)fhm->Get("hcntpt"); c1[1]->cd(); c1[1]->SetLogy(); hcntpt->Rebin(4); hcntpt_hm->Rebin(4); SetStyle(*hcntpt,1.2,1,20,0,0); SetStyle(*hcntpt_hm,1.2,2,24,0,0); hcntpt->Draw("P"); hcntpt_hm->Draw("Psame"); c1[1]->Print("fig/hcntpt.png"); TH2F* pc3dphidz = (TH2F*)fmb->Get("pc3dphidz"); TH1F* pc3dphi = (TH1F*)pc3dphidz->ProjectionX("pc3dphi",0,-1); TH1F* pc3dz = (TH1F*)pc3dphidz->ProjectionY("pc3dz",0,-1); c1[2]->cd(); SetStyle(*pc3dphi,1.2,1,20,0,0); pc3dphi->Draw("P"); c1[2]->Print("fig/pc3dphi.png"); c1[3]->cd(); SetStyle(*pc3dz,1.2,1,20,0,0); pc3dz->Rebin(4); pc3dz->Draw("P"); c1[3]->Print("fig/pc3dz.png"); TH2F* hntracknmpc = (TH2F*)fmb->Get("hntracknmpc"); TH2F* hntracknmpc_hm = (TH2F*)fhm->Get("hntracknmpc"); TH1F* hntrack = (TH1F*)hntracknmpc->ProjectionX("hntrack",0,-1); TH1F* hntrack_hm = (TH1F*)hntracknmpc_hm->ProjectionX("hntrack_hm",0,-1); c1[4]->cd(); c1[4]->SetLogy(); hntrack->Scale(1./hntrack->Integral()); hntrack_hm->Scale(1./hntrack_hm->Integral()); SetStyle(*hntrack,1.2,1,20,0,0); SetStyle(*hntrack_hm,1.2,2,24,0,0); SetRange(*hntrack,0,1e-11,20,10); hntrack->Draw(); hntrack_hm->Draw("Psame"); c1[4]->Print("fig/ntrack.png"); /* //tof TH2F* tofdphidz = (TH2F*)f->Get("tofdphidz"); TH1F* tofdphi = (TH1F*)tofdphidz->ProjectionX("tofdphi",0,-1); TH1F* tofdz = (TH1F*)tofdphidz->ProjectionY("tofdz",0,-1); c1[4]->cd(); tofdphi->Draw(); c1[4]->Print("fig/tofdphi.png"); c1[5]->cd(); tofdz->Draw(); c1[5]->Print("fig/tofdz.png"); TH2F* tofwdphidz = (TH2F*)f->Get("tofwdphidz"); TH2F* ttofqpratio = (TH2F*)f->Get("ttofqpratio"); c1[6]->cd(); ttofqpratio->Draw("colz"); c1[6]->Print("fig/ttofqpratio.png"); TH2F* m2qpratio = (TH2F*)f->Get("m2qpratio"); //vtx TH2F* hcluetaphi[4]; c1[7]->Divide(2,2); for(int i=0;i<4;i++){ hcluetaphi[i] = (TH2F*)f->Get(Form("hcluetaphi_%d",i)); c1[7]->cd(i+1); hcluetaphi[i]->Draw("colz"); TLatex t; t.SetNDC(); t.DrawLatex(0.1,0.8,Form("layer %d",i)); } c1[7]->Print("fig/hcluetaphi.png"); //bbc TH1F* bbcet = (TH1F*)f->Get("bbcet"); c1[8]->cd(); c1[8]->SetLogy(); bbcet->Draw(); c1[8]->Print("fig/bbcet.png"); //fvtx TH2D *DCAxydis[2]; TH2D *DCAxy2dis[2]; TH2D *DCAcentdis[2]; c1[9]->Divide(1,2); c1[10]->Divide(1,2); c1[11]->Divide(1,2); for(int iarm=0;iarm<2;iarm++){ DCAxydis[iarm] = (TH2D*)f->Get(Form("DCAxydis_%d",iarm)); DCAxy2dis[iarm] = (TH2D*)f->Get(Form("DCAxy2dis_%d",iarm)); DCAcentdis[iarm] = (TH2D*)f->Get(Form("DCAcentdis_%d",iarm)); c1[9]->cd(iarm+1); c1[9]->SetLogz(); DCAxydis[iarm]->Draw("colz"); c1[10]->cd(iarm+1); c1[10]->SetLogz(); DCAxy2dis[iarm]->Draw("colz"); c1[11]->cd(iarm+1); c1[11]->SetLogz(); DCAcentdis[iarm]->Draw("colz"); } c1[9]->Print("fig/DCAxydis.png"); c1[10]->Print("fig/DCAxy2dis.png"); c1[11]->Print("fig/DCAcentdis.png"); // TH1F *fvtxdphidis; // TH1F *fvtxdphidis2; c1[12]->Divide(1,2); TH2D *hvtx0etaz = (TH2D*) f->Get("hvtx0etaz"); TH2D *hvtx1etaz = (TH2D*) f->Get("hvtx1etaz"); c1[12]->cd(1); hvtx0etaz->Draw("colz"); c1[12]->cd(2); hvtx1etaz->Draw("colz"); c1[12]->Print("fig/hvtxetaz.png"); c1[13]->Divide(1,2); TH2D *hvtx0etaphi = (TH2D*)f->Get("hvtx0etaphi");; TH2D *hvtx1etaphi = (TH2D*)f->Get("hvtx1etaphi");; c1[13]->cd(1); hvtx0etaphi->Draw("colz"); c1[13]->cd(2); hvtx1etaphi->Draw("colz"); c1[13]->Print("fig/hvtxetaphi.png"); //mpc TH2F* mpcetdis; TH2F* mpcetetasouth[1]; TH2F* mpcetetanorth[1]; TH2F* mpc_south_cent; TH2F* mpc_north_cent; TH2F* mpc_south_north; TH2F *south_mpc_north_mpc; //correlate TH2F* hvtxzfvtxz = (TH2F*)f->Get("hvtxzfvtxz"); c1[14]->cd(); c1[14]->SetLogz(); hvtxzfvtxz->Draw("colz"); c1[14]->Print("fig/hvtxzfvtxz.png"); TH2F* hpc1hitsbbc = (TH2F*)f->Get("hpc1hitsbbc"); TH1F* hpc1hits = (TH1F*)hpc1hitsbbc->ProjectionX("hpc1hits",0,-1); c1[15]->cd(); c1[15]->SetLogy(); hpc1hits->Draw(); c1[15]->Print("fig/hpc1hits.png"); TH1F* hbbc = (TH1F*)hpc1hitsbbc->ProjectionY("hbbc",0,-1); c1[16]->cd(); c1[16]->SetLogy(); hbbc->Draw(); c1[16]->Print("fig/hbbc.png"); TH2F* hnpc3hitsntof = (TH2F*)f->Get("hnpc3hitsntof"); TH1F* hnpc3hits = (TH1F*)hnpc3hitsntof->ProjectionX("hnpc3hits",0,-1); c1[17]->cd(); c1[17]->SetLogy(); hnpc3hits->Draw(); c1[17]->Print("fig/hnpc3hits.png"); TH1F* hntof = (TH1F*)hnpc3hitsntof->ProjectionY("hntof",0,-1); c1[18]->cd(); c1[18]->SetLogy(); hntof->Draw(); c1[18]->Print("fig/hntof.png"); TH2F* hbbcnbbc = (TH2F*)f->Get("hbbcnbbc"); c1[19]->cd(); c1[19]->SetLogz(); hbbcnbbc->Draw("colz"); c1[19]->Print("fig/hbbcnbbc.png"); TH2F* hbbcsbbcn = (TH2F*)f->Get("hbbcsbbcn"); c1[20]->cd(); c1[20]->SetLogz(); hbbcsbbcn->Draw("colz"); c1[20]->Print("fig/hbbcsbbcn.png"); */ TH2F* hnvtxnfvtxtrk[4]; TH2F* hbbcsnvtx[4]; TH2F* hbbcnnvtx[4]; TH2F* hbbcnvtx[4]; TH2F* hbbcnvtx_hm[4]; c1[21]->Divide(2,2); for(int i=0;i<4;i++){ hnvtxnfvtxtrk[i] = (TH2F*)fmb->Get(Form("hnvtxnfvtxtrk_%d",i)); hbbcsnvtx[i] = (TH2F*)fmb->Get(Form("hbbcsnvtx_%d",i)); hbbcnnvtx[i] = (TH2F*)fmb->Get(Form("hbbcnvtx_%d",i)); hbbcnvtx[i] = (TH2F*)fmb->Get(Form("hbbcnvtx_%d",i)); hbbcnvtx_hm[i] = (TH2F*)fhm->Get(Form("hbbcnvtx_%d",i)); c1[21]->cd(i+1); c1[21]->SetLogz(); hnvtxnfvtxtrk[i]->Draw("colz"); TLatex t; t.SetNDC(); t.DrawLatex(0.1,0.8,Form("layer %d",i)); } c1[21]->Print("fig/hnvtxnfvtxtrk.png"); TH1F* hnvtx = (TH1F*)hbbcnvtx[0]->ProjectionY("hnvtx",0,-1); TH1F* hnvtx_hm = (TH1F*)hbbcnvtx_hm[0]->ProjectionY("hnvtx_hm",0,-1); TH1F* hbbc = (TH1F*)hbbcnvtx[0]->ProjectionX("hbbc",0,-1); TH1F* hbbc_hm = (TH1F*)hbbcnvtx_hm[0]->ProjectionX("hbbc_hm",0,-1); c1[22]->cd(); c1[22]->SetLogy(); hnvtx->Rebin(4); hnvtx_hm->Rebin(4); hnvtx->Scale(1./hnvtx->Integral()); hnvtx_hm->Scale(1./hnvtx_hm->Integral()); SetRange(*hnvtx,0,1e-11,200,10); SetTitle(*hnvtx,"#hits in cluster layer 1","normalized",""); SetStyle(*hnvtx,1.2,1,20,0,0); SetStyle(*hnvtx_hm,1.2,2,24,0,0); hnvtx->Draw("P"); hnvtx_hm->Draw("Psame"); c1[22]->Print("fig/hnvtx.png"); c1[23]->cd(); c1[23]->SetLogy(); SetTitle(*hbbc,"bbc charge sum","normalized",""); hbbc->Rebin(5); hbbc_hm->Rebin(5); hbbc->Scale(1./hbbc->Integral()); hbbc_hm->Scale(1./hbbc_hm->Integral()); SetRange(*hbbc,0,1e-11,200,10); SetStyle(*hbbc,1.2,1,20,0,0); SetStyle(*hbbc_hm,1.2,2,24,0,0); hbbc->Draw("P"); hbbc_hm->Draw("Psame"); c1[23]->Print("fig/hbbc.png"); c1[24]->cd(); c1[24]->SetLogz(); SetTitle(*hbbcnvtx_hm[0],"bbc charge sum","#hits in cluster layer 1",""); hbbcnvtx_hm[0]->Draw("colz"); c1[24]->Print("fig/hbbcnvtx_hm.png"); /* TH2F* hnbbcnclu = (TH2F*)f->Get("hnbbcnclu"); TH1F* hnbbc = (TH1F*)hnbbcnclu->ProjectionX("hnbbc",0,-1); TH1F* hnclu = (TH1F*)hnbbcnclu->ProjectionY("hnclu",0,-1); c1[23]->cd(); c1[23]->SetLogy(); hnbbc->Draw(); c1[23]->Print("fig/hnbbc.png"); c1[24]->cd(); c1[24]->SetLogy(); hnclu->Draw(); c1[24]->Print("fig/hnclu.png"); TH2F *hnfvtxtrkbbc = (TH2F*)f->Get("hnfvtxtrkbbc"); c1[25]->cd(); c1[25]->SetLogz(); hnfvtxtrkbbc->Draw("colz"); c1[25]->Print("fig/hnfvtxtrkbbc.png"); TH2F *hnfvtxtrksnmpcs = (TH2F*)f->Get("hnfvtxtrksnmpcs"); TH2F *hnfvtxtrknnmpcn = (TH2F*)f->Get("hnfvtxtrknnmpcn"); TH2F *south_mpc_south_bbc; TH2F *north_mpc_north_bbc; */ }
int plotBasics(){//main TString plotDir = "../PLOTS/version_20/scenario_0/"; //const double Emip = 0.0559;//in MeV //const unsigned nLayers = 30; TFile *inputFile = TFile::Open(plotDir+"/CalibHistos.root"); if (!inputFile) { std::cout << " -- Error, input file " << plotDir << "/CalibHistos.root cannot be opened. Exiting..." << std::endl; return 1; } TCanvas *myc = new TCanvas("myc","myc",1);//1500,1000); ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// //parameters to change TString genEn = "500"; //list histos TH1F *p_nSimHits = (TH1F*)gDirectory->Get("p_nSimHits_"+genEn); TH1F *p_nRecHits = (TH1F*)gDirectory->Get("p_nRecHits_"+genEn); std::ostringstream saveName; saveName.str(""); saveName << plotDir << "/nHits_" << genEn; ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// gStyle->SetOptStat(1110); myc->Divide(2,1); myc->cd(1); p_nSimHits->Rebin(200); float xMin = p_nSimHits->GetMean()-5*p_nSimHits->GetRMS(); float xMax = p_nSimHits->GetMean()+5*p_nSimHits->GetRMS(); float yMax = p_nSimHits->GetMaximum(); p_nSimHits->GetXaxis()->SetRangeUser(xMin,xMax); p_nSimHits->Draw("PE"); TLatex lat; lat.DrawLatex(xMin,yMax*1.2,"e-, "+genEn+" GeV, 2.5#times2.5 mm^{2} cells"); myc->cd(2); p_nRecHits->Rebin(20); xMin = p_nRecHits->GetMean()-5*p_nRecHits->GetRMS(); xMax = p_nRecHits->GetMean()+5*p_nRecHits->GetRMS(); yMax = p_nRecHits->GetMaximum(); p_nRecHits->GetXaxis()->SetRangeUser(xMin,xMax); p_nRecHits->Draw("PE"); lat.DrawLatex(xMin,yMax*1.2,"e-, "+genEn+" GeV, 1#times1 cm^{2} cells"); myc->Update(); myc->Print("Basics/nHits_"+genEn+".png"); myc->Print("Basics/nHits_"+genEn+".pdf"); return 0; }//main
// const char* infilePairStd="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoPairType1.root", // const char* infilePairRegit="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoPairType2.root", // const char* infileTrkStd="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoTrkType1.root", // const char* infileTrkRegit="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoTrkType2.root", //____________________________________________________________________________________ void makeEfficiency(const char* pTuplePairStd="mcmatchanalysis/pnSimRecoPairType1", const char* pTuplePairRegit="mcmatchanalysis/pnSimRecoPairType2", const char* pTupleTrkStd="mcmatchanalysis/pnSimRecoTrkType1", const char* pTupleTrkRegit="mcmatchanalysis/pnSimRecoTrkType2", const char* pOutFilePath="outputfigs", const char* pOutFileName="effs_bjpsi", Bool_t bSavePlots=true) { gROOT->Macro("/afs/cern.ch/user/m/mironov/utilities/setStyle.C+"); gStyle->SetPalette(1); const char* aInFileLocation[4] = {"", // "/tmp/camelia/tuple_jpsi_v11_minbias" "/afs/cern.ch/user/e/echapon/workspace/private/jpsi_PbPb_5_3_17/CMSSW_5_3_17/src/RegitStudy/McAnalyzer/test/ntuples_bjpsi/ntuples_pp", "/afs/cern.ch/user/e/echapon/workspace/private/jpsi_PbPb_5_3_17/CMSSW_5_3_17/src/RegitStudy/McAnalyzer/test/ntuples_bjpsi/ntuples_regit", "/afs/cern.ch/user/e/echapon/workspace/private/jpsi_PbPb_5_3_17/CMSSW_5_3_17/src/RegitStudy/McAnalyzer/test/ntuples_bjpsi/ntuples_regit_3LastRegitStepsAsPp" }; const int nPtBins = 2; const char* aPtSignalBins[nPtBins] = {"", "" // "_ptSignal03_", // "_ptSignal36_", // "_ptSignal69_", //"_ptSignal1215_", // "_ptSignal1530_" }; bool bDoSinglePlots = true; bool bDo2D = true; bool bDoPairPlots = true; float ptPairMin = 0; float ptPairMax = 20; int nPtPairBins = 10; float ptTrkMin = 0; float ptTrkMax = 20; int nPtTrkBins = 10; TCut pairGenSelection("smuacc(pt1,eta1)&&smuacc(pt2,eta2) &&npixelhits1>2&&npixelhits2>2 &&nmuonhits1>0&&nmuonhits2>0"); TCut pairRecoSelection("smuacc(ptreco1,etareco1)&&smuacc(ptreco2,etareco2) &&nvalidpixelhitsreco1>2&&nvalidpixelhitsreco2>2 &&nvalidmuonhitsreco1>0&&nvalidmuonhitsreco2>0 &&minvreco>2.6&&minvreco<3.5&&chi2ndofreco1<4&&chi2ndofreco2<4"); TCut trkGenSelection("TMath::Abs(eta)<2.4&&(abs(idparent)<550&&abs(idparent)>442) &&npixelhits>2&&nmuonhits>0"); TCut trkRecoSelection("TMath::Abs(eta)<2.4&&(abs(idparent)<550&&abs(idparent)>442) &&nvalidpixelhitsreco>2&&nvalidmuonhitsreco>0 &&nmatch>0&&chi2ndofreco<4"); // TCut pairGenSelection("TMath::Abs(eta1)<2.4&&TMath::Abs(eta2)<2.4&&npixelhits1>1&&npixelhits2>1&&nmuonhits1>0&&nmuonhits2>0"); // TCut pairRecoSelection("nmuonhits1>0&&nmuonhits2>0&&minvreco>2.6&&minvreco<3.5"); // TCut trkGenSelection("TMath::Abs(eta)<2.4&&idparent==443&&npixelhits>1&&nmuonhits>0"); // TCut trkRecoSelection("nvalidmuonhitsreco>0"); // axis pair TH1F *phPtTmp = new TH1F("phPtTmp",";p_{T}^{#mu#mu}[GeV/c];Efficiency",1,ptPairMin,ptPairMax); TH1F *phYTmp = new TH1F("phYTmp",";y^{#mu#mu};Efficiency",1,-2.4,2.4); phPtTmp->SetMinimum(0.005); phYTmp->SetMinimum(0.005); phPtTmp->SetMaximum(1.); phYTmp->SetMaximum(1.); TH2F *phPtYTmp = new TH2F("phPtYTmp",";y;p_{T}^{#mu#mu}[GeV/c]",1,-2.4,2.4,1,ptPairMin,ptPairMax); // axis single TH1F *phPtTmp2 = new TH1F("phPtTmp2",";p_{T}^{#mu}[GeV/c];Efficiency",1,ptTrkMin,ptTrkMax); phPtTmp2->SetMinimum(0.005); phPtTmp2->SetMaximum(1.); TH1F *phEtaTmp = new TH1F("phEtaTmp",";#eta^{#mu};Efficiency",1,-2.4,2.4); phEtaTmp->SetMinimum(0.005); phEtaTmp->SetMaximum(1.); TH2F *phPtEtaTmp = new TH2F("phPtEtaTmp",";#eta;p_{T}^{#mu}[GeV/c]",1,-2.4,2.4,1,ptTrkMin,ptTrkMax); // TH2F *phPtEtaTmp = new TH2F("phPtEtaTmp",";#eta;p_{T}^{#mu}[GeV/c]",1,-2.4,2.4,1,ptTrkMin,5); if(bDoPairPlots) { TChain *ptPairPp = new TChain(Form("%s",pTuplePairStd)); TChain *ptPairStd = new TChain(Form("%s",pTuplePairStd)); TChain *ptPairRegit = new TChain(Form("%s",pTuplePairRegit)); for(int iptbin=1; iptbin<nPtBins; iptbin++) { const char* infilePairPp = Form("%s%s.root",aInFileLocation[1],aPtSignalBins[iptbin]); ptPairPp->Add(infilePairPp); const char* infilePairStd = Form("%s%s.root",aInFileLocation[2],aPtSignalBins[iptbin]); ptPairStd->Add(infilePairStd); const char* infilePairRegit = Form("%s%s.root",aInFileLocation[3],aPtSignalBins[iptbin]); ptPairRegit->Add(infilePairRegit); } // ########## pair plots!!! TH1D *phPtGenRecoPair_pp = new TH1D("phPtGenRecoPair_pp","phPtGenRecoPair_pp",nPtPairBins,ptPairMin,ptPairMax); TH1D *phPtGenPair_pp = new TH1D("phPtGenPair_pp","phPtGenPair_pp",nPtPairBins,ptPairMin,ptPairMax); TH1D *phYGenRecoPair_pp = new TH1D("phYGenRecoPair_pp","phYGenRecoPair_pp",12,-2.4,2.4); TH1D *phYGenPair_pp = new TH1D("phYGenPair_pp","phYGenPair_pp",12,-2.4,2.4); phPtGenRecoPair_pp->Sumw2(); phPtGenPair_pp->Sumw2(); phYGenRecoPair_pp->Sumw2(); phYGenPair_pp->Sumw2(); TH1D *phPtGenRecoPair_std = new TH1D("phPtGenRecoPair_std","phPtGenRecoPair_std",nPtPairBins,ptPairMin,ptPairMax); TH1D *phPtGenPair_std = new TH1D("phPtGenPair_std","phPtGenPair_std",nPtPairBins,ptPairMin,ptPairMax); TH1D *phYGenRecoPair_std = new TH1D("phYGenRecoPair_std","phYGenRecoPair_std",12,-2.4,2.4); TH1D *phYGenPair_std = new TH1D("phYGenPair_std","phYGenPair_std",12,-2.4,2.4); phPtGenRecoPair_std->Sumw2(); phPtGenPair_std->Sumw2(); phYGenRecoPair_std->Sumw2(); phYGenPair_std->Sumw2(); TH1D *phPtGenRecoPair_regit = new TH1D("phPtGenRecoPair_regit","phPtGenRecoPair_regit",nPtPairBins,ptPairMin,ptPairMax); TH1D *phPtGenPair_regit = new TH1D("phPtGenPair_regit","phPtGenPair_regit",nPtPairBins,ptPairMin,ptPairMax); TH1D *phYGenRecoPair_regit = new TH1D("phYGenRecoPair_regit","phYGenRecoPair_regit",12,-2.4,2.4); TH1D *phYGenPair_regit = new TH1D("phYGenPair_regit","phYGenPair_regit",12,-2.4,2.4); phPtGenRecoPair_regit->Sumw2(); phPtGenPair_regit->Sumw2(); phYGenRecoPair_regit->Sumw2(); phYGenPair_regit->Sumw2(); // 2d histos TH2F *phPtYGenRecoPair_pp = new TH2F("phPtYGenRecoPair_pp",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax); TH2F *phPtYGenPair_pp = new TH2F("phPtYGenPair_pp",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax); TH2F *phPtYGenRecoPair_std = new TH2F("phPtYGenRecoPair_std",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax); TH2F *phPtYGenPair_std = new TH2F("phPtYGenPair_std",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax); TH2F *phPtYGenRecoPair_regit = new TH2F("phPtYGenRecoPair_regit",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax); TH2F *phPtYGenPair_regit = new TH2F("phPtYGenPair_regit",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax); TCanvas *pcTemp = new TCanvas("pcTemp","pcTemp", 900, 400); pcTemp->Divide(3,1); pcTemp->cd(1); ptPairPp->Draw("pt>>phPtGenPair_pp","","E"); ptPairPp->Draw("pt>>phPtGenPair_pp",pairGenSelection,"E"); ptPairPp->Draw("ptreco>>phPtGenRecoPair_pp",pairRecoSelection,"Esame"); pcTemp->cd(2); ptPairPp->Draw("y>>phYGenPair_pp",pairGenSelection,"E"); ptPairPp->Draw("yreco>>phYGenRecoPair_pp",pairRecoSelection,"Esame"); pcTemp->cd(1); ptPairStd->Draw("pt>>phPtGenPair_std",pairGenSelection,"Esame"); ptPairStd->Draw("ptreco>>phPtGenRecoPair_std",pairRecoSelection,"Esame"); pcTemp->cd(2); ptPairStd->Draw("y>>phYGenPair_std",pairGenSelection,"Esame"); ptPairStd->Draw("yreco>>phYGenRecoPair_std",pairRecoSelection,"Esame"); pcTemp->cd(1); ptPairRegit->Draw("pt>>phPtGenPair_regit",pairGenSelection,"Esame"); ptPairRegit->Draw("ptreco>>phPtGenRecoPair_regit",pairRecoSelection,"Esame"); pcTemp->cd(2); ptPairRegit->Draw("y>>phYGenPair_regit",pairGenSelection,"Esame"); ptPairRegit->Draw("yreco>>phYGenRecoPair_regit",pairRecoSelection,"Esame"); ptPairPp->Draw("pt:y>>phPtYGenPair_pp",pairGenSelection,"colz"); ptPairPp->Draw("ptreco:yreco>>phPtYGenRecoPair_pp",pairRecoSelection,"colz"); ptPairStd->Draw("pt:y>>phPtYGenPair_std",pairGenSelection,"colz"); ptPairStd->Draw("ptreco:yreco>>phPtYGenRecoPair_std",pairRecoSelection,"colz"); ptPairRegit->Draw("pt:y>>phPtYGenPair_regit",pairGenSelection,"colz"); ptPairRegit->Draw("ptreco:yreco>>phPtYGenRecoPair_regit",pairRecoSelection,"colz"); TH1D *pgPtEff_pp = new TH1D("pgPtEff_pp","pgPtEff_pp",nPtPairBins,ptPairMin,ptPairMax); TH1D *pgYEff_pp = new TH1D("pgYEff_pp","pgYEff_pp",12,-2.4,2.4); pgPtEff_pp->Sumw2(); pgYEff_pp->Sumw2(); TH1D *pgPtEff_std = new TH1D("pgPtEff_std","pgPtEff_std",nPtPairBins,ptPairMin,ptPairMax); TH1D *pgYEff_std = new TH1D("pgYEff_std","pgYEff_std",12,-2.4,2.4); pgPtEff_std->Sumw2(); pgYEff_std->Sumw2(); TH1D *pgPtEff_regit = new TH1D("pgPtEff_regit","pgPtEff_regit",nPtPairBins,ptPairMin,ptPairMax); TH1D *pgYEff_regit = new TH1D("pgYEff_regit","pgYEff_regit",12,-2.4,2.4); pgPtEff_regit->Sumw2(); pgYEff_regit->Sumw2(); pgPtEff_pp->Divide(phPtGenRecoPair_pp,phPtGenPair_pp,1,1,"b"); pgYEff_pp->Divide(phYGenRecoPair_pp,phYGenPair_pp,1,1,"b"); pgPtEff_std->Divide(phPtGenRecoPair_std,phPtGenPair_std,1,1,"b"); pgYEff_std->Divide(phYGenRecoPair_std,phYGenPair_std,1,1,"b"); pgPtEff_regit->Divide(phPtGenRecoPair_regit,phPtGenPair_regit,1,1,"b"); pgYEff_regit->Divide(phYGenRecoPair_regit,phYGenPair_regit,1,1,"b"); // 2d histos TH2D *pgPtYEff_pp = new TH2D("pgPtYEff_pp","pgPtYEff_pp",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax); TH2D *pgPtYEff_std = new TH2D("pgPtYEff_std","pgPtYEff_std",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax); TH2D *pgPtYEff_regit = new TH2D("pgPtYEff_regit","pgPtYEff_regit",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax); pgPtYEff_pp->Divide(phPtYGenRecoPair_pp,phPtYGenPair_pp,1,1,"b"); pgPtYEff_std->Divide(phPtYGenRecoPair_std,phPtYGenPair_std,1,1,"b"); pgPtYEff_regit->Divide(phPtYGenRecoPair_regit,phPtYGenPair_regit,1,1,"b"); // drawing pgPtEff_pp->SetLineColor(3); pgPtEff_pp->SetMarkerColor(3); pgPtEff_pp->SetMarkerStyle(3); pgYEff_pp->SetLineColor(3); pgYEff_pp->SetMarkerColor(3); pgYEff_pp->SetMarkerStyle(3); pgPtEff_std->SetLineColor(4); pgPtEff_std->SetMarkerColor(4); pgPtEff_std->SetMarkerStyle(4); pgYEff_std->SetLineColor(4); pgYEff_std->SetMarkerColor(4); pgYEff_std->SetMarkerStyle(4); pgPtEff_regit->SetLineColor(2); pgPtEff_regit->SetMarkerColor(2); pgPtEff_regit->SetMarkerStyle(25); pgYEff_regit->SetLineColor(2); pgYEff_regit->SetMarkerColor(2); pgYEff_regit->SetMarkerStyle(25); TCanvas *pcPairEff = new TCanvas("pcPairEff","pcPairEff",900,500); pcPairEff->Divide(2,1); pcPairEff->cd(1);// gPad->SetLogy(); phPtTmp->Draw(); pgPtEff_pp->Draw("pl same"); pgPtEff_std->Draw("pl same"); pgPtEff_regit->Draw("pl same"); pcPairEff->cd(2); //gPad->SetLogy(); phYTmp->Draw(); pgYEff_pp->Draw("pl same"); pgYEff_std->Draw("pl same"); pgYEff_regit->Draw("pl same"); TLegend *t = new TLegend(0.34,0.78,0.94,0.91); t->SetBorderSize(0); t->SetFillStyle(0); t->AddEntry(pgPtEff_pp,"Pp_reco","pl"); t->AddEntry(pgPtEff_std,"Std_reco","pl"); t->AddEntry(pgPtEff_regit,"Regit_reco","pl"); t->Draw(); //2D histo if(bDo2D) { TLatex lx; TCanvas *pcPtYPairEff = new TCanvas("pcPtYPairEff","pcPtYPairEff",1500,600); pcPtYPairEff->Divide(3,1); pcPtYPairEff->cd(1); pcPtYPairEff->GetPad(1)->SetLeftMargin(0.16); pcPtYPairEff->GetPad(1)->SetRightMargin(0.15); phPtYTmp->Draw(); pgPtYEff_pp->GetZaxis()->SetRangeUser(0.0,1.0); pgPtYEff_pp->Draw("colz same"); lx.DrawLatex(0.,2.,"Pp_reco"); gPad->Update(); pcPtYPairEff->cd(2); pcPtYPairEff->GetPad(2)->SetLeftMargin(0.16); pcPtYPairEff->GetPad(2)->SetRightMargin(0.15); phPtYTmp->Draw(); pgPtYEff_std->GetZaxis()->SetRangeUser(0.0,1.0); pgPtYEff_std->Draw("colz same"); lx.DrawLatex(0.,2.,"Std_reco"); gPad->Update(); pcPtYPairEff->cd(3); pcPtYPairEff->GetPad(3)->SetLeftMargin(0.16); pcPtYPairEff->GetPad(3)->SetRightMargin(0.15); phPtYTmp->Draw(); pgPtYEff_regit->GetZaxis()->SetRangeUser(0.0,1.0); pgPtYEff_regit->Draw("colz same"); lx.DrawLatex(0.,2,"Regit_reco"); if(bSavePlots) { TString outFileBase1(Form("%s/%s_%s",pOutFilePath,pcPtYPairEff->GetTitle(),pOutFileName)); TString outFileGif1 = outFileBase1+".gif"; pcPtYPairEff->Print(outFileGif1.Data(),"gifLandscape"); TString outFilePdf1 = outFileBase1+".pdf"; pcPtYPairEff->SaveAs(outFilePdf1.Data()); } } if(bSavePlots) { TString outFileBase(Form("%s/%s_%s",pOutFilePath,pcPairEff->GetTitle(),pOutFileName)); TString outFileGif = outFileBase+".gif"; pcPairEff->Print(outFileGif.Data(),"gifLandscape"); TString outFilePdf = outFileBase+".pdf"; pcPairEff->SaveAs(outFilePdf.Data()); } } // ##########--------------------- single plots!!! if(bDoSinglePlots) { TChain *ptTrkPp = new TChain(Form("%s",pTupleTrkStd)); TChain *ptTrkStd = new TChain(Form("%s",pTupleTrkStd)); TChain *ptTrkRegit = new TChain(Form("%s",pTupleTrkRegit)); //nPtBins for(int iptbin=1; iptbin<nPtBins; iptbin++) { const char* infileTrkPp = Form("%s%s.root",aInFileLocation[1],aPtSignalBins[iptbin]); ptTrkPp->Add(infileTrkPp); const char* infileTrkStd = Form("%s%s.root",aInFileLocation[2],aPtSignalBins[iptbin]); ptTrkStd->Add(infileTrkStd); const char* infileTrkRegit = Form("%s%s.root",aInFileLocation[3],aPtSignalBins[iptbin]); ptTrkRegit->Add(infileTrkRegit); } TH1D *phPtGenRecoTrk_pp = new TH1D("phPtGenRecoTrk_pp","phPtGenRecoTrk_pp",nPtTrkBins,ptTrkMin,ptTrkMax); TH1D *phPtGenTrk_pp = new TH1D("phPtGenTrk_pp","phPtGenTrk_pp",nPtTrkBins,ptTrkMin,ptTrkMax); TH1D *phEtaGenRecoTrk_pp = new TH1D("phEtaGenRecoTrk_pp","phEtaGenRecoTrk_pp",12,-2.4,2.4); TH1D *phEtaGenTrk_pp = new TH1D("phEtaGenTrk_pp","phEtaGenTrk_pp",12,-2.4,2.4); phPtGenRecoTrk_pp->Sumw2(); phPtGenTrk_pp->Sumw2(); phEtaGenRecoTrk_pp->Sumw2(); phEtaGenTrk_pp->Sumw2(); TH1D *phPtGenRecoTrk_std = new TH1D("phPtGenRecoTrk_std","phPtGenRecoTrk_std",nPtTrkBins,ptTrkMin,ptTrkMax); TH1D *phPtGenTrk_std = new TH1D("phPtGenTrk_std","phPtGenTrk_std",nPtTrkBins,ptTrkMin,ptTrkMax); TH1D *phEtaGenRecoTrk_std = new TH1D("phEtaGenRecoTrk_std","phEtaGenRecoTrk_std",12,-2.4,2.4); TH1D *phEtaGenTrk_std = new TH1D("phEtaGenTrk_std","phEtaGenTrk_std",12,-2.4,2.4); phPtGenRecoTrk_std->Sumw2(); phPtGenTrk_std->Sumw2(); phEtaGenRecoTrk_std->Sumw2(); phEtaGenTrk_std->Sumw2(); TH1D *phPtGenRecoTrk_regit = new TH1D("phPtGenRecoTrk_regit","phPtGenRecoTrk_regit",nPtTrkBins,ptTrkMin,ptTrkMax); TH1D *phPtGenTrk_regit = new TH1D("phPtGenTrk_regit","phPtGenTrk_regit",nPtTrkBins,ptTrkMin,ptTrkMax); TH1D *phEtaGenRecoTrk_regit= new TH1D("phEtaGenRecoTrk_regit","phEtaGenRecoTrk_regit",12,-2.4,2.4); TH1D *phEtaGenTrk_regit = new TH1D("phEtaGenTrk_regit","phEtaGenTrk_regit",12,-2.4,2.4); phPtGenRecoTrk_regit->Sumw2(); phPtGenTrk_regit->Sumw2(); phEtaGenRecoTrk_regit->Sumw2(); phEtaGenTrk_regit->Sumw2(); TCanvas *pcTemp2 = new TCanvas("pcTemp2","pcTemp2", 900, 400); pcTemp2->Divide(2,1); pcTemp2->cd(1); pcTemp2->cd(1); ptTrkPp->Draw("pt>>phPtGenTrk_pp",trkGenSelection,"E"); ptTrkPp->Draw("ptreco>>phPtGenRecoTrk_pp",trkRecoSelection,"Esame"); pcTemp2->cd(2); ptTrkPp->Draw("eta>>phEtaGenTrk_pp",trkGenSelection,"E"); ptTrkPp->Draw("etareco>>phEtaGenRecoTrk_pp",trkRecoSelection,"Esame"); ptTrkStd->Draw("pt>>phPtGenTrk_std",trkGenSelection,"Esame"); ptTrkStd->Draw("ptreco>>phPtGenRecoTrk_std",trkRecoSelection,"Esame"); pcTemp2->cd(2); ptTrkStd->Draw("eta>>phEtaGenTrk_std",trkGenSelection,"Esame"); ptTrkStd->Draw("etareco>>phEtaGenRecoTrk_std",trkRecoSelection,"Esame"); pcTemp2->cd(1); ptTrkRegit->Draw("pt>>phPtGenTrk_regit",trkGenSelection,"Esame"); ptTrkRegit->Draw("ptreco>>phPtGenRecoTrk_regit",trkRecoSelection,"Esame"); pcTemp2->cd(2); ptTrkRegit->Draw("eta>>phEtaGenTrk_regit",trkGenSelection,"Esame"); ptTrkRegit->Draw("etareco>>phEtaGenRecoTrk_regit",trkRecoSelection,"Esame"); TH1D *pgPtTrkEff_pp = new TH1D("pgPtTrkEff_pp","pgPtTrkEff_pp",nPtTrkBins,ptTrkMin,ptTrkMax); TH1D *pgEtaTrkEff_pp = new TH1D("pgEtaTrkEff_pp","pgEtaTrkEff_pp",12,-2.4,2.4); pgPtTrkEff_pp->Sumw2(); pgEtaTrkEff_pp->Sumw2(); TH1D *pgPtTrkEff_std = new TH1D("pgPtTrkEff_std","pgPtTrkEff_std",nPtTrkBins,ptTrkMin,ptTrkMax); TH1D *pgEtaTrkEff_std = new TH1D("pgEtaTrkEff_std","pgEtaTrkEff_std",12,-2.4,2.4); pgPtTrkEff_std->Sumw2(); pgEtaTrkEff_std->Sumw2(); TH1D *pgPtTrkEff_regit = new TH1D("pgPtTrkEff_regit","pgPtTrkEff_regit",nPtTrkBins,ptTrkMin,ptTrkMax); TH1D *pgEtaTrkEff_regit = new TH1D("pgEtaTrkEff_regit","pgEtaTrkEff_regit",12,-2.4,2.4); pgPtTrkEff_regit->Sumw2(); pgEtaTrkEff_regit->Sumw2(); pgPtTrkEff_pp->Divide(phPtGenRecoTrk_pp,phPtGenTrk_pp,1,1,"b"); pgEtaTrkEff_pp->Divide(phEtaGenRecoTrk_pp,phEtaGenTrk_pp,1,1,"b"); pgPtTrkEff_std->Divide(phPtGenRecoTrk_std,phPtGenTrk_std,1,1,"b"); pgEtaTrkEff_std->Divide(phEtaGenRecoTrk_std,phEtaGenTrk_std,1,1,"b"); pgPtTrkEff_regit->Divide(phPtGenRecoTrk_regit,phPtGenTrk_regit,1,1,"b"); pgEtaTrkEff_regit->Divide(phEtaGenRecoTrk_regit,phEtaGenTrk_regit,1,1,"b"); // 2D stuff TH2F *phPtEtaGenRecoTrk_pp = new TH2F("phPtEtaGenRecoTrk_pp",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax); TH2F *phPtEtaGenTrk_pp = new TH2F("phPtEtaGenTrk_pp",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax); ptTrkPp->Draw("pt:eta>>phPtEtaGenTrk_pp",trkGenSelection,"colz"); ptTrkPp->Draw("ptreco:etareco>>phPtEtaGenRecoTrk_pp",trkRecoSelection,"colz"); TH2F *phPtEtaGenRecoTrk_std = new TH2F("phPtEtaGenRecoTrk_std",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax); TH2F *phPtEtaGenTrk_std = new TH2F("phPtEtaGenTrk_std",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax); ptTrkStd->Draw("pt:eta>>phPtEtaGenTrk_std",trkGenSelection,"colz"); ptTrkStd->Draw("ptreco:etareco>>phPtEtaGenRecoTrk_std",trkRecoSelection,"colz"); TH2F *phPtEtaGenRecoTrk_regit= new TH2F("phPtEtaGenRecoTrk_regit",";#eta;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax); TH2F *phPtEtaGenTrk_regit = new TH2F("phPtEtaGenTrk_regit",";#eta;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax); ptTrkRegit->Draw("pt:eta>>phPtEtaGenTrk_regit",trkGenSelection,"colz"); ptTrkRegit->Draw("ptreco:etareco>>phPtEtaGenRecoTrk_regit",trkRecoSelection,"colz"); TH2D *pgPtEtaEff_pp = new TH2D("pgPtEtaEff_pp",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax); TH2D *pgPtEtaEff_std = new TH2D("pgPtEtaEff_std",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax); TH2D *pgPtEtaEff_regit = new TH2D("pgPtEtaEff_regit",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax); pgPtEtaEff_pp->Divide(phPtEtaGenRecoTrk_pp,phPtEtaGenTrk_pp,1,1,"b"); pgPtEtaEff_std->Divide(phPtEtaGenRecoTrk_std,phPtEtaGenTrk_std,1,1,"b"); pgPtEtaEff_regit->Divide(phPtEtaGenRecoTrk_regit,phPtEtaGenTrk_regit,1,1,"b"); // drawing pgPtTrkEff_pp->SetLineColor(3); pgPtTrkEff_pp->SetMarkerColor(3); pgPtTrkEff_pp->SetMarkerStyle(3); pgEtaTrkEff_pp->SetLineColor(3); pgEtaTrkEff_pp->SetMarkerColor(3); pgEtaTrkEff_pp->SetMarkerStyle(3); pgPtTrkEff_std->SetLineColor(4); pgPtTrkEff_std->SetMarkerColor(4); pgPtTrkEff_std->SetMarkerStyle(4); pgEtaTrkEff_std->SetLineColor(4); pgEtaTrkEff_std->SetMarkerColor(4); pgEtaTrkEff_std->SetMarkerStyle(4); pgPtTrkEff_regit->SetLineColor(2); pgPtTrkEff_regit->SetMarkerColor(2); pgPtTrkEff_regit->SetMarkerStyle(25); pgEtaTrkEff_regit->SetLineColor(2); pgEtaTrkEff_regit->SetMarkerColor(2); pgEtaTrkEff_regit->SetMarkerStyle(25); TCanvas *pcTrkEff = new TCanvas("pcTrkEff","pcTrkEff",1000,600); pcTrkEff->Divide(2,1); pcTrkEff->cd(1); //gPad->SetLogy(); phPtTmp2->Draw(); pgPtTrkEff_pp->Draw("pl same"); pgPtTrkEff_std->Draw("pl same"); pgPtTrkEff_regit->Draw("pl same"); pcTrkEff->cd(2); //gPad->SetLogy(); phEtaTmp->Draw(); pgEtaTrkEff_pp->Draw("pl same"); pgEtaTrkEff_std->Draw("pl same"); pgEtaTrkEff_regit->Draw("pl same"); TLegend *t2 = new TLegend(0.34,0.78,0.94,0.91); t2->SetBorderSize(0); t2->SetFillStyle(0); t2->AddEntry(pgPtTrkEff_pp,"Pp_reco","pl"); t2->AddEntry(pgPtTrkEff_std,"Std_reco","pl"); t2->AddEntry(pgPtTrkEff_regit,"Regit_reco","pl"); t2->Draw(); // 2d plots //2D histo if(bDo2D) { TLatex lx2; TCanvas *pcPtEtaTrkEff = new TCanvas("pcPtEtaTrkEff","pcPtEtaTrkEff",1300,500); pcPtEtaTrkEff->Divide(3,1); pcPtEtaTrkEff->cd(1); pcPtEtaTrkEff->GetPad(1)->SetLeftMargin(0.16); pcPtEtaTrkEff->GetPad(1)->SetRightMargin(0.15); phPtEtaTmp->Draw(); pgPtEtaEff_pp->GetZaxis()->SetRangeUser(0.0,1.0); pgPtEtaEff_pp->Draw("COLZ same"); lx2.DrawLatex(-0.2,2,"Pp_reco"); pcPtEtaTrkEff->cd(2); pcPtEtaTrkEff->GetPad(2)->SetLeftMargin(0.16); pcPtEtaTrkEff->GetPad(2)->SetRightMargin(0.15); phPtEtaTmp->Draw(); pgPtEtaEff_std->GetZaxis()->SetRangeUser(0.0,1.0); pgPtEtaEff_std->Draw("COLZ same"); lx2.DrawLatex(-0.2,2,"Std_reco"); pcPtEtaTrkEff->cd(3); pcPtEtaTrkEff->GetPad(3)->SetLeftMargin(0.16); pcPtEtaTrkEff->GetPad(3)->SetRightMargin(0.15); phPtEtaTmp->Draw(); pgPtEtaEff_regit->GetZaxis()->SetRangeUser(0.0,1.0); pgPtEtaEff_regit->Draw("colz same"); lx2.DrawLatex(-0.2,2,"Regit_reco"); if(bSavePlots) { TString outFileBase2(Form("%s/%s_%s",pOutFilePath,pcPtEtaTrkEff->GetTitle(),pOutFileName)); TString outFileGif2 = outFileBase2+".gif"; pcPtEtaTrkEff->Print(outFileGif2.Data(),"gifLandscape"); TString outFilePdf2 = outFileBase2+".pdf"; pcPtEtaTrkEff->SaveAs(outFilePdf2.Data()); } } if(bSavePlots) { TString outFileBase(Form("%s/%s_%s",pOutFilePath,pcTrkEff->GetTitle(),pOutFileName)); TString outFileGif = outFileBase+".gif"; pcTrkEff->Print(outFileGif.Data(),"gifLandscape"); TString outFilePdf2 = outFileBase+".pdf"; pcTrkEff->SaveAs(outFilePdf2.Data()); } } }
void makePrettyTurnOn(){ setTDRStyle(); TFile *inFile = TFile::Open("Hydjet502MC_CentralityCalibration.root"); TGraphAsymmErrors *asymm[NThresholds];//[2]; TLine *line[NThresholds]; for(int i = 1; i < NThresholds; i++) { asymm[i] = (TGraphAsymmErrors*)inFile->Get(Form("asymm_cen_%d_cen",(int)L1_THRESHOLD[i])); asymm[i]->SetMarkerColor(COLORS[i]); asymm[i]->SetLineColor(COLORS[i]); line[i]=new TLine(L1_THRESHOLD[i],0.,L1_THRESHOLD[i],1.); line[i]->SetLineWidth(2); line[i]->SetLineStyle(2); line[i]->SetLineColor(COLORS[i]); } const int nBins = 100; const double maxPt = 100; TH1D *hEmpty = new TH1D("hEmpty",";Offline centrality (%); Efficiency",nBins,0.,maxPt); TCanvas *c1 = new TCanvas("c1","c1",720,600); //c1->SetRightMargin(0.5); TPad *pad1 = new TPad("pad1","",0,0,1,1); TPad *pad2 = new TPad("pad2","",0,0,1,1); pad1->SetRightMargin(1.2/7.2); pad2->SetRightMargin(1.2/7.2); //pad2->SetFillStyle(4000); pad2->SetFillColorAlpha(kWhite,0); pad1->Draw(); pad1->cd(); hEmpty->SetMinimum(0); hEmpty->SetMaximum(1.15); hEmpty->Draw(); pad1->Update(); pad2->Draw(); pad2->cd(); TH1D *hEmpty2 = new TH1D("hEmpty2","",nBins,0.,2*maxPt); hEmpty2->SetMinimum(0); hEmpty2->SetMaximum(1.15); hEmpty2->GetXaxis()->SetLabelSize(0); hEmpty2->GetXaxis()->SetNdivisions(0, 0,0, false); hEmpty2->Draw("][sames"); TLatex *tex = new TLatex(5, 1.05 , "CMS Simulation Preliminary"); tex->SetTextFont(42); tex->SetTextSize(0.05); tex->Draw(); for(int i = 1; i < NThresholds; i++){ asymm[i]->Draw("p"); } TLegend *leg = new TLegend(0.848,0.330,0.995,0.75,"L1 Threshold"); //TLegend *leg = new TLegend(0.3689777,0.305074,0.6927732,0.7257928); //leg->SetTextAlign(13); leg->SetFillColor(0); leg->SetTextFont(42); leg->SetTextSize(0.03); //leg->AddEntry((TObject*)0, "L1 Centrality Threshold", ""); //leg->AddEntry((TObject*)0, "Threshold", ""); for(int i = 1; i < NThresholds; i++){ leg->AddEntry(asymm[i],Form("%d%%",(int)L1_THRESHOLD[i]/2),"lp"); line[i]->Draw(); } // TLine *endLine=new TLine(200,0.,200,1.); // endLine->SetLineWidth(1); // endLine->SetLineStyle(1); // endLine->SetLineColor(kBlack); // endLine->Draw(); leg->Draw(); //pad1->cd(); //hEmpty->Draw(); c1->SaveAs("Plots/TurnOnCurveCentrality.pdf"); c1->SaveAs("Plots/TurnOnCurveCentrality.gif"); }
//// runCode // 0=merged, 1=1stRun, 2=2ndRun void draw_1D_bfrac_pt_ETHF(char* dirName = "6rap3pt", int runCode=1, bool isScale = false,bool isLog = false) { gROOT->Macro("./JpsiStyle.C"); //TCanvas *ctmp0 = new TCanvas("ctmp0","RFB vs ET",900,600); //ctmp0->Divide(3,2); TCanvas *ctmp0 = new TCanvas("ctmp0","ET 0-20",900,600); ctmp0->Divide(3,2); TCanvas *ctmp1 = new TCanvas("ctmp1","ET 20-30",900,600); ctmp1->Divide(3,2); TCanvas *ctmp2 = new TCanvas("ctmp2","ET30-120",900,600); ctmp2->Divide(3,2); // set info. const Double_t br = 0.0593 ; const Double_t brErr = 0.0006; Double_t lumi_nb; Double_t lumi_nb_err; Double_t lumi_mub; Double_t lumi_mub_err; string runstring; string lumistring; string cmsstring = "CMS preliminary"; string beamstring = "pPb #sqrt{s_{NN}} = 5.02 TeV"; if (runCode ==0) { runstring = "All"; lumi_nb =34.622; lumi_nb_err=1.2; } else if (runCode == 1) { runstring = "Pbp"; lumi_nb =20.7; lumi_nb_err=0.7; }//1stRun else if (runCode == 2) { runstring = "pPb"; lumi_nb = 14.0; lumi_nb_err=0.5; }//2ndRun else { cout << " *** Error!!! choose runCode 0, 1, or 2 " << endl; return ; } lumistring = Form("L_{int} = %.1f nb^{ -1}", lumi_nb); lumi_mub = lumi_nb * 1000; // (nb)^{-1} -> {#mub}^{-1} lumi_mub_err = lumi_nb_err * 1000; // (nb)^{-1} -> {#mub}^{-1} //rap array in yCM (from forward to backward) //Double_t rapArrNumFB[] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4, -2.87};// for pt dist. //Double_t rapArrNumBF[] = {-2.87, -2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist. Double_t rapArrNumFB[] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93};// for pt dist. //Double_t rapArrNumBF[] = {-1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist. const Int_t nRap = sizeof(rapArrNumFB)/sizeof(Double_t)-1; cout << "nRap = " << nRap << endl; Double_t rapBinW[nRap]; for (Int_t iy=0; iy<nRap; iy++) { rapBinW[iy] = rapArrNumFB[iy]-rapArrNumFB[iy+1]; cout << iy <<"th rapBinW = " << rapBinW[iy] <<endl; } //pt array //Double_t ptArrNum[] = {0.0, 3.0, 4.0, 5.0, 6.5, 7.5, 8.5, 10., 14., 30.}; Double_t ptArrNum[] = {5.0, 6.5, 10., 30.}; //6rap3pt const Int_t nPt = sizeof(ptArrNum)/sizeof(Double_t)-1; cout << "nPt = " << nPt << endl; Double_t ptBinW[nPt]; for (Int_t ipt=0; ipt<nPt; ipt++) { ptBinW[ipt] = ptArrNum[ipt+1]-ptArrNum[ipt]; cout << ipt <<"th ptBinW = " << ptBinW[ipt] <<endl; } //ethf array Double_t etArrNum[] = {0.0, 20.0, 30.0, 120.0}; const Int_t nEtBins = sizeof(etArrNum)/sizeof(double)-1; cout << "nEtBins=" << nEtBins << endl; // array string string rapArr[nRap]; for (Int_t iy=0; iy<nRap; iy++) { formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]); cout << iy <<"th rapArr = " << rapArr[iy] << endl; } string ptArr[nPt]; for (Int_t ipt=0; ipt<nPt; ipt++) { formPtArr(ptArrNum[ipt], ptArrNum[ipt+1], &ptArr[ipt]); cout << ipt <<"th ptArr = " << ptArr[ipt] << endl; } string etArr[nEtBins]; for (Int_t i=0; i<nEtBins; i++){ formEtArr(etArrNum[i], etArrNum[i+1], &etArr[i]); cout << "etArr["<<i<<"] = "<< etArr[i].c_str() << endl; } // --- read-in file TFile * f2D = new TFile(Form("../total2Dhist_%s.root",dirName)); cout << "dirName = " << dirName << endl; cout << "runCode = " << runCode << ", runstring = " << runstring.c_str() << endl; // --- read-in 2D hist for corrected yield TH2D* h2D_corrY_Pbp[nEtBins]; TH2D* h2D_corrY_pPb[nEtBins]; for (int iet=0; iet<nEtBins; iet++){ h2D_corrY_Pbp[iet] = (TH2D*)f2D->Get(Form("otherFitInfo/h2D_fit_pt_y_bFrac_Pbp_%d",iet)); h2D_corrY_pPb[iet] = (TH2D*)f2D->Get(Form("otherFitInfo/h2D_fit_pt_y_bFrac_pPb_%d",iet)); cout << iet << "th h2D_corrY_Pbp = " << h2D_corrY_Pbp[iet] << endl; cout << iet << "th h2D_corrY_pPb = " << h2D_corrY_pPb[iet] << endl; } const int nbinsX = h2D_corrY_Pbp[0]->GetNbinsX(); const int nbinsY = h2D_corrY_Pbp[0]->GetNbinsY(); cout << "nbinsX = " << nbinsX << endl; cout << "nbinsY = " << nbinsY << endl; if (nbinsX != nRap) { cout << " *** Error!!! nbinsX != nRap"; return; }; if (nbinsY != nPt) { cout << " *** Error!!! nbinsY != nPt"; return; }; // --- projection to 1D hist TH1D* h1D_corrY_Pbp[nEtBins][nbinsX]; TH1D* h1D_corrY_pPb[nEtBins][nbinsX]; // iy=0 refers to forwards !!! (ordering here) for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_corrY_Pbp[iet][iy] = h2D_corrY_Pbp[iet]->ProjectionY(Form("h1D_corrY_Pbp_%d_%d",iet,iy),iy+1,iy+1); h1D_corrY_Pbp[iet][iy]->SetName(Form("h1D_corrY_Pbp_%d_%d",iet,iy)); //for 2nd run h1D_corrY_pPb[iet][iy] = h2D_corrY_pPb[iet]->ProjectionY(Form("h1D_corrY_pPb_%d_%d",iet,iy),nbinsX-iy,nbinsX-iy); h1D_corrY_pPb[iet][iy]->SetName(Form("h1D_corrY_pPb_%d_%d",iet,iy)); } } ////////////////////////////////////////////////////////////////////////////////////// // set values as zero for unused bins for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { if (iy>=1 && iy<=4) { h1D_corrY_Pbp[iet][iy]->SetBinContent(1,0); h1D_corrY_Pbp[iet][iy]->SetBinError(1,0); h1D_corrY_pPb[iet][iy]->SetBinContent(1,0); h1D_corrY_pPb[iet][iy]->SetBinError(1,0); } } } /* ////// after zero-bin setting, normalize! for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_corrY_Pbp[iet][iy]->Scale(1./h1D_corrY_Pbp[iet][iy]->Integral()); h1D_corrY_pPb[iet][iy]->Scale(1./h1D_corrY_pPb[iet][iy]->Integral()); h1D_corrY_Pbp[iet][iy]->Scale(1,"width"); h1D_corrY_pPb[iet][iy]->Scale(1,"width"); } } */ ////////////////////////////////////////////////////////////////// //// --- Draw histograms TLegend *legUR = new TLegend(0.45, 0.75, 0.86, 0.92); //upper left TLegend *legBL = new TLegend(0.18, 0.18, 0.59, 0.35); //upper left SetLegendStyle(legUR); SetLegendStyle(legBL); //latex box for beam, rapidity, pT info TLatex* latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextSize(0.04); for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { if (iet==0) { ctmp0->cd(iy+1);} else if (iet==1) { ctmp1->cd(iy+1); } else if (iet==2) { ctmp2->cd(iy+1); } SetHistStyle(h1D_corrY_Pbp[iet][iy],1,0); SetHistStyle(h1D_corrY_pPb[iet][iy],2,0); h1D_corrY_Pbp[iet][iy]->GetYaxis()->SetRangeUser(0,0.6); h1D_corrY_Pbp[iet][iy]->Draw("pe"); h1D_corrY_pPb[iet][iy]->Draw("pe same"); //h1D_corrY_pPb[iet][iy]->Draw("pe"); } } /* ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// // 1) merge Pbp+pPb corrected yield TH1D* h1D_corrY_tot[nEtBins][nbinsX]; for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { if (runCode ==0) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_Pbp[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); h1D_corrY_tot[iet][iy]->Add(h1D_corrY_pPb[iet][iy]); } else if (runCode ==1) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_Pbp[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); } else if (runCode ==2) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_pPb[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); } // if (iet==0) { ctmp0->cd(iy+1); h1D_corrY_tot[iet][iy]->Draw("pe"); } // if (iet==1) { ctmp1->cd(iy+1); h1D_corrY_tot[iet][iy]->Draw("pe"); } // if (iet==2) { ctmp2->cd(iy+1); h1D_corrY_tot[iet][iy]->Draw("pe"); } } } ////////////////////////////////////////////////////////////////// /////////// calculate RFB const int nRapRFB = 3; TH1D* h1D_RFB_tot_tmp[nEtBins][nbinsX]; // corrYield with merged pT TH1D* h1D_RFB_tot[nEtBins][nRapRFB]; // actual RFB vs pt // bin settingg string rapAbsArr[nRap]; for (Int_t iy=0; iy<nRapRFB; iy++) { formAbsRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapAbsArr[iy]); cout << iy <<"th rapAbsArr = " << rapAbsArr[iy] << endl; } Double_t ptArrRFBNum[] = {5.0, 6.5, 30.}; const Int_t nPtRFB = sizeof(ptArrRFBNum)/sizeof(Double_t)-1; cout << "nPtRFB = " << nPtRFB << endl; // merging pT bins (KYO - byHand) double tmpPRval01, tmpPRerr01, tmpPRval02, tmpPRerr02; double actPRval01, actPRerr01, actPRval02, actPRerr02; for (int iet=0; iet<nEtBins; iet++){ for (int iy=0; iy<nRapRFB*2; iy++){ h1D_RFB_tot_tmp[iet][iy]= new TH1D(Form("h1D_RFB_tot_tmp_%d_%d",iet,iy),Form("h1D_RFB_tot_tmp_%d_%d",iet,iy),nPtRFB,ptArrRFBNum); h1D_RFB_tot_tmp[iet][iy]->Sumw2(); actPRval01=0; actPRval02=0; actPRerr01=0; actPRerr02=0; // 1) pT 5-6.5 GeV tmpPRval01=0; tmpPRval02=0; tmpPRerr01=0; tmpPRerr02=0; if (iy==0 || iy==nRapRFB*2-1){ actPRval01=h1D_corrY_tot[iet][iy]->GetBinContent(1); actPRerr01=h1D_corrY_tot[iet][iy]->GetBinError(1); h1D_RFB_tot_tmp[iet][iy]->SetBinContent(1,actPRval01); h1D_RFB_tot_tmp[iet][iy]->SetBinError(1,actPRerr01); } else { h1D_RFB_tot_tmp[iet][iy]->SetBinContent(1,0.); h1D_RFB_tot_tmp[iet][iy]->SetBinError(1,0.); } // 2) pT 6.5-30. GeV tmpPRval01=0; tmpPRval02=0; tmpPRerr01=0; tmpPRerr02=0; tmpPRval01=h1D_corrY_tot[iet][iy]->GetBinContent(2); tmpPRerr01=h1D_corrY_tot[iet][iy]->GetBinError(2); tmpPRval02=h1D_corrY_tot[iet][iy]->GetBinContent(3); tmpPRerr02=h1D_corrY_tot[iet][iy]->GetBinError(3); actPRval02=tmpPRval01+tmpPRval02; actPRerr02=TMath::Sqrt( TMath::Power(tmpPRerr01,2) + TMath::Power(tmpPRerr02,2) ); h1D_RFB_tot_tmp[iet][iy]->SetBinContent(2,actPRval02); h1D_RFB_tot_tmp[iet][iy]->SetBinError(2,actPRerr02); //cout << iet<<"th,"<<iy<<"th h1D_RFB_tot_tmp = "<<h1D_RFB_tot_tmp[iet][iy]<<endl; // if (iet==0) { ctmp0->cd(iy+1); h1D_RFB_tot_tmp[iet][iy]->Draw("pe"); } // if (iet==1) { ctmp1->cd(iy+1); h1D_RFB_tot_tmp[iet][iy]->Draw("pe"); } // if (iet==2) { ctmp2->cd(iy+1); h1D_RFB_tot_tmp[iet][iy]->Draw("pe"); } } } // actual RFB calculation vs pT!! for (int iet=0; iet<nEtBins; iet++){ for (int iy=0; iy<nRapRFB; iy++){ h1D_RFB_tot[iet][iy] = (TH1D*)h1D_RFB_tot_tmp[iet][iy]->Clone(Form("h1D_RFB_tot_%d_%d",iet,iy)); h1D_RFB_tot[iet][iy]->Divide(h1D_RFB_tot_tmp[iet][2*nRapRFB-iy-1]); cout << iet<<"th, "<<iy<<"th h1D_RFB_tot = "<<h1D_RFB_tot[iet][iy]<<endl; //if (iet==0) { ctmp0->cd(iy+1); h1D_RFB_tot[iet][iy]->Draw("pe"); } //if (iet==1) { ctmp1->cd(iy+1); h1D_RFB_tot[iet][iy]->Draw("pe"); } //if (iet==2) { ctmp2->cd(iy+1); h1D_RFB_tot[iet][iy]->Draw("pe"); } } } /////////////////////////////////////////////// //////// --- RFB vs ETHF : 4 histograms //in=0 : pT 5-6.5, rap 1.5-1.93 //in=1 : pT 6.5-30, rap 1.5-1.93 //in=2 : pT 6.5-30, rap 0.9-1.5 //in=3 : pT 6.5-30, rap 0.0-0.9 const int nHist=4; double tmpRFBval01, tmpRFBerr01, tmpRFBval02, tmpRFBerr02, tmpRFBval03, tmpRFBerr03; TH1D* h1D_RFB_ETHF_tot[nHist]; for (int in=0; in< nHist; in++){ h1D_RFB_ETHF_tot[in]= new TH1D(Form("h1D_RFB_ETHF_tot_%d",in),Form("h1D_RFB_ETHF_tot_%d",in),nEtBins,etArrNum); h1D_RFB_ETHF_tot[in]->Sumw2(); tmpRFBval01=0;tmpRFBerr01=0;tmpRFBval02=0;tmpRFBerr02=0;tmpRFBval03=0;tmpRFBerr03=0; for (int iet=0; iet<nEtBins;iet++){ if (in==0) { tmpRFBval01=h1D_RFB_tot[iet][0]->GetBinContent(1); tmpRFBerr01=h1D_RFB_tot[iet][0]->GetBinError(1); h1D_RFB_ETHF_tot[in]->SetBinContent(iet+1,tmpRFBval01); h1D_RFB_ETHF_tot[in]->SetBinError(iet+1,tmpRFBerr01); } else { tmpRFBval01=h1D_RFB_tot[iet][in-1]->GetBinContent(2); tmpRFBerr01=h1D_RFB_tot[iet][in-1]->GetBinError(2); h1D_RFB_ETHF_tot[in]->SetBinContent(iet+1,tmpRFBval01); h1D_RFB_ETHF_tot[in]->SetBinError(iet+1,tmpRFBerr01); } } h1D_RFB_ETHF_tot[in]->SetMinimum(0.0); h1D_RFB_ETHF_tot[in]->SetMaximum(1.4); ctmp0->cd(in+1); h1D_RFB_ETHF_tot[in]->Draw("pe"); dashedLine(0.,1.,120.,1.,1,1); } */ // convert to TGraphAsymErrors /* // root file //TFile *fOut = new TFile(Form("1Dhist_%s/tmp_crossSection_pt.root",dirName),"RECREATE"); TFile *fOut = new TFile(Form("1Dhist_%s/crossSection_pt_%s.root",dirName,runstring.c_str()),"RECREATE"); fOut->cd(); for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_corrY_NP_Pbp[iy]->Write(); h1D_corrY_NP_pPb[iy]->Write(); h1D_corrY_NP_tot[iy]->Write(); } //tRap->Write(); fOut->Close(); */ return; } // end of main func.