void CMS_lumi( TPad* pad, int iPeriod, int iPosX, TString label ) { bool outOfFrame = false; if( iPosX/10==0 ) { outOfFrame = true; } int alignY_=3; int alignX_=2; if( iPosX/10==0 ) alignX_=1; if( iPosX==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; if( iPosX == 0 ) relPosX = 0.12; 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, lumiText2; if( iPeriod==1 ) { lumiText += lumi_7TeV; lumiText += " (7 TeV)"; } else if ( iPeriod==2 ) { lumiText += lumi_8TeV; 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"; } else if ( iPeriod==99 ) { lumiText += lumi_5TeV; // lumiText += " (#sqrt{s_{NN}} = 5.02 TeV)"; lumiText2 += " #sqrt{s_{NN}} = 5.02 TeV"; } else if (iPeriod==101) { lumiText += lumi_PbPb2011; lumiText2 += " #sqrt{s_{NN}} = 2.76 TeV"; // lumiText += " (2.76 TeV)"; } else if (iPeriod==102) { lumiText += lumi_pp2013; lumiText2 += " #sqrt{s} = 2.76 TeV"; // lumiText += " (2.76 TeV)"; } else if (iPeriod==103) { lumiText += lumi_PbPb2011; lumiText += ", "; lumiText += lumi_pp2013; lumiText2 += " #sqrt{s_{NN}} = 2.76 TeV"; // lumiText += " (2.76 TeV)"; } else if (iPeriod==104) { lumiText += label; lumiText2 += " #sqrt{s_{NN}} = 5.02 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,lumiText2); // latex.DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); latex.SetTextAlign(11); latex.DrawLatex(l,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_=0; 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 (pad->GetTickx()) posX_ -= cmsTextOffset; cout << pad->GetTickx() << endl; if (pad->GetTicky()) posY_ -= cmsTextOffset; 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 canvas1DhEff_ppInc() { //=========Macro generated from canvas: canvas1D/ //========= (Mon Dec 5 21:22:37 2016) by ROOT version6.02/10 TCanvas *canvas1D = new TCanvas("canvas1D", "",0,0,600,600); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); canvas1D->SetHighLightColor(2); canvas1D->Range(-4.625,-0.07500001,61.625,0.675); canvas1D->SetFillColor(0); canvas1D->SetBorderMode(0); canvas1D->SetBorderSize(2); canvas1D->SetFrameBorderMode(0); canvas1D->SetFrameBorderMode(0); TH2F *hemptyEff1 = new TH2F("hemptyEff1","",50,2,55,10,0,0.6); hemptyEff1->SetMinimum(0); hemptyEff1->SetMaximum(0.6); hemptyEff1->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); hemptyEff1->SetLineColor(ci); hemptyEff1->SetMarkerStyle(20); hemptyEff1->GetXaxis()->SetTitle("p_{T} GeV^{-1}c)"); hemptyEff1->GetXaxis()->CenterTitle(true); hemptyEff1->GetXaxis()->SetLabelFont(42); hemptyEff1->GetXaxis()->SetLabelSize(0.035); hemptyEff1->GetXaxis()->SetTitleSize(0.05); hemptyEff1->GetXaxis()->SetTitleOffset(0.9); hemptyEff1->GetXaxis()->SetTitleFont(42); hemptyEff1->GetYaxis()->SetTitle("#alpha x #epsilon"); hemptyEff1->GetYaxis()->CenterTitle(true); hemptyEff1->GetYaxis()->SetLabelFont(42); hemptyEff1->GetYaxis()->SetLabelSize(0.035); hemptyEff1->GetYaxis()->SetTitleSize(0.05); hemptyEff1->GetYaxis()->SetTitleOffset(0.95); hemptyEff1->GetYaxis()->SetTitleFont(42); hemptyEff1->GetZaxis()->SetLabelFont(42); hemptyEff1->GetZaxis()->SetLabelSize(0.035); hemptyEff1->GetZaxis()->SetTitleSize(0.035); hemptyEff1->GetZaxis()->SetTitleFont(42); hemptyEff1->Draw(""); Double_t xAxis1[2] = {7, 50}; TH1D *hEff2 = new TH1D("hEff2","",1, xAxis1); hEff2->SetBinContent(1,0.05799468); hEff2->SetBinError(1,0.0003918457); hEff2->SetEntries(21905.14); hEff2->SetStats(0); hEff2->SetLineColor(2); hEff2->SetMarkerColor(2); hEff2->SetMarkerStyle(20); hEff2->GetXaxis()->CenterTitle(true); hEff2->GetXaxis()->SetLabelFont(42); hEff2->GetXaxis()->SetLabelSize(0.035); hEff2->GetXaxis()->SetTitleSize(0.035); hEff2->GetXaxis()->SetTitleFont(42); hEff2->GetYaxis()->CenterTitle(true); hEff2->GetYaxis()->SetLabelFont(42); hEff2->GetYaxis()->SetLabelSize(0.035); hEff2->GetYaxis()->SetTitleSize(0.035); hEff2->GetYaxis()->SetTitleFont(42); hEff2->GetZaxis()->SetLabelFont(42); hEff2->GetZaxis()->SetLabelSize(0.035); hEff2->GetZaxis()->SetTitleSize(0.035); hEff2->GetZaxis()->SetTitleFont(42); hEff2->Draw("same"); TLatex * tex = new TLatex(0.5,0.75,"|y| < 2.4"); tex->SetNDC(); tex->SetTextFont(42); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.08,0.95,"CMS Preliminary"); tex->SetNDC(); tex->SetTextAlign(13); tex->SetTextSize(0.038); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.9,0.92,"25.8 pb^{-1} (5.02 TeV pp)"); tex->SetNDC(); tex->SetTextAlign(31); tex->SetTextFont(42); tex->SetTextSize(0.038); tex->SetLineWidth(2); tex->Draw(); canvas1D->Modified(); canvas1D->cd(); canvas1D->SetSelected(canvas1D); }
void fsr(int ins = -1, double pt = 200., std::string sample = "dijet") { setTDRStyle(); TDirectory *curdir = gDirectory; const char *cs = sample.c_str(); map<string, const char *> title; title["dijet"] = "Dijet"; title["gamjet"] = "#gamma+jet"; TFile *fp8 = new TFile("alphafracs_p8.root","READ"); assert(fp8 && !fp8->IsZombie()); TFile *fp6 = new TFile("alphafracs_p6.root","READ"); assert(fp6 && !fp6->IsZombie()); TFile *fhw = new TFile("alphafracs_hwpp.root","READ"); assert(fhw && !fhw->IsZombie()); curdir->cd(); TProfile *p8_10 = (TProfile*)fp8->Get("prof10"); assert(p8_10); TProfile *p8_15 = (TProfile*)fp8->Get("prof15"); assert(p8_15); TProfile *p8_20 = (TProfile*)fp8->Get("prof20"); assert(p8_20); TProfile *p8_30 = (TProfile*)fp8->Get("prof30"); assert(p8_30); TH1D *h8_0 = p8_10->ProjectionX("h8_10"); TProfile *p6_10 = (TProfile*)fp6->Get("prof10"); assert(p6_10); TProfile *p6_15 = (TProfile*)fp6->Get("prof15"); assert(p6_15); TProfile *p6_20 = (TProfile*)fp6->Get("prof20"); assert(p6_20); TProfile *p6_30 = (TProfile*)fp6->Get("prof30"); assert(p6_30); TH1D *h6_0 = p6_10->ProjectionX("h6_10"); TProfile *hw_10 = (TProfile*)fhw->Get("prof10"); assert(hw_10); TProfile *hw_15 = (TProfile*)fhw->Get("prof15"); assert(hw_15); TProfile *hw_20 = (TProfile*)fhw->Get("prof20"); assert(hw_20); TProfile *hw_30 = (TProfile*)fhw->Get("prof30"); assert(hw_30); TH1D *hw_0 = hw_10->ProjectionX("hw_10"); TH1D *dt_0 = (TH1D*)hw_0->Clone("dt_0"); TH1D *dt_10 = hw_10->ProjectionX("dt_10"); TH1D *dt_15 = hw_15->ProjectionX("dt_15"); TH1D *dt_20 = hw_20->ProjectionX("dt_20"); TH1D *dt_30 = hw_30->ProjectionX("dt_30"); const int ns = 3;//4; const int np = 5; TH1D* ps[ns][np] = {{h8_0, p8_10, p8_15, p8_20, p8_30}, {h6_0, p6_10, p6_15, p6_20, p6_30}, {hw_0, hw_10, hw_15, hw_20, hw_30}};//, //{dt_0, dt_10, dt_15, dt_20, dt_30}}; double alpha[np] = {0, 0.10, 0.15, 0.20, 0.30}; int markers[ns][2] = {{kFullSquare, kFullCircle}, {kOpenSquare, kOpenCircle}, {kOpenDiamond, kOpenStar}};//, //{kDot, kDot}}; int colors[np] = {kBlack, kRed, kOrange+2, kGreen+2, kBlue}; assert(ins>=-1 && ins<ns); // Approximate data as 1:1 mixture of P6 and Herwig++ /* double whw = 0.5; for (int j = 0; j != np; ++j) { for (int k = 1; k != hw_0->GetNbinsX()+1; ++k) { ps[ns-1][j]->SetBinContent(k, (1-whw)*ps[1][j]->GetBinContent(k) + whw*ps[2][j]->GetBinContent(k)); ps[ns-1][j]->SetBinError(k, (1-whw)*ps[1][j]->GetBinError(k) + whw*ps[2][j]->GetBinError(k)); } } */ TGraphErrors *gas[ns]; TGraphErrors *ga = new TGraphErrors(4); TF1 *f1 = new TF1("f1","[0]+[1]*x",0,0.35); for (int i = 0; i != ns; ++i) { for (int k = 1; k != p8_10->GetNbinsX()+1; ++k) { for (int j = 1; j != np; ++j) { ga->SetPoint(j, alpha[j], ps[i][j]->GetBinContent(k)); ga->SetPointError(j, 0., ps[i][j]->GetBinError(k)); } ga->Fit(f1, "QRN"); ps[i][0]->SetBinContent(k, f1->GetParameter(0)); ps[i][0]->SetBinError(k, f1->GetParError(0)); if (p8_10->FindBin(pt)==k) { gas[i] = (TGraphErrors*)ga->Clone(Form("ga_%d",i)); } } } TH1D *h = new TH1D("h",";p_{T,parton} (GeV);" "#LTp_{T,gen} / p_{T,parton}#GT", 100, 0, 900); h->SetMaximum(1.06);//1.03); h->SetMinimum(0.91);//0.96); TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(0.045); extraText = "Simulation"; //extraText2 = "Preliminary"; if (ins==0) lumi_13TeV = "Pythia8"; if (ins==1) lumi_13TeV = "Pythia6"; if (ins==2) lumi_13TeV = "Herwig++"; if (ins==-1) lumi_13TeV = "Herwig++ / Pythia8 / Pythia6"; TCanvas *c1 = tdrCanvas("c1",h,2,0,kSquare); tex->DrawLatex(0.18,0.87,title[cs]); tex->DrawLatex(0.18,0.80,"Anti-k_{T} R=0.5"); tex->DrawLatex(0.18,0.75,"|#eta| < 1.3"); tex->DrawLatex(0.0,0.01,"#copyright Hannu Siikonen"); for (int i = 0; i != ns; ++i) { for (int j = 0; j != np; ++j) { if ((ins == -1 && (j==0 || j==np-1)) || i == ins) tdrDraw(ps[i][j], "P", markers[i][j==0 ? 0 : 1], colors[j]); } } //tdrDraw(h8_0,"P",kFullSquare,kBlack); //tdrDraw(p8_10,"P",kFullCircle,kRed); //tdrDraw(p8_15,"P",kFullCircle,kOrange+2); //tdrDraw(p8_20,"P",kFullCircle,kGreen+1); //tdrDraw(p8_30,"P",kFullCircle,kBlue); TF1 *f2 = new TF1("f2","[0] + [1]*pow(x,[2])",100,840); f2->SetParameters(1,-0.1,-0.5); for (int i = 0; i != ns; ++i) { for (int j = 0; j != np; ++j) { ps[i][j]->Fit(f2,"QRN"); f2->SetLineColor(ps[i][j]->GetMarkerColor()); if ((ins == -1 && (j==0 || j==np-1)) || i == ins) f2->DrawClone("SAME"); } } if (ins!=-1) { TLegend *leg = tdrLeg(0.70,0.65,0.90,0.90); leg->AddEntry(ps[ins][0],"#alpha_{max}#rightarrow0","PL"); leg->AddEntry(ps[ins][1],"#alpha<0.10","PL"); leg->AddEntry(ps[ins][2],"#alpha<0.15","PL"); leg->AddEntry(ps[ins][3],"#alpha<0.20","PL"); leg->AddEntry(ps[ins][4],"#alpha<0.30","PL"); } if (ins==-1) { TLegend *ll = tdrLeg(0.50,0.70,0.70,0.90); ll->SetHeader("#alpha#rightarrow0"); ll->AddEntry(ps[0][0],"","PL"); ll->AddEntry(ps[1][0],"","PL"); ll->AddEntry(ps[2][0],"","PL"); //ll->AddEntry(ps[3][0],"","PL"); TLegend *lr = tdrLeg(0.60,0.70,0.80,0.90); lr->SetHeader("#alpha<0.30"); lr->AddEntry(ps[0][np-1]," Pythia 8","PL"); lr->AddEntry(ps[1][np-1]," Pythia 6","PL"); lr->AddEntry(ps[2][np-1]," Herwig++","PL"); //lr->AddEntry(ps[3][np-1]," \"DATA\"","PL"); } c1->SaveAs(Form("pdf/fsr_ins%d_%s.pdf",ins,cs)); TH1D *h2 = new TH1D("h2",";#alpha_{max};#LTp_{T,gen} / p_{T,parton}#GT", 10,0,0.4); h2->SetMinimum(0.91); h2->SetMaximum(1.05); lumi_13TeV = "Herwig++ / Pythia8 / Pythia6"; TCanvas *c2 = tdrCanvas("c2",h2,2,0,kSquare); tex->DrawLatex(0.18,0.87,title[cs]); tex->DrawLatex(0.18,0.80,"Anti-k_{T} R=0.5"); tex->DrawLatex(0.18,0.75,"|#eta| < 1.3"); tex->DrawLatex(0.0,0.01,"#copyright Hannu Siikonen"); TF1 *f3 = new TF1("f3","[0]+[1]*x+[2]*x*x",0,0.35); f3->SetLineStyle(kDashed); for (int i = 0; i != ns; ++i) { tdrDraw(gas[i], "P", markers[i][1], colors[i]); gas[i]->Fit(f1,"QRN"); f1->SetLineColor(gas[i]->GetLineColor()); f1->DrawClone("SAME"); gas[i]->Fit(f3,"QRN"); f3->SetLineColor(gas[i]->GetLineColor()); f3->DrawClone("SAME"); } int ipt = dt_0->FindBin(pt); double ptmin = dt_0->GetBinLowEdge(ipt); double ptmax = dt_0->GetBinLowEdge(ipt+1); tex->DrawLatex(0.18, 0.18, Form("%1.0f<p_{T}<%1.0f GeV", ptmin, ptmax)); TLegend *leg = tdrLeg(0.70,0.70,0.90,0.90); leg->AddEntry(gas[0], "Pythia 8", "PL"); leg->AddEntry(gas[1], "Pythia 6", "PL"); leg->AddEntry(gas[2], "Herwig++", "PL"); //leg->AddEntry(gas[3], "\"DATA\"", "PL"); c2->SaveAs(Form("pdf/fsr_vsalpha_%s.pdf",cs)); }
void CMS_lumi( TPad* pad, int iPeriod, int iPosX ) { //https://ghm.web.cern.ch/ghm/plots/ 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 += lumi_8TeV; 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_+0.05, 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; }
// ----------------------------------------------------------------------------- // int qcdBkgdEst_new() { // int nn = 100; // std::vector<float> xx; // std::vector<float> yy; // for ( uint i = 0; i < nn; ++i ) { xx.push_back( i*100. ); } // for ( uint ilumi = 0; ilumi < nn; ++ilumi ) { bool plots = true; // 0 = false (force to gaussian), 1 = true, 2 = for prescales int use_sumw2 = 2; std::string label = ""; //int last_bin = 7; setTDRStyle(); // Misc bool efficiency = false; enum choices { PLOT_NUMERATOR=1, PLOT_DENOMINATOR=2, PLOT_RATIO=5 }; int choice = 5; bool min_max_with_errors = true; bool use_meff = false; double axis_offset = 2.; bool simulation = false; // Some analysis defaults double offset = 0.; //double pt1_default = 100.; //double pt2_default = 100.; //double pt3_default = 50.; //double ht_default = 375. + offset; //double meff_default = ht_default + pt3_default; //double x1_default = pt1_default / meff_default; //double x2_default = pt2_default / meff_default; //double x3_default = pt3_default / meff_default ; //double x3_factor = ( 1. - x3_default ) / ( x3_default ); std::string dir = "/vols/cms04/bainbrid/qcd/stable/SUSY2/results/"; //std::string histo = "HtAfterAlphaT"; //std::string histo = "HtAfterRecHit"; std::string histo = "HtAfterBaby"; std::vector<double> at; at.push_back(0.51); at.push_back(0.52); at.push_back(0.53); at.push_back(0.54); at.push_back(0.55); //at.push_back(0.60); const uint nat = at.size(); std::vector<int> multi; multi.push_back(-2); const uint nmulti = multi.size(); double ht_min = 0.; double ht_max = 0.; int nht = 20; //@@ number of bins std::vector<double> ht; std::vector<double> ht_step; // override histo binning if ( true ) { ht.push_back(275.); ht.push_back(325.); for ( uint iht = 0; iht <= 6; ++iht ) { ht.push_back(375.+iht*100.); } //for ( uint iht = 0; iht <= 8; ++iht ) { ht.push_back(300.+iht*100.); } nht = ht.size() - 1; ht_min = ht.front() + offset; ht_max = ht.back() + offset; } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- StringVV files; bool test = true; if ( test ) { //std::string trunk = dir + "v02/Ratio__"; //StringV q; q.push_back(trunk+"data.root"); files.push_back(q); //StringV q1; q1.push_back(dir + "v19/Ratio__data.root"); files.push_back(q1); StringV q3; q3.push_back(dir + "v21/Ratio__data.root"); files.push_back(q3); StringV q1; q1.push_back(dir + "v26/Ratio__data_1fb.root"); files.push_back(q1); StringV q2; q2.push_back(dir + "v22/Ratio__data.root"); files.push_back(q2); //StringV q; q.push_back("../python/Ratio_QCDPY.root"); //StringV w(q); w.push_back(trunk+"wjets.root"); //StringV z(q); z.push_back(trunk+"zinv.root"); //StringV tt(q); tt.push_back(trunk+"ttbar.root"); } bool results = false; if ( results ) { std::string trunk = dir + "v08/Ratio__"; StringV q; q.push_back(trunk+"qcdmg.root"); StringV sm(q); sm.push_back(trunk+"wjets.root"); sm.push_back(trunk+"zinv.root"); sm.push_back(trunk+"ttbar.root"); files.push_back(sm); StringV sm1(q); sm1.push_back(trunk+"wjets_incl.root"); sm1.push_back(trunk+"zinv.root"); sm1.push_back(trunk+"ttbar.root"); files.push_back(sm1); //StringV lm6(sm); lm6.push_back(trunk+"lm6.root"); files.push_back(lm6); StringV wi(q); wi.push_back(trunk+"wjets_incl.root"); files.push_back(wi); StringV w(q); w.push_back(trunk+"wjets.root"); files.push_back(w); StringV z(q); z.push_back(trunk+"zinv.root"); files.push_back(z); StringV tt(q); tt.push_back(trunk+"ttbar.root"); files.push_back(tt); //StringV t(q); t.push_back(trunk+"top.root"); files.push_back(t); files.push_back(StringV(1,dir+"v08/Ratio__data.root")); // std::string trunk = dir + "v36/Ratio__"; // StringV sm1; // sm1.push_back(trunk+"qcdpy.root"); // //sm1.push_back(trunk+"wjets.root"); // sm1.push_back(trunk+"zinv.root"); // sm1.push_back(trunk+"ttbar.root"); // sm1.push_back(trunk+"top.root"); // trunk = dir + "v37/Ratio__"; // StringV sm2; // sm2.push_back(trunk+"qcdpy.root"); // sm2.push_back(trunk+"wjets.root"); // sm2.push_back(trunk+"zinv.root"); // sm2.push_back(trunk+"ttbar.root"); // trunk = dir + "v40/Ratio__"; // StringV sm3; // sm3.push_back(trunk+"qcdpy.root"); // sm3.push_back(trunk+"wjets.root"); // sm3.push_back(trunk+"zinv.root"); // sm3.push_back(trunk+"ttbar.root"); // files.push_back(sm1); // files.push_back(sm2); // files.push_back(sm3); } const uint nfile = files.size(); std::vector<std::string> his; if ( his.size() < nfile ) { his.resize(nfile,histo); } std::vector<std::string> type; if ( test ) { // type.push_back("1"); // type.push_back("2"); //type.push_back("Data"); type.push_back("HT-aT cross triggers"); type.push_back("HT-MHT cross triggers"); type.push_back("HT prescaled triggers"); //type.push_back("QcdMg"); //type.push_back("Nominal"); //type.push_back("Alternative"); } if ( results ) { //type.push_back("SM + LM6 (Spring11)"); //type.push_back("Spring11"); //type.push_back("Summer11(Wincl)"); //type.push_back("Summer11(W300)"); type.push_back("SM (W+jets HT-binned)"); type.push_back("SM (W+jets inclusive)"); // type.push_back("SM "); type.push_back("Wjets (incl)"); type.push_back("Wjets (HT-binned)"); type.push_back("Zinv "); type.push_back("TTbar"); //type.push_back("Single top "); type.push_back("Data "); } if ( type.size() < nfile ) { type.resize(nfile,"unknown"); } double lumi = 4650.; std::vector<double> lumis; if ( test ) { lumi = 4650; lumis.push_back(100.); //lumis.push_back(100.*lumi/1140.); lumis.push_back(100.); //lumis.push_back(lumi); } if ( results ) { double tmp = 4650.;//xx[ilumi]; lumi = tmp; lumis.push_back(tmp); lumis.push_back(tmp); lumis.push_back(tmp); lumis.push_back(tmp); lumis.push_back(tmp); lumis.push_back(tmp); lumis.push_back(100.); } if ( lumis.size() < nfile ) { lumis.resize(nfile,100.); } // Which file is the data file int data_file = -1; for ( uint itype = 0; itype < nfile; ++itype ) { if ( type[itype] == "data" || type[itype] == "Data" ) { data_file = itype; break; } } // if ( data_file == -1 ) { // data_file = 0; // std::cout << "Problem identifying data file!" << std::endl; // } std::vector<int> style; if ( test ) { style.push_back(20); style.push_back(24); style.push_back(25); } if ( results ) { style.push_back(24); style.push_back(25); style.push_back(26); style.push_back(28); style.push_back(27); style.push_back(30); style.push_back(20); } if ( style.size() < nfile ) { style.resize(nfile,25); } std::vector<double> size; if ( size.size() < nfile ) { size.resize(nfile,1.5); } std::vector<int> col; if ( test ) { col.push_back(1); col.push_back(2); col.push_back(4); } if ( results ) { col.push_back(2); col.push_back(4); col.push_back(6); col.push_back(6); col.push_back(6); col.push_back(6); col.push_back(1); } if ( col.size() < nfile ) { col.resize(nfile,1); } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- DoubleVVVV numer; resize( numer, nfile, nmulti, nat, nht ); DoubleVVVV numer_errh; resize( numer_errh, nfile, nmulti, nat, nht ); DoubleVVVV numer_errl; resize( numer_errl, nfile, nmulti, nat, nht ); DoubleVVVV denom; resize( denom, nfile, nmulti, nat, nht ); DoubleVVVV denom_errh; resize( denom_errh, nfile, nmulti, nat, nht ); DoubleVVVV denom_errl; resize( denom_errl, nfile, nmulti, nat, nht ); DoubleVVVV ratio; resize( ratio, nfile, nmulti, nat, nht ); DoubleVVVV errh; resize( errh, nfile, nmulti, nat, nht ); DoubleVVVV errl; resize( errl, nfile, nmulti, nat, nht ); IntVVV length; resize( length, nfile, nmulti, nat ); // Min/max values for ratios DoubleVV min; min.resize( nmulti, DoubleV( nat, 0. ) ); DoubleVV max; max.resize( nmulti, DoubleV( nat, 0. ) ); std::cout << " nfile: " << nfile << " nmulti: " << nmulti << " nat: " << nat << " nht: " << nht << " total: " << nfile*nmulti*nat*nht << std::endl; // Init arrays for ( uint imulti = 0; imulti < nmulti; ++imulti ) { for ( uint iat = 0; iat < nat; ++iat ) { for ( uint ifile = 0; ifile < nfile; ++ifile ) { for ( int iht = 0; iht < nht; ++iht ) { numer[ifile][imulti][iat][iht] = 0.; numer_errh[ifile][imulti][iat][iht] = 0.; numer_errl[ifile][imulti][iat][iht] = 0.; denom[ifile][imulti][iat][iht] = 0.; denom_errh[ifile][imulti][iat][iht] = 0.; denom_errl[ifile][imulti][iat][iht] = 0.; ratio[ifile][imulti][iat][iht] = 0.; errh[ifile][imulti][iat][iht] = 0.; errl[ifile][imulti][iat][iht] = 0.; } length[ifile][imulti][iat] = 0; } min[imulti][iat] = 0.; max[imulti][iat] = 0.; } } std::cout << " CALCULATING RATIOS..." << std::endl; calcRatio( nfile, nmulti, nat, nht, his, files, lumis, multi, at, ht, ht_min, ht_max, numer, numer_errh, numer_errl, denom, denom_errh, denom_errl, ratio, errh, errl, length, label, efficiency, use_sumw2, data_file ); ht_step.clear(); for ( int iht = 0; iht < nht; ++iht ) { ht_step.push_back( ht[iht+1] - ht[iht] ); } // std::cout << " size " << ht.size() // << " nbins " << nht // << " htmin " << ht_min // << " htmax " << ht_max // << std::endl; // for ( int iht = 0; iht <= nht; ++iht ) { // std::cout << " ibin " << iht // << " ht " << ht[iht] // << " htstep " << (iht<nht?ht_step[iht]:0.) // << std::endl; // } // // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // Print numbers bool print = true; if (print) { for ( uint ifile = 0; ifile < nfile; ++ifile ) { for ( uint imulti = 0; imulti < nmulti; ++imulti ) { for ( uint iat = 0; iat < nat; ++iat ) { for ( int iht = 0; iht < nht; ++iht ) { double n = numer[ifile][imulti][iat][iht]; double neh = numer_errh[ifile][imulti][iat][iht]; double nel = numer_errl[ifile][imulti][iat][iht]; double d = denom[ifile][imulti][iat][iht]; double deh = denom_errh[ifile][imulti][iat][iht]; double del = denom_errl[ifile][imulti][iat][iht]; double r = ratio[ifile][imulti][iat][iht]; double eh = errh[ifile][imulti][iat][iht]; double el = errl[ifile][imulti][iat][iht]; std::cout //<< " PRINT: " << "" << type[ifile] << "" //<< " njets: " << multi[imulti] << " aT: " << at[iat] << std::fixed << std::setprecision(0) << " HT: " << ht[iht] << std::scientific << std::setprecision(3) << ", pass: "******" + " << neh << " - " << nel // << ",pass," << n // << "," << neh // << "," << nel //<< " (" << ( n > 0. ? sqrt(n)/n : -1. ) << ")" << ", fail: " << d << " + " << deh << " - " << del // << ",fail," << d // << "," << deh // << "," << del //<< " (" << ( d > 0. ? sqrt(d)/d : -1. ) << ")" //<< " R: " << ( d > 0. ? n/d : -1. ) //<< " E: " << ( d > 0. ? sqrt(n*(n/(n+d))*(1-(n/(n+d)))) : -1. ) << ", ratio: " << r << " + " << eh << " - " << el // << ", ratio ," << r // << "," << eh // << "," << el // << " (" << int(( r > 0. ? eh/r : -1. )*100.) << "," // << int(( r > 0. ? el/r : -1. )*100.) << ")" << std::endl; } } } } } // ----------------------------------------------------------------------------- // For Ted bool print_ted = true; if (print_ted) { for ( uint ifile = 0; ifile < nfile; ++ifile ) { for ( uint imulti = 0; imulti < nmulti; ++imulti ) { for ( uint iat = 0; iat < nat; ++iat ) { std::stringstream ted; ted << " sample: \"" << type[ifile] << "\"" << " Multiplicity: " << multi[imulti] << " AlphaT: " << at[iat] << std::endl; ted << "\"had\":\t\t" << float(lumi) << ", #lumi" << std::endl; ted << "\"hadBulk\":\t" << float(lumi) << ", #lumi" << std::endl; // Bulk ted << "\"nHadBulk\":\t("; for ( int iht = 0; iht < nht; ++iht ) { double d = denom[ifile][imulti][iat][iht]; ted << std::setw(9) << std::scientific << std::setprecision(3) << d << ", "; } ted << ")" << std::endl; // Tail ted << "\"nHad\":\t\t("; for ( int iht = 0; iht < nht; ++iht ) { double n = numer[ifile][imulti][iat][iht]; ted << std::setw(9) << std::scientific << std::setprecision(3) << n << ", "; } ted << ")" << std::endl; // Mean HT ted << "self._htMeans = ("; for ( int iht = 0; iht < nht; ++iht ) { ted << std::setw(9) << std::scientific << std::setprecision(3) << ht[iht] << ", "; } ted << ")" << std::endl; std::cout << ted.str() << std::endl; } } } } // ----------------------------------------------------------------------------- if (!plots) return 0; // Variable to plot std::cout << " EXTRACTING VALUES TO PLOT..." << std::endl; double valx[nfile][nmulti][nat][nht]; double errxh[nfile][nmulti][nat][nht]; double errxl[nfile][nmulti][nat][nht]; double valy[nfile][nmulti][nat][nht]; double erryh[nfile][nmulti][nat][nht]; double erryl[nfile][nmulti][nat][nht]; for ( uint ifile = 0; ifile < nfile; ++ifile ) { for ( uint imulti = 0; imulti < nmulti; ++imulti ) { for ( uint iat = 0; iat < nat; ++iat ) { for ( int iht = 0; iht < nht; ++iht ) { valx[ifile][imulti][iat][iht] = 0.; errxh[ifile][imulti][iat][iht] = 0.; errxl[ifile][imulti][iat][iht] = 0.; valy[ifile][imulti][iat][iht] = 0.; erryh[ifile][imulti][iat][iht] = 0.; erryl[ifile][imulti][iat][iht] = 0.; double width = (1.*ht_step[nht-1]) / (1.*ht_step[iht]); //std::cout << " iht " << iht << " width " << width << std::endl; if ( choice == PLOT_NUMERATOR ) { valx[ifile][imulti][iat][iht] = ht[iht] + ht_step[iht]/2. + axis_offset*ifile; errxh[ifile][imulti][iat][iht] = ht_step[iht]/2. + axis_offset*ifile; errxl[ifile][imulti][iat][iht] = ht_step[iht]/2. - axis_offset*ifile; valy[ifile][imulti][iat][iht] = numer[ifile][imulti][iat][iht] * width; erryh[ifile][imulti][iat][iht] = numer_errh[ifile][imulti][iat][iht] * width; erryl[ifile][imulti][iat][iht] = numer_errl[ifile][imulti][iat][iht] * width; } else if ( choice == PLOT_DENOMINATOR ) { valx[ifile][imulti][iat][iht] = ht[iht] + ht_step[iht]/2. + axis_offset*ifile; errxh[ifile][imulti][iat][iht] = ht_step[iht]/2. + axis_offset*ifile; errxl[ifile][imulti][iat][iht] = ht_step[iht]/2. - axis_offset*ifile; valy[ifile][imulti][iat][iht] = denom[ifile][imulti][iat][iht] * width; erryh[ifile][imulti][iat][iht] = denom_errh[ifile][imulti][iat][iht] * width; erryl[ifile][imulti][iat][iht] = denom_errl[ifile][imulti][iat][iht] * width; } else if ( choice == PLOT_RATIO ) { //if ( iht < length[ifile][imulti][iat] ) { valx[ifile][imulti][iat][iht] = ht[iht] + ht_step[iht]/2. + axis_offset*ifile; errxh[ifile][imulti][iat][iht] = ht_step[iht]/2. + axis_offset*ifile; errxl[ifile][imulti][iat][iht] = ht_step[iht]/2. - axis_offset*ifile; valy[ifile][imulti][iat][iht] = ratio[ifile][imulti][iat][iht]; erryh[ifile][imulti][iat][iht] = errh[ifile][imulti][iat][iht]; erryl[ifile][imulti][iat][iht] = errl[ifile][imulti][iat][iht]; //} } } } } } if ( choice == PLOT_NUMERATOR ) { std::cout << "Plotting numerator..." << std::endl; } else if ( choice == PLOT_DENOMINATOR ) { std::cout << "Plotting denominator..." << std::endl; } else if ( choice == PLOT_RATIO ) { std::cout << "Plotting ratio..." << std::endl; } else { std::cout << "Plotting unknown!!..." << std::endl; } // ----------------------------------------------------------------------------- // Calculate min and max values for y-axis (ratio) for ( uint imulti = 0; imulti < nmulti; ++imulti ) { for ( uint iat = 0; iat < nat; ++iat ) { min[imulti][iat] = 1.e12; max[imulti][iat] = 1.e-12; for ( uint ifile = 0; ifile < nfile; ++ifile ) { for ( int iht = 0; iht < nht; ++iht ) { if ( ht[iht] < ht_min && ht[iht] > ht_max ) { continue; } double ymin = valy[ifile][imulti][iat][iht] - erryl[ifile][imulti][iat][iht]; double ymax = valy[ifile][imulti][iat][iht] + erryh[ifile][imulti][iat][iht]; if ( valy[ifile][imulti][iat][iht] > 0. && valy[ifile][imulti][iat][iht] < min[imulti][iat] ) { if ( min_max_with_errors && ymin > 0. && ymin < min[imulti][iat] ) { min[imulti][iat] = ymin; } else { min[imulti][iat] = valy[ifile][imulti][iat][iht]; } } if ( valy[ifile][imulti][iat][iht] > 0. && valy[ifile][imulti][iat][iht] > max[imulti][iat] ) { if ( min_max_with_errors && ymax > 0. && ymax > max[imulti][iat] ) { max[imulti][iat] = ymax; } else { max[imulti][iat] = valy[ifile][imulti][iat][iht]; } } } } } } if (false) { for ( uint ifile = 0; ifile < nfile; ++ifile ) { for ( uint imulti = 0; imulti < nmulti; ++imulti ) { for ( uint iat = 0; iat < nat; ++iat ) { std::cout << " sample:\"" << type[ifile] << "\"" << " multi: " << multi[imulti] << " aT:" << at[iat] << " min:" << min[imulti][iat] << " max:" << max[imulti][iat] << std::endl; } } } } if (false) { for ( uint ifile = 0; ifile < nfile; ++ifile ) { for ( uint imulti = 0; imulti < nmulti; ++imulti ) { for ( uint iat = 0; iat < nat; ++iat ) { std::cout << " PLOTTING:" << " sample:\"" << type[ifile] << "\"" << " multi: " << multi[imulti] << " aT:" << at[iat] << " valy: " << valy[ifile][imulti][iat] << " erryh: " << erryh[ifile][imulti][iat] << " erryl: " << erryl[ifile][imulti][iat] << std::endl; } } } } // ----------------------------------------------------------------------------- // Check number of pt and ht bins are the same std::cout << " CREATING PLOTS..." << std::endl; std::vector<double> rat; std::vector<float> fits; for ( uint imulti = 0; imulti < nmulti; ++imulti ) { for ( uint iat = 0; iat < nat; ++iat ) { std::string name; if ( choice == PLOT_NUMERATOR ) { name = "Pass"; } else if ( choice == PLOT_DENOMINATOR ) { if ( efficiency ) { name = "Total"; } else { name = "Fail"; } } else if ( choice == PLOT_RATIO ) { if ( efficiency ) { name = "Eff"; } else { name = "Ratio"; } } else { name = "Unknown"; } std::stringstream ss_canvas; ss_canvas << "Multi"; if ( multi[imulti] >= 0 ) { ss_canvas << multi[imulti]; } else { ss_canvas << abs(multi[imulti]) << "Incl"; } ss_canvas << "_AlphaT" << at[iat]; gStyle->SetOptFit(111); TCanvas* canvas = 0; TLegend* legend = 0; TLatex* prelim = 0; TLatex* lumitxt = 0; TMultiGraph* mg = 0; canvas = new TCanvas(TString(name+"_"+ss_canvas.str()), TString(name+"_"+ss_canvas.str()),800,600); canvas->SetFillColor(0); canvas->SetLineColor(0); canvas->SetLeftMargin(0.17); legend = new TLegend( 0.65, 0.7-(nfile*0.04), 0.85, 0.7, NULL, "brNDC" ); legend->SetTextSize(0.035); legend->SetFillColor(0); legend->SetLineColor(0); legend->SetShadowColor(0); if (!simulation) { prelim = new TLatex( 0.20, 0.88, "#scale[0.8]{CMS preliminary 2011}" ); } else { prelim = new TLatex( 0.20, 0.88, "#scale[0.8]{CMS simulation 2011}" ); } prelim->SetTextSize(0.035); prelim->SetNDC(); std::stringstream ssl; ssl << "#scale[0.8]{#int L dt = " << std::setprecision(3) << lumi/1000. << " fb^{-1}, #sqrt{s} = 7 TeV}"; lumitxt = new TLatex( 0.68, 0.88, ssl.str().c_str() ); lumitxt->SetTextSize(0.035); lumitxt->SetNDC(); mg = new TMultiGraph(); std::stringstream ss_axis; if ( choice == PLOT_NUMERATOR ) { ss_axis << "N(#alpha_{T}>" << at[iat] << ") / " << ht_step[nht-1] << " GeV"; } else if ( choice == PLOT_DENOMINATOR ) { if ( efficiency ) { ss_axis << "Total"; } else { ss_axis << "N(#alpha_{T}<" << at[iat] << ") / " << ht_step[nht-1] << " GeV"; } } else if ( choice == PLOT_RATIO ) { if ( !efficiency ) { //ss_axis << "R_{#alpha_{T}}(" << at[iat] << ")"; if ( iat+1 < nat ) { ss_axis << "N(" << at[iat] << "<#alpha_{T}<" << at[iat+1] << ") / N(#alpha_{T}<" << at[iat] << ")"; } else { ss_axis << "N(#alpha_{T}>" << at[iat] << ") / N(#alpha_{T}<" << at[iat] << ")"; } } else { ss_axis << "#varepsilon(#alpha_{T}=" << at[iat] << ")"; } } else { ss_axis << "a.u."; } std::stringstream ss_flat; std::stringstream ss_line; std::stringstream ss_expo; for ( uint ifile = 0; ifile < nfile; ++ifile ) { std::stringstream ss_histo; ss_histo << name << "_" << type[ifile] << "_" << ss_canvas.str(); gStyle->SetOptFit(0); TGraphAsymmErrors* gr = new TGraphAsymmErrors(nht, valx[ifile][imulti][iat], valy[ifile][imulti][iat], errxh[ifile][imulti][iat], errxl[ifile][imulti][iat], erryl[ifile][imulti][iat], erryh[ifile][imulti][iat]); // Fitting if (true) { TGraphAsymmErrors* tmp_gr = new TGraphAsymmErrors(*gr); //tmp_gr->Fit("pol0","Q0","",valx[ifile][imulti][iat][0]-1.e-6,valx[ifile][imulti][iat][last_bin]+1.e-6); tmp_gr->Fit("pol0","Q0","",ht_min-1.e-6,ht_max+1.e-6); TF1* fit_c = (TF1*)tmp_gr->FindObject("pol0"); if ( fit_c ) { if ( ifile == 0 ) { ss_flat << "Constant (y=A):" << std::endl; } ss_flat << "" << type[ifile] << " " << std::setprecision(3) << fit_c->GetChisquare() << "/" << std::setprecision(0) << fit_c->GetNDF() << " (" << std::setprecision(3) << fit_c->GetProb() << ") " << std::endl << "" << type[ifile] << " " << std::scientific << std::setprecision(3) << "A: " << fit_c->GetParameter(0) << " +/- " << fit_c->GetParError(0) << std::endl; //yy.push_back( fit_c->GetProb() ); //@@ ADDED if ( (int)ifile == data_file ) { fits.push_back( fit_c->GetProb() ); } //rat.push_back( fit_c->GetParameter(0) ); } else { //yy.push_back( 0. ); //@@ ADDED std::cout << " NULL PTR! " << std::endl; } //tmp_gr->Fit("pol1","Q0","",valx[ifile][imulti][iat][0]-1.e-6,valx[ifile][imulti][iat][last_bin]+1.e-6); tmp_gr->Fit("pol1","Q0","",ht_min-1.e-6,ht_max+1.e-6); TF1* fit_l = (TF1*)tmp_gr->FindObject("pol1"); if ( fit_l ) { if ( ifile == 0 ) { ss_line << "Linear (y=A+Bx):" << std::endl; } ss_line << "" << type[ifile] << " " << std::setprecision(3) << fit_l->GetChisquare() << "/" << std::setprecision(0) << fit_l->GetNDF() << " (" << std::setprecision(3) << fit_l->GetProb() << ") " << std::endl << "" << type[ifile] << " " << std::scientific << std::setprecision(3) << "A: " << fit_l->GetParameter(0) << " +/- " << fit_l->GetParError(0) << " B: " << fit_l->GetParameter(1) << " +/- " << fit_l->GetParError(1) << std::endl; if ( (int)ifile == data_file ) { fits.push_back( fit_l->GetProb() ); } //rat.push_back( fit_l->GetParameter(0) ); } else { std::cout << " NULL PTR! " << std::endl; } //tmp_gr->Fit("expo","Q0","",valx[ifile][imulti][iat][0]-1.e-6,valx[ifile][imulti][iat][last_bin]+1.e-6); //TF1* fit_e = new TF1("expo+expo", tmp_gr->FindObject("expo"); //tmp_gr->Fit("expo","Q0","",ht_min-1.e-6,ht_max+1.e-6); tmp_gr->Fit("expo","Q0","",325.-1.e-6,675.+1.e-6); TF1* fit_e = (TF1*)tmp_gr->FindObject("expo"); if ( fit_e ) { if ( ifile == 0 ) { ss_expo << "Exponential (y=e^{A+kx}):" << std::endl; } ss_expo << "" << type[ifile] << " " << std::fixed << std::setprecision(3) << fit_e->GetChisquare() << "/" << std::setprecision(0) << fit_e->GetNDF() << " (" << std::setprecision(3) << fit_e->GetProb() << ") " << std::endl << "" << type[ifile] << " " << std::scientific << std::setprecision(3) << "A: " << fit_e->GetParameter(0) << " +/- " << fit_e->GetParError(0) << " k: " << fit_e->GetParameter(1) << " +/- " << fit_e->GetParError(1) << std::endl; if ( (int)ifile == data_file ) { fits.push_back( fit_e->GetProb() ); } rat.push_back( fit_e->GetParameter(1) ); } else { std::cout << " NULL PTR! " << std::endl; } //if (tmp_gr) delete tmp_gr; } for ( int ii = 0; ii < nht; ++ii ) { double x = 0.; double y = 0.; gr->GetPoint(ii,x,y); //if ( y == 0. ) { gr->SetPointEYhigh(ii,0.); gr->SetPointEYlow(ii,0.); } if (false) { std::cout << " sample:\"" << type[ifile] << "\"" << " multi: " << multi[imulti] << " aT:" << at[iat] << " HT:" << ht[ii] << " ARRAY x: " << valx[ifile][imulti][iat][ii] << " y: " << valy[ifile][imulti][iat][ii] << " + " << erryh[ifile][imulti][iat][ii] << " - " << erryl[ifile][imulti][iat][ii] << " HISTO x: " << x << " y: " << y << " + " << gr->GetErrorYhigh(ii) << " - " << gr->GetErrorYlow(ii) << std::endl; } } if ( nfile - ifile == 1 ) { //std::cout << ss_flat.str() << std::endl; //std::cout << ss_line.str() << std::endl; std::cout << ss_expo.str() << std::endl; } mg->Add(gr,"p"); std::stringstream ss_legend; ss_legend << type[ifile]; legend->AddEntry( gr, TString(ss_legend.str()), "p" ); gr->SetTitle(TString(ss_legend.str())); gr->SetMarkerStyle(style[ifile]); gr->SetMarkerSize(size[ifile]); gr->SetMarkerColor(col[ifile]); gr->SetLineColor(col[ifile]); } // ifile mg->Draw("a"); mg->GetXaxis()->SetTitle(label.c_str()); if (!use_meff) mg->GetXaxis()->SetTitle("H_{T} (GeV)"); else mg->GetXaxis()->SetTitle("M_{eff} (GeV)"); mg->GetYaxis()->SetTitle(TString(ss_axis.str())); mg->GetYaxis()->SetTitleOffset(1.3); mg->GetXaxis()->SetRangeUser(ht_min+offset,ht_max+offset); mg->GetYaxis()->SetRangeUser(min[imulti][iat]/2.0,max[imulti][iat]*1.2); //else mg->GetYaxis()->SetRangeUser(0.,0.12e-3); //mg->GetYaxis()->SetNoExponent(true); //mg->GetXaxis()->SetRangeUser(250,450.); //mg->GetYaxis()->SetRangeUser(0.,25.e-6); //mg->GetYaxis()->SetRangeUser(0.,0.05e-3); //mg->GetYaxis()->SetRangeUser(0.,0.04e-3); canvas->SetLogy(); //if (choice==1) mg->GetYaxis()->SetRangeUser(0.1,1.e4); //else if (choice==2) mg->GetYaxis()->SetRangeUser(0.1,1.e8); legend->Draw("same"); //prelim->Draw("same"); //lumitxt->Draw("same"); canvas->Update(); std::stringstream ss_text; ss_text << "#alpha_{T} = " << at[iat]; TLatex* text = new TLatex(0.5,0.92,TString(ss_text.str())); text->SetNDC(kTRUE); text->SetTextSize(0.04); //text->Draw(); //canvas->SaveAs(TString(name+"_"+ss_canvas.str()+".C")); //canvas->SaveAs(TString(name+"_"+ss_canvas.str()+".png")); //canvas->SaveAs(TString(name+"_"+ss_canvas.str()+".pdf")); //if (canvas) delete canvas; } // iat } // imulti int index = 0; std::vector<float> cuts; std::vector<float>::const_iterator ifit = fits.begin(); std::vector<float>::const_iterator jfit = fits.end(); for ( ; ifit != jfit; ++ifit ) { cuts.push_back(at[index]); index++; } //if ( !fits.empty() ) qcd(cuts,fits); // Draw RaT if ( false && !rat.empty() ) { bool plot_ratio = false; setTDRStyle(); gStyle->SetOptStat("emr"); TCanvas* c2 = new TCanvas("RaTvsEwkComposition","RaTvsEwkComposition"); c2->SetFillColor(0); c2->SetLineColor(0); TH1D* diff = 0; if ( !plot_ratio ) { diff = new TH1D("RaTvsEwkComposition","",1000,0.,1e-3); //diff = new TH1D("RaTvsEwkComposition","",1000,-20.,0.); for ( uint ifile = 0; ifile < nfile; ++ifile ) { std::cout << "sample: " << type[ifile] << " fit: " << rat[ifile] << std::endl; diff->Fill( rat[ifile], 1. ); } } else { diff = new TH1D("RaTvsEwkComposition","",200,0.6,1.4); for ( uint ifile = 1; ifile < nfile; ++ifile ) { std::cout << "sample: " << type[ifile] << " nominal: " << rat[0] << " ratio: " << rat[ifile]/rat[0] << std::endl; diff->Fill( rat[ifile]/rat[0], 1. ); } } c2->cd(); c2->SetRightMargin(0.12); c2->SetBottomMargin(0.15); diff->Draw("h"); if (!plot_ratio) diff->GetXaxis()->SetTitle("Best fit value"); else { //diff->GetXaxis()->SetTitle("Best fit value relative to nominal"); diff->GetXaxis()->SetTitle("R_{#alpha_{T}}^{(#pm15%)} / R_{#alpha_{T}}^{(nominal)}"); diff->GetXaxis()->SetTitleOffset(1.1); } diff->GetYaxis()->SetTitle("Number of tests with #pm15%"); if (!plot_ratio) c2->SaveAs("RaTvsEwkComposition.pdf"); else c2->SaveAs("RaTvsEwkComposition_ratio.pdf"); } // } // yy.resize(xx.size(),0.); // TCanvas* c1 = new TCanvas(); // TGraph* gr = new TGraph(nn, &(xx.front()), &(yy.front()) ); // c1->cd(); // gr->Draw("ap"); // //gr->SetBorderSize(0); // gr->SetTitle("Fit range: 325 < HT < 985"); // gr->GetXaxis()->SetTitle("Integrated Lumi (pb^{-1})"); // gr->GetYaxis()->SetTitle("p-value"); // c1->SaveAs("tmp.C"); // delete c1; // std::cout << std::endl; // for ( uint i = 0; i < nn; ++i ) { std::cout << xx[i] << std::endl; } // std::cout << std::endl; // for ( uint i = 0; i < nn; ++i ) { std::cout << yy[i] << std::endl; } // std::cout << std::endl; return 0; }
void plotTree(TTree *tree_, std::string whichfit, std::string selectString){ // Create a map for plotting the pullsummaries: std::map < const char*, std::pair <double,double> > pullSummaryMap; int nPulls=0; TObjArray *l_branches = tree_->GetListOfBranches(); int nBranches = l_branches->GetEntries(); gStyle->SetPadTopMargin(0.01); TCanvas *c = new TCanvas("c","",960,800); std::string treename = tree_->GetName(); c->SaveAs(Form("%s.pdf[",treename.c_str())); // File to store plots in TFile *fOut = new TFile(Form("%s.root",treename.c_str()),"RECREATE"); for (int iobj=0;iobj<nBranches;iobj++){ TBranch *br =(TBranch*) l_branches->At(iobj); // Draw the normal histogram const char* name = br->GetName(); // names with - are not allowed string namestr(name); if(namestr.find("-")!=string::npos) { std::cout << "Variable " << name << " contains a bad character: -. Skipping. " << std::endl; continue; } bool fitPull=false; bool fitPullf=false; bool plotLH=false; TGraph *gr=NULL; double p_mean =0; double p_err =0; int nToysInTree = tree_->GetEntries(); // Find out if paramter is fitted value or constraint term bool isFitted = findNuisancePre(name); if (doPull && isFitted){ p_mean = bfvals_[name].first; // toy constrainits thrown about best fit to data if(namestr.find("n_exp")==string::npos) p_err = prevals_[name].second; // uncertainties taken from card std::cout << "******* "<< name << " *******"<<std::endl; std::cout << p_mean << " " << p_err << std::endl; std::cout << "******************************" <<std::endl; const char* drawInput; // if the parameter is a normalization, the error is not available. Do the residual instead of the pull if(namestr.find("n_exp")!=string::npos) drawInput = Form("(%s-%f)/%f",name,p_mean,p_mean); else drawInput = Form("(%s-%f)/%f",name,p_mean,p_err); tree_->Draw(Form("%s>>%s",drawInput,name),""); tree_->Draw(Form("%s>>%s_fail",drawInput,name),selectString.c_str(),"same"); fitPull = true; fitPullf = true; if (doLH) { gr = graphLH(name,p_err,whichfit); if (gr) plotLH=true; } } else{ tree_->Draw(Form("%s>>%s",name,name),""); tree_->Draw(Form("%s>>%s_fail",name,name),selectString.c_str(),"same"); } TH1F* bH = (TH1F*) gROOT->FindObject(Form("%s",name))->Clone(); TH1F* bHf = (TH1F*) gROOT->FindObject(Form("%s_fail",name))->Clone(); bHf->SetLineColor(2); bH->GetXaxis()->SetTitle(bH->GetTitle()); bH->GetYaxis()->SetTitle(Form("no toys (%d total)",nToysInTree)); bH->GetYaxis()->SetTitleOffset(1.05); bH->GetXaxis()->SetTitleOffset(0.9); bH->GetYaxis()->SetTitleSize(0.05); bH->GetXaxis()->SetTitleSize(0.05); if (isFitted) {bH->GetXaxis()->SetTitle(Form("(%s-#theta_{B})/#sigma_{#theta}",name));} else {bH->GetXaxis()->SetTitle(Form("%s",name));} bH->SetTitle(""); if ( bH->Integral() <=0 ) fitPull = false; if (fitPull) {bH->Fit("gaus"); bH->GetFunction("gaus")->SetLineColor(4);} if ( bHf->Integral() <=0 ) fitPullf = false; if (fitPullf) {bHf->Fit("gaus"); bHf->GetFunction("gaus")->SetLineColor(2);} c->Clear(); //TPad pad1("t1","",0.01,0.02,0.59,0.98); // Pad 1 sizes depend on the parameter type ... double pad1_x1,pad1_x2,pad1_y1,pad1_y2; if ( !isFitted ) { pad1_x1 = 0.01; pad1_x2 = 0.98; pad1_y1 = 0.045; pad1_y2 = 0.98; } else { pad1_x1 = 0.01; pad1_x2 = 0.59; pad1_y1 = 0.56; pad1_y2 = 0.98; } TPad pad1("t1","",pad1_x1,pad1_y1,pad1_x2,pad1_y2); TPad pad1a("t1a","",0.01,0.045,0.59,0.522); TPad pad2("t2","",0.59,0.04,0.98,0.62); TPad pad3("t3","",0.55,0.64,0.96,0.95); pad1.SetNumber(1); pad2.SetNumber(2); pad3.SetNumber(3); pad1a.SetNumber(4); if ( isFitted ) {pad1a.Draw();pad2.Draw();pad3.Draw();} pad1.Draw(); pad2.SetGrid(true); TLatex *titletext = new TLatex();titletext->SetNDC(); if ( isFitted ){ c->cd(4); tree_->Draw(Form("%s:%s_In>>%s_%s_2d",name,name,name,tree_->GetName()),""); //TH2D *h2d_corr = (TH2D*)gROOT->FindObject(Form("%s_2d",name)); //h2d_corr->SetMarkerColor(4); //h2d_corr->SetTitle(""); //h2d_corr->GetXaxis()->SetTitle(Form("%s_In",name)); //h2d_corr->GetYaxis()->SetTitle(Form("%s",name)); titletext->SetTextAlign(11); titletext->SetTextSize(0.05); titletext->DrawLatex(0.05,0.02,Form("%s_In",name)); titletext->SetTextAngle(90); titletext->DrawLatex(0.04,0.06,Form("%s",name)); titletext->SetTextAngle(0); } c->cd(1); bH->Draw(); bHf->Draw("same"); TLegend *legend = new TLegend(0.6,0.8,0.9,0.89); legend->SetFillColor(0); legend->AddEntry(bH,"All Toys","L"); legend->AddEntry(bHf,selectString.c_str(),"L"); legend->Draw(); if (doPull && plotLH) { c->cd(2); gr->Draw("ALP"); } if (fitPull){ c->cd(3); double gap; TLatex *tlatex = new TLatex(); tlatex->SetNDC(); if (fitPullf) {tlatex->SetTextSize(0.09); gap=0.12;} else {tlatex->SetTextSize(0.11);gap=0.14;} tlatex->SetTextColor(4); tlatex->DrawLatex(0.11,0.80,Form("Mean : %.3f #pm %.3f",bH->GetFunction("gaus")->GetParameter(1),bH->GetFunction("gaus")->GetParError(1))); tlatex->DrawLatex(0.11,0.80-gap,Form("Sigma : %.3f #pm %.3f",bH->GetFunction("gaus")->GetParameter(2),bH->GetFunction("gaus")->GetParError(2))); if (fitPullf){ tlatex->SetTextColor(2); tlatex->DrawLatex(0.11,0.60,Form("Mean : %.3f #pm %.3f",bHf->GetFunction("gaus")->GetParameter(1),bHf->GetFunction("gaus")->GetParError(1))); tlatex->DrawLatex(0.11,0.60-gap,Form("Sigma : %.3f #pm %.3f",bHf->GetFunction("gaus")->GetParameter(2),bHf->GetFunction("gaus")->GetParError(2))); } tlatex->SetTextSize(0.10); tlatex->SetTextColor(1); if(namestr.find("n_exp")!=string::npos) tlatex->DrawLatex(0.11,0.33,Form("Pre-fit: %.3f",prevals_[name].first)); else tlatex->DrawLatex(0.11,0.33,Form("Pre-fit #pm #sigma_{#theta}: %.3f #pm %.3f",prevals_[name].first, p_err)); tlatex->DrawLatex(0.11,0.18,Form("Best-fit (#theta_{B}) : %.3f ",p_mean)); tlatex->DrawLatex(0.11,0.03,Form("Best-fit (#theta_{S+B}): %.3f ",bfvals_sb_[name].first)); pullSummaryMap[name]=std::make_pair<double,double>(bH->GetFunction("gaus")->GetParameter(1),bH->GetFunction("gaus")->GetParameter(2)); nPulls++; } double titleSize = isFitted ? 0.1 : 0.028; titletext->SetTextSize(titleSize);titletext->SetTextAlign(21); titletext->DrawLatex(0.55,0.92,name); c->SaveAs(Form("%s.pdf",treename.c_str())); fOut->WriteObject(c,Form("%s_%s",treename.c_str(),name)); //c->SaveAs(Form("%s_%s.pdf",treename.c_str(),name)); } if (doPull && nPulls>0){ std::cout << "Generating Pull Summaries" <<std::endl; int nRemainingPulls = nPulls; TCanvas *hc = new TCanvas("hc","",3000,2000); hc->SetGrid(0); std::map < const char*, std::pair <double,double> >::iterator pull_it = pullSummaryMap.begin(); std::map < const char*, std::pair <double,double> >::iterator pull_end = pullSummaryMap.end(); int pullPlots = 1; while (nRemainingPulls > 0){ int nThisPulls = min(maxPullsPerPlot,nRemainingPulls); TH1F pullSummaryHist("pullSummary","",nThisPulls,0,nThisPulls); for (int pi=1;pull_it!=pull_end && pi<=nThisPulls ;pull_it++,pi++){ pullSummaryHist.GetXaxis()->SetBinLabel(pi,(*pull_it).first); pullSummaryHist.SetBinContent(pi,((*pull_it).second).first); pullSummaryHist.SetBinError(pi,((*pull_it).second).second); nRemainingPulls--; } pullSummaryHist.SetMarkerStyle(21);pullSummaryHist.SetMarkerSize(1.5);pullSummaryHist.SetMarkerColor(2);pullSummaryHist.SetLabelSize(pullLabelSize); pullSummaryHist.GetYaxis()->SetRangeUser(-3,3);pullSummaryHist.GetYaxis()->SetTitle("pull summary (n#sigma)");pullSummaryHist.Draw("E1"); hc->SaveAs(Form("%s.pdf",treename.c_str())); fOut->WriteObject(hc,Form("comb_pulls_%s_%d",treename.c_str(),pullPlots)); // hc->SaveAs(Form("comb_pulls_%s_%d.pdf",treename.c_str(),pullPlots)); pullPlots++; } delete hc; } c->SaveAs(Form("%s.pdf]",treename.c_str())); fOut->Close(); delete c; return; }
void TnPDrawMass_test_5eta5() { char *infile; //char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_2G_v1.root"; //char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_Multi_v1.root"; //char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_PAMu7_v1.root"; //char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_merge_v1.root"; //char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_narrow_v1.root"; char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/data/outputEveryCut_data_allDirection_v24_nominalCond_5etaBins_cutG_all_nominal_v8_oldeta.root"; TString outname_in, outname_mid, outname_out; TString middle_name, middle_name2; gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); gStyle->SetTitle(0); gStyle->SetPaperSize(20,26); TCanvas *c1 = new TCanvas(); Int_t type = 112; TString out1 = outfile_ + "["; c1->SetLogy(); c1->Print(out1); infile = files; TFile *f = new TFile(infile); outname_in = "Jpsi_" + Cat1 + "_" + Cat2 + "_Mass_" + middle_name + ".ps["; outname_mid = "Jpsi_" + Cat1 + "_" + Cat2 + "_Mass_" + middle_name + ".ps"; outname_out = "Jpsi_" + Cat1 + "_" + Cat2 + "_Mass_" + middle_name + ".ps]"; cout<<" Out Name : "<<outname_in<<" "<<outname_mid<<" "<<outname_in<<endl; TString tot_dir; //dir_suffix; //TString ptbins[ptBins] = {"pt_bin0_", "pt_bin1_", "pt_bin2_", "pt_bin3_", "pt_bin4_", // "pt_bin5_", "pt_bin6_", "pt_bin7_", "pt_bin8_",};//1 //TString ptbins1[ptBins1] = {"3.3 - 3.8 GeV", "3.8 - 4.3 GeV", "4.3 - 5 GeV", "5 - 6 GeV", "6 - 7 GeV", // "7 - 8 GeV", "8 - 10 GeV", "10 - 13 GeV", "13 - 30 GeV"};//1 TString dir_pt[ptBins] = {"tpTree/ptBin_eta5_0/", "tpTree/ptBin_eta5_1/", "tpTree/ptBin_eta5_2/", "tpTree/ptBin_eta5_3/", "tpTree/ptBin_eta5_4/", "tpTree/ptBin_eta5_5/", "tpTree/ptBin_eta5_6/", "tpTree/ptBin_eta5_7/"};//5 TString ptbins1[ptBins1] = {"1.3 - 1.6 GeV", "1.6 - 1.8 GeV", "1.8 - 2.0 GeV", "2.0 - 2.6 GeV", "2.6 - 3.4 GeV", "3.4 - 4.8 GeV", "4.8 -6.0 GeV", "6.0 - 30 GeV"};//5 //TString ptbins[ptBins] = {"pt_bin0_", "pt_bin1_", "pt_bin2_", "pt_bin3_", "pt_bin4_", // "pt_bin5_", "pt_bin6_", "pt_bin7_", "pt_bin8_", "pt_bin9_"};//3 //TString ptbins1[ptBins1] = {"0 - 3.3 GeV", "3.3 - 3.8 GeV", "3.8 - 4.3 GeV", "4.3 - 5 GeV", "5 -6 GeV", // "6 - 7 GeV", "7 - 8 GeV", "8 - 10 GeV", "10 - 13 GeV", "13 - 30 GeV"};//3 //TString ptbins[ptBins] = {"pt_bin0_", "pt_bin1_", "pt_bin2_", "pt_bin3_", "pt_bin4_", // "pt_bin5_", "pt_bin6_", "pt_bin7_", "pt_bin8_", "pt_bin9_"};//4 //TString ptbins1[ptBins1] = {"0 - 3.3 GeV", "3.3 - 3.8 GeV", "3.8 - 4.3 GeV", "4.3 - 5 GeV", "5 -6 GeV", // "6 - 7 GeV", "7 - 8 GeV", "8 - 10 GeV", "10 - 13 GeV", "13 - 30 GeV"};//4 //TString ptbins[ptBins] = {"pt_bin0_", "pt_bin1_", "pt_bin2_", "pt_bin3_", "pt_bin4_", // "pt_bin5_", "pt_bin6_", "pt_bin7_", "pt_bin8_", "pt_bin9_"};//5 //TString ptbins1[ptBins1] = {"0 - 3.3 GeV", "3.3 - 3.8 GeV", "3.8 - 4.3 GeV", "4.3 - 5 GeV", "5 -6 GeV", // "6 - 7 GeV", "7 - 8 GeV", "8 - 10 GeV", "10 - 13 GeV", "13 - 30 GeV"};//5 //dir_pt = "tpTree/ptBin_eta1/"; //dir_pt = "tpTree/ptBin_eta3/"; //dir_pt = "tpTree/ptBin_eta3/"; //dir_pt = "tpTree/ptBin_eta5/"; //dir_pt = "tpTree/ptBin_eta5/"; //dir_suffix = "_cbGaussPlusPoly1"; //dir_suffix = "_cbGaussPlusPoly4"; TString dir_suffix[ptBins]= {"_cbGaussPlusExpo5_0","_cbGaussPlusExpo5_1","_cbGaussPlusExpo5_2","_cbGaussPlusExpo5_3","_cbGaussPlusExpo5_4","_cbGaussPlusExpo5_5", "_cbGaussPlusExpo5_6", "_cbGaussPlusExpo5_7"}; //dir_suffix = "_GaussPlusExpo"; //dir_suffix = "_twoGaussPlusExpo"; gStyle->SetPaperSize(20,26); c1->Print(outname_in); int cnt = 0; TCanvas *tmp1 = new TCanvas(); tmp1->cd(); TString title; title = "J/#psi Efficiency Heavy Ion TnP Result (" + middle_name2 + ")"; c1 = (TCanvas *)tmp1->Clone(); c1->Print(outname_mid); c1->Print(outfile_); TString mid_title = "Centrality : (" + middle_name2 + ")"; TString leg_title = Cat2 + " Efficiency (" + middle_name2 + ")"; // pt for(int j = 0; j < ptBins; j++){ //TString tot_dir = dir_pt + "abseta_bin0__event_PrimaryVertex_z_bin0__" + ptbins[j] + "_tag_eta_bin0__tag_pt_bin0__Acc_JPsi_pass__Calo_pass__tag_PAMu3_standard_pass_" + dir_suffix; TString tot_dir = dir_pt[j] + "abseta_bin0__event_PrimaryVertex_z_bin0__pt_bin0__tag_eta_bin0__tag_pt_bin0__Acc_JPsiG_pass__Calo_pass__tag_PAMu3_standard_pass_" + dir_suffix[j];//2G,PAMu3,merge //TString tot_dir = dir_pt + "abseta_bin0__event_PrimaryVertex_z_bin0__" + ptbins[j] + "_tag_eta_bin0__tag_pt_bin0__Acc_JPsiG_pass__Calo_pass__tag_PAMu7_standard_pass_" + dir_suffix;//PAMu7 //TString tot_dir = dir_pt + "abseta_bin0__event_PrimaryVertex_z_bin0__pair_probeMultiplicity_bin0__" + ptbins[j] + "_tag_eta_bin0__tag_pt_bin0__Acc_JPsiG_pass__Calo_pass__tag_PAMu3_standard_pass_" + dir_suffix;//multi //TString tot_dir = dir_pt + "abseta_bin0__event_PrimaryVertex_z_bin0__" + ptbins[j] + "_tag_eta_bin0__tag_pt_bin0__Acc_JPsi_pass__Calo_pass__tag_PAMu3_standard_pass_" + dir_suffix;//merge // f->cd(tot_dir); cout<<" tot_dir : "<<tot_dir<<endl; TDirectory *root_dir = gDirectory; TIter rootnextkey( root_dir->GetListOfKeys() ); root_dir->cd(); TKey *rootkey; TCanvas *ctmp = new TCanvas(); ctmp->cd(); TLatex l; l.SetTextAlign(13); l.SetTextSize(0.06); l.DrawLatex(0.1,0.8,mid_title); l.DrawLatex(0.1,0.6,"Bin : "); l.SetTextSize(0.04); //l.DrawLatex(0.1,0.5,tot_dir); l.DrawLatex(0.1,0.5,ptbins1[j]); ctmp->Update(); c1 = (TCanvas *)ctmp->Clone(); c1->Print(outname_mid); c1->Print(outfile_); while( rootkey = (TKey*)rootnextkey() ) { TObject *rootobj = rootkey->ReadObj(); TDirectory *rdir = gDirectory; TIter rdirnextkey(rdir->GetListOfKeys()); rdir->cd(); TKey *dir_key; while( dir_key = (TKey*)rdirnextkey()) { if (rootobj->IsA()->InheritsFrom("TCanvas")){ c1 = (TCanvas *)rootobj; c1->SetLogy(); c1->Modified(); c1->Update(); c1->Print(outname_mid); c1->Print(outfile_); cnt++; cout<<"Count : "<<cnt<<endl; if(cnt > 0) break; } } } } c1->Print(outname_out); TString out2 = outfile_ + "]"; c1->Print(out2); }
void AccTimesEff::Loop() { TStopwatch timer; timer.Start(); // parameters ///////////////////////////////////////////////////////////// vector<TString> files; files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-750_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_10000ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1250_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9997ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1750_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9997ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-2000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-2500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-3000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_10000ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-3500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9898ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-4000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-5000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9966ev.root"); string outfileName = "accTimesEffHistos"; // output file formats const bool saveSpec = 0; const bool saveAsPdf = 0; const bool saveAsPng = 1; const bool saveAsRoot = 0; TString plotDir = "./plots/"; int font = 42; //62 // selection cuts ///////////////////////////////////////////////////////// float elePtCut = 35.; float muPtCut = 35.; float minInvMass = 0.; TH1::SetDefaultSumw2(kTRUE); /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// TH1F *hGenEvts = new TH1F("hGenEvts", "hGenEvts", 145, 0., 5010.); hGenEvts->GetXaxis()->SetTitle("M_{Z'}^{truth}"); hGenEvts->GetXaxis()->SetTitleFont(font); hGenEvts->GetXaxis()->SetLabelFont(font); hGenEvts->GetYaxis()->SetTitle("Events"); hGenEvts->GetYaxis()->SetTitleFont(font); hGenEvts->GetYaxis()->SetLabelFont(font); hGenEvts->GetYaxis()->SetTitleOffset(1.2); hGenEvts->SetLineColor(kBlack); hGenEvts->SetLineWidth(2); hGenEvts->SetMarkerStyle(20); hGenEvts->SetMarkerColor(kBlack); TH1F *hGenEvtsEleInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAcc"); TH1F *hGenEvtsEleInAccEB = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAccEB"); TH1F *hGenEvtsEleInAccEE = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAccEE"); TH1F *hGenEvtsMuInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsMuInAcc"); TH1F *hGenEvtsInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsInAcc"); TH1F *hTrgEvts = (TH1F*)hGenEvts->Clone("hTrgEvts"); hTrgEvts->SetTitle("hTrgEvts"); TH1F *hRecoEvts = (TH1F*)hGenEvts->Clone("hRecoEvts"); hRecoEvts->SetTitle("hRecoEvts"); TH1F *hRecoEvtsEB = (TH1F*)hRecoEvts->Clone("hRecoEvtsEB"); TH1F *hRecoEvtsEE = (TH1F*)hRecoEvts->Clone("hRecoEvtsEE"); TH1F *hRecoEleEvts = (TH1F*)hRecoEvts->Clone("hRecoEleEvts"); TH1F *hRecoEleEvtsEB = (TH1F*)hRecoEvts->Clone("hRecoEleEvtsEB"); TH1F *hRecoEleEvtsEE = (TH1F*)hRecoEvts->Clone("hRecoEleEvtsEE"); TH1F *hRecoMuEvts = (TH1F*)hRecoEvts->Clone("hRecoMuEvts"); TH1F *hRecoNoTrgEvts = (TH1F*)hGenEvts->Clone("hRecoNoTrgEvts"); hRecoNoTrgEvts->SetTitle("hRecoNoTrgEvts"); TH1F *hRecoNoTrgEvtsEB = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEvtsEB"); TH1F *hRecoNoTrgEvtsEE = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEvtsEE"); TH1F *hRecoNoTrgEleEvts = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvts"); TH1F *hRecoNoTrgEleEvtsEB = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvtsEB"); TH1F *hRecoNoTrgEleEvtsEE = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvtsEE"); TH1F *hRecoNoTrgMuEvts = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgMuEvts"); TH1F* hAcc; TH1F* hAccEle; TH1F* hAccEleEB; TH1F* hAccEleEE; TH1F* hAccMu; TH1F* hAccTimesTrgEff; TH1F* hTrgEff; TH1F* hAccTimesEff; TH1F* hAccTimesEffEB; TH1F* hAccTimesEffEE; TH1F* hAccTimesEffEle; TH1F* hAccTimesEffEleEB; TH1F* hAccTimesEffEleEE; TH1F* hAccTimesEffMu; TH1F* hAccTimesEffNoTrg; //TH1F* hAccTimesEffNoTrgEB; //TH1F* hAccTimesEffNoTrgEE; TH1F* hAccTimesEffNoTrgEle; TH1F* hAccTimesEffNoTrgEleEB; TH1F* hAccTimesEffNoTrgEleEE; TH1F* hAccTimesEffNoTrgMu; TH1F* hEffAftTrg; TH1F* hEffAftTrgEle; TH1F* hEffAftTrgEleEB; TH1F* hEffAftTrgEleEE; TH1F* hEffAftTrgMu; TH1F* hTrgRecoVsReco; //TH1F* hTrgRecoVsRecoEB; //TH1F* hTrgRecoVsRecoEE; TH1F* hTrgRecoVsRecoEle; TH1F* hTrgRecoVsRecoEleEB; TH1F* hTrgRecoVsRecoEleEE; TH1F* hTrgRecoVsRecoMu; // output file stringstream ssOutfile; ssOutfile << outfileName << ".root"; TFile *output = new TFile(ssOutfile.str().c_str(), "recreate"); /////////////////////////////////////////////////////////////////////////// //LOOP OVER FILES /////////////////////////////////////////////////////////////////////////// for (unsigned int p = 0; p < files.size(); ++p) { TFile* input = new TFile(files[p]); TTree *thetree = (TTree*)input->Get("gsfcheckerjob/tree"); Init(thetree); Long64_t nentries = fChain->GetEntriesFast(); cout << nentries << " events" << endl; unsigned int evCounter = 0; ///////////////////////////////////////////////////////////////////////////////////////////// //LOOP OVER EVENTS ///////////////////////////////////////////////////////////////////////////////////////////// //nentries = 10000; for (Long64_t jentry = 0; jentry < nentries; ++jentry) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); // if (Cut(ientry) < 0) continue; //if (jentry % 50000 == 0) cout << "Processing event " << jentry << endl; thetree->GetEntry(jentry); // fill the gen histograms hGenEvts->Fill(genelemom_mass[0]); // fill the acc histograms if (hardGenEle_pt[0] > elePtCut) { if (fabs(hardGenEle_eta[0]) < 1.442) { hGenEvtsEleInAcc->Fill(genelemom_mass[0]); hGenEvtsEleInAccEB->Fill(genelemom_mass[0]); } else if (fabs(hardGenEle_eta[0]) > 1.56 && fabs(hardGenEle_eta[0]) < 2.5) { hGenEvtsEleInAcc->Fill(genelemom_mass[0]); hGenEvtsEleInAccEE->Fill(genelemom_mass[0]); } } if (hardGenMu_pt[0] > muPtCut && fabs(hardGenMu_eta[0]) < 2.4) { hGenEvtsMuInAcc->Fill(genelemom_mass[0]); if (fabs(hardGenEle_eta[0]) < 1.442 || (fabs(hardGenEle_eta[0]) > 1.56 && fabs(hardGenEle_eta[0]) < 2.5)) { if (hardGenEle_pt[0] > elePtCut) hGenEvtsInAcc->Fill(genelemom_mass[0]); } } // trigger? if (HLT_Mu22_Photon22_CaloIdL) hTrgEvts->Fill(genelemom_mass[0]); // at least one gsf electron and one muon above the threshold if (gsf_size < 1 || muon_size < 1) continue; vector<int> GSF_passHEEP; vector<int> MU_passGOOD; ///////////////////////////////////////////////////////////////////////////////////////////// //loop over electrons for (int j = 0; j < gsf_size; ++j) { //cleaning: fake electrons from muons bool fakeEle = false; for (int k = 0; k < muon_size; ++k) { float DeltaR = deltaR(gsf_eta[j], gsf_phi[j], muon_eta[k], muon_phi[k]); if (DeltaR < 0.1) { fakeEle = true; break; } } if (fakeEle) continue; if (PassHEEP(j)) GSF_passHEEP.push_back(j); } //loop over muons for (int j = 0; j < muon_size; ++j) { if (PassHighPtMu(j)) MU_passGOOD.push_back(j); } if (GSF_passHEEP.size() == 1) { if (HLT_Mu22_Photon22_CaloIdL) { hRecoEleEvts->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoEleEvtsEB->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoEleEvtsEE->Fill(genelemom_mass[0]); } hRecoNoTrgEleEvts->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoNoTrgEleEvtsEB->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoNoTrgEleEvtsEE->Fill(genelemom_mass[0]); } if (MU_passGOOD.size() == 1) { if (HLT_Mu22_Photon22_CaloIdL) hRecoMuEvts->Fill(genelemom_mass[0]); hRecoNoTrgMuEvts->Fill(genelemom_mass[0]); } // veto when there are more than one good candidates if (GSF_passHEEP.size() != 1 || MU_passGOOD.size() != 1) continue; //HEEP ele + GOOD muon TLorentzVector ele1; TLorentzVector mu1; ele1.SetPtEtaPhiM(gsf_gsfet[GSF_passHEEP[0]], gsf_eta[GSF_passHEEP[0]], gsf_phi[GSF_passHEEP[0]], 0.000511); mu1.SetPtEtaPhiM(muon_pt[MU_passGOOD[0]], muon_eta[MU_passGOOD[0]], muon_phi[MU_passGOOD[0]], 0.10566); double invMass = (ele1 + mu1).M(); //MASS CUT if (invMass < minInvMass) continue; if (HLT_Mu22_Photon22_CaloIdL) { hRecoEvts->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoEvtsEB->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoEvtsEE->Fill(genelemom_mass[0]); } hRecoNoTrgEvts->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoNoTrgEvtsEB->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoNoTrgEvtsEE->Fill(genelemom_mass[0]); ++evCounter; /////////////////////////////////////////////////////////////////////// } //END LOOP OVER EVENTS ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// } //END LOOP OVER FILES ////////////////////////////////////////////////////////////////////////// hAcc = (TH1F*)hGenEvtsInAcc->Clone("hAcc"); hAccEle = (TH1F*)hGenEvtsEleInAcc->Clone("hAccEle"); hAccEleEB = (TH1F*)hGenEvtsEleInAccEB->Clone("hAccEleEB"); hAccEleEE = (TH1F*)hGenEvtsEleInAccEE->Clone("hAccEleEE"); hAccMu = (TH1F*)hGenEvtsMuInAcc->Clone("hAccMu"); hAccTimesTrgEff = (TH1F*)hTrgEvts->Clone("hAccTimesTrgEff"); hTrgEff = (TH1F*)hTrgEvts->Clone("hTrgEff"); hAccTimesEff = (TH1F*)hRecoEvts->Clone("hAccTimesEff"); hAccTimesEffEB = (TH1F*)hRecoEvtsEB->Clone("hAccTimesEffEB"); hAccTimesEffEE = (TH1F*)hRecoEvtsEE->Clone("hAccTimesEffEE"); hAccTimesEffEle = (TH1F*)hRecoEleEvts->Clone("hAccTimesEffEle"); hAccTimesEffEleEB = (TH1F*)hRecoEleEvtsEB->Clone("hAccTimesEffEleEB"); hAccTimesEffEleEE = (TH1F*)hRecoEleEvtsEE->Clone("hAccTimesEffEleEE"); hAccTimesEffMu = (TH1F*)hRecoMuEvts->Clone("hAccTimesEffMu"); hAccTimesEffNoTrg = (TH1F*)hRecoNoTrgEvts->Clone("hAccTimesEffNoTrg"); //hAccTimesEffNoTrgEB = (TH1F*)hRecoNoTrgEvtsEB->Clone("hAccTimesEffNoTrgEB"); //hAccTimesEffNoTrgEE = (TH1F*)hRecoNoTrgEvtsEE->Clone("hAccTimesEffNoTrgEE"); hAccTimesEffNoTrgEle = (TH1F*)hRecoNoTrgEleEvts->Clone("hAccTimesEffNoTrgEle"); hAccTimesEffNoTrgEleEB = (TH1F*)hRecoNoTrgEleEvtsEB->Clone("hAccTimesEffNoTrgEleEB"); hAccTimesEffNoTrgEleEE = (TH1F*)hRecoNoTrgEleEvtsEE->Clone("hAccTimesEffNoTrgEleEE"); hAccTimesEffNoTrgMu = (TH1F*)hRecoNoTrgMuEvts->Clone("hAccTimesEffNoTrgMu"); hEffAftTrg = (TH1F*)hRecoEvts->Clone("hAccTimesEff"); hEffAftTrgEle = (TH1F*)hRecoEleEvts->Clone("hAccTimesEffEle"); hEffAftTrgEleEB = (TH1F*)hRecoEleEvtsEB->Clone("hAccTimesEffEleEB"); hEffAftTrgEleEE = (TH1F*)hRecoEleEvtsEE->Clone("hAccTimesEffEleEE"); hEffAftTrgMu = (TH1F*)hRecoMuEvts->Clone("hAccTimesEffMu"); hTrgRecoVsReco = (TH1F*)hRecoEvts->Clone("hTrgRecoVsReco"); //hTrgRecoVsRecoEB = (TH1F*)hRecoEvtsEB->Clone("hTrgRecoVsRecoEB"); //hTrgRecoVsRecoEE = (TH1F*)hRecoEvtsEE->Clone("hTrgRecoVsRecoEE"); hTrgRecoVsRecoEle = (TH1F*)hRecoEleEvts->Clone("hTrgRecoVsRecoEle"); hTrgRecoVsRecoEleEB = (TH1F*)hRecoEleEvtsEB->Clone("hTrgRecoVsRecoEleEB"); hTrgRecoVsRecoEleEE = (TH1F*)hRecoEleEvtsEE->Clone("hTrgRecoVsRecoEleEE"); hTrgRecoVsRecoMu = (TH1F*)hRecoMuEvts->Clone("hTrgRecoVsRecoMu"); hAcc->Divide(hGenEvts); hAccEle->Divide(hGenEvts); hAccEleEB->Divide(hGenEvts); hAccEleEE->Divide(hGenEvts); hAccMu->Divide(hGenEvts); hAccTimesTrgEff->Divide(hGenEvts); hTrgEff->Divide(hGenEvtsInAcc); hAccTimesEff->Divide(hGenEvts); hAccTimesEffEB->Divide(hGenEvts); hAccTimesEffEE->Divide(hGenEvts); hAccTimesEffEle->Divide(hGenEvts); hAccTimesEffEleEB->Divide(hGenEvts); hAccTimesEffEleEE->Divide(hGenEvts); hAccTimesEffMu->Divide(hGenEvts); hAccTimesEffNoTrg->Divide(hGenEvts); //hAccTimesEffNoTrgEB->Divide(hGenEvts); //hAccTimesEffNoTrgEE->Divide(hGenEvts); hAccTimesEffNoTrgEle->Divide(hGenEvts); hAccTimesEffNoTrgEleEB->Divide(hGenEvts); hAccTimesEffNoTrgEleEE->Divide(hGenEvts); hAccTimesEffNoTrgMu->Divide(hGenEvts); hEffAftTrg->Divide(hTrgEvts); hEffAftTrgEle->Divide(hTrgEvts); hEffAftTrgEleEB->Divide(hTrgEvts); hEffAftTrgEleEE->Divide(hTrgEvts); hEffAftTrgMu->Divide(hTrgEvts); hTrgRecoVsReco->Divide(hRecoNoTrgEvts); //hTrgRecoVsRecoEB->Divide(hRecoNoTrgEvtsEB); //hTrgRecoVsRecoEE->Divide(hRecoNoTrgEvtsEE); hTrgRecoVsRecoEle->Divide(hRecoNoTrgEleEvts); hTrgRecoVsRecoEleEB->Divide(hRecoNoTrgEleEvtsEB); hTrgRecoVsRecoEleEE->Divide(hRecoNoTrgEleEvtsEE); hTrgRecoVsRecoMu->Divide(hRecoNoTrgMuEvts); // plot TCanvas *accTimesEffPlot = new TCanvas("accTimesEffPlot", "acc x eff", 100, 100, 600, 600); TPad *accTimesEffPad = new TPad("accTimesEffPad", "acc x eff pad", 0., 0., 1., 1.); accTimesEffPad->SetBottomMargin(0.12); accTimesEffPad->SetBorderMode(0); accTimesEffPad->SetBorderSize(2); accTimesEffPad->SetFrameBorderMode(0); accTimesEffPad->SetFillColor(0); accTimesEffPad->SetFrameFillColor(0); accTimesEffPad->SetLeftMargin(0.11); accTimesEffPad->SetRightMargin(0.09); accTimesEffPad->SetTopMargin(0.08); accTimesEffPad->SetTickx(1); accTimesEffPad->SetTicky(1); accTimesEffPad->Draw(); accTimesEffPad->cd(); gStyle->SetTitleFont(font); gStyle->SetLabelFont(font); gStyle->SetLegendFont(font); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetOptFit(1111); gStyle->SetTitleXOffset(1.); gStyle->SetTitleYOffset(1.3); gPad->SetTicks(1, 1); gPad->SetGrid(1, 1); TH1F* hAccTimesEff2 = (TH1F*)hAccTimesEff->Clone("hAccTimesEff2"); TF1 *fitFunc = new TF1("fitFunc", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.); //TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2])", 10., 5010.); TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.); TF1 *fitFuncEE = new TF1("fitFuncEE", "[0] + [1]/ (x*x + [2])", 10., 5010.); fitFunc->SetLineColor(kBlue); fitFuncEB->SetLineColor(kBlue); fitFuncEE->SetLineColor(kBlue); hAccTimesEff->Fit("fitFunc", "", "", 480., 5010.); hAccTimesEffEB->Fit("fitFuncEB", "", "", 480., 5010.); hAccTimesEffEE->Fit("fitFuncEE", "", "", 480., 5010.); cout << "Chi^2 / NDF: " << fitFunc->GetChisquare() << " / " << fitFunc->GetNDF() << ", prob: " << fitFunc->GetProb() << endl; cout << "Chi^2 / NDF EB: " << fitFuncEB->GetChisquare() << " / " << fitFuncEB->GetNDF() << ", prob: " << fitFuncEB->GetProb() << endl; cout << "Chi^2 / NDF EE: " << fitFuncEE->GetChisquare() << " / " << fitFuncEE->GetNDF() << ", prob: " << fitFuncEE->GetProb() << endl; hAccTimesEff->GetYaxis()->SetTitle("acc x eff"); hAccTimesEff->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEff->Draw(); TLatex *tex = new TLatex(0.22, 0.21, "P(M|p0,p1,p2,p3) = p0 + #frac{p1}{M+p2} + p3*M"); tex->SetNDC(); tex->SetTextFont(font); tex->SetLineWidth(2); tex->SetTextSize(0.03); tex->Draw(); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.17, 0.85, "trg + electron + muon"); TCanvas *accTimesEffPlotEB = new TCanvas("accTimesEffPlotEB", "acc x eff, barrel electron + muon", 100, 100, 600, 600); TPad *accTimesEffPadEB = (TPad*)accTimesEffPad->Clone("accTimesEffPadEB"); accTimesEffPadEB->Draw(); accTimesEffPadEB->cd(); hAccTimesEffEB->GetYaxis()->SetTitle("acc x eff"); hAccTimesEffEB->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEffEB->Draw(); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); //tex->DrawLatex(0.46, 0.21, "P(M|p0,p1,p2) = p0 + #frac{p1}{M+p2}"); tex->DrawLatex(0.22, 0.21, "P(M|p0,p1,p2,p3) = p0 + #frac{p1}{M+p2} + p3*M"); tex->DrawLatex(0.17, 0.85, "trg + barrel electron + muon"); TCanvas *accTimesEffPlotEE = new TCanvas("accTimesEffPlotEE", "acc x eff, endcap electron + muon", 100, 100, 600, 600); TPad *accTimesEffPadEE = (TPad*)accTimesEffPad->Clone("accTimesEffPadEE"); accTimesEffPadEE->Draw(); accTimesEffPadEE->cd(); hAccTimesEffEE->GetYaxis()->SetTitle("acc x eff"); hAccTimesEffEE->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEffEE->Draw(); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.45, 0.38, "P(M|p0,p1,p2) = p0 + #frac{p1}{M^{2}+p2}"); tex->DrawLatex(0.17, 0.85, "trg + endcap electron + muon"); TCanvas *accTimesEffObjPlot = new TCanvas("accTimesEffObjPlot", "acc x eff, objects", 100, 100, 600, 600); TPad *accTimesEffObjPad = (TPad*)accTimesEffPad->Clone("accTimesEffObjPad"); accTimesEffObjPad->Draw(); accTimesEffObjPad->cd(); hAccTimesEffEle->GetYaxis()->SetTitle("acc x eff"); hAccTimesEffEle->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEffEle->SetMarkerStyle(kFullSquare); hAccTimesEffEle->SetMarkerColor(kViolet); hAccTimesEffEle->SetLineColor(kViolet); hAccTimesEffEle->Draw(); hAccTimesEffEleEB->SetMarkerStyle(kFullTriangleUp); hAccTimesEffEleEB->SetMarkerColor(kRed); hAccTimesEffEleEB->SetLineColor(kRed); hAccTimesEffEleEB->Draw("same"); hAccTimesEffEleEE->SetMarkerStyle(kFullTriangleDown); hAccTimesEffEleEE->SetMarkerColor(kBlue); hAccTimesEffEleEE->SetLineColor(kBlue); hAccTimesEffEleEE->Draw("same"); hAccTimesEffMu->SetMarkerStyle(34); hAccTimesEffMu->SetMarkerColor(kGreen+1); hAccTimesEffMu->SetLineColor(kGreen+1); hAccTimesEffMu->Draw("same"); hAccTimesEff2->Draw("same"); TLegend* legend = new TLegend(0.592, 0.279, 0.881, 0.467); legend->SetTextFont(font); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetLineColor(1); legend->SetLineStyle(1); legend->SetLineWidth(1); legend->SetFillColor(19); legend->SetFillStyle(0); legend->AddEntry(hAccTimesEff, "total acc x eff"); legend->AddEntry(hAccTimesEffMu, "muons"); legend->AddEntry(hAccTimesEffEle, "all electrons"); legend->AddEntry(hAccTimesEffEleEB, "barrel electrons"); legend->AddEntry(hAccTimesEffEleEE, "endcap electrons"); legend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.17, 0.85, "trg: HLT_Mu22_Photon22_CaloIdL"); // acc x eff with no trg applied TCanvas *accTimesEffNoTrgObjPlot = new TCanvas("accTimesEffNoTrgObjPlot", "acc x eff, no trigger, objects", 100, 100, 600, 600); TPad *accTimesEffNoTrgObjPad = (TPad*)accTimesEffPad->Clone("accTimesEffNoTrgObjPad"); accTimesEffNoTrgObjPad->Draw(); accTimesEffNoTrgObjPad->cd(); hAccTimesEffNoTrgEle->GetYaxis()->SetTitle("acc x eff"); hAccTimesEffNoTrgEle->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEffNoTrgEle->SetMarkerStyle(kFullSquare); hAccTimesEffNoTrgEle->SetMarkerColor(kViolet); hAccTimesEffNoTrgEle->SetLineColor(kViolet); hAccTimesEffNoTrgEle->Draw(); hAccTimesEffNoTrgEleEB->SetMarkerStyle(kFullTriangleUp); hAccTimesEffNoTrgEleEB->SetMarkerColor(kRed); hAccTimesEffNoTrgEleEB->SetLineColor(kRed); hAccTimesEffNoTrgEleEB->Draw("same"); hAccTimesEffNoTrgEleEE->SetMarkerStyle(kFullTriangleDown); hAccTimesEffNoTrgEleEE->SetMarkerColor(kBlue); hAccTimesEffNoTrgEleEE->SetLineColor(kBlue); hAccTimesEffNoTrgEleEE->Draw("same"); hAccTimesEffNoTrgMu->SetMarkerStyle(34); hAccTimesEffNoTrgMu->SetMarkerColor(kGreen+1); hAccTimesEffNoTrgMu->SetLineColor(kGreen+1); hAccTimesEffNoTrgMu->Draw("same"); hAccTimesEffNoTrg->Draw("same"); TLegend* accXeffNoTrg = (TLegend*)legend->Clone("effAftTrgLegend"); accXeffNoTrg->Clear(); accXeffNoTrg->AddEntry(hAccTimesEffNoTrg, "total acc x eff"); accXeffNoTrg->AddEntry(hAccTimesEffNoTrgMu, "muons"); accXeffNoTrg->AddEntry(hAccTimesEffNoTrgEle, "all electrons"); accXeffNoTrg->AddEntry(hAccTimesEffNoTrgEleEB, "barrel electrons"); accXeffNoTrg->AddEntry(hAccTimesEffNoTrgEleEE, "endcap electrons"); accXeffNoTrg->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.17, 0.85, "trg: none"); // efficiency on triggered events TCanvas *effAftTrgPlot = new TCanvas("effAftTrgPlot", "efficiency after trigger", 100, 100, 600, 600); TPad *effAftTrgPad = (TPad*)accTimesEffPad->Clone("effAftTrgPad"); effAftTrgPad->Draw(); effAftTrgPad->cd(); hEffAftTrgEle->GetYaxis()->SetTitle("eff"); hEffAftTrgEle->GetYaxis()->SetRangeUser(0., 1.); hEffAftTrgEle->SetMarkerStyle(kFullSquare); hEffAftTrgEle->SetMarkerColor(kViolet); hEffAftTrgEle->SetLineColor(kViolet); hEffAftTrgEle->Draw(); hEffAftTrgEleEB->SetMarkerStyle(kFullTriangleUp); hEffAftTrgEleEB->SetMarkerColor(kRed); hEffAftTrgEleEB->SetLineColor(kRed); hEffAftTrgEleEB->Draw("same"); hEffAftTrgEleEE->SetMarkerStyle(kFullTriangleDown); hEffAftTrgEleEE->SetMarkerColor(kBlue); hEffAftTrgEleEE->SetLineColor(kBlue); hEffAftTrgEleEE->Draw("same"); hEffAftTrgMu->SetMarkerStyle(34); hEffAftTrgMu->SetMarkerColor(kGreen+1); hEffAftTrgMu->SetLineColor(kGreen+1); hEffAftTrgMu->Draw("same"); hEffAftTrg->Draw("same"); TLegend* effAftTrgLegend = (TLegend*)legend->Clone("effAftTrgLegend"); effAftTrgLegend->Clear(); effAftTrgLegend->AddEntry(hEffAftTrg, "total eff after trigger"); effAftTrgLegend->AddEntry(hEffAftTrgMu, "muons"); effAftTrgLegend->AddEntry(hEffAftTrgEle, "all electrons"); effAftTrgLegend->AddEntry(hEffAftTrgEleEB, "barrel electrons"); effAftTrgLegend->AddEntry(hEffAftTrgEleEE, "endcap electrons"); effAftTrgLegend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.14, 0.15, "trg: HLT_Mu22_Photon22_CaloIdL"); // acceptance TCanvas *accPlot = new TCanvas("accPlot", "acc", 100, 100, 600, 600); TPad *accPad = (TPad*)accTimesEffPad->Clone("accPad"); accPad->Draw(); accPad->cd(); hAcc->GetYaxis()->SetTitle("acc"); hAcc->GetYaxis()->SetRangeUser(0., 1.); hAccEle->SetMarkerStyle(kFullSquare); hAccEle->SetMarkerColor(kViolet); hAccEle->SetLineColor(kViolet); hAccEle->Draw(); hAccEleEB->SetMarkerStyle(kFullTriangleUp); hAccEleEB->SetMarkerColor(kRed); hAccEleEB->SetLineColor(kRed); hAccEleEB->Draw("same"); hAccEleEE->SetMarkerStyle(kFullTriangleDown); hAccEleEE->SetMarkerColor(kBlue); hAccEleEE->SetLineColor(kBlue); hAccEleEE->Draw("same"); hAccMu->SetMarkerStyle(34); hAccMu->SetMarkerColor(kGreen+1); hAccMu->SetLineColor(kGreen+1); hAccMu->Draw("same"); hAcc->Draw("same"); TLegend* accLegend = (TLegend*)legend->Clone("accLegend"); accLegend->Clear(); accLegend->AddEntry(hAcc, "total acceptance"); accLegend->AddEntry(hAccMu, "muons"); accLegend->AddEntry(hAccEle, "all electrons"); accLegend->AddEntry(hAccEleEB, "barrel electrons"); accLegend->AddEntry(hAccEleEE, "endcap electrons"); accLegend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); // reco with trg vs. reco TCanvas *trgRecoVsRecoPlot = new TCanvas("trgRecoVsRecoPlot", "reco with trg vs. reco", 100, 100, 600, 600); TPad *trgRecoVsRecoPad = (TPad*)accTimesEffPad->Clone("trgRecoVsRecoPad"); trgRecoVsRecoPad->Draw(); trgRecoVsRecoPad->cd(); hTrgRecoVsRecoEle->GetYaxis()->SetTitle("eff"); hTrgRecoVsRecoEle->GetYaxis()->SetRangeUser(0., 1.); hTrgRecoVsRecoEle->SetMarkerStyle(kFullSquare); hTrgRecoVsRecoEle->SetMarkerColor(kViolet); hTrgRecoVsRecoEle->SetLineColor(kViolet); hTrgRecoVsRecoEle->Draw(); //hTrgRecoVsRecoEleEB->SetMarkerStyle(kFullTriangleUp); //hTrgRecoVsRecoEleEB->SetMarkerColor(kRed); //hTrgRecoVsRecoEleEB->SetLineColor(kRed); //hTrgRecoVsRecoEleEB->Draw("same"); //hTrgRecoVsRecoEleEE->SetMarkerStyle(kFullTriangleDown); //hTrgRecoVsRecoEleEE->SetMarkerColor(kBlue); //hTrgRecoVsRecoEleEE->SetLineColor(kBlue); //hTrgRecoVsRecoEleEE->Draw("same"); hTrgRecoVsRecoMu->SetMarkerStyle(34); hTrgRecoVsRecoMu->SetMarkerColor(kGreen+1); hTrgRecoVsRecoMu->SetLineColor(kGreen+1); hTrgRecoVsRecoMu->Draw("same"); hTrgRecoVsReco->Draw("same"); TLegend* trgRecoVsRecoLegend = (TLegend*)legend->Clone("trgRecoVsRecoLegend"); trgRecoVsRecoLegend->Clear(); trgRecoVsRecoLegend->AddEntry(hTrgRecoVsReco, "total"); trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoMu, "muons"); trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoEle, "electrons"); //trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoEleEB, "barrel electrons"); //trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoEleEE, "endcap electrons"); trgRecoVsRecoLegend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); TCanvas *accTimesTrgEffPlot = new TCanvas("accTimesTrgEffPlot", "acc x trigger eff", 100, 100, 600, 600); TPad *accTimesTrgEffPad = (TPad*)accTimesEffPad->Clone("accTimesTrgEffPad"); accTimesTrgEffPad->Draw(); accTimesTrgEffPad->cd(); hAccTimesTrgEff->GetYaxis()->SetTitle("acc x trg eff"); hAccTimesTrgEff->GetYaxis()->SetRangeUser(0., 1.); hAccTimesTrgEff->SetMarkerStyle(20); hAccTimesTrgEff->SetMarkerColor(kCyan); hAccTimesTrgEff->SetLineColor(kCyan); hAccTimesTrgEff->Draw(); hTrgEff->SetMarkerStyle(21); hTrgEff->SetMarkerColor(kMagenta); hTrgEff->SetLineColor(kMagenta); hTrgEff->Draw("same"); TLegend* trgLegend = (TLegend*)legend->Clone("trgLegend"); trgLegend->Clear(); trgLegend->AddEntry(hTrgEff, "trigger eff in acc"); trgLegend->AddEntry(hAccTimesTrgEff, "acc x trigger eff"); trgLegend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); // safe in various file formats if (saveSpec) { if (saveAsPdf) { accTimesTrgEffPlot->Print(plotDir + accTimesTrgEffPlot->GetName() + ".pdf", "pdf"); accTimesEffPlot->Print(plotDir + accTimesEffPlot->GetName() + ".pdf", "pdf"); accTimesEffPlotEB->Print(plotDir + accTimesEffPlotEB->GetName() + ".pdf", "pdf"); accTimesEffPlotEE->Print(plotDir + accTimesEffPlotEE->GetName() + ".pdf", "pdf"); accTimesEffObjPlot->Print(plotDir + accTimesEffObjPlot->GetName() + ".pdf", "pdf"); accTimesEffNoTrgObjPlot->Print(plotDir + accTimesEffNoTrgObjPlot->GetName() + ".pdf", "pdf"); effAftTrgPlot->Print(plotDir + effAftTrgPlot->GetName() + ".pdf", "pdf"); trgRecoVsRecoPlot->Print(plotDir + trgRecoVsRecoPlot->GetName() + ".pdf", "pdf"); accPlot->Print(plotDir + accPlot->GetName() + ".pdf", "pdf"); } if (saveAsPng) { accTimesTrgEffPlot->Print(plotDir + accTimesTrgEffPlot->GetName() + ".png", "png"); accTimesEffPlot->Print(plotDir + accTimesEffPlot->GetName() + ".png", "png"); accTimesEffPlotEB->Print(plotDir + accTimesEffPlotEB->GetName() + ".png", "png"); accTimesEffPlotEE->Print(plotDir + accTimesEffPlotEE->GetName() + ".png", "png"); accTimesEffObjPlot->Print(plotDir + accTimesEffObjPlot->GetName() + ".png", "png"); accTimesEffNoTrgObjPlot->Print(plotDir + accTimesEffNoTrgObjPlot->GetName() + ".png", "png"); effAftTrgPlot->Print(plotDir + effAftTrgPlot->GetName() + ".png", "png"); trgRecoVsRecoPlot->Print(plotDir + trgRecoVsRecoPlot->GetName() + ".png", "png"); accPlot->Print(plotDir + accPlot->GetName() + ".png", "png"); } if (saveAsRoot) { accTimesTrgEffPlot->Print(plotDir + accTimesTrgEffPlot->GetName() + ".root", "root"); accTimesEffPlot->Print(plotDir + accTimesEffPlot->GetName() + ".root", "root"); accTimesEffPlotEB->Print(plotDir + accTimesEffPlotEB->GetName() + ".root", "root"); accTimesEffPlotEE->Print(plotDir + accTimesEffPlotEE->GetName() + ".root", "root"); accTimesEffObjPlot->Print(plotDir + accTimesEffObjPlot->GetName() + ".root", "root"); accTimesEffNoTrgObjPlot->Print(plotDir + accTimesEffNoTrgObjPlot->GetName() + ".root", "root"); effAftTrgPlot->Print(plotDir + effAftTrgPlot->GetName() + ".root", "root"); trgRecoVsRecoPlot->Print(plotDir + trgRecoVsRecoPlot->GetName() + ".root", "root"); accPlot->Print(plotDir + accPlot->GetName() + ".root", "root"); } } // write histos to file output->cd(); hGenEvts->Write(); hGenEvtsEleInAcc->Write(); hGenEvtsEleInAccEB->Write(); hGenEvtsEleInAccEE->Write(); hGenEvtsMuInAcc->Write(); hGenEvtsInAcc->Write(); hTrgEvts->Write(); hRecoEvts->Write(); hRecoEvtsEB->Write(); hRecoEvtsEE->Write(); hRecoEleEvts->Write(); hRecoEleEvtsEB->Write(); hRecoEleEvtsEE->Write(); hRecoMuEvts->Write(); hAccEle->Write(); hAccEleEB->Write(); hAccEleEE->Write(); hAccMu->Write(); hAccTimesTrgEff->Write(); hTrgEff->Write(); hAccTimesEff->Write(); hAccTimesEffEB->Write(); hAccTimesEffEE->Write(); hAccTimesEffEle->Write(); hAccTimesEffEleEB->Write(); hAccTimesEffEleEE->Write(); hAccTimesEffMu->Write(); hEffAftTrg->Write(); hEffAftTrgEle->Write(); hEffAftTrgEleEB->Write(); hEffAftTrgEleEE->Write(); hEffAftTrgMu->Write(); fitFunc->Write(); fitFuncEB->Write(); fitFuncEE->Write(); output->Close(); timer.Stop(); timer.Print(); }
void getX0() { gROOT->Reset(); gROOT->LoadMacro("fitfun.C"); // fit function for localY, local Z const Int_t N = 120; const Int_t M = 7; // number of module angle groups //histograms to check the par2 and par3 distributions TH1D *hPar2 = new TH1D("Par2","",500,0., 5.); TH1D *hPar3 = new TH1D("Par3","",500,0., 1.); Double_t a[M] = {0., 16., 20., 22., 26., 30., 32.}; TH2D *zLocal2D[M]; TH1D *zLocal[N][M]; TFile *fin = new TFile("align.root"); for(int j=0;j<M;j++) { char inhis[100]; sprintf(inhis,"zLocal_%d",j); zLocal2D[j] = (TH2D *)fin->Get(inhis); zLocal2D[j]->RebinY(5); for(int i=0;i<N;i++) { char hisname[100]; sprintf(hisname,"Tray_%d_A_%d",i+1,j); zLocal[i][j] = zLocal2D[j]->ProjectionY(hisname,i+1,i+1); zLocal[i][j]->Sumw2(); } } TF1 *fitfun = new TF1("fitfun",fitfun,-6.,6.,5); double t[N]; double z0[N][M], ze[N][M]; gStyle->SetOptStat(101); gStyle->SetOptFit(100); gStyle->SetTextSize(0.06); gStyle->SetTextFont(42); TCanvas *c1 = new TCanvas("c1","c1",0,0,800,600); c1->SetFillColor(10); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->Divide(4,3); TPostScript *ps = new TPostScript("fig/xLocalFit.ps",112); for(int j=0;j<M;j++) { for(int i=0;i<N;i++) { t[i] = i+1; // tray number if(i%12==0) ps->NewPage(); // 12 trays per page c1->cd(i%12+1); double par[5], err[5]; fitfun->SetParameters(0., zLocal[i][j]->GetBinContent(50), 0.1, 1., 0.); fitfun->SetLineWidth(2); zLocal[i][j]->Draw("e"); double entries = zLocal[i][j]->Integral(1,100); if(entries>10) { fitfun->SetParLimits(0, -3., 3.); fitfun->SetParLimits(2, 2.9, 3.1); fitfun->SetParLimits(3, 0.01, 0.16); zLocal[i][j]->Fit("fitfun","R"); fitfun->GetParameters(&par[0]); err[0] = fitfun->GetParError(0); } else { par[0] = 0.; err[0] = 0.; } hPar2->Fill(par[2]); hPar3->Fill(par[3]); char text[100]; sprintf(text, "Z0 = %5.3f #pm %5.3f", par[0], err[0]); TLatex *tex = new TLatex(-3, par[1]/3., text); tex->SetTextSize(0.07); tex->SetTextFont(12); tex->Draw("same"); z0[i][j] = par[0]; ze[i][j] = err[0]; c1->Update(); } } gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetEndErrorSize(0.01); TF1 *fitangle = new TF1("fitangle","[0]*sin(x*3.14159/180.)+[1]",-10.,40.); double z00[N], ze0[N]; // angle=0 modules zOffset double z0F[N], zeF[N]; // angle=0 modules zOffset after fitangle fit double x0[N], xe[N]; for(int i=0;i<N;i++) { if(i%12==0) ps->NewPage(); // 12 trays per page c1->cd(i%12+1); z00[i] = z0[i][0]; ze0[i] = ze[i][0]; double x1 = -10.; double x2 = 50.; double y1 = -2.5; double y2 = 1.5; char title[100]; sprintf(title,"Tray_%d",i+1); TH1D *h0 = new TH1D("h0",title,1, x1, x2); h0->SetMinimum(y1); h0->SetMaximum(y2); h0->GetXaxis()->SetNdivisions(208); h0->GetXaxis()->CenterTitle(); h0->GetXaxis()->SetTitle("Module Angle (deg)"); h0->GetXaxis()->SetTitleOffset(1.0); h0->GetXaxis()->SetTitleSize(0.07); h0->GetXaxis()->SetLabelOffset(0.01); h0->GetXaxis()->SetLabelSize(0.045); h0->GetXaxis()->SetLabelFont(42); h0->GetXaxis()->SetTitleFont(42); h0->GetYaxis()->SetNdivisions(210); h0->GetYaxis()->SetTitle("zLocal Offset"); h0->GetYaxis()->SetTitleOffset(1.0); h0->GetYaxis()->SetTitleSize(0.07); h0->GetYaxis()->SetLabelOffset(0.01); h0->GetYaxis()->SetLabelSize(0.045); h0->GetYaxis()->SetLabelFont(42); h0->GetYaxis()->SetTitleFont(42); h0->Draw(); TGraphErrors *gr = new TGraphErrors(M, a, z0[i], 0, ze[i]); gr->SetMarkerStyle(24); gr->SetMarkerSize(1.5); gr->SetLineWidth(2); gr->Draw("p"); fitangle->SetParameters(-0.5, 0.0); gr->Fit("fitangle","R"); x0[i] = fitangle->GetParameter(0); z0F[i] = fitangle->GetParameter(1); xe[i] = fitangle->GetParError(0); zeF[i] = fitangle->GetParError(1); c1->Update(); } ps->NewPage(); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetEndErrorSize(0.01); TCanvas *c1 = new TCanvas("c1","c1",0,0,800,600); c1->SetFillColor(10); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetLeftMargin(0.14); c1->SetBottomMargin(0.15); c1->SetTopMargin(0.02); c1->SetRightMargin(0.04); c1->Draw(); double x1 = 0.5; double x2 = 120.5; double y1 = -3.; double y2 = 1.; TH1D *h0 = new TH1D("h0","",1, x1, x2); h0->SetMinimum(y1); h0->SetMaximum(y2); h0->GetXaxis()->SetNdivisions(208); h0->GetXaxis()->CenterTitle(); h0->GetXaxis()->SetTitle("Tray #"); h0->GetXaxis()->SetTitleOffset(1.0); h0->GetXaxis()->SetTitleSize(0.07); h0->GetXaxis()->SetLabelOffset(0.01); h0->GetXaxis()->SetLabelSize(0.05); h0->GetXaxis()->SetLabelFont(42); h0->GetXaxis()->SetTitleFont(42); h0->GetYaxis()->SetNdivisions(210); h0->GetYaxis()->SetTitle("zLocal Offset"); h0->GetYaxis()->SetTitleOffset(1.0); h0->GetYaxis()->SetTitleSize(0.07); h0->GetYaxis()->SetLabelOffset(0.01); h0->GetYaxis()->SetLabelSize(0.045); h0->GetYaxis()->SetLabelFont(42); h0->GetYaxis()->SetTitleFont(42); h0->Draw(); TLine *l1 = new TLine(x1,y1,x2,y1); l1->SetLineWidth(3); l1->Draw("same"); TLine *l2 = new TLine(x1,y2,x2,y2); l2->SetLineWidth(3); l2->Draw("same"); TLine *l3 = new TLine(x1,y1,x1,y2); l3->SetLineWidth(3); l3->Draw("same"); TLine *l4 = new TLine(x2,y1,x2,y2); l4->SetLineWidth(3); l4->Draw("same"); TGraphErrors *gr = new TGraphErrors(N, t, z00, 0, ze0); gr->SetMarkerStyle(20); gr->SetMarkerSize(1.5); gr->SetLineWidth(2); gr->Draw("p"); TGraphErrors *gr = new TGraphErrors(N, t, z0F, 0, zeF); gr->SetMarkerStyle(24); gr->SetMarkerSize(1.5); gr->SetLineWidth(2); gr->Draw("p"); c1->Update(); ps->NewPage(); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetEndErrorSize(0.01); TCanvas *c1 = new TCanvas("c1","c1",0,0,800,600); c1->SetFillColor(10); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetLeftMargin(0.14); c1->SetBottomMargin(0.15); c1->SetTopMargin(0.02); c1->SetRightMargin(0.04); c1->Draw(); double x1 = 0.5; double x2 = 120.5; double y1 = -2.; double y2 = 3.; TH1D *h0 = new TH1D("h0","",1, x1, x2); h0->SetMinimum(y1); h0->SetMaximum(y2); h0->GetXaxis()->SetNdivisions(208); h0->GetXaxis()->CenterTitle(); h0->GetXaxis()->SetTitle("Tray #"); h0->GetXaxis()->SetTitleOffset(1.0); h0->GetXaxis()->SetTitleSize(0.07); h0->GetXaxis()->SetLabelOffset(0.01); h0->GetXaxis()->SetLabelSize(0.05); h0->GetXaxis()->SetLabelFont(42); h0->GetXaxis()->SetTitleFont(42); h0->GetYaxis()->SetNdivisions(210); h0->GetYaxis()->SetTitle("xLocal Offset"); h0->GetYaxis()->SetTitleOffset(1.0); h0->GetYaxis()->SetTitleSize(0.07); h0->GetYaxis()->SetLabelOffset(0.01); h0->GetYaxis()->SetLabelSize(0.045); h0->GetYaxis()->SetLabelFont(42); h0->GetYaxis()->SetTitleFont(42); h0->Draw(); TLine *l1 = new TLine(x1,y1,x2,y1); l1->SetLineWidth(3); l1->Draw("same"); TLine *l2 = new TLine(x1,y2,x2,y2); l2->SetLineWidth(3); l2->Draw("same"); TLine *l3 = new TLine(x1,y1,x1,y2); l3->SetLineWidth(3); l3->Draw("same"); TLine *l4 = new TLine(x2,y1,x2,y2); l4->SetLineWidth(3); l4->Draw("same"); TGraphErrors *gr = new TGraphErrors(N, t, x0, 0, xe); gr->SetMarkerStyle(20); gr->SetMarkerSize(1.5); gr->SetLineWidth(2); gr->Draw("p"); c1->Update(); ps->Close(); ofstream outData; outData.open("xOffset.dat"); for(int i=0;i<N;i++) { outData << setw(15) << z00[i] << setw(15) << ze0[i] << setw(15) << x0[i] << setw(15) << xe[i] << endl; } outData.close(); TFile *fout = new TFile("xFitPar.root","recreate"); hPar2->Write(); hPar3->Write(); fout->Close(); }
void cutChecker() { int kCut =2 ;//1:vProb, 2:dca, 3:MatchedStations, 4:ctau/ctauErr int pbpb=false; gROOT->Macro("./cm/logon.C+");//it all looks much nicer with this. // TString fname2011="../dimuonTree_HI2011_fulldataset_trkRot.root"; // TFile *_file0 = TFile::Open(fname2011); // TTree *upsi2011 = (TTree*)_file0->Get("UpsilonTree"); if(pbpb) { TString fname2013=" ../dimuonTree_upsiMiniTree_AA2p76tev_WithIDCuts_RunHIN-15-001_trigBit1_allTriggers0.root";//../dimuonTree_upsiMiniTree_aa276tev_regitreco_glbglb_Runa_trigBit1_allTriggers0_pt4.root"; }else if(!pbpb){ TString fname2013=" ../dimuonTree_upsiMiniTree_pp2p76tev_noIDVars_GlbGlb_RunHIN-15-001_trigBit2_allTriggers0.root"; } //TString fname2013="../upsiMiniTree_pyquen1S_noMuonPtCuts_QQtrigbit1_Trig_analysisOK_20140729_cuts10-006.root"; TFile *_file1 = TFile::Open(fname2013); TTree *upsi2013 = (TTree*)_file1->Get("UpsilonTree"); RooRealVar* upsPt = new RooRealVar("upsPt","p_{T}(#Upsilon)",0,60,"GeV"); // RooRealVar* upsEta = new RooRealVar("upsEta", "upsEta" ,-10,10); RooRealVar* upsRapidity= new RooRealVar("upsRapidity", "upsRapidity",-1000, 1000); RooRealVar* vProb = new RooRealVar("vProb", "vProb" ,0.01,1.00); RooRealVar* _dca = new RooRealVar("_dca", "_dca" ,0.0,5.00); RooRealVar* _ctau = new RooRealVar("_ctau", "_ctau" ,-100,100,"cm"); RooRealVar* _ctauErr = new RooRealVar("_ctauErr", "_ctauErr" ,-100,100,"cm"); RooRealVar* muPlusPt = new RooRealVar("muPlusPt","muPlusPt",3.5,100); RooRealVar* muMinusPt = new RooRealVar("muMinusPt","muMinusPt",3.5,100); RooRealVar* muPlusEta = new RooRealVar("muPlusEta","muPlusEta", -2.4,2.4); RooRealVar* muMinusEta = new RooRealVar("muMinusEta","muMinusEta",-2.4,2.4); RooRealVar* _mupl_StationsMatched = new RooRealVar("_mupl_StationsMatched","_mupl_StationsMatched",0,5); RooRealVar* _mumi_StationsMatched = new RooRealVar("_mumi_StationsMatched","_mumi_StationsMatched",0,5); RooRealVar* muMinusEta = new RooRealVar("muMinusEta","muMinusEta",-2.4,2.4); RooRealVar* mass = new RooRealVar("invariantMass","#mu#mu mass",7,14,"GeV/c^{2}"); TCut cut_acc = " ((muPlusPt >3.5 && muMinusPt>4)||(muPlusPt>4 &&muMinusPt>3.5)) && abs(upsRapidity)<2.4 && (invariantMass<14 && invariantMass>7)"; // cout << "cut: "<< cut_acc.Print() << endl; // TCut cut_add(cutList(1,1)); //cout << "cut: "<< cut_add.Print() << endl; switch (kCut){ case 1: //vProb] RooDataSet *data0 = new RooDataSet("data0","data0",upsi2013, RooArgSet(*mass,*muPlusPt,*muMinusPt,*upsRapidity,*vProb)); string cut[4]={"vProb>0.01",// very loose "vProb>0.05", "vProb>0.1", "vProb>0.2"};//very tight // for plotting purposes... break; case 2: //dca RooDataSet *data0 = new RooDataSet("data0","data0",upsi2013, RooArgSet(*mass,*muPlusPt,*muMinusPt,*upsRapidity,*_dca)); string cut[4]={"_dca<0.004", //very tight "_dca<0.006", "_dca<0.008", "_dca<0.01"}; // very loose break; case 3: // number of matched Stations RooDataSet *data0 = new RooDataSet("data0","data0",upsi2013, RooArgSet(*mass,*muPlusPt,*muMinusPt,*upsRapidity,*_mupl_StationsMatched,*_mumi_StationsMatched)); string cut[4]={ "_mumi_StationsMatched>0&&_mupl_StationsMatched>0", "_mumi_StationsMatched>1&&_mupl_StationsMatched>1", "_mumi_StationsMatched>2&&_mupl_StationsMatched>2", "_mumi_StationsMatched>3&&_mupl_StationsMatched>3"}; string cutname[4]={ "at least one", "more than 1", "more than 2", "more than 3"}; break; case 4: ///fabs(ctau/ctau_err) RooDataSet *data0 = new RooDataSet("data0","data0",upsi2013, RooArgSet(*mass,*muPlusPt,*muMinusPt,*upsRapidity,*_ctau,*_ctauErr)); string cut[4]={"abs(_ctau/_ctauErr)<5",//very loose "abs(_ctau/_ctauErr)<4" , "abs(_ctau/_ctauErr)<3" , "abs(_ctau/_ctauErr)<2" }; //tighter string cutname[4]={"|c#tau/#sigma(c#tau)| < 5", "|c#tau/#sigma(c#tau)| < 4", "|c#tau/#sigma(c#tau)| < 3", "|c#tau/#sigma(c#tau)| < 2"}; break; default: cout<< "no Cut Variable specified!"<<endl; break; } TCut cut_add1((cut[0]).c_str()); TCut cut_add2((cut[1]).c_str()); TCut cut_add3((cut[2]).c_str()); TCut cut_add4((cut[3]).c_str()); TString figName_(Form("%s",(cut[0]).c_str())); figName_.ReplaceAll(">","_gt"); figName_.ReplaceAll("<","_lt"); figName_.ReplaceAll(".","p"); figName_.ReplaceAll("&&","_AND_"); figName_.ReplaceAll("||","_OR_"); figName_.ReplaceAll("(",""); figName_.ReplaceAll("/","-"); figName_.ReplaceAll(")",""); cout << "hello"<< endl; // cut_add.Print(); int nt = data0->sumEntries(); redData1 = ( RooDataSet*) data0->reduce(Cut(cut_acc+cut_add1)); redData1->Print(); TH1D *MReco1; MReco1 = new TH1D("MReco1","Reco di-muon mass",70,7,14); MReco1 = (TH1D*) redData1->createHistogram("invariantMass",*mass); redData2 = ( RooDataSet*) data0->reduce(Cut(cut_acc+cut_add2)); redData2->Print(); TH1D *MReco2; MReco2 = new TH1D("MReco2","Reco di-muon mass",70,7,14); MReco2 = (TH1D*) redData2->createHistogram("invariantMass",*mass); redData3 = ( RooDataSet*) data0->reduce(Cut(cut_acc+cut_add3)); redData3->Print(); TH1D *MReco3; MReco3 = new TH1D("MReco3","Reco di-muon mass",70,7,14); MReco3 = (TH1D*) redData3->createHistogram("invariantMass",*mass); redData4 = ( RooDataSet*) data0->reduce(Cut(cut_acc+cut_add4)); redData4->Print(); TH1D *MReco4; MReco4 = new TH1D("MReco4","Reco di-muon mass",70,7,14); MReco4 = (TH1D*) redData4->createHistogram("invariantMass",*mass); const double M1S = 9.46; //upsilon 1S pgd mass value const double M2S = 10.023; //upsilon 2S pgd mass value const double M3S = 10.355; //upsilon 3S pgd mass value RooRealVar *nsig1f = new RooRealVar("N_{#Upsilon(1S)}","nsig1S",0,nt*10); RooRealVar *nsig2f = new RooRealVar("N_{#Upsilon(2S)}","nsig2S", nt*0.25,-1*nt,10*nt); RooRealVar *nsig3f = new RooRealVar("N_{#Upsilon(3S)}","nsig3S", nt*0.25,-1*nt,10*nt); RooRealVar *mean = new RooRealVar("mass1S","#Upsilon mean",M1S,M1S-0.1,M1S+0.1); RooConstVar *rat2 = new RooConstVar("rat2", "rat2", M2S/M1S); RooConstVar *rat3 = new RooConstVar("rat3", "rat3", M3S/M1S); // scale mean and resolution by mass ratio RooFormulaVar *mean1S = new RooFormulaVar("mean1S","@0",RooArgList(*mean)); RooFormulaVar *mean2S = new RooFormulaVar("mean2S","@0*@1", RooArgList(*mean,*rat2)); RooFormulaVar *mean3S = new RooFormulaVar("mean3S","@0*@1", RooArgList(*mean,*rat3)); //detector resolution ?? where is this coming from? RooRealVar *sigma1 = new RooRealVar("#sigma_{CB1}","#sigma_{CB1}",0,0.5); // RooFormulaVar *sigma1S = new RooFormulaVar("sigma1S","@0" ,RooArgList(*sigma1)); RooFormulaVar *sigma2S = new RooFormulaVar("sigma2S","@0*@1",RooArgList(*sigma1,*rat2)); RooFormulaVar *sigma3S = new RooFormulaVar("sigma3S","@0*@1",RooArgList(*sigma1,*rat3)); RooRealVar *alpha = new RooRealVar("#alpha_{CB}","tail shift",0.01,8); // MC 5tev 1S pol2 RooRealVar *npow = new RooRealVar("npow","power order",1,60); // MC 5tev 1S pol2 RooRealVar *sigmaFraction = new RooRealVar("sigmaFraction","Sigma Fraction",0.,1.); // scale the sigmaGaus with sigma1S*scale=sigmaGaus now. RooRealVar *scaleWidth = new RooRealVar("#sigma_{CB2}/#sigma_{CB1}","scaleWidth",1.,2.7); RooFormulaVar *sigmaGaus = new RooFormulaVar("sigmaGaus","@0*@1", RooArgList(*sigma1,*scaleWidth)); RooFormulaVar *sigmaGaus2 = new RooFormulaVar("sigmaGaus","@0*@1*@2", RooArgList(*sigma1,*scaleWidth,*rat2)); RooFormulaVar *sigmaGaus3 = new RooFormulaVar("sigmaGaus","@0*@1*@2", RooArgList(*sigma1,*scaleWidth,*rat3)); RooCBShape *cb1S_1 = new RooCBShape ("cb1S_1", "FSR cb 1s", *mass,*mean1S,*sigma1,*alpha,*npow); RooCBShape *cb1S_2 = new RooCBShape ("cb1S_2", "FSR cb 1s", *mass,*mean1S,*sigmaGaus,*alpha,*npow); RooAddPdf *sig1S = new RooAddPdf ("cbcb","1S mass pdf", RooArgList(*cb1S_1,*cb1S_2),*sigmaFraction); // /// Upsilon 2S RooCBShape *cb2S_1 = new RooCBShape ("cb2S_1", "FSR cb 2s", *mass,*mean2S,*sigma2S,*alpha,*npow); RooCBShape *cb2S_2 = new RooCBShape ("cb2S_2", "FSR cb 2s", *mass,*mean2S,*sigmaGaus2,*alpha,*npow); RooAddPdf *sig2S = new RooAddPdf ("sig2S","2S mass pdf", RooArgList(*cb2S_1,*cb2S_2),*sigmaFraction); // /// Upsilon 3S RooCBShape *cb3S_1 = new RooCBShape ("cb3S_1", "FSR cb 3s", *mass,*mean3S,*sigma3S,*alpha,*npow); RooCBShape *cb3S_2 = new RooCBShape ("cb3S_2", "FSR cb 3s", *mass,*mean3S,*sigmaGaus3,*alpha,*npow); RooAddPdf *sig3S = new RooAddPdf ("sig3S","3S mass pdf", RooArgList(*cb3S_1,*cb3S_2),*sigmaFraction); // bkg Chebychev RooRealVar *nbkgd = new RooRealVar("n_{Bkgd}","nbkgd",0,nt); RooRealVar *bkg_a1 = new RooRealVar("a1_bkg", "bkg_{a1}", 0, -5, 5); RooRealVar *bkg_a2 = new RooRealVar("a2_Bkg", "bkg_{a2}", 0, -5, 5); RooRealVar *bkg_a3 = new RooRealVar("a3_Bkg", "bkg_{a3}", 0, -2, 2); RooAbsPdf *pdf_combinedbkgd = new RooChebychev("bkgPdf","bkgPdf", *mass, RooArgList(*bkg_a1,*bkg_a2)); RooRealVar turnOn("turnOn","turnOn",2.,8.6); RooRealVar width("width","width",0.3,8.5);// MB 2.63 RooRealVar decay("decay","decay",1,18);// MB: 3.39 RooGenericPdf *ErrPdf = new RooGenericPdf("ErrPdf","ErrPdf", "exp(-@0/decay)*(TMath::Erf((@0-turnOn)/width)+1)", RooArgList(*mass,turnOn,width,decay)); // bkg_a2->setVal(0); // bkg_a2->setConstant(); RooDataHist binnedData1 ("binnedData1","binnedData1",*mass,Import(*MReco1)); RooDataHist binnedData2 ("binnedData2","binnedData2",*mass,Import(*MReco2)); RooDataHist binnedData3 ("binnedData3","binnedData3",*mass,Import(*MReco3)); RooDataHist binnedData4 ("binnedData4","binnedData4",*mass,Import(*MReco4)); RooAbsPdf *pdf = new RooAddPdf ("pdf","total p.d.f.", RooArgList(*sig1S,*sig2S,*sig3S,*ErrPdf), RooArgList(*nsig1f,*nsig2f,*nsig3f,*nbkgd)); npow->setVal(2); npow->setConstant(); //for the plots! TCanvas c; c.cd(); TPad phead("phead","phead",0.05,0.9,1.,1.,0,0,0); phead.Draw(); phead.cd(); TLatex *cms = new TLatex (0.1,0.1,"CMS Internal"); cms->SetTextFont(40); cms->SetTextSize(0.4); cms->SetTextColor(kBlack); cms->Draw(); if(pbpb){ TLatex *pbpb = new TLatex (0.6,0.1,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); pbpb->SetTextFont(42); pbpb->SetTextSize(0.35); pbpb->SetTextColor(kBlack); pbpb->Draw(); }else if(!pbpb){ TLatex *pp = new TLatex (0.6,0.1,"pp #sqrt{s} = 2.76 TeV"); pp->SetTextFont(42); pp->SetTextSize(0.35); pp->SetTextColor(kBlack); pp->Draw(); } TPad pbody("pbody","pbody",0.0,0.0,1.,0.9,0,0,0); c.cd(); pbody.SetLeftMargin(0.15); pbody.Draw(); pbody.cd(); RooPlot* frame = mass->frame(Bins(70),Range(7,14)); // 1st round RooAbsReal* nll1 = pdf->createNLL(binnedData1,NumCPU(4)) ; RooMinuit(*nll1).migrad(); RooMinuit(*nll1).hesse(); binnedData1.plotOn(frame,Name("theData"),MarkerSize(0.6),MarkerStyle(20),MarkerColor(kBlue)); pdf->plotOn(frame,Name("thePdf"),LineColor(kBlue)); double signif1 = nsig1f->getVal()/nsig1f->getError(); double signif1_2s = nsig2f->getVal()/nsig2f->getError(); double signif1_3s = nsig3f->getVal()/nsig3f->getError(); MReco1->SetMarkerSize(1.0); MReco1->SetMarkerStyle(20); MReco1->SetMarkerColor(kBlue); MReco1->Draw("esame"); // 2nd round RooAbsReal* nll2 = pdf->createNLL(binnedData2,NumCPU(4)) ; RooMinuit(*nll2).migrad(); RooMinuit(*nll2).hesse(); binnedData2.plotOn(frame,Name("theData"),MarkerSize(0.6),MarkerStyle(20),MarkerColor(kRed)); pdf->plotOn(frame,Name("thePdf"),LineColor(kRed)); double signif2 = nsig1f->getVal()/nsig1f->getError(); double signif2_2s = nsig2f->getVal()/nsig2f->getError(); double signif2_3s = nsig3f->getVal()/nsig3f->getError(); MReco2->SetMarkerSize(1.0); MReco2->SetMarkerStyle(20); MReco2->SetMarkerColor(kRed); MReco2->Draw("esame"); // 3rd round RooAbsReal* nll3 = pdf->createNLL(binnedData3,NumCPU(4)) ; RooMinuit(*nll3).migrad(); RooMinuit(*nll3).hesse(); binnedData3.plotOn(frame,Name("theData"),MarkerSize(0.6),MarkerStyle(20),MarkerColor(8)); pdf->plotOn(frame,Name("thePdf"),LineColor(8)); double signif3 = nsig1f->getVal()/nsig1f->getError(); double signif3_2s = nsig2f->getVal()/nsig2f->getError(); double signif3_3s = nsig3f->getVal()/nsig3f->getError(); MReco3->SetMarkerSize(1.0); MReco3->SetMarkerStyle(20); MReco3->SetMarkerColor(8); MReco3->Draw("esame"); // 4th round RooAbsReal* nll4 = pdf->createNLL(binnedData4,NumCPU(4)) ; RooMinuit(*nll4).migrad(); RooMinuit(*nll4).hesse(); binnedData4.plotOn(frame,Name("theData"),MarkerSize(0.6),MarkerStyle(20),MarkerColor(28)); pdf->plotOn(frame,Name("thePdf"),LineColor(28)); double signif4 = nsig1f->getVal()/nsig1f->getError(); double signif4_2s = nsig2f->getVal()/nsig2f->getError(); double signif4_3s = nsig3f->getVal()/nsig3f->getError(); // pdf->paramOn(frame,Layout(0.5,0.95,0.9),Parameters(RooArgSet(signif)),Format("N",AutoPrecision(1))); MReco4->SetMarkerSize(1.0); MReco4->SetMarkerStyle(20); MReco4->SetMarkerColor(28); MReco4->Draw("esame"); // and all that. frame->SetTitle(""); frame->GetXaxis()->SetTitle("m_{#mu^{+}#mu^{-}} (GeV/c^{2})"); frame->GetXaxis()->CenterTitle(kTRUE); frame->GetYaxis()->SetTitleOffset(2); frame->GetXaxis()->SetTitleOffset(1.5); frame->Draw(); TLegend *legend = new TLegend(0.5,0.6,0.95,0.9); legend->SetTextSize(0.034); legend->SetFillStyle(0); legend->SetFillColor(0); legend->SetBorderSize(0); legend->SetTextFont(42); legend->AddEntry(MReco1,"1S significance, #Sigma",""); switch (kCut){ case 1: //vProb] legend->AddEntry(MReco1,"Vertex Probability",""); legend->AddEntry(MReco1,Form("%s, #Sigma = %0.2f",cut[0].c_str(),signif1),"p"); legend->AddEntry(MReco2,Form("%s, #Sigma = %0.2f",cut[1].c_str(),signif2),"p"); legend->AddEntry(MReco3,Form("%s, #Sigma = %0.2f",cut[2].c_str(),signif3),"p"); legend->AddEntry(MReco4,Form("%s, #Sigma = %0.2f",cut[3].c_str(),signif4),"p"); break; case 2: legend->AddEntry(MReco1,"Dist. of closest approach",""); legend->AddEntry(MReco1,Form("%s, #Sigma = %0.2f",cut[0].c_str(),signif1),"p"); legend->AddEntry(MReco2,Form("%s, #Sigma = %0.2f",cut[1].c_str(),signif2),"p"); legend->AddEntry(MReco3,Form("%s, #Sigma = %0.2f",cut[2].c_str(),signif3),"p"); legend->AddEntry(MReco4,Form("%s, #Sigma = %0.2f",cut[3].c_str(),signif4),"p"); break; case 3: legend->AddEntry(MReco1,"Stations matched to each track",""); legend->AddEntry(MReco1,Form("%s, #Sigma = %0.2f",cutname[0].c_str(),signif1),"p"); legend->AddEntry(MReco2,Form("%s, #Sigma = %0.2f",cutname[1].c_str(),signif2),"p"); legend->AddEntry(MReco3,Form("%s, #Sigma = %0.2f",cutname[2].c_str(),signif3),"p"); legend->AddEntry(MReco4,Form("%s, #Sigma = %0.2f",cutname[3].c_str(),signif4),"p"); break; case 4: legend->AddEntry(MReco1,"Pseudo-proper decay length",""); legend->AddEntry(MReco1,Form("%s, #Sigma = %0.2f",cutname[0].c_str(),signif1),"p"); legend->AddEntry(MReco2,Form("%s, #Sigma = %0.2f",cutname[1].c_str(),signif2),"p"); legend->AddEntry(MReco3,Form("%s, #Sigma = %0.2f",cutname[2].c_str(),signif3),"p"); legend->AddEntry(MReco4,Form("%s, #Sigma = %0.2f",cutname[3].c_str(),signif4),"p"); break; default: break; } legend->Draw(); // legend->AddEntry(MReco1,Form(",),"f"); // TLatex latex1; // latex1.SetNDC(); // latex1.SetTextSize(0.032); // latex1.DrawLatex(0.35,1.-0.05*2.,Form("significance: #Sigma vs %s",cut[0].c_str())); // latex1.DrawLatex(0.55,1.-0.05*3.,Form(" #Sigma = %f",signif1)); // latex1.DrawLatex(0.55,1.-0.05*4.,Form(" #Sigma = %f",signif2)); // latex1.DrawLatex(0.55,1.-0.05*5.,Form(" #Sigma = %f",signif3)); // latex1.DrawLatex(0.55,1.-0.05*6.,Form(" #Sigma = %f",signif4)); c.Draw(); if(pbpb){ c.SaveAs("~/Desktop/Grenelle/"+figName_+".pdf"); } else if(!pbpb){ c.SaveAs("~/Desktop/Grenelle/"+figName_+"_pp.pdf"); } cout <<" SIGNIFICANCES \\Sigma OF ALL STATES:" << endl; cout << "xxxx - \\Sigma(1S) \& \\Sigma(2S) \& \\Sigma(3S) " <<endl; cout << cut[0].c_str() <<" & "<< signif1 << " &"<< signif1_2s << " & "<< signif1_3s << endl; cout << cut[1].c_str() <<" & "<< signif2 << " &"<< signif2_2s << " & "<< signif2_3s << endl; cout << cut[2].c_str() <<" & "<< signif3 << " &"<< signif3_2s << " & "<< signif3_3s << endl; cout << cut[3].c_str() <<" & "<< signif4 << " &"<< signif4_2s << " & "<< signif4_3s << endl; }
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 = true; bool use470m = true; bool use600m = true; 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); double NULLVec[2][20]; double OscVec[2][1001][7][20]; for(int i = 0; i < 20; i++){ NULLVec[0][i] = 0; NULLVec[1][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; } } } int nbinsE = 0; if (use100m){ std::string temp_name = /*"../MatrixFiles/combined_ntuple_100m_nu_processed_numu.root";*/"../MatrixFiles/combined_ntuple_100m_nu_processed_CoreyBins_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[0][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[0][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; } } delete NULL_100; temp_file.Close(); } if (use470m){ std::string temp_name = /*"../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_numu.root";*/"../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_CoreyBins_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[1][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[1][u][s][i-1] = (OSC_470->GetBinContent(i)); if(OscVec[1][u][s][i-1] != OscVec[1][u][s][i-1]) OscVec[1][u][s][i-1] = NULLVec[1][i-1];//std::cout << "erm, u :" << u << " s : " << s << " E : " << i <<std::endl; } delete OSC_470; } } delete NULL_470; temp_file.Close(); } int nL = 2; 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 < 2; Lrow++){ for(int Erow = 0; Erow < nbinsE; Erow++){ Errj = 0; for(int Lcol = 0; Lcol < 2; 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))); std::cout << M6 (Erri,Errj) << "\t"; 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *ND = new TLatex(.15,.01,"LAr1-ND (100m) "); ND->SetNDC(); ND->SetTextFont(62); ND->SetTextSize(0.04); ND->Draw(); TLatex *MD = new TLatex(.5,.01,"T600 (600m, on axis)"); MD->SetNDC(); MD->SetTextFont(62); MD->SetTextSize(0.04); MD->Draw(); TLatex *ND45 = new TLatex(.05,.15,"LAr1-ND (100m) "); ND45->SetNDC(); ND45->SetTextAngle(90); ND45->SetTextFont(62); ND45->SetTextSize(0.04); ND45->Draw(); TLatex *MD45 = new TLatex(.05,.54,"T600 (600m, on axis)"); 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_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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); ND->Draw(); MD->Draw(); ND45->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_correlation_matrix.pdf"); TCanvas* c5 = new TCanvas("c5","",700,700); c5->SetLeftMargin(.1); c5->SetBottomMargin(.1); c5->SetTopMargin(.075); c5->SetRightMargin(.15); c5->cd(); M5.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("K^{+} Covariance 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{+} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c5->Print("mult5_matrix.pdf"); TCanvas* c51 = new TCanvas("c51","",700,700); c51->SetLeftMargin(.1); c51->SetBottomMargin(.1); c51->SetTopMargin(.075); c51->SetRightMargin(.15); c51->cd(); C5.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{+} Correlation 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{+} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c51->Print("mult5_correlation_matrix.pdf"); TCanvas* c4 = new TCanvas("c4","",700,700); c4->SetLeftMargin(.1); c4->SetBottomMargin(.1); c4->SetTopMargin(.075); c4->SetRightMargin(.15); c4->cd(); M4.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{-} Covariance 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{-} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c4->Print("mult4_matrix.pdf"); TCanvas* c41 = new TCanvas("c41","",700,700); c41->SetLeftMargin(.1); c41->SetBottomMargin(.1); c41->SetTopMargin(.075); c41->SetRightMargin(.15); c41->cd(); C4.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{-} Correlation 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{-} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c41->Print("mult4_correlation_matrix.pdf"); TCanvas* c3 = new TCanvas("c3","",700,700); c3->SetLeftMargin(.1); c3->SetBottomMargin(.1); c3->SetTopMargin(.075); c3->SetRightMargin(.15); c3->cd(); M3.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{0} Covariance 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{0} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c3->Print("mult3_matrix.pdf"); TCanvas* c31 = new TCanvas("c31","",700,700); c31->SetLeftMargin(.1); c31->SetBottomMargin(.1); c31->SetTopMargin(.075); c31->SetRightMargin(.15); c31->cd(); C3.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{0} Correlation 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{0} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c31->Print("mult3_correlation_matrix.pdf"); TCanvas* c2 = new TCanvas("c2","",700,700); c2->SetLeftMargin(.1); c2->SetBottomMargin(.1); c2->SetTopMargin(.075); c2->SetRightMargin(.15); c2->cd(); M2.Draw("COLZ"); gStyle->SetPalette(56,0); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->SetContour(999); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{+} Covariance 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{+} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c2->Print("mult2_matrix.pdf"); TCanvas* c21 = new TCanvas("c21","",700,700); c21->SetLeftMargin(.1); c21->SetBottomMargin(.1); c21->SetTopMargin(.075); c21->SetRightMargin(.15); c21->cd(); C2.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{+} Correlation 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{+} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c21->Print("mult2_correlation_matrix.pdf"); TCanvas* c1 = new TCanvas("c1","",700,700); c1->SetLeftMargin(.1); c1->SetBottomMargin(.1); c1->SetTopMargin(.075); c1->SetRightMargin(.15); c1->cd(); M1.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{-} Covariance 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{-} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c1->Print("mult1_matrix.pdf"); TCanvas* c11 = new TCanvas("c11","",700,700); c11->SetLeftMargin(.1); c11->SetBottomMargin(.1); c11->SetTopMargin(.075); c11->SetRightMargin(.15); c11->cd(); C1.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{-} Correlation 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{-} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c11->Print("mult1_correlation_matrix.pdf"); TCanvas* c0 = new TCanvas("c0","",700,700); c0->SetLeftMargin(.1); c0->SetBottomMargin(.1); c0->SetTopMargin(.075); c0->SetRightMargin(.15); c0->cd(); M0.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Beam UniSim Covariance 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Beam Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c0->Print("mult0_matrix.pdf"); TCanvas* c01 = new TCanvas("c01","",700,700); c01->SetLeftMargin(.1); c01->SetBottomMargin(.1); c01->SetTopMargin(.075); c01->SetRightMargin(.15); c01->cd(); C0.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Beam UniSim Correlation 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); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Beam Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c01->Print("mult0_correlation_matrix.pdf"); TCanvas* c86 = new TCanvas("c86","",800,400); c86->SetLeftMargin(.1); c86->SetBottomMargin(.1); c86->SetTopMargin(.05); c86->SetRightMargin(.05); c86->cd(); Fig6->GetYaxis()->SetTitle("Fractional Error"); Fig6->GetYaxis()->SetTitleFont(62); Fig6->GetXaxis()->SetTitleFont(62); Fig6->GetYaxis()->SetLabelFont(62); Fig6->GetXaxis()->SetLabelFont(62); Fig6->GetYaxis()->CenterTitle(); Fig6->GetYaxis()->SetTitleSize(0.06); Fig6->GetYaxis()->SetTitleOffset(0.8); Fig6->GetXaxis()->SetLabelSize(0.06); Fig6->GetYaxis()->SetLabelSize(0.06); Fig6->GetXaxis()->SetTitleOffset(1.5); Fig6->SetStats(0); Fig6->SetMinimum(-0.01); Fig6->SetMaximum(0.21); Fig6->SetMarkerStyle(8); Fig6->GetYaxis()->SetNdivisions(509); Fig6->GetXaxis()->SetNdivisions(509); Fig6->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); TLatex *ND = new TLatex(.23,.85,"LAr1-ND (100m) "); ND->SetNDC(); ND->SetTextFont(62); ND->SetTextSize(0.05); ND->Draw(); TLatex *MD = new TLatex(.65,.85,"T600 (600m, on axis)"); MD->SetNDC(); MD->SetTextFont(62); MD->SetTextSize(0.05); MD->Draw(); // c86->Print("FractionalErrors_Total.pdf"); TCanvas* c85 = new TCanvas("c85","",800,400); c85->SetLeftMargin(.1); c85->SetBottomMargin(.1); c85->SetTopMargin(.05); c85->SetRightMargin(.05); c85->cd(); Fig5->GetYaxis()->SetTitle("K#lower[-0.2]{+} Fractional Error"); Fig5->GetYaxis()->SetTitleFont(62); Fig5->GetXaxis()->SetTitleFont(62); Fig5->GetYaxis()->SetLabelFont(62); Fig5->GetXaxis()->SetLabelFont(62); Fig5->GetYaxis()->CenterTitle(); Fig5->GetYaxis()->SetTitleSize(0.06); Fig5->GetYaxis()->SetTitleOffset(0.8); Fig5->GetXaxis()->SetLabelSize(0.06); Fig5->GetYaxis()->SetLabelSize(0.06); Fig5->GetXaxis()->SetTitleOffset(1.5); Fig5->SetStats(0); Fig5->SetMinimum(-0.01); Fig5->SetMaximum(0.21); Fig5->SetMarkerStyle(8); Fig5->GetYaxis()->SetNdivisions(509); Fig5->GetXaxis()->SetNdivisions(509); Fig5->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c85->Print("FractionalErrors_Kplus.pdf"); TCanvas* c84 = new TCanvas("c84","",800,400); c84->SetLeftMargin(.1); c84->SetBottomMargin(.1); c84->SetTopMargin(.05); c84->SetRightMargin(.05); c84->cd(); Fig4->GetYaxis()->SetTitle("K#lower[-0.2]{-} Fractional Error"); Fig4->GetYaxis()->SetTitleFont(62); Fig4->GetXaxis()->SetTitleFont(62); Fig4->GetYaxis()->SetLabelFont(62); Fig4->GetXaxis()->SetLabelFont(62); Fig4->GetYaxis()->CenterTitle(); Fig4->GetYaxis()->SetTitleSize(0.06); Fig4->GetYaxis()->SetTitleOffset(0.8); Fig4->GetXaxis()->SetLabelSize(0.06); Fig4->GetYaxis()->SetLabelSize(0.06); Fig4->GetXaxis()->SetTitleOffset(1.5); Fig4->SetStats(0); Fig4->SetMinimum(-0.01); Fig4->SetMaximum(0.21); Fig4->SetMarkerStyle(8); Fig4->GetYaxis()->SetNdivisions(509); Fig4->GetXaxis()->SetNdivisions(509); Fig4->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c84->Print("FractionalErrors_Kmin.pdf"); TCanvas* c83 = new TCanvas("c83","",800,400); c83->SetLeftMargin(.1); c83->SetBottomMargin(.1); c83->SetTopMargin(.05); c83->SetRightMargin(.05); c83->cd(); Fig3->GetYaxis()->SetTitle("K#lower[-0.2]{0} Fractional Error"); Fig3->GetYaxis()->SetTitleFont(62); Fig3->GetXaxis()->SetTitleFont(62); Fig3->GetYaxis()->SetLabelFont(62); Fig3->GetXaxis()->SetLabelFont(62); Fig3->GetYaxis()->CenterTitle(); Fig3->GetYaxis()->SetTitleSize(0.06); Fig3->GetYaxis()->SetTitleOffset(0.8); Fig3->GetXaxis()->SetLabelSize(0.06); Fig3->GetYaxis()->SetLabelSize(0.06); Fig3->GetXaxis()->SetTitleOffset(1.5); Fig3->SetStats(0); Fig3->SetMinimum(-0.01); Fig3->SetMaximum(0.21); Fig3->SetMarkerStyle(8); Fig3->GetYaxis()->SetNdivisions(509); Fig3->GetXaxis()->SetNdivisions(509); Fig3->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c83->Print("FractionalErrors_K0.pdf"); TCanvas* c82 = new TCanvas("c82","",800,400); c82->SetLeftMargin(.1); c82->SetBottomMargin(.1); c82->SetTopMargin(.05); c82->SetRightMargin(.05); c82->cd(); Fig2->GetYaxis()->SetTitle("#pi#lower[-0.2]{+} Fractional Error"); Fig2->GetYaxis()->SetTitleFont(62); Fig2->GetXaxis()->SetTitleFont(62); Fig2->GetYaxis()->SetLabelFont(62); Fig2->GetXaxis()->SetLabelFont(62); Fig2->GetYaxis()->CenterTitle(); Fig2->GetYaxis()->SetTitleSize(0.06); Fig2->GetYaxis()->SetTitleOffset(0.8); Fig2->GetXaxis()->SetLabelSize(0.06); Fig2->GetYaxis()->SetLabelSize(0.06); Fig2->GetXaxis()->SetTitleOffset(1.5); Fig2->SetStats(0); Fig2->SetMinimum(-0.01); Fig2->SetMaximum(0.21); Fig2->SetMarkerStyle(8); Fig2->GetYaxis()->SetNdivisions(509); Fig2->GetXaxis()->SetNdivisions(509); Fig2->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c82->Print("FractionalErrors_piplus.pdf"); TCanvas* c81 = new TCanvas("c81","",800,400); c81->SetLeftMargin(.1); c81->SetBottomMargin(.1); c81->SetTopMargin(.05); c81->SetRightMargin(.05); c81->cd(); Fig1->GetYaxis()->SetTitle("#pi#lower[-0.2]{-} Fractional Error"); Fig1->GetYaxis()->SetTitleFont(62); Fig1->GetXaxis()->SetTitleFont(62); Fig1->GetYaxis()->SetLabelFont(62); Fig1->GetXaxis()->SetLabelFont(62); Fig1->GetYaxis()->CenterTitle(); Fig1->GetYaxis()->SetTitleSize(0.06); Fig1->GetYaxis()->SetTitleOffset(0.8); Fig1->GetXaxis()->SetLabelSize(0.06); Fig1->GetYaxis()->SetLabelSize(0.06); Fig1->GetXaxis()->SetTitleOffset(1.5); Fig1->SetStats(0); Fig1->SetMinimum(-0.01); Fig1->SetMaximum(0.21); Fig1->SetMarkerStyle(8); Fig1->GetYaxis()->SetNdivisions(509); Fig1->GetXaxis()->SetNdivisions(509); Fig1->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c81->Print("FractionalErrors_pimin.pdf"); TCanvas* c80 = new TCanvas("c80","",800,400); c80->SetLeftMargin(.1); c80->SetBottomMargin(.1); c80->SetTopMargin(.05); c80->SetRightMargin(.05); c80->cd(); Fig0->GetYaxis()->SetTitle("Beam Fractional Error"); Fig0->GetYaxis()->SetTitleFont(62); Fig0->GetXaxis()->SetTitleFont(62); Fig0->GetYaxis()->SetLabelFont(62); Fig0->GetXaxis()->SetLabelFont(62); Fig0->GetYaxis()->CenterTitle(); Fig0->GetYaxis()->SetTitleSize(0.06); Fig0->GetYaxis()->SetTitleOffset(0.8); Fig0->GetXaxis()->SetLabelSize(0.06); Fig0->GetYaxis()->SetLabelSize(0.06); Fig0->GetXaxis()->SetTitleOffset(1.5); Fig0->SetStats(0); Fig0->SetMinimum(-0.01); Fig0->SetMaximum(0.21); Fig0->SetMarkerStyle(8); Fig0->GetYaxis()->SetNdivisions(509); Fig0->GetXaxis()->SetNdivisions(509); Fig0->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c80->Print("FractionalErrors_beam.pdf"); cout<<"\nEnd of routine.\n"; return 0; }
TCanvas* example_plot( int iPeriod, int iPos ) { // if( iPos==0 ) relPosX = 0.12; int W = 800; int H = 600; int H_ref = 600; int W_ref = 800; // references for T, B, L, R float T = 0.08*H_ref; float B = 0.12*H_ref; float L = 0.12*W_ref; float R = 0.04*W_ref; TString canvName = "FigExample_"; canvName += W; canvName += "-"; canvName += H; canvName += "_"; canvName += iPeriod; if( writeExtraText ) canvName += "-prelim"; if( iPos%10==0 ) canvName += "-out"; else if( iPos%10==1 ) canvName += "-left"; else if( iPos%10==2 ) canvName += "-center"; else if( iPos%10==3 ) canvName += "-right"; TCanvas* canv = new TCanvas(canvName,canvName,50,50,W,H); canv->SetFillColor(0); canv->SetBorderMode(0); canv->SetFrameFillStyle(0); canv->SetFrameBorderMode(0); canv->SetLeftMargin( L/W ); canv->SetRightMargin( R/W ); canv->SetTopMargin( T/H ); canv->SetBottomMargin( B/H ); canv->SetTickx(0); canv->SetTicky(0); int histLineColor = kOrange+7; int histFillColor = kOrange-2; float markerSize = 1.0; { TLatex latex; int n_ = 2; float x1_l = 0.92; float y1_l = 0.60; float dx_l = 0.30; float dy_l = 0.18; float x0_l = x1_l-dx_l; float y0_l = y1_l-dy_l; TPad* legend = new TPad("legend_0","legend_0",x0_l,y0_l,x1_l, y1_l ); // legend->SetFillColor( kGray ); legend->Draw(); legend->cd(); float ar_l = dy_l/dx_l; float x_l[1]; float ex_l[1]; float y_l[1]; float ey_l[1]; // float gap_ = 0.09/ar_l; float gap_ = 1./(n_+1); float bwx_ = 0.12; float bwy_ = gap_/1.5; x_l[0] = 1.2*bwx_; // y_l[0] = 1-(1-0.10)/ar_l; y_l[0] = 1-gap_; ex_l[0] = 0; ey_l[0] = 0.04/ar_l; TGraph* gr_l = new TGraphErrors(1, x_l, y_l, ex_l, ey_l ); gStyle->SetEndErrorSize(0); gr_l->SetMarkerSize(0.9); gr_l->Draw("0P"); latex.SetTextFont(42); latex.SetTextAngle(0); latex.SetTextColor(kBlack); latex.SetTextSize(0.25); latex.SetTextAlign(12); TLine line_; TBox box_; float xx_ = x_l[0]; float yy_ = y_l[0]; latex.DrawLatex(xx_+1.*bwx_,yy_,"Data"); yy_ -= gap_; box_.SetLineStyle( kSolid ); box_.SetLineWidth( 1 ); // box_.SetLineColor( kBlack ); box_.SetLineColor( histLineColor ); box_.SetFillColor( histFillColor ); box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 ); box_.SetFillStyle(0); box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 ); latex.DrawLatex(xx_+1.*bwx_,yy_,"Z #rightarrow e^{+}e^{-} (MC)"); canv->cd(); } { TGraphErrors *gre = new TGraphErrors(12); gre->SetName("Graph0"); gre->SetTitle(""); gre->SetFillColor(1); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#0000ff"); gre->SetLineColor(ci); ci = TColor::GetColor("#0000ff"); gre->SetMarkerColor(ci); gre->SetMarkerStyle(21); gre->SetPoint(0,0.1428571,0.943962); gre->SetPointError(0,0,0.00470259); gre->SetPoint(1,0.1714286,0.940484); gre->SetPointError(1,0,0.00447348); gre->SetPoint(2,0.2,0.935519); gre->SetPointError(2,0,0.00484668); gre->SetPoint(3,0.2285714,0.928495); gre->SetPointError(3,0,0.00504356); gre->SetPoint(4,0.2571429,0.931586); gre->SetPointError(4,0,0.00551296); gre->SetPoint(5,0.2857143,0.924183); gre->SetPointError(5,0,0.00521949); gre->SetPoint(6,0.3142857,0.925186); gre->SetPointError(6,0,0.00541335); gre->SetPoint(7,0.3428572,0.918469); gre->SetPointError(7,0,0.00520881); gre->SetPoint(8,0.3714286,0.926619); gre->SetPointError(8,0,0.00524148); gre->SetPoint(9,0.4,0.931496); gre->SetPointError(9,0,0.00526956); gre->SetPoint(10,0.4285714,0.932581); gre->SetPointError(10,0,0.00466349); gre->SetPoint(11,0.4571429,0.924199); gre->SetPointError(11,0,0.00348535); TH1F *Graph_Graph1 = new TH1F("Graph_Graph1","",100,0.1114286,0.4885714); Graph_Graph1->SetMinimum(0); Graph_Graph1->SetMaximum(1); Graph_Graph1->SetDirectory(0); Graph_Graph1->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1->SetLineColor(ci); Graph_Graph1->GetXaxis()->SetTitle("Threshold (pC)"); Graph_Graph1->GetXaxis()->CenterTitle(true); Graph_Graph1->GetXaxis()->SetLabelFont(42); Graph_Graph1->GetXaxis()->SetLabelSize(0.05); Graph_Graph1->GetXaxis()->SetTitleSize(0.05); Graph_Graph1->GetXaxis()->SetTitleFont(42); Graph_Graph1->GetYaxis()->SetTitle("Efficiency"); Graph_Graph1->GetYaxis()->SetRange(0,1); Graph_Graph1->GetYaxis()->CenterTitle(true); Graph_Graph1->GetYaxis()->SetLabelFont(42); Graph_Graph1->GetYaxis()->SetLabelSize(0.05); Graph_Graph1->GetYaxis()->SetTitleSize(0.05); Graph_Graph1->GetYaxis()->SetTitleFont(42); Graph_Graph1->GetZaxis()->SetLabelFont(42); Graph_Graph1->GetZaxis()->SetLabelSize(0.035); Graph_Graph1->GetZaxis()->SetTitleSize(0.035); Graph_Graph1->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1); gre->Draw("ap"); } TLegend *leg = new TLegend(0.55,0.35,0.70,0.50); leg->SetTextSize(0.035); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetHeader("GIF++ test beams 08.2015"); leg->AddEntry(gre, "Low Resistivity Glass RPC", "p"); leg->Draw(); // writing the lumi information and the CMS "logo" CMS_lumi( canv, iPeriod, iPos ); canv->Update(); canv->RedrawAxis(); canv->GetFrame()->Draw(); canv->Print(canvName+".pdf",".pdf"); canv->Print(canvName+".png",".png"); return canv; }
void plotPPBalanceAll(){ bool isPF = true; TString data_tag; TString mc_tag; TString jetfinder, jetfinder_tag; if(!isPF){ data_tag = "hdata_ak5calo_DijetBalance"; mc_tag = "hmc_ak5calo_DijetBalance_histonly"; jetfinder_tag = "calo"; }else{ data_tag = "hdata_ak5pf_DijetBalance"; mc_tag = "hmc_ak5pf_DijetBalance_histonly"; jetfinder_tag ="pf"; } TFile *fDATA = new TFile(Form("./%s.root",data_tag.Data())); TFile *fMC = new TFile(Form("./%s.root",mc_tag.Data())); TH1F *hDijetBal_data = (TH1F*) fDATA->Get("hDataDijetBalance"); TH1F *hDijetBal_mc = (TH1F*) fMC->Get("hQCDDijetBalance"); // normalization should be matched with what's in ANA hDijetBal_data->Scale(1./hDijetBal_data->Integral()); hDijetBal_data->Rebin(2); hDijetBal_mc->Scale(1./hDijetBal_mc->Integral()); hDijetBal_mc->Rebin(2); cout<<"Bin Width = "<<hDijetBal_data->GetBinWidth(1)<<endl; // canvas setting --- TCanvas *c1 = new TCanvas("c1","",560,620); // dum styling ---- TH1F *hDum = new TH1F("hDum","",10,0,1.0); hDum->SetLineColor(kBlue); hDum->SetFillColor(kAzure-8); hDum->SetFillStyle(3005); hDum->SetStats(0); hDum->SetXTitle("A_{J} = (p_{T}^{j1}-p_{T}^{j2})/(p_{T}^{j1}+p_{T}^{j2})"); hDum->SetYTitle("Event Fraction"); hDum->GetXaxis()->SetLabelSize(30); hDum->GetXaxis()->SetLabelFont(43); hDum->GetXaxis()->SetTitleSize(30); hDum->GetXaxis()->SetTitleFont(43); hDum->GetXaxis()->SetTitleOffset(1.4); hDum->GetXaxis()->CenterTitle(); hDum->GetXaxis()->SetNdivisions(905,true); hDum->GetYaxis()->SetLabelSize(30); hDum->GetYaxis()->SetLabelFont(43); hDum->GetYaxis()->SetTitleSize(30); hDum->GetYaxis()->SetTitleFont(43); hDum->GetYaxis()->SetTitleOffset(1.8); hDum->GetYaxis()->CenterTitle(); hDum->SetAxisRange(0,0.25,"Y"); // data, mc styling hDijetBal_mc->SetLineColor(kBlue); hDijetBal_mc->SetFillColor(kAzure-8); hDijetBal_mc->SetFillStyle(3352); // 3352 hDum->Draw("hist"); hDijetBal_mc->SetMarkerSize(2.0); hDijetBal_mc->Draw("histsame"); hDijetBal_data->SetMarkerSize(2.0); hDijetBal_data->Draw("pzsame"); // Legend TLegend *t3=new TLegend(0.53,0.57,0.91,0.82); //t3->SetHeader("ant-k_{T} (R=0.5) CaloJets"); t3->AddEntry(hDijetBal_data,"p + p #sqrt{s}=7.0 TeV","pl"); t3->AddEntry(hDijetBal_mc,"PYTHIA","lf"); t3->SetFillColor(0); t3->SetBorderSize(0); t3->SetFillStyle(0); t3->SetTextFont(63); t3->SetTextSize(20); t3->Draw(); // other labeling TLatex *cms = new TLatex(0.20,0.23,"CMS"); cms->SetTextFont(63); cms->SetTextSize(20); cms->Draw(); TLatex *lumi = new TLatex(0.35,0.23,"#intL dt = 35.1 pb^{-1}"); lumi->SetTextFont(63); lumi->SetTextSize(18); lumi->Draw(); TLatex *jetf; if(!isPF) jetf = new TLatex(0.46,0.21,"anti-k_{T} (R=0.5) CaloJets"); else jetf = new TLatex(0.46,0.21,"anti-k_{T} (R=0.5) PFJets"); jetf->SetTextFont(63); jetf->SetTextSize(20); jetf->Draw(); c1->Print(Form("./fig/%s_%s_v1.gif",data_tag.Data(),jetfinder_tag.Data())); c1->Print(Form("./fig/%s_%s_v1.pdf",data_tag.Data(),jetfinder_tag.Data())); c1->Print(Form("./fig/%s_%s_v1.eps",data_tag.Data(),jetfinder_tag.Data())); }
void X_Resolution() { //=========Macro generated from canvas: c/c //========= (Thu Sep 10 11:42:14 2015) by ROOT version6.03/03 TCanvas *c = new TCanvas("c", "c",2119,55,800,700); c->SetHighLightColor(2); c->Range(-6.445783,-257.7555,5.60241,1890.207); c->SetFillColor(0); c->SetBorderMode(0); c->SetBorderSize(2); c->SetLeftMargin(0.12); c->SetRightMargin(0.05); c->SetTopMargin(0.07); c->SetBottomMargin(0.12); c->SetFrameBorderMode(0); c->SetFrameBorderMode(0); TH1F *histo__1 = new TH1F("histo__1","",40,-5,5); histo__1->SetBinContent(0,72); histo__1->SetBinContent(1,14); histo__1->SetBinContent(2,17); histo__1->SetBinContent(3,17); histo__1->SetBinContent(4,21); histo__1->SetBinContent(5,29); histo__1->SetBinContent(6,22); histo__1->SetBinContent(7,29); histo__1->SetBinContent(8,18); histo__1->SetBinContent(9,23); histo__1->SetBinContent(10,45); histo__1->SetBinContent(11,41); histo__1->SetBinContent(12,70); histo__1->SetBinContent(13,122); histo__1->SetBinContent(14,156); histo__1->SetBinContent(15,314); histo__1->SetBinContent(16,471); histo__1->SetBinContent(17,709); histo__1->SetBinContent(18,1055); histo__1->SetBinContent(19,1472); histo__1->SetBinContent(20,1657); histo__1->SetBinContent(21,1576); histo__1->SetBinContent(22,1318); histo__1->SetBinContent(23,1050); histo__1->SetBinContent(24,800); histo__1->SetBinContent(25,511); histo__1->SetBinContent(26,263); histo__1->SetBinContent(27,180); histo__1->SetBinContent(28,110); histo__1->SetBinContent(29,60); histo__1->SetBinContent(30,64); histo__1->SetBinContent(31,41); histo__1->SetBinContent(32,20); histo__1->SetBinContent(33,27); histo__1->SetBinContent(34,17); histo__1->SetBinContent(35,12); histo__1->SetBinContent(36,14); histo__1->SetBinContent(37,27); histo__1->SetBinContent(38,14); histo__1->SetBinContent(39,23); histo__1->SetBinContent(40,17); histo__1->SetBinContent(41,65); histo__1->SetEntries(12583); histo__1->SetStats(0); TF1 *f1 = new TF1("f","[0]*(TMath::Erf((2*(x-[1])+[2])/([3]*TMath::Sqrt(8))) + TMath::Erf((2*([1]-x)+[2])/([3]*TMath::Sqrt(8))))",-1.8,1.8); f1->SetFillColor(19); f1->SetFillStyle(0); f1->SetLineColor(2); f1->SetLineWidth(2); f1->SetChisquare(44.11321); f1->SetNDF(10); f1->GetXaxis()->SetLabelFont(42); f1->GetXaxis()->SetLabelSize(0.035); f1->GetXaxis()->SetTitleSize(0.035); f1->GetXaxis()->SetTitleFont(42); f1->GetYaxis()->SetLabelFont(42); f1->GetYaxis()->SetLabelSize(0.035); f1->GetYaxis()->SetTitleSize(0.035); f1->GetYaxis()->SetTitleFont(42); f1->SetParameter(0,5944.829); f1->SetParError(0,4323.748); f1->SetParLimits(0,0,0); f1->SetParameter(1,0.002390321); f1->SetParError(1,0.007416957); f1->SetParLimits(1,0,0); f1->SetParameter(2,0.2459713); f1->SetParError(2,0.1804005); f1->SetParLimits(2,0,0); f1->SetParameter(3,0.7402116); f1->SetParError(3,0.008551957); f1->SetParLimits(3,0,0); histo__1->GetListOfFunctions()->Add(f1); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); histo__1->SetLineColor(ci); histo__1->SetLineWidth(2); histo__1->GetXaxis()->SetTitle("X [mm]"); histo__1->GetXaxis()->SetLabelFont(42); histo__1->GetXaxis()->SetLabelSize(0.035); histo__1->GetXaxis()->SetTitleSize(0.06); histo__1->GetXaxis()->SetTitleOffset(0.8); histo__1->GetXaxis()->SetTitleFont(42); histo__1->GetYaxis()->SetTitle("entries / 0.25 mm"); histo__1->GetYaxis()->SetLabelFont(42); histo__1->GetYaxis()->SetLabelSize(0.035); histo__1->GetYaxis()->SetTitleSize(0.06); histo__1->GetYaxis()->SetTitleOffset(0.95); histo__1->GetYaxis()->SetTitleFont(42); histo__1->GetZaxis()->SetLabelFont(42); histo__1->GetZaxis()->SetLabelSize(0.035); histo__1->GetZaxis()->SetTitleSize(0.035); histo__1->GetZaxis()->SetTitleFont(42); histo__1->Draw(""); TLatex * tex = new TLatex(0.93,0.88,"#sigma = 0.74 #pm 0.01 [mm]"); tex->SetNDC(); tex->SetTextAlign(31); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); c->Modified(); c->cd(); c->SetSelected(c); }
// // Principal code segment // void pi0_HadCorrelations_Projections(const int iMultOption = 4, const bool peakRegionFile = true, const bool sideBandFile = false, const bool usePbPbData = false, const bool usepPbData = false, const bool useSimReco = false, const bool useGenEvts = true, const bool useV1V2Fit = true, const bool useV2FitOnly = false) { // // Control Parameter Instructions // iMultOption = 0, 1, 2, 3, 4 controls the track multiplicity selection [120-150, 150-195, 185-220, 220-260, 120-260] // peakRegionFile = true means that the input file inputTrue.root will be used // it is assumed that inputTrue.root is soft-linked to a peak-region output ROOT file from the EDM // this could be either a PbPb, or a pPb, or a pPb simulation ROOT file from the EDM // // sideBandFile = true is the same logic for a side-band output ROOT file from the EDM analyzer // the inputSide.root is to be soft-lined to a side-band output ROOT file from the EDM // // only one of peakRegionFile or sideBandFile can be true // // usePbPbData, usepPbData, useSimReco, or useGenEvts indicate which type of data or MC is being processed // // for the pPb data and the Sim data choices, there are 8 pT bins // for the PbPb data there are 6 pT bins // // // Output results // The macro produces two sets of plots: two-dimensional correlation and Fourier-fitted one-dimension // The macro produces an output text file, either PeakRegion_ijkMultlmn.txt or SideBand_ijkMultlmn.txt // the ijk and lmn are the track multiplicity limits determined by the iOption choice // if(sideBandFile && useGenEvts) { cerr << "\n\n Error in input parameters: cannot have a side-band file for generator events" << endl << endl; return; } int nPtBins = 8; const float _PbPb_ptMin[6] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0}; const float _PbPb_ptMax[6] = {1.0, 1.5, 2.0, 2.5, 3.0, 5.0}; const float _pPb_ptMin[8] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0}; const float _pPb_ptMax[8] = {1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0}; float _ptMin[8] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0}; float _ptMax[8] = {1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0}; bool goodDataSource = false; char *dataText = new char[200]; if(usePbPbData) { if(usepPbData || useSimReco || useGenEvts) { cerr << "\n Cannot only specify one data source as true" << endl; return; } nPtBins = 6; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _PbPb_ptMin[kPt]; _ptMax[kPt] = _PbPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using PbPbData source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "CMS PbPb #sqrt{s_{NN}}=2.76 TeV"); } if(usepPbData) { if(usePbPbData || useSimReco || useGenEvts) { cerr << "\n Cannot only specify one data source as true" << endl; return; } nPtBins = 8; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _pPb_ptMin[kPt]; _ptMax[kPt] = _pPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using pPbData source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "CMS pPb #sqrt{s_{NN}}=5.0 TeV"); } if(useSimReco) { if(usePbPbData || usepPbData || useGenEvts) { cerr << "\n Cannot only specify one data source as true" << endl; return; } nPtBins = 8; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _pPb_ptMin[kPt]; _ptMax[kPt] = _pPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using SimData source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "EPOS RECO pPb #sqrt{s_{NN}}=5.01 TeV"); } if(useGenEvts) { if(usePbPbData || usepPbData || useSimReco) { cerr << "\n Cannot only specify one data source as true" << endl; return; } if(!peakRegionFile) { cerr << "\n The peakRegionFile must be set to true when useGenEvts is true" << endl; return; } nPtBins = 8; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _pPb_ptMin[kPt]; _ptMax[kPt] = _pPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using GenEvts source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "EPOS GEN pPb #sqrt{s_{NN}}=5.01 TeV"); } if(!goodDataSource) { cerr << "\n The data source was not specified" << endl; return; } if(peakRegionFile && sideBandFile) { cerr << "\n Cannot have the peakRegionFile and the sideBandFile both set to true"<< endl; return; } if(!peakRegionFile && !sideBandFile) { cerr << "\n Cannot have the peakRegionFile and the sideBandFile both set to false"<< endl; return; } TCanvas *c1 = new TCanvas("c1","",900,900); Canvas(); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); c1->SetTopMargin(0.05); c1->SetBottomMargin(0.1); c1->SetLeftMargin(0.1742581); c1->SetRightMargin(0.05); c1->SetTheta(50.61189); c1->SetPhi(40.90062); if(nPtBins == 8) c1->Divide(3,3); if(nPtBins == 6) c1->Divide(3,2); TCanvas *c2 = new TCanvas("c2", "c2",900,900); gStyle->SetOptFit(0); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c2->Range(0,0,1,1); c2->SetFillColor(0); c2->SetBorderMode(0); c2->SetBorderSize(2); //c1->SetLogy(); c2->SetTickx(1); c2->SetTicky(1); c2->SetLeftMargin(0.16); c2->SetRightMargin(0.16); c2->SetTopMargin(0.05); c2->SetBottomMargin(0.13); c2->SetFrameFillStyle(0); c2->SetFrameBorderMode(0); if(nPtBins == 8) c2->Divide(3,3); if(nPtBins == 6) c2->Divide(3,2); TH1::SetDefaultSumw2(); char *inputFileName = new char[200]; if(peakRegionFile) { sprintf(inputFileName, "inputTrue.root"); } if(sideBandFile) { sprintf(inputFileName, "inputSide.root"); } TFile *_fpPbData = new TFile(inputFileName, "r"); if(!_fpPbData) { cerr << "\n Cannot find input file " << inputFileName << endl; return; } else { cout << "\n Found input file " << inputFileName << endl; } TH1F * _hEvent_pPb; double _nEvents_pPb; TH2D *_hSignal_pPb[8]; TH2D *_hBackground_pPb[8]; char *multText = new char[10]; char *eventText = new char[100]; char *signalText = new char[100]; char *bkgText = new char[100]; int lowMultiplicity = 120; int highMultiplicity = 150; char *multiplicityText = new char[200]; bool goodMultOption = false; if(iMultOption == 0) { sprintf(multText, "EcalFlowNtpMult100"); goodMultOption = true; sprintf(multiplicityText, "120 #leq N_{track}^{offline} < 150"); } if(iMultOption == 1) { sprintf(multText, "EcalFlowNtpMult130"); lowMultiplicity = 150; highMultiplicity = 185; goodMultOption = true; sprintf(multiplicityText, "150 #leq N_{track}^{offline} < 185"); } if(iMultOption == 2) { sprintf(multText, "EcalFlowNtpMult160"); lowMultiplicity = 185; highMultiplicity = 220; goodMultOption = true; sprintf(multiplicityText, "185 #leq N_{track}^{offline} < 220"); } if(iMultOption == 3) { sprintf(multText, "EcalFlowNtpMult190"); lowMultiplicity = 220; highMultiplicity = 260; goodMultOption = true; sprintf(multiplicityText, "220 #leq N_{track}^{offline} < 260"); } if(iMultOption == 4) { sprintf(multText, "EcalFlowNtp"); lowMultiplicity = 120; highMultiplicity = 260; goodMultOption = true; sprintf(multiplicityText, "120 #leq N_{track}^{offline} < 260"); } if(goodMultOption) { if(!useGenEvts) { sprintf(eventText, "%s/ChargedParticles/tHPTracks_", multText); sprintf(signalText, "%s/pi0HadCorrFunc/hSignalPtBin", multText); sprintf(bkgText, "%s/pi0HadCorrFunc/hBackgroundPtBin", multText); } else { sprintf(eventText, "%s/ChargedParticles/tHPTracks_", multText); sprintf(signalText, "%s/pi0HadCorrFunc/hGenSignalPtBin", multText); sprintf(bkgText, "%s/pi0HadCorrFunc/hGenBackgroundPtBin", multText); } } else { cerr << "\n Multiplicity option " << iMultOption << " is not valid" << endl; return; } // safety check ofstream myfile; char *myFileName = new char[200]; if(peakRegionFile) { sprintf(myFileName, "PeakRegion_%dMult%d.txt", lowMultiplicity, highMultiplicity); } if(sideBandFile) { sprintf(myFileName, "SideBand_%dMult%d.txt", lowMultiplicity, highMultiplicity); } cout << "\n Opening output text file " << myFileName << endl; myfile.open (myFileName); cout << "\n eventText = " << eventText; cout << "\n signalText= " << signalText; cout << "\n signalText = " << bkgText; cout << endl; char *_SignalHistoName1 = new char[200]; char *_BkgHistoName1 = new char[200]; // // Why are these numbers hard=coded here? // float _SignalFraction[8] = {0.09, 0.23, 0.44, 0.59, 0.66, 0.71, 0.73, 0.74}; _hEvent_pPb = (TH1F*)_fpPbData->Get(eventText); if(!_hEvent_pPb) { cerr << "\n Unable to find hEvent_pPb with name " << eventText << endl; return; } _nEvents_pPb = _hEvent_pPb->Integral(); cout << "\n Number of events _nEvents_pPb = " << _nEvents_pPb << "; setting up 8 histogram names" << endl; for(int iCount=0; iCount<8; ++iCount) { sprintf(_SignalHistoName1, "%s%d", signalText, iCount); sprintf(_BkgHistoName1, "%s%d", bkgText, iCount); cout << " iCount = " << iCount << '\t' << "Signal name = " << _SignalHistoName1<<endl; cout << " iCount = " << iCount << '\t' << "Background name = " << _BkgHistoName1<<endl; _hSignal_pPb[iCount] = (TH2D*)_fpPbData->Get(_SignalHistoName1); if(!_hSignal_pPb[iCount]) { cerr << "\n Unable to find _hSignal_pPb[iCount]" << endl; return; } _hBackground_pPb[iCount] = (TH2D*)_fpPbData->Get(_BkgHistoName1); if(!_hBackground_pPb[iCount]) { cerr << "\n Unable to find _hBackground_pPb[iCount]" << endl; return; } } // loop over 8 histogram bins double _etabinwidth = _hSignal_pPb[0]->GetXaxis()->GetBinWidth(1); double _phibinwidth = _hSignal_pPb[0]->GetYaxis()->GetBinWidth(1); for(long iCount=0; iCount<nPtBins; ++iCount) { _hSignal_pPb[iCount]->Divide(_hBackground_pPb[iCount]); int _x0 = _hBackground_pPb[iCount]->GetXaxis()->FindBin(0.0); int _y0 = _hBackground_pPb[iCount]->GetYaxis()->FindBin(0.0); double _B0 = _hBackground_pPb[iCount]->GetBinContent(_x0,_y0); _hSignal_pPb[iCount]->Scale(_B0/(_nEvents_pPb)); _hSignal_pPb[iCount]->Scale(1.0/_etabinwidth/_phibinwidth); c1->cd(iCount+1); _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29); _hSignal_pPb[iCount]->GetXaxis()->SetTitle("#Delta#eta"); _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29); _hSignal_pPb[iCount]->GetXaxis()->CenterTitle(true); _hSignal_pPb[iCount]->GetXaxis()->SetLabelFont(42); _hSignal_pPb[iCount]->GetXaxis()->SetLabelSize(0.035); _hSignal_pPb[iCount]->GetXaxis()->SetTitleSize(0.05); _hSignal_pPb[iCount]->GetXaxis()->SetTitleOffset(1.38); _hSignal_pPb[iCount]->GetXaxis()->SetTitleFont(42); _hSignal_pPb[iCount]->GetYaxis()->SetTitle("#Delta#phi"); _hSignal_pPb[iCount]->GetYaxis()->CenterTitle(true); _hSignal_pPb[iCount]->GetYaxis()->SetLabelFont(42); _hSignal_pPb[iCount]->GetYaxis()->SetLabelSize(0.035); _hSignal_pPb[iCount]->GetYaxis()->SetTitleSize(0.05); _hSignal_pPb[iCount]->GetYaxis()->SetTitleOffset(1.59); _hSignal_pPb[iCount]->GetYaxis()->SetTitleFont(42); _hSignal_pPb[iCount]->GetZaxis()->SetTitle("#frac{1}{N_{trig}} #frac{d^{2}N^{pair}}{d#Delta#etad#Delta#phi}"); _hSignal_pPb[iCount]->GetZaxis()->SetLabelFont(42); _hSignal_pPb[iCount]->GetZaxis()->SetLabelSize(0.035); _hSignal_pPb[iCount]->GetZaxis()->SetTitleSize(0.035); _hSignal_pPb[iCount]->GetZaxis()->SetTitleOffset(2.33); _hSignal_pPb[iCount]->GetZaxis()->SetTitleFont(42); _hSignal_pPb[iCount]->GetZaxis()->SetNdivisions(505); _hSignal_pPb[iCount]->Draw("SURF1"); TLatex * tex = new TLatex(-0.8847018,0.9364877,Form("%5.1f < p_{T} < %5.1f (GeV/c)",_ptMin[iCount],_ptMax[iCount])); tex->SetTextSize(0.06); tex->Draw(); } // loop over 8 histogram bins cout <<"\n Now drawing the projections..." << endl; float etaMin = 2.0; float etaMax = 3.6; TString _Name = "projClone"; TString _Name2 = "_pi0HadProj"; TString _Name4 = "FourierDecompose"; TString _Name1, _Name3, _Name5; TH2D *_projCorrFunc[9]; TH1D * _pi0HadCorrProj[9]; TF1 *_FourierDecompose[9]; const int n = 9; double _Parameter0[n]; double _Par0Error[n]; double _Parameter2[n]; double _Par2Error[n]; double _Ratio[n]; double _Error[n]; for(long iCount=0; iCount<nPtBins; ++iCount) { _Name1 = _Name + iCount; _Name3 = _Name2 + iCount; _Name5 = _Name4 + iCount; _projCorrFunc[iCount] = (TH2D*) _hSignal_pPb[iCount]->Clone(_Name1); Int_t etabin10m=_projCorrFunc[iCount]->GetXaxis()->FindBin(etaMin+0.01); Int_t etabin10p=_projCorrFunc[iCount]->GetXaxis()->FindBin(etaMax-0.01); _pi0HadCorrProj[iCount] = (TH1D *) _projCorrFunc[iCount]->ProjectionY(_Name3,etabin10m,etabin10p,"e"); _pi0HadCorrProj[iCount]->GetXaxis()->SetRange(8,24); c2->cd(iCount+1); _pi0HadCorrProj[iCount]->SetMarkerColor(4); _pi0HadCorrProj[iCount]->SetMarkerStyle(20); _pi0HadCorrProj[iCount]->SetMarkerSize(1.0); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitle("#Delta#phi"); _pi0HadCorrProj[iCount]->GetXaxis()->SetLabelFont(42); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleSize(0.06); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleOffset(0.67); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleFont(42); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitle("Associated yield"); _pi0HadCorrProj[iCount]->GetYaxis()->SetLabelFont(42); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleSize(0.06); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleOffset(0.77); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleFont(42); _pi0HadCorrProj[iCount]->GetZaxis()->SetLabelFont(42); _pi0HadCorrProj[iCount]->GetZaxis()->SetLabelSize(0.035); _pi0HadCorrProj[iCount]->GetZaxis()->SetTitleSize(0.035); _pi0HadCorrProj[iCount]->GetZaxis()->SetTitleFont(42); float maximumHistogramValue = _pi0HadCorrProj[iCount]->GetMaximum(); float minimumHistogramValue = _pi0HadCorrProj[iCount]->GetMinimum(); _pi0HadCorrProj[iCount]->SetMaximum(maximumHistogramValue + 0.60*(maximumHistogramValue - minimumHistogramValue)); _pi0HadCorrProj[iCount]->Draw("E1"); (c2->cd(iCount+1))->SetGrid(); if(useV1V2Fit) { _FourierDecompose[iCount] = new TF1(_Name5, v1v2Fit, -1.4, 4.88, 3); _FourierDecompose[iCount]->SetParNames("Norm","v1", "v2"); } if(useV2FitOnly) { _FourierDecompose[iCount] = new TF1(_Name5, v2Fit, -1.4, 4.88, 2); _FourierDecompose[iCount]->SetParNames("Norm","v2"); } if(!useV2FitOnly && !useV1V2Fit) { _FourierDecompose[iCount] = new TF1(_Name5, Function, -1.4, 4.88, 4); _FourierDecompose[iCount]->SetParNames("Par0","Par1","Par2","Par3"); } _pi0HadCorrProj[iCount]->Fit(_Name5, "", "", -1.4, 4.84); double v1 = 0; double v1Error = 0; double v3 = 0; double v3Error = 0; if(useV1V2Fit) { v1 = ((_FourierDecompose[iCount]->GetParameter(1))/0.232); v1Error = ((_FourierDecompose[iCount]->GetParError(1))/0.232); _Ratio[iCount] = (_FourierDecompose[iCount]->GetParameter(2))/0.232; _Error[iCount] = (_FourierDecompose[iCount]->GetParError(2))/0.232; } // using a v1 + v2 fit function if(useV2FitOnly) { _Ratio[iCount] = (_FourierDecompose[iCount]->GetParameter(1))/0.232; _Error[iCount] = (_FourierDecompose[iCount]->GetParError(1))/0.232; } // using a pure v2 fit function if(!useV2FitOnly && !useV1V2Fit) { _Parameter0[iCount] = _FourierDecompose[iCount]->GetParameter(0); _Par0Error[iCount] = _FourierDecompose[iCount]->GetParError(0); _Parameter2[iCount] = _FourierDecompose[iCount]->GetParameter(2); _Par2Error[iCount] = _FourierDecompose[iCount]->GetParError(2); v3 = ((_FourierDecompose[iCount]->GetParameter(3))/0.232)/_Parameter0[iCount]; v3Error = ((_FourierDecompose[iCount]->GetParError(3))/0.232)/_Parameter0[iCount]; _Ratio[iCount] = _Parameter2[iCount]/_Parameter0[iCount]; _Ratio[iCount] /= 0.232; // v2 of the EPOS generator charged particles, 0.3 - 3.0 GeV/c, according to Z. Chen (May 4, 2014, K0-short analysis) _Error[iCount] = _Ratio[iCount]*(sqrt((_Par2Error[iCount]/_Parameter2[iCount])*(_Par2Error[iCount]/_Parameter2[iCount]) + (_Par0Error[iCount]/_Parameter0[iCount])*(_Par0Error[iCount]/_Parameter0[iCount]) + (0.0001364/0.08609)*(0.0001364/0.08609))); } // using Monika's fitting function TLegend *legend = new TLegend(0.15, 0.65, 0.88, 0.85); char *legendHeader = new char[200]; sprintf(legendHeader, "%s, %s", dataText, multiplicityText); legend->SetHeader(legendHeader); legend->SetTextSize(0.04); legend->SetTextColor(kBlue); char *ptRangeText = new char[200]; if(sideBandFile) { sprintf(ptRangeText, "Bkg: %4.1f < p_{T} < %4.1f (GeV/c)", _ptMin[iCount], _ptMax[iCount]); } if(peakRegionFile) { sprintf(ptRangeText, "Peak for: %4.1f < p_{T} < %4.1f (GeV/c)", _ptMin[iCount], _ptMax[iCount]); } char *fitResults = new char[200]; if(useV1V2Fit) { sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f, v_{1} = %4.3f #pm %4.3f",_Ratio[iCount], _Error[iCount], v1, v1Error); } if(useV2FitOnly) { sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f (pure v_{2} fit)",_Ratio[iCount], _Error[iCount]); } if(!useV2FitOnly && !useV1V2Fit) { sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f, v_{3} = %4.3f #pm %4.3f",_Ratio[iCount], _Error[iCount], v3, v3Error); } legend->AddEntry(_Name5, fitResults, "l"); legend->AddEntry((TObject*)0, ptRangeText, ""); legend->Draw(); } // loop over pT bins cout << "\n Now writing to the output text file " << myFileName << endl; cout << "------------------------****-------------------" << endl; for(long iCount=0; iCount<8; ++iCount) { cout << "Final v2(pi0) ["<< iCount << "] = " << _Ratio[iCount] << '\t' << _Error[iCount] << '\t' << _Error[iCount]/_SignalFraction[iCount] << endl; myfile << _Ratio[iCount] << '\t' << _Error[iCount] << endl; } cout <<"------------------------****-------------------" << endl; myfile.close(); }
void optiMva2(){ TChain b("ntp1"); b.Add("AWG82/ntuples/small/Add_R24Rest_RunAll.root"); TChain uds("ntp1"); TChain ccbar("ntp1"); uds.Add("AWG82/ntuples/small/udsRests_2_3_RunAll.root"); uds.Add("AWG82/ntuples/small/udsRests_3_3_RunAll.root"); ccbar.Add("AWG82/ntuples/small/ccbarRests_2_3_RunAll.root"); ccbar.Add("AWG82/ntuples/small/ccbarRests_3_3_RunAll.root"); double NBpRun[2][6] = {{34878000, 101690000, 56035000, 166784000, 215168000, 130336000}, {44172000, 130056000, 67039000, 216196000, 291011000, 160817000}}; double NB0Run[2][6] = {{34941000, 104188000, 57888000, 169801000, 215953000, 135224000}, {43741000, 128709000, 67786000, 213996000, 245874000, 124453000}}; double nccbar[] = {55254000, 164146000, 88321000, 267308000, 343667000, 208664000}; double nuds[] = {160514000, 451636000, 275869000, 421599000, 553604000, 327032000}; double nMCB = 0, totuds = 0, totccbar = 0, fracRest = 1/3.*3/2; for(int i=1; i<7; i++){ totuds += nuds[i-1]; totccbar += nccbar[i-1]; nMCB += NBpRun[0][i-1]+NB0Run[0][i-1]; } double wuds = nMCB/totuds*2.09/1.05*fracRest; double wccbar = nMCB/totccbar*1.3/1.05*fracRest; int xbin = 40, ybin = 40; double xlow = -0.2, ylow = -0.1, xhi = 0.6, yhi = 0.6; TH2F *hMVA[4]; for(int i=0; i<4; i++){ TString hname = "MVA"; hname += i; hMVA[i] = new TH2F(hname,"Optimization MVA",xbin,xlow,xhi,ybin,ylow,yhi); } TCut sigCut[] = {"MCType==5","MCType==6", "MCType==11","MCType==12"}; TString Dnames[] = {"D^{0}","D*^{0}","D^{+}","D*^{+}"}; TLatex *label = new TLatex(); label->SetNDC(kTRUE); label->SetTextSize(0.06); double signal; TCanvas c("cMVA","Optimization MVA",800,600); c.Divide(2,2); for(int j=1; j<5; j++){ c.cd(j); cout<<"Calculating "<<Dnames[j-1]<<endl; double hiSig = 0, hiDl=0, hiComb=0; for(int i=1; i<ybin+1; i++){ for(int m=1; m<xbin+1; m++){ if(i%5==0 && m==1)cout<<"Bin "<<i<<" of "<<ybin<<endl; double Dlcut = ((double)i)*(yhi-ylow)/((double)ybin)+ylow; double Combcut = ((double)m)*(xhi-xlow)/((double)xbin)+xlow; TString Cut = "candType=="; Cut+=j; Cut+="&&candPMiss>.2&&candQ2>4&&candM2>"; if(j%2==1)Cut+="2"; else Cut +="1"; Cut+="&&candMvaDl>"; Cut += Dlcut; Cut += "&&candMvaComb>"; Cut += Combcut; double total = b.GetEntries(Cut); TCut sc = sigCut[j-1]; sc += Cut.Data(); signal = b.GetEntries(sc); // if(j<3) { // total /= 1.04974787; // signal /= 1.04974787; // } else { // total /= 1.0710204897; // signal /= 1.0710204897; // } total += uds.GetEntries(Cut)*wuds+ccbar.GetEntries(Cut)*wccbar; double signi = 0; if(total) signi = signal/sqrt(total); hMVA[j-1]->SetBinContent(m,i,signi); if(signi>hiSig){ hiSig=signi; hiDl = Dlcut; hiComb = Combcut; } } } gStyle->SetOptStat(0); gStyle->SetPalette(1); TString hTitle = "Highest S/sqr(S+B) is "; hTitle += round(hiSig,2); hTitle += ", for Dlnu > "; hTitle += round(hiDl,2); hTitle += " and Comb > "; hTitle += round(hiComb,2); hMVA[j-1]->SetTitle(hTitle); hMVA[j-1]->SetXTitle("Combinatoric MVA cut"); hMVA[j-1]->SetYTitle("Dlnu MVA cut"); hMVA[j-1]->Draw("cont4z"); label->DrawLatex(.9,0.93,Dnames[j-1]); } c.SaveAs("babar_code/eps/MVA2Opti.eps"); }
void CalcFakeRate(string infile, bool useData=true, bool doSystematics=false){ cout<<" UseData="<<useData<<" dosystematics="<<doSystematics<<endl; TFile *f = TFile::Open(infile.c_str(), "read"); assert(f); TH2F* hFakeRateNum = NULL; TH2F* hFakeRateAll = NULL; gStyle->SetOptStat(0); gStyle->SetPalette(1); gStyle->SetTextFont(132); gStyle->SetTextSize(1.2); //gROOT->ForceStyle(); bool useElectrons = infile.find("Muon") == string::npos; bool doWLep = infile.find("-TT") == string::npos; vector<string> allsamples; if(!useData){ allsamples.push_back("WJetsToLNu"); if(!doSystematics){ allsamples.push_back("TTJets"); allsamples.push_back("ZZ"); allsamples.push_back("GVJets"); allsamples.push_back("WWTo2L2Nu"); allsamples.push_back("WZJetsTo3LNu"); allsamples.push_back("DYJetsToLL"); } }else{ allsamples.push_back("data"); } float offset = 0.01; float eta[] = {0., 1.5, 2.5}; int neta = 3; if(!useElectrons){ eta[1] = 2.4; neta = 2;//eta[2] = 2.4; } //float pt [] = {0., 20., 40., 1000}; const int npt = 4; //float pt [] = {0., 10., 20., 30., 1000}; const int npt = 5; //float pt [] = {0., 10., 15., 25., 1000}; const int npt = 5; //float pt [] = {0., 10., 15., 20., 30., 1000}; const int npt = 6; float pt [] = {10., 15., 20., 30., 40., 100}; const int npt = 6; //float pt [] = {0., 20., 25., 30., 50., 1000}; const int npt = 6; hFakeRateNum = new TH2F("hFakeRateNum", "hFakeRateNum;p_{T} (GeV);#eta", npt-1, pt, neta-1, eta); hFakeRateAll = new TH2F("hFakeRateAll", "hFakeRateAll;p_{T} (GeV);#eta", npt-1, pt, neta-1, eta); string title = useElectrons ? "Electron Fake Rate" : "Muon Fake Rate"; title += useData ? " from Data" : " from MC"; title += !useData && doSystematics ? " Systematics" : ""; title += " using W+Jets method"; title += doWLep ? " on W lepton" : " on Z lepton"; hFakeRateNum->SetTitle(title.c_str()); /////////This is for eta, pt agnotistic Fake Rate Calc float in_tot(0), out_tot(0); for(unsigned i=0; i<allsamples.size(); ++i){ string hist_name = allsamples[i] + "/hNumEvts"; TH1F* hist = (TH1F*) f->Get(hist_name.c_str()); assert(hist); int lastbin = hist->GetNbinsX(); float in(0), out(0); in = hist->GetBinContent(lastbin); out = hist->GetBinContent(lastbin-1); in_tot += in; out_tot += out; //cout<<"Sample: "<<allsamples[i]<<" = "<<in/out<<" = pass/total = "<<in<<"/"<<out<<endl; printf(" Sample: %s = %.2f%% : pass/total = %.2f / %.2f \n",allsamples[i].c_str(), in/out*100, in, out); } float eff = in_tot/out_tot; float deff = TMath::Sqrt(eff * (1-eff)/out_tot); //cout<<"Total: "<<eff*100<<"% +/- "<<deff*100<<"% = in_tot/out_tot*100% = "<<in_tot<<"/"<<out_tot<<"*100%\n"; printf("Total: %.2f%% +/- %.2f%% = in_tot/out_tot*100%% = %.2f/%.2f\n", eff*100, deff*100, in_tot, out_tot); /////////This is for 2D Fake Rate Calc for(unsigned i=0; i<allsamples.size(); ++i){ string hist_name = allsamples[i] + "/hNumEvts"; TH1F* hist = (TH1F*) f->Get(hist_name.c_str()); assert(hist); int lastbin = hist->GetNbinsX(); float in(0), out(0); string binNameNum = hist->GetXaxis()->GetBinLabel(lastbin); string binNameDenom = hist->GetXaxis()->GetBinLabel(lastbin-1); string hist_nameNum = allsamples[i] + "/hEtaVsPt_" + binNameNum; TH2F* histNum = (TH2F*) f->Get(hist_nameNum.c_str()); assert(histNum); string hist_nameDenom = allsamples[i] + "/hEtaVsPt_" + binNameDenom; TH2F* histDenom = (TH2F*) f->Get(hist_nameDenom.c_str()); assert(histDenom); /* cout<<" Total from 2D Plot is "<<histNum->Integral()<<" / "<<histDenom->Integral()<<endl; //By default, integral doesn't count over/underflow cout<<" Total from 2D Plot is "<<histNum->GetEntries()<<" / "<<histDenom->GetEntries()<<endl; float sUnder(0), sOver(0); for(int ybin = 0; ybin<= histDenom->GetYaxis()->GetNbins() + 1; ++ybin){ for(int xbin = 0; xbin<= histDenom->GetXaxis()->GetNbins() +1; ++xbin){ int bin = histDenom->GetBin(xbin, ybin); if(histDenom->IsBinOverflow(bin)) sOver += histDenom->GetBinContent(bin); if(histDenom->IsBinUnderflow(bin)) sUnder += histDenom->GetBinContent(bin); } } printf("Total overflow, underflow in denom histo is %.2f , %.2f\n", sOver, sUnder); */ for(int ieta=0; ieta<neta-1; ++ieta){ float ymin = eta[ieta]; float ymax = eta[ieta+1]-offset; for(int ipt=0; ipt<npt-1; ++ipt){ float xmin = pt[ipt]; float xmax = pt[ipt+1]; int xminbin,xmaxbin,yminbin,ymaxbin; xminbin = histNum->GetXaxis()->FindBin(xmin); //+ (ipt!=0);//Avoid overlap except for first bin xmaxbin = histNum->GetXaxis()->FindBin(xmax)-1 + (ipt == npt-1-1); yminbin = histNum->GetYaxis()->FindBin(ymin); ymaxbin = histNum->GetYaxis()->FindBin(ymax); /* cout<<"("<<pt[ipt]<<", "<<eta[ieta]<<")\t" <<xmin<<"-"<<xmax<<":" <<ymin<<"-"<<ymax<<":" <<"\t"; cout<<"("<<ipt<<", "<<ieta<<")\t" <<xminbin<<"-"<<xmaxbin<<":" <<yminbin<<"-"<<ymaxbin <<endl; */ in = histNum ->Integral(xminbin, xmaxbin, yminbin, ymaxbin); out = histDenom->Integral(xminbin, xmaxbin, yminbin, ymaxbin); //Cory: Deal with negative eta (Y axis) yminbin = histNum->GetYaxis()->FindBin(-1*ymax); ymaxbin = histNum->GetYaxis()->FindBin(-1*ymin)-1;//avoid overlap /* cout<<"("<<pt[ipt]<<", "<<eta[ieta]<<")\t" <<xmin<<"-"<<xmax<<":" <<ymin<<"-"<<ymax<<":" <<"\t"; cout<<"("<<ipt<<", "<<ieta<<")\t" <<xminbin<<"-"<<xmaxbin<<":" <<yminbin<<"-"<<ymaxbin <<endl; */ in += histNum ->Integral(xminbin, xmaxbin, yminbin, ymaxbin); out += histDenom->Integral(xminbin, xmaxbin, yminbin, ymaxbin); //cout<<"("<<pt[ipt]<<","<<eta[ieta]<<") "<<in<<"/"<<out<<endl; //cout<<"("<<(pt[ipt]+pt[ipt+1])/2<<","<<(eta[ieta]+eta[ieta+1])/2<<") "<<in<<"/"<<out<<endl; hFakeRateNum ->Fill( (pt[ipt]+pt[ipt+1])/2, (eta[ieta]+eta[ieta+1])/2, in); hFakeRateAll->Fill( (pt[ipt]+pt[ipt+1])/2, (eta[ieta]+eta[ieta+1])/2, out); } } } if(hFakeRateNum){ //TGraphAsymmErrors* hFakeRateEff = new TGraphAsymmErrors(hFakeRateNum->GetArray(), hFakeRateAll->GetArray(), ""); //TGraphAsymmErrors* hFakeRateEff = new TGraphAsymmErrors(hFakeRateNum, hFakeRateAll, ""); TH2F* hFakeRate = (TH2F*) hFakeRateNum->Clone("hFakeRate"); //hFakeRate->Divide(hFakeRateAll); //hFakeRate->Scale(100.); //make is a percent TCanvas c1; c1.SetLogx(1); //gStyle->SetTextFont(132); //gStyle->SetTextSize(1.2); hFakeRate->SetMarkerSize(3); //gStyle->SetPaintTextFormat("3.0f m"); gStyle->SetPaintTextFormat("4.0f"); hFakeRate->Draw("colz"); TLatex latexLabel; latexLabel.SetNDC(); latexLabel.SetTextSize(0.04); latexLabel.SetTextFont(42); latexLabel.SetTextAngle(90); latexLabel.SetTextAlign(22); for(int ybin = 1; ybin<= hFakeRate->GetYaxis()->GetNbins(); ++ybin){ int nx = hFakeRate->GetXaxis()->GetNbins(); TGraphAsymmErrors* gFakeRatePt = new TGraphAsymmErrors(nx); gFakeRatePt->SetMaximum(1.1); gFakeRatePt->SetMinimum(0.); gFakeRatePt->SetTitle((title + ";p_{T} (GeV);Rate").c_str()); for(int xbin = nx; xbin >= 1; --xbin){ float xcen = hFakeRate->GetXaxis()->GetBinCenter(xbin); float ycen = hFakeRate->GetYaxis()->GetBinCenter(ybin); double xpos, ypos; GetNDC(c1, xcen, ycen, xpos, ypos); int bin = hFakeRate->GetBin(xbin, ybin); float pass = hFakeRateNum->GetBinContent(bin); float tot = hFakeRateAll->GetBinContent(bin); float mean = tot>0 ? pass / tot : 0.; float errUp = TEfficiency::ClopperPearson(tot, pass, 0.68, true) - mean;//hFakeRateEff->GetErrorYhigh(bin-1); float errDown = mean - TEfficiency::ClopperPearson(tot, pass, 0.68, false);//hFakeRateEff->GetErrorYlow(bin-1); errDown = max(errDown, (float) 0.); hFakeRate->SetBinContent(bin, mean); //hFakeRate->SetBinError(bin, err); float err = (errUp + errDown)/2; printf("if(pt > %.0f) return Value(%.4f, %.4f); //pt %3.0f eta %.1f, bin %2i, (mean, err)= (%.4f, %.4f) (%.2f / %.2f) +%.4f -%.4f\n", hFakeRate->GetXaxis()->GetBinLowEdge(xbin), mean, err, hFakeRate->GetXaxis()->GetBinLowEdge(xbin), hFakeRate->GetYaxis()->GetBinLowEdge(ybin), bin, mean, err, pass, tot, errUp, errDown); if(xbin != 1) latexLabel.DrawLatex(xpos, ypos, Form("%.0f^{+%.0f}_{-%.0f}%% (%.0f/%.0f)(%.f-%.f)GeV",mean*100, errUp*100, errDown*100, pass, tot, pt[xbin-1],pt[xbin])); gFakeRatePt->SetPoint (xbin-1, xcen, mean); gFakeRatePt->SetPointEYhigh(xbin-1, errUp); gFakeRatePt->SetPointEYlow (xbin-1, errDown); gFakeRatePt->SetPointEXhigh(xbin-1, hFakeRate->GetXaxis()->GetBinLowEdge(xbin+1) - xcen); gFakeRatePt->SetPointEXlow (xbin-1, xcen - hFakeRate->GetXaxis()->GetBinLowEdge(xbin)); }//pt loop c1.Clear(); c1.SetLogx(1); //c1.SetGrid(); gFakeRatePt->Draw("ap*"); string outName = Form("WJetsFakeRatePt-Eta%.1fto%.1f-", hFakeRate->GetYaxis()->GetBinLowEdge(ybin), hFakeRate->GetYaxis()->GetBinLowEdge(ybin+1)); replace(outName.begin(), outName.end(), '.', 'p'); outName += useElectrons ? "Elec" : "Muon"; outName += useData ? "Data" : "MC"; outName += !useData && doSystematics ? "Sys" : ""; outName += doWLep ? "WLep" : "ZLep"; outName += ".pdf"; c1.Print(outName.c_str()); }//eta loop c1.Clear(); c1.SetLogx(1); string outName = "FakeRate"; outName += useElectrons ? "Elec" : "Muon"; outName += useData ? "Data" : "MC"; outName += !useData && doSystematics ? "Sys" : ""; outName += doWLep ? "WLep" : "ZLep"; outName += ".pdf"; c1.Print(outName.c_str()); //Now make profiles c1.Clear(); c1.SetLogx(0); //c1.SetGrid(); TH1D* hFakeRateNumEta = hFakeRateNum->ProjectionY("hFakeRateNumEta", 0, -1, "e"); TH1D* hFakeRateAllEta = hFakeRateAll->ProjectionY("hFakeRateAllEta", 0, -1, "e"); //TH1D* hFakeRateEta = (TH1D*) hFakeRateNumEta->Clone("hFakeRateEta"); int n = hFakeRateAllEta->GetXaxis()->GetNbins(); TGraphAsymmErrors* hFakeRateEta = new TGraphAsymmErrors(n);//hFakeRateNumEta, hFakeRateAllEta); hFakeRateEta->SetMaximum(1.); hFakeRateEta->SetMinimum(0.); hFakeRateEta->SetTitle((title + ";#eta;Rate").c_str()); //hFakeRateEta->SetMarkerStyle(21); for(int xbin = 1; xbin <= n; ++xbin){ float x = hFakeRateAllEta->GetXaxis()->GetBinCenter(xbin); float pass = hFakeRateNumEta->GetBinContent(xbin); float tot = hFakeRateAllEta->GetBinContent(xbin); float mean = tot>0 ? pass / tot : 0.; float errUp = TEfficiency::ClopperPearson(tot, pass, 0.68, true) - mean;//hFakeRateEff->GetErrorYhigh(bin-1); float errDown = mean - TEfficiency::ClopperPearson(tot, pass, 0.68, false);//hFakeRateEff->GetErrorYlow(bin-1); errDown = max(errDown, (float) 0.); hFakeRateEta->SetPoint (xbin, x, mean); hFakeRateEta->SetPointEYhigh(xbin, errUp); hFakeRateEta->SetPointEYlow (xbin, errDown); //printf("bin: %i, x=%.0f, %.0f/%.0f = %.0f +%.0f -%.0f\n", xbin, x, pass, tot, mean*100, errUp*100, errDown*100); } //hFakeRateEta->Divide(hFakeRateAllEta); //hFakeRateEta->Scale(100.); hFakeRateEta->Draw("ap*"); outName = "FakeRateEta"; outName += useElectrons ? "Elec" : "Muon"; outName += useData ? "Data" : "MC"; outName += !useData && doSystematics ? "Sys" : ""; outName += doWLep ? "WLep" : "ZLep"; outName += ".pdf"; c1.Print(outName.c_str()); //Pt projections (split these by eta?) c1.Clear(); c1.SetLogx(1); //c1.SetGrid(); TH1D* hFakeRateNumPt = hFakeRateNum->ProjectionX("hFakeRateNumPt", 0, -1, "e"); TH1D* hFakeRateAllPt = hFakeRateAll->ProjectionX("hFakeRateAllPt", 0, -1, "e"); //TH1D* hFakeRatePt = (TH1D*) hFakeRateNumPt->Clone("hFakeRatePt"); n = hFakeRateAllPt->GetXaxis()->GetNbins(); TGraphAsymmErrors* hFakeRatePt = new TGraphAsymmErrors(n);//hFakeRateNumPt, hFakeRateAllPt); hFakeRatePt->SetMaximum(1.); hFakeRatePt->SetMinimum(0.); hFakeRatePt->SetTitle((title + ";p_{T} (GeV);Rate").c_str()); for(int xbin = 1; xbin <= n; ++xbin){ float x = hFakeRateAllPt->GetXaxis()->GetBinCenter(xbin); float pass = hFakeRateNumPt->GetBinContent(xbin); float tot = hFakeRateAllPt->GetBinContent(xbin); float mean = tot>0 ? pass / tot : 0.; float errUp = TEfficiency::ClopperPearson(tot, pass, 0.68, true) - mean;//hFakeRateEff->GetErrorYhigh(bin-1); float errDown = mean - TEfficiency::ClopperPearson(tot, pass, 0.68, false);//hFakeRateEff->GetErrorYlow(bin-1); errDown = max(errDown, (float) 0.); hFakeRatePt->SetPoint (xbin, x, mean); hFakeRatePt->SetPointEYhigh(xbin, errUp); hFakeRatePt->SetPointEYlow (xbin, errDown); //cout<<"low edge is "<<hFakeRateAllPt->GetXaxis()->GetBinLowEdge(xbin)<<" up edge is " // <<hFakeRateAllPt->GetXaxis()->GetBinLowEdge(xbin+1)<<endl; hFakeRatePt->SetPointEXhigh(xbin, hFakeRateAllPt->GetXaxis()->GetBinLowEdge(xbin+1) - x); hFakeRatePt->SetPointEXlow (xbin, x - hFakeRateAllPt->GetXaxis()->GetBinLowEdge(xbin)); printf("bin: %i, x=%.0f, %.0f/%.0f = %.0f +%.0f -%.0f\n", xbin, x, pass, tot, mean*100, errUp*100, errDown*100); } //hFakeRatePt->Divide(hFakeRateAllPt); //hFakeRatePt->Scale(100.); hFakeRatePt->Draw("ap*"); outName = "FakeRatePt"; outName += useElectrons ? "Elec" : "Muon"; outName += useData ? "Data" : "MC"; outName += !useData && doSystematics ? "Sys" : ""; outName += doWLep ? "WLep" : "ZLep"; outName += ".pdf"; c1.Print(outName.c_str()); } }
void drawPlot(string workspaceFilename, string inputFilename, string outFilename, Int_t EnergyType, Int_t CategoryBin, double minMass, double maxMass, double mean_bw, double gamma_bw, double cutoff_cb, double power_cb, const char* plotOpt, const int nbins) { TFile *workspaceFile = new TFile(workspaceFilename.c_str(), "read"); RooWorkspace* w = (RooWorkspace*)workspaceFile->Get("ZeeMassScaleAndResolutionFit"); //Create Data Set RooRealVar *mass = (RooRealVar*)w->var("mass"); // Reading everything from root tree instead citana::ZeeEventTree *zeeTree = new citana::ZeeEventTree(); zeeTree->LoadTree(inputFilename.c_str(), citana::ZeeEventTree::kCITZeeEvent); RooArgSet zMassArgSet(*mass); RooDataSet* data = new RooDataSet("data", "ntuple parameters", zMassArgSet); for (int i = 0; i < zeeTree->tree_->GetEntries(); i++) { zeeTree->tree_->GetEntry(i); //************************************************************************* //Electron Selection //************************************************************************* if (!(zeeTree->fEle1PassHZZICHEP2012 == 1 && zeeTree->fEle2PassHZZICHEP2012 == 1)) continue; //************************************************************************* //Compute electron four vector; //************************************************************************* double ele1pt = zeeTree->fEle1Pt; double ele2pt = zeeTree->fEle2Pt; if (EnergyType == 1) { ele1pt = zeeTree->fEle1EnergyRegressionWithTrkVarTwoPtBins / TMath::CosH(zeeTree->fEle1Eta); ele2pt = zeeTree->fEle2EnergyRegressionWithTrkVarTwoPtBins / TMath::CosH(zeeTree->fEle2Eta); } else if (EnergyType == 2) { ele1pt = zeeTree->fEle1EnergyRegressionWithTrkVar / TMath::CosH(zeeTree->fEle1Eta); ele2pt = zeeTree->fEle2EnergyRegressionWithTrkVar / TMath::CosH(zeeTree->fEle2Eta); } else if (EnergyType == 3) { ele1pt = zeeTree->fEle1EnergyRegressionNoTrkVarTwoPtBins / TMath::CosH(zeeTree->fEle1Eta); ele2pt = zeeTree->fEle2EnergyRegressionNoTrkVarTwoPtBins / TMath::CosH(zeeTree->fEle2Eta); } else if (EnergyType == 4) { ele1pt = zeeTree->fEle1EnergyRegressionNoTrkVar / TMath::CosH(zeeTree->fEle1Eta); ele2pt = zeeTree->fEle2EnergyRegressionNoTrkVar / TMath::CosH(zeeTree->fEle2Eta); } TLorentzVector ele1FourVector; ele1FourVector.SetPtEtaPhiM(ele1pt, zeeTree->fEle1Eta, zeeTree->fEle1Phi, ELECTRONMASS); TLorentzVector ele2FourVector; ele2FourVector.SetPtEtaPhiM(ele2pt, zeeTree->fEle2Eta, zeeTree->fEle2Phi, ELECTRONMASS); //************************************************************************* //pt and eta cuts on electron //************************************************************************* if (! (ele1pt > 7 && ele2pt > 7 && fabs( zeeTree->fEle1Eta) < 2.5 && fabs( zeeTree->fEle2Eta) < 2.5 )) continue; //************************************************************************* //pt bins and eta bins //************************************************************************* Int_t Ele1PtBin = -1; Int_t Ele1EtaBin = -1; Int_t Ele2PtBin = -1; Int_t Ele2EtaBin = -1; if (ele1pt > 10 && ele1pt < 20) Ele1PtBin = 0; else if (ele1pt < 30) Ele1PtBin = 1; else if (ele1pt < 40) Ele1PtBin = 2; else Ele1PtBin = 3; if (ele2pt > 10 && ele2pt < 20) Ele2PtBin = 0; else if (ele2pt < 30) Ele2PtBin = 1; else if (ele2pt < 40) Ele2PtBin = 2; else Ele2PtBin = 3; if (fabs(zeeTree->fEle1SCEta) < 1.0) Ele1EtaBin = 0; else if (fabs(zeeTree->fEle1SCEta) < 1.479) Ele1EtaBin = 1; else Ele1EtaBin = 2; if (fabs(zeeTree->fEle2SCEta) < 1.0) Ele2EtaBin = 0; else if (fabs(zeeTree->fEle2SCEta) < 1.479) Ele2EtaBin = 1; else Ele2EtaBin = 2; if (CategoryBin == 0) { if (!(Ele1EtaBin == 0 && Ele2EtaBin == 0)) continue; } else if (CategoryBin == 1) { if (!(Ele1EtaBin == 1 && Ele2EtaBin == 1)) continue; } else if (CategoryBin == 2) { if (!(Ele1EtaBin == 2 && Ele2EtaBin == 2)) continue; } //************************************************************************* // restrict range of mass //************************************************************************* double zMass = (ele1FourVector+ele2FourVector).M(); if (zMass < minMass || zMass > maxMass) continue; //************************************************************************* //set mass variable //************************************************************************* zMassArgSet.setRealValue("mass", zMass); data->add(zMassArgSet); } cout << "dataset size: " << data->numEntries() << endl; RooRealVar *cbBias = (RooRealVar*)w->var("#Deltam_{CB}"); RooRealVar *cbSigma = (RooRealVar*)w->var("sigma_{CB}"); RooRealVar *cbCut = (RooRealVar*)w->var("a_{CB}"); RooRealVar *cbPower = (RooRealVar*)w->var("n_{CB}"); // // Now if it's a restricted fit, fix values of cbCut and cbPower to MC values. // if (isRestricted) { // cbCut.setConstant(kTRUE); // cbPower.setConstant(kTRUE); // } // Mass model for signal electrons p.d.f. RooAddPdf *model = (RooAddPdf*)w->pdf("model"); TCanvas* c = new TCanvas("c","c", 0,0,800,600); //========================== Plotting ============================ //Create a frame RooPlot* plot = mass->frame(Range(minMass,maxMass),Bins(nbins)); // Add data and model to canvas plot->SetTitle(""); plot->GetYaxis()->SetTitleOffset(1.4); plot->GetXaxis()->SetTitle("m_{ee} (GeV/c^{2})"); data->plotOn(plot); model->plotOn(plot); // model->paramOn(plot, Format(plotOpt, AutoPrecision(1)), Parameters(RooArgSet(*cbBias, *cbSigma, *cbCut, *cbPower)), Layout(0.60,0.90,0.90)); model->paramOn(plot, Format(plotOpt, AutoPrecision(1)), Parameters(RooArgSet(*cbBias, *cbSigma, *cbCut, *cbPower)), Layout(0.12,0.38,0.60)); plot->getAttText()->SetTextSize(.025); plot->Draw(); // Print Fit Values TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(.04); tex->SetTextFont(2); tex->DrawLatex(0.195,0.775, "Run 2012A/B"); tex->Draw(); // tex->SetTextSize(0.022); // tex->DrawLatex(0.195, 0.75, "Z #rightarrow ee^{+}"); // tex->SetTextSize(0.024); // tex->DrawLatex(0.645, 0.59, Form("BW Mean = %.2f GeV/c^{2}", bwMean.getVal())); // tex->DrawLatex(0.645, 0.54, Form("BW #sigma = %.2f GeV/c^{2}", bwWidth.getVal())); c->Update(); c->SaveAs((outFilename + ".gif").c_str()); }
void plotTreeNorms(TTree *tree_, std::string selectString, bool do7TeV){ // Create a map for plotting the pullsummaries: std::map < const char*, std::pair <double,double> > pullSummaryMap; int nPulls=0; TObjArray *l_branches = tree_->GetListOfBranches(); int nBranches = l_branches->GetEntries(); gStyle->SetPadTopMargin(0.01); TCanvas *c = new TCanvas("c","",960,800); std::string treename = tree_->GetName(); c->SaveAs(Form("%s_normresiduals.pdf[",treename.c_str())); // File to store plots in TFile *fOut = new TFile(Form("%s_normresiduals.root",treename.c_str()),"RECREATE"); TH1F *bHd = new TH1F("bHd","",50,-1.0,1.0); TH1F *bHfd = new TH1F("bHfd","",50,-1.0,1.0); for (int iobj=0;iobj<nBranches;iobj++){ TBranch *br =(TBranch*) l_branches->At(iobj); // Draw the normal histogram const char* name = br->GetName(); // select only the normalizations string namestr(name); if(namestr.find("n_exp")==string::npos) continue; bool fitPull=true; bool fitPullf=true; double p_mean =0; int nToysInTree = tree_->GetEntries(); // Find out if paramter is fitted value or constraint term. bool isFitted = true; p_mean = prenorms_[name].first; // toy initial parameters from the datacards std::cout << "******* "<< name << " *******"<<std::endl; std::cout << p_mean << std::endl; std::cout << "******************************" <<std::endl; TH1F* bH = (TH1F*)bHd->Clone(Form("%s",name)); TH1F* bHf = (TH1F*)bHfd->Clone(Form("%s_fail",name)); const char* drawInput = Form("(%s-%f)/%f",name,p_mean,p_mean); tree_->Draw(Form("%s>>%s",drawInput,name),""); tree_->Draw(Form("%s>>%s_fail",drawInput,name),selectString.c_str(),"same"); fitPull = true; fitPullf = true; bHf->SetLineColor(2); bH->GetXaxis()->SetTitle(bH->GetTitle()); bH->GetYaxis()->SetTitle(Form("no toys (%d total)",nToysInTree)); bH->GetYaxis()->SetTitleOffset(1.05); bH->GetXaxis()->SetTitleOffset(0.9); bH->GetYaxis()->SetTitleSize(0.05); bH->GetXaxis()->SetTitleSize(0.05); bH->GetXaxis()->SetTitle(Form("%s",name)); bH->SetTitle(""); if ( bH->Integral() <=0 ) fitPull = false; if (fitPull) {bH->Fit("gaus"); bH->GetFunction("gaus")->SetLineColor(4);} if ( bHf->Integral() <=0 ) fitPullf = false; if (fitPullf) {bHf->Fit("gaus"); bHf->GetFunction("gaus")->SetLineColor(2);} c->Clear(); TPad pad1("t1","",0.01,0.01,0.66,0.95); TPad pad2("t2","",0.70,0.20,0.98,0.80); pad1.SetNumber(1); pad2.SetNumber(2); if ( isFitted ) {pad2.Draw();} pad1.Draw(); pad1.SetGrid(true); TLatex *titletext = new TLatex();titletext->SetNDC(); c->cd(1); bH->Draw(); bHf->Draw("same"); TLegend *legend = new TLegend(0.6,0.8,0.9,0.89); legend->SetFillColor(0); legend->AddEntry(bH,"All Toys","L"); legend->AddEntry(bHf,selectString.c_str(),"L"); legend->Draw(); if (fitPull){ c->cd(2); double gap; TLatex *tlatex = new TLatex(); tlatex->SetNDC(); if (fitPullf) {tlatex->SetTextSize(0.09); gap=0.12;} else {tlatex->SetTextSize(0.11);gap=0.14;} tlatex->SetTextColor(4); tlatex->DrawLatex(0.11,0.80,Form("Mean : %.3f #pm %.3f",bH->GetFunction("gaus")->GetParameter(1),bH->GetFunction("gaus")->GetParError(1))); tlatex->DrawLatex(0.11,0.80-gap,Form("Sigma : %.3f #pm %.3f",bH->GetFunction("gaus")->GetParameter(2),bH->GetFunction("gaus")->GetParError(2))); if (fitPullf){ tlatex->SetTextColor(2); tlatex->DrawLatex(0.11,0.60,Form("Mean : %.3f #pm %.3f",bHf->GetFunction("gaus")->GetParameter(1),bHf->GetFunction("gaus")->GetParError(1))); tlatex->DrawLatex(0.11,0.60-gap,Form("Sigma : %.3f #pm %.3f",bHf->GetFunction("gaus")->GetParameter(2),bHf->GetFunction("gaus")->GetParError(2))); } tlatex->SetTextSize(0.10); tlatex->SetTextColor(1); tlatex->DrawLatex(0.11,0.33,Form("Pre-fit: %.3f",p_mean)); pullSummaryMap[name]=std::make_pair<double,double>(bH->GetFunction("gaus")->GetParameter(1),bH->GetFunction("gaus")->GetParameter(2)); nPulls++; } // double titleSize = isFitted ? 0.1 : 0.028; //titletext->SetTextSize(titleSize);titletext->SetTextAlign(21); titletext->DrawLatex(0.55,0.92,name); c->SaveAs(Form("%s_normresiduals_%s.pdf",treename.c_str(),(do7TeV ? "7TeV": "8TeV"))); c->SaveAs(Form("mlfit/%s_residual_%s_%s.pdf",name,treename.c_str(),(do7TeV ? "7TeV": "8TeV"))); fOut->WriteObject(c,Form("%s_%s",treename.c_str(),name)); } if (nPulls>0){ std::cout << "Generating Pull Summaries" <<std::endl; int nRemainingPulls = nPulls; TCanvas *hc = new TCanvas("hc","",3000,2000); hc->SetGrid(0); std::map < const char*, std::pair <double,double> >::iterator pull_it = pullSummaryMap.begin(); std::map < const char*, std::pair <double,double> >::iterator pull_end = pullSummaryMap.end(); int pullPlots = 1; while (nRemainingPulls > 0){ int nThisPulls = min(maxPullsPerPlot,nRemainingPulls); TH1F pullSummaryHist("pullSummary","",nThisPulls,0,nThisPulls); for (int pi=1;pull_it!=pull_end && pi<=nThisPulls ;pull_it++,pi++){ pullSummaryHist.GetXaxis()->SetBinLabel(pi,(*pull_it).first); pullSummaryHist.SetBinContent(pi,((*pull_it).second).first); pullSummaryHist.SetBinError(pi,((*pull_it).second).second); nRemainingPulls--; } pullSummaryHist.SetMarkerStyle(21);pullSummaryHist.SetMarkerSize(1.5);pullSummaryHist.SetMarkerColor(2);pullSummaryHist.SetLabelSize(pullLabelSize); pullSummaryHist.GetYaxis()->SetRangeUser(-1,1);pullSummaryHist.GetYaxis()->SetTitle("residual summary (relative)");pullSummaryHist.Draw("E1"); hc->SaveAs(Form("%s_normresiduals_%s.pdf",treename.c_str(),(do7TeV ? "7TeV": "8TeV"))); hc->SaveAs(Form("mlfit/residual_summary_%d_%s_%s.pdf",pullPlots,treename.c_str(),(do7TeV ? "7TeV": "8TeV"))); fOut->WriteObject(hc,Form("comb_pulls_%s_%d",treename.c_str(),pullPlots)); // hc->SaveAs(Form("comb_pulls_%s_%d.pdf",treename.c_str(),pullPlots)); pullPlots++; } delete hc; } c->SaveAs(Form("%s_normresiduals_%s.pdf]",treename.c_str(),(do7TeV ? "7TeV": "8TeV"))); fOut->Close(); delete c; return; }
TCanvas* WmunuOthers( int iV=0 ) { gStyle->SetOptStat(0); gStyle->SetOptTitle(0); TGaxis::SetMaxDigits(3); double intLumi(36); // channels, ordered as in the legend vector<TString> channels; vector<TString> hnames; vector<TString> type; map<TString,int> fillColor_; map<TString,int> lineColor_; int lineWidth1(2); int lineWidth2(1); bool salamanderStyle=true; if( salamanderStyle ) { lineWidth1 = 2; lineWidth2 = 1; fillColor_["Signal"] = kOrange-2; lineColor_["Signal"] = kOrange+3; fillColor_["EWK"] = kOrange+7; lineColor_["EWK"] = kOrange+3; fillColor_["QCD"] = kViolet-5; lineColor_["QCD"] = kViolet+3; fillColor_["ttbar"] = kRed+2; lineColor_["ttbar"] = kRed+4; fillColor_["gamma+jet"] = kMagenta+4; lineColor_["gamma+jet"] = kViolet+3; } else { lineWidth1 = 2; lineWidth2 = 2; fillColor_["Signal"] = kPink+6; lineColor_["Signal"] = kMagenta+3; fillColor_["EWK"] = kAzure+8; lineColor_["EWK"] = kAzure+4; fillColor_["QCD"] = kYellow-7; lineColor_["QCD"] = kYellow+4; fillColor_["ttbar"] = kGreen; lineColor_["ttbar"] = kGreen+2; fillColor_["gamma+jet"] = kOrange; lineColor_["gamma+jet"] = kOrange+2; } // log scale? bool logScaleY=false; bool logScaleX=false; // rebin? int rb = 1; // histogram limits, in linear and logarithmic int nbin_(0); float xmin_(0.), xmax_(0.); float ymin_(0.), ymax_(0.); float yminl_(0.), ymaxl_(0.); // titles and axis, marker size TString xtitle; TString ytitle; int ndivx(510); int ndivy(510); float markerSize(1.); float titleOffset(1.00); float r0_ = 1.; float dr_ = 0.3; if( use_chi ) { r0_ = 0.; dr_ = 7.5; } // canvas name TString cname; TString ctitle; // legend position and scale; float xl_ = 0.; float yl_ = 0.; float scalel_ = 0.075; // root file, where the data is // TString fname("../Results/"); TString fname = "./Wmunu_Fit_pfMet"; TString dataHistName("data"); double factor; // *** // Only the following is specific if( iV==6 || iV==7 || iV==20 || iV ==22 || iV==21 || iV==23) { if( iV==6 || iV==20 || iV==22) { // MET plots in linear scale (inclusive) if(iV==20) fname = "./Wmunu_PLUS_pfMet"; else if(iV==22) fname = "./Wmunu_MINUS_pfMet"; logScaleY = false; ctitle = "W to mu-nu analysis - MET linear scale"; dataHistName = "DataMET"; channels.push_back("WTemplateMET"); if(iV==6) {cname="Wmn_MET";hnames.push_back(" W #rightarrow #mu#nu"); factor=1;} else if(iV==20) {cname="Wmn_MET_plus";hnames.push_back(" W^{+} #rightarrow #mu^{+}#nu"); factor=3./5.;} else {cname="Wmn_MET_minus";hnames.push_back(" W^{-} #rightarrow #mu^{-}#nu");factor=2./5.;} type.push_back("Signal"); channels.push_back("NonQCDMET"); hnames.push_back(" EWK+t#bar{t}"); type.push_back("EWK"); channels.push_back("QCDMET"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 100; xmin_ = 0.; xmax_ = 100.; xtitle = "#slash{E}_{T} [GeV]"; ytitle = "number of events / 2 GeV"; ndivx = 506; ndivy = 506; markerSize = 1.1; ymin_ = 0.; xl_ = 0.6; yl_ = 0.53; //ymax_ = 500.*intLumi*factor; if(iV==6) ymax_ = 14e3; else ymax_ = 8e3; } else if( iV==7 || iV==21 || iV==23) { // MET plots in log scale (inclusive) logScaleY = true; if(iV==21) fname = "./Wmunu_PLUS_pfMet"; else if(iV==23) fname = "./Wmunu_MINUS_pfMet"; ctitle = "W to mu-nu analysis - MET log scale"; dataHistName = "DataMET"; channels.push_back("WTemplateMET"); if(iV==7) {cname="Wmn_MET";hnames.push_back(" W #rightarrow #mu#nu");} else if(iV==21) {cname="Wmn_MET_plus";hnames.push_back(" W^{+} #rightarrow #mu^{+}#nu");} else {cname="Wmn_MET_minus";hnames.push_back(" W^{-} #rightarrow #mu^{-}#nu");} type.push_back("Signal"); channels.push_back("EWKMET"); hnames.push_back(" EWK"); type.push_back("EWK"); channels.push_back("TTbar_MCMET"); hnames.push_back(" t#bar{t}"); type.push_back("ttbar"); channels.push_back("QCDMET"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 200; xmin_ = 0.; xmax_ = 200.; xtitle = "#slash{E}_{T} [GeV]"; ytitle = "number of events / 2 GeV"; ndivx = 506; ndivy = 506; markerSize = 0.9; yminl_ = 0.05; ymaxl_ = 800.*intLumi; xl_ = 0.6; yl_ = 0.43; } } else if( iV==8 || iV==9 ) { if( iV==8 ) {cname="pt"; // pT plots in linear scale (inclusive) logScaleY = false; ctitle = "W to mu-nu analysis - pT linear scale"; dataHistName = "DataPT"; channels.push_back("WTemplatePT"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("NonQCDPT"); hnames.push_back(" EWK+t#bar{t}"); type.push_back("EWK"); channels.push_back("QCDPT"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 60; xmin_ = 20.; xmax_ = 80.; xtitle = "p_{T}(#mu) [GeV]"; ytitle = "number of events / 2 GeV"; ndivx = 506; ndivy = 506; markerSize = 1.1; ymin_ = 0.; ymax_ = 500.*intLumi; xl_ = 0.6; yl_ = 0.53; } else if( iV==9 ) {cname="pt"; // pT plots in log scale (inclusive) logScaleY = true; ctitle = "W to mu-nu analysis - pT log scale"; dataHistName = "DataPT"; channels.push_back("WTemplatePT"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("EWKPT"); hnames.push_back(" EWK"); type.push_back("EWK"); channels.push_back("TTbar_MCPT"); hnames.push_back(" t#bar{t}"); type.push_back("ttbar"); channels.push_back("QCDPT"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 80; xmin_ = 20.; xmax_ = 100.; xtitle = "p_{T}(#mu) [GeV]"; ytitle = "number of events / 2 GeV"; ndivx = 506; ndivy = 506; markerSize = 0.9; yminl_ = 0.1; ymaxl_ = 30000.*intLumi; xl_ = 0.6; yl_ = 0.45; } } else if( iV==13 || iV==14 ) { if( iV==13 ) {cname="ptw"; // pT plots in linear scale (inclusive) logScaleY = false; ctitle = "W to mu-nu analysis - W pT linear scale"; dataHistName = "DataPTW"; channels.push_back("WTemplatePTW"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("NonQCDPTW"); hnames.push_back(" EWK+t#bar{t}"); type.push_back("EWK"); channels.push_back("QCDPTW"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 100; xmin_ = 0.; xmax_ = 100.; xtitle = "p_{T}(W) [GeV]"; ytitle = "number of events / 2 GeV"; ndivx = 506; ndivy = 506; markerSize = 1.1; ymin_ = 0.; ymax_ = 500.*intLumi; xl_ = 0.6; yl_ = 0.53; } else if( iV==14 ) {cname="ptw"; // pT plots in log scale (inclusive) logScaleY = true; ctitle = "W to mu-nu analysis - pT log scale"; dataHistName = "DataPTW"; channels.push_back("WTemplatePTW"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("EWKPTW"); hnames.push_back(" EWK"); type.push_back("EWK"); channels.push_back("TTbar_MCPTW"); hnames.push_back(" t#bar{t}"); type.push_back("ttbar"); channels.push_back("QCDPTW"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 100; xmin_ = 0.; xmax_ = 100.; xtitle = "p_{T}(W) [GeV]"; ytitle = "number of events / 2 GeV"; ndivx = 506; ndivy = 506; markerSize = 0.9; yminl_ = 0.1; ymaxl_ = 45000.*intLumi; xl_ = 0.6; yl_ = 0.48; } } else if( iV==10 || iV==11 || iV==12 ) { if( iV==10 ) {cname="iso"; // isolation plot in linear scale logScaleY = false; ctitle = "W to mu-nu analysis - isolation, linear scale"; dataHistName = "DataISO"; channels.push_back("WTemplateISO"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("NonQCDISO"); hnames.push_back(" EWK+t#bar{t}"); type.push_back("EWK"); channels.push_back("QCDISO"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 25; xmin_ = 0.; xmax_ = 0.5; xtitle = "I^{rel}_{comb}"; ytitle = "number of events"; //ytitle = "CMS preliminary"; ndivx = 506; ndivy = 506; markerSize = 1.1; titleOffset = 1.25; ymin_ = 0.; ymax_ = 5000.*intLumi; xl_ = 0.6; yl_ = 0.53; } else if( iV==11 ) {cname="iso"; // isolation plot in log scale logScaleY = true; ctitle = "W to mu-nu analysis - isolation, log scale"; dataHistName = "DataISO"; channels.push_back("WTemplateISO"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("EWKISO"); hnames.push_back(" EWK"); type.push_back("EWK"); channels.push_back("TTbar_MCISO"); hnames.push_back(" t#bar{t}"); type.push_back("ttbar"); channels.push_back("QCDISO"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 25; xmin_ = 0.; xmax_ = 0.5; xtitle = "I^{rel}_{comb}"; ytitle = "number of events"; //ytitle = "CMS preliminary"; ndivx = 506; ndivy = 506; markerSize = 0.9; yminl_ = 50; ymaxl_ = 30000.*intLumi; xl_ = 0.6; yl_ = 0.45; } else if( iV==12 ) {cname="iso2"; // isolation plot in log scale logScaleX = true; logScaleY = true; ctitle = "W to mu-nu analysis - isolation, log scale"; dataHistName = "DataISO"; channels.push_back("WTemplateISO"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("EWKISO"); hnames.push_back(" EWK"); type.push_back("EWK"); channels.push_back("TTbar_MCISO"); hnames.push_back(" t#bar{t}"); type.push_back("ttbar"); channels.push_back("QCDISO"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 200; xmin_ = 0.; xmax_ = 0.5; xtitle = "I^{rel}_{comb}"; ytitle = "number of events"; ndivx = 506; ndivy = 506; markerSize = 0.9; yminl_ = 1; ymaxl_ = 4000000.*intLumi; xl_ = 0.6; yl_ = 0.45; } } else if( iV==15 ) {cname="acop"; // pT plots in linear scale (inclusive) logScaleY = false; ctitle = "W to mu-nu analysis - acop linear scale"; dataHistName = "DataACOP"; channels.push_back("WTemplateACOP"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("NonQCDACOP"); hnames.push_back(" EWK+t#bar{t}"); type.push_back("EWK"); channels.push_back("QCDACOP"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 60; xmin_ = 0; xmax_ = 3.14; xtitle = "acop"; ytitle = "number of events"; ndivx = 506; ndivy = 506; markerSize = 1.1; ymin_ = 0.; ymax_ = 400.*intLumi; xl_ = 0.6; yl_ = 0.53; } else if( iV==16 ) {cname="eta"; // pT plots in linear scale (inclusive) logScaleY = false; ctitle = "W to mu-nu analysis - eta linear scale"; dataHistName = "DataETA"; channels.push_back("WTemplateETA"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("NonQCDETA"); hnames.push_back(" EWK+t#bar{t}"); type.push_back("EWK"); channels.push_back("QCDETA"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 60; xmin_ = -3; xmax_ = 3; xtitle = "eta"; ytitle = "number of events"; ndivx = 506; ndivy = 506; markerSize = 1.1; ymin_ = 0.; ymax_ = 120.*intLumi; xl_ = 0.25; yl_ = 0.63; } else if( iV==17 ) {cname="ptw_minus"; fname = "./Wmunu_MINUS_pfMet"; // pT plots in linear scale (inclusive) logScaleY = false; ctitle = "W to mu-nu analysis - eta linear scale"; dataHistName = "DataPTW"; channels.push_back("WTemplatePTW"); hnames.push_back(" W^{-} #rightarrow #mu^{-}#nu"); type.push_back("Signal"); channels.push_back("NonQCDPTW"); hnames.push_back(" EWK+t#bar{t}"); type.push_back("EWK"); channels.push_back("QCDPTW"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 100; xmin_ = 0; xmax_ = 100; xtitle = "W pt (GeV)"; ytitle = "number of events / 2 GeV"; ndivx = 506; ndivy = 506; markerSize = 1.1; ymin_ = 0.; ymax_ = 200.*intLumi; xl_ = 0.6; yl_ = 0.53; } else if( iV==18 ) {cname="ptw_plus"; fname = "./Wmunu_PLUS_pfMet"; // pT plots in linear scale (inclusive) logScaleY = false; ctitle = "W to mu-nu analysis - eta linear scale"; dataHistName = "DataPTW"; channels.push_back("WTemplatePTW"); hnames.push_back(" W^{+} #rightarrow #mu^{+}#nu"); type.push_back("Signal"); channels.push_back("NonQCDPTW"); hnames.push_back(" EWK+t#bar{t}"); type.push_back("EWK"); channels.push_back("QCDPTW"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 100; xmin_ = 0; xmax_ = 100; xtitle = "W pt (GeV)"; ytitle = "number of events / 2 GeV"; ndivx = 506; ndivy = 506; markerSize = 1.1; ymin_ = 0.; ymax_ = 300.*intLumi; xl_ = 0.6; yl_ = 0.53; } else if( iV==19 ) {cname="phi"; //fname = "../Results/Wmunu__pfMet.root"; // pT plots in linear scale (inclusive) logScaleY = false; ctitle = "W to mu-nu analysis - phi linear scale"; dataHistName = "DataPHI"; channels.push_back("WTemplatePHI"); hnames.push_back(" W #rightarrow #mu#nu"); type.push_back("Signal"); channels.push_back("NonQCDPHI"); hnames.push_back(" EWK+t#bar{t}"); type.push_back("EWK"); channels.push_back("QCDPHI"); hnames.push_back(" QCD"); type.push_back("QCD"); nbin_ = 60; xmin_ = -3.5; xmax_ = 3.5; xtitle = "Phi"; ytitle = "number of events"; ndivx = 506; ndivy = 506; markerSize = 1.1; ymin_ = 0.; ymax_ = 100.*intLumi; xl_ = 0.25; yl_ = 0.63; } int nChan=channels.size(); // open the root file containing histograms and graphs fname += ".root"; TFile* f_ = TFile::Open(fname,"READ"); // the canvas if( logScaleY ) cname += "_log"; //else cname += "_lin"; TCanvas* c_=new TCanvas(cname,ctitle,300,300,479,510); c_->SetLeftMargin( 87./479 ); c_->SetRightMargin( 42./479 ); c_->SetTopMargin( 30./510 ); c_->SetBottomMargin( 80./510 ); c_->SetFillColor(0); c_->SetTickx(1); c_->SetTicky(1); c_->SetFrameFillStyle(0); c_->SetFrameLineWidth(2); c_->SetFrameBorderMode(0); Double_t scale = 4; Double_t wbin = 42*scale; Double_t left = 8*scale; Double_t right = 5*scale; Double_t h1 = 135*scale; Double_t h2 = 45*scale; Double_t top1 = 15*scale; Double_t bot1 = 3*scale; Double_t top2 = 3*scale; // Double_t bot1 = 0*scale; // Double_t top2 = 0*scale; Double_t bot2 = 80*scale; Double_t W = left + wbin + right; Double_t H = h1 + h2; Double_t s[2] = {1, h1/h2 }; TPad* pad[2]; pad[0] = new TPad( "top", "top", 0, h2/H, 1, 1, kWhite,0,0); pad[0]->SetLeftMargin( left/W ); pad[0]->SetRightMargin( right/W ); pad[0]->SetTopMargin( top1/H ); pad[0]->SetBottomMargin( bot1/H ); pad[1] = new TPad( "bottom", "bottom", 0, 0, 1, h2/H, kWhite,0,0); pad[1]->SetLeftMargin( left/W ); pad[1]->SetRightMargin( right/W ); pad[1]->SetTopMargin( top2/H ); pad[1]->SetBottomMargin( bot2/H ); pad[1]->SetGridy(); for( int ii=0; ii<2; ii++ ) { pad[ii]->SetFillColor(0); pad[ii]->SetTickx(1); pad[ii]->SetTicky(1); pad[ii]->SetFrameFillStyle(0); pad[ii]->SetFrameLineWidth(2); pad[ii]->SetFrameBorderMode(0); pad[ii]->SetFrameFillStyle(0); pad[ii]->SetFrameLineWidth(2); pad[ii]->SetFrameBorderMode(0); } // a dummy histogram with the correct x axis // Warning: setTDRstyle() must be called before cout << nbin_<<endl; TH1F* h_= new TH1F( "bidon", "bidon", nbin_, xmin_, xmax_ ); TAxis* ax_ = h_->GetXaxis(); TAxis* ay_ = h_->GetYaxis(); ax_->SetTitle(xtitle); ax_->CenterTitle(); ax_->SetNdivisions(ndivx); ax_->SetTitleOffset(1.0); ax_->SetTitleSize( 1.4*ax_->GetTitleSize() ); ax_->SetLabelSize( 1.2*ax_->GetLabelSize() ); ay_->SetTitle(ytitle); ay_->CenterTitle(); ay_->SetNdivisions(ndivy); /*if(logScaleY) */ titleOffset *=1.1; ay_->SetTitleOffset(titleOffset); ay_->SetLabelOffset(0.015); ay_->SetLabelSize( 1.2*ay_->GetLabelSize() ); ay_->SetTitleSize( 1.4*ay_->GetTitleSize() ); // fetch histograms and dress them vector<TH1F*> histos; for( int ii=0; ii<nChan; ii++ ) { TH1F* tmp = (TH1F*)f_->Get(channels[ii]); tmp->Rebin(rb); tmp->SetStats(kFALSE); // tmp->UseCurrentStyle(); tmp->SetFillStyle( 1001 ); tmp->SetFillColor( fillColor_[type[ii]] ); tmp->SetLineColor( lineColor_[type[ii]] ); tmp->SetLineWidth( lineWidth2 ); histos.push_back(tmp); } TH1* h_sig = (TH1*) histos[0]->Clone(); h_sig->SetFillStyle(0); h_sig->SetLineColor(lineColor_["Signal"]); h_sig->SetLineWidth( 2 ); h_sig->SetLineStyle( kDashed ); TH1* h_tot = (TH1*) histos[0]->Clone(); h_tot->SetFillStyle(0); // // stack histogram // THStack* stackedHisto=new THStack("stackedHisto","XXX"); TH1F* totalHisto(0); for(int ii=0;ii<nChan;ii++) { stackedHisto->Add(histos[nChan-ii-1],"ah"); if(ii==0) { totalHisto = (TH1F*)histos[ii]->Clone(); } else { totalHisto->Add(histos[ii]); } } // colors the stacked histogram totalHisto->SetLineColor( lineColor_["Signal"] ); totalHisto->SetFillColor( 0 ); totalHisto->SetLineWidth( lineWidth1 ); // The data points are presented as a TGraph // possibly a TGraph with asymmetric errors where // - error bars indicate the Poisson confidence interval at 68% // - bins with zero entry are removed // TGraphAsymmErrors* dataGraph = (TGraphAsymmErrors*)f_->Get("data"); // The data points are presented as a TGraph // possibly a TGraph with asymmetric errors where // - error bars indicate the Poisson confidence interval at 68% // - bins with zero entry are removed TH1* hdata = (TH1*) f_->Get( dataHistName ); assert( hdata ); hdata->Rebin(rb); RooHist* roohist; TGraphAsymmErrors* dataGraph; roohist = new RooHist((*hdata)); int Nn0=0; vector<double> vY; vector<double> vX; vector<double > veY; vector<double > veX; vector<double> tmp(0,2); for(int ip=0;ip<roohist->GetN();ip++) { double Y,X; // double eY[2],eX[2]; roohist->GetPoint(ip,X,Y); if(Y!=0) { Nn0++; vY.push_back(Y); vX.push_back(X); veX.push_back( roohist->GetErrorXlow(ip) ); veX.push_back( roohist->GetErrorXhigh(ip) ); veY.push_back( roohist->GetErrorYlow(ip) ); veY.push_back( roohist->GetErrorYhigh(ip) ); } } dataGraph=new TGraphAsymmErrors(Nn0); for(int ip=0;ip<Nn0;ip++) { dataGraph->SetPoint(ip,vX[ip],vY[ip]); dataGraph->SetPointError(ip,veX[ip*2],veX[ip*2+1],veY[ip*2],veY[ip*2+1]); } dataGraph->SetName("data"); dataGraph->SetMarkerStyle(kFullCircle); dataGraph->SetMarkerColor(kBlack); if(logScaleY) markerSize *= 0.45; else markerSize *= 0.7; dataGraph->SetMarkerSize(markerSize); TGraph* dummyGraph = (TGraph*) dataGraph->Clone("dummyGraph"); dummyGraph->SetLineColor(0); dummyGraph->SetMarkerSize(1.5*markerSize); // Remove the null bins double x_(0), y_(0); for( int ii=0; ii<dataGraph->GetN(); ii++ ) { dataGraph->SetPointEXlow(ii,0); dataGraph->SetPointEXhigh(ii,0); dataGraph->GetPoint(ii,x_,y_ ); if( y_==0 ) { dataGraph->RemovePoint( ii ); ii--; } } // get the ratio data/fit TGraphAsymmErrors* ratioGraph = (TGraphAsymmErrors*) dataGraph->Clone("ratio"); TH1* hfit = totalHisto; for( int ii=0; ii<dataGraph->GetN(); ii++ ) { dataGraph->GetPoint(ii,x_,y_ ); ratioGraph->SetPointEYlow(ii,0); ratioGraph->SetPointEYhigh(ii,0); ratioGraph->SetPoint(ii,x_,0 ); double eyl_ = dataGraph->GetErrorYlow(ii); double eyh_ = dataGraph->GetErrorYhigh(ii); int jj = hfit->FindBin(x_); float fit_ = hfit->GetBinContent( jj ); if( fit_>0 ) { if( use_chi ) { ratioGraph->SetPointEYlow(ii,eyl_/sqrt(fit_)); ratioGraph->SetPointEYhigh(ii,eyh_/sqrt(fit_)); ratioGraph->SetPoint(ii,x_,(y_-fit_)/sqrt(fit_) ); } else { ratioGraph->SetPointEYlow(ii,eyl_/fit_); ratioGraph->SetPointEYhigh(ii,eyh_/fit_); ratioGraph->SetPoint(ii,x_,y_/fit_ ); } } // cout << ii << " ratio=" << ratioGraph->GetY()[ii] // << "+" << ratioGraph->GetEYhigh()[ii] // << "-" << ratioGraph->GetEYlow()[ii] << endl; } TH1* hratio_ = (TH1*) h_->Clone("hratio"); ax_->SetLabelOffset(99); ax_->SetTitleOffset(99); // // now plotting // c_->Draw(); c_->cd(); TPad* p_ = pad[0]; p_->Draw(); p_->cd(); if( logScaleY ) { p_->SetLogy(true); } else { p_->SetLogy(false); } if( !logScaleY ) { h_->GetYaxis()->SetRangeUser(ymin_+0.001*(ymax_-ymin_),rb*ymax_); } else { h_->GetYaxis()->SetRangeUser(yminl_,rb*ymaxl_); } h_->Draw("hist"); float dxl_ = scalel_*3.5; float dyl_ = scalel_*(nChan+0.5); TLegend* legend=new TLegend(xl_,yl_,xl_+dxl_,yl_+dyl_); legend->SetTextFont(42); legend->SetTextSize(0.045); legend->SetLineColor(0); legend->SetFillColor(0); legend->AddEntry(dummyGraph," data","pl"); legend->AddEntry(dummyGraph," ","0"); // skip a line for( int ii=0; ii<nChan; ii++ ) { legend->AddEntry(histos[ii],hnames[ii],"f"); } legend->Draw("same"); stackedHisto->Draw("samehist"); h_sig->Draw("samehist"); totalHisto->Draw("samehist"); // draw the data points dataGraph->Draw("PE"); // redraw axis p_->RedrawAxis(); //lumi pad, cms prelim pad etc.. { int txtFont = 42; float txtSize1 = 0.055; float txtX1 = 0.91; float txtY1 = 0.935; float txtSize2 = 0.05; float txtX2 = 0.85; float txtY2 = 0.83; TLatex latex; latex.SetNDC(); latex.SetTextFont(txtFont); latex.SetTextSize(txtSize1); latex.SetTextAlign(31); // align right // latex.DrawLatex(txtX1,txtY1,"CMS preliminary"); latex.DrawLatex(txtX1,txtY1,"CMS"); latex.SetTextAlign(31); // align right latex.SetTextSize(txtSize2); latex.DrawLatex(txtX2,txtY2,"36 pb^{-1} at #sqrt{s} = 7 TeV"); } c_->cd(); p_ = pad[1]; p_->Draw(); p_->cd(); TAxis* xratio_ = hratio_->GetXaxis(); TAxis* yratio_ = hratio_->GetYaxis(); yratio_->SetRangeUser(r0_-0.9999*dr_,r0_+0.9999*dr_); yratio_->SetLabelSize( s[1]*yratio_->GetLabelSize() ); yratio_->SetTitleSize( s[1]*yratio_->GetTitleSize() ); yratio_->SetLabelOffset( yratio_->GetLabelOffset() ); yratio_->SetTitleOffset( yratio_->GetTitleOffset()/s[1] ); if( use_chi ) { yratio_->SetTitle("#chi"); yratio_->SetNdivisions(4); } else { yratio_->SetTitle("data/fit"); yratio_->SetNdivisions(3); } xratio_->SetLabelSize( s[1]*xratio_->GetLabelSize() ); xratio_->SetTitleSize( s[1]*xratio_->GetTitleSize() ); xratio_->SetTitleOffset( 1.0 ); xratio_->CenterTitle(); xratio_->SetLabelOffset( xratio_->GetLabelOffset()*s[1] ); xratio_->SetTickLength( xratio_->GetTickLength()*s[1] ); hratio_->Draw(); ratioGraph->SetMarkerSize( ratioGraph->GetMarkerSize()*1. ); ratioGraph->SetLineColor( kBlack ); ratioGraph->SetMarkerColor( kGray+2 ); ratioGraph->SetMarkerStyle( kFullCircle ); ratioGraph->DrawClone("PE"); ratioGraph->SetMarkerColor( kBlack ); ratioGraph->SetMarkerStyle( kOpenCircle ); ratioGraph->DrawClone("PE"); p_->RedrawAxis(); c_->cd(); c_->SaveAs("plot.pdf"); return c_; }
//Fitting with the RooFit package //Author: Chengping Shen void Fit() { gSystem->Load("libRooFit") ; using namespace RooFit ; RooRealVar x("x","M_{ee} (GeV/c^{2})", 60, 120) ; //BreitWinger RooRealVar mean("mean","",91,80,95) ; RooRealVar mean2("mean2","",91.1,80.1,95) ; RooRealVar mean5("mean5","",91,80,95) ; RooRealVar width("width","", 4,0.3,8) ; RooRealVar width1("width1","", 4,0.3,8) ; RooRealVar width2("width2","", 2.5,0.3,8) ; RooRealVar width3("width3","", 4,0.3,8) ; RooRealVar width4("width4","", 4,0.1,8) ; RooRealVar width5("width5","", 6,0.2,8) ; RooBreitWigner bw1("bw1","Breit Wigner", x, mean, width1 ); RooBreitWigner bw2("bw2","Breit Wigner", x, mean, width ); RooBreitWigner bw3("bw3","Breit Wigner", x, mean, width3 ); RooBreitWigner bw4("bw4","Breit Wigner", x, mean, width4 ); RooBreitWigner bw5("bw5","Breit Wigner", x, mean5, width5 ); //Novosibirsk RooRealVar meanNb("meanNb","meanNb", 0,-1,1) ; RooRealVar widthNb("widthNb","widthNb", 0.1, 0.001, 5) ; RooRealVar tailNb("tailNb","tailNb", 0.3, -5, 4) ; RooNovosibirsk Nb("Nb","Nb",x,meanNb,widthNb,tailNb); //Landau RooRealVar meanLa("meanLa","meanLa", 0) ; RooRealVar sigmaLa2("sigmaLa","x resolution", 1.0,0.15,10) ; RooLandau La2("La2","La2",x,meanLa,sigmaLa2); RooRealVar sigmaLa5("sigmaLa5","x resolution", 2,0.01,10) ; RooLandau La5("La5","La5",x,meanLa,sigmaLa5); //Polynomial RooRealVar c1("c1","c1",0.001,-0.5,0.01); RooRealVar c2("c2","c2",0.001,-1.5,0.01); // RooRealVar c3("c3","c3",0.,-50,50); RooPolynomial px("px","px",x,RooArgSet(c1,c2)) ; //Chebychev RooChebychev Cheb("Cheb","Cheb",x,RooArgSet(c1,c2)); //RooCBShape RooRealVar CB_m0("CB_m0","x",0) ; RooRealVar CB_sigma("CB_sigma","x resolution", 2,0.15,10) ; RooRealVar CB_alpha("CB_alpha","x resolution", 2,-10,10) ; RooRealVar CB_n("CB_n","x resolution", 2,1,130) ; RooCBShape CB("CB","CB",x,CB_m0,CB_sigma,CB_alpha,CB_n); //gaussion RooRealVar sigmean("sigmean","x",0) ; RooRealVar sigwidth1("sigwidth1","x resolution", 2,0.15,10) ; RooRealVar sigwidth2("sigwidth2","x resolution", 3,0.15,10) ; RooRealVar sigwidth3("sigwidth3","x resolution", 2,0.15,10) ; RooRealVar sigwidth4("sigwidth4","x resolution", 2,0.15,10) ; RooRealVar sigwidth5("sigwidth5","x resolution", 4,0.15,10) ; RooGaussian gauss1("gauss1","gaussian PDF",x,sigmean,sigwidth1) ; RooGaussian gauss2("gauss2","gaussian PDF",x,sigmean,sigwidth2) ; RooGaussian gauss3("gauss3","gaussian PDF",x,sigmean,sigwidth3) ; RooGaussian gauss4("gauss4","gaussian PDF",x,sigmean,sigwidth4) ; RooGaussian gauss5("gauss5","gaussian PDF",x,sigmean,sigwidth5) ; //Double Gaussin RooRealVar mean1("mean1","#eta_{c} mass", 0.0) ; RooRealVar sigma1("sigma1", "eta_{c} resolution1",0.07 , 0.001,1.); RooRealVar ratio2("ratio2", "ratio of the second gaussion", 7.e-01,0.01,1.); RooRealVar diff("diff", "mean difference", 0.02 , -10.0, 10.0) ; RooRealVar sigratio2("sigratio2", "the second gaussion sigma", 4.0e-01, 0.0, 10.0); RooGenericPdf dgaus("dgaus", "double gaussion", "(1.-ratio2)*(1./sqrt(2.*3.1415926))*exp(-0.5*((x-mean1)/sigma1)**2)/sigma1 + ratio2*(1./sqrt(2.*3.1415926))*exp(-0.5*((x-mean1-diff)/(sigma1*sigratio2))**2)/(sigma1*sigratio2)", RooArgSet(x,mean1,sigma1,ratio2, diff, sigratio2)); //*** eff curve **** // RooGenericPdf eff("eff", "eff curve", "-0.8262+0.4445*x-0.0535*x**2", RooArgSet(x)); //Fitting pdf=Breit Wiger convolve Gaussion // RooNumConvPdf bwxgaus("bw","bwxgaus",x,bw,gauss); // RooVoigtian bwxxx("bw", "bw (X) gauss", x, mean, width, sigwidth); //x.setBins("fft",10000); //bwXgauss RooFFTConvPdf bxg1("bxg1","",x,bw1,gauss1); RooFFTConvPdf bxg2("bxg2","",x,bw2,gauss2); RooFFTConvPdf bxg3("bxg3","",x,bw3,gauss3); RooFFTConvPdf bxg4("bxg4","",x,bw4,gauss4); RooFFTConvPdf bxg5("bxg5","",x,bw5,gauss5); //bwXNovosibirsk RooFFTConvPdf bxN2("bxN2","",x,bw2,Nb); //bwXLandau RooFFTConvPdf bxLa2("bxLa2","",x,bw2,La2); RooFFTConvPdf bxLa5("bxLa5","",x,bw2,La5); //bwXCB RooFFTConvPdf bxCB("bxCB","",x,bw1,CB); //*** BW * eff curve ***** // RooProdPdf bwtmp("bwtmp", "bwtmp", RooArgSet(bwxxx, eff)); // RooRealVar nsig("nsig","number of signal events",Nsig) ; RooRealVar nsig("nsig","number of signal",10000,0,200000) ; RooRealVar nsig1("nsig1","number of signal",10000,1,200000) ; RooRealVar nsig2("nsig2","number of signal",10000,1,200000) ; RooRealVar nsig3("nsig3","number of signal",10000,1,170000) ; RooRealVar nsig4("nsig4","number of signal",10000,1,200000) ; RooRealVar nsig5("nsig5","number of signal",10000,1,70000) ; RooRealVar nsig6("nsig6","number of signal",10000,1,200000) ; RooRealVar nsig7("nsig7","number of signal",10000,1,200000) ; RooRealVar nsig8("nsig8","number of signal",10000,1,170000) ; RooRealVar nsig9("nsig9","number of signal",10000,1,200000) ; RooRealVar nsig10("nsig10","number of signal",10000,1,70000) ; // RooRealVar nsig("nsig","number of signal events",0) ; RooRealVar nbkg("nbkg","number of background events",1,0,10000) ; RooRealVar nbkg1("nbkg1","number of background events",1,0,100) ; RooRealVar nbkg2("nbkg2","number of background events",1,1,10000) ; RooRealVar nbkg3("nbkg3","number of background events",1,0,1000) ; RooRealVar nbkg4("nbkg4","number of background events",1,1,500) ; RooRealVar nbkg5("nbkg5","number of background events",1,0,100) ; RooAddPdf model1("sum1","bkg+bw",RooArgList(bxCB,Cheb),RooArgList(nsig,nbkg)) ; RooAddPdf model2("sum2","bkg+bw",RooArgList(bxLa2,Cheb),RooArgList(nsig,nbkg)) ; RooAddPdf model3("sum3","bkg+bw",RooArgList(bxg3,Cheb),RooArgList(nsig,nbkg)) ; RooAddPdf model4("sum4","bkg+bw",RooArgList(bxg4,Cheb),RooArgList(nsig,nbkg)) ; RooAddPdf model5("sum5","bkg+bw",RooArgList(bxLa5,Cheb),RooArgList(nsig,nbkg)) ; /* RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.9,0.,1.) ; RooAddPdf bxCB_Cheb("bxCB+cheb","bxCB+cheb",RooArgList(bxCB,Cheb),sig1frac); RooAddPdf bxLa2_Cheb("bxLa2+cheb","bxLa2+cheb",RooArgList(bxLa2,Cheb),sig1frac); RooAddPdf bxg3_Cheb("bxg3+cheb","bxg3+cheb",RooArgList(bxg3,Cheb),sig1frac); RooAddPdf bxg4_Cheb("bxg4+cheb","bxg4+cheb",RooArgList(bxg4,Cheb),sig1frac); RooAddPdf bxLa5_Cheb("bxLa5+cheb","bxLa5+cheb",RooArgList(bxLa5,Cheb),sig1frac); RooExtendPdf model1("esig","extended signal p.d.f",bxCB_Cheb,n1) ; RooExtendPdf model2("esig","extended signal p.d.f",bxLa2_Cheb,n2) ; RooExtendPdf model3("esig","extended signal p.d.f",bxg3_Cheb,n3) ; RooExtendPdf model4("esig","extended signal p.d.f",bxg4_Cheb,n4) ; RooExtendPdf model5("esig","extended signal p.d.f",bxLa5_Cheb,n5) ; RooExtendPdf model6("esig","extended signal p.d.f",bxLa2_Cheb,n6) ; */ // RooAddPdf model("sum","bw",RooArgList(bwxxx),RooArgList(nsig)) ; // RooRealVar nsig("f","f",0.1,0.,1.) ; // RooAddPdf model("model","model",RooArgList(bwtmp,px),f) ;// // // TFile *f1 = new TFile("./Tag_probe_Data2015B_hist.root"); TH1F *h_moreone_35_50_B=(TH1F*)f1->Get("moreone_35_50_B"); TH1F *h_moreone_50_80_B=(TH1F*)f1->Get("moreone_50_80_B"); TH1F *h_moreone_80_120_B=(TH1F*)f1->Get("moreone_80_120_B"); TH1F *h_moreone_120_200_B=(TH1F*)f1->Get("moreone_120_200_B"); TH1F *h_moreone_200_plus_B=(TH1F*)f1->Get("moreone_200_plus_B"); TH1F *h_moreone_35_50_E=(TH1F*)f1->Get("moreone_35_50_E"); TH1F *h_moreone_50_80_E=(TH1F*)f1->Get("moreone_50_80_E"); TH1F *h_moreone_80_120_E=(TH1F*)f1->Get("moreone_80_120_E"); TH1F *h_moreone_120_200_E=(TH1F*)f1->Get("moreone_120_200_E"); TH1F *h_moreone_200_plus_E=(TH1F*)f1->Get("moreone_200_plus_E"); RooDataHist H_moreone_35_50_B("H_moreone_35_50_B","",x,h_moreone_35_50_B); RooDataHist H_moreone_50_80_B("H_moreone_50_80_B","",x,h_moreone_50_80_B); RooDataHist H_moreone_80_120_B("H_moreone_80_120_B","",x,h_moreone_80_120_B); RooDataHist H_moreone_120_200_B("H_moreone_120_200_B","",x,h_moreone_120_200_B); RooDataHist H_moreone_200_plus_B("H_moreone_200_plus_B","",x,h_moreone_200_plus_B); RooDataHist H_moreone_35_50_E("H_moreone_35_50_E","",x,h_moreone_35_50_E); RooDataHist H_moreone_50_80_E("H_moreone_50_80_E","",x,h_moreone_50_80_E); RooDataHist H_moreone_80_120_E("H_moreone_80_120_E","",x,h_moreone_80_120_E); RooDataHist H_moreone_120_200_E("H_moreone_120_200_E","",x,h_moreone_120_200_E); RooDataHist H_moreone_200_plus_E("H_moreone_200_plus_E","",x,h_moreone_200_plus_E); //// Fix some parameters sigmean.setConstant(kTRUE); // sigwidth.setConstant(kTRUE); // rr = (RooFitResult*) model.fitTo(hmc,Extended(),Minos(kFALSE),Save(kTRUE)); // sum1.fitTo(hdata,Extended()) ; // --- Plot toy data and composite PDF overlaid --- // set Margins for labels etc. /* gStyle->SetPadLeftMargin(0.17); gStyle->SetPadBottomMargin(0.17); gStyle->SetPadRightMargin(0.05); gStyle->SetPadTopMargin(0.05); */ TLatex* Label = new TLatex(0.2 , 0.95 , "CMS Interal, #sqrt{s} = 13 TeV, 50 ns, 49.98 pb^{-1}"); Label->SetTextSize(0.05); Label->SetNDC(); TLatex* Label_BWXLa = new TLatex(0.15 , 0.7 , "BW#otimesLandau + Chebychev"); Label_BWXLa->SetTextSize(0.05); Label_BWXLa->SetNDC(); TLatex* Label_BWXCB = new TLatex(0.15 , 0.7 , "BW#otimesCB + Chebychev"); Label_BWXCB->SetTextSize(0.05); Label_BWXCB->SetNDC(); TLatex* Label_BWXGauss = new TLatex(0.15 , 0.7 , "BW#otimesGauss + Chebychev"); Label_BWXGauss->SetTextSize(0.05); Label_BWXGauss->SetNDC(); /* RooFitResult* m_35_50_B = model1.fitTo(H_moreone_35_50_B,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_35_50_B = x.frame(); H_moreone_35_50_B.plotOn(xframe_m_35_50_B,DataError(RooAbsData::SumW2)) ; model1.plotOn(xframe_m_35_50_B) ; model1.plotOn(xframe_m_35_50_B,Components(Cheb),LineStyle(kDashed),LineColor(kRed)); model1.paramOn(xframe_m_35_50_B,Layout(0.55)) ; TCanvas* ca1 = new TCanvas("ca1","ca1",600,400) ; TLatex* N_1 = new TLatex(0.15 , 0.8 , "Barrel, E_{T}^{probe}(35-50GeV)"); N_1->SetTextSize(0.05); N_1->SetNDC(); xframe_m_35_50_B->addObject(N_1); xframe_m_35_50_B->addObject(Label); xframe_m_35_50_B->addObject(Label_BWXCB); xframe_m_35_50_B->SetTitle(""); xframe_m_35_50_B->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_35_50_B->GetXaxis()->CenterTitle(true); xframe_m_35_50_B->GetXaxis()->SetTitleSize(0.08); xframe_m_35_50_B->GetXaxis()->SetLabelSize(0.06); xframe_m_35_50_B->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_35_50_B->GetYaxis()->CenterTitle(true); xframe_m_35_50_B->GetYaxis()->SetTitleSize(0.08); xframe_m_35_50_B->GetYaxis()->SetLabelSize(0.06); xframe_m_35_50_B->SetTitleOffset(0.7, "Y"); xframe_m_35_50_B->SetTitleOffset(0.8, "X"); xframe_m_35_50_B->Draw(); RooFitResult* m_50_80_B = model2.fitTo(H_moreone_50_80_B,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_50_80_B = x.frame(); H_moreone_50_80_B.plotOn(xframe_m_50_80_B,DataError(RooAbsData::SumW2)) ; model2.plotOn(xframe_m_50_80_B) ; model2.plotOn(xframe_m_50_80_B,Components(Cheb),LineStyle(kDashed),LineColor(kRed)) ; model2.paramOn(xframe_m_50_80_B,Layout(0.55)) ; TCanvas* ca2 = new TCanvas("ca2","ca2",600,400) ; TLatex* N_2 = new TLatex(0.15 , 0.8 , "Barrel, E_{T}^{probe}(50-80GeV)"); N_2->SetTextSize(0.06); N_2->SetNDC(); xframe_m_50_80_B->addObject(N_2); xframe_m_50_80_B->addObject(Label); xframe_m_50_80_B->addObject(Label_BWXLa); xframe_m_50_80_B->SetTitle(""); xframe_m_50_80_B->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_50_80_B->GetXaxis()->CenterTitle(true); xframe_m_50_80_B->GetXaxis()->SetTitleSize(0.08); xframe_m_50_80_B->GetXaxis()->SetLabelSize(0.06); xframe_m_50_80_B->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_50_80_B->GetYaxis()->CenterTitle(true); xframe_m_50_80_B->GetYaxis()->SetTitleSize(0.08); xframe_m_50_80_B->GetYaxis()->SetLabelSize(0.06); xframe_m_50_80_B->SetTitleOffset(0.7, "Y"); xframe_m_50_80_B->SetTitleOffset(0.8, "X"); xframe_m_50_80_B->Draw(); RooFitResult* m_80_120_B = model3.fitTo(H_moreone_80_120_B,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_80_120_B = x.frame(); H_moreone_80_120_B.plotOn(xframe_m_80_120_B,DataError(RooAbsData::SumW2)) ; model3.plotOn(xframe_m_80_120_B) ; model3.plotOn(xframe_m_80_120_B,Components(Cheb),LineStyle(kDashed),LineColor(kRed)) ; model3.paramOn(xframe_m_80_120_B,Layout(0.55)) ; TCanvas* ca3 = new TCanvas("ca3","ca3",600,400) ; TLatex* N_3 = new TLatex(0.15 , 0.8 , "Barrel, E_{T}^{probe}(80-120GeV)"); N_3->SetTextSize(0.06); N_3->SetNDC(); xframe_m_80_120_B->addObject(N_3); xframe_m_80_120_B->addObject(Label); xframe_m_80_120_B->addObject(Label_BWXGauss); xframe_m_80_120_B->SetTitle(""); xframe_m_80_120_B->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_80_120_B->GetXaxis()->CenterTitle(true); xframe_m_80_120_B->GetXaxis()->SetTitleSize(0.08); xframe_m_80_120_B->GetXaxis()->SetLabelSize(0.06); xframe_m_80_120_B->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_80_120_B->GetYaxis()->CenterTitle(true); xframe_m_80_120_B->GetYaxis()->SetTitleSize(0.08); xframe_m_80_120_B->GetYaxis()->SetLabelSize(0.06); xframe_m_80_120_B->SetTitleOffset(0.7, "Y"); xframe_m_80_120_B->SetTitleOffset(0.8, "X"); xframe_m_80_120_B->Draw(); RooFitResult* m_120_200_B = model4.fitTo(H_moreone_120_200_B,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_120_200_B = x.frame(); H_moreone_120_200_B.plotOn(xframe_m_120_200_B,DataError(RooAbsData::SumW2)) ; model4.plotOn(xframe_m_120_200_B) ; model4.plotOn(xframe_m_120_200_B,Components(Cheb),LineStyle(kDashed),LineColor(kRed)) ; model4.paramOn(xframe_m_120_200_B,Layout(0.55)) ; TCanvas* ca4 = new TCanvas("ca4","ca4",600,400) ; TLatex* N_4 = new TLatex(0.15 , 0.8 , "Barrel, E_{T}^{probe}(120-200GeV)"); N_4->SetTextSize(0.06); N_4->SetNDC(); xframe_m_120_200_B->addObject(N_4); xframe_m_120_200_B->addObject(Label); xframe_m_120_200_B->addObject(Label_BWXGauss); xframe_m_120_200_B->SetTitle(""); xframe_m_120_200_B->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_120_200_B->GetXaxis()->CenterTitle(true); xframe_m_120_200_B->GetXaxis()->SetTitleSize(0.08); xframe_m_120_200_B->GetXaxis()->SetLabelSize(0.06); xframe_m_120_200_B->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_120_200_B->GetYaxis()->CenterTitle(true); xframe_m_120_200_B->GetYaxis()->SetTitleSize(0.08); xframe_m_120_200_B->GetYaxis()->SetLabelSize(0.06); xframe_m_120_200_B->SetTitleOffset(0.7, "Y"); xframe_m_120_200_B->SetTitleOffset(0.8, "X"); xframe_m_120_200_B->Draw(); RooFitResult* m_200_plus_B = model5.fitTo(H_moreone_200_plus_B,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_200_plus_B = x.frame(); H_moreone_200_plus_B.plotOn(xframe_m_200_plus_B,DataError(RooAbsData::SumW2)) ; model5.plotOn(xframe_m_200_plus_B) ; model5.plotOn(xframe_m_200_plus_B,Components(Cheb),LineStyle(kDashed),LineColor(kRed)) ; model5.paramOn(xframe_m_200_plus_B,Layout(0.55)) ; TCanvas* ca5 = new TCanvas("ca5","ca5",600,400) ; TLatex* N_5 = new TLatex(0.15 , 0.8 , "Barrel, E_{T}^{probe}(>200GeV)"); N_5->SetTextSize(0.06); N_5->SetNDC(); xframe_m_200_plus_B->addObject(N_5); xframe_m_200_plus_B->addObject(Label); xframe_m_200_plus_B->addObject(Label_BWXLa); xframe_m_200_plus_B->SetTitle(""); xframe_m_200_plus_B->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_200_plus_B->GetXaxis()->CenterTitle(true); xframe_m_200_plus_B->GetXaxis()->SetTitleSize(0.08); xframe_m_200_plus_B->GetXaxis()->SetLabelSize(0.06); xframe_m_200_plus_B->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_200_plus_B->GetYaxis()->CenterTitle(true); xframe_m_200_plus_B->GetYaxis()->SetTitleSize(0.08); xframe_m_200_plus_B->GetYaxis()->SetLabelSize(0.06); xframe_m_200_plus_B->SetTitleOffset(0.7, "Y"); xframe_m_200_plus_B->SetTitleOffset(0.8, "X"); xframe_m_200_plus_B->Draw(); RooFitResult* m_35_50_E = model2.fitTo(H_moreone_35_50_E,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_35_50_E = x.frame(); H_moreone_35_50_E.plotOn(xframe_m_35_50_E,DataError(RooAbsData::SumW2)) ; model2.plotOn(xframe_m_35_50_E) ; model2.plotOn(xframe_m_35_50_E,Components(Cheb),LineStyle(kDashed),LineColor(kRed)); model2.paramOn(xframe_m_35_50_E,Layout(0.55)) ; TCanvas* ca6 = new TCanvas("ca6","ca6",600,400) ; TLatex* N_6 = new TLatex(0.15 , 0.8 , "Earrel, E_{T}^{probe}(35-50GeV)"); N_6->SetTextSize(0.05); N_6->SetNDC(); xframe_m_35_50_E->addObject(N_6); xframe_m_35_50_E->addObject(Label); xframe_m_35_50_E->addObject(Label_BWXLa); xframe_m_35_50_E->SetTitle(""); xframe_m_35_50_E->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_35_50_E->GetXaxis()->CenterTitle(true); xframe_m_35_50_E->GetXaxis()->SetTitleSize(0.08); xframe_m_35_50_E->GetXaxis()->SetLabelSize(0.06); xframe_m_35_50_E->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_35_50_E->GetYaxis()->CenterTitle(true); xframe_m_35_50_E->GetYaxis()->SetTitleSize(0.08); xframe_m_35_50_E->GetYaxis()->SetLabelSize(0.06); xframe_m_35_50_E->SetTitleOffset(0.7, "Y"); xframe_m_35_50_E->SetTitleOffset(0.8, "X"); xframe_m_35_50_E->Draw(); RooFitResult* m_50_80_E = model2.fitTo(H_moreone_50_80_E,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_50_80_E = x.frame(); H_moreone_50_80_E.plotOn(xframe_m_50_80_E,DataError(RooAbsData::SumW2)) ; model2.plotOn(xframe_m_50_80_E) ; model2.plotOn(xframe_m_50_80_E,Components(Cheb),LineStyle(kDashed),LineColor(kRed)) ; model2.paramOn(xframe_m_50_80_E,Layout(0.55)) ; TCanvas* ca7 = new TCanvas("ca7","ca7",600,400) ; TLatex* N_7 = new TLatex(0.15 , 0.8 , "Earrel, E_{T}^{probe}(50-80GeV)"); N_7->SetTextSize(0.06); N_7->SetNDC(); xframe_m_50_80_E->addObject(N_7); xframe_m_50_80_E->addObject(Label); xframe_m_50_80_E->addObject(Label_BWXLa); xframe_m_50_80_E->SetTitle(""); xframe_m_50_80_E->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_50_80_E->GetXaxis()->CenterTitle(true); xframe_m_50_80_E->GetXaxis()->SetTitleSize(0.08); xframe_m_50_80_E->GetXaxis()->SetLabelSize(0.06); xframe_m_50_80_E->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_50_80_E->GetYaxis()->CenterTitle(true); xframe_m_50_80_E->GetYaxis()->SetTitleSize(0.08); xframe_m_50_80_E->GetYaxis()->SetLabelSize(0.06); xframe_m_50_80_E->SetTitleOffset(0.7, "Y"); xframe_m_50_80_E->SetTitleOffset(0.8, "X"); xframe_m_50_80_E->Draw(); RooFitResult* m_80_120_E = model1.fitTo(H_moreone_80_120_E,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_80_120_E = x.frame(); H_moreone_80_120_E.plotOn(xframe_m_80_120_E,DataError(RooAbsData::SumW2)) ; model1.plotOn(xframe_m_80_120_E) ; model1.plotOn(xframe_m_80_120_E,Components(Cheb),LineStyle(kDashed),LineColor(kRed)) ; model1.paramOn(xframe_m_80_120_E,Layout(0.55)) ; TCanvas* ca8 = new TCanvas("ca8","ca8",600,400) ; TLatex* N_8 = new TLatex(0.15 , 0.8 , "Earrel, E_{T}^{probe}(80-120GeV)"); N_8->SetTextSize(0.06); N_8->SetNDC(); xframe_m_80_120_E->addObject(N_8); xframe_m_80_120_E->addObject(Label); xframe_m_80_120_E->addObject(Label_BWXCB); xframe_m_80_120_E->SetTitle(""); xframe_m_80_120_E->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_80_120_E->GetXaxis()->CenterTitle(true); xframe_m_80_120_E->GetXaxis()->SetTitleSize(0.08); xframe_m_80_120_E->GetXaxis()->SetLabelSize(0.06); xframe_m_80_120_E->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_80_120_E->GetYaxis()->CenterTitle(true); xframe_m_80_120_E->GetYaxis()->SetTitleSize(0.08); xframe_m_80_120_E->GetYaxis()->SetLabelSize(0.06); xframe_m_80_120_E->SetTitleOffset(0.7, "Y"); xframe_m_80_120_E->SetTitleOffset(0.8, "X"); xframe_m_80_120_E->Draw(); RooFitResult* m_120_200_E = model4.fitTo(H_moreone_120_200_E,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_120_200_E = x.frame(); H_moreone_120_200_E.plotOn(xframe_m_120_200_E,DataError(RooAbsData::SumW2)) ; model4.plotOn(xframe_m_120_200_E) ; model4.plotOn(xframe_m_120_200_E,Components(Cheb),LineStyle(kDashed),LineColor(kRed)) ; model4.paramOn(xframe_m_120_200_E,Layout(0.55)) ; TCanvas* ca9 = new TCanvas("ca9","ca9",600,400) ; TLatex* N_9 = new TLatex(0.15 , 0.8 , "Earrel, E_{T}^{probe}(120-200GeV)"); N_9->SetTextSize(0.06); N_9->SetNDC(); xframe_m_120_200_E->addObject(N_9); xframe_m_120_200_E->addObject(Label); xframe_m_120_200_E->addObject(Label_BWXGauss); xframe_m_120_200_E->SetTitle(""); xframe_m_120_200_E->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_120_200_E->GetXaxis()->CenterTitle(true); xframe_m_120_200_E->GetXaxis()->SetTitleSize(0.08); xframe_m_120_200_E->GetXaxis()->SetLabelSize(0.06); xframe_m_120_200_E->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_120_200_E->GetYaxis()->CenterTitle(true); xframe_m_120_200_E->GetYaxis()->SetTitleSize(0.08); xframe_m_120_200_E->GetYaxis()->SetLabelSize(0.06); xframe_m_120_200_E->SetTitleOffset(0.7, "Y"); xframe_m_120_200_E->SetTitleOffset(0.8, "X"); xframe_m_120_200_E->Draw(); */ RooFitResult* m_200_plus_E = model5.fitTo(H_moreone_200_plus_E,Minos(kFALSE),Range(60,120),Save(kTRUE)) ; RooPlot* xframe_m_200_plus_E = x.frame(); H_moreone_200_plus_E.plotOn(xframe_m_200_plus_E,DataError(RooAbsData::SumW2)) ; model5.plotOn(xframe_m_200_plus_E) ; model5.plotOn(xframe_m_200_plus_E,Components(Cheb),LineStyle(kDashed),LineColor(kRed)) ; model5.paramOn(xframe_m_200_plus_E,Layout(0.55)) ; TCanvas* ca10 = new TCanvas("ca10","ca10",600,400) ; TLatex* N_10 = new TLatex(0.15 , 0.8 , "Earrel, E_{T}^{probe}(>200GeV)"); N_10->SetTextSize(0.06); N_10->SetNDC(); xframe_m_200_plus_E->addObject(N_10); xframe_m_200_plus_E->addObject(Label); xframe_m_200_plus_E->addObject(Label_BWXLa); xframe_m_200_plus_E->SetTitle(""); xframe_m_200_plus_E->SetYTitle("Number / 1 GeV/c^{2}"); xframe_m_200_plus_E->GetXaxis()->CenterTitle(true); xframe_m_200_plus_E->GetXaxis()->SetTitleSize(0.08); xframe_m_200_plus_E->GetXaxis()->SetLabelSize(0.06); xframe_m_200_plus_E->SetXTitle("M_{ee}(GeV/c^{2})"); xframe_m_200_plus_E->GetYaxis()->CenterTitle(true); xframe_m_200_plus_E->GetYaxis()->SetTitleSize(0.08); xframe_m_200_plus_E->GetYaxis()->SetLabelSize(0.06); xframe_m_200_plus_E->SetTitleOffset(0.7, "Y"); xframe_m_200_plus_E->SetTitleOffset(0.8, "X"); xframe_m_200_plus_E->Draw(); // --- Plot frame on canvas --- /* xframe->SetTitle(""); xframe->SetYTitle("Number / (GeV/c^{2})"); xframe->GetXaxis()->CenterTitle(true); xframe->GetXaxis()->SetTitleSize(0.08); xframe->GetXaxis()->SetLabelSize(0.06); xframe->SetXTitle("M^{Z}(GeV/c^{2})"); xframe->GetYaxis()->CenterTitle(true); xframe->GetYaxis()->SetTitleSize(0.08); xframe->GetYaxis()->SetLabelSize(0.06); xframe->SetNdivisions(510,"X"); */ // std::cout<<"N_m_35_50_B="<<nsig1.getVal()<<" Error="<<nsig1.getError()<<" bgk="<<nbgk1.getVal()<<"error="<<<<std::endl; // std::cout<<"N_m_50_80_B="<<nsig2.getVal()<<" Error="<<nsig2.getError()<<std::endl; // std::cout<<"N_m_80_120_B="<<nsig3.getVal()<<" Error="<<nsig3.getError()<<std::endl; // std::cout<<"N_m_120_200_B="<<nsig4.getVal()<<" Error="<<nsig4.getError()<<std::endl; // std::cout<<"N_m_200_plus_B="<<nsig5.getVal()<<" Error="<<nsig5.getError()<<std::endl; // std::cout<<"N_m_35_50_E="<<nsig6.getVal()<<" Error="<<nsig6.getError()<<std::endl; // std::cout<<"N_m_50_80_E="<<nsig7.getVal()<<" Error="<<nsig7.getError()<<std::endl; // std::cout<<"N_m_80_120_E="<<nsig8.getVal()<<" Error="<<nsig8.getError()<<std::endl; // std::cout<<"N_m_120_200_E="<<nsig9.getVal()<<" Error="<<nsig9.getError()<<std::endl; // std::cout<<"N_m_200_plus_E="<<nsig10.getVal()<<" Error="<<nsig10.getError()<<std::endl; }
TCanvas* example_plot( int iPeriod, int iPos ) { // if( iPos==0 ) relPosX = 0.12; int W = 800; int H = 600; // // Simple example of macro: plot with CMS name and lumi text // (this script does not pretend to work in all configurations) // iPeriod = 1*(0/1 7 TeV) + 2*(0/1 8 TeV) + 4*(0/1 13 TeV) // For instance: // iPeriod = 3 means: 7 TeV + 8 TeV // iPeriod = 7 means: 7 TeV + 8 TeV + 13 TeV // Initiated by: Gautier Hamel de Monchenault (Saclay) // int H_ref = 600; int W_ref = 800; // references for T, B, L, R float T = 0.08*H_ref; float B = 0.12*H_ref; float L = 0.12*W_ref; float R = 0.04*W_ref; TString canvName = "FigExample_"; canvName += W; canvName += "-"; canvName += H; canvName += "_"; canvName += iPeriod; if( writeExtraText ) canvName += "-prelim"; if( iPos%10==0 ) canvName += "-out"; else if( iPos%10==1 ) canvName += "-left"; else if( iPos%10==2 ) canvName += "-center"; else if( iPos%10==3 ) canvName += "-right"; TCanvas* canv = new TCanvas(canvName,canvName,50,50,W,H); canv->SetFillColor(0); canv->SetBorderMode(0); canv->SetFrameFillStyle(0); canv->SetFrameBorderMode(0); canv->SetLeftMargin( L/W ); canv->SetRightMargin( R/W ); canv->SetTopMargin( T/H ); canv->SetBottomMargin( B/H ); canv->SetTickx(0); canv->SetTicky(0); TH1* h = new TH1F("h","h",40,70,110); h->GetXaxis()->SetNdivisions(6,5,0); h->GetXaxis()->SetTitle("m_{e^{+}e^{-}} (GeV)"); h->GetYaxis()->SetNdivisions(6,5,0); h->GetYaxis()->SetTitleOffset(1); h->GetYaxis()->SetTitle("Events / 0.5 GeV"); h->SetMaximum( 260 ); if( iPos==1 ) h->SetMaximum( 300 ); h->Draw(); int histLineColor = kOrange+7; int histFillColor = kOrange-2; float markerSize = 1.0; { TLatex latex; int n_ = 2; float x1_l = 0.92; float y1_l = 0.60; float dx_l = 0.30; float dy_l = 0.18; float x0_l = x1_l-dx_l; float y0_l = y1_l-dy_l; TPad* legend = new TPad("legend_0","legend_0",x0_l,y0_l,x1_l, y1_l ); // legend->SetFillColor( kGray ); legend->Draw(); legend->cd(); float ar_l = dy_l/dx_l; float x_l[1]; float ex_l[1]; float y_l[1]; float ey_l[1]; // float gap_ = 0.09/ar_l; float gap_ = 1./(n_+1); float bwx_ = 0.12; float bwy_ = gap_/1.5; x_l[0] = 1.2*bwx_; // y_l[0] = 1-(1-0.10)/ar_l; y_l[0] = 1-gap_; ex_l[0] = 0; ey_l[0] = 0.04/ar_l; TGraph* gr_l = new TGraphErrors(1, x_l, y_l, ex_l, ey_l ); gStyle->SetEndErrorSize(0); gr_l->SetMarkerSize(0.9); gr_l->Draw("0P"); latex.SetTextFont(42); latex.SetTextAngle(0); latex.SetTextColor(kBlack); latex.SetTextSize(0.25); latex.SetTextAlign(12); TLine line_; TBox box_; float xx_ = x_l[0]; float yy_ = y_l[0]; latex.DrawLatex(xx_+1.*bwx_,yy_,"Data"); yy_ -= gap_; box_.SetLineStyle( kSolid ); box_.SetLineWidth( 1 ); // box_.SetLineColor( kBlack ); box_.SetLineColor( histLineColor ); box_.SetFillColor( histFillColor ); box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 ); box_.SetFillStyle(0); box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 ); latex.DrawLatex(xx_+1.*bwx_,yy_,"Z #rightarrow e^{+}e^{-} (MC)"); canv->cd(); } { // Observed data TFile file_("histo.root","READ"); TH1F *data = (TH1*) (file_.Get("data")->Clone()); data->SetDirectory(0); data->SetMarkerStyle(20); data->SetMarkerSize(markerSize); TH1F *MC = (TH1*) (file_.Get("MC")->Clone()); MC->SetDirectory(0); MC->SetLineColor(histLineColor); MC->SetFillColor(histFillColor); MC->Draw("histsame"); data->Draw("esamex0"); file_.Close(); } // writing the lumi information and the CMS "logo" CMS_lumi( canv, iPeriod, iPos ); canv->Update(); canv->RedrawAxis(); canv->GetFrame()->Draw(); canv->Print(canvName+".pdf",".pdf"); canv->Print(canvName+".png",".png"); return canv; }
void drawCtauPlot(RooWorkspace& myws, // Local workspace string outputDir, // Output directory struct InputOpt opt, // Variable with run information (kept for legacy purpose) struct KinCuts cut, // Variable with current kinematic cuts string plotLabel, // The label used to define the output file name // Select the type of datasets to fit string DSTAG, // Specifies the type of datasets: i.e, DATA, MCJPSINP, ... bool isPbPb, // Define if it is PbPb (True) or PP (False) // Select the drawing options bool setLogScale, // Draw plot with log scale bool incSS, // Include Same Sign data int nBins, // Number of bins used for plotting bool paperStyle=false,// if true, print less info bool saveWS=true // save the workspace into a file ) { if (DSTAG.find("_")!=std::string::npos) DSTAG.erase(DSTAG.find("_")); string dsOSName = Form("dOS_%s_%s", DSTAG.c_str(), (isPbPb?"PbPb":"PP")); string dsSSName = Form("dSS_%s_%s", DSTAG.c_str(), (isPbPb?"PbPb":"PP")); // Create the main plot of the fit // RooPlot* frame = myws.var("invMass")->frame(Bins(nBins), Range(cut.dMuon.M.Min, cut.dMuon.M.Max)); RooPlot* frame = myws.var("ctau")->frame(Bins(nBins), Range(-1,3)); myws.data(dsOSName.c_str())->plotOn(frame, Name("dOS"), DataError(RooAbsData::SumW2), XErrorSize(0), MarkerColor(kBlack), LineColor(kBlack), MarkerSize(1.2)); if (paperStyle) TGaxis::SetMaxDigits(3); // to display powers of 10 if (incSS) { myws.data(dsSSName.c_str())->plotOn(frame, Name("dSS"), MarkerColor(kRed), LineColor(kRed), MarkerSize(1.2)); } myws.data(dsOSName.c_str())->plotOn(frame, Name("dOS"), DataError(RooAbsData::SumW2), XErrorSize(0), MarkerColor(kBlack), LineColor(kBlack), MarkerSize(1.2)); // set the CMS style setTDRStyle(); // Create the main canvas TCanvas *cFig = new TCanvas(Form("cMassFig_%s", (isPbPb?"PbPb":"PP")), "cMassFig",800,800); TPad *pad1 = new TPad(Form("pad1_%s", (isPbPb?"PbPb":"PP")),"",0,paperStyle ? 0 : 0.23,1,1); TPad *pad2 = new TPad(Form("pad2_%s", (isPbPb?"PbPb":"PP")),"",0,0,1,.228); TLine *pline = new TLine(cut.dMuon.M.Min, 0.0, cut.dMuon.M.Max, 0.0); // TPad *pad4 = new TPad("pad4","This is pad4",0.55,0.46,0.97,0.87); TPad *pad4 = new TPad("pad4","This is pad4",0.55,paperStyle ? 0.29 : 0.36,0.97,paperStyle ? 0.70 : 0.77); pad4->SetFillStyle(0); pad4->SetLeftMargin(0.28); pad4->SetRightMargin(0.10); pad4->SetBottomMargin(0.21); pad4->SetTopMargin(0.072); frame->SetTitle(""); frame->GetXaxis()->CenterTitle(kTRUE); if (!paperStyle) { frame->GetXaxis()->SetTitle(""); frame->GetXaxis()->SetTitleSize(0.045); frame->GetXaxis()->SetTitleFont(42); frame->GetXaxis()->SetTitleOffset(3); frame->GetXaxis()->SetLabelOffset(3); frame->GetYaxis()->SetLabelSize(0.04); frame->GetYaxis()->SetTitleSize(0.04); frame->GetYaxis()->SetTitleOffset(1.7); frame->GetYaxis()->SetTitleFont(42); } else { frame->GetXaxis()->SetTitle("#font[12]{l}_{J/#psi} (mm)"); frame->GetXaxis()->SetTitleOffset(1.1); frame->GetYaxis()->SetTitleOffset(1.45); frame->GetXaxis()->SetTitleSize(0.05); frame->GetYaxis()->SetTitleSize(0.05); } setRange(myws, frame, dsOSName, setLogScale, cut.dMuon.AbsRap.Min); if (paperStyle) { double Ydown = 0.1;//frame->GetMinimum(); double Yup = 0.9*frame->GetMaximum(); frame->GetYaxis()->SetRangeUser(Ydown,Yup); } cFig->cd(); pad2->SetTopMargin(0.02); pad2->SetBottomMargin(0.4); pad2->SetFillStyle(4000); pad2->SetFrameFillStyle(4000); if (!paperStyle) pad1->SetBottomMargin(0.015); //plot fit pad1->Draw(); pad1->cd(); frame->Draw(); pad1->SetLogy(setLogScale); // Drawing the text in the plot TLatex *t = new TLatex(); t->SetNDC(); t->SetTextSize(0.032); float dy = 0; t->SetTextSize(0.03); if (!paperStyle) { // do not print selection details for paper style t->DrawLatex(0.21, 0.86-dy, "2015 HI Soft Muon ID"); dy+=0.045; if (isPbPb) { t->DrawLatex(0.21, 0.86-dy, "HLT_HIL1DoubleMu0_v1"); dy+=0.045; } else { t->DrawLatex(0.21, 0.86-dy, "HLT_HIL1DoubleMu0_v1"); dy+=0.045; } } if (cut.dMuon.AbsRap.Min>0.1) {t->DrawLatex(0.20, 0.86-dy, Form("%.1f < |y^{#mu#mu}| < %.1f",cut.dMuon.AbsRap.Min,cut.dMuon.AbsRap.Max)); dy+=1.5*0.045;} else {t->DrawLatex(0.20, 0.86-dy, Form("|y^{#mu#mu}| < %.1f",cut.dMuon.AbsRap.Max)); dy+=1.5*0.045;} t->DrawLatex(0.20, 0.86-dy, Form("%g < p_{T}^{#mu#mu} < %g GeV/c",cut.dMuon.Pt.Min,cut.dMuon.Pt.Max)); dy+=0.045; t->DrawLatex(0.20, 0.86-dy, Form("%g < M^{#mu#mu} < %g GeV/c^{2}",cut.dMuon.M.Min,cut.dMuon.M.Max)); dy+=0.045; if (isPbPb) {t->DrawLatex(0.20, 0.86-dy, Form("Cent. %d-%d%%", (int)(cut.Centrality.Start/2), (int)(cut.Centrality.End/2))); dy+=0.045;} dy+=0.5*0.045; t->DrawLatex(0.20, 0.86-dy, "#mu in acceptance"); dy+=0.045; // Drawing the Legend double ymin = 0.7802; if (paperStyle) { ymin = 0.72; } TLegend* leg = new TLegend(0.5175, ymin, 0.7180, 0.8809); leg->SetTextSize(0.03); leg->AddEntry(frame->findObject("dOS"), (incSS?"Opposite Charge":"Data"),"pe"); if (incSS) { leg->AddEntry(frame->findObject("dSS"),"Same Charge","pe"); } leg->Draw("same"); //Drawing the title TString label; if (isPbPb) { if (opt.PbPb.RunNb.Start==opt.PbPb.RunNb.End){ label = Form("PbPb Run %d", opt.PbPb.RunNb.Start); } else { label = Form("%s [%s %d-%d]", "PbPb", "HIOniaL1DoubleMu0", opt.PbPb.RunNb.Start, opt.PbPb.RunNb.End); } } else { if (opt.pp.RunNb.Start==opt.pp.RunNb.End){ label = Form("PP Run %d", opt.pp.RunNb.Start); } else { label = Form("%s [%s %d-%d]", "PP", "DoubleMu0", opt.pp.RunNb.Start, opt.pp.RunNb.End); } } // CMS_lumi(pad1, isPbPb ? 105 : 104, 33, label); CMS_lumi(pad1, isPbPb ? 108 : 107, 33, ""); if (!paperStyle) gStyle->SetTitleFontSize(0.05); pad1->Update(); cFig->cd(); // Save the plot in different formats gSystem->mkdir(Form("%splot/%s/root/", outputDir.c_str(), DSTAG.c_str()), kTRUE); cFig->SaveAs(Form("%splot/%s/root/%s_%s_%s%s_pt%.0f%.0f_rap%.0f%.0f_cent%d%d.root", outputDir.c_str(), DSTAG.c_str(), DSTAG.c_str(), "Psi2SJpsi", (isPbPb?"PbPb":"PP"), plotLabel.c_str(), (cut.dMuon.Pt.Min*10.0), (cut.dMuon.Pt.Max*10.0), (cut.dMuon.AbsRap.Min*10.0), (cut.dMuon.AbsRap.Max*10.0), cut.Centrality.Start, cut.Centrality.End)); gSystem->mkdir(Form("%splot/%s/png/", outputDir.c_str(), DSTAG.c_str()), kTRUE); cFig->SaveAs(Form("%splot/%s/png/%s_%s_%s%s_pt%.0f%.0f_rap%.0f%.0f_cent%d%d.png", outputDir.c_str(), DSTAG.c_str(), DSTAG.c_str(), "Psi2SJpsi", (isPbPb?"PbPb":"PP"), plotLabel.c_str(), (cut.dMuon.Pt.Min*10.0), (cut.dMuon.Pt.Max*10.0), (cut.dMuon.AbsRap.Min*10.0), (cut.dMuon.AbsRap.Max*10.0), cut.Centrality.Start, cut.Centrality.End)); gSystem->mkdir(Form("%splot/%s/pdf/", outputDir.c_str(), DSTAG.c_str()), kTRUE); cFig->SaveAs(Form("%splot/%s/pdf/%s_%s_%s%s_pt%.0f%.0f_rap%.0f%.0f_cent%d%d.pdf", outputDir.c_str(), DSTAG.c_str(), DSTAG.c_str(), "Psi2SJpsi", (isPbPb?"PbPb":"PP"), plotLabel.c_str(), (cut.dMuon.Pt.Min*10.0), (cut.dMuon.Pt.Max*10.0), (cut.dMuon.AbsRap.Min*10.0), (cut.dMuon.AbsRap.Max*10.0), cut.Centrality.Start, cut.Centrality.End)); cFig->Clear(); cFig->Close(); // Save the workspace if (saveWS) { gSystem->mkdir(Form("%sresult/%s/", outputDir.c_str(), DSTAG.c_str()), kTRUE); TFile *file = NULL; file = new TFile(Form("%sresult/%s/FIT_%s_%s_%s%s_pt%.0f%.0f_rap%.0f%.0f_cent%d%d.root", outputDir.c_str(), DSTAG.c_str(), DSTAG.c_str(), "Psi2SJpsi", (isPbPb?"PbPb":"PP"), plotLabel.c_str(), (cut.dMuon.Pt.Min*10.0), (cut.dMuon.Pt.Max*10.0), (cut.dMuon.AbsRap.Min*10.0), (cut.dMuon.AbsRap.Max*10.0), cut.Centrality.Start, cut.Centrality.End), "RECREATE"); if (!file) { cout << "[ERROR] Output root file with fit results could not be created!" << endl; } else { file->cd(); myws.Write("workspace"); file->Write(); file->Close(); delete file; } } }
TF1* fit(TTree* nt, TTree* ntMC, Double_t ptmin, Double_t ptmax, int isMC) { static int count=0; count++; TCanvas* c= new TCanvas(Form("c%d",count),"",600,600); TH1D* h = new TH1D(Form("h-%d",count),"",nbinsmasshisto,minhisto,maxhisto); TH1D* hMCSignal = new TH1D(Form("hMCSignal-%d",count),"",nbinsmasshisto,minhisto,maxhisto); TH1D* hMCSwapped = new TH1D(Form("hMCSwapped-%d",count),"",nbinsmasshisto,minhisto,maxhisto); TF1* f = new TF1(Form("f%d",count),"[0]*([7]*([9]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[9])*Gaus(x,[1],[10])/(sqrt(2*3.14159)*[10]))+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]+[4]*x+[5]*x*x+[6]*x*x*x", 1.7, 2.0); if(isMC==1) nt->Project(Form("h-%d",count),"Dmass",Form("%s*(%s&&Dpt>%f&&Dpt<%f)",weight.Data(),seldata.Data(),ptmin,ptmax)); else nt->Project(Form("h-%d",count),"Dmass",Form("(%s&&Dpt>%f&&Dpt<%f)",seldata.Data(),ptmin,ptmax)); ntMC->Project(Form("hMCSignal-%d",count),"Dmass",Form("%s*(%s&&Dpt>%f&&Dpt<%f&&(Dgen==23333))",weight.Data(),selmc.Data(),ptmin,ptmax)); ntMC->Project(Form("hMCSwapped-%d",count),"Dmass",Form("%s*(%s&&Dpt>%f&&Dpt<%f&&(Dgen==23344))",weight.Data(),selmc.Data(),ptmin,ptmax)); /* TFile *fout=new TFile(Form("FitsFiles/Fits_%s_%d.root",collisionsystem.Data(),count),"recreate"); fout->cd(); hMCSignal->Write(); hMCSwapped->Write(); h->Write(); */ f->SetParLimits(4,-1000,1000); f->SetParLimits(10,0.001,0.05); f->SetParLimits(2,0.01,0.1); f->SetParLimits(8,0.02,0.2); f->SetParLimits(7,0,1); f->SetParLimits(9,0,1); f->SetParameter(0,setparam0); f->SetParameter(1,setparam1); f->SetParameter(2,setparam2); f->SetParameter(10,setparam10); f->SetParameter(9,setparam9); f->FixParameter(8,setparam8); f->FixParameter(7,1); f->FixParameter(1,fixparam1); f->FixParameter(3,0); f->FixParameter(4,0); f->FixParameter(5,0); f->FixParameter(6,0); h->GetEntries(); hMCSignal->Fit(Form("f%d",count),"q","",minhisto,maxhisto); hMCSignal->Fit(Form("f%d",count),"q","",minhisto,maxhisto); f->ReleaseParameter(1); hMCSignal->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f%d",count),"L m","",minhisto,maxhisto); f->FixParameter(1,f->GetParameter(1)); f->FixParameter(2,f->GetParameter(2)); f->FixParameter(10,f->GetParameter(10)); f->FixParameter(9,f->GetParameter(9)); f->FixParameter(7,0); f->ReleaseParameter(8); f->SetParameter(8,setparam8); hMCSwapped->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f%d",count),"L m","",minhisto,maxhisto); f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000))); f->FixParameter(8,f->GetParameter(8)); f->ReleaseParameter(3); f->ReleaseParameter(4); f->ReleaseParameter(5); f->ReleaseParameter(6); f->SetLineColor(kRed); h->Fit(Form("f%d",count),"q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"q","",minhisto,maxhisto); f->ReleaseParameter(1); //f->ReleaseParameter(2); // you need to release these two parameters if you want to perform studies on the sigma shape //f->ReleaseParameter(10); // you need to release these two parameters if you want to perform studies on the sigma shape h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L m","",minhisto,maxhisto); TF1* background = new TF1(Form("background%d",count),"[0]+[1]*x+[2]*x*x+[3]*x*x*x"); background->SetParameter(0,f->GetParameter(3)); background->SetParameter(1,f->GetParameter(4)); background->SetParameter(2,f->GetParameter(5)); background->SetParameter(3,f->GetParameter(6)); background->SetLineColor(4); background->SetRange(minhisto,maxhisto); background->SetLineStyle(2); TF1* mass = new TF1(Form("fmass%d",count),"[0]*([3]*([4]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[4])*Gaus(x,[1],[5])/(sqrt(2*3.14159)*[5])))"); mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10)); mass->SetParError(0,f->GetParError(0)); mass->SetParError(1,f->GetParError(1)); mass->SetParError(2,f->GetParError(2)); mass->SetParError(3,f->GetParError(7)); mass->SetParError(4,f->GetParError(9)); mass->SetParError(5,f->GetParError(10)); mass->SetFillColor(kOrange-3); mass->SetFillStyle(3002); mass->SetLineColor(kOrange-3); mass->SetLineWidth(3); mass->SetLineStyle(2); TF1* massSwap = new TF1(Form("fmassSwap%d",count),"[0]*(1-[2])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3])"); massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8)); massSwap->SetParError(0,f->GetParError(0)); massSwap->SetParError(1,f->GetParError(1)); massSwap->SetParError(2,f->GetParError(7)); massSwap->SetParError(3,f->GetParError(8)); massSwap->SetFillColor(kGreen+4); massSwap->SetFillStyle(3005); massSwap->SetLineColor(kGreen+4); massSwap->SetLineWidth(3); massSwap->SetLineStyle(1); h->SetXTitle("m_{#piK} (GeV/c^{2})"); h->SetYTitle("Entries / (5 MeV/c^{2})"); h->GetXaxis()->CenterTitle(); h->GetYaxis()->CenterTitle(); h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y"); h->GetXaxis()->SetTitleOffset(1.3); h->GetYaxis()->SetTitleOffset(1.8); h->GetXaxis()->SetLabelOffset(0.007); h->GetYaxis()->SetLabelOffset(0.007); h->GetXaxis()->SetTitleSize(0.045); h->GetYaxis()->SetTitleSize(0.045); h->GetXaxis()->SetTitleFont(42); h->GetYaxis()->SetTitleFont(42); h->GetXaxis()->SetLabelFont(42); h->GetYaxis()->SetLabelFont(42); h->GetXaxis()->SetLabelSize(0.04); h->GetYaxis()->SetLabelSize(0.04); h->SetMarkerSize(0.8); h->SetMarkerStyle(20); h->SetStats(0); h->Draw("e"); background->Draw("same"); mass->SetRange(minhisto,maxhisto); mass->Draw("same"); massSwap->SetRange(minhisto,maxhisto); massSwap->Draw("same"); f->Draw("same"); Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass; Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0); std::cout<<"YIELD="<<yield<<std::endl; TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillStyle(0); leg->AddEntry(h,"Data","pl"); leg->AddEntry(f,"Fit","l"); leg->AddEntry(mass,"D^{0}+#bar{D^{#lower[0.2]{0}}} Signal","f"); leg->AddEntry(massSwap,"K-#pi swapped","f"); leg->AddEntry(background,"Combinatorial","l"); leg->Draw("same"); TLatex Tl; Tl.SetNDC(); Tl.SetTextAlign(12); Tl.SetTextSize(0.04); Tl.SetTextFont(42); Tl.DrawLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary"); Tl.DrawLatex(0.65,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV",collisionsystem.Data())); TLatex* tex; tex = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax)); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.22,0.83,"|y| < 1.0"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); h->GetFunction(Form("f%d",count))->Delete(); TH1F* histo_copy_nofitfun = ( TH1F * ) h->Clone("histo_copy_nofitfun"); histo_copy_nofitfun->Draw("esame"); // if(nBins==1) c->SaveAs(Form("DMass-inclusive%s_%d.pdf",collisionsystem.Data(),count)); else c->SaveAs(Form("DMass%s_%d.pdf",collisionsystem.Data(),count)); return mass; }
int QA_calm_plots_diff(const char* filename1, const char* filename2, const char* type = "PipPip", const char* type2 = "PipPip", bool ifSave = false) { TFile* f1 = new TFile(filename1,"READ"); TH2F* hevmultPID = ((TH2F*) f1->Get(Form("hevmultPID%s",type))); TH1D* heta = ((TH1D*) f1->Get(Form("heta%s",type))); TH1D* hpt = ((TH1D*) f1->Get(Form("hpt%s",type))); TH1D* hphiS = ((TH1D*) f1->Get(Form("hphiS%s",type))); TH1D* hphiP = ((TH1D*) f1->Get(Form("hphiP%s",type))); TH1D* hpid1 = ((TH1D*) f1->Get(Form("hpid1%s",type))); TH1D* hpid2 = ((TH1D*) f1->Get(Form("hpid2%s",type))); TH1D* hevmultAll = ((TH1D*) f1->Get(Form("hevmultAll%s",type))); TH1D* hevmult = ((TH1D*) f1->Get(Form("hevmult%s",type))); TH1D* hevweight = ((TH1D*) f1->Get(Form("hevweight%s",type))); TH1D* hevweighttaken = ((TH1D*) f1->Get(Form("hevweighttaken%s",type))); TH1D* hevweightdensity= ((TH1D*) f1->Get(Form("hevweightdensity%s",type))); TH1D* hptTotal = ((TH1D*) f1->Get(Form("hptTotal%s",type))); TFile* f2 = new TFile(filename2,"READ"); TH2F* hevmultPID2 = ((TH2F*) f2->Get(Form("hevmultPID%s",type2))); TH1D* heta2 = ((TH1D*) f2->Get(Form("heta%s",type2))); TH1D* hpt2 = ((TH1D*) f2->Get(Form("hpt%s",type2))); TH1D* hphiS2 = ((TH1D*) f2->Get(Form("hphiS%s",type2))); TH1D* hphiP2 = ((TH1D*) f2->Get(Form("hphiP%s",type2))); TH1D* hpid12 = ((TH1D*) f2->Get(Form("hpid1%s",type2))); TH1D* hpid22 = ((TH1D*) f2->Get(Form("hpid2%s",type2))); TH1D* hevmultAll2 = ((TH1D*) f2->Get(Form("hevmultAll%s",type2))); TH1D* hevmult2 = ((TH1D*) f2->Get(Form("hevmult%s",type2))); TH1D* hevweight2 = ((TH1D*) f2->Get(Form("hevweight%s",type2))); TH1D* hevweighttaken2 = ((TH1D*) f2->Get(Form("hevweighttaken%s",type2))); TH1D* hevweightdensity2= ((TH1D*) f2->Get(Form("hevweightdensity%s",type2))); TH1D* hptTotal2 = ((TH1D*) f2->Get(Form("hptTotal%s",type))); int rebin = 2; double eta = 1.1; gStyle->SetOptStat(000);//111); const char* first = "";//Cons. laws only"; const char* second = "";//Minijets"; if(rebin>0) { heta->Rebin(rebin); hpt->Rebin(rebin); hphiS->Rebin(rebin); hphiP->Rebin(rebin); heta2->Rebin(rebin); hpt2->Rebin(rebin); hphiS2->Rebin(rebin); hphiP2->Rebin(rebin); } heta2->SetLineColor(kGreen+2); hpt2->SetLineColor(kGreen+2); hphiS2->SetLineColor(kGreen+1); hphiP2->SetLineColor(kGreen+2); hpid12->SetLineColor(kGreen+2); hpid22->SetLineColor(kGreen+2); hevmultAll2->SetLineColor(kGreen+2); hevmult2->SetLineColor(kGreen+2); heta->Scale(1./heta->Integral()); heta2->Scale(1./heta2->Integral()); hpt->Scale(1./hpt->Integral()); hpt2->Scale(1./hpt2->Integral()); hevmult->Scale(1./hevmult->Integral()); hevmult2->Scale(1./hevmult2->Integral()); hevmultAll->Scale(1./hevmultAll->Integral()); hevmultAll2->Scale(1./hevmultAll2->Integral()); hpid1->Scale(1./hpid1->Integral()); hpid2->Scale(1./hpid2->Integral()); hpid12->Scale(1./hpid12->Integral()); hpid22->Scale(1./hpid22->Integral()); hphiP->Scale(1./hphiP->Integral()); hphiS->Scale(1./hphiS->Integral()); hphiP2->Scale(1./hphiP2->Integral()); hphiS2->Scale(1./hphiS2->Integral()); hptTotal->Scale(1./hptTotal->Integral()); hptTotal2->Scale(1./hptTotal2->Integral()); TCanvas* canv = new TCanvas("canv", "GENBOD results", 10,10,3*550,2*400); canv->Divide(3,3); canv->cd(1); heta->Draw(); heta2->Draw("same"); canv->cd(2); hpt->GetXaxis()->SetRangeUser(0,5); hpt->Draw(); hpt2->Draw("same"); hptTotal->SetLineColor(kMagenta); hptTotal->Draw("same"); canv->cd(3); hphiS->Draw(); hphiP->SetLineColor(kRed); hphiP->Draw("same"); hphiP2->Draw("same"); hphiS2->Draw("same"); canv->cd(4); hpid1->Draw(); hpid12->Draw("same"); canv->cd(5); hpid2->Draw(); hpid22->Draw("same"); canv->cd(6); hevmultAll->GetXaxis()->SetRangeUser(5,41); hevmultAll->Draw(); hevmultAll2->Draw("same"); canv->cd(7); hevmult->GetXaxis()->SetRangeUser(0,41); hevmult->Draw(); hevmult2->Draw("same"); canv->cd(8); hevweight->Draw(); hevweight->Draw("same"); canv->cd(9); //hevweightdensity->SetLineColor(kRed); //hevweightdensity->Draw(); //hevweightdensity2->Draw("same"); hptTotal->Draw(); hptTotal2->SetLineColor(kGreen+2); hptTotal2->Draw("same"); TF1* Ptot = new TF1("Ptot","4.33538e-02*TMath::Landau(x,3.24886e+00,2.17010e+00)*exp(8.34570e-03*x)",0,30); Ptot->Draw("same"); TCanvas* canv2 = new TCanvas("canv2", "GENBOD results", 10,10,550,400); //canv->Divide(3,3); canv2->cd(); hevmultPID->Draw("colz"); double counter[11]; double counttrue[] = {1.493,1.493, 1.493,0.183, 0.183,0.083,0.083, 0.048, 0.048,0.183,0.183}; for(int i=1;i<12;i++) counter[i-1] = ((TH1F*)hevmultPID->ProjectionY("_py",i,i))->GetMean(); for(int i=1;i<12;i++) { TLatex *part = new TLatex(0.072*i+0.05,0.7,Form("%.2f",counter[i-1])); part->SetNDC(); //part->SetTextColor(kRed+2); part->SetTextFont(42); part->SetTextSize(0.04); part->SetLineWidth(2); part->Draw(); TLatex *part1 = new TLatex(0.072*i+0.05,0.6,Form("%.1f%%",counter[i-1]/counter[0]*100.)); cout<<Form("%.1f%%",counter[i-1]/counter[0]*100.)<<endl; part1->SetNDC(); part1->SetTextColor(kRed+2); part1->SetTextFont(42); part1->SetTextSize(0.03); part1->SetLineWidth(2); part1->Draw(); TLatex *part2 = new TLatex(0.072*i+0.05,0.5,Form("%.1f%%",counttrue[i-1]/counttrue[0]*100.)); cout<<Form("%.1f%%",counttrue[i-1]/counttrue[0]*100.)<<endl; part2->SetNDC(); part2->SetTextColor(kBlue+2); part2->SetTextFont(42); part2->SetTextSize(0.03); part2->SetLineWidth(2); part2->Draw(); } }
void drawcentffgamma() { TFile *_file0 = TFile::Open("all.root"); int save = 1; const int yaxismax = 5; const static int ncentbins = 4; float binwidth = 5.000000e-01; int centmins[] = {0,20,60,100,140}; int centmaxs[] = {20,60,100,200,200}; string cents[] = {"0-10%","10-30%","30-50%","50-100%","70-100%"}; TCanvas * c1_pbpbdata[ncentbins]; // ncentbins TH1D * hgammaffxi_pbpbdata_[ncentbins]; TH1D * hjetpt_pbpbdata_[ncentbins]; TH1D * hgammaffxi_refcone_pbpbdata_[ncentbins]; float njets_pbpbdata[ncentbins]; TLegend * leg_ff_pbpbdata[ncentbins]; TCanvas * c1_pbpbmc[ncentbins]; TH1D * hgammaffxi_pbpbmc_[ncentbins]; TH1D * hjetpt_pbpbmc_[ncentbins]; TH1D * hgammaffxi_refcone_pbpbmc_[ncentbins]; float njets_pbpbmc[ncentbins]; TLegend * leg_ff_pbpbmc[ncentbins]; TCanvas * c1_subpbpb[ncentbins]; TH2D * dummy_pbpbsub[ncentbins]; TH1D * clone_hgammaffxi_refcone_pbpbdata_[ncentbins]; TH1D * clone_hgammaffxi_pbpbdata_[ncentbins]; TH1D * clone_hgammaffxi_refcone_pbpbmc_[ncentbins]; TH1D * clone_hgammaffxi_pbpbmc_[ncentbins]; TLegend * leg_ff_pbpbsub[ncentbins]; TCanvas * call = new TCanvas("call","",1400,500); // makeMultiPanelCanvas(call,6,1,0,0,-2.99,0.2,0.04); // makeMultiPanelCanvas(call,6,1,0.02,0.0,-6,0.2,0.04); // makeMultiPanelCanvas(call,4,1,0,0,0.2,0.2,0.04); makeMultiPanelCanvas(call,ncentbins+1,1,0.02,0.0,-6,0.2,0.04); for (int icent = 0; icent < ncentbins; icent++) { // Raw FF pbpdata // c1_pbpbdata[icent] = new TCanvas(Form("c1_pbpbdata_%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_pbpbdata_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); hjetpt_pbpbdata_[icent] = (TH1D*) _file0->Get(Form("hjetpt_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_refcone_pbpbdata_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_refcone_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); njets_pbpbdata[icent] = hjetpt_pbpbdata_[icent]->Integral(); hgammaffxi_pbpbdata_[icent]->Sumw2(); hgammaffxi_refcone_pbpbdata_[icent]->Sumw2(); hgammaffxi_pbpbdata_[icent]->Scale(1.0/njets_pbpbdata[icent]/binwidth); hgammaffxi_refcone_pbpbdata_[icent]->Scale(1.0/njets_pbpbdata[icent]/binwidth); hgammaffxi_pbpbdata_[icent]->GetXaxis()->CenterTitle(); hgammaffxi_pbpbdata_[icent]->SetYTitle("dN/d#xi"); hgammaffxi_pbpbdata_[icent]->GetYaxis()->CenterTitle(); // hgammaffxi_pbpbdata_[icent]->Draw(); hgammaffxi_refcone_pbpbdata_[icent]->SetMarkerStyle(24); // hgammaffxi_refcone_pbpbdata_[icent]->Draw("same"); leg_ff_pbpbdata[icent] = new TLegend(0.23,0.59,0.50,0.92); leg_ff_pbpbdata[icent]->SetFillColor(0); leg_ff_pbpbdata[icent]->SetTextSize(0.05); leg_ff_pbpbdata[icent]->SetFillStyle(0); leg_ff_pbpbdata[icent]->SetTextFont(42); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_pbpbdata_[icent],"raw frag. func","p"); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_refcone_pbpbdata_[icent],"#eta reflected cone","p"); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_refcone_pbpbdata_[icent],"PbPb #sqrt{s_{NN}}=5 TeV",""); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_refcone_pbpbdata_[icent],"trk p_{T}>1 GeV",""); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_refcone_pbpbdata_[icent],"100>#gamma p_{T}>300 GeV",""); // leg_ff_pbpbdata[icent]->Draw(); // c1_pbpbdata[icent]->SaveAs("pbpbdata_unsubffspectrum_45_gamma_100.png"); // Raw FF pbpdata // Raw FF pbmc // c1_pbpbmc[icent] = new TCanvas(Form("c1_pbpbmc_%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); hjetpt_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hjetpt_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_refcone_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_refcone_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); njets_pbpbmc[icent] = hjetpt_pbpbmc_[icent]->Integral(); hgammaffxi_pbpbmc_[icent]->Sumw2(); hgammaffxi_refcone_pbpbmc_[icent]->Sumw2(); hgammaffxi_pbpbmc_[icent]->Scale(1.0/njets_pbpbmc[icent]/binwidth); hgammaffxi_refcone_pbpbmc_[icent]->Scale(1.0/njets_pbpbmc[icent]/binwidth); hgammaffxi_pbpbmc_[icent]->GetXaxis()->CenterTitle(); hgammaffxi_pbpbmc_[icent]->SetYTitle("dN/d#xi"); hgammaffxi_pbpbmc_[icent]->GetYaxis()->CenterTitle(); // hgammaffxi_pbpbmc_[icent]->Draw(); hgammaffxi_refcone_pbpbmc_[icent]->SetMarkerStyle(24); // hgammaffxi_refcone_pclone_hgammaffxi_refcone_pbpbdata_bpbmc_[icent]->Draw("same"); leg_ff_pbpbmc[icent] = new TLegend(0.22,0.59,0.49,0.92); leg_ff_pbpbmc[icent]->SetFillColor(0); leg_ff_pbpbmc[icent]->SetTextSize(0.05); leg_ff_pbpbmc[icent]->SetFillStyle(0); leg_ff_pbpbmc[icent]->SetTextFont(42); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_pbpbmc_[icent],"raw frag. func","p"); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_refcone_pbpbmc_[icent],"#eta reflected cone","p"); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_refcone_pbpbmc_[icent],"Pythia+Hydjet #hat{p}_{T}=",""); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_refcone_pbpbmc_[icent],"trk p_{T}>1 GeV",""); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_refcone_pbpbmc_[icent],"45>#gamma p_{T}>100 GeV",""); // leg_ff_pbpbmc[icent]->Draw(); // c1_pbpbmc[icent]->SaveAs("pbpbmc_unsubffspectrum_45_gamma_100.png"); // Raw FF pbpbmc // Eta cone subtracted FF pbpbdata and pbpbmc // c1_subpbpb[icent] = new TCanvas(Form("c1_subpbpb_%d_%d",centmins[icent],centmaxs[icent])); // call->cd(icent+2); call->cd(icent+2); dummy_pbpbsub[icent] = new TH2D(Form("dummy_pbpbsub_%d_%d",centmins[icent],centmaxs[icent]),";#xi;dN/d#xi",1,0.01,4.99,1,0,yaxismax); dummy_pbpbsub[icent]->GetXaxis()->SetTitleOffset(0.8); dummy_pbpbsub[icent]->GetXaxis()->CenterTitle(); dummy_pbpbsub[icent]->GetYaxis()->CenterTitle(); // if(icent!=0) // { dummy_pbpbsub[icent]->GetXaxis()->SetTitleSize(dummy_pbpbsub[icent]->GetXaxis()->GetTitleSize()*1.5); // } clone_hgammaffxi_refcone_pbpbdata_[icent] = (TH1D*) hgammaffxi_refcone_pbpbdata_[icent]->Clone(Form("clone_hgammaffxi_refcone_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_refcone_pbpbdata_[icent]->Scale(-1); clone_hgammaffxi_pbpbdata_[icent] = (TH1D*) hgammaffxi_pbpbdata_[icent]->Clone(Form("clone_hgammaffxi_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_pbpbdata_[icent]->Add(clone_hgammaffxi_refcone_pbpbdata_[icent]); clone_hgammaffxi_refcone_pbpbmc_[icent] = (TH1D*) hgammaffxi_refcone_pbpbmc_[icent]->Clone(Form("clone_hgammaffxi_refcone_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_refcone_pbpbmc_[icent]->Scale(-1); clone_hgammaffxi_pbpbmc_[icent] = (TH1D*) hgammaffxi_pbpbmc_[icent]->Clone(Form("clone_hgammaffxi_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_pbpbmc_[icent]->Add(clone_hgammaffxi_refcone_pbpbmc_[icent]); clone_hgammaffxi_pbpbmc_[icent]->SetMarkerColor(kRed); // fixedFontHist(dummy_pbpbsub[icent]); dummy_pbpbsub[icent]->Draw(); clone_hgammaffxi_pbpbdata_[icent]->Draw("same"); // hgammaffxi_pbpbmc_[icent]->Draw("same"); // hgammaffxi_refcone_pbpbmc_[icent]->Draw("same"); clone_hgammaffxi_pbpbmc_[icent]->Draw("same"); if(icent==0) { // leg_ff_pbpbsub[icent] = new TLegend(0.25,0.697,0.875,0.92); leg_ff_pbpbsub[icent] = new TLegend(0.05,0.697,0.27,0.92); leg_ff_pbpbsub[icent]->SetTextSize(0.05*1.3); } else { leg_ff_pbpbsub[icent] = new TLegend(0,0.697,0.27,0.92); // leg_ff_pbpbsub[icent]->SetTextSize(0.05*1.2); leg_ff_pbpbsub[icent]->SetTextSize(0.05*1.3); } leg_ff_pbpbsub[icent]->SetFillColor(0); leg_ff_pbpbsub[icent]->SetFillStyle(0); leg_ff_pbpbsub[icent]->SetTextFont(42); if(icent==0) { leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbdata_[icent],"PbPb #sqrt{s_{NN}}=5 TeV","p"); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"Pythia+Hydjet","p"); } else if(icent==1) { // leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"#eta cone sub",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"trk p_{T}>1 GeV, R < 0.3",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"100>#gamma p_{T}>300 GeV",""); } else if(icent==2) { leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"0.3 < |#eta^{jet}| < 1.6",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"p_{T}^{jet} > 40 GeV",""); } else { leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"",""); } leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],Form("%s",cents[icent].data()),""); leg_ff_pbpbsub[icent]->Draw(); // c1_subpbpb[icent]->SaveAs("pbpbdata_pbpbmc_etaconesubtracted_45_gamma_100.png"); // Eta cone subtracted FF pbpbdata and pbpbmc } call->cd(1); TH2D * axis_dummy = new TH2D("axis_dummy","",1,0.01,4.99,1,0,yaxismax); gStyle->SetFrameLineColor(0); axis_dummy->UseCurrentStyle(); axis_dummy->Draw("FB BB A"); TLatex * ldndxi = new TLatex(0.4,0.5,"dN/d#xi"); ldndxi->SetTextSize(ldndxi->GetTextSize()*1.3); ldndxi->SetNDC(); ldndxi->SetTextAngle(90); TLatex * laxis[yaxismax]; for (int ilatex = 0; ilatex < yaxismax; ilatex++) { laxis[ilatex] = new TLatex(3.,ilatex-0.1,Form("%d",ilatex)); laxis[ilatex]->SetTextSize(laxis[ilatex]->GetTextSize()*1.3); laxis[ilatex]->Draw(); } ldndxi->Draw(); // call->cd(1); // TLatex * ldndxi = new TLatex(0.7,0.5,"dN/d#xi"); // ldndxi->SetTextSize(ldndxi->GetTextSize()*1.2); // ldndxi->SetNDC(); // ldndxi->SetTextAngle(90); // ldndxi->Draw(); }
void offline(const char* FileName="test", Int_t mode = 0) { if (strcmp(FileName, "") == 0 || mode == 0 || mode > 2) { cout << "Error in input of offline('fileName',mode):" << endl << "mode 1: c/cbar; mode 2: b/bbar." << endl << "Need File Name: ''pythia_tree_Aug##_#''" << endl; abort(); } // Set Style parameters for this macro //gStyle->SetOptTitle(1); // Show Title (off by default for cleanliness) gErrorIgnoreLevel = kError; // Set Verbosity Level (kPrint shows all) // Set Output options Int_t number; checkBatchMode(); Bool_t makePDF = checkMakePDF(); Bool_t makeROOT= checkMakeRoot(); // Use mode input to decide whether C or B templates to work on char type[10] = "X"; if(mode == 1) sprintf(type, "C"); if(mode == 2) sprintf(type, "B"); // Open output file char fname[100]; TFile* file; if(makeROOT){ sprintf(fname,"/Users/zach/Research/pythia/ptHatTemplate/%s_%s_processed.root",FileName,type); file = new TFile(fname,"RECREATE"); if (file->IsOpen()==kFALSE) { std::cout << "!!! Outfile Not Opened !!!" << std::endl; makeROOT = kFALSE; } } // Initialize Histos for Summing and other global vars const Int_t numPtHatBins = 8; const Int_t numPtBins = anaConst::nPtBins; Float_t lowpt[numPtBins],highpt[numPtBins]; for(Int_t c=0; c< numPtBins; c++){ lowpt[c] = anaConst::lpt[c]; highpt[c] = anaConst::hpt[c]; } Float_t hptCut=anaConst::hptCut; Float_t hptMax=25; // Set max above range to allow overflow TH1F* ptHat = new TH1F("pThat", "" ,1500, 0, 150); TH1F* ptHatCorr = new TH1F("pThatCorrected", "" ,1500, 0, 150); TH3F* mh3delPhi; TH2F* mh2npePt; TH1F* hStats; TH2F* mh2ptHatPt; TH1D* projpthatall; char hist[100]; TH1F* delPhi[numPtBins]; TH1F* NpeY[numPtBins]; TH1F* ptNorm; TH1D* projDelPhi[numPtBins]; TH1D* projNpeY[numPtBins]; TH1D* projptHat[numPtBins]; TH1F* temp; TH1F* delPhi2535 = new TH1F("delPhi2535","",200,-10,10); TH1F* trigCount = new TH1F("trigCount","",10,0,10); Float_t norm2535; for(Int_t ptbin=0; ptbin<numPtBins; ptbin++) // initialize all before the actual sorting { delPhi[ptbin]= new TH1F(Form("delPhi_%i",ptbin), "Delta Phi" ,200, -10, 10); delPhi[ptbin]->Sumw2(); NpeY[ptbin] = new TH1F(Form("NpeY_%i",ptbin),"NpeY",60,-3,3); } ptNorm = new TH1F("ptNorm", "pT Norm" ,200, 0, 20); ptNorm ->Sumw2(); Float_t totalNorm[numPtBins]={0.}; Double_t wt=0.; Int_t pthatlow[numPtHatBins] = {0,1,2,4,8,16,32,64}; Int_t pthathigh[numPtHatBins]= {1,2,4,8,16,32,64,128}; // Make Canvases TCanvas* deltaPhi = new TCanvas("deltaPhi","Pythia Delta Phi",150,0,1150,1000); deltaPhi -> Divide(4,3); TCanvas* ptHatC = new TCanvas("ptHatC","ptHat Stitching Comparison",150,0,1150,1000); ptHatC -> Divide(1,2); TPaveText* lbl[numPtBins]; char textLabel[100]; char name[1000]; // Loop over all ptHat bins for(Int_t pthBin=0; pthBin < numPtHatBins; pthBin++) { // Open ROOT File (example: output/pythia_tree_Aug31_1_C2_4.root) sprintf(name,"/Users/zach/Research/pythia/ptHatTemplate/%s_%s%i_%i.root",FileName,type,pthatlow[pthBin],pthathigh[pthBin]); TFile *f = new TFile(name,"READ"); if (f->IsOpen()==kFALSE) { std::cout << "!!! File Not Found !!!" << std::endl; exit(1); } else { cout << name << " is open!" << endl;} char histName[100]; // Get Histos from run output sprintf(hist, "histo3D%s0", type); mh3delPhi = (TH3F*)f->Get(hist); sprintf(hist, "histos2D%s1", type); mh2npePt = (TH2F*)f->Get(hist); sprintf(hist, "histos2D%s10", type); mh2ptHatPt = (TH2F*)f->Get(hist); sprintf(hist, "hStatistics"); hStats = (TH1F*)f->Get(hist); sprintf(hist, "delPhi"); temp = (TH1F*)f->Get(hist); sprintf(hist, "trigCount"); trigCount = (TH1F*)f->Get(hist); // Calculate Weight factors wt = 1e9*1e-3*(hStats->GetBinContent(1)/hStats->GetBinContent(2)); // Taken from Zhenyu's method. The 1e# factors are luminosity(?) corrections? projpthatall = mh2ptHatPt->ProjectionY("test",0,-1); ptHat -> Add(projpthatall); ptHatCorr -> Add(projpthatall,wt); // pt bin independent delPhi2535 -> Add(temp,wt); // still need weight from pthat //trigCount -> Scale(wt); // " " " " " norm2535 += trigCount->GetBinContent(1); //delPhi2535 -> Scale(1./norm2535); // Analyze each ptH bin individually, adding to the overall hists for(Int_t ptbin=0; ptbin<numPtBins; ptbin++) { // DEBUGcout << "pthbin: " << pthBin << " ptbin: " << ptbin << endl; projDelPhi[ptbin] = mh3delPhi->ProjectionZ(Form("projDelPhi_%i",ptbin),mh3delPhi->GetXaxis()->FindBin(lowpt[ptbin]),mh3delPhi->GetXaxis()->FindBin(highpt[ptbin])-1,mh3delPhi->GetYaxis()->FindBin(hptCut),mh3delPhi->GetYaxis()->FindBin(hptMax)); projNpeY[ptbin] = mh2npePt->ProjectionY(Form("projNpeY_%i",ptbin),mh2npePt->GetXaxis()->FindBin(lowpt[ptbin]),mh2npePt->GetXaxis()->FindBin(highpt[ptbin])-1); projptHat[ptbin] = mh2ptHatPt->ProjectionY(Form("projPtHat_%i",ptbin),mh2ptHatPt->GetXaxis()->FindBin(lowpt[ptbin]),mh2ptHatPt->GetXaxis()->FindBin(highpt[ptbin])-1); delPhi[ptbin] -> Add(projDelPhi[ptbin],wt); NpeY[ptbin] -> Add(projNpeY[ptbin],wt); // Calculate scaling Factor Double_t Norm = NpeY[ptbin]->Integral(); ptNorm->SetBinContent(ptNorm->GetBin(ptbin+1),Norm); totalNorm[ptbin] += Norm; } } // For making plots ptHatC->cd(1); gPad-> SetLogy(); ptHat->GetXaxis()->SetTitle("pT-Hat (GeV/c)"); ptHat->SetTitle("Raw pT Hat"); ptHat->Draw(); ptHatC->cd(2); gPad-> SetLogy(); ptHatCorr->GetXaxis()->SetTitle("pT-Hat (GeV/c)"); ptHatCorr->SetTitle("Weighted pT Hat"); ptHatCorr->Draw(); for(Int_t ptbin=0; ptbin<numPtBins; ptbin++) { // Init necessary plotting tools lbl[ptbin] = new TPaveText(.2,.8,.5,.85,Form("NB NDC%i",ptbin)); sprintf(textLabel,"%.1f < P_{T,e} < %.1f",lowpt[ptbin],highpt[ptbin]); lbl[ptbin]->AddText(textLabel); lbl[ptbin]->SetFillColor(kWhite); deltaPhi->cd(ptbin+1); delPhi[ptbin]->GetXaxis()->SetTitle("#Delta#phi_{eh}"); // delPhi[ptbin]->Sumw2(); //cout << totalNorm[ptbin] << endl; //delPhi[ptbin]->Scale(wt); delPhi[ptbin]->GetYaxis()->SetTitle("1/N_{NPE} #upoint dN/d(#Delta)#phi"); delPhi[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5); if(ptbin == 0) { if(mode == 1) delPhi[ptbin]->SetTitle("Pythia NPE-had #Delta#phi - c/#bar{c}"); if(mode == 2) delPhi[ptbin]->SetTitle("Pythia NPE-had #Delta#phi - b/#bar{b}"); } else delPhi[ptbin]->SetTitle(""); if(ptbin < 13){ delPhi[ptbin]->Draw("E"); lbl[ptbin]->Draw("same"); } } // Make PDF with output canvases if(makePDF) { //Set front page TCanvas* fp = new TCanvas("fp","Front Page",100,0,1000,900); fp->cd(); TBox *bLabel = new TBox(0.01, 0.88, 0.99, 0.99); bLabel->SetFillColor(38); bLabel->Draw(); TLatex tl; tl.SetNDC(); tl.SetTextColor(kWhite); tl.SetTextSize(0.033); char tlName[100]; char tlName2[100]; TString titlename = FileName; int found = titlename.Last('/'); if(found >= 0){ titlename.Replace(0, found+1, ""); } sprintf(tlName, "RUN 12 NPE-h #Delta#phi Pythia Templates"); tl.SetTextSize(0.05); tl.SetTextColor(kWhite); tl.DrawLatex(0.05, 0.92,tlName); TBox *bFoot = new TBox(0.01, 0.01, 0.99, 0.12); bFoot->SetFillColor(38); bFoot->Draw(); tl.SetTextColor(kWhite); tl.SetTextSize(0.05); tl.DrawLatex(0.05, 0.05, (new TDatime())->AsString()); tl.SetTextColor(kBlack); tl.SetTextSize(0.03); tl.DrawLatex(0.1, 0.14, titlename); sprintf(tlName,"TEST"); tl.DrawLatex(0.1, 0.8,tlName); // Place canvases in order TCanvas* temp = new TCanvas(); sprintf(name, "%s.pdf[", FileName); temp->Print(name); sprintf(name, "%s.pdf", FileName); temp = fp; // print front page temp->Print(name); temp = ptHatC; temp->Print(name); temp = deltaPhi; temp->Print(name); sprintf(name, "%s.pdf]", FileName); temp->Print(name); } if(makeROOT) { file->Write(); file->Close(); } }
void analyzer_stack() { //int main(){ const int nfiles = 8; const int nhistos = 46; const int ndiscr = 5; TString leg_names[nfiles] = {/*"powheg, m(H) = 130 GeV","amc@NLO, m(H) = 125 GeV",*/"powheg, m(H) = 125 GeV" ,"QCD, H_{T}=100-200 GeV","QCD, H_{T}=200-300 GeV","QCD, H_{T}=300-500 GeV","QCD, H_{T}=500-700 GeV","QCD, H_{T}=700-1000 GeV","QCD, H_{T}=1500-2000 GeV","QCD, H_{T}=2000-Inf GeV"}; TString file_names[nfiles] = {/*"Spring15_powheg_M130","Spring15_amcatnlo_M125",*/"Spring15_powheg_M125","Spring15_QCD_HT100to200","Spring15_QCD_HT200to300","Spring15_QCD_HT300to500","Spring15_QCD_HT500to700","Spring15_QCD_HT700to1000","Spring15_QCD_HT1500to2000","Spring15_QCD_HT2000toInf"}; for (int i=0; i<nfiles; i++) { // file_names[i].Prepend("SingleBtag_"); file_names[i].Prepend("../data40pb/tree"); file_names[i].Append(".root"); } TString trigger = "DoubleBtag_"; //TString trigger = "SingleBtag_"; //TString dir_name= "plots_powheg_130/"; TString dir_name= "plots_powheg_125/"; //TString dir_name = "plots_amc/"; Double_t xsec[nfiles] = { /* 1.96, 2.16,*/2.16, 2.75E07, 6.52E03, 3.67E05, 2.94E04, 2.54E01, 1.74E06, 121.5 }; TLegend *leg = new TLegend(0.35,0.58,0.75,0.88); leg->SetBorderSize(0); leg->SetTextSize(0.04); TString hist_names[nhistos]= {"hJet1_pt","hJet2_pt","hJet3_pt","hJet4_pt","hJet1_eta","hJet2_eta","hJet3_eta","hJet4_eta","hJet1_phi","hJet2_phi","hJet3_phi","hJet4_phi","hMqq", "hEtaQQ", "hPhiBB", "hEtaSoftJets", "hPtSoftJets","hMassSoftJets","hHTsoft","hSoft_n2","hSoft_n5","hSoft_n10","hMbb","hqgl","hbtag","hqgl2","hbtag2","hPtSoftJets2","hPtSoftJets3","hcosOqqbb","hEtaQB1", "hEtaQB2", "hPhiQB1", "hPhiQB2","hx1","hx2","hVB1_mass","hVB2_mass","hEtot","hPxtot","hPytot","hPztot","hJet5_pt","hPtqqbb","hEtaqqbb","hPhiqqbb"}; std::string hist_names_sort[nhistos]; for (int i=0; i<nhistos; i++) { hist_names_sort[i] = hist_names[i]; } Float_t discriminators[nhistos]; TString stacks_names[nhistos]; for (int i=0; i<nhistos; i++) { stacks_names[i] = hist_names[i]; stacks_names[i].Prepend("s"); } TString output_names[nhistos]; for (int i=0; i<nhistos; i++) { output_names[i] = hist_names[i]; output_names[i].Prepend(dir_name); output_names[i].Prepend(trigger); output_names[i].Append(".png"); } const char *xaxis_names[100] = {"1^{st} Jet p_{T} (GeV)","2^{nd} Jet p_{T} (GeV)","3^{rd} Jet p_{T} (GeV)","4^{th} Jet p_{T} (GeV)","1^{st} Jet #eta", "2^{nd} Jet #eta", "3^{rd} Jet #eta", "4^{th} Jet #eta", "1^{st} Jet #phi", "2^{nd} Jet #phi", "3^{rd} Jet #phi", "4^{th} Jet #phi","m_{qq} (GeV)","|#Delta#eta_{qq}|","|#Delta#phi_{bb}|","#eta^{soft}","1^{st} Soft jet p_{T} (GeV)","m^{soft} (GeV)","H_{T}^{soft} (GeV)","N^{soft}","m_{bb} (GeV)", "QGL of the first quark jet candidate","CSV of 1^{st} b-jet","QGL of the second quark jet candidate","CSV of 2^{nd} b-jet","2^{nd} Soft jet p_{T} (GeV)","3^{rd} Soft jet p_{T} (GeV)","H_{T}^{soft 3 jets} (GeV)","cos#theta_{qqbb}","#Delta#eta_{qb}^{forward}","#Delta#eta_{qb}^{backward}","|#Delta#phi_{qb}^{forward}|","|#Delta#phi_{qb}^{backward}|","x_{1}","x_{2}","M_{W'_{1}} (GeV)","M_{W'_{2}} (GeV)","E^{tot} (GeV)","p_{x}^{tot} (GeV)","p_{y}^{tot} (GeV)","p_{z}^{tot} (GeV)", "5^{th} Jet p_{T} (GeV)"}; TH1F *signal_histos[100]; TH1F *discr_histos[100];//Mqq,delta eta, delta phi, qgl, btag //12,13,14,21,22 int discr_index[100] = {12,13,14,21,22};//not used now int files=0; THStack *stacks[100]; for (int i=0; i<nhistos; ++i) { stacks[i] = new THStack(stacks_names[i],""); } Double_t totalBG=0.; ofstream out_efficiency; ofstream out_discrimination; out_efficiency.open(trigger+dir_name+"efficiency.txt"); do { TFile *file_initial = new TFile(file_names[files]); file_initial->ls(); TString temp_number; temp_number.Form("%d",files); TH1F *histos[100]; for (int hist=0; hist<nhistos; ++hist) { histos[hist] = (TH1F*)file_initial->Get(hist_names[hist]); histos[hist]->Sumw2(kFALSE); // histos[hist]->Scale(40.); if (files==0) signal_histos[hist] = (TH1F*)file_initial->Get(hist_names[hist]); // signal_histos[hist]->Scale(40.); // histos[hist]->SetLineColor(1+files); // histos[hist]->SetFillColor(1+files); if (files==1) { histos[hist]->SetFillColor(kBlue-10); histos[hist]->SetLineColor(kBlue-10); } if (files==2) { histos[hist]->SetFillColor(kBlue); histos[hist]->SetLineColor(kBlue); } if (files==3) { histos[hist]->SetFillColor(kOrange); histos[hist]->SetLineColor(kOrange); } if (files==4) { histos[hist]->SetFillColor(kRed); histos[hist]->SetLineColor(kRed); } if (files==5) { histos[hist]->SetFillColor(kAzure+10); histos[hist]->SetLineColor(kAzure+10); } if (files==6) { histos[hist]->SetFillColor(kGreen+2); histos[hist]->SetLineColor(kGreen+2); } if (files==7) { histos[hist]->SetFillColor(kPink+9); histos[hist]->SetLineColor(kPink+9); } if (files==0) { histos[hist]->SetFillStyle(3324); histos[hist]->SetFillColor(1); histos[hist]->SetLineColor(1); signal_histos[hist]->SetFillStyle(3324); signal_histos[hist]->SetLineColor(1); signal_histos[hist]->SetFillColor(1); } if (files>=0)stacks[hist]->Add(histos[hist]); if (hist==0) leg->AddEntry(histos[hist],leg_names[files],"F"); if (files==1) { discr_histos[hist] = (TH1F*)file_initial->Get(hist_names[hist]); } if ((files>1)) { discr_histos[hist]->Add(histos[hist]); } } if (files!=0) totalBG+=histos[4]->Integral(); if (files==0) out_efficiency<<"Sample & \t\t\t yield(per $fb^{-1}$)& \t efficiency"<<endl; if (files==0) out_efficiency<<leg_names[files]<<"&\t \t \t"<<histos[5]->Integral()*1000. <<"&\t"<< histos[5]->Integral()/xsec[files] <<endl; else out_efficiency<<leg_names[files]<<"&\t "<<histos[4]->Integral()*1000. <<"&\t"<< histos[4]->Integral()/xsec[files] <<endl; if (files==nfiles-1) out_efficiency<<"Total BG"<<"&\t \t \t "<<totalBG*1000.<< endl; files++; } while (files<nfiles); out_efficiency.close(); for (int d=0; d<nhistos; d++) { discriminators[d] = Discr(discr_histos[d],signal_histos[d]); } bubblesort(discriminators, hist_names_sort,nhistos); out_discrimination.open(trigger+dir_name+"discrimination.txt"); for (int d=0; d<nhistos; d++) { if (d==0) out_discrimination<<"Variable &\t d"<<endl; out_discrimination<<"$"<<hist_names_sort[d]<<"$"<<" & \t "<< std::setprecision(2)<< discriminators[d]<<endl; } out_discrimination.close(); TLatex* tex = new TLatex(0.90,0.92,"13 TeV, PU = 20, bx = 25 ns, 1 pb^{-1}"); tex->SetNDC(); tex->SetTextAlign(35); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); TLatex *tex1 = new TLatex(0.13,0.83,"CMS"); tex1->SetNDC(); tex1->SetTextAlign(20); tex1->SetTextFont(61); tex1->SetTextSize(0.06); tex1->SetLineWidth(2); TLatex* tex2 = new TLatex(0.22,0.77,"Work in progress"); tex2->SetNDC(); tex2->SetTextAlign(20); tex2->SetTextFont(52); tex2->SetTextSize(0.04); tex2->SetLineWidth(2); TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, DoubleBtag"); // TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, SingleBtag"); tex_file->SetNDC(); tex_file->SetTextAlign(35); tex_file->SetTextFont(42); tex_file->SetTextSize(0.04); tex_file->SetLineWidth(2); for (int i=0; i<nhistos; i++) { TString temp_str; temp_str.Form("%2.2f",Discr(discr_histos[i],signal_histos[i])); TString disc_value = temp_str.Prepend(", d = "); TLatex *disc_value_text = new TLatex(0.86,0.853,disc_value); disc_value_text->SetNDC(); disc_value_text->SetTextAlign(35); disc_value_text->SetTextFont(42); disc_value_text->SetTextSize(0.04); disc_value_text->SetLineWidth(2); TCanvas *c1 = new TCanvas(); c1->SetBottomMargin(.12); c1->cd(); c1->SetLogy(); Double_t xmin = signal_histos[i]->GetBinCenter(0); Double_t xmax = signal_histos[i]->GetBinCenter(signal_histos[i]->GetNbinsX()); TH1F *frame = new TH1F("frame","",1,xmin,xmax); frame->SetMinimum(1e-4); frame->SetMaximum(1e10); frame->GetYaxis()->SetTitleOffset(0.9); frame->GetXaxis()->SetTitleOffset(0.91); frame->SetStats(0); frame->SetTitleFont(42,"x"); frame->SetTitleFont(42,"y"); frame->SetTitleSize(0.05, "XYZ"); frame->SetXTitle(signal_histos[i]->GetXaxis()->GetTitle()); if ((i<4))frame->SetYTitle("Events / 20 GeV"); else if (i==37)frame->SetYTitle("Events / 20 GeV"); else if (i==41)frame->SetYTitle("Events / 20 GeV"); else if ((i>=4) && (i<8)) frame->SetYTitle("Events / 0.5"); else if (i==15) frame->SetYTitle("Events / 0.5"); else if ((i>=8) && (i<12)) frame->SetYTitle("Events / 0.2"); else if (i==40) frame->SetYTitle("Events / 100 GeV"); else if ((i==10)||(i==12)||(i==16)||(i==17)||(i==18) || (i==20) || (i==25) || (i==26) || (i==27) || (i==35) || (i==36) ||(i==38) || (i==39)) frame->SetYTitle("Events / 10 GeV"); else if ((i==13)||(i==14)) frame->SetYTitle("Events / 0.1"); else if ((i==21)||(i==22)) frame->SetYTitle("Events / 0.05"); else if ((i==23)||(i==24)) frame->SetYTitle("Events / 0.01"); else if (i==28) frame->SetYTitle("Events / 0.02"); else if ((i==29) || (i==30) || (i==31) || (i==32) )frame->SetYTitle("Events / 0.1"); else if ((i==33) || (i==33))frame->SetYTitle("Events / 0.01"); else frame->SetYTitle("Events"); frame->Draw(); tex->Draw(); tex1->Draw(); tex2->Draw(); tex_file->Draw(); stacks[i]->Draw("nostacksame"); leg->Draw("same"); signal_histos[i]->Draw("same"); disc_value_text->Draw(); c1->Print(output_names[i]); c1->Delete(); } }
void PlotLimit ( string LimitFile , string filePrefix, string LimTitle , bool DoObsLim , bool DoExpLim ) { setTDRStyle(); vector<float> vMass ; vector<float> vObsLimit ; vector<float> vMeanExpLimit ; vector<float> vMedianExpLimit ; vector<float> vExpLim68Down ; vector<float> vExpLim68Up ; vector<float> vExpLim95Down ; vector<float> vExpLim95Up ; ifstream indata; indata.open(LimitFile.c_str()); if(!indata) { // file couldn't be opened cerr << "Error: file could not be opened" << endl; return; } float Mass ; float ObsLimit ; float MeanExpLimit ; float MedianExpLimit ; float ExpLim68Down ; float ExpLim68Up ; float ExpLim95Down ; float ExpLim95Up ; while ( indata >> Mass >> ObsLimit >> MeanExpLimit >> MedianExpLimit >> ExpLim95Down >> ExpLim68Down >> ExpLim68Up >> ExpLim95Up ) { cout << Mass << " " << MeanExpLimit << " " << MedianExpLimit <<" "<< ExpLim68Down <<" "<< ExpLim68Up <<" "<< ExpLim95Down <<" "<< ExpLim95Up << endl; vMass .push_back(Mass ); vObsLimit .push_back(ObsLimit ); vMeanExpLimit .push_back(MeanExpLimit ); vMedianExpLimit .push_back(MedianExpLimit ); vExpLim68Down .push_back(ExpLim68Down ); vExpLim68Up .push_back(ExpLim68Up ); vExpLim95Down .push_back(ExpLim95Down ); vExpLim95Up .push_back(ExpLim95Up ); } TCanvas* cLimit = new TCanvas("c1","c1",900,600); cLimit->cd(); float x1 = vMass.at(0) - 5. ; float x2 = vMass.at(vMass.size()-1) + 5. ; // Expected Limit TGraph* ExpLim = NULL ; TGraphAsymmErrors* ExpBand68 = NULL ; TGraphAsymmErrors* ExpBand95 = NULL ; float min = 999999., max = 0; float minZoom = 999999., maxZoom = 0; if ( DoExpLim ) { float x[100]; float ex[100]; float y[100]; float yu68[100]; float yd68[100]; float yu95[100]; float yd95[100]; for ( int i = 0 ; i < (signed) vMass.size() ; ++i ) { x[i] = vMass.at(i) ; ex[i] = 0 ; y[i] = vMedianExpLimit.at(i) ; if(y[i] > max) max = y[i] ; if(y[i] < min) min = y[i] ; if(x[i]<=250){ if(y[i] > maxZoom) maxZoom = y[i] ; if(y[i] < minZoom) minZoom = y[i] ;} yu68[i] = vExpLim68Up.at(i) -y[i]; if(yu68[i] > max) max = yu68[i]; if(yu68[i] < min) min = yu68[i]; yd68[i] = y[i] - vExpLim68Down.at(i); if(yd68[i] > max) max = yd68[i]; if(yd68[i] < min) min = yd68[i]; yu95[i] = vExpLim95Up.at(i) -y[i]; if(yu95[i] > max) max = yu95[i]; if(yu95[i] < min) min = yu95[i]; yd95[i] = y[i] - vExpLim95Down.at(i); if(yd95[i] > max) max = yd95[i]; if(yd95[i] < min) min = yd95[i]; } ExpBand95 = new TGraphAsymmErrors((signed) vMass.size(),x,y,ex,ex,yd95,yu95); ExpBand95->SetFillColor(kYellow); ExpBand95->GetYaxis()->SetRangeUser(0.,50); ExpBand95->GetXaxis()->SetRangeUser(x1,x2); ExpBand95->GetXaxis()->SetTitle("Higgs mass [GeV/c^{2}]"); ExpBand95->GetYaxis()->SetTitle("95% Limit on #sigma/#sigma_{SM} "); ExpBand95->Draw("A3"); ExpBand95->GetYaxis()->SetRangeUser(0.,50); ExpBand95->Draw("A3"); ExpBand68 = new TGraphAsymmErrors((signed) vMass.size(),x,y,ex,ex,yd68,yu68); ExpBand68->SetFillColor(kGreen); ExpBand68->Draw("3"); ExpLim = new TGraph((signed) vMass.size(),x,y); ExpLim->SetLineWidth(2); ExpLim->SetLineStyle(1); ExpLim->Draw("l"); } // Observed Limit TGraph* ObsLim = NULL ; if ( DoObsLim ) { float x[100]; float y[100]; for ( int i = 0 ; i < (signed) vMass.size() ; ++i ) { x[i] = vMass.at(i) ; y[i] = vObsLimit.at(i) ; if(y[i] > max) max = y[i]; if(y[i] < min) min = y[i]; if(x[i]<=250){ if(y[i] > maxZoom) maxZoom = y[i] ; if(y[i] < minZoom) minZoom = y[i] ;} } ObsLim = new TGraph((signed) vMass.size(),x,y); ObsLim->SetMarkerColor(kBlue); ObsLim->SetLineWidth(2); ObsLim->SetLineColor(kBlue); //ObsLim->SetLineStyle(2); ObsLim->SetMarkerStyle(kFullCircle); if (DoExpLim) ObsLim->Draw("lp"); else { ObsLim->GetYaxis()->SetRangeUser(0.,10); ObsLim->GetXaxis()->SetRangeUser(x1,x2); ObsLim->GetXaxis()->SetTitle("Higgs mass [GeV/c^{2}]"); ObsLim->GetYaxis()->SetTitle("95% CL Limit on #sigma/#sigma_{SM} "); ObsLim->Draw("alp"); } } TLine *l = new TLine(x1,1,x2,1); l->SetLineWidth(2); l->SetLineColor(kBlack); l->Draw("same"); TLatex* title = new TLatex(.19,.82,LimTitle.c_str()); title->SetTextSize(.04); title->SetNDC(1); title->Draw("same"); TText* CMS = new TText(.19,.88,"CMS Preliminary"); CMS ->SetTextSize(.05); CMS ->SetNDC(1); CMS ->Draw("same"); //TLatex* Lumi = new TLatex(.19,.84,"Lumi = 1.5 fb^{-1} "); //Lumi ->SetTextSize(.03); //Lumi ->SetNDC(1); //Lumi ->Draw("same"); TLegend* leg = NULL ; leg = new TLegend(0.60,0.75,0.9,0.88,""); if (DoExpLim) leg->AddEntry(ExpLim, "95% CL: median","l"); if (DoExpLim) leg->AddEntry(ExpBand68,"95% CL: 68% band","f"); if (DoExpLim) leg->AddEntry(ExpBand95,"95% CL: 95% band","f"); if (DoObsLim) leg->AddEntry(ObsLim,"Observed","lp"); leg->SetTextSize(.03); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetShadowColor(0); leg->SetFillColor(0); leg->Draw("same"); vector<string> extensions; extensions.push_back(".png"); extensions.push_back(".pdf"); extensions.push_back(".eps"); ExpBand95->GetXaxis()->SetRangeUser(x1,x2); ExpBand95->GetYaxis()->SetRangeUser(min-0.2,max+2); cLimit->Update(); for(size_t i=0;i<extensions.size();++i) cLimit->Print( ("plots/"+filePrefix+"_lin"+extensions[i]).c_str() ); ExpBand95->GetXaxis()->SetRangeUser(x1,250); ExpBand95->GetYaxis()->SetRangeUser(minZoom/3.,maxZoom+0.2*maxZoom); cLimit->Update(); for(size_t i=0;i<extensions.size();++i) cLimit->Print( ("plots/"+filePrefix+"_zoom_lin"+extensions[i]).c_str() ); cLimit->SetLogy(); ExpBand95->GetXaxis()->SetRangeUser(x1,x2); ExpBand95->GetYaxis()->SetRangeUser(min/3.,max*10); cLimit->Update(); for(size_t i=0;i<extensions.size();++i) cLimit->Print( ("plots/"+filePrefix+"_log"+extensions[i]).c_str() ); ExpBand95->GetXaxis()->SetRangeUser(x1,250); ExpBand95->GetYaxis()->SetRangeUser(minZoom/3.,maxZoom*10); cLimit->Update(); for(size_t i=0;i<extensions.size();++i) cLimit->Print( ("plots/"+filePrefix+"_zoom_log"+extensions[i]).c_str() ); // ExpBand95->GetXaxis()->SetRangeUser(x1,300.); // gPad->WaitPrimitive(); // figName = "LimitPlots/" + LimTitle + "_zoom.gif" ; // cLimit->SaveAs(figName.c_str()) ; return; }
void plotv2vseta(){ int ibin=0; TFile *f = TFile::Open("mergedv_Prod2_eta.root"); TFile *fProd = TFile::Open("mergedv_Prod2_eta.root"); TVectorD *vecDv2 = (TVectorD*)f->Get(Form("D_%d/vmean",ibin)); TVectorD *vecDv2err = (TVectorD*)f->Get(Form("D_%d/deltavmean",ibin)); TVectorD *vecDavgeta = (TVectorD*)f->Get(Form("D_%d/avgeta",ibin)); TVectorD *vecDv2_ = (TVectorD*)fProd->Get(Form("D_%d/vmean",ibin)); TVectorD *vecDv2err_ = (TVectorD*)fProd->Get(Form("D_%d/deltavmean",ibin)); TVectorD *vecDavgeta_ = (TVectorD*)fProd->Get(Form("D_%d/avgeta",ibin)); double *avgeta = vecDavgeta->GetMatrixArray(); double *v2 = vecDv2->GetMatrixArray(); double *v2err = vecDv2err->GetMatrixArray(); double *avgeta_ = vecDavgeta_->GetMatrixArray(); double *v2_ = vecDv2_->GetMatrixArray(); double *v2err_ = vecDv2err_->GetMatrixArray(); double v2corr[netav],v2corr_[netav]; for(int i=0;i<netav;i++){ v2corr[i]=v2[i]; v2corr_[i]=v2_[i]; } TCanvas *c1 = new TCanvas(); /*V2vsPt->SetLineColor(2); V2vsPt->SetTitle("v_{2} vs momentum"); V2vsPt->GetXaxis()->SetTitle("p_{T} (GeV/c)"); V2vsPt->GetYaxis()->SetTitle("v_{2}"); V2vsPt->GetYaxis()->SetRangeUser(0,0.1); V2vsPt->Draw(); */ TGraphErrors *gr=new TGraphErrors(netav,avgeta,v2corr,0,v2err); TGraphErrors *grProd=new TGraphErrors(netav,avgeta_,v2corr_,0,v2err_); grProd->SetTitle("v_{2} vs #eta"); grProd->GetXaxis()->SetTitle("#eta"); grProd->GetYaxis()->SetTitle("v_{2}"); grProd->GetYaxis()->SetRangeUser(0,0.15); grProd->SetMarkerSize(1.3); grProd->SetMarkerColor(1); grProd->SetMarkerStyle(20); grProd->SetMarkerStyle(29); grProd->SetMarkerColor(4); //gr->Draw("AP"); grProd->Draw("AP"); TLegend *tl = new TLegend(0.6,0.6,0.8,0.75); tl->SetFillColor(0); tl->SetBorderSize(0); tl->SetTextSize(0.05); //tl->AddEntry(V2vsPt,"input v_{2}","lp"); //tl->AddEntry(gr,"LYZ Sum method","lp"); tl->AddEntry(grProd,"LYZ Prod method","lp"); tl->Draw("same"); TLatex *tlx = new TLatex(0.2,0.7,"150<multi<185"); tlx->SetNDC(); tlx->SetTextSize(0.045); tlx->Draw("same"); c1->Print("v2vseta.png"); f->Close(); }