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 PlotShapeSystematics() { TFile *file = 0; TH1F *DefaultShape = 0; TH1F *UpShape = 0; TH1F *DownShape = 0; TCanvas *cv = 0; TLegend *legend = 0; //********************************************************* //0 Jet Bin - OF //********************************************************* file = new TFile("/data/smurf/sixie/data/Thesis/cards/130/hwwof_0j.input.root","READ"); DefaultShape = (TH1F*)file->Get("histo_qqWW"); UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp"); DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); NormalizeHist(DefaultShape); NormalizeHist(UpShape); NormalizeHist(DownShape); cv = new TCanvas("cv","cv",800,600); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Bounding Shape (Up)", "L"); legend->AddEntry(DownShape, "Bounding Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Fraction of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.4); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,0.25); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF0Jet.png"); cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF0Jet.eps"); //********************************************************* //0 Jet Bin - SF //********************************************************* file = new TFile("/data/smurf/sixie/data/Thesis/cards/130/hwwsf_0j.input.root","READ"); DefaultShape = (TH1F*)file->Get("histo_qqWW"); UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp"); DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); NormalizeHist(DefaultShape); NormalizeHist(UpShape); NormalizeHist(DownShape); cv = new TCanvas("cv","cv",800,600); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Bounding Shape (Up)", "L"); legend->AddEntry(DownShape, "Bounding Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Fraction of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.4); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,0.25); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_SF0Jet.png"); cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_SF0Jet.eps"); //********************************************************* //1 Jet Bin - OF //********************************************************* file = new TFile("/data/smurf/sixie/data/Thesis/cards/130/hwwof_1j.input.root","READ"); DefaultShape = (TH1F*)file->Get("histo_qqWW"); UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp"); DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); NormalizeHist(DefaultShape); NormalizeHist(UpShape); NormalizeHist(DownShape); cv = new TCanvas("cv","cv",800,600); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Bounding Shape (Up)", "L"); legend->AddEntry(DownShape, "Bounding Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Fraction of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.4); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,0.4); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF1Jet.png"); cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF1Jet.eps"); //********************************************************* //1 Jet Bin - SF //********************************************************* file = new TFile("/data/smurf/sixie/data/Thesis/cards/130/hwwsf_1j.input.root","READ"); DefaultShape = (TH1F*)file->Get("histo_qqWW"); UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp"); DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); NormalizeHist(DefaultShape); NormalizeHist(UpShape); NormalizeHist(DownShape); cv = new TCanvas("cv","cv",800,600); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Bounding Shape (Up)", "L"); legend->AddEntry(DownShape, "Bounding Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Fraction of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.4); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,0.4); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_SF1Jet.png"); cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_SF1Jet.eps"); //********************************************************* //0 Jet Bin - OF //********************************************************* file = new TFile("/data/smurf/sixie/data/Thesis/cards/130/hwwof_0j.input.root","READ"); DefaultShape = (TH1F*)file->Get("histo_qqWW"); UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwUp"); DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); NormalizeHist(DefaultShape); NormalizeHist(UpShape); NormalizeHist(DownShape); cv = new TCanvas("cv","cv",800,600); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Bounding Shape (Up)", "L"); legend->AddEntry(DownShape, "Bounding Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Fraction of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.4); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,0.25); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_OF0Jet.png"); cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_OF0Jet.eps"); //********************************************************* //0 Jet Bin - SF //********************************************************* file = new TFile("/data/smurf/sixie/data/Thesis/cards/130/hwwsf_0j.input.root","READ"); DefaultShape = (TH1F*)file->Get("histo_qqWW"); UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwUp"); DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); NormalizeHist(DefaultShape); NormalizeHist(UpShape); NormalizeHist(DownShape); cv = new TCanvas("cv","cv",800,600); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Bounding Shape (Up)", "L"); legend->AddEntry(DownShape, "Bounding Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Fraction of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.4); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,0.25); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_SF0Jet.png"); cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_SF0Jet.eps"); //********************************************************* //1 Jet Bin - OF //********************************************************* file = new TFile("/data/smurf/sixie/data/Thesis/cards/130/hwwof_1j.input.root","READ"); DefaultShape = (TH1F*)file->Get("histo_qqWW"); UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwUp"); DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); NormalizeHist(DefaultShape); NormalizeHist(UpShape); NormalizeHist(DownShape); cv = new TCanvas("cv","cv",800,600); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Bounding Shape (Up)", "L"); legend->AddEntry(DownShape, "Bounding Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Fraction of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.4); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,0.4); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_OF1Jet.png"); cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_OF1Jet.eps"); //********************************************************* //1 Jet Bin - SF //********************************************************* file = new TFile("/data/smurf/sixie/data/Thesis/cards/130/hwwsf_1j.input.root","READ"); DefaultShape = (TH1F*)file->Get("histo_qqWW"); UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwUp"); DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); NormalizeHist(DefaultShape); NormalizeHist(UpShape); NormalizeHist(DownShape); cv = new TCanvas("cv","cv",800,600); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Bounding Shape (Up)", "L"); legend->AddEntry(DownShape, "Bounding Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Fraction of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.4); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,0.4); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_SF1Jet.png"); cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_SF1Jet.eps"); }
void dileptonMassFit(const char* pInFileName="PanchoSkim4JanAll.root", // "PromtRecoV2V3V3H_DiMuonPlot_TightSTACutsAll15Dec.root", // "Z0_DataMixPt50_PatDiMuonPlots_NewCutAll14Dec.root", const char* pHistNameOpCh="diMuonsGlobalInvMassVsPt",//diMuonsGlobalInvMassVsPtW", const char* pHistNameSameCh="diMuonsGlobalSameChargeInvMassVsPt", const char* pSpectra="pt", // pt, y, centr bool doMc=false, int nFitFunction = 3, int getYield = 1) { gROOT->Macro("setStyle.C+"); //gROOT->Macro("/Users/eusmartass/Software/utilities/setStyle.C+"); char szBuf[256]; //////// definitions of Switches /////////// // nFitFunction = 1 RBW + Pol2 // nFitFunction = 2 Gaus + Pol2 // nFitFunction = 3 RBWGaus + Pol2 // getYield = 1 Bin counting // getYield = 2 Integral //////////////////////////////////////////////////////////// // make some choices float MassZ0 = 91.1876; float WidthZ0 = 2.4952; float massFit_low = 60; float massFit_high = 120; // Fit ranges float massDraw_low = 30.0; // 0. float massDraw_high = 130.0; // 200/ int nrebin = 80; bool isLog = 0; bool isFit = 1; // draw ranges float massCount_low = 60.0; //78.0 float massCount_high = 120.0; //102.0 //___________________________________________________________________________________ // ------- Open input file sprintf(szBuf,"%s",pInFileName); TString inFileName(szBuf); TFile *pfInFile = new TFile(inFileName); // ------- get histograms: sprintf(szBuf,"%s",pHistNameOpCh); TH2D *phDimuMass_1 = (TH2D*)pfInFile->Get(szBuf)->Clone("phDimuMass_1"); sprintf(szBuf,"%s",pHistNameSameCh); TH2D *phDimuMass_1S = (TH2D*)pfInFile->Get(szBuf)->Clone("phDimuMass_1S"); phDimuMass_1->SetDirectory(0); phDimuMass_1S->SetDirectory(0); // Open pp data file TFile *ppFile = new TFile("Zmumu_40-200_35pb.root"); TH1F *Zmumu = (TH1F*)ppFile->Get("hdata"); //___________________________________________________________________________________ // bins definition: const char* Xname[] = {" ", "p_{T}^{Dimuon} (GeV/c)", "rapidity", "centrality"}; bool doPt = false; bool doY = false; bool doCent = false; int GenRange, nBins; double binEdge[10]; char* label; sprintf(szBuf,"%s",pSpectra); TString wichSpectra(szBuf); if ( wichSpectra.CompareTo("pt") == 0) { doPt = true; label = (char*)Xname[1]; GenRange = 20; nBins = 1; binEdge[0] = 0.0; binEdge[1]= 100.0; // double binEdge[10] = {0.0, 10., 20., 100.0}; if(doMc) { nBins = 1; binEdge[0] = 0.0; binEdge[1]= 50.0; // nBins = 7; // binEdge[0] = 0.0; binEdge[1] = 2.0; binEdge[2] = 4.0; binEdge[3] = 8.0; //binEdge[4] = 12.0; binEdge[5] = 16.0; binEdge[6] = 22.0; binEdge[7] = 50.0; } } else { if ( wichSpectra.CompareTo("y") == 0) { doY = true; label = (char*)Xname[2]; nBins = 3; GenRange = 4.8; binEdge[0] = -2.4; binEdge[1] = -0.8; binEdge[2] = 0.8; binEdge[3] = 2.4; } else { if ( wichSpectra.CompareTo("cent") == 0) { doCent = true; label = (char*)Xname[3]; nBins = 4; GenRange = 40; binEdge[0] = 0.; binEdge[1] = 4; binEdge[2] = 8.; binEdge[3] = 16; binEdge[4] = 40; } else { cout<<"Don't know what you want to do!!!!"<<endl; return; } } } double PT[10], DelPT[10], mom_err[100]; for (Int_t ih = 0; ih < nBins; ih++) { PT[ih] = (binEdge[ih] + binEdge[ih+1])/2.0; DelPT[ih] = binEdge[ih+1] - binEdge[ih]; mom_err[ih] = DelPT[ih]/2.0; } //___________________________________________________________________________________ double gen_pt[10]; double egen_pt[10]; TCanvas *pcPt_1 = new TCanvas("pcPt_1"," Z0 Yield Vs. Pt ", 40,40,600,600); if(doMc) { pcPt_1->Divide(nBins,2); //TH2D *genMass_1 = (TH2D*)pfInFile->Get("diMuonsGenInvMassVsPt"); TH2D *genMass_1 = (TH2D*)pfInFile->Get("diMuonsGenInvMassVsPtW"); TH1D *ptaxis = (TH1D*)genMass_1->ProjectionY("ptaxis"); for (Int_t ih = 0; ih < nBins; ih++) { pcPt_1->cd(ih+nBins+1); int bin1 = ptaxis->FindBin(binEdge[ih]+0.0000001); int bin2 = ptaxis->FindBin(binEdge[ih+1]+0.0000001); TH1D * genMassVsPt = (TH1D*)genMass_1->ProjectionX("genMassVsPt", bin1, bin2-1); genMassVsPt->Draw("EPL"); pcPt_1->Update(); TAxis *axs = genMassVsPt->GetXaxis(); int binlow = axs->FindBin(massCount_low); int binhi = axs->FindBin(massCount_high); double int_sig_gen; double int_sig_gen_sqr; for(Int_t bin = binlow; bin<=binhi; bin++) { // cout << " int_sig += dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin);"<<int_sigpow_gen <<"+="<< "bin" << bin << " content"<<genMassVsPt->GetBinContent(bin)<<endl; int_sig_gen += genMassVsPt->GetBinContent(bin); int_sig_gen_sqr += pow(genMassVsPt->GetBinContent(bin),2); } gen_pt[ih] = int_sig_gen;//genMassVsPt->GetEntries(); cout<<" gen entries : "<< gen_pt[ih]<<endl; egen_pt[ih] =int_sig_gen_sqr; } } else { if (nBins == 2) pcPt_1->Divide(2,1); if (nBins == 3 || nBins == 4) pcPt_1->Divide(2,2); if (nBins == 5 || nBins == 6) pcPt_1->Divide(3,2); } //___________________________________________________________________________________ // Fit Function // const char *name_fit[] = {" ", "RBWPol1", "GausPol1", "RBWGausPol2"}; int nParam[] = {0,6,6,7}; int nFitParam = nParam[nFitFunction]; TF1 *RBWPOL=0; if(nFitFunction == 1) RBWPOL = new TF1("RBWPOL", RBWPol2, 0, 200, nFitParam); if(nFitFunction == 2) RBWPOL = new TF1("RBWPOL", GausPol2, 0, 200, nFitParam); if(nFitFunction == 3) RBWPOL = new TF1("RBWPOL", RBWGausPol2, 0, 200, nFitParam); TF1 *EXP = new TF1("EXP", Exp, 0, 200, 2); RBWPOL->SetLineWidth(1); RBWPOL->SetParameter(1, MassZ0); RBWPOL->SetParameter(2, WidthZ0); RBWPOL->SetParLimits(1, 0.9*MassZ0, 1.1*MassZ0); RBWPOL->SetParLimits(2, 0.1*WidthZ0, 5.0*WidthZ0); if(nFitFunction == 1 || nFitFunction == 2) RBWPOL->FixParameter(5, 0); if(nFitFunction == 3 || nFitFunction == 4) { RBWPOL->SetParameter(3, WidthZ0); RBWPOL->SetParLimits(3, 0.1, 20); RBWPOL->FixParameter(2, WidthZ0); RBWPOL->FixParameter(4, 0); // for no bkg RBWPOL->FixParameter(5, 0); // for no bkg RBWPOL->FixParameter(6, 0); } //___________________________________________________________________________________ // Efficiency double yld_cat_1[10], cyld_cat_1[10], eyld_cat_1[10], ceyld_cat_1[10]; double Eff_cat_1[10], errEff_cat_1[10]; ///// Write the spectra sprintf(szBuf,"fileSpecta%d.root", getYield); // TFile *fileSpectra = new TFile(szBuf, "recreate"); //___________________________________________________________________________________ // Drawing // Category _1 TLegend *pLegCategory = new TLegend(.66, .74, .92, .94); // pLegCategory = new TLegend(.1, .82, .50, .93); pLegCategory->SetBorderSize(0); pLegCategory->SetFillStyle(0); pLegCategory->SetFillColor(0); pLegCategory->SetTextSize(0.03); // pLegCategory->AddEntry(RBWPOL," CMS Preliminary", " "); pLegCategory->AddEntry(RBWPOL," CMS Pb+Pb ", " "); pLegCategory->AddEntry(RBWPOL," #sqrt{s_{NN}} = 2.76 TeV ", " "); pLegCategory->AddEntry(RBWPOL," #int Ldt = 6.6 #mub^{-1} ", " "); // pLegCategory->AddEntry(RBWPOL," Global-Global ", ""); //pLegCategory->AddEntry(RBWPOL," |y| < 2.4 ", "P"); //pLegCategory->AddEntry(RBWPOL," Run# 150431-151027 ", "P"); TLegend *legend_1[12]; for(int i=0; i<12; i++) { if(isFit) legend_1[i] = new TLegend(.13, .66, .52, 0.94); if(!isFit) legend_1[i] = new TLegend(.13, .66, .52, 0.94 ); // legend_1[i] = new TLegend(.68, .62, .91, 0.93 ); legend_1[i]->SetBorderSize(0); legend_1[i]->SetFillStyle(0); legend_1[i]->SetFillColor(0); legend_1[i]->SetTextSize(0.028); } int bin_bound[100]; TH1D *dimuonsGlobalInvMassVsPt[10]; TH1D *dimuonsGlobalInvMassVsPtS[10]; TH1D *service = (TH1D*)phDimuMass_1->ProjectionY("service"); // cout << endl << label << " Yield Mass (GeV) Width (GeV) GauWidth chi2/ndf " << endl << endl; for (Int_t ih = 0; ih < nBins; ih++) { pcPt_1->cd(ih+1); gPad->SetTickx(); gPad->SetTicky(); // Project 1 D bin_bound[ih] = service->FindBin(binEdge[ih]+0.0000001); bin_bound[ih+1] = service->FindBin(binEdge[ih+1]+0.0000001); sprintf(szBuf,"Z0_1_pt_%d",ih); dimuonsGlobalInvMassVsPt[ih] = (TH1D*)phDimuMass_1->ProjectionX(szBuf, bin_bound[ih], bin_bound[ih+1]-1+1, "e"); sprintf(szBuf,"Z0_1S_pt_%d",ih); dimuonsGlobalInvMassVsPtS[ih] = (TH1D*)phDimuMass_1S->ProjectionX(szBuf, bin_bound[ih], bin_bound[ih+1]-1+1); cout << "reco entries" << dimuonsGlobalInvMassVsPt[ih]->GetEntries() <<endl; if(doPt || doY) { sprintf(szBuf," %s [%.1f, %.1f]", label, service->GetBinLowEdge(bin_bound[ih]), service->GetBinLowEdge(bin_bound[ih+1]-1) + service->GetBinWidth(bin_bound[ih+1])); } if(doCent) { sprintf(szBuf," %s [%.1f, %.1f] %s", label, 2.5*service->GetBinLowEdge(bin_bound[ih]), 2.5*(service->GetBinLowEdge(bin_bound[ih+1]-1) + service->GetBinWidth(bin_bound[ih+1])), "%"); } dimuonsGlobalInvMassVsPt[ih]->Rebin(nrebin); dimuonsGlobalInvMassVsPtS[ih]->Rebin(nrebin); // -------- Fit Function + Bkg Function double part[20]; dimuonsGlobalInvMassVsPt[ih]->Fit("EXP","LEQ", "", 34, 60); EXP->GetParameters(part); if(nFitFunction == 4) { RBWPOL->FixParameter(4, part[0]); RBWPOL->FixParameter(5, part[1]); } if(isFit) { //dimuonsGlobalInvMassVsPt[ih]->Fit("RBWPOL","LEQ", "", massFit_low, massFit_high); //TFitResultPtr r = dimuonsGlobalInvMassVsPt[ih]->Fit("RBWPOL","LEQS0","", massFit_low, massFit_high); // if(r->IsValid()) r->Print(); //else cout<<"Fit not valid!!!\n"<<endl; } //------ get fit parameters double par[20]; RBWPOL->GetParameters(par); float GGphDimuMass = RBWPOL->GetParameter(1); float GGZ0Width = RBWPOL->GetParameter(2); float GauWidth =0; if(nFitFunction == 3 || nFitFunction == 4) GauWidth = RBWPOL->GetParameter(3); double chisq = RBWPOL->GetChisquare(); int ndf = RBWPOL->GetNDF(); double chisqdf =1000; if(ndf!=0) chisqdf=chisq/ndf; // +++ set backgroudn fit sprintf(szBuf,"pt_1B_%d",ih); TF1 *bkgFit_1 = new TF1(szBuf, Pol2, massFit_low, massFit_high, 3); // if(nFitFunction == 4) bkgFit_1 = new TF1(namePt_1B, Exp, massFit_low, massFit_high, 2); bkgFit_1->SetParameters(&par[3]); if(nFitFunction == 3 || nFitFunction == 4) bkgFit_1->SetParameters(&par[4]); // ---------- Integrated Yield // float massCount_low =GGphDimuMass-(4.0*GGZ0Width); // float massCount_high =GGphDimuMass+(4.0*GGZ0Width); TAxis *axs = dimuonsGlobalInvMassVsPt[ih]->GetXaxis(); int binlow = axs->FindBin(massCount_low); int binhi = axs->FindBin(massCount_high); Double_t bin_size = (1.0*dimuonsGlobalInvMassVsPt[ih]->GetNbinsX())/(axs->GetXmax() - axs->GetXmin()); Float_t int_sig = 0.0; Float_t int_sig_sqr = 0.0; for(Int_t bin = binlow; bin<=binhi; bin++) { // cout << " int_sig += dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin);"<<int_sig <<"+="<< "bin" << bin << " content"<<dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin)<<endl; int_sig += dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin); int_sig_sqr += pow(dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin),2); } if(getYield == 2) { int_sig = RBWPOL->Integral(massCount_low, massCount_high)*bin_size; yld_cat_1[ih] = int_sig - bin_size*bkgFit_1->Integral(massCount_low, massCount_high); eyld_cat_1[ih] = TMath::Sqrt(int_sig + bin_size*bkgFit_1->Integral(massCount_low, massCount_high) ); } else { yld_cat_1[ih] = int_sig ; eyld_cat_1[ih] = int_sig_sqr; } cout << "int_sig - bin_size*bkgFit_1->Integral(massCount_low, massCount_high);" << int_sig<< " -"<< bin_size<<"*"<<bkgFit_1->Integral(massCount_low, massCount_high)<< " with low"<< massCount_low<<" high "<< massCount_high<<endl; //// Printing ///// cout << PT[ih] << " " << yld_cat_1[ih] << " +- " << eyld_cat_1[ih] <<" " << GGphDimuMass << " " << GGZ0Width << " " << GauWidth <<" "<< chisq << "/" << ndf << endl; // -------------- Draw // dimuonsGlobalInvMassVsPt[ih]->SetMinimum(-.05*dimuonsGlobalInvMassVsPt[ih]->GetMaximum()); if(isLog) gPad->SetLogy(1); TColor *pal = new TColor(); Int_t kblue = pal->GetColor(9,0,200); // Int_t korange = pal->GetColor(101, 42, 0); // +++ opposite charge dimuonsGlobalInvMassVsPt[ih]->SetMarkerStyle(21); dimuonsGlobalInvMassVsPt[ih]->SetMarkerColor(kblue); dimuonsGlobalInvMassVsPt[ih]->SetLineColor(kblue); dimuonsGlobalInvMassVsPt[ih]->SetMarkerSize(1.1); dimuonsGlobalInvMassVsPt[ih]->GetXaxis()->SetTitle("Dimuon mass (GeV/c^{2})"); dimuonsGlobalInvMassVsPt[ih]->GetYaxis()->SetTitle("dN/dM (2 GeV/c^{2})^{-1}"); dimuonsGlobalInvMassVsPt[ih]->GetXaxis()->SetRangeUser(massDraw_low,massDraw_high); // dimuonsGlobalInvMassVsPt[ih]->Add(dimuonsGlobalInvMassVsPtS[ih], -1); pcPt_1->cd(ih+1); dimuonsGlobalInvMassVsPt[ih]->DrawCopy("EPLsame"); // pp data TAxis *axs1 = Zmumu->GetXaxis(); int ll = axs1->FindBin(massCount_low); int hh = axs1->FindBin(massCount_high); double scalefactor = yld_cat_1[ih]/Zmumu->Integral(ll, hh); cout << Zmumu->Integral(ll, hh) << endl; Zmumu->Scale(scalefactor); Zmumu->SetFillColor(19); Zmumu->Draw("same"); dimuonsGlobalInvMassVsPt[ih]->DrawCopy("EPLsame"); // dimuonsGlobalInvMassVsPt[ih]->Draw("B"); // +++ same charge dimuonsGlobalInvMassVsPtS[ih]->SetMarkerStyle(8); dimuonsGlobalInvMassVsPtS[ih]->SetMarkerColor(46); dimuonsGlobalInvMassVsPtS[ih]->SetLineColor(46); dimuonsGlobalInvMassVsPtS[ih]->SetMarkerSize(1.1); dimuonsGlobalInvMassVsPtS[ih]->DrawCopy("EPsame"); // background // RBWPOL->SetLineColor(kblue); bkgFit_1->SetLineColor(46); bkgFit_1->SetLineWidth(1); // if(isFit) bkgFit_1->Draw("same"); // ++++ legend pLegCategory->Draw("same"); // legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," Global-Global", " "); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," |#eta^{#mu}| < 2.4, p_{T}^{#mu} > 10 GeV/c ", ""); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," Unlike Sign ", "LP"); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPtS[ih]," Like Sign ", "LP"); legend_1[ih]->AddEntry(Zmumu," pp Data ", "L"); // legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], text, ""); sprintf(szBuf, "N=%1.0f #pm %1.1f ", yld_cat_1[ih], sqrt(yld_cat_1[ih]) ); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], szBuf, ""); // sprintf(label_1, "N_{Z^{0}} = 27"); sprintf(szBuf, "mass = %1.2f #pm %1.2f GeV/c^{2}", RBWPOL->GetParameter(1), RBWPOL->GetParError(1)); // if(isFit) legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih],szBuf, ""); sprintf(szBuf, "#sigma_{Gauss} = %1.2f #pm %1.2f GeV/c^{2}", RBWPOL->GetParameter(2), RBWPOL->GetParError(2)); if(nFitFunction ==3 || nFitFunction == 4) sprintf(szBuf, "#sigma_{Gauss} = %1.2f #pm %1.2f GeV/c^{2}", RBWPOL->GetParameter(3), RBWPOL->GetParError(3)); // if(isFit) legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], szBuf, ""); sprintf(szBuf, "#chi^{2}/ndf = %1.2f / %d", chisq, ndf); // if(isFit) legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], label_4, ""); legend_1[ih]->Draw("same"); pcPt_1->Update(); } cout << endl << endl; TGraphErrors *Z0pt_cat_1 = new TGraphErrors(nBins, PT, yld_cat_1, mom_err, eyld_cat_1); Z0pt_cat_1->SetMarkerStyle(20); Z0pt_cat_1->SetMarkerColor(2); Z0pt_cat_1->GetXaxis()->SetTitle(label); Z0pt_cat_1->GetYaxis()->SetTitle("counts"); TCanvas *pc2 = new TCanvas("pc2","pc2"); Z0pt_cat_1->SetMinimum(0.0); Z0pt_cat_1->SetName("Z0pt_cat_1"); Z0pt_cat_1->Draw("AP"); TGraphErrors *Z0ptC_cat_1_gen = new TGraphErrors(nBins, PT, gen_pt, mom_err, egen_pt); // Z0ptC_cat_1_gen->SetMarkerStyle(23); //Z0ptC_cat_1_gen->SetMarkerColor(3); //Z0ptC_cat_1_gen->Draw("AP"); pLegCategory->Draw("same"); Z0pt_cat_1->Write(); pLegCategory->Write(); // gPad->Print("Pt_Z0YieldCat_1.png"); pcPt_1->Print("Pt_Z0YieldCat_1.png"); cout << endl << endl; ////////////////////////////////////////////////////////////////////////////// // Efficiency correction if(doMc) { ofstream fileout("correction.txt"); cout << label << " Eff_cat_1 " << endl; for (Int_t ih = 0; ih < nBins; ih++) { Eff_cat_1[ih] = yld_cat_1[ih]/gen_pt[ih]; errEff_cat_1[ih] = sqrt( (pow(Eff_cat_1[ih]/yld_cat_1[ih],2))*eyld_cat_1[ih] +(pow((1-Eff_cat_1[ih]/yld_cat_1[ih]),2))*( yld_cat_1[ih]-gen_pt[ih]/ yld_cat_1[ih])); // errEff_cat_1[ih] = sqrt( (pow(Eff_cat_1[ih]/yld_cat_1[ih],2))*eyld_cat_1[ih] // +(pow((1-Eff_cat_1[ih]/yld_cat_1[ih]),2))*event failing); // fileout << PT[ih] <<" "<< Eff_cat_1[ih] << " " << Eff_cat_2[ih] <<" " << Eff_cat_3[ih] << endl; // cout <<" " << PT[ih] <<" "<< Eff_cat_1[ih] << " " << Eff_cat_2[ih] << " " << Eff_cat_3[ih] << endl; fileout << PT[ih] <<" "<< Eff_cat_1[ih] << " " << errEff_cat_1[ih] << endl; cout <<" " << PT[ih] <<" "<< Eff_cat_1[ih] << " +- " << errEff_cat_1[ih] << endl; cyld_cat_1[ih] = Eff_cat_1[ih]; ceyld_cat_1[ih] = errEff_cat_1[ih]; } } else { ifstream filein("correction.txt"); cout << label << " yld_cat_1 " << " efficiency " << " corr. yld_cat_1 " << endl; for (Int_t ih = 0; ih < nBins; ih++) { // filein >> PT[ih] >> Eff_cat_1[ih] >> Eff_cat_2[ih] >> Eff_cat_3[ih] ; // cout << " " << PT[ih] << " "<< yld_cat_1[ih] << " " << yld_cat_2[ih] <<" " << yld_cat_3[ih] << endl; filein >> PT[ih] >> Eff_cat_1[ih] >> errEff_cat_1[ih]; cout << " " << PT[ih] << " " << yld_cat_1[ih] << " " << Eff_cat_1[ih] << " " << yld_cat_1[ih]/Eff_cat_1[ih] << endl; cyld_cat_1[ih] = yld_cat_1[ih]/Eff_cat_1[ih]; ceyld_cat_1[ih] = eyld_cat_1[ih]/Eff_cat_1[ih]; } } // TF1 *EXPA = new TF1("EXPA", Exp, 0, 100, 2); TGraphErrors *Z0ptC_cat_1 = new TGraphErrors(nBins, PT, cyld_cat_1, mom_err, ceyld_cat_1); Z0ptC_cat_1->SetMarkerStyle(20); Z0ptC_cat_1->SetMarkerColor(2); Z0ptC_cat_1->GetXaxis()->SetTitle(label); Z0ptC_cat_1->GetYaxis()->SetTitle("Acc x Eff"); // if(part == 2) Z0ptC_cat_1->Fit("EXPA","LEQ", "", 7, 16); new TCanvas; Z0ptC_cat_1->SetMinimum(0.0); Z0ptC_cat_1->SetMaximum(0.8); Z0ptC_cat_1->SetName("Z0ptC_cat_1"); Z0ptC_cat_1->Draw("AP"); pLegCategory->Draw("same"); cout << endl << endl; Z0ptC_cat_1->Write(); }
//------------------------------------------------------------------------------ //Subtraction //------------------------------------------------------------------------------ void Subtraction(TString hname, TString xtitle, Int_t ngroup = -1, Int_t precision = 1, TString units = "NULL", Double_t xmin = -999, Double_t xmax = 999, Bool_t moveOverflow = true) { TCanvas* canvas = new TCanvas(hname, hname, 800, 800); TPad* pad1 = new TPad("pad1", "pad1", 0, 0.0, 1, 1.0); pad1->SetTopMargin (0.08); //pad1->SetBottomMargin(0.02); pad1->Draw(); //---------------------------------------------------------------------------- // pad1 //---------------------------------------------------------------------------- pad1->cd(); pad1->SetLogy(_setLogy); TH1F* hist[nProcesses]; for (UInt_t ip=0; ip<nProcesses; ip++) { hist[ip] = (TH1F*)input[ip]->Get(hname); hist[ip]->SetName(hname + process[ip]); if (moveOverflow) MoveOverflowBins (hist[ip], xmin, xmax); else ZeroOutOfRangeBins(hist[ip], xmin, xmax); if (ngroup > 0) hist[ip]->Rebin(ngroup); if (_dataDriven && ip == iWW) hist[ip]->Scale(WWScale[_njet]); if (_dataDriven && ip == iDY) hist[ip]->Scale(ZjScale[_njet]); if (_dataDriven && ip == iDYtau) hist[ip]->Scale(ZjScale[_njet]); } // Data subtraction for Top background estimation //---------------------------------------------------------------------------- TH1F* subData = (TH1F*)hist[iData]->Clone("subData"); for (UInt_t ip=0; ip<nProcesses; ip++) { if (ip == itt) continue; if (ip == itW) continue; if (ip == iData ) continue; subData->Add(hist[ip],-1); } subData->SetLineColor(kRed+1); Double_t subData_Yield = subData->Integral(); //subData->SetLineColor(); // Top background //---------------------------------------------------------------------------- TH1F* Top = (TH1F*)hist[itt]->Clone("Top"); Top->Add(hist[itW]); Top->SetLineColor(kBlue+1); Double_t Top_Yield = Top->Integral(); // Axis labels //---------------------------------------------------------------------------- TAxis* xaxis = subData->GetXaxis(); TAxis* yaxis = subData->GetYaxis(); TString ytitle = Form("entries / %s.%df", "%", precision); xaxis->SetTitle(xtitle); yaxis->SetTitle(Form(ytitle.Data(), subData->GetBinWidth(0))); yaxis->SetTitleOffset(1.6); if (!units.Contains("NULL")) { xaxis->SetTitle(Form("%s [%s]", xaxis->GetTitle(), units.Data())); yaxis->SetTitle(Form("%s %s", yaxis->GetTitle(), units.Data())); } // Draw //---------------------------------------------------------------------------- xaxis->SetRangeUser(xmin, xmax); subData->Draw("hist"); Top->Draw("hist same"); // Adjust scale //---------------------------------------------------------------------------- subData->SetMinimum(0.0); Float_t theMax = GetMaximumIncludingErrors(subData, xmin, xmax); Float_t theMaxMC = GetMaximumIncludingErrors(Top, xmin, xmax); if (theMaxMC > theMax) theMax = theMaxMC; if (pad1->GetLogy()) { theMax = TMath::Power(10, TMath::Log10(theMax) + 2.7); subData->SetMinimum(0.05); } else theMax *= 1.55; subData->SetMaximum(theMax); // Legend //---------------------------------------------------------------------------- Double_t x0 = 0.720; Double_t y0 = 0.834; Double_t yoffset = 0.048; Double_t delta = yoffset + 0.001; Double_t ndelta = 0; DrawLegend(x0 - 0.49, y0 - ndelta, subData, Form(" Data Subtraction (MC without Top) (%.0f)", Yield(subData)), "l", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, Top, Form(" Top (%.0f)", Yield(Top)), "l", 0.03, 0.2, yoffset); ndelta += delta; // Additional titles //---------------------------------------------------------------------------- //TString channelLabel = "ee/#mu#mu/e#mu/#mue"; TString channelLabel = ""; //if (_channel == "EE") channelLabel = "ee"; //if (_channel == "MuMu") channelLabel = "#mu#mu"; //if (_channel == "EMu") channelLabel = "e#mu"; //if (_channel == "MuE") channelLabel = "#mue"; //if (_channel == "SF") channelLabel = "ee/#mu#mu"; //if (_channel == "OF") channelLabel = "e#mu/#mue"; channelLabel += Form(" %d", _njet); if (_njet == 0) channelLabel += "-jets"; if (_njet == 1) channelLabel += "-jet"; if (_njet >= 2) channelLabel += "-jets"; DrawTLatex(0.185, 0.975, 0.05, 13, channelLabel.Data()); DrawTLatex(0.940, 0.983, 0.05, 33, Form("L = %.1f fb^{-1}", _luminosity/1e3)); if (Top_Yield!=0){ cout << "subData_Yield = "<<subData_Yield<<", Top_Yield = "<<Top_Yield<<", Ratio = "<< subData_Yield/Top_Yield <<endl; TLatex *tex3 = new TLatex(0.250, 0.75, "Scale Factor"); tex3->SetNDC(); tex3->SetTextSize(0.035); tex3->Draw(); TLatex *tex4 = new TLatex(0.250, 0.7, Form("%.0f / %.0f = %3.3f",subData_Yield ,Top_Yield ,subData_Yield/Top_Yield)); tex4->SetNDC(); tex4->SetTextSize(0.035); tex4->Draw(); } // Save //---------------------------------------------------------------------------- pad1->cd(); //SetAxis(subData, "", subData->GetYaxis()->GetTitle(), 0.05, 1.6); canvas->cd(); TString suffixLogy = (_setLogy) ? "_Log" : "_Lin"; canvas->SaveAs(Form("%s/%s%s_sub.%s", _output.Data(), hname.Data(), suffixLogy.Data(), _format.Data())); }
/* void formatCanvas(TCanvas *c){ c->Divide(1,2,0.01,0.01); c->cd(1); c->GetPad(1)->SetLogy(); c->GetPad(1)->SetPad(0.,0.425,1.,1.); c->GetPad(2)->SetPad(0.,0.0,1.,0.425); c->GetPad(2)->SetBottomMargin(0.3); c->GetPad(2)->SetGridy(1); } // divide by bin width void divideBinWidth(TH1 *h) { h->Sumw2(); for (int i=0;i<=h->GetNbinsX();i++) { Float_t val = h->GetBinContent(i); Float_t valErr = h->GetBinError(i); val/=h->GetBinWidth(i); valErr/=h->GetBinWidth(i); h->SetBinContent(i,val); h->SetBinError(i,valErr); } h->GetXaxis()->CenterTitle(); h->GetYaxis()->CenterTitle(); } void cleanup(TH1F *h) { for (int i=1;i<=h->GetNbinsX();i++) { double val1 = h->GetBinContent(i); double valErr1 = h->GetBinError(i); if (valErr1>=val1) { h->SetBinContent(i,0); h->SetBinError(i,0); } } } // rebin the spectra TH1F *rebin(TH1F *h, char *histName) { TH1F *hRebin = new TH1F(Form("%s_rebin",h->GetName()),Form("rebin %s",h->GetTitle()),nbins_recrebin,boundaries_recrebin); for (int i=1;i<=h->GetNbinsX();i++) { double val=h->GetBinContent(i); double valErr=h->GetBinError(i); int binNum = hRebin->FindBin(h->GetBinCenter(i)); double val1 = hRebin->GetBinContent(binNum); double valErr1 = hRebin->GetBinError(binNum); hRebin->SetBinContent(binNum,val+val1); hRebin->SetBinError(binNum,sqrt(valErr1*valErr1+valErr*valErr)); } cleanup(hRebin); hRebin->SetName(histName); return hRebin; } TH1F *rebin2(TH1F *h, char *histName) { TH1F *hRebin = new TH1F(Form("%s_rebin",h->GetName()),Form("rebin %s",h->GetTitle()),nbins_recrebin_2,boundaries_recrebin_2); for (int i=1;i<=h->GetNbinsX();i++) { double val=h->GetBinContent(i); double valErr=h->GetBinError(i); int binNum = hRebin->FindBin(h->GetBinCenter(i)); double val1 = hRebin->GetBinContent(binNum); double valErr1 = hRebin->GetBinError(binNum); hRebin->SetBinContent(binNum,val+val1); hRebin->SetBinError(binNum,sqrt(valErr1*valErr1+valErr*valErr)); } cleanup(hRebin); hRebin->SetName(histName); return hRebin; } void drawText(const char *text, float xp, float yp, int size){ TLatex *tex = new TLatex(xp,yp,text); tex->SetTextFont(63); tex->SetTextSize(size); tex->SetTextColor(kBlack); tex->SetLineWidth(1); //tex->SetTextFont(42); tex->SetNDC(); tex->Draw(); } void putCMSPrel(double x, double y, double size){ TLatex *tex=0; tex = new TLatex(x,y,"CMS Preliminary"); tex->SetTextSize(size); tex->SetLineWidth(2); tex->SetNDC(); tex->Draw(); } void putCMSSim(double x, double y, double size){ TLatex *tex=0; tex = new TLatex(x,y,"CMS Simulation"); tex->SetTextSize(size); tex->SetLineWidth(2); tex->SetNDC(); tex->Draw(); } TLegend *myLegend(double x1,double y1,double x2, double y2) { TLegend *leg = new TLegend(x1,y1,x2,y2); leg->SetBorderSize(0); leg->SetFillStyle(0); return leg; } */ void nlo_comp_macro(int radius = 3){ TH1::SetDefaultSumw2(); gStyle->SetOptStat(0); TFile *fPP = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/result-2013-akVs3PF-cent-1-isFineBin-0/pbpb_pp_merged_chmx_pt_isMC_0_Unfo_2013_akVs3PF_cent_1_isFineBin_0.root"); //TFile *fNLO_err = TFile::Open("fnl4350a_cteq"); TFile *fNLO_nnpdf = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/fnl4350a_nnpdf21-nlo_aspdf_new.root"); TFile *fNLO_cteq = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/fnl4350a_cteq66-nlo_aspdf_all_new.root"); TFile *fNLO_ct10n = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/fnl4350a_ct10n-nlo_aspdf_new.root"); TFile *fNLO_hera = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/fnl4350a_hera15all-nlo_aspdf_new.root"); TFile *fPP_data_R3 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/pp_2013_2760TeV_data_ak3PF.root"); TFile *fPP_data_R4 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/pp_2013_2760TeV_data_ak4PF.root"); TFile *fPP_data_R5 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/pp_2013_2760TeV_data_ak5PF.root"); TFile *faditya = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/comparison.root"); //alright lets get the unfolded data here: remember we need it for eta range -2 to +2 //TFile* fPP_unfo_R3 = TFile::Open("pp_2013_2760_abs_eta_2_mc_ak3PF.root"); TFile* fPP_unfo_R4 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/pp_2013_2760_abs_eta_2_mc_ak4PF.root"); TFile* fPP_unfo_R5 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/pp_2013_2760_abs_eta_2_mc_ak5PF.root"); //TFile *f_unfold_R2 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/RAA/CMSSW_5_3_20/src/Output/PbPb_pp_unfold_marguerite_jet80_chMaxjtpt_norawptcut_test_65GeVCut_akPu2PF_20150205_test.root"); TFile *f_unfold_R3 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/RAA/CMSSW_5_3_20/src/Output/PbPb_pp_unfold_marguerite_comb_chMaxjtpt_norawptcut_test_65GeVCut_akPu3PF_20150206_test.root"); //TFile *f_unfold_R4 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/RAA/CMSSW_5_3_20/src/Output/PbPb_pp_unfold_marguerite_jet80_chMaxjtpt_norawptcut_test_65GeVCut_akPu4PF_20150205_test.root"); TH1F* hPP_data_R_3 = (TH1F*)f_unfold_R3->Get("PP_bayesian_unfolded_spectra"); //PP_measured[0] = (TH1F*)f_unfold_R2->Get("PP_measured_unfolded_spectra"); //PP_binbybin[0] = (TH1F*)f_unfold_R2->Get("PP_binbybin_unfolded_spectra"); //TH1F* PP_bayesian[1] = (TH1F*)f_unfold_R4->Get("PP_bayesian_unfolded_spectra"); //PP_measured[1] = (TH1F*)f_unfold_R3->Get("PP_measured_unfolded_spectra"); //PP_binbybin[1] = (TH1F*)f_unfold_R3->Get("PP_binbybin_unfolded_spectra"); TFile fout("pp_2760GeV_nlo_histos.root","RECREATE"); fout.cd(); TH1F* hPP_nnpdf_NLO = (TH1F*)fNLO_nnpdf->Get(Form("h100%d00",radius-1)); TH1F* hPP_cteq_NLO = (TH1F*)fNLO_cteq->Get(Form("h100%d00",radius-1)); TH1F* hPP_ct10n_NLO = (TH1F*)fNLO_ct10n->Get(Form("h100%d00",radius-1)); TH1F* hPP_hera_NLO = (TH1F*)fNLO_hera->Get(Form("h100%d00",radius-1)); //TH1F* hPP_data_R_3 = (TH1F*)fPP_unfo_R3->Get("Unfolded_cent1"); TH1F* hPP_data_R_4 = (TH1F*)fPP_unfo_R4->Get("Unfolded_cent1"); TH1F* hPP_data_R_5 = (TH1F*)fPP_unfo_R5->Get("Unfolded_cent1"); hPP_data_R_3->Scale(5.3*1e3); hPP_data_R_3->Scale(1./5300e6); //hPP_data_R_3->Scale(1./4); //divideBinWidth(hPP_data_R_3); hPP_data_R_4->Scale(1./5300e6); hPP_data_R_4->Scale(1./4); divideBinWidth(hPP_data_R_4); hPP_data_R_5->Scale(1./5300e6); hPP_data_R_5->Scale(1./4); divideBinWidth(hPP_data_R_5); // NLO histograms without any R# at the end correspond to R=0.3 the standard. others are named accordingly TH1F* hPP_nnpdf_NLO_R4 = (TH1F*)fNLO_nnpdf->Get("h100300"); TH1F* hPP_nnpdf_NLO_R2 = (TH1F*)fNLO_nnpdf->Get("h100100"); TH1F* hPP_cteq_NLO_R4 = (TH1F*)fNLO_cteq->Get("h100300"); TH1F* hPP_ct10n_NLO_R4 = (TH1F*)fNLO_ct10n->Get("h100300"); TH1F* hPP_hera_NLO_R4 = (TH1F*)fNLO_hera->Get("h100300"); TH1F* hPP_cteq_NLO_R2 = (TH1F*)fNLO_cteq->Get("h100100"); TH1F* hPP_ct10n_NLO_R2 = (TH1F*)fNLO_ct10n->Get("h100100"); TH1F* hPP_hera_NLO_R2 = (TH1F*)fNLO_hera->Get("h100100"); TH1F* hPP_err = (TH1F*)fNLO_cteq->Get("h100203"); TH1F* hPP_err_R4 = (TH1F*)fNLO_cteq->Get("h100303"); TH1F* hPP_err_R2 = (TH1F*)fNLO_cteq->Get("h100103"); for(int i = 0;i<hPP_nnpdf_NLO->GetNbinsX();i++){ Float_t valErr = hPP_err->GetBinError(i); hPP_nnpdf_NLO->SetBinError(i,valErr); hPP_cteq_NLO->SetBinError(i,valErr); hPP_hera_NLO->SetBinError(i,valErr); hPP_ct10n_NLO->SetBinError(i,valErr); Float_t valErr_R4 = hPP_err_R4->GetBinError(i); hPP_nnpdf_NLO_R4->SetBinError(i,valErr_R4); hPP_cteq_NLO_R4->SetBinError(i,valErr_R4); hPP_ct10n_NLO_R4->SetBinError(i,valErr_R4); hPP_hera_NLO_R4->SetBinError(i,valErr_R4); Float_t valErr_R2 = hPP_err_R2->GetBinError(i); hPP_nnpdf_NLO_R2->SetBinError(i,valErr_R2); hPP_cteq_NLO_R2->SetBinError(i,valErr_R2); hPP_ct10n_NLO_R2->SetBinError(i,valErr_R2); hPP_hera_NLO_R2->SetBinError(i,valErr_R2); } //add the NPC factors char etaWidth[dir][256] = { "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20", "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20", "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20", "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20", "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20" }; char radius_lable[dir][256] = { "R2","R2","R2","R2","R2","R2","R2","R2","R2","R2", "R3","R3","R3","R3","R3","R3","R3","R3","R3","R3", "R4","R4","R4","R4","R4","R4","R4","R4","R4","R4", "R5","R5","R5","R5","R5","R5","R5","R5","R5","R5", "R7","R7","R7","R7","R7","R7","R7","R7","R7","R7" }; ifstream fin_txt[dir]; int energy = 2760; for(int i = 0;i<dir;i++){ //ostringstream filename; //filename<<"/net/hisrv0001/home/rkunnawa/WORK/RAA/CMSSW_5_3_8_HI_patch2/src/Macros/RAA/nlo_files/input_np_txtfiles/NPC_ak_"<<radius_lable[i]<<etaWidth[i]<<"_energy"<<energy<<".txt"; fin_txt[i].open(Form("/net/hisrv0001/home/rkunnawa/WORK/RAA/CMSSW_5_3_8_HI_patch2_old/src/Macros/RAA/nlo_files/input_np_txtfiles/NPC_ak_%s_%s_energy%d.txt",radius_lable[i],etaWidth[i],energy)); } //apply the correction factors to the NLO histograms Float_t npc = 0; Float_t bin = 0; //before applying the corrections, lets get a clone of the uncorrected histogram. TH1F* hPP_nnpdf_NLO_noNPC = (TH1F*)hPP_nnpdf_NLO->Clone("hPP_nnpdf_NLO_noNPC"); int counter = 0; while(1){ fin_txt[11]>>bin>>npc; cout<<bin<<" "<<npc<<endl; if(!fin_txt[11].good())break; int bin_no = hPP_nnpdf_NLO->FindBin(bin); //cout<<"bin no = "<<bin_no<<endl; //cout<<"boundaries_pt of bin no"<<boundaries_yaxian_large[bin_no]<<endl; cout<<"value before applying = "<<hPP_nnpdf_NLO->GetBinContent(bin_no)<<endl; hPP_nnpdf_NLO->SetBinContent(bin_no,npc*hPP_nnpdf_NLO->GetBinContent(bin_no)); cout<<"value after applying = "<<hPP_nnpdf_NLO->GetBinContent(bin_no)<<endl; hPP_cteq_NLO->SetBinContent(bin_no,npc*hPP_cteq_NLO->GetBinContent(bin_no)); hPP_ct10n_NLO->SetBinContent(bin_no,npc*hPP_ct10n_NLO->GetBinContent(bin_no)); hPP_hera_NLO->SetBinContent(bin_no,npc*hPP_hera_NLO->GetBinContent(bin_no)); fin_txt[1]>>bin>>npc; if(!fin_txt[1].good())break; bin_no = hPP_nnpdf_NLO_R2->FindBin(bin); hPP_nnpdf_NLO_R2->SetBinContent(bin_no,npc*hPP_nnpdf_NLO_R2->GetBinContent(bin_no)); hPP_cteq_NLO_R2->SetBinContent(bin_no,npc*hPP_cteq_NLO_R2->GetBinContent(bin_no)); hPP_ct10n_NLO_R2->SetBinContent(bin_no,npc*hPP_ct10n_NLO_R2->GetBinContent(bin_no)); hPP_hera_NLO_R2->SetBinContent(bin_no,npc*hPP_hera_NLO_R2->GetBinContent(bin_no)); fin_txt[21]>>bin>>npc; if(!fin_txt[21].good())break; bin_no = hPP_nnpdf_NLO_R4->FindBin(bin); hPP_nnpdf_NLO_R4->SetBinContent(bin_no,npc*hPP_nnpdf_NLO_R4->GetBinContent(bin_no)); hPP_cteq_NLO_R4->SetBinContent(bin_no,npc*hPP_cteq_NLO_R4->GetBinContent(bin_no)); hPP_ct10n_NLO_R4->SetBinContent(bin_no,npc*hPP_ct10n_NLO_R4->GetBinContent(bin_no)); hPP_hera_NLO_R4->SetBinContent(bin_no,npc*hPP_hera_NLO_R4->GetBinContent(bin_no)); counter++; } cout<<"counter = "<<counter<<endl; //get a clone after applying the corrections, TH1F* hPP_nnpdf_NLO_NPC = (TH1F*)hPP_nnpdf_NLO->Clone("hPP_nnpdf_NLO_NPC"); TH1F* hPP_NPC_ratio = (TH1F*)hPP_nnpdf_NLO_NPC->Clone("hPP_NPC_ratio"); hPP_NPC_ratio->Divide(hPP_nnpdf_NLO_noNPC); /* TCanvas *cnpc = new TCanvas("cnpc","",800,600); //cnpc->SetLogy(); hPP_NPC_ratio->SetTitle("NPC 2.76 TeV R=0.3"); hPP_NPC_ratio->SetXTitle("Jet p_{T} (GeV/c)"); hPP_NPC_ratio->SetYTitle("NP factors"); hPP_NPC_ratio->SetAxisRange(0.7,1.3,"Y"); hPP_NPC_ratio->Draw(); cnpc->SaveAs("pp_2760_npc_R3.pdf","RECREATE"); */ hPP_nnpdf_NLO->SetName("hPP_nnpdf_NLO"); hPP_cteq_NLO->SetName("hPP_cteq_NLO"); hPP_ct10n_NLO->SetName("hPP_ct10n_NLO"); hPP_hera_NLO->SetName("hPP_hera_NLO"); hPP_nnpdf_NLO_R2->SetName("hPP_nnpdf_NLO_R2"); hPP_nnpdf_NLO_R2->Print("base"); hPP_cteq_NLO_R2->SetName("hPP_cteq_NLO_R2"); hPP_cteq_NLO_R2->Print("base"); hPP_ct10n_NLO_R2->SetName("hPP_ct10n_NLO_R2"); hPP_ct10n_NLO_R2->Print("base"); hPP_hera_NLO_R2->SetName("hPP_hera_NLO_R2"); hPP_nnpdf_NLO_R4->SetName("hPP_nnpdf_NLO_R4"); hPP_cteq_NLO_R4->SetName("hPP_cteq_NLO_R4"); hPP_ct10n_NLO_R4->SetName("hPP_ct10n_NLO_R4"); hPP_hera_NLO_R4->SetName("hPP_hera_NLO_R4"); hPP_nnpdf_NLO->Write(); hPP_cteq_NLO->Write(); hPP_ct10n_NLO->Write(); hPP_hera_NLO->Write(); hPP_nnpdf_NLO_R2->Write(); hPP_cteq_NLO_R2->Write(); hPP_ct10n_NLO_R2->Write(); hPP_hera_NLO_R2->Write(); hPP_nnpdf_NLO_R4->Write(); hPP_cteq_NLO_R4->Write(); hPP_ct10n_NLO_R4->Write(); hPP_hera_NLO_R4->Write(); TH1F* hPPrebin = (TH1F*)hPP_data_R_3->Clone("hPPrebin"); //TH1F* hPPrebin_test = (TH1F*)faditya->Get("Corrected Jet Spectrum Aditya"); //TH1F* hPPrebin = (TH1F*)hPPrebin_test->Rebin(nbins_yaxian_large,"hPPrebin",boundaries_yaxian_large); //TH1F* hPPunfo = (TH1F*)fPP->Get("Unfolded_cent6"); TH1F* hPPgen = (TH1F*)fPP->Get("hGen_cent1"); //hPPrebin->Scale(64);//remove the sigma scaling from the previous macros //dont need this now since we are taking it from a dedicated macro which gives us diff cross section hPP_data_R_3->Scale(1e9); hPP_data_R_4->Scale(1e9); hPP_data_R_5->Scale(1e9); //hPP_nnpdf_NLO->Scale(1./4); //hPP_cteq_NLO->Scale(1./4); //hPP_hera_NLO->Scale(1./4); hPPrebin->Scale(1e9); //hPPrebin->Scale(1./5300e6); //hPPrebin->Scale(1./4); //divideBinWidth(hPPrebin); hPPgen->Scale(1./4); hPPgen->Scale(1e9); fout.Write(); TH1F* hRatio_nnpdf_mc = (TH1F*)hPPgen->Rebin(nbins_yaxian_large,"hRatio_nnpdf_mc",boundaries_yaxian_large); hRatio_nnpdf_mc->Divide(hPP_nnpdf_NLO); TH1F* hRatio_cteq_mc = (TH1F*)hPPgen->Rebin(nbins_yaxian_large,"hRatio_cteq_mc",boundaries_yaxian_large); hRatio_cteq_mc->Divide(hPP_cteq_NLO); TH1F* hRatio_hera_mc = (TH1F*)hPPgen->Rebin(nbins_yaxian_large,"hRatio_hera_mc",boundaries_yaxian_large); hRatio_hera_mc->Divide(hPP_hera_NLO); TH1F* hRatio_ct10n_mc = (TH1F*)hPPgen->Rebin(nbins_yaxian_large,"hRatio_ct10n_mc",boundaries_yaxian_large); hRatio_ct10n_mc->Divide(hPP_ct10n_NLO); TH1F* hRatio_nnpdf = (TH1F*)hPP_nnpdf_NLO->Rebin(nbins_yaxian_large,"hRatio_nnpdf",boundaries_yaxian_large); hRatio_nnpdf->Divide(hPPrebin); TH1F* hRatio_cteq = (TH1F*)hPP_cteq_NLO->Rebin(nbins_yaxian_large,"hRatio_cteq",boundaries_yaxian_large); hRatio_cteq->Divide(hPPrebin); TH1F* hRatio_ct10n = (TH1F*)hPP_ct10n_NLO->Rebin(nbins_yaxian_large,"hRatio_ct10n",boundaries_yaxian_large); hRatio_ct10n->Divide(hPPrebin); TH1F* hRatio_hera = (TH1F*)hPP_hera_NLO->Rebin(nbins_yaxian_large,"hRatio_hera",boundaries_yaxian_large); hRatio_hera->Divide(hPPrebin); TH1F* hRatio_ppgen = (TH1F*)hPPgen->Rebin(nbins_yaxian_large,"hRatio_ppgen",boundaries_yaxian_large); hRatio_ppgen->Divide(hPPrebin); TH1F* hRatio_nnpdf_R_2_4 = (TH1F*)hPP_nnpdf_NLO_R2->Rebin(nbins_yaxian_large,"hRatio_nnpdf_R_2_4",boundaries_yaxian_large); hRatio_nnpdf_R_2_4->Divide(hPP_nnpdf_NLO_R4); TH1F* hRatio_nnpdf_R_3_4 = (TH1F*)hPP_nnpdf_NLO->Rebin(nbins_yaxian_large,"hRatio_nnpdf_R_3_4",boundaries_yaxian_large); hRatio_nnpdf_R_3_4->Divide(hPP_nnpdf_NLO_R4); TH1F* hRatio_cteq_R_2_4 = (TH1F*)hPP_cteq_NLO_R2->Rebin(nbins_yaxian_large,"hRatio_cteq_R_2_4",boundaries_yaxian_large); hRatio_cteq_R_2_4->Divide(hPP_cteq_NLO_R4); TH1F* hRatio_cteq_R_3_4 = (TH1F*)hPP_cteq_NLO->Rebin(nbins_yaxian_large,"hRatio_cteq_R_3_4",boundaries_yaxian_large); hRatio_cteq_R_3_4->Divide(hPP_cteq_NLO_R4); TH1F* hRatio_ct10n_R_2_4 = (TH1F*)hPP_ct10n_NLO_R2->Rebin(nbins_yaxian_large,"hRatio_ct10n_R_2_4",boundaries_yaxian_large); hRatio_ct10n_R_2_4->Divide(hPP_ct10n_NLO_R4); TH1F* hRatio_ct10n_R_3_4 = (TH1F*)hPP_ct10n_NLO->Rebin(nbins_yaxian_large,"hRatio_ct10n_R_3_4",boundaries_yaxian_large); hRatio_ct10n_R_3_4->Divide(hPP_ct10n_NLO_R4); TH1F* hRatio_hera_R_2_4 = (TH1F*)hPP_hera_NLO_R2->Rebin(nbins_yaxian_large,"hRatio_hera_R_2_4",boundaries_yaxian_large); hRatio_hera_R_2_4->Divide(hPP_hera_NLO_R4); TH1F* hRatio_hera_R_3_4 = (TH1F*)hPP_hera_NLO->Rebin(nbins_yaxian_large,"hRatio_hera_R_3_4",boundaries_yaxian_large); hRatio_hera_R_3_4->Divide(hPP_hera_NLO_R4); TH1F* hRatio_data_nnpdf_R_3 = (TH1F*)hPP_nnpdf_NLO->Rebin(nbins_yaxian_large,"hRatio_data_nnpdf_R_3",boundaries_yaxian_large); hRatio_data_nnpdf_R_3->Divide(hPP_data_R_3); TH1F* hRatio_data_nnpdf_R_4 = (TH1F*)hPP_nnpdf_NLO_R4->Rebin(nbins_yaxian_large,"hRatio_data_nnpdf_R_4",boundaries_yaxian_large); hRatio_data_nnpdf_R_4->Divide(hPP_data_R_4); TH1F* hRatio_data_R_3_4 = (TH1F*)hPP_data_R_3->Clone("hRatio_data_R_3_4"); hRatio_data_R_3_4->Divide(hPP_data_R_4); TH1F* hRatio_data_R_3_5 = (TH1F*)hPP_data_R_3->Clone("hRatio_data_R_3_5"); hRatio_data_R_3_5->Divide(hPP_data_R_5); TH1F* hRatio_data_R_4_5 = (TH1F*)hPP_data_R_4->Clone("hRatio_data_R_4_5"); hRatio_data_R_4_5->Divide(hPP_data_R_5); /* TCanvas *cnlo_mc = new TCanvas("cnlo_mc","",800,600); hRatio_nnpdf_mc->SetMarkerColor(kRed); hRatio_nnpdf_mc->SetMarkerStyle(20); hRatio_nnpdf_mc->SetXTitle("Jet p_{T} (GeV/c)"); hRatio_nnpdf_mc->SetYTitle("MC/NLO"); hRatio_nnpdf_mc->SetTitle(" "); hRatio_nnpdf_mc->SetAxisRange(0,1.5,"Y"); hRatio_nnpdf_mc->Draw(); hRatio_cteq_mc->SetMarkerColor(kBlue); hRatio_cteq_mc->SetMarkerStyle(20); hRatio_cteq_mc->Draw("same"); hRatio_ct10n_mc->SetMarkerColor(9); hRatio_ct10n_mc->SetMarkerStyle(20); hRatio_ct10n_mc->Draw("same"); hRatio_hera_mc->SetMarkerColor(kGreen); hRatio_hera_mc->SetMarkerStyle(20); hRatio_hera_mc->Draw("same"); TLegend *titlenlomc = myLegend(0.10,0.10,0.30,0.30); titlenlomc->AddEntry(hRatio_nnpdf_mc,"nnpdf","pl"); titlenlomc->AddEntry(hRatio_cteq_mc,"cteq","pl"); titlenlomc->AddEntry(hRatio_ct10n_mc,"ct10n","pl"); titlenlomc->AddEntry(hRatio_hera_mc,"hera","pl"); titlenlomc->SetTextSize(0.04); titlenlomc->Draw(); putCMSSim(0.1,0.92,0.06); drawText("pp #sqrt{s}=2.76(TeV)",0.65,0.92,16); drawText(Form("anti k_{T} R = 0.%d, NP corrections added to NLO",radius),0.15,0.83,16); cnlo_mc->SaveAs(Form("Ratio_mc_with_nlo_with_np_R%d.pdf",radius),"RECREATE"); */ TCanvas *c1 = new TCanvas("c1","",800,600); formatCanvas(c1); c1->cd(1); c1->cd(1)->SetLogy(); hPP_nnpdf_NLO->SetMarkerColor(kRed); hPP_nnpdf_NLO->SetMarkerStyle(24); hPP_cteq_NLO->SetMarkerColor(kBlue); hPP_cteq_NLO->SetMarkerStyle(24); hPP_ct10n_NLO->SetMarkerColor(9);//purple hPP_ct10n_NLO->SetMarkerStyle(20); hPP_hera_NLO->SetMarkerColor(kGreen); hPP_hera_NLO->SetMarkerStyle(20); hPPrebin->SetMarkerColor(kBlack); hPPrebin->SetMarkerStyle(8); hPPgen->SetMarkerColor(kOrange); hPPgen->SetMarkerStyle(8); //hPPgen->SetMarkerColor(kRed); //hPPgen->SetMarkerStyle(8); makeHistTitle(hPP_nnpdf_NLO,"","p_{T} (GeV/c)","#frac{d^{2} #sigma}{d p_{T} d #eta} (pb#frac{GeV}{c})"); //hPP_nnpdf_NLO->SetYTitle("#frac{d^{2} #sigma}{d p_{T} d #eta} (pb#frac{GeV}{c})"); //hPP_nnpdf_NLO->SetXTitle("p_{T} (GeV/c)"); hPP_nnpdf_NLO->SetAxisRange(22,500,"X"); hPP_nnpdf_NLO->SetTitle(" "); hPP_nnpdf_NLO->Draw("p"); hPP_cteq_NLO->Draw("same p"); //hPP_ct10n_NLO->Draw("same p"); //hPP_hera_NLO->Draw("same p"); hPPrebin->Draw("same p"); //hPPgen->Draw("same p"); TLegend * title = myLegend(0.47, 0.50,0.67, 0.8); title->AddEntry(hPP_nnpdf_NLO,"NLO nnpdf","pl"); title->AddEntry(hPP_cteq_NLO,"NLO cteq","pl"); //title->AddEntry(hPP_ct10n_NLO,"NLO ct10n","pl"); //title->AddEntry(hPP_hera_NLO,"NLO hera","pl"); //title->AddEntry(hPPgen,"pp MC spectra","pl"); title->AddEntry(hPPrebin,"pp unfolded 2013 data","pl"); title->SetTextSize(0.04); title->Draw(); putCMSPrel(0.1,0.92,0.06); drawText("pp 2013, #sqrt{s}=2.76(TeV), #int L dt = 5.3 (pb)^{-1}",0.35,0.92,16); drawText(Form("anti k_{T} R = 0.3, NP corrections added to NLO",radius),0.35,0.83,16); c1->cd(2); makeHistTitle(hRatio_nnpdf,"","p_{T} (GeV/c)","X / pp data"); //hRatio_nnpdf->SetYTitle(" X / pp data"); //hRatio_nnpdf->SetXTitle("p_{T} (GeV/c)"); hRatio_nnpdf->SetTitle(" "); hRatio_nnpdf->SetAxisRange(0.8,2,"Y"); hRatio_nnpdf->SetMarkerColor(kRed); hRatio_nnpdf->SetMarkerStyle(20); hRatio_hera->SetMarkerColor(kGreen); hRatio_hera->SetMarkerStyle(20); hRatio_cteq->SetMarkerColor(kBlue); hRatio_cteq->SetMarkerStyle(20); hRatio_ct10n->SetMarkerColor(9); hRatio_ct10n->SetMarkerStyle(20); hRatio_ppgen->SetMarkerColor(kOrange); hRatio_ppgen->SetMarkerStyle(20); hRatio_nnpdf->Draw("p"); hRatio_nnpdf->SetAxisRange(22,500,"X"); //hRatio_hera->Draw("same p"); hRatio_cteq->Draw("same p"); //hRatio_ppgen->Draw("same p"); c1->SaveAs(Form("pp_2760GeV_NLO_NPadded_ak%dPF_spectra.pdf",radius),"RECREATE"); /* //get the information from the ratio per bins - to use to scale down the NLO in 5.02 TeV. ofstream R_nnpdf,R_hera,R_cteq; R_nnpdf.open(Form("ratio_nnpdf_vs_pp_data_2760_ak%d.txt",radius)); R_hera.open(Form("ratio_hera_vs_pp_data_2760_ak%d.txt",radius)); R_cteq.open(Form("ratio_cteq_vs_pp_data_2760_ak%d.txt",radius)); for(int i = 0;i<hRatio_nnpdf->GetNbinsX();i++){ R_nnpdf<<i<<"\t"<<hRatio_nnpdf->GetBinContent(i)<<endl; R_hera<<i<<"\t"<<hRatio_hera->GetBinContent(i)<<endl; R_cteq<<i<<"\t"<<hRatio_cteq->GetBinContent(i)<<endl; } R_nnpdf.close(); R_hera.close(); R_cteq.close(); //draw the results for NLO comparison within different radius at the same energy TCanvas *c2 = new TCanvas("c2","",800,600); formatCanvas(c2); c2->cd(1); hPP_nnpdf_NLO->SetMarkerStyle(22); hPP_nnpdf_NLO->SetMarkerColor(3); hPP_nnpdf_NLO->Draw("p"); hPP_nnpdf_NLO_R2->SetMarkerStyle(22); hPP_nnpdf_NLO_R2->SetMarkerColor(2); hPP_nnpdf_NLO_R2->Draw("same p"); hPP_nnpdf_NLO_R4->SetMarkerStyle(22); hPP_nnpdf_NLO_R4->SetMarkerColor(4); hPP_nnpdf_NLO_R4->Draw("same p"); hPP_data_R_4->SetMarkerStyle(23); hPP_data_R_4->SetMarkerColor(4); hPP_data_R_4->Draw("same p"); hPP_data_R_3->SetMarkerStyle(23); hPP_data_R_3->SetMarkerColor(3); hPP_data_R_3->Draw("same p"); hPP_data_R_5->SetMarkerStyle(23); hPP_data_R_5->SetMarkerColor(9); hPP_data_R_5->Draw("same p"); TLegend * title2 = myLegend(0.47, 0.50,0.67, 0.8); title2->AddEntry(hPP_nnpdf_NLO_R2,"NNPDF21 R=0.2","pl"); title2->AddEntry(hPP_nnpdf_NLO,"NNPDF21 R=0.3","pl"); title2->AddEntry(hPP_nnpdf_NLO_R4,"NNPDF21 R=0.4","pl"); title2->AddEntry(hPP_data_R_3,"Data R=0.3","pl"); title2->AddEntry(hPP_data_R_4,"Data R=0.4","pl"); title2->AddEntry(hPP_data_R_5,"Data R=0.5","pl"); title2->SetTextSize(0.04); title2->Draw(); putCMSPrel(0.1,0.92,0.06); drawText("pp 2013, #sqrt{s}=2.76(TeV), #int L dt = 5.3 (pb)^{-1}",0.35,0.92,16); drawText(Form("anti k_{T}, Data vs Theory",radius),0.47,0.83,16); c2->cd(2); hRatio_nnpdf_R_2_4->SetMarkerStyle(29); hRatio_nnpdf_R_2_4->SetMarkerColor(2); hRatio_nnpdf_R_2_4->SetAxisRange(0.6,1.6,"Y"); hRatio_nnpdf_R_2_4->SetAxisRange(22,500,"X"); hRatio_nnpdf_R_2_4->SetTitle(" "); hRatio_nnpdf_R_2_4->SetYTitle("Ratios"); hRatio_nnpdf_R_2_4->SetXTitle("p_{T}(GeV/c)"); hRatio_nnpdf_R_2_4->Draw("p"); hRatio_nnpdf_R_3_4->SetMarkerStyle(29); hRatio_nnpdf_R_3_4->SetMarkerColor(3); hRatio_nnpdf_R_3_4->Draw("same p"); hRatio_data_nnpdf_R_3->SetMarkerStyle(33); hRatio_data_nnpdf_R_3->SetMarkerColor(4); hRatio_data_nnpdf_R_3->Draw("same p"); hRatio_data_nnpdf_R_4->SetMarkerStyle(33); hRatio_data_nnpdf_R_4->SetMarkerColor(7); hRatio_data_nnpdf_R_4->Draw("same p"); hRatio_data_R_3_4->SetMarkerStyle(34); hRatio_data_R_3_4->SetMarkerColor(6); hRatio_data_R_3_4->Draw("same p"); hRatio_data_R_3_5->SetMarkerStyle(34); hRatio_data_R_3_5->SetMarkerColor(7); hRatio_data_R_3_5->Draw("same p"); hRatio_data_R_4_5->SetMarkerStyle(34); hRatio_data_R_4_5->SetMarkerColor(8); hRatio_data_R_4_5->Draw("same p"); c2->cd(1); TLegend * title3 = myLegend(0.67, 0.40,0.77, 0.8); title3->AddEntry(hRatio_nnpdf_R_2_4,"NLO R=0.2/R=0.4","pl"); title3->AddEntry(hRatio_nnpdf_R_3_4,"NLO R=0.3/R=0.4","pl"); title3->AddEntry(hRatio_data_nnpdf_R_3,"R=0.3 NNPDF21/Data","pl"); title3->AddEntry(hRatio_data_nnpdf_R_4,"R=0.4 NNPDF21/Data","pl"); title3->AddEntry(hRatio_data_R_3_4,"Data R=0.3/R=0.4","pl"); title3->AddEntry(hRatio_data_R_3_5,"Data R=0.3/R=0.5","pl"); title3->AddEntry(hRatio_data_R_4_5,"Data R=0.4/R=0.5","pl"); title3->SetTextSize(0.04); title3->Draw(); c2->SaveAs("pp_2760GeV_data_NLO_NPCadded_radius_comparison.pdf","RECREATE"); fout.Write(); fout.Close(); */ /* TCanvas *c2 = new TCanvas("c2","",1000,800); c2->Divide(2,1); c2->cd(1); c2->cd(1)->SetLogy(); hPPunfo->SetTitle("PP 2013 2.76 TeV Merged, Unfolded p_{T} Spectra"); hPPunfo->SetYTitle("#frac{dN}{N_{MB} d p_{T} d #eta}"); hPPunfo->GetYaxis()->SetTitleOffset(1.4); hPPunfo->SetXTitle("Jet p_{T} GeV/c"); hPPunfo->GetXaxis()->SetRangeUser(50,500); hPPunfo->Draw(); hPPmeas->GetXaxis()->SetRangeUser(50,500); hPPmeas->SetMarkerStyle(22); hPPmeas->SetMarkerColor(kBlack); hPPmeas->Draw("same"); TLegend *titl = myLegend(0.54,0.65,0.85,0.9); titl->AddEntry(hPPmeas,"PP2013 Meas ak3PF","pl"); titl->AddEntry(hPPunfo,"PP2013 Unfo Bayesian","pl"); titl->SetTextSize(0.03); titl->Draw(); drawText("Anti-k_{T}PF R = 0.3",0.43,0.6,22); drawText("|#eta|<2, |vz|<15",0.47,0.5,22); c2->cd(2); TH1F* hPPRatio = (TH1F*)hPPmeas->Clone("hPPRatio"); hPPRatio->Divide(hPPunfo); hPPRatio->SetXTitle("Jet p_{T} GeV/c"); hPPRatio->SetYTitle("Ratio Measured/Unfolded"); hPPRatio->SetTitle("PP2013 ak3PF merged"); hPPRatio->GetYaxis()->SetRangeUser(0,2); hPPRatio->Draw(); c2->SaveAs("pp_2013_ak3_merged_unfolded_pt.pdf","RECREATE"); */ /* TH1F *hNLO_err = (TH1F*)fNLO->Get("h100203"); for(int i = 0;i<hNLO_err->GetNbinsX();i++){ Float_T valErr = hNLO_Err->GetBinError(i); hNLO->SetBinError(i,valErr); } */ /* //h100300 - ak4PF, h100200 - ak3PF TH1F* hNLO_2 = (TH1F*)hNLO->Clone("hNLO_2"); hNLO->Print("base"); TCanvas *cComp = new TCanvas("cComp","",800,600); cComp->Divide(2,1); cComp->cd(1); cComp->cd(1)->SetLogy(); hPPrebin->SetMarkerStyle(22); hPPrebin->SetMarkerColor(kRed); hNLO->SetMarkerStyle(20); hNLO->SetMarkerColor(kBlack); hNLO->SetTitle("PP 2.76 TeV"); hNLO->SetYTitle("#sigma pb"); hNLO->SetXTitle("Jet p_{T} GeV/c"); hNLO->Draw("pl"); hPPMCrebin->SetMarkerStyle(21); hPPMCrebin->SetMarkerColor(kBlue); hPPMCrebin->Draw("same"); hPPrebin->Draw("same"); TLegend *title = myLegend(0.34,0.65,0.54,0.75); title->AddEntry(hNLO,"NLO nnpdf21","pl"); title->AddEntry(hPPrebin,"PP ak3PF unfo","pl"); title->AddEntry(hPPMCrebin,"PP ak3PF MC Gen","pl"); title->SetTextSize(0.06); title->Draw(); cComp->cd(2); TH1F *hPP = (TH1F*)hPPrebin->Clone("hPP"); TH1F* hPPMC_v2 = (TH1F*)hPPMCrebin->Clone("hPPMC_v2"); hPP->Print("base"); hPPMC_v2->Print("base"); hPP->Divide(hNLO); hPPMC_v2->Divide(hNLO); hPP->SetTitle("Ratio of PP ak3PF unfolded and MC Gen to NLO"); //hPP->SetTitle("Ratio of PP ak4PF measured to NLO"); hPP->SetYTitle("#frac{#sigma_{PP}}{#sigma_{NLO}}"); hPP->SetXTitle("Jet p_{T} GeV/c"); hPP->Draw(); hPPMC_v2->Draw("same"); cComp->SaveAs("fastNLO_comparison/ratio_pp_ak3_merged_NLO_nnpdf21nlo.pdf","RECREATE"); TCanvas c1; c1.SetLogy(); hPPrebin->SetAxisRange(50,500,"X"); hPPrebin->SetYTitle("#sigma (pb)"); hPPrebin->SetXTitle("Jet p_{T} GeV/c"); hPPrebin->SetTitle("PP ak3PF unfolded"); hPPrebin->Draw(); c1.SaveAs("fastNLO_comparison/PP_2013_ak3_merged_Unfolded_crosssection.pdf","RECREATE"); c1.SaveAs("fastNLO_comparison/PP_2013_ak3_merged_Unfolded_crosssection.C","RECREATE"); TCanvas *c3 = new TCanvas("c3","",800,600); c3->SetGrid(); c3->SetLogy(); //TGraphErrors graph_Expected("./fastNLO_comparison/files/s2760_R0.3fine.tex","%lg %lg"); //graph_Expected.SetTitle("Non Perturbative corrections (extrapolation from Atlas) s2760;p_{T} GeV/c;#sigma nb"); //graph_Expected.DrawClone("E3AL"); TFile *fNPC = TFile::Open("fastNLO_comparison/files/npc_extrapolation_ivan.root"); TH1F* hNPC = (TH1F*)fNPC->Get("hNPC"); hNPC->Scale(1000);// 1000 for the pb from nb //hNPC->Print("base"); //TH1F* hNPC_rebin1 = rebin2(hNPC,"hNPC_rebin1"); //divideBinWidth(hNPC_rebin1); hNPC->SetTitle("Non Perturbative corrections (extrapolation from Atlas) s2760"); hNPC->SetXTitle("p_{T} GeV/c"); hNPC->SetYTitle("#sigma (pb)"); hNPC->Draw(); hPPrebin->Draw("same"); c3->SaveAs("fastNLO_comparison/NPC_atlas_ak3.pdf","RECREATE"); TCanvas *c4 = new TCanvas("c4","",800,600); c4->SetLogy(); //TH1F* hNPC_rebin = (TH1F*)hNPC->Clone("hNPC_rebin"); TH1F* hNPC_rebin = rebin2(hNPC,"hNPC_rebin"); divideBinWidth(hNPC_rebin); hPPrebin_2->SetTitle("PP Cross sections Data and Theory comparisons"); hPPrebin_2->SetYTitle("#sigma (pb)"); hPPrebin_2->SetXTitle("p_{T} GeV/c"); //hNPC_rebin->SetAxisRange(1e4,1e-2,"Y"); hPPrebin_2->SetMarkerStyle(23); hPPrebin_2->SetMarkerColor(kBlack); hPPrebin_2->SetAxisRange(50,450,"X"); hPPrebin_2->Draw("E"); //hPPrebin_2->SetAxisRange(50,450,"X"); hNPC_rebin->SetMarkerStyle(21); hNPC_rebin->SetMarkerColor(kRed); hNPC_rebin->Draw("same"); hNLO_2->SetMarkerStyle(25); hNLO_2->SetMarkerColor(kBlue); hNLO_2->Draw("same"); TLegend *title2 = myLegend(0.54,0.65,0.85,0.9); title2->AddEntry(hNPC_rebin,"Ivan NPC - Atlas R=0.3","pl"); title2->AddEntry(hPPrebin_2,"PP2013 ak3PF unfolded","pl"); title2->AddEntry(hNLO_2,"CMS NLO nnpdf21 R=0.3","l"); title2->SetTextSize(0.04); title2->Draw(); gStyle->SetOptStat(0); c4->SaveAs("fastNLO_comparison/pp_ak3_nlo_overlay_hist.pdf","RECREATE"); TCanvas *c6 = new TCanvas("c6","",800,600); TH1F* hPPratio = (TH1F*)hPPrebin_2->Clone("hPPratio"); //add the error bars directly before dividing them and then set that as the error. //FLoat_t delta_PP = 0; //Float_t delta_NPC = 0; //Float_t delta hPPratio->Divide(hNPC_rebin); hPPratio->SetTitle("Ratio of PP 2013 ak3 unfolded w/ Ivan's NPC Atlas"); hPPratio->SetYTitle(" "); hPPratio->SetXTitle("p_{T} GeV/c"); hPPratio->Draw(); c6->SaveAs("pp_ak3_npc_ratio.pdf","RECREATE"); TCanvas *c5 = new TCanvas("c5","",800,600); hNPC->Draw(); hNPC_rebin->Draw("same"); c5->SetLogy(); c5->SaveAs("Ivan_plot_rebin_ak3.pdf","RECREATE"); */ }
void MakePlotDATAMC(std::string var, std::string xlabel){ TCanvas* c1 = new TCanvas("c1", "c1", 1); c1->cd(); c1->Divide(1,2); c1->cd(1); TFile* fin_data = TFile::Open("/afs/cern.ch/work/s/soffi/CMSSW_5_3_26-MonoJet/src/GJet/histos_GJets_DATA.root"); TFile* fin_bkg = TFile::Open("/afs/cern.ch/work/s/soffi/CMSSW_5_3_26-MonoJet/src/GJet/histos_GJets_MC.root"); TH1F* h_data = (TH1F*) fin_data->Get(("h_"+var).c_str()); TH1F* h_bkg = (TH1F*) fin_bkg->Get(("h_"+var).c_str()); h_data->Sumw2(); h_bkg->Sumw2(); double data_norm = h_data->Integral(); double bkg_norm = h_bkg->Integral()*19.7*1.33; std::cout<<data_norm<< " "<<bkg_norm<< std::endl; //h_bkg->Scale( h_data->Integral()/h_bkg->Integral()); h_bkg->Scale(bkg_norm/h_bkg->Integral()); if(var == "phmet" || var == "phmetW"){ hdensity(h_data); hdensity(h_bkg); std::cout<<"\\begin{table}[bthp]"<<std::endl; std::cout<<"\\begin{tabular}{||cc||}"<<std::endl; std::cout<<"\\hline"<<std::endl; // std::cout<<"MET range \& $\\gamma$+jets events \\\\"<<td::endl; std::cout<<"MET range \& $Z\\rightarrow \\nu\\nu$ events \\\\"<<td::endl; std::cout<<"\\hline"<<std::endl; std::cout<<"250--300 \&"<<h_data->Integral(h_data->FindBin(250),h_data->FindBin(300))<<" \\\\"<<std::endl; std::cout<<"300--350 \&"<<h_data->Integral(h_data->FindBin(300)+1,h_data->FindBin(350))<<" \\\\"<<std::endl; std::cout<<"350--400 \&"<<h_data->Integral(h_data->FindBin(350)+1,h_data->FindBin(400))<<" \\\\"<<std::endl; std::cout<<"400--500 \&"<<h_data->Integral(h_data->FindBin(400)+1,h_data->FindBin(500))<<" \\\\"<<std::endl; std::cout<<"500--1000 \&"<<h_data->Integral(h_data->FindBin(500)+1,h_data->FindBin(1000))<<" \\\\"<<std::endl; std::cout<<"\\hline"<<std::endl; std::cout<<"\\end{tabular}\\end{table}"<<std::endl; } h_bkg->SetLineColor(kAzure+7); h_bkg->SetFillColor(kAzure+6); h_bkg->SetLineWidth(2); h_data->Draw("PE"); h_bkg->Draw("histsame"); h_bkg->GetXaxis()->SetTitle(xlabel.c_str()); h_data->SetMarkerSize(0.7); h_data->Draw("PEsame"); TLegend* legmc; legmc = new TLegend(0.6, 0.55, 0.82, 0.89, "", "brNDC"); legmc->SetTextFont(42); legmc->SetBorderSize(0); legmc->SetFillStyle(0); legmc->AddEntry(h_data, "Data", "L"); legmc->AddEntry(h_bkg, "#gamma + jet", "L"); legmc->Draw("same"); CMS_lumi( (TPad*)c1->cd(1),true,0); c1->cd(2); TH1F* hs = (TH1F*) h_data->Clone(); hs->Divide(h_bkg); hs->Draw("pe"); hs->GetXaxis()->SetTitle(xlabel.c_str()); hs->GetYaxis()->SetTitle("Data/MC"); hs->GetYaxis()->SetRangeUser(0., 2.); TLine line(hs->GetBinCenter(1),1,hs->GetBinCenter(hs->GetNbinsX()+1),1); line.SetLineColor(kRed); line.Draw("same"); int iPos=0 ; CMS_lumi( (TPad*)c1->cd(2),true,iPos ); c1->SaveAs(("~/www/MonoJet/MC-DATA_"+var+"_cat.png").c_str()); c1->SaveAs(("~/www/MonoJet/MC-DATA_"+var+"_cat.pdf").c_str()); c1->cd(1)->SetLogy(); c1->SaveAs(("~/www/MonoJet/MC-DATA_"+var+"_LOG_cat.png").c_str()); c1->SaveAs(("~/www/MonoJet/MC-DATA_"+var+"_LOG_cat.pdf").c_str()); }
//------------------------------------------------------------------------ void DrawLEDminCFD() { Int_t npeaks = 10; Int_t sigma=10.; Bool_t down=false; Int_t index[20]; TCanvas *c1 = new TCanvas("c1", " LED-CFD C side",0,48,1280,951); c1->Divide(4,3); Char_t buf1[20]; for (Int_t i=0; i<12; i++) { c1->cd(i+1); sprintf(buf1,"LEDminCFD%i",i+1); TH1F *cfd = (TH1F*) gFile->Get(buf1); cfd->Draw(); TSpectrum *s = new TSpectrum(2*npeaks,1); Int_t nfound = s->Search(cfd,sigma," ",0.2); cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; if(nfound!=0) { Float_t *xpeak = s->GetPositionX(); TMath::Sort(nfound, xpeak, index,down); Float_t xp = xpeak[index[0]]; Int_t xbin = cfd->GetXaxis()->FindBin(xp); Float_t yp = cfd->GetBinContent(xbin); cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl; Float_t hmin=xp-3*sigma; Float_t hmax =xp+3*sigma; cfd->GetXaxis()->SetRange(hmin,hmax); TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); cfd->Fit("g1","RQ"); } } TCanvas *c2 = new TCanvas("c2", "LED-CFD A side",0,48,1280,951); c2->Divide(4,3); Char_t buf1[20]; for (Int_t i=12; i<24; i++) { c2->cd(i+1-12); sprintf(buf1,"LEDminCFD%i",i+1); TH1F *cfd = (TH1F*) gFile->Get(buf1); cfd->Draw(); TSpectrum *s = new TSpectrum(2*npeaks,1); Int_t nfound = s->Search(cfd,sigma," ",0.2); cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; if(nfound!=0) { Float_t *xpeak = s->GetPositionX(); TMath::Sort(nfound, xpeak, index,down); Float_t xp = xpeak[index[0]]; Int_t xbin = cfd->GetXaxis()->FindBin(xp); Float_t yp = cfd->GetBinContent(xbin); cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl; Float_t hmin=xp-3*sigma; Float_t hmax =xp+3*sigma; cfd->GetXaxis()->SetRange(hmin,hmax); TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); cfd->Fit("g1","RQ"); } } /* TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951); c1->Divide(2,2); Char_t buf1[10]; for (Int_t i=0; i<4; i++) { c1->cd(i+1); sprintf(buf1,"LED-CFD%i",i+1); TH1F *cfd = (TH1F*) file->Get(buf1); // cout<<buf1<<" "<<cfd<<endl; // cfd->Draw(); // cfd->GetXaxis()->SetRange(0,100); Float_t mean = cfd->GetMean(); Float_t rms = cfd->GetRMS(); Float_t hmin=mean - 3*rms; Float_t hmax =mean + 3*rms; cfd->GetXaxis()->SetRange(hmin-10,hmax+10); cout<<" cfd range "<<mean<<" rms "<<rms<<" "<<hmin<<" "<<hmax<<endl; // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); // cfd->Fit("g1","RQ"); cfd->Draw(); } */ }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // drawFigure6 // // logy = 0 // logy = 1 // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void drawFigure6(Int_t logy = 0) { gInterpreter->ExecuteMacro("WZPaperStyle.C"); gSystem->mkdir("pdf", kTRUE); gSystem->mkdir("png", kTRUE); // Read the input file //---------------------------------------------------------------------------- TString name = "WZ_PtZ_plot_allCh_largeATGC"; TFile* file = new TFile("rootfiles/" + name + ".root", "read"); TCanvas* c1 = (TCanvas*)file->Get("c1_allCh"); TH1F* data = (TH1F*)c1->FindObject("histo_data_3e"); TH1F* aTGC_dk = (TH1F*)c1->FindObject("histo_aTGC_dk_3e"); TH1F* aTGC_lam = (TH1F*)c1->FindObject("histo_aTGC_lam_3e"); TH1F* aTGC_dg = (TH1F*)c1->FindObject("histo_aTGC_dg_3e"); TH1F* WZ = (TH1F*)c1->FindObject("histo_SM_3e"); TH1F* fakes = (TH1F*)c1->FindObject("fake_0"); TH1F* ZZ = (TH1F*)c1->FindObject("total_bkg_rebined_ZZ_0"); TH1F* Zgamma = (TH1F*)c1->FindObject("total_bkg_rebined_Zgamma_0"); TH1F* WV = (TH1F*)c1->FindObject("total_bkg_rebined_WV_0"); TH1F* VVV = (TH1F*)c1->FindObject("total_bkg_rebined_VVV_0"); WZ->SetFillColor(kOrange-2); WZ->SetLineColor(kOrange-2); Zgamma->SetFillColor(kRed+1); Zgamma->SetLineColor(kRed+1); ZZ->SetFillColor(kRed+1); ZZ->SetLineColor(kRed+1); fakes->SetFillColor(kGray+1); fakes->SetLineColor(kGray+1); WV->SetFillColor(kRed+1); WV->SetLineColor(kRed+1); VVV->SetFillColor(kRed+1); VVV->SetLineColor(kRed+1); // Draw //---------------------------------------------------------------------------- TCanvas* canvas = new TCanvas("canvas", "canvas"); canvas->SetLogy(logy); data->Draw("ep"); // Axis labels //---------------------------------------------------------------------------- TAxis* xaxis = data->GetXaxis(); TAxis* yaxis = data->GetYaxis(); xaxis->SetLabelFont ( 42); xaxis->SetLabelOffset(0.01); xaxis->SetLabelSize (0.05); xaxis->SetNdivisions ( 505); xaxis->SetTitleFont ( 42); xaxis->SetTitleOffset( 1.2); xaxis->SetTitleSize (0.05); yaxis->SetLabelFont ( 42); yaxis->SetLabelOffset(0.01); yaxis->SetLabelSize (0.05); yaxis->SetNdivisions ( 505); yaxis->SetTitleFont ( 42); yaxis->SetTitleOffset( 1.6); yaxis->SetTitleSize (0.05); xaxis->SetTitle("p_{T}^{Z} (GeV)"); yaxis->SetTitle(Form("Events / %.0f GeV", data->GetBinWidth(0))); // Adjust scale //---------------------------------------------------------------------------- Float_t theMax = GetMaximumIncludingErrors(data); Float_t theMaxMC = GetMaximumIncludingErrors(aTGC_dk); if (theMaxMC > theMax) theMax = theMaxMC; if (canvas->GetLogy()) { data->SetMaximum(15 * theMax); data->SetMinimum(1); } else { data->SetMaximum(1.2 * theMax); } // Legend //---------------------------------------------------------------------------- Double_t x0; Double_t y0; if (logy) { x0 = 0.630; y0 = 0.765; DrawTLegend(x0 - 0.37, y0 + 2.*(_yoffset+0.001), data, " Data", "ep"); DrawTLegend(x0 - 0.37, y0 + 1.*(_yoffset+0.001), aTGC_dk, " WZ aTGC (#Delta#kappa^{Z} = 0.6)", "l"); DrawTLegend(x0 - 0.37, y0, aTGC_dg, " WZ aTGC (#Deltag^{Z}_{1} = -0.06)", "l"); DrawTLegend(x0 - 0.37, y0 - 1.*(_yoffset+0.001), aTGC_lam, " WZ aTGC (#lambda = 0.04)", "l"); DrawTLegend(x0, y0 + 2.*(_yoffset+0.001), WZ, " WZ", "f"); DrawTLegend(x0, y0 + 1.*(_yoffset+0.001), fakes, " Non-prompt leptons", "f"); DrawTLegend(x0, y0, ZZ, " MC background", "f"); } else { x0 = 0.570; y0 = 0.755; DrawTLegend(x0, y0 + 2.*(_yoffset+0.001), data, " Data", "ep"); DrawTLegend(x0, y0 + 1.*(_yoffset+0.001), aTGC_dk, " WZ aTGC (#Delta#kappa^{Z} = 0.6)", "l"); DrawTLegend(x0, y0, aTGC_dg, " WZ aTGC (#Deltag^{Z}_{1} = -0.06)", "l"); DrawTLegend(x0, y0 - 1.*(_yoffset+0.001), aTGC_lam, " WZ aTGC (#lambda = 0.04)", "l"); DrawTLegend(x0, y0 - 2.*(_yoffset+0.001), WZ, " WZ", "f"); DrawTLegend(x0, y0 - 3.*(_yoffset+0.001), fakes, " Non-prompt leptons", "f"); DrawTLegend(x0, y0 - 4.*(_yoffset+0.001), ZZ, " MC background", "f"); } // Finish it //---------------------------------------------------------------------------- data->SetTitle(""); if (logy) { DrawTLatex(_cmsTextFont, 0.190, 0.94, 0.055, 11, "CMS"); // DrawTLatex(_extraTextFont, 0.315, 0.94, 0.030, 11, "Preliminary"); } else { DrawTLatex(_cmsTextFont, 0.215, 0.891, 0.055, 13, "CMS"); // DrawTLatex(_extraTextFont, 0.215, 0.837, 0.030, 13, "Preliminary"); } DrawTLatex(_lumiTextFont, 0.940, 0.94, 0.040, 31, "19.6 fb^{-1} (8 TeV)"); WZ ->Draw("hist,same"); aTGC_dk ->Draw("hist,same"); aTGC_lam->Draw("hist,same"); aTGC_dg ->Draw("hist,same"); fakes ->Draw("hist,same"); ZZ ->Draw("hist,same"); Zgamma ->Draw("hist,same"); WV ->Draw("hist,same"); VVV ->Draw("hist,same"); data ->Draw("ep,same"); canvas->GetFrame()->DrawClone(); canvas->RedrawAxis(); canvas->Update(); TString cname = name; if (logy) cname += "_log_range"; canvas->SaveAs("pdf/" + cname + ".pdf"); canvas->SaveAs("png/" + cname + ".png"); }
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; }
int TrackParametrization( TString csvfile="fitslices_out.csv" ) { /* Read data from input file */ TTree *tres = new TTree(); tres->ReadFile( csvfile, "ptrue:etatrue:psig:psig_err:pmean:pmean_err:norm", ',' ); /* Print read-in tree */ tres->Print(); /* colors array */ unsigned colors[8] = {1,2,3,4,6,7,14,16}; /* Create vector of theta values to include for visualization*/ vector< double > etas_vis; etas_vis.push_back(-2.75); etas_vis.push_back(-2.25); etas_vis.push_back(-1.75); etas_vis.push_back(-0.25); etas_vis.push_back( 0.25); etas_vis.push_back( 1.75); etas_vis.push_back( 2.25); // etas_vis.push_back(-3.25); // etas_vis.push_back(-2.25); // etas_vis.push_back(-1.25); // etas_vis.push_back(-0.25); // etas_vis.push_back( 0.25); // etas_vis.push_back( 1.25); // etas_vis.push_back( 2.25); // etas_vis.push_back( 3.25); /* Create vector of theta values to include for fitting*/ vector< double > etas_fit; for ( double eta = -4.45; eta < 4.5; eta += 0.1 ) etas_fit.push_back( eta ); /* Create fit function */ TF1* f_momres = new TF1("f_momres", "sqrt( [0]*[0] + [1]*[1]*x*x )" ); cout << "\nFit function: " << f_momres->GetTitle() << "\n" << endl; /* Create scratch canvas */ TCanvas *cscratch = new TCanvas("cscratch"); /* Create framehistogram */ TH1F* hframe = new TH1F("hframe","",100,0,40); hframe->GetYaxis()->SetRangeUser(0,0.15); hframe->GetYaxis()->SetNdivisions(505); hframe->GetXaxis()->SetTitle("Momentum (GeV/c)"); hframe->GetYaxis()->SetTitle("#sigma_{p}/p"); /* create combined canvas plot */ TCanvas *c1 = new TCanvas(); hframe->Draw(); /* Create legend */ TLegend* leg_eta = new TLegend( 0.2, 0.6, 0.5, 0.9); leg_eta->SetNColumns(2); /* Create ofstream to write fit parameter results */ ofstream ofsfit("track_momres_new.csv"); ofsfit<<"eta,par1,par1err,par2,par2err"<<endl; /* Create resolution-vs-momentum plot with fits for each selected theta value */ for ( int i = 0; i < etas_fit.size(); i++ ) { /* Switch to scratch canvas */ cscratch->cd(); double eta = etas_fit.at(i); /* No tracking outside -4 < eta < 4 */ if ( eta < -4 || eta > 4 ) continue; cout << "\n***Eta = " << eta << endl; /* Define range of theta because float comparison with fixed value doesn't work too well for cuts in ROOT trees */ double eta_min = eta * 0.999; double eta_max = eta * 1.001; /* Cut for tree */ TCut cutx( Form("ptrue > 1 && ( (etatrue > 0 && (etatrue > %f && etatrue < %f)) || (etatrue < 0 && (etatrue < %f && etatrue > %f)) )", eta_min, eta_max, eta_min, eta_max) ); /* "Draw" tree on scratch canvas to fill V1...V4 arrays */ tres->Draw("psig:ptrue:psig_err:0", cutx ); /* Create TGraphErrors with selected data from tree */ TGraphErrors *gres = new TGraphErrors( tres->GetEntries(cutx), &(tres->GetV2())[0], &(tres->GetV1())[0], &(tres->GetV4())[0], &(tres->GetV3())[0] ); /* reset function parameters before fit */ f_momres->SetParameter(0,0.1); f_momres->SetParameter(1,0.1); /* Only plot pseudorapidities listed on etas_vis; if not plotting, still do the fit */ bool vis = false; int vi = 0; for ( vi = 0; vi < etas_vis.size(); vi++ ) { if ( abs( etas_vis.at(vi) - eta ) < 0.001 ) { vis = true; break; } } if ( vis ) { /* Add graph to legend */ leg_eta->AddEntry(gres, Form("#eta = %.1f", eta), "P"); /* Add graph to plot */ c1->cd(); gres->SetMarkerColor(colors[vi]); gres->Draw("Psame"); f_momres->SetLineColor(colors[vi]); gres->Fit(f_momres); } else { gres->Fit(f_momres); } /* Write fir results to file */ double par1 = f_momres->GetParameter(0); double par1err = f_momres->GetParError(0); double par2 = f_momres->GetParameter(1); double par2err = f_momres->GetParError(1); ofsfit << eta << "," << par1 << "," << par1err << "," << par2 << "," << par2err << endl; } /* Draw legend */ c1->cd(); //TCanvas *c2 = new TCanvas(); //hframe->Draw(); leg_eta->Draw(); /* Print plots */ c1->Print("track_momres_vareta.eps"); //c2->Print("track_momres_vareta_legend.eps"); /* Close output stream */ ofsfit.close(); return 0; }
void DrawBoosted(TString VAR, float XMIN, float XMAX, int REBIN, TString XTITLE) { gROOT->ForceStyle(); const int N = 7; float XSEC[N] = {1.74e+6,3.67e+5,2.94e+4,6.524e+03,1.064e+03,121.5,2.542e+01}; TString SAMPLE[N] = { "QCD_HT200to300", "QCD_HT300to500", "QCD_HT500to700", "QCD_HT700to1000", "QCD_HT1000to1500", "QCD_HT1500to2000", "QCD_HT2000toInf" }; TFile *inf[N]; TH1F *h0[N],*h1[N]; TH1F *hQCD0,*hQCD1; TCanvas *can = new TCanvas("Boosted","Boosted",900,600); can->cd(1); can->SetBottomMargin(0.3); //can->SetRightMargin(0.15); for(int k=0;k<N;k++) { inf[k] = TFile::Open("Histo_"+SAMPLE[k]+".root"); h0[k] = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_ctl"); h0[k]->Sumw2(); h0[k]->Rebin(REBIN); h1[k] = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_sig"); h1[k]->Sumw2(); h1[k]->Rebin(REBIN); h0[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1)); h1[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1)); cout<<SAMPLE[k]<<": "<<h0[k]->GetEntries()<<" "<<h0[k]->Integral()<<endl; if (k == 0) { hQCD0 = (TH1F*)h0[k]->Clone(); hQCD1 = (TH1F*)h1[k]->Clone(); } if (k > 0) { hQCD0->Add(h0[k]); hQCD1->Add(h1[k]); } } hQCD0->Scale(1/hQCD0->Integral()); hQCD1->Scale(1/hQCD1->Integral()); double max1 = TMath::Max(hQCD0->GetBinContent(hQCD0->GetMaximumBin()),hQCD1->GetBinContent(hQCD1->GetMaximumBin())); hQCD0->SetMaximum(1.2*max1); hQCD0->SetMinimum(1e-4); hQCD0->GetXaxis()->SetLabelSize(0.0); hQCD0->GetXaxis()->SetRangeUser(XMIN,XMAX); hQCD0->Draw("HIST"); hQCD1->Draw("sameE"); TLegend *leg = new TLegend(0.6,0.7,0.9,0.9); leg->SetHeader("QCD Closure"); leg->SetBorderSize(0); leg->SetTextFont(42); leg->SetTextSize(0.05); leg->AddEntry(hQCD1,"Signal sample","P"); leg->AddEntry(hQCD0,"Control sample","F"); leg->Draw(); TH1F *hRatio = (TH1F*)hQCD1->Clone("Ratio"); hRatio->Divide(hQCD0); hRatio->SetLineColor(kBlack); hRatio->SetMarkerColor(kBlack); TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.); pad->SetTopMargin(0.7); //pad->SetRightMargin(0.15); pad->SetFillColor(0); pad->SetFillStyle(0); pad->Draw(); pad->cd(0); gPad->SetGridy(); hRatio->GetXaxis()->SetTitle(XTITLE); hRatio->GetXaxis()->SetRangeUser(XMIN,XMAX); hRatio->GetYaxis()->SetNdivisions(505); hRatio->GetYaxis()->SetRangeUser(0,2); hRatio->GetYaxis()->SetLabelSize(0.04); hRatio->Draw(); hRatio->Draw("same"); }
void fractionFit() { char name[1000]; sprintf(name,"/Users/zach/Research/pythia/npeTemplate/outputs/currentB.root"); TFile *fB = new TFile(name,"READ"); sprintf(name,"/Users/zach/Research/pythia/npeTemplate/outputs/currentC.root"); TFile *fC = new TFile(name,"READ"); sprintf(name,"/Users/zach/Research/rootFiles/run12NPEhPhi/currentData.root"); TFile *fD = new TFile(name,"READ"); if (fB->IsOpen()==kFALSE || fC->IsOpen()==kFALSE) { std::cout << "!!!!!! Either B,C, or Data File not found !!!!!!" << std::endl << "Looking for currentB.root, currentC.root, and currentData.root" << std::endl; exit(1); } // Set constants and projection bins const Int_t numPtBins = 10; Float_t lowpt[14] ={2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.5,10.,14.0}; Float_t highpt[14]={3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.5,10.,14.,200.}; Float_t hptCut=0.5; // Make Canvases TCanvas* deltaPhi = new TCanvas("deltaPhi","Pythia Delta Phi",150,0,1150,1000); TCanvas* fitResult0 = new TCanvas("fitResult0","RB Extraction HT0",150,0,1150,1000); // TCanvas* fitResult2 = new TCanvas("fitResult2","RB Extraction HT2",150,0,1150,1000); deltaPhi->Divide(2,2); fitResult0->Divide(4,3); //fitResult2->Divide(4,3); // Make histos TH1D* projB[numPtBins]; TH1D* projC[numPtBins]; TH1D* projData0[numPtBins]; TH1D* projData2[numPtBins]; // Get and Draw histos TPaveText* lbl[numPtBins]; char textLabel[100]; Int_t plotbin; for(Int_t ptbin=0; ptbin<numPtBins; ptbin++) { if(ptbin!=0 && ptbin!=2 && ptbin!=4 && ptbin!=6) continue; if(ptbin==0)plotbin=0; if(ptbin==2)plotbin=1; if(ptbin==4)plotbin=2; if(ptbin==6)plotbin=3; // Init necessary plotting tools lbl[ptbin] = new TPaveText(.2,.76,.5,.82,Form("NB NDC%i",ptbin)); sprintf(textLabel,"%.1f < P_{T,e} < %.1f",lowpt[ptbin],highpt[ptbin]); lbl[ptbin]->AddText(textLabel); lbl[ptbin]->SetFillColor(kWhite); projB[ptbin] = (TH1D*)fB->Get(Form("projDelPhi_%i",ptbin)); projC[ptbin] = (TH1D*)fC->Get(Form("projDelPhi_%i",ptbin)); projData0[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_0_%i",ptbin)); projData2[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_2_%i",ptbin)); Int_t RB = 8; projB[ptbin]->Rebin(RB); projC[ptbin]->Rebin(RB); // Draw Templates on own plots deltaPhi->cd(plotbin+1); projData0[ptbin]->SetLineColor(kBlue); projData2[ptbin]->SetLineColor(kGreen+3); projB[ptbin]->SetLineColor(kRed); projC[ptbin]->SetLineColor(kBlack); // projC[ptbin]->GetYaxis()->SetRangeUser(0.,0.5); projC[ptbin] -> Draw(); projB[ptbin] -> Draw("same"); projData0[ptbin]-> Draw("same"); projData2[ptbin]-> Draw("same"); lbl[ptbin] -> Draw("same"); TLegend* leg = new TLegend(0.5,0.73,0.85,0.85); leg->AddEntry(projB[ptbin],"b#bar{b}->NPE","lpe"); leg->AddEntry(projC[ptbin],"c#bar{c}->NPE","lpe"); leg->AddEntry(projData0[ptbin],"HT0","lpe"); leg->AddEntry(projData2[ptbin],"HT2","lpe"); leg->Draw(); // Do the actual fit TObjArray *mc = new TObjArray(2); // MC histograms are put in this array mc->Add(projC[ptbin]); mc->Add(projB[ptbin]); fitResult0->cd(ptbin+1); TFractionFitter* fit = new TFractionFitter(projData0[ptbin], mc,"V"); // initialise fit->Constrain(1,0.0,1.0); // constrain fraction 1 to be between 0 and 1 fit->SetRangeX(46,56); // use only the first 15 bins in the fit Int_t status = fit->Fit(); // perform the fit std::cout << "fit status: " << status << std::endl; if (status == 0) { // check on fit status TH1F* result = (TH1F*) fit->GetPlot(); projData0[ptbin]->Draw("Ep"); result->Draw("same"); } /* fitResult2->cd(ptbin+1); TFractionFitter* fit2 = new TFractionFitter(projData2[ptbin], mc); // initialise fit2->Constrain(0,0.0,1.0); // constrain fraction 0 fit2->Constrain(1,0.0,1.0); // constrain fraction 1 to be between 0 and 1 fit2->SetRangeX(23,29); // use only the first 15 bins in the fit Int_t status2 = fit2->Fit(); // perform the fit std::cout << "fit status: " << status2 << std::endl; if (status2 == 0) { // check on fit status TH1F* result2 = (TH1F*) fit2->GetPlot(); projData2[ptbin]->Draw("Ep"); result2->Draw("same"); }*/ } }
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 msquared() { double yPos, xPos, theta, energy = 0.; // NOTE: theta comes in degrees int numHit, pID = 0; // Initialize histograms double nEnergyMin = 10; // MeV double nEnergyMax = 510; // MeV int nEnergyBins = 50; double dEnergyBinSize = (double)(nEnergyMax - nEnergyMin) / (double)nEnergyBins; double nThetaMin = 34; // mrad double nThetaMax = 88; // mrad int nThetaBins = 50; double dThetaBinSize = (nThetaMax - nThetaMin) / nThetaBins; double nM2Min = -5000; // MeV double nM2Max = 5000; // MeV int nM2Bins = 100; double dM2BinSize = (nM2Max - nM2Min)/nM2Bins; THStack *hs = new THStack("hs","Stacked M^2"); TFile* file = new TFile("e+e-2yyGUN.root"); TTree* Hits_Info = (TTree *)file->Get("Signal"); Hits_Info->SetBranchAddress("numHits", &numHit); Hits_Info->SetBranchAddress("energyTot", &energy); Hits_Info->SetBranchAddress("XPosition", &xPos); Hits_Info->SetBranchAddress("YPosition", &yPos); Hits_Info->SetBranchAddress("Particle_ID", &pID); Hits_Info->SetBranchAddress("Theta", &theta); TH1D* hmyy = new TH1D("M_{A'}^{2}" , // plot label "e+e- > yy", // title nM2Bins, // x number of bins nM2Min, // x lower bound nM2Max); // x upper bound // go through all entries and fill the histograms int nentries = Hits_Info->GetEntries(); for (int i=0; i<nentries; i++) { Hits_Info->GetEntry(i); if (pID == 22) { // gammas only theta*= TMath::Pi()/180; //radians cout << "M^2 is: " << mSquared(energy, theta) << endl; cout << "Energy is: " << energy << endl; hmyy->Fill(mSquared(energy, theta), XSECyy * BINNING_WEIGHT / dM2BinSize); } } cout << "DM2binsize is:" << dM2BinSize << endl; hmyy->SetFillColor(kBlue); hmyy->SetFillStyle(3001); hmyy->GetXaxis()->SetTitle("M_{A'}^{2} (MeV^{2})"); hmyy->GetYaxis()->SetTitle("Photons per MeV^{2} per Second (MeV^{-2} s^{-1})"); hmyy->GetXaxis()->CenterTitle(); hmyy->GetYaxis()->CenterTitle(); TFile* fileyyy = new TFile("e+e-2yyyGUN.root"); TTree* Hits_Infoyyy = (TTree *)fileyyy->Get("Signal"); Hits_Infoyyy->SetBranchAddress("numHits", &numHit); Hits_Infoyyy->SetBranchAddress("energyTot", &energy); Hits_Infoyyy->SetBranchAddress("XPosition", &xPos); Hits_Infoyyy->SetBranchAddress("YPosition", &yPos); Hits_Infoyyy->SetBranchAddress("Particle_ID", &pID); Hits_Infoyyy->SetBranchAddress("Theta", &theta); TH1D* hmyyy = new TH1D("M_{A'}^{2}" , // plot label "e+e- > yyy", // title nM2Bins, // x number of bins nM2Min, // x lower bound nM2Max); // x upper bound // go through all entries and fill the histograms nentries = Hits_Infoyyy->GetEntries(); for (int i=0; i<nentries; i++) { Hits_Infoyyy->GetEntry(i); if (pID == 22) { // gammas only theta*= TMath::Pi()/180; //radians cout << "M^2 is: " << mSquared(energy, theta) << endl; cout << "Energy is: " << energy << endl; hmyyy->Fill(mSquared(energy, theta), XSECyyy * BINNING_WEIGHT / dM2BinSize); } } cout << "DM2binsize is:" << dM2BinSize << endl; hmyyy->SetFillColor(kRed); hmyyy->SetFillStyle(3001); hmyyy->GetXaxis()->SetTitle("M_{A'}^{2} (MeV^{2})"); hmyyy->GetYaxis()->SetTitle("Photons per MeV^{2} per Second (MeV^{-2} s^{-1})"); hmyyy->GetXaxis()->CenterTitle(); hmyyy->GetYaxis()->CenterTitle(); TFile* fileepluseminusy = new TFile("e+e-2e+e-yECUT0.3NOPT_2_5_1000000.root"); //This is 1000000 events so DOWNEIGHT IT: XSECepluseminusy = 0.1 * XSECepluseminusy; TTree* Hits_Infoepluseminusy = (TTree *)fileepluseminusy->Get("Signal"); Hits_Infoepluseminusy->SetBranchAddress("numHits", &numHit); Hits_Infoepluseminusy->SetBranchAddress("energyTot", &energy); Hits_Infoepluseminusy->SetBranchAddress("XPosition", &xPos); Hits_Infoepluseminusy->SetBranchAddress("YPosition", &yPos); Hits_Infoepluseminusy->SetBranchAddress("Particle_ID", &pID); Hits_Infoepluseminusy->SetBranchAddress("Theta", &theta); TH1D* hmepluseminusy = new TH1D("M_{A'}^{2}" , // plot label "e+e- > e+e-y (only registering gammas)", // title nM2Bins, // x number of bins nM2Min, // x lower bound nM2Max); // x upper bound // go through all entries and fill the histograms nentries = Hits_Infoepluseminusy->GetEntries(); for (int i=0; i<nentries; i++) { Hits_Infoepluseminusy->GetEntry(i); if (pID == 22) { // gammas only theta*= TMath::Pi()/180; //radians cout << "M^2 is: " << mSquared(energy, theta) << endl; cout << "Energy is: " << energy << endl; hmepluseminusy->Fill(mSquared(energy, theta), XSECepluseminusy * BINNING_WEIGHT / dM2BinSize); } } cout << "DM2binsize is:" << dM2BinSize << endl; hmepluseminusy->SetFillColor(7); hmepluseminusy->SetFillStyle(3001); hmepluseminusy->GetXaxis()->SetTitle("M_{A'}^{2} (MeV^{2})"); hmepluseminusy->GetYaxis()->SetTitle("Photons per MeV^{2} per Second (MeV^{-2} s^{-1})"); hmepluseminusy->GetXaxis()->CenterTitle(); hmepluseminusy->GetYaxis()->CenterTitle(); //ADD YIMIN'S PLOT TFile *f = new TFile("YIMINPLOTBREM.root"); f->ls(); TH1F * hYIMIN = (TH1F*)f->Get("M^2"); hYIMIN->SetFillColor(kOrange); hYIMIN->SetTitle("Bremsstrahlung"); hYIMIN->SetFillStyle(3001); hYIMIN->GetXaxis()->SetTitle("M_{A'}^{2} (MeV^{2})"); hYIMIN->GetYaxis()->SetTitle("Photons per MeV^{2} per Second (MeV^{-2} s^{-1})"); hYIMIN->GetXaxis()->CenterTitle(); hYIMIN->GetYaxis()->CenterTitle(); /********************** ADD BRIANS PLOT ********************/ NUM_TOT_POSITRONS = 1e+07; BIAS = 1e+04; BINNING_WEIGHT = POSITRONS_PER_SEC/(BIAS*NUM_TOT_POSITRONS); B = pow(1-pow(GAMMA_PLUS, -2.), .5); TFile* fileinelastic = new TFile("brian_1e7_pos_1e4_bias.root"); TTree* Hits_Infoinelastic = (TTree *)fileinelastic->Get("Signal"); Hits_Infoinelastic->SetBranchAddress("numHits", &numHit); Hits_Infoinelastic->SetBranchAddress("energyTot", &energy); Hits_Infoinelastic->SetBranchAddress("XPosition", &xPos); Hits_Infoinelastic->SetBranchAddress("YPosition", &yPos); Hits_Infoinelastic->SetBranchAddress("Particle_ID", &pID); Hits_Infoinelastic->SetBranchAddress("Theta", &theta); TH1D* hminelastic = new TH1D("M_{A'}^{2}" , // plot label "Inelastic (only registering gammas)", // title nM2Bins, // x number of bins nM2Min, // x lower bound nM2Max); // x upper bound // go through all entries and fill the histograms nentries = Hits_Infoinelastic->GetEntries(); for (int i=0; i<nentries; i++) { Hits_Infoinelastic->GetEntry(i); if (pID == 22) { // gammas only theta*= TMath::Pi()/180; //radians cout << "M^2 is: " << mSquared(energy, theta) << endl; cout << "Energy is: " << energy << endl; hminelastic->Fill(mSquared(energy, theta), BINNING_WEIGHT / dM2BinSize); } } cout << "DM2binsize is:" << dM2BinSize << endl; hminelastic->SetFillColor(kGreen); hminelastic->SetFillStyle(3001); hminelastic->GetXaxis()->SetTitle("M_{A'}^{2} (MeV^{2})"); hminelastic->GetYaxis()->SetTitle("Photons per MeV^{2} per Second (MeV^{-2} s^{-1})"); hminelastic->GetXaxis()->CenterTitle(); hminelastic->GetYaxis()->CenterTitle(); hs->Add(hminelastic); hs->Add(hYIMIN); hs->Add(hmyyy); hs->Add(hmepluseminusy); hs->Add(hmyy); // create canvas and draw histogram TCanvas* canvas = new TCanvas("canvas", "canvas", 700, 700); canvas->Divide(3,2); TPad* p; p = (TPad*)canvas->cd(1); //p->SetGrid(); p->SetLogy(); hs->Draw(); hs->GetXaxis()->SetTitle("M_{A'}^{2} (MeV^{2})"); hs->GetYaxis()->SetTitle("Photons per MeV^{2} per Second (MeV^{-2} s^{-1})"); hs->GetXaxis()->CenterTitle(); hs->GetYaxis()->CenterTitle(); p = (TPad*)canvas->cd(4); hmepluseminusy->Draw(); p = (TPad*)canvas->cd(3); hmyyy->Draw(); p = (TPad*)canvas->cd(2); hmyy->Draw(); p = (TPad*)canvas->cd(5); hYIMIN->Draw(); p = (TPad*)canvas->cd(6); hminelastic->Draw(); /* p = (TPad*)canvas->cd(4); p->SetLogy(); p->SetGrid(); hm2->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 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; }
void met_cuts(double pt1min, double pt2min, double METmin, int jets, int DataFlag){ TLegend* leg = new TLegend(0.5,0.72,0.89,0.89); leg->SetNColumns(2); TCanvas *canvas = new TCanvas("c1n","",500,500); gPad->SetLogy(); TCut mggmax = "mgg<200"; TCut mggmin = "mgg>100"; TCut pt1Cut = Form("pt1>%lf",pt1min); TCut pt2Cut = Form("pt2>%lf",pt2min); TCut METCut = Form("t1pfmet>%lf",METmin); TCut eveto1 = "eleveto1 == 1"; TCut eveto2 = "eleveto2 == 1"; TCut eveto = eveto1 && eveto2; TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))"; TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))"; TCut Cut_Jets = Form("nJets<%d",jets); /* TFile *M1 = TFile::Open("./50ns_betaV4/NewWeightDMHtoGG_M1.root","READ"); TFile *M10 = TFile::Open("./50ns_betaV4/NewWeightDMHtoGG_M10.root","READ"); TFile *M100 = TFile::Open("./50ns_betaV4/NewWeightDMHtoGG_M100.root","READ"); TFile *M1000 = TFile::Open("./50ns_betaV4/NewWeightDMHtoGG_M1000.root","READ"); */ TFile *data = TFile::Open("./25ns_2246inv/DoubleEG.root","READ"); TFile *sig1 = TFile::Open("./25ns_2246inv/2HDM_mZP600.root","READ"); TFile *sig2 = TFile::Open("./25ns_2246inv/2HDM_mZP800.root","READ"); TFile *sig3 = TFile::Open("./25ns_2246inv/2HDM_mZP1000.root","READ"); TFile *sig4 = TFile::Open("./25ns_2246inv/2HDM_mZP1200.root","READ"); TFile *sig5 = TFile::Open("./25ns_2246inv/2HDM_mZP1400.root","READ"); /* TFile *bkg1 = TFile::Open("./50ns_betaV4/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./50ns_betaV4/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./50ns_betaV4/GJets.root","READ"); TFile *bkg4 = TFile::Open("./50ns_betaV4/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./50ns_betaV4/QCD.root","READ"); TFile *bkg6 = TFile::Open("./50ns_betaV4/VH.root","READ"); */ TFile *bkg1 = TFile::Open("./25ns_2246inv/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./25ns_2246inv/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./25ns_2246inv/GJets.root","READ"); TFile *bkg4 = TFile::Open("./25ns_2246inv/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./25ns_2246inv/QCD.root","READ"); TFile *bkg6 = TFile::Open("./25ns_2246inv/VH.root","READ"); /* TTree *tree_M1 = (TTree*) M1->Get("DiPhotonTree"); TTree *tree_M10 = (TTree*) M10->Get("DiPhotonTree"); TTree *tree_M100 = (TTree*) M100->Get("DiPhotonTree"); TTree *tree_M1000 = (TTree*) M1000->Get("DiPhotonTree"); */ TTree *tree_data = (TTree*) data->Get("DiPhotonTree"); TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree"); TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree"); TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree"); TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree"); TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree"); TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree"); /* tree_M1->Draw("(t1pfmet)>>h1(30,100,200)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_M10->Draw("(t1pfmet)>>h2(30,100,200)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_M100->Draw("(t1pfmet)>>h3(30,100,200)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_M1000->Draw("(t1pfmet)>>h4(30,100,200)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); */ tree_data->Draw("(t1pfmet)>>hdata(60,0,900)",(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets && metF)); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); tree_sig1->Draw("(t1pfmet)>>h1(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("(t1pfmet)>>h2(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("(t1pfmet)>>h3(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("(t1pfmet)>>h4(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("(t1pfmet)>>h5(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); h1->Scale(0.00009338); h2->Scale(0.00010348); h3->Scale(0.00008394); h4->Scale(0.00006352); h5->Scale(0.00004712); tree_bkg1->Draw("(t1pfmet)>>hbkg1(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("(t1pfmet)>>hbkg2(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("(t1pfmet)>>hbkg3(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets && genmatch)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("(t1pfmet)>>hbkg4(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("(t1pfmet)>>hbkg5(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets && genmatch)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("(t1pfmet)>>hbkg6(60,0,900)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); double DeltaN = 0; double DeltaS1 = 0; double DeltaS2 = 0; double DeltaS3 = 0; double DeltaS4 = 0; double DeltaS5 = 0; double DeltaF1 = 0; double DeltaF2 = 0; double DeltaF3 = 0; double DeltaF4 = 0; double DeltaF5 = 0; double DeltaF6 = 0; double DeltaNi = 0; double DeltaS1i= 0; double DeltaS2i= 0; double DeltaS3i= 0; double DeltaS4i= 0; double DeltaS5i= 0; double DeltaF1i= 0; double DeltaF2i= 0; double DeltaF3i = 0; double DeltaF4i = 0; double DeltaF5i = 0; double DeltaF6i = 0; for(i=0; i<60; i++){ DeltaNi=hdata->GetBinError(i); DeltaS1i=h1->GetBinError(i); DeltaS2i=h2->GetBinError(i); DeltaS3i=h3->GetBinError(i); DeltaS4i=h4->GetBinError(i); DeltaS5i=h5->GetBinError(i); DeltaF1i=hbkg1->GetBinError(i); DeltaF2i= hbkg2->GetBinError(i); DeltaF3i= hbkg3->GetBinError(i); DeltaF4i= hbkg4->GetBinError(i); DeltaF5i= hbkg5->GetBinError(i); DeltaF6i= hbkg6->GetBinError(i); DeltaN += pow(DeltaNi,2); DeltaS1 += pow(DeltaS1i,2); DeltaS2 += pow(DeltaS2i,2); DeltaS3 += pow(DeltaS3i,2); DeltaS4 += pow(DeltaS4i,2); DeltaS5 += pow(DeltaS5i,2); DeltaF1 += pow(DeltaF1i,2); DeltaF2 += pow(DeltaF2i,2); DeltaF3 += pow(DeltaF3i,2); DeltaF4 += pow(DeltaF4i,2); DeltaF5 += pow(DeltaF5i,2); DeltaF6 += pow(DeltaF6i,2); } DeltaN = sqrt(DeltaN); DeltaS1 = sqrt(DeltaS1); DeltaS2 = sqrt(DeltaS2); DeltaS3 = sqrt(DeltaS3); DeltaS4 = sqrt(DeltaS4); DeltaS5 = sqrt(DeltaS5); DeltaF1 = sqrt(DeltaF1); DeltaF2 = sqrt(DeltaF2); DeltaF3 = sqrt(DeltaF3); DeltaF4 = sqrt(DeltaF4); DeltaF5 = sqrt(DeltaF5); DeltaF6 = sqrt(DeltaF6); double Ndata= hdata->Integral(); cout<<"Ndata= "<<Ndata<<" +/- "<<DeltaN<<endl; double S1= h1->Integral(); double S2= h2->Integral(); double S3= h3->Integral(); double S4= h4->Integral(); double S5= h5->Integral(); cout<<"S1= "<<S1<<" +/- "<<DeltaS1<<endl; cout<<"S2= "<<S2<<" +/- "<<DeltaS2<<endl; cout<<"S3= "<<S3<<" +/- "<<DeltaS3<<endl; cout<<"S4= "<<S4<<" +/- "<<DeltaS4<<endl; cout<<"S5= "<<S5<<" +/- "<<DeltaS5<<endl; double DiPho = hbkg1->Integral(); cout<<"diphoton = "<<DiPho<<" +/- "<<DeltaF1<<endl; double DY = hbkg2->Integral(); cout<<"DY = "<<DY<<" +/- "<<DeltaF2<<endl; double GJ = hbkg3->Integral(); cout<<"GJ = "<<GJ<<" +/- "<<DeltaF3<<endl; double GluGlu = hbkg4->Integral(); cout<<"GluGlu = "<<GluGlu<<" +/- "<<DeltaF4<<endl; double QCD = hbkg5->Integral(); cout<<"QCD = "<<QCD<<" +/- "<<DeltaF5<<endl; double VHiggs = hbkg6->Integral(); cout<<"VH = "<<VHiggs<<" +/- "<<DeltaF6<<endl; h1->SetLineColor(kRed-4); h2->SetLineColor(kRed+2); h3->SetLineColor(kPink+2); h4->SetLineColor(kPink+4); h5->SetLineColor(kMagenta+2); //only for 25ns samples h1->SetLineWidth(2); h2->SetLineWidth(2); h3->SetLineWidth(2); h4->SetLineWidth(2); h5->SetLineWidth(2); //only for 25ns samples THStack *hs=new THStack("hs",""); hbkg6->SetFillColor(kGreen+3); hbkg4->SetFillColor(kGreen+4); hbkg1->SetFillColor(kBlue); hbkg2->SetFillColor(kBlue+2); hbkg3->SetFillColor(kMagenta+4); hbkg5->SetFillColor(kMagenta+2); hbkg1->SetLineColor(kBlack); hbkg2->SetLineColor(kBlack); hbkg3->SetLineColor(kBlack); hbkg4->SetLineColor(kBlack); hbkg5->SetLineColor(kBlack); hbkg6->SetLineColor(kBlack); hs->Add(hbkg6); hs->Add(hbkg4); hs->Add(hbkg1); hs->Add(hbkg2); hs->Add(hbkg3); hs->Add(hbkg5); TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); hsum->Add(hbkg2); hsum->Add(hbkg3); hsum->Add(hbkg4); hsum->Add(hbkg5); hsum->Add(hbkg6); hs->SetMinimum(0.001); hs->SetMaximum(5000); hs->SetTitle(""); hs->Draw("HIST"); hsum->SetMarkerStyle(1); hsum->SetFillColor(kGray+3); hsum->SetFillStyle(3001); hsum->Draw("same e2"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h1->Draw("same hist"); h5->Draw("same hist"); //only for 25ns samples if(DataFlag==1){ hdata->Draw("same E1"); } hs->GetXaxis()->SetTitle("MET [GeV]"); hs->GetYaxis()->SetTitleOffset(1.2); hs->GetYaxis()->SetTitle("Events/15 GeV"); gPad->Modified(); /*leg->AddEntry(h1,"m_{#chi} = 1 GeV","l"); leg->AddEntry(h2,"m_{#chi} = 10 GeV","l"); leg->AddEntry(h3,"m_{#chi} = 100 GeV","l"); leg->AddEntry(h4,"m_{#chi} = 1000 GeV","l");*/ leg->AddEntry(h1,"m_{Z'} = 600 GeV","l"); leg->AddEntry(hbkg1,"#gamma #gamma","f"); leg->AddEntry(h2,"m_{Z'} = 800 GeV","l"); leg->AddEntry(hbkg2,"Drell Yann","f"); leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); leg->AddEntry(hbkg3,"#gamma + Jets","f"); leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); leg->AddEntry(hbkg4,"ggH","f"); leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg5,"QCD","f"); leg->AddEntry(hbkg6,"VH","f"); leg->Draw("same"); gStyle->SetOptStat(0); /* if(jets<3){ canvas->SaveAs(Form("met_cuts_M%d_%djets.pdf",sigMass,(jets-1))); canvas->SaveAs(Form("met_cuts_M%d_%djets.png",sigMass,(jets-1))); }else{ canvas->SaveAs(Form("met_cuts_M%d_noJetsCut.pdf",sigMass)); canvas->SaveAs(Form("met_cuts_M%d_noJetsCut.png",sigMass)); }*/ }
int rdEztFeePed( int nEve=3000, Int_t nFiles = 20, char* file="R5135068ezB.lis", char* inDir = "../oldPanitkin/muDst/", TString outPath="feePed4/" ){ // file="st_physics_6008023_raw_1030001.MuDst.root";// pedestal, 1987eve file="st_physics_6008016_raw_1020001.MuDst.root";// commisCu, ~20Keve // inDir = "./"; gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C"); loadSharedLibraries(); cout << " loading done " << endl; assert( !gSystem->Load("StEEmcPoolmuEztFeePed")); // assert( !gSystem->Load("StEEmcUtil")); // create chain chain = new StChain("StChain"); printf("adding muDst from '%s' ....\n",file); // Now we add Makers to the chain... muMk = new StMuDstMaker(0,0,inDir,file,"MuDst.root",nFiles); TChain* tree=muMk->chain(); assert(tree); int nEntries=tree->GetEntries(); printf("total eve in chain =%d\n",nEntries); printf("in=%s%s=\n",inDir,file); //return; HList=new TObjArray; myMk3=new StFeePedMaker("eeFeePed","MuDst"); myMk3->SetHList(HList); gMessMgr->SwitchOff("D"); gMessMgr->SwitchOn("I"); muMk->SetStatus("*",0); muMk->SetStatus("EztAll",1); chain->Init(); chain->ls(3); // muMk->printArrays(); printf("All Ezt-branches set\n"); int eventCounter=0; int stat=0; int t1=time(0); StMuTimer timer; timer.start(); //--------------------------------------------------- while ( 1) {// loop over events if(eventCounter>=nEve) break; eventCounter++; chain->Clear(); stat = chain->Make(); if(stat) break; if(eventCounter%1000!=0)continue; printf("\n\n ====================%d processing ==============\n", eventCounter); } printf("sorting done, nEve=%d of %d\n",nEve, nEntries); int t2=time(0); if(t1==t2) t2++; float rate=1.*eventCounter/(t2-t1); float nMnts=(t2-t1)/60.; printf("sorting done %d of nEve=%d, elapsed rate=%.1f Hz, tot %.1f minutes\n",eventCounter,nEntries,rate,nMnts); if (eventCounter) { cout << "CPU time/event= " << timer.elapsedTime()/eventCounter << " sec " << " rate= " << eventCounter/timer.elapsedTime() << " Hz" << endl; } //-------------------- calculate FEE peds & produce output files ------ printf("name Nentries chi2 gaus_ampl gaus_mean gaus_sig err_ampl err_mean err_sig \n"); TIterator* iter = HList->MakeIterator(); TH1F* h; char oName[100]; FILE *fo; oName[0]=0; int nPed=0; TString fName=outPath+"eemcPed4.dat"; FILE *fo2=fopen(fName.Data(),"w"); while((h=(TH1F*)iter->Next())) { char *txt=h->GetName(); int cr=atoi(txt+2); int chan=atoi(txt+6); int ped4=0; if(chan%32==0) { if(oName[0]) fclose(fo); sprintf(oName,"%scrate%dboard%d.ped4",outPath.Data(),cr, 1+chan/32); FILE *fo=fopen(oName,"w"); if(fo==0) { printf("\n\nDid you created dir=%s ??? ,JB\n\n",outPath.Data()); printf("ABORT macro\n"); assert(fo); } printf(" write to '%s'\n",oName); } int ret=-1; // Fit range max -low, max+high, default: max-5, max+4 if(cr==4 && chan==127) ret=myMk3->fitPed(h,20); // just example else ret=myMk3->fitPed(h); if (ret) { printf("%s empty\n",h->GetName()); fprintf(fo2," %d %3d 5000 %d\n",cr,chan,ped4); fprintf(fo," %d\n",ped4); continue; } TF1* fit= h->GetFunction("pedFun"); assert(fit); nPed++; // fit->Print(); return; float ped=fit->GetParameter(1); int ped4=(25-ped)/4; if(ped>24) ped4=(22-ped)/4; fprintf(fo2,"%d %d %.1f %d\n",cr,chan,ped,ped4); fprintf(fo,"%d\n",ped4); printf("%s %8.0f %8.3f %9.3f %8.2f %7.2f %6.2f %7.2f %6.2f\n", h->GetName(), h->GetEntries(), fit->GetChisquare(), fit->GetParameter(0), fit->GetParameter(1), // pedestal centroid fit->GetParameter(2), // sigma of gaussian fit->GetParError(0), fit->GetParError(1), fit->GetParError(2)); // break; } myMk3->saveHisto(outPath+"feePed"); fclose(fo2); fclose(fo); printf("Fit found %d pedestals\n",nPed); // h=(TH1F*)HList->FindObject("cr5_ch095"); // this is 'stuck bit' channel h=(TH1F*)HList->FindObject("cr5_ch094"); // a regular channel h->Draw(); gPad->SetLogy(); }
void select_pgs() { gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetLineWidth(2); Float_t bins[5] = {500, 700, 1100, 1600, 2000}; // TH1 *histMjjNoMatching = new TH1F("mjj_no_matching", "m_jj", 10, 0.0, 1000.); // TH1 *histMjjMatching = new TH1F("mjj_matching", "m_jj", 10, 0.0, 1000.); // TH1 *histMjjNoMatchingDown = new TH1F("mjj_no_matching_down", "m_jj", 10, 0.0, 1000.); // TH1 *histMjjNoMatchingUp = new TH1F("mjj_no_matching_up", "m_jj", 10, 0.0, 1000.); // TH1 *histMjjMatchingDown = new TH1F("mjj_matching_down", "m_jj", 10, 0.0, 1000.); // TH1 *histMjjMatchingUp = new TH1F("mjj_matching_up", "m_jj", 10, 0.0, 1000.); TH1F *histMjjNoMatching = new TH1F("mjj_no_matching", "m_jj", 4, bins); TH1F *histMjjMatching = new TH1F("mjj_matching", "m_jj", 4, bins); TH1F *histMjjNoMatchingDown = new TH1F("mjj_no_matching_down", "m_jj", 4, bins); TH1F *histMjjNoMatchingUp = new TH1F("mjj_no_matching_up", "m_jj", 4, bins); TH1F *histMjjMatchingDown = new TH1F("mjj_matching_down", "m_jj", 4, bins); TH1F *histMjjMatchingUp = new TH1F("mjj_matching_up", "m_jj", 4, bins); fillHistogram(histMjjMatching, "/scratch3/anlevin/MG5_aMC_v2_0_0/ww_qed_4_qcd_99_pythia_matching/Events/run_01/tag_1_pgs_events.root",0.0215); fillHistogram(histMjjMatchingUp, "/scratch3/anlevin/MG5_aMC_v2_0_0/ww_qed_4_qcd_99_pythia_matching_up/Events/run_01/tag_1_pgs_events.root",0.01852); fillHistogram(histMjjMatchingDown, "/scratch3/anlevin/MG5_aMC_v2_0_0/ww_qed_4_qcd_99_pythia_matching_down/Events/run_01/tag_1_pgs_events.root",0.02547); fillHistogram(histMjjNoMatching, "/scratch3/anlevin/MG5_aMC_v2_0_0/ww_qed_4_qcd_99_pythia_no_matching/Events/run_01/tag_1_pgs_events.root",0.01625); fillHistogram(histMjjNoMatchingUp,"/scratch3/anlevin/MG5_aMC_v2_0_0/ww_qed_4_qcd_99_pythia_no_matching_up/Events/run_01/tag_1_pgs_events.root",0.01386); fillHistogram(histMjjNoMatchingDown, "/scratch3/anlevin/MG5_aMC_v2_0_0/ww_qed_4_qcd_99_pythia_no_matching_down/Events/run_01/tag_1_pgs_events.root",0.01939 ); histMjjNoMatching->SetLineColor(kBlack); histMjjMatching->SetLineColor(kBlue); histMjjNoMatchingDown->SetLineColor(kBlack); histMjjNoMatchingUp->SetLineColor(kBlack); histMjjMatchingDown->SetLineColor(kBlue); histMjjMatchingUp->SetLineColor(kBlue); histMjjNoMatching->SetLineWidth(2); histMjjMatching->SetLineWidth(2); histMjjNoMatchingDown->SetLineWidth(2); histMjjNoMatchingUp->SetLineWidth(2); histMjjMatchingDown->SetLineWidth(2); histMjjMatchingUp->SetLineWidth(2); histMjjMatchingDown->SetMinimum(0); histMjjMatchingDown->GetXaxis()->SetTitle("m_{jj} (GeV)"); histMjjMatchingDown->Draw("E"); histMjjNoMatchingDown->Draw("ESAME"); histMjjNoMatchingUp->Draw("ESAME"); histMjjNoMatching->Draw("ESAME"); histMjjMatching->Draw("ESAME"); histMjjMatchingUp->Draw("ESAME"); TLegend *legend = new TLegend(0.532,0.64,0.874,0.86); legend->AddEntry(histMjjMatching,"with matching","L"); legend->AddEntry(histMjjNoMatching,"without matching","L"); legend->SetFillStyle(0); legend->Draw("SAME"); }
void plot_1411() { gROOT->Reset(); gStyle->SetOptStat(0); gStyle->SetTitleOffset(1.,"Y"); gStyle->SetTitleOffset(.7,"X"); gStyle->SetLabelSize(0.04,"XY"); gStyle->SetTitleSize(0.06,"XY"); gStyle->SetPadLeftMargin(0.12); TFile *fsimc = new TFile("rootfiles/shms_20cmtarg_20deg_wc_mscat.root"); TTree *tsimc = (TTree*)fsimc->Get("h1411"); //Declaration of leaves types Float_t hsxfp; // position at focal plane ,+X is pointing down Float_t hsyfp; // X x Y = Z so +Y pointing central ray left Float_t hsxpfp; // dx/dz at focal plane Float_t hsypfp; // dy/dz at focal plane Float_t hsztari; // thrown position along the beam direction Float_t hsytari; //thrown horizontal position X x Y = Z so +Y pointing central ray left at plane perpendicular to SHMS at z=0 Float_t hsdeltai; // thrown 100*(p - pc)/pc with pc = central SHMS momentum Float_t hsyptari; // thrown target dy/dz horizontal slope Float_t hsxptari; // thrown target dx/dz vertical slope Float_t hsztar; // reconstructed position along the beam directio Float_t hsytar; //reconstructed horizontal position Float_t hsdelta;//reconstructed Float_t hsyptar;//reconstructed Float_t hsxptar;//reconstructed Float_t hsxtari;// from thrown kinematics , the calculated vertical position at plane perpendicular to SHMS at z=0 Float_t yrast;// vertical raster position // Set branch addresses. tsimc->SetBranchAddress("hsxfp",&hsxfp); tsimc->SetBranchAddress("hsyfp",&hsyfp); tsimc->SetBranchAddress("hsxpfp",&hsxpfp); tsimc->SetBranchAddress("hsypfp",&hsypfp); tsimc->SetBranchAddress("hsztari",&hsztari); tsimc->SetBranchAddress("hsytari",&hsytari); tsimc->SetBranchAddress("hsdeltai",&hsdeltai); tsimc->SetBranchAddress("hsyptari",&hsyptari); tsimc->SetBranchAddress("hsxptari",&hsxptari); tsimc->SetBranchAddress("hsztar",&hsztar); tsimc->SetBranchAddress("hsytar",&hsytar); tsimc->SetBranchAddress("hsdelta",&hsdelta); tsimc->SetBranchAddress("hsyptar",&hsyptar); tsimc->SetBranchAddress("hsxptar",&hsxptar); tsimc->SetBranchAddress("hsxtari",&hsxtari); // TH1F *hxptari = new TH1F("hxptari",";Initial xptar ",100,-.1,.1); TH1F *hxptarf = new TH1F("hxptarf",";Recon xptar ",100,-.1,.1); TH1F *difxptar = new TH1F("difxptar",";Xptar diff (mr) ",50,-5,5.); TH2F *difxptarVxptari = new TH2F("difxptarVxptari",";Init xptar (rad);Xptar diff (mr)",25,-.05,.05,50,-5,5.); TH2F *difxptarVyptari = new TH2F("difxptarVyptari",";Init yptar (rad);Xptar diff (mr)",30,-.03,.03,50,-5,5.); TH2F *difxptarVxfp = new TH2F("difxptarVxfp",";xfp (cm);Xptar diff (mr)",100,-40.,40.,50,-5,5.); TH2F *difxptarVyfp = new TH2F("difxptarVyfp",";yfp (cm);Xptar diff (mr)",100,-30.,30.,50,-5,5.); TH2F *difxptarVxpfp = new TH2F("difxptarVxpfp",";xpfp (cm);Xptar diff (mr)",100,-.1,.1,50,-5,5.); TH2F *difxptarVypfp = new TH2F("difxptarVypfp",";ypfp (cm);Xptar diff (mr)",100,-.05,.05,50,-5,5.); TH2F *difxptarVdeltai = new TH2F("difxptarVdeltai",";Init delta ;Xptar diff (mr)",16,-.1,.22,50,-5,5.); TH1F *hyptari = new TH1F("hyptari",";Initial yptar ",100,-.05,.05); TH1F *hyptarf = new TH1F("hyptarf",";Recon yptar ",100,-.05,.05); // TH1F *difyptar = new TH1F("difyptar",";Yptar diff (mr) ",50,-5,5.); TH2F *difyptarVxptari = new TH2F("difyptarVxptari",";Init xptar (rad);Yptar diff (mr)",25,-.05,.05,50,-5,5.); TH2F *difyptarVyptari = new TH2F("difyptarVyptari",";Init yptar (rad);Yptar diff (mr)",30,-.03,.03,50,-5,5.); TH2F *difyptarVxfp = new TH2F("difyptarVxfp",";xfp (cm);Yptar diff (mr)",100,-40.,40.,50,-5,5.); TH2F *difyptarVyfp = new TH2F("difyptarVyfp",";yfp (cm);Yptar diff (mr)",100,-30.,30.,50,-5,5.); TH2F *difyptarVxpfp = new TH2F("difyptarVxpfp",";xpfp (cm);Yptar diff (mr)",100,-.1,.1,50,-5,5.); TH2F *difyptarVypfp = new TH2F("difyptarVypfp",";ypfp (cm);Yptar diff (mr)",100,-.05,.05,50,-5,5.); TH2F *difyptarVdeltai = new TH2F("difyptarVdeltai",";Init delta ;Yptar diff (mr)",16,-.1,.22,50,-5,5.); // TH1F *difytar = new TH1F("difytar",";Ytar diff (cm) ",40,-2.,2.); TH2F *difytarVxptari = new TH2F("difytarVxptari",";Init xptar (rad);Ytar diff (cm)",25,-.05,.05,40,-2.,2.); TH2F *difytarVyptari = new TH2F("difytarVyptari",";Init yptar (rad);Ytar diff (cm)",30,-.03,.03,40,-2.,2.); TH2F *difytarVxfp = new TH2F("difytarVxfp",";xfp (cm);Ytar diff (cm)",100,-40.,40.,40,-2.,2.); TH2F *difytarVyfp = new TH2F("difytarVyfp",";yfp (cm);Ytar diff (cm)",100,-30.,30.,40,-2.,2.); TH2F *difytarVxpfp = new TH2F("difytarVxpfp",";xpfp (cm);Ytar diff (cm)",100,-.1,.1,40,-2.,2.); TH2F *difytarVypfp = new TH2F("difytarVypfp",";ypfp (cm);Ytar diff (cm)",100,-.05,.05,40,-2.,2.); TH2F *difytarVdeltai = new TH2F("difytarVdeltai",";Init delta ;Ytar diff (cm)",16,-.1,.22,40,-2.,2.); // TH1F *difdelta = new TH1F("difdelta",";Delta diff (%) ",40,-.1,.1); TH2F *difdeltaVxptari = new TH2F("difdeltaVxptari",";Init xptar (rad);Delta diff (%)",25,-.05,.05,40,-.1,.1); TH2F *difdeltaVyptari = new TH2F("difdeltaVyptari",";Init yptar (rad);Delta diff (%)",30,-.03,.03,40,-.1,.1); TH2F *difdeltaVxfp = new TH2F("difdeltaVxfp",";xfp (cm);Delta diff (%)",100,-40.,40.,40,-.1,.1); TH2F *difdeltaVyfp = new TH2F("difdeltaVyfp",";yfp (cm);Delta diff (%)",100,-30.,30.,40,-.1,.1); TH2F *difdeltaVxpfp = new TH2F("difdeltaVxpfp",";xpfp (cm);Delta diff (%)",100,-.1,.1,40,-.1,.1); TH2F *difdeltaVypfp = new TH2F("difdeltaVypfp",";ypfp (cm);Delta diff (%)",100,-.05,.05,40,-.1,.1); TH2F *difdeltaVdeltai = new TH2F("difdeltaVdeltai",";Init delta ;Delta diff (%)",16,-.1,.22,40,-.1,.1); // Long64_t nentries = tsimc->GetEntries(); for (int i = 0; i < nentries; i++) { tsimc->GetEntry(i); hxptari->Fill(hsxptari); hxptarf->Fill(hsxptar); difxptar->Fill(1000*(hsxptar-hsxptari)); difxptarVxptari->Fill(hsxptari,1000*(hsxptar-hsxptari)); difxptarVyptari->Fill(hsyptari,1000*(hsxptar-hsxptari)); difxptarVxfp->Fill(hsxfp,1000*(hsxptar-hsxptari)); difxptarVyfp->Fill(hsyfp,1000*(hsxptar-hsxptari)); difxptarVxpfp->Fill(hsxpfp,1000*(hsxptar-hsxptari)); difxptarVypfp->Fill(hsypfp,1000*(hsxptar-hsxptari)); difxptarVdeltai->Fill(hsdeltai/100.,1000*(hsxptar-hsxptari)); // difyptar->Fill(1000*(hsyptar-hsyptari)); difyptarVxptari->Fill(hsxptari,1000*(hsyptar-hsyptari)); difyptarVyptari->Fill(hsyptari,1000*(hsyptar-hsyptari)); difyptarVxfp->Fill(hsxfp,1000*(hsyptar-hsyptari)); difyptarVyfp->Fill(hsyfp,1000*(hsyptar-hsyptari)); difyptarVxpfp->Fill(hsxpfp,1000*(hsyptar-hsyptari)); difyptarVypfp->Fill(hsypfp,1000*(hsyptar-hsyptari)); difyptarVdeltai->Fill(hsdeltai/100.,1000*(hsyptar-hsyptari)); // difdelta->Fill((hsdelta-hsdeltai)); difdeltaVxptari->Fill(hsxptari,(hsdelta-hsdeltai)); difdeltaVyptari->Fill(hsyptari,(hsdelta-hsdeltai)); difdeltaVxfp->Fill(hsxfp,(hsdelta-hsdeltai)); difdeltaVyfp->Fill(hsyfp,(hsdelta-hsdeltai)); difdeltaVxpfp->Fill(hsxpfp,(hsdelta-hsdeltai)); difdeltaVypfp->Fill(hsypfp,(hsdelta-hsdeltai)); difdeltaVdeltai->Fill(hsdeltai/100.,(hsdelta-hsdeltai)); // difytar->Fill((hsytar-hsytari)); difytarVxptari->Fill(hsxptari,(hsytar-hsytari)); difytarVyptari->Fill(hsyptari,(hsytar-hsytari)); difytarVxfp->Fill(hsxfp,(hsytar-hsytari)); difytarVyfp->Fill(hsyfp,(hsytar-hsytari)); difytarVxpfp->Fill(hsxpfp,(hsytar-hsytari)); difytarVypfp->Fill(hsypfp,(hsytar-hsytari)); difytarVdeltai->Fill(hsdeltai/100.,(hsytar-hsytari)); } // TCanvas *cxptar = new TCanvas("cxptar"," Compare Recon/Inital xptar 8 GeV, point target, no wire ch, no mscat",1400,1000); cxptar->Divide(4,3); cxptar->cd(4); difxptar->Draw(); cxptar->cd(1); difxptarVdeltai->Draw("colz"); cxptar->cd(5); difxptarVdeltai->FitSlicesY(); TH1D *difxptarVdeltai_2 = (TH1D*)gDirectory->Get("difxptarVdeltai_2"); difxptarVdeltai_2->SetTitle(";Init Delta; Fitted Sigma of Xptar diff (mr)"); difxptarVdeltai_2->Draw(); cxptar->cd(2); difxptarVxptari->Draw("colz"); cxptar->cd(6); difxptarVxptari->FitSlicesY(); TH1D *difxptarVxptari_2 = (TH1D*)gDirectory->Get("difxptarVxptari_2"); difxptarVxptari_2->SetTitle(";Init Xptar; Fitted Sigma of Xptar diff (mr)"); difxptarVxptari_2->Draw(); cxptar->cd(3); difxptarVyptari->Draw("colz"); cxptar->cd(7); difxptarVyptari->FitSlicesY(); TH1D *difxptarVyptari_2 = (TH1D*)gDirectory->Get("difxptarVyptari_2"); difxptarVyptari_2->SetTitle(";Init Yptar; Fitted Sigma of Xptar diff (mr)"); difxptarVyptari_2->Draw(); cxptar->cd(9); difxptarVxfp->Draw("colz"); cxptar->cd(10); difxptarVyfp->Draw("colz"); cxptar->cd(11); difxptarVxpfp->Draw("colz"); cxptar->cd(12); difxptarVypfp->Draw("colz"); // TCanvas *cyptar = new TCanvas("cyptar"," Compare Recon/Inital yptar 8 GeV, point target, no wire ch, no mscat",1400,1000); cyptar->Divide(4,3); cyptar->cd(4); difyptar->Draw(); cyptar->cd(1); difyptarVdeltai->Draw("colz"); cyptar->cd(5); difyptarVdeltai->FitSlicesY(); TH1D *difyptarVdeltai_2 = (TH1D*)gDirectory->Get("difyptarVdeltai_2"); difyptarVdeltai_2->SetTitle(";Init Delta; Fitted Sigma of Yptar diff (mr)"); difyptarVdeltai_2->Draw(); cyptar->cd(2); difyptarVxptari->Draw("colz"); cyptar->cd(6); difyptarVxptari->FitSlicesY(); TH1D *difyptarVxptari_2 = (TH1D*)gDirectory->Get("difyptarVxptari_2"); difyptarVxptari_2->SetTitle(";Init Xptar; Fitted Sigma of Yptar diff (mr)"); difyptarVxptari_2->Draw(); cyptar->cd(3); difyptarVyptari->Draw("colz"); cyptar->cd(7); difyptarVyptari->FitSlicesY(); TH1D *difyptarVyptari_2 = (TH1D*)gDirectory->Get("difyptarVyptari_2"); difyptarVyptari_2->SetTitle(";Init Yptar; Fitted Sigma of Yptar diff (mr)"); difyptarVyptari_2->Draw(); cyptar->cd(9); difyptarVxfp->Draw("colz"); cyptar->cd(10); difyptarVyfp->Draw("colz"); cyptar->cd(11); difyptarVxpfp->Draw("colz"); cyptar->cd(12); difyptarVypfp->Draw("colz"); // TCanvas *cdelta = new TCanvas("cdelta"," Compare Recon/Inital delta 8 GeV, point target, no wire ch, no mscat",1400,1000); cdelta->Divide(4,3); cdelta->cd(4); difdelta->Draw(); cdelta->cd(1); difdeltaVdeltai->Draw("colz"); cdelta->cd(5); difdeltaVdeltai->FitSlicesY(); TH1D *difdeltaVdeltai_2 = (TH1D*)gDirectory->Get("difdeltaVdeltai_2"); difdeltaVdeltai_2->SetTitle(";Init Delta; Fitted Sigma of Delta diff (%)"); difdeltaVdeltai_2->Draw(); cdelta->cd(2); difdeltaVxptari->Draw("colz"); cdelta->cd(6); difdeltaVxptari->FitSlicesY(); TH1D *difdeltaVxptari_2 = (TH1D*)gDirectory->Get("difdeltaVxptari_2"); difdeltaVxptari_2->SetTitle(";Init Xptar; Fitted Sigma of Delta diff (%)"); difdeltaVxptari_2->Draw(); cdelta->cd(3); difdeltaVyptari->Draw("colz"); cdelta->cd(7); difdeltaVyptari->FitSlicesY(); TH1D *difdeltaVyptari_2 = (TH1D*)gDirectory->Get("difdeltaVyptari_2"); difdeltaVyptari_2->SetTitle(";Init Yptar; Fitted Sigma of Delta diff (%)"); difdeltaVyptari_2->Draw(); cdelta->cd(9); difdeltaVxfp->Draw("colz"); cdelta->cd(10); difdeltaVyfp->Draw("colz"); cdelta->cd(11); difdeltaVxpfp->Draw("colz"); cdelta->cd(12); difdeltaVypfp->Draw("colz"); // TCanvas *cytar = new TCanvas("cytar"," Compare Recon/Inital ytar 8 GeV, point target, no wire ch, no mscat",1400,1000); cytar->Divide(4,3); cytar->cd(4); difytar->Draw(); cytar->cd(1); difytarVdeltai->Draw("colz"); cytar->cd(5); difytarVdeltai->FitSlicesY(); TH1D *difytarVdeltai_2 = (TH1D*)gDirectory->Get("difytarVdeltai_2"); difytarVdeltai_2->SetTitle(";Init Delta; Fitted Sigma of Ytar diff (cm)"); difytarVdeltai_2->Draw(); cytar->cd(2); difytarVxptari->Draw("colz"); cytar->cd(6); difytarVxptari->FitSlicesY(); TH1D *difytarVxptari_2 = (TH1D*)gDirectory->Get("difytarVxptari_2"); difytarVxptari_2->SetTitle(";Init Xptar; Fitted Sigma of Ytar diff (cm)"); difytarVxptari_2->Draw(); cytar->cd(3); difytarVyptari->Draw("colz"); cytar->cd(7); difytarVyptari->FitSlicesY(); TH1D *difytarVyptari_2 = (TH1D*)gDirectory->Get("difytarVyptari_2"); difytarVyptari_2->SetTitle(";Init Yptar; Fitted Sigma of Ytar diff (cm)"); difytarVyptari_2->Draw(); cytar->cd(9); difytarVxfp->Draw("colz"); cytar->cd(10); difytarVyfp->Draw("colz"); cytar->cd(11); difytarVxpfp->Draw("colz"); cytar->cd(12); difytarVypfp->Draw("colz"); }
//------------------------------------------------------------------------------ // DrawHistogram //------------------------------------------------------------------------------ void DrawHistogram(TString hname, TString xtitle, Int_t ngroup = -1, Int_t precision = 1, TString units = "NULL", Double_t xmin = -999, Double_t xmax = 999, Bool_t moveOverflow = true) { //TCanvas* canvas = new TCanvas(hname, hname, 550, 720); TCanvas* canvas = new TCanvas(hname, hname, 800, 800); TPad* pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0); TPad* pad2 = new TPad("pad2", "pad2", 0, 0.0, 1, 0.3); pad1->SetTopMargin (0.08); pad1->SetBottomMargin(0.02); pad1->Draw(); pad2->SetTopMargin (0.08); pad2->SetBottomMargin(0.35); pad2->Draw(); //---------------------------------------------------------------------------- // pad1 //---------------------------------------------------------------------------- pad1->cd(); pad1->SetLogy(_setLogy); THStack* hstack = new THStack(hname, hname); TH1F* hist[nProcesses]; TH1F* hist_0[nProcesses]; // 0-jet TH1F* hist_1[nProcesses]; // 1-jet for (UInt_t ip=0; ip<nProcesses; ip++) { if( _njet == 10 ){ hist_0[ip] = (TH1F*)input_0[ip]->Get(hname); hist_1[ip] = (TH1F*)input_1[ip]->Get(hname); }else{ //hist[ip] = (TH1F*)input[ip]->Get(hname); //hist[ip]->SetName(hname + process[ip]); } if (moveOverflow){ if(_njet ==10){ MoveOverflowBins (hist_0[ip], xmin, xmax); MoveOverflowBins (hist_1[ip], xmin, xmax); }else{ //MoveOverflowBins (hist[ip], xmin, xmax); } }else{ if(_njet == 10){ ZeroOutOfRangeBins(hist_0[ip], xmin, xmax); ZeroOutOfRangeBins(hist_1[ip], xmin, xmax); }else{ //ZeroOutOfRangeBins(hist[ip], xmin, xmax); } } if (ngroup > 0){ if(_njet == 10){ hist_0[ip]->Rebin(ngroup); hist_1[ip]->Rebin(ngroup); }else{ //hist[ip]->Rebin(ngroup); } } // Add 0, 1 jet if (ip == iData) { if(_njet == 10 ){ hist[ip] = (TH1F*)hist_0[ip]->Clone(hname+process[ip]); hist[ip]->Add(hist_1[ip]); hist[ip]->SetMarkerStyle(kFullCircle); }else{ //hist[ip]->SetMarkerStyle(kFullCircle); } } else { if(_njet == 10){ if (_dataDriven && ip == itt) hist_0[ip]->Scale(ttScale[0]); if (_dataDriven && ip == itW) hist_0[ip]->Scale(tWScale[0]); if (_dataDriven && ip == iWW) hist_0[ip]->Scale(WWScale[0]); if (_dataDriven && ip == iDY) hist_0[ip]->Scale(ZjScale[0]); if (_dataDriven && ip == iDYtau) hist_0[ip]->Scale(ZjScale[0]); if (_dataDriven && ip == itt) hist_1[ip]->Scale(ttScale[1]); if (_dataDriven && ip == itW) hist_1[ip]->Scale(tWScale[1]); if (_dataDriven && ip == iWW) hist_1[ip]->Scale(WWScale[1]); if (_dataDriven && ip == iDY) hist_1[ip]->Scale(ZjScale[1]); if (_dataDriven && ip == iDYtau) hist_1[ip]->Scale(ZjScale[1]); hist[ip] = (TH1F*)hist_0[ip]->Clone(hname+process[ip]); hist[ip]->Add(hist_1[ip]); hist[ip]->SetFillColor(color[ip]); hist[ip]->SetFillStyle(1001); hist[ip]->SetLineColor(color[ip]); }else{ //hist[ip]->SetFillColor(color[ip]); //hist[ip]->SetFillStyle(1001); //hist[ip]->SetLineColor(color[ip]); //if (_dataDriven && ip == itt) hist[ip]->Scale(ttScale[_njet]); //if (_dataDriven && ip == itW) hist[ip]->Scale(tWScale[_njet]); //if (_dataDriven && ip == iWW) hist[ip]->Scale(WWScale[_njet]); //if (_dataDriven && ip == iDY) hist[ip]->Scale(ZjScale[_njet]); //if (_dataDriven && ip == iDYtau) hist[ip]->Scale(ZjScale[_njet]); } hstack->Add(hist[ip]); } } //========================================================= //Save histograms to root file to draw paper style plots //========================================================= //TFile* outfile; //TString fname = Form("files/%s_%djet.root", hname.Data(),_njet); //TString fname = "files/0jet_"+hname+".root"; //if(_njet==1) fname = "files/1jet_"+hname+".root"; //if(_njet==10) fname = "files/10jet_"+hname+".root"; //outfile = new TFile(fname, "create"); //if(ip == iData) TH1F* data = (TH1F*)hist[iData]->Clone("Data"); //data -> Sumw2(); //if(ip == itt) TH1F* top = (TH1F*)hist[itt]->Clone("top"); //top -> Sumw2(); //if(ip == itW) TH1F* tW = (TH1F*)hist[itW]->Clone("tW"); //tW -> Sumw2(); //if(ip == iWW) TH1F* WW = (TH1F*)hist[iWW]->Clone("WW"); //WW -> Sumw2(); //if(ip == iWZ) TH1F* VVandVVV = (TH1F*)hist[iWZ]->Clone("VVandVVV"); //VV -> Sumw2(); //if(ip == iZZ) TH1F* ZZ = (TH1F*)hist[iZZ]->Clone("ZZ"); //ZZ -> Sumw2(); //if(ip == iWg) TH1F* Wg = (TH1F*)hist[iWg]->Clone("Wg"); //Wg -> Sumw2(); //if(ip == iWj) TH1F* Wjets = (TH1F*)hist[iWj]->Clone("W+jets"); //Wjets -> Sumw2(); //if(ip == iDY) TH1F* Zjets = (TH1F*)hist[iDY]->Clone("Z+jets"); //Zjets -> Sumw2(); //if(ip == iDYtau) TH1F* DYtau = (TH1F*)hist[iDYtau]->Clone("DYtau"); //DYtau -> Sumw2(); //if(ip == iZgamma) TH1F* Zgamma = (TH1F*)hist[iZgamma]->Clone("Zgamma"); //Zgamma -> Sumw2(); //if(ip == iH125) TH1F* ggH = (TH1F*)hist[iH125]->Clone("ggH"); //ggH -> Sumw2(); // //top -> Add(tW); //VVandVVV -> Add(ZZ); //VVandVVV -> Add(Wg); //Zjets -> Add(DYtau); //Zjets -> Add(Zgamma); // //data -> Write(); //top -> Write(); //WW -> Write(); //VVandVVV -> Write(); //Wjets -> Write(); //Zjets -> Write(); //ggH -> Write(); // //outfile -> Close(); // //========================================================= //Draw paper style plots //========================================================= //Use LatinoPlotTools. //As input root file, use above saved root file "outfile" //Run the following executable file: //https://github.com/latinos/LatinoPlotTools/blob/master/WWRunI/scripts/doHWidth_Top_control.sh // All MC //---------------------------------------------------------------------------- TH1F* allmc = (TH1F*)hist[iData]->Clone("allmc"); allmc->SetFillColor (kGray+2); allmc->SetFillStyle ( 3345); allmc->SetLineColor (kGray+2); allmc->SetMarkerColor(kGray+2); allmc->SetMarkerSize ( 0); for (UInt_t ibin=1; ibin<=allmc->GetNbinsX(); ibin++) { Double_t binValue = 0; Double_t binError = 0; for (UInt_t ip=0; ip<nProcesses; ip++) { if (ip == iData) continue; Double_t binContent = hist[ip]->GetBinContent(ibin); binValue += binContent; binError += (hist[ip]->GetBinError(ibin) * hist[ip]->GetBinError(ibin)); //We need to calculate systematic uncertainty for ggH case // if (_dataDriven) // binError += (systError[ip]*binContent * systError[ip]*binContent); } binError = sqrt(binError); allmc->SetBinContent(ibin, binValue); allmc->SetBinError (ibin, binError); } // Axis labels //---------------------------------------------------------------------------- TAxis* xaxis = hist[iData]->GetXaxis(); TAxis* yaxis = hist[iData]->GetYaxis(); TString ytitle = Form("entries / %s.%df", "%", precision); xaxis->SetTitle(xtitle); yaxis->SetTitle(Form(ytitle.Data(), hist[iData]->GetBinWidth(0))); yaxis->SetTitleOffset(1.6); if (!units.Contains("NULL")) { xaxis->SetTitle(Form("%s [%s]", xaxis->GetTitle(), units.Data())); yaxis->SetTitle(Form("%s %s", yaxis->GetTitle(), units.Data())); } // Draw //---------------------------------------------------------------------------- xaxis->SetRangeUser(xmin, xmax); hist[iData]->Draw("ep"); hstack ->Draw("hist,same"); allmc ->Draw("e2,same"); hist[iData]->Draw("ep,same"); // Adjust scale //---------------------------------------------------------------------------- Float_t theMax = GetMaximumIncludingErrors(hist[iData], xmin, xmax); Float_t theMaxMC = GetMaximumIncludingErrors(allmc, xmin, xmax); if (theMaxMC > theMax) theMax = theMaxMC; if (pad1->GetLogy()) { theMax = TMath::Power(10, TMath::Log10(theMax) + 2.7); hist[iData]->SetMinimum(0.05); } else theMax *= 1.55; hist[iData]->SetMaximum(theMax); // Legend //---------------------------------------------------------------------------- Double_t x0 = 0.720; Double_t y0 = 0.834; Double_t yoffset = 0.048; Double_t delta = yoffset + 0.001; Double_t ndelta = 0; Double_t YieldTop = Yield(hist[itt]) + Yield(hist[itW]); Double_t YieldVV = Yield(hist[iWZ]) + Yield(hist[iZZ]) + Yield(hist[iWg]); //Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]); Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]) + Yield(hist[iZgamma]); DrawLegend(x0 - 0.49, y0 - ndelta, hist[iData], Form(" data (%.0f)", Yield(hist[iData])), "lp", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, allmc, Form(" all (%.0f)", Yield(allmc)), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWW], Form(" WW (%.0f)", Yield(hist[iWW])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWZ], Form(" VV (%.0f)", YieldVV), "f", 0.03, 0.2, yoffset); ndelta += delta; ndelta = 0; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDY], Form(" Z+jets (%.0f)", YieldZJets), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iWj], Form(" W+jets (%.0f)", Yield(hist[iWj])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[itt], Form(" top (%.0f)", YieldTop), "f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125], Form(" Higgs (%.0f)", Yield(hist[iH125])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125], Form(" ggH (%.0f)", Yield(hist[iH125])), "f", 0.03, 0.2, yoffset); ndelta += delta; // Additional titles //---------------------------------------------------------------------------- //TString channelLabel = "ee/#mu#mu/e#mu/#mue"; TString channelLabel = ""; //if (_channel == "EE") channelLabel = "ee"; //if (_channel == "MuMu") channelLabel = "#mu#mu"; //if (_channel == "EMu") channelLabel = "e#mu"; //if (_channel == "MuE") channelLabel = "#mue"; //if (_channel == "SF") channelLabel = "ee/#mu#mu"; //if (_channel == "OF") channelLabel = "e#mu/#mue"; if( _njet != 10) channelLabel += Form(" %d", _njet); if (_njet == 0) channelLabel += "-jets"; if (_njet == 1) channelLabel += "-jet"; if (_njet >= 2 && _njet!= 10) channelLabel += "-jets"; if ( _njet== 10) channelLabel += "SS 0+1 jets"; DrawTLatex(0.185, 0.975, 0.05, 13, channelLabel.Data()); DrawTLatex(0.940, 0.983, 0.05, 33, Form("L = %.1f fb^{-1}", _luminosity/1e3)); //---------------------------------------------------------------------------- // pad2 //---------------------------------------------------------------------------- pad2->cd(); TH1F* ratio = hist[iData]->Clone("ratio"); TH1F* uncertainty = allmc->Clone("uncertainty"); for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) { Double_t mcValue = allmc->GetBinContent(ibin); Double_t mcError = allmc->GetBinError (ibin); Double_t dtValue = ratio->GetBinContent(ibin); Double_t dtError = ratio->GetBinError (ibin); Double_t ratioValue = (mcValue > 0) ? dtValue/mcValue : 0.0; Double_t ratioError = (mcValue > 0) ? dtError/mcValue : 0.0; Double_t uncertaintyError = (mcValue > 0) ? mcError/mcValue : 0.0; ratio->SetBinContent(ibin, ratioValue); ratio->SetBinError (ibin, ratioError); uncertainty->SetBinContent(ibin, 1.0); uncertainty->SetBinError (ibin, uncertaintyError); } TAxis* uaxis = (TAxis*)uncertainty->GetXaxis(); uaxis->SetRangeUser(xmin, xmax); uncertainty->Draw("e2"); ratio ->Draw("ep,same"); uncertainty->GetYaxis()->SetRangeUser(0, 2.5); // Save //---------------------------------------------------------------------------- pad2->cd(); SetAxis(uncertainty, hist[iData]->GetXaxis()->GetTitle(), "data / prediction", 0.10, 0.8); pad1->cd(); SetAxis(hist[iData], "", hist[iData]->GetYaxis()->GetTitle(), 0.05, 1.6); canvas->cd(); TString suffixLogy = (_setLogy) ? "_Log" : "_Lin"; canvas->SaveAs(Form("%s/%s%s.%s", _output.Data(), hname.Data(), suffixLogy.Data(), _format.Data())); }
void compare_ATLAS_pp_fitBoth_TH1F(Int_t nfit=6, Int_t FitStart=50, Int_t FitEnd=450){ TH1::SetDefaultSumw2(); gStyle->SetOptFit(1); gStyle->SetOptStat(0); //=========Macro generated from canvas: cATLAS_pp/ //========= (Wed Jul 22 23:01:26 2015) by ROOT version5.32/00 TF1 *fitppATLAS = new TF1("fitppATLAS","[0]*pow(x+[2],[1])"); //create function fitppATLAS->SetParameters(1e10,-5,0); fitppATLAS->SetLineColor(kRed); TF1 *fitppCMS = new TF1("fitppCMS","[0]*pow(x+[2],[1])"); //create function fitppCMS->SetParameters(1e10,-5,0); fitppCMS->SetLineColor(kBlue); TF1 *fitppATLASHist = new TF1("fitppATLASHist","[0]*pow(x+[2],[1])"); //create function fitppATLASHist->SetParameters(1e10,-5,0); fitppATLASHist->SetLineColor(kGreen+1); TGraphAsymmErrors *grae = new TGraphAsymmErrors(12); grae->SetName("/HepData/8719/d2x1y1"); grae->SetTitle(" "); grae->SetFillColor(1); grae->SetMarkerStyle(33); grae->SetPoint(0,35,180); grae->SetPointError(0,4,4,29.95905,29.95905); grae->SetPoint(1,44.5,55.7); grae->SetPointError(1,5.5,5.5,7.828377,7.828377); grae->SetPoint(2,56.5,16.9); grae->SetPointError(2,6.5,6.5,2.625436,2.625436); grae->SetPoint(3,71,4.85); grae->SetPointError(3,8,8,0.6276957,0.6276957); grae->SetPoint(4,89.5,1.42); grae->SetPointError(4,10.5,10.5,0.1878054,0.1878054); grae->SetPoint(5,112.5,0.364); grae->SetPointError(5,12.5,12.5,0.04772427,0.04772427); grae->SetPoint(6,141.5,0.0882); grae->SetPointError(6,16.5,16.5,0.01103805,0.01103805); grae->SetPoint(7,178.5,0.0197); grae->SetPointError(7,20.5,20.5,0.002292152,0.002292152); grae->SetPoint(8,225,0.00406); grae->SetPointError(8,26,26,0.0004822521,0.0004822521); grae->SetPoint(9,283.5,0.000735); grae->SetPointError(9,32.5,32.5,8.981748e-05,8.981748e-05); grae->SetPoint(10,357,0.000114); grae->SetPointError(10,41,41,1.442494e-05,1.442494e-05); grae->SetPoint(11,449.5,1.41e-05); grae->SetPointError(11,51.5,51.5,1.98855e-06,1.98855e-06); TH1F *hATLASpp = new TH1F("hATLASpp"," ",100,50,450); hATLASpp->SetMinimum(1.090031e-05); hATLASpp->SetMaximum(230.955); hATLASpp->SetDirectory(0); hATLASpp->SetStats(0); Int_t ci; // for color index setting ci = TColor::GetColor("#000099"); hATLASpp->SetLineColor(ci); hATLASpp->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)"); hATLASpp->GetXaxis()->SetLabelFont(42); hATLASpp->GetXaxis()->SetLabelSize(0.035); hATLASpp->GetXaxis()->SetTitleSize(0.035); hATLASpp->GetXaxis()->SetTitleFont(42); hATLASpp->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dp_{T} d#eta} nb"); hATLASpp->GetYaxis()->SetLabelFont(42); hATLASpp->GetYaxis()->SetLabelSize(0.035); hATLASpp->GetYaxis()->SetTitleSize(0.035); hATLASpp->GetYaxis()->SetTitleFont(42); hATLASpp->GetZaxis()->SetLabelFont(42); hATLASpp->GetZaxis()->SetLabelSize(0.035); hATLASpp->GetZaxis()->SetTitleSize(0.035); hATLASpp->GetZaxis()->SetTitleFont(42); grae->SetHistogram(hATLASpp); Double_t xAxisATLASpp[13] = {31,39,50,63,79,100,125,158,199,251,316,398,501}; TH1F *hATLASppHist = new TH1F("hATLASppHist"," ",12,xAxisATLASpp); hATLASppHist->SetMinimum(1.090031e-05); hATLASppHist->SetMaximum(230.955); hATLASppHist->SetDirectory(0); hATLASppHist->SetStats(0); hATLASppHist->SetBinContent(1,180); hATLASppHist->SetBinError(1,29.95905); hATLASppHist->SetBinContent(2,55.7); hATLASppHist->SetBinError(2,7.828377); hATLASppHist->SetBinContent(3,16.9); hATLASppHist->SetBinError(3,2.625436); hATLASppHist->SetBinContent(4,4.85); hATLASppHist->SetBinError(4,0.6276957); hATLASppHist->SetBinContent(5,1.42); hATLASppHist->SetBinError(5,0.1878054); hATLASppHist->SetBinContent(6,0.364); hATLASppHist->SetBinError(6,0.04772427); hATLASppHist->SetBinContent(7,0.0882); hATLASppHist->SetBinError(7,0.01103805); hATLASppHist->SetBinContent(8,0.0197); hATLASppHist->SetBinError(8,0.002292152); hATLASppHist->SetBinContent(9,0.00406); hATLASppHist->SetBinError(9,0.0004822521); hATLASppHist->SetBinContent(10,0.000735); hATLASppHist->SetBinError(10,8.981748e-05); hATLASppHist->SetBinContent(11,0.000114); hATLASppHist->SetBinError(11,1.442494e-05); hATLASppHist->SetBinContent(12,1.41e-05); hATLASppHist->SetBinError(12,1.98855e-06); // c1=new TCanvas(); // // c1.cd(); // hATLASppHist->Draw(); // was grae for(int i=0; i<nfit; ++i){ grae->Fit("fitppATLAS","","",FitStart,FitEnd); //fit function } cout<<"now to fit hATLASppHist"<<endl; for(int ib=0; ib<nfit; ++ib){ hATLASppHist->Fit("fitppATLASHist","IL","",FitStart,FitEnd); //fit function } TCanvas *cATLAS_ppHist = new TCanvas("cATLAS_ppHist", "",0,0,1200,1000); cATLAS_ppHist->Range(-3.725291e-06,-5.878322,500,3.279288); cATLAS_ppHist->SetFillColor(0); cATLAS_ppHist->SetBorderMode(0); cATLAS_ppHist->SetBorderSize(2); cATLAS_ppHist->SetLogy(); cATLAS_ppHist->SetFrameBorderMode(0); cATLAS_ppHist->SetFrameBorderMode(0); // grae->SetHistogram(hATLASpp); TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(10); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("NULL","","h"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(62); entry=leg->AddEntry("hATLASppHist","ATLAS pp histogram","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(kGreen); entry->SetMarkerStyle(22); entry->SetMarkerSize(1); entry->SetTextFont(62); entry=leg->AddEntry("grae","ATLAS pp TGraphAsymErrors","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(33); entry->SetMarkerSize(1); leg->Draw(); hATLASppHist->SetMarkerColor(kGreen); hATLASppHist->SetMarkerStyle(22); grae->SetMarkerStyle(21); grae->SetMarkerColor(1); hATLASpp->Draw(); grae->Draw("ap,same"); // uPP_R4_SVD->Draw("same E1"); hATLASppHist->Draw("ap,same"); TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *text = pt->AddText(" "); pt->Draw(); cATLAS_ppHist->Modified(); cATLAS_ppHist->cd(); cATLAS_ppHist->SetSelected(cATLAS_ppHist); // for(int ic=0; ic<nfit; ic++){ // uPP_R4_SVD->Fit("fitppCMS","IL","",60,FitEnd); //fit function // // uPP_R4_SVD->Fit("fitppCMS","IL","",50,300); //fit function // } // hATLASpp->Draw(); // grae->Draw("ap,same"); // uPP_R4_SVD->Draw("same E1"); // hATLASppHist->Draw("same E1"); leg->Draw(); cATLAS_ppHist->SaveAs("Plots/ATLASHistfit_spectra_pp.pdf"); Double_t xAxis2086[101] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000}; TH1F *uPP_R4_SVD = new TH1F("uPP_R4_SVD","Unfold Matrix refpt jtpt from trigger addition R4 20_eta_20 ",100, xAxis2086); uPP_R4_SVD->SetBinContent(1,15.44572); uPP_R4_SVD->SetBinContent(2,81.73347); uPP_R4_SVD->SetBinContent(3,85.49986); uPP_R4_SVD->SetBinContent(4,90.07588); uPP_R4_SVD->SetBinContent(5,47.67952); uPP_R4_SVD->SetBinContent(6,18.31659); uPP_R4_SVD->SetBinContent(7,7.348095); uPP_R4_SVD->SetBinContent(8,3.295203); uPP_R4_SVD->SetBinContent(9,1.60486); uPP_R4_SVD->SetBinContent(10,0.8393627); uPP_R4_SVD->SetBinContent(11,0.4622419); uPP_R4_SVD->SetBinContent(12,0.265131); uPP_R4_SVD->SetBinContent(13,0.1587068); uPP_R4_SVD->SetBinContent(14,0.09774788); uPP_R4_SVD->SetBinContent(15,0.06153403); uPP_R4_SVD->SetBinContent(16,0.03981187); uPP_R4_SVD->SetBinContent(17,0.02620752); uPP_R4_SVD->SetBinContent(18,0.01766706); uPP_R4_SVD->SetBinContent(19,0.01206758); uPP_R4_SVD->SetBinContent(20,0.008403017); uPP_R4_SVD->SetBinContent(21,0.005956108); uPP_R4_SVD->SetBinContent(22,0.004267026); uPP_R4_SVD->SetBinContent(23,0.003102345); uPP_R4_SVD->SetBinContent(24,0.002273482); uPP_R4_SVD->SetBinContent(25,0.001699103); uPP_R4_SVD->SetBinContent(26,0.001281323); uPP_R4_SVD->SetBinContent(27,0.000971557); uPP_R4_SVD->SetBinContent(28,0.0007444665); uPP_R4_SVD->SetBinContent(29,0.0005746992); uPP_R4_SVD->SetBinContent(30,0.0004462709); uPP_R4_SVD->SetBinContent(31,0.0003483805); uPP_R4_SVD->SetBinContent(32,0.0002725941); uPP_R4_SVD->SetBinContent(33,0.0002141152); uPP_R4_SVD->SetBinContent(34,0.0001705039); uPP_R4_SVD->SetBinContent(35,0.0001352845); uPP_R4_SVD->SetBinContent(36,0.0001073623); uPP_R4_SVD->SetBinContent(37,8.559958e-05); uPP_R4_SVD->SetBinContent(38,6.847693e-05); uPP_R4_SVD->SetBinContent(39,5.506579e-05); uPP_R4_SVD->SetBinContent(40,4.404838e-05); uPP_R4_SVD->SetBinContent(41,3.566817e-05); uPP_R4_SVD->SetBinContent(42,2.88001e-05); uPP_R4_SVD->SetBinContent(43,2.33088e-05); uPP_R4_SVD->SetBinContent(44,1.897322e-05); uPP_R4_SVD->SetBinContent(45,1.546483e-05); uPP_R4_SVD->SetBinContent(46,1.251424e-05); uPP_R4_SVD->SetBinContent(47,1.020799e-05); uPP_R4_SVD->SetBinContent(48,8.267746e-06); uPP_R4_SVD->SetBinContent(49,6.760333e-06); uPP_R4_SVD->SetBinContent(50,5.504337e-06); uPP_R4_SVD->SetBinContent(51,4.514429e-06); uPP_R4_SVD->SetBinContent(52,3.665816e-06); uPP_R4_SVD->SetBinContent(53,3.010496e-06); uPP_R4_SVD->SetBinContent(54,2.463812e-06); uPP_R4_SVD->SetBinContent(55,2.01082e-06); uPP_R4_SVD->SetBinContent(56,1.624154e-06); uPP_R4_SVD->SetBinContent(57,1.334625e-06); uPP_R4_SVD->SetBinContent(58,1.088798e-06); uPP_R4_SVD->SetBinContent(59,8.896167e-07); uPP_R4_SVD->SetBinContent(60,7.305952e-07); uPP_R4_SVD->SetBinContent(61,5.930196e-07); uPP_R4_SVD->SetBinContent(62,4.863888e-07); uPP_R4_SVD->SetBinContent(63,3.941485e-07); uPP_R4_SVD->SetBinContent(64,3.221651e-07); uPP_R4_SVD->SetBinContent(65,2.636797e-07); uPP_R4_SVD->SetBinContent(66,2.146457e-07); uPP_R4_SVD->SetBinContent(67,1.742243e-07); uPP_R4_SVD->SetBinContent(68,1.409108e-07); uPP_R4_SVD->SetBinContent(69,1.142703e-07); uPP_R4_SVD->SetBinContent(70,9.293402e-08); uPP_R4_SVD->SetBinContent(71,7.511816e-08); uPP_R4_SVD->SetBinContent(72,6.013509e-08); uPP_R4_SVD->SetBinContent(73,4.927971e-08); uPP_R4_SVD->SetBinContent(74,3.992714e-08); uPP_R4_SVD->SetBinContent(75,3.176246e-08); uPP_R4_SVD->SetBinContent(76,2.560933e-08); uPP_R4_SVD->SetBinContent(77,2.039975e-08); uPP_R4_SVD->SetBinContent(78,1.627726e-08); uPP_R4_SVD->SetBinContent(79,1.272043e-08); uPP_R4_SVD->SetBinContent(80,1.022684e-08); uPP_R4_SVD->SetBinContent(81,8.172451e-09); uPP_R4_SVD->SetBinContent(82,6.570082e-09); uPP_R4_SVD->SetBinContent(83,5.205766e-09); uPP_R4_SVD->SetBinContent(84,4.075393e-09); uPP_R4_SVD->SetBinContent(85,3.265506e-09); uPP_R4_SVD->SetBinContent(86,2.62088e-09); uPP_R4_SVD->SetBinContent(87,2.003114e-09); uPP_R4_SVD->SetBinContent(88,1.535628e-09); uPP_R4_SVD->SetBinContent(89,1.063791e-09); uPP_R4_SVD->SetBinContent(90,9.092138e-10); uPP_R4_SVD->SetBinContent(91,6.803265e-10); uPP_R4_SVD->SetBinContent(92,4.778346e-10); uPP_R4_SVD->SetBinContent(93,3.988072e-10); uPP_R4_SVD->SetBinContent(94,2.474126e-10); uPP_R4_SVD->SetBinContent(95,2.140924e-10); uPP_R4_SVD->SetBinContent(96,1.623732e-10); uPP_R4_SVD->SetBinContent(97,1.45067e-10); uPP_R4_SVD->SetBinContent(98,9.186947e-11); uPP_R4_SVD->SetBinContent(99,6.040857e-11); uPP_R4_SVD->SetBinContent(100,6.157141e-11); uPP_R4_SVD->SetBinError(1,0.1237595); uPP_R4_SVD->SetBinError(2,0.6234048); uPP_R4_SVD->SetBinError(3,0.586929); uPP_R4_SVD->SetBinError(4,0.5173901); uPP_R4_SVD->SetBinError(5,0.2055361); uPP_R4_SVD->SetBinError(6,0.04990473); uPP_R4_SVD->SetBinError(7,0.01308245); uPP_R4_SVD->SetBinError(8,0.006804987); uPP_R4_SVD->SetBinError(9,0.003260532); uPP_R4_SVD->SetBinError(10,0.001534405); uPP_R4_SVD->SetBinError(11,0.001026545); uPP_R4_SVD->SetBinError(12,0.000705749); uPP_R4_SVD->SetBinError(13,0.0004784051); uPP_R4_SVD->SetBinError(14,0.0003483983); uPP_R4_SVD->SetBinError(15,0.0002598719); uPP_R4_SVD->SetBinError(16,0.0001903908); uPP_R4_SVD->SetBinError(17,0.0001387089); uPP_R4_SVD->SetBinError(18,0.0001040173); uPP_R4_SVD->SetBinError(19,7.981541e-05); uPP_R4_SVD->SetBinError(20,6.24475e-05); uPP_R4_SVD->SetBinError(21,4.937991e-05); uPP_R4_SVD->SetBinError(22,3.947987e-05); uPP_R4_SVD->SetBinError(23,3.254473e-05); uPP_R4_SVD->SetBinError(24,2.764293e-05); uPP_R4_SVD->SetBinError(25,2.429597e-05); uPP_R4_SVD->SetBinError(26,2.159774e-05); uPP_R4_SVD->SetBinError(27,1.917051e-05); uPP_R4_SVD->SetBinError(28,1.6997e-05); uPP_R4_SVD->SetBinError(29,1.498669e-05); uPP_R4_SVD->SetBinError(30,1.312744e-05); uPP_R4_SVD->SetBinError(31,1.142902e-05); uPP_R4_SVD->SetBinError(32,9.871913e-06); uPP_R4_SVD->SetBinError(33,8.480939e-06); uPP_R4_SVD->SetBinError(34,7.324674e-06); uPP_R4_SVD->SetBinError(35,6.255272e-06); uPP_R4_SVD->SetBinError(36,5.306614e-06); uPP_R4_SVD->SetBinError(37,4.495288e-06); uPP_R4_SVD->SetBinError(38,3.800242e-06); uPP_R4_SVD->SetBinError(39,3.214166e-06); uPP_R4_SVD->SetBinError(40,2.692884e-06); uPP_R4_SVD->SetBinError(41,2.275421e-06); uPP_R4_SVD->SetBinError(42,1.910914e-06); uPP_R4_SVD->SetBinError(43,1.60384e-06); uPP_R4_SVD->SetBinError(44,1.350324e-06); uPP_R4_SVD->SetBinError(45,1.135728e-06); uPP_R4_SVD->SetBinError(46,9.463317e-07); uPP_R4_SVD->SetBinError(47,7.933288e-07); uPP_R4_SVD->SetBinError(48,6.591956e-07); uPP_R4_SVD->SetBinError(49,5.520988e-07); uPP_R4_SVD->SetBinError(50,4.597711e-07); uPP_R4_SVD->SetBinError(51,3.851643e-07); uPP_R4_SVD->SetBinError(52,3.190695e-07); uPP_R4_SVD->SetBinError(53,2.670117e-07); uPP_R4_SVD->SetBinError(54,2.22444e-07); uPP_R4_SVD->SetBinError(55,1.84622e-07); uPP_R4_SVD->SetBinError(56,1.515098e-07); uPP_R4_SVD->SetBinError(57,1.263889e-07); uPP_R4_SVD->SetBinError(58,1.045901e-07); uPP_R4_SVD->SetBinError(59,8.662012e-08); uPP_R4_SVD->SetBinError(60,7.20551e-08); uPP_R4_SVD->SetBinError(61,5.920339e-08); uPP_R4_SVD->SetBinError(62,4.912298e-08); uPP_R4_SVD->SetBinError(63,4.024705e-08); uPP_R4_SVD->SetBinError(64,3.324212e-08); uPP_R4_SVD->SetBinError(65,2.747888e-08); uPP_R4_SVD->SetBinError(66,2.258106e-08); uPP_R4_SVD->SetBinError(67,1.849393e-08); uPP_R4_SVD->SetBinError(68,1.50859e-08); uPP_R4_SVD->SetBinError(69,1.233344e-08); uPP_R4_SVD->SetBinError(70,1.010825e-08); uPP_R4_SVD->SetBinError(71,8.230567e-09); uPP_R4_SVD->SetBinError(72,6.634947e-09); uPP_R4_SVD->SetBinError(73,5.473309e-09); uPP_R4_SVD->SetBinError(74,4.462479e-09); uPP_R4_SVD->SetBinError(75,3.571148e-09); uPP_R4_SVD->SetBinError(76,2.895626e-09); uPP_R4_SVD->SetBinError(77,2.318939e-09); uPP_R4_SVD->SetBinError(78,1.859689e-09); uPP_R4_SVD->SetBinError(79,1.460273e-09); uPP_R4_SVD->SetBinError(80,1.179314e-09); uPP_R4_SVD->SetBinError(81,9.46416e-10); uPP_R4_SVD->SetBinError(82,7.638915e-10); uPP_R4_SVD->SetBinError(83,6.075323e-10); uPP_R4_SVD->SetBinError(84,4.772801e-10); uPP_R4_SVD->SetBinError(85,3.836821e-10); uPP_R4_SVD->SetBinError(86,3.088773e-10); uPP_R4_SVD->SetBinError(87,2.367363e-10); uPP_R4_SVD->SetBinError(88,1.819577e-10); uPP_R4_SVD->SetBinError(89,1.263493e-10); uPP_R4_SVD->SetBinError(90,1.082238e-10); uPP_R4_SVD->SetBinError(91,8.113796e-11); uPP_R4_SVD->SetBinError(92,5.70881e-11); uPP_R4_SVD->SetBinError(93,4.772047e-11); uPP_R4_SVD->SetBinError(94,2.964495e-11); uPP_R4_SVD->SetBinError(95,2.568217e-11); uPP_R4_SVD->SetBinError(96,1.949672e-11); uPP_R4_SVD->SetBinError(97,1.743206e-11); uPP_R4_SVD->SetBinError(98,1.104588e-11); uPP_R4_SVD->SetBinError(99,7.265969e-12); uPP_R4_SVD->SetBinError(100,7.407249e-12); uPP_R4_SVD->SetEntries(100); uPP_R4_SVD->SetStats(0); ci = TColor::GetColor("#000099"); uPP_R4_SVD->SetLineColor(ci); // ci = TColor::GetColor("#0000ff"); // uPP_R4_SVD->SetMarkerColor(ci); // uPP_R4_SVD->SetMarkerStyle(24); // uPP_R4_SVD->GetXaxis()->CenterTitle(true); // uPP_R4_SVD->GetXaxis()->SetLabelFont(42); // uPP_R4_SVD->GetXaxis()->SetLabelSize(0.035); // uPP_R4_SVD->GetXaxis()->SetTitleSize(0.035); // uPP_R4_SVD->GetXaxis()->SetTitleFont(42); // uPP_R4_SVD->GetYaxis()->CenterTitle(true); // uPP_R4_SVD->GetYaxis()->SetLabelFont(42); // uPP_R4_SVD->GetYaxis()->SetLabelSize(0.035); // uPP_R4_SVD->GetYaxis()->SetTitleSize(0.035); // uPP_R4_SVD->GetYaxis()->SetTitleFont(42); // uPP_R4_SVD->GetZaxis()->SetLabelFont(42); // uPP_R4_SVD->GetZaxis()->SetLabelSize(0.035); // uPP_R4_SVD->GetZaxis()->SetTitleSize(0.035); // uPP_R4_SVD->GetZaxis()->SetTitleFont(42); // uPP_R4_SVD->Draw("same E1"); // TBox *box = new TBox(60,7.108492,70,7.587699); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(70,3.186674,80,3.403731); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(80,1.551541,90,1.658179); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(90,0.8111346,100,0.8675909); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(100,0.4464541,110,0.4780297); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(110,0.2045159,130,0.2193219); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(130,0.07677678,150,0.08250514); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(150,0.03180206,170,0.03421734); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(170,0.01431415,190,0.01542048); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(190,0.006909775,210,0.007449351); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(210,0.003092187,240,0.003336382); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(240,0.001266417,270,0.001368238); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); // box = new TBox(270,0.00056544,300,0.0006115177); // box->SetFillColor(2); // box->SetFillStyle(0); // box->SetLineColor(2); // box->Draw(); TCanvas *cATLAS_pp = new TCanvas("cATLAS_pp", "",0,0,1200,1000); cATLAS_pp->Range(-3.725291e-06,-5.878322,500,3.279288); cATLAS_pp->SetFillColor(0); cATLAS_pp->SetBorderMode(0); cATLAS_pp->SetBorderSize(2); cATLAS_pp->SetLogy(); cATLAS_pp->SetFrameBorderMode(0); cATLAS_pp->SetFrameBorderMode(0); grae->SetHistogram(hATLASpp); hATLASpp->Draw(); grae->Draw("ap,same"); TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(10); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("NULL","","h"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(62); entry=leg->AddEntry("/HepData/8719/d2x1y1","ATLAS pp","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(33); entry->SetMarkerSize(1); entry=leg->AddEntry("uPP_R4_SVD","CMS pp","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#0000ff"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(24); entry->SetMarkerSize(1); leg->Draw(); TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *text = pt->AddText(" "); pt->Draw(); cATLAS_pp->Modified(); cATLAS_pp->cd(); cATLAS_pp->SetSelected(cATLAS_pp); for(int ic=0; ic<nfit; ic++){ uPP_R4_SVD->Fit("fitppCMS","IL","",60,FitEnd); //fit function // uPP_R4_SVD->Fit("fitppCMS","IL","",50,300); //fit function } hATLASpp->Draw(); grae->Draw("ap,same"); uPP_R4_SVD->Draw("same E1"); leg->Draw(); cATLAS_pp->SaveAs("Plots/CMSfit_ATLASfit_spectra_pp.pdf"); TCanvas *cCMS_pp = new TCanvas("cCMS_pp", "",0,0,1200,1000); cCMS_pp->Range(-3.725291e-06,-5.878322,500,3.279288); cCMS_pp->SetFillColor(0); cCMS_pp->SetBorderMode(0); cCMS_pp->SetBorderSize(2); cCMS_pp->SetLogy(); cCMS_pp->SetLogx(); cCMS_pp->SetFrameBorderMode(0); cCMS_pp->SetFrameBorderMode(0); uPP_R4_SVD->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)"); uPP_R4_SVD->GetXaxis()->SetLabelFont(42); uPP_R4_SVD->GetXaxis()->SetLabelSize(0.035); uPP_R4_SVD->GetXaxis()->SetTitleSize(0.035); uPP_R4_SVD->GetXaxis()->SetTitleFont(42); uPP_R4_SVD->GetXaxis()->SetRangeUser(50,450); uPP_R4_SVD->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dp_{T} d#eta} nb"); uPP_R4_SVD->GetYaxis()->SetLabelFont(42); uPP_R4_SVD->GetYaxis()->SetLabelSize(0.035); uPP_R4_SVD->GetYaxis()->SetTitleSize(0.035); uPP_R4_SVD->GetYaxis()->SetTitleFont(42); uPP_R4_SVD->GetZaxis()->SetLabelFont(42); uPP_R4_SVD->GetZaxis()->SetLabelSize(0.035); uPP_R4_SVD->GetZaxis()->SetTitleSize(0.035); uPP_R4_SVD->GetZaxis()->SetTitleFont(42); uPP_R4_SVD->Draw(); TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(10); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("NULL","","h"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(33); entry->SetMarkerSize(1); entry=leg->AddEntry("uPP_R4_SVD","CMS pp","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#0000ff"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(24); entry->SetMarkerSize(1); leg->Draw(); TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *text = pt->AddText(" "); pt->Draw(); cCMS_pp->Modified(); cCMS_pp->cd(); cCMS_pp->SetSelected(cCMS_pp); cCMS_pp->SaveAs("Plots/CMSfit_spectra_pp.pdf"); TCanvas *cATLAS_lin_pp = new TCanvas("cATLAS_lin_pp", "",0,0,1200,1000); cATLAS_lin_pp->Range(-3.725291e-06,-5.878322,500,3.279288); cATLAS_lin_pp->SetFillColor(0); cATLAS_lin_pp->SetBorderMode(0); cATLAS_lin_pp->SetBorderSize(2); cATLAS_lin_pp->SetFrameBorderMode(0); cATLAS_lin_pp->SetFrameBorderMode(0); cATLAS_lin_pp->SetLogy(); cATLAS_lin_pp->SetLogx(); hATLASpp->Draw(); grae->Draw("ap,same"); TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(10); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("NULL","","h"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(62); entry=leg->AddEntry("/HepData/8719/d2x1y1","ATLAS pp","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(33); entry->SetMarkerSize(1); entry=leg->AddEntry("uPP_R4_SVD","CMS pp","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#0000ff"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(24); entry->SetMarkerSize(1); leg->Draw(); TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *text = pt->AddText(" "); pt->Draw(); cATLAS_lin_pp->Modified(); cATLAS_lin_pp->cd(); cATLAS_lin_pp->SetSelected(cATLAS_lin_pp); // for(int ic=0; ic<nfit; ic++){ // uPP_R4_SVD->Fit("fitppCMS","IL","",60,FitEnd); //fit function // // uPP_R4_SVD->Fit("fitppCMS","IL","",50,300); //fit function // } hATLASpp->Draw(); grae->Draw("ap,same"); uPP_R4_SVD->Draw("same E1"); leg->Draw(); cATLAS_lin_pp->SaveAs("Plots/CMSfit_ATLASfit_spectra_loglog_pp.pdf"); fitppCMS->SetBit(TF1::kNotDraw); fitppCMS->SetLineColor(0); uPP_R4_SVD->SetBit(TF1::kNotDraw); TH1F *hFitRatioATLAS = (TH1F*)functionHist(fitppCMS,uPP_R4_SVD,"hFitRatioATLAS"); //clone fitRatioATLAS from fitppCMS // hFitRatioATLAS->SetLineColor(0); TH1F *hRatioATLAS = (TH1F*)uPP_R4_SVD->Clone("hRatioATLAS"); //clone histogram hRatio from h TH1F *hfunctionATLAS = (TH1F*)functionHist(fitppATLAS,uPP_R4_SVD,"hfunctionATLAS"); hFitRatioATLAS->Divide(hfunctionATLAS); hFitRatioATLAS->SetMarkerColor(kRed); hFitRatioATLAS->SetMarkerStyle(21); hFitRatioATLAS->SetMarkerSize(1.2); hFitRatioATLAS->SetLineColor(0); TH1F *hfunctionATLASHist = (TH1F*)functionHist(fitppATLASHist,uPP_R4_SVD,"hfunctionATLASHist"); TH1F *hRatioATLASHist = (TH1F*)uPP_R4_SVD->Clone("hRatioATLASHist"); //clone histogram hRatio from h hRatioATLASHist->Divide(hfunctionATLASHist); hRatioATLASHist->SetMarkerColor(kGreen+1); hRatioATLASHist->SetMarkerStyle(22); hRatioATLASHist->SetMarkerSize(1.2); hRatioATLASHist->SetLineColor(0); // hfunctionATLAS->Draw(); // hATLASpp->Draw(); hRatioATLAS->Divide(hfunctionATLAS); TCanvas *cRatio_pp = new TCanvas("cRatio_pp", "",0,0,1200,1000); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); cRatio_pp->Range(-50.00001,-6.302699,538.2353,2.631555); cRatio_pp->SetFillColor(0); cRatio_pp->SetBorderMode(0); cRatio_pp->SetBorderSize(0); cRatio_pp->SetTickx(1); cRatio_pp->SetTicky(1); cRatio_pp->SetLeftMargin(0.17); cRatio_pp->SetRightMargin(0.15); cRatio_pp->SetTopMargin(0.03); cRatio_pp->SetBottomMargin(0.15); cRatio_pp->SetFrameLineColor(0); cRatio_pp->SetFrameBorderMode(0); cRatio_pp->SetFrameLineColor(0); cRatio_pp->SetFrameBorderMode(0); TH1F *hRatioBlank = new TH1F("hRatioBlank"," ",100,50,300); hRatioBlank->SetMinimum(0); hRatioBlank->SetMaximum(1.2); hRatioBlank->SetDirectory(0); hRatioBlank->SetStats(0); hRatioBlank->SetFillColor(1); hRatioBlank->SetFillStyle(0); hRatioBlank->SetLineStyle(0); hRatioBlank->SetMarkerStyle(20); hRatioBlank->SetMarkerSize(1.2); hRatioBlank->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)"); hRatioBlank->GetXaxis()->SetLabelFont(42); hRatioBlank->GetXaxis()->SetLabelOffset(0.01); hRatioBlank->GetXaxis()->SetLabelSize(0.045); hRatioBlank->GetXaxis()->SetTitleSize(0.055); hRatioBlank->GetXaxis()->SetTitleFont(42); hRatioBlank->GetYaxis()->SetTitle("CMS/ATLAS #frac{d^{2}#sigma}{dp_{T} d#eta} nb"); hRatioBlank->GetYaxis()->SetLabelFont(42); hRatioBlank->GetYaxis()->SetLabelOffset(0.01); hRatioBlank->GetYaxis()->SetLabelSize(0.045); hRatioBlank->GetYaxis()->SetTitleSize(0.055); hRatioBlank->GetYaxis()->SetTitleOffset(1.5); hRatioBlank->GetYaxis()->SetTitleFont(42); hRatioBlank->GetZaxis()->SetLabelFont(42); hRatioBlank->GetZaxis()->SetLabelSize(0.045); hRatioBlank->GetZaxis()->SetTitleSize(0.035); hRatioBlank->GetZaxis()->SetTitleFont(42); hRatioBlank->Draw(); // hRatioATLAS->Scale(5.3/4); // hFitRatioATLAS->Scale(5.3/4); hFitRatioATLAS->Draw("ap,same"); hRatioATLAS->Draw("ap,same"); hRatioATLASHist->Draw("ap,same"); cRatio_pp->SaveAs("Plots/CMSfit_ATLASfit_ratio_pp.pdf"); }
void quickLifetimeFit(string filename, bool isB0) { setTDRStyle(); TFile *_file0 = TFile::Open(filename.c_str()); TTree *tree = (TTree*)gDirectory->Get("fittree"); TCanvas *c = new TCanvas("c","c",600,800); c->Divide(2,3); int canvasctr(0); string strSigWindow, strBgrWindow; double SoverSB; if (isB0) { strSigWindow = "mass>5.25&&mass<5.31"; strBgrWindow = "mass>5.35&&mass<5.55"; SoverSB = 0.90; // from another fit } else { strSigWindow = "mass>5.60&&mass<5.64"; strBgrWindow = "mass>5.75&&mass<6.30"; SoverSB = 0.60; // from another fit } c->cd(++canvasctr); tree->Draw("mass>>hmsigwindow", strSigWindow.c_str()); TH1F *hmsigwindow = (TH1F*)gDirectory->GetList()->FindObject("hmsigwindow"); const int nSigWindow = hmsigwindow->GetEntries(); c->cd(++canvasctr); tree->Draw("mass>>hbgrwindow", strBgrWindow.c_str()); TH1F *hbgrwindow = (TH1F*)gDirectory->GetList()->FindObject("hbgrwindow"); const int nBgrWindow = hbgrwindow->GetEntries(); const double nSig = nSigWindow * SoverSB; const double nBgr = nSigWindow * (1.-SoverSB); const double scale = (double)nBgr / (double)nBgrWindow; c->cd(++canvasctr); tree->Draw("t>>hsigt(34,-2e-12,15e-12)", strSigWindow.c_str()); TH1F *hsigt = (TH1F*)gDirectory->GetList()->FindObject("hsigt"); gPad->SetLogy(); c->cd(++canvasctr); tree->Draw("t>>hbgrt(34,-2e-12,15e-12)", strBgrWindow.c_str()); TH1F *hbgrt = (TH1F*)gDirectory->GetList()->FindObject("hbgrt"); hbgrt->Scale(scale); gPad->SetLogy(); c->cd(++canvasctr); hsigt->Draw(); hsigt->SetLineColor(4); hbgrt->Draw("same"); hbgrt->SetLineColor(2); gPad->SetLogy(); c->cd(++canvasctr); TH1F *hdiff = new TH1F("hdiff","hdiff",34,-2e-12,15e-12); hdiff->Add(hsigt,hbgrt,1,-1); hdiff->Draw(); gPad->SetLogy(); c->SaveAs("quickFit.pdf"); TCanvas *c2 = new TCanvas("c2","c2",1000,800); hdiff->Draw(); gPad->SetLogy(); }
int main() { ModTDRStyle(); ch::CombineHarvester cb; cb.SetVerbosity(0); cb.ParseDatacard("output/CMSDAS/hgg_8TeV_MVA_cat0145.txt", "hgg", "8TeV", "hgg", 0, "*"); cb.RenameParameter("pdf_data_pol_model_8TeV_cat0_norm", "shapeBkg_bkg_mass_cat0__norm"); cb.RenameParameter("pdf_data_pol_model_8TeV_cat1_norm", "shapeBkg_bkg_mass_cat1__norm"); cb.RenameParameter("pdf_data_pol_model_8TeV_cat4_norm", "shapeBkg_bkg_mass_cat4__norm"); cb.RenameParameter("pdf_data_pol_model_8TeV_cat5_norm", "shapeBkg_bkg_mass_cat5__norm"); cb.SetPdfBins(300); ch::Parameter mh; mh.set_name("MH"); mh.set_val(125); mh.set_err_d(0); mh.set_err_u(0); cb.UpdateParameters({mh}); RooFitResult fitresult = ch::OpenFromTFile<RooFitResult>("output/CMSDAS/hgg_mlfit.root:fit_s"); cb.UpdateParameters(&fitresult); ch::CombineHarvester cb_sig = cb.cp(); cb_sig.bin({"cat4"}).signals(); ch::CombineHarvester cb_bkg = cb.cp(); cb_bkg.bin({"cat4"}).backgrounds(); TFile fout("hgg_output.root", "RECREATE"); TH1F sig_shape = cb_sig.GetShapeWithUncertainty(&fitresult, 500); sig_shape.SetName("sig"); TH1F bkg_shape = cb_bkg.GetShapeWithUncertainty(&fitresult, 500); bkg_shape.SetName("bkg"); TH1F data = cb_sig.GetObservedShape(); sig_shape.Write(); bkg_shape.Write(); data.Write(); TH1::AddDirectory(0); TString canvName = "FigExample"; TCanvas* canv = new TCanvas(canvName, canvName); canv->cd(); std::vector<TPad*> pads = OnePad(); data.Rebin(2); sig_shape.Scale(data.GetBinWidth(1) / sig_shape.GetBinWidth(1)); bkg_shape.Scale(data.GetBinWidth(1) / bkg_shape.GetBinWidth(1)); TH1F err_shape = bkg_shape; std::vector<TH1*> h = CreateAxisHists(1, &data); h[0]->GetXaxis()->SetTitleOffset(1.0); StandardAxes(h[0]->GetXaxis(), h[0]->GetYaxis(), "m_{#gamma#gamma}", "GeV"); h[0]->Draw("axis"); err_shape.SetFillColor(17); err_shape.SetMarkerSize(0); err_shape.Draw("E3SAME"); sig_shape.Add(&bkg_shape); sig_shape.SetLineColor(4); sig_shape.SetLineWidth(3); sig_shape.Draw("SAME HIST C"); bkg_shape.SetLineColor(2); bkg_shape.SetLineWidth(3); bkg_shape.Draw("SAME HIST C"); data.Draw("esamex0"); FixTopRange(pads[0], GetPadYMax(pads[0]), 0.15); // DrawCMSLogo(pads[0], "CMS", "Preliminary", 11, 0.045, 0.035, 1.2); DrawTitle(pads[0], "CombineHarvester", 1); DrawTitle(pads[0], "hgg", 3); // DrawTitle(pads[0], "H#rightarrow#gamma#gamma", 1); TLegend *legend = PositionedLegend(0.35, 0.23, 3, 0.03); legend->SetTextFont(42); FixBoxPadding(pads[0], legend, 0.05); legend->AddEntry(&data, "Observed", "pe"); legend->AddEntry(&bkg_shape, "Background", "l"); legend->AddEntry(&err_shape, "Uncertainty", "f"); legend->AddEntry(&sig_shape, "SM H(125 GeV)#rightarrow#gamma#gamma", "l"); legend->Draw(); canv->Update(); pads[0]->RedrawAxis(); pads[0]->GetFrame()->Draw(); canv->SaveAs("hgg.pdf"); fout.Close(); }
void plot(int mass) { double myQCDRelUncert = 0.038; double myEWKRelUncert = 0.131; double myFakesRelUncert = 0.238; double delta = 1.4; double br = 0.05; bool debug = false; bool log = false; double ymin = 0.001; double ymax = 48; static bool bMessage = false; if (!bMessage) { cout << "Values used as relative uncertainty (please check):" << endl; cout << " QCD: " << myQCDRelUncert << endl; cout << " EWK genuine tau: " << myEWKRelUncert << endl; cout << " EWK fake tau: " << myFakesRelUncert << endl << endl; bMessage = true; } cout << "Processing mass point: " << mass << " GeV/c2" << endl; gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetTitleFont(43, "xyz"); gStyle->SetTitleSize(33, "xyz"); gStyle->SetLabelFont(43, "xyz"); gStyle->SetLabelSize(27, "xyz"); //std::string infile = "EPS_data_nodeltaphi/hplus_100.root"; //std::string infile = "EPS_data_deltaphi160/hplus_100.root"; std::stringstream s; s << "lands_histograms_hplushadronic_m" << mass << ".root"; std::string infile = s.str(); // Canvas TCanvas *myCanvas = new TCanvas("myCanvas", "",0,0,600,600); myCanvas->SetHighLightColor(2); myCanvas->Range(0,0,1,1); myCanvas->SetFillColor(0); myCanvas->SetBorderMode(0); myCanvas->SetBorderSize(2); if (log) myCanvas->SetLogy(); myCanvas->SetTickx(1); myCanvas->SetTicky(1); myCanvas->SetLeftMargin(0.16); myCanvas->SetRightMargin(0.05); myCanvas->SetTopMargin(0.05); myCanvas->SetBottomMargin(0.08); myCanvas->SetFrameFillStyle(0); myCanvas->SetFrameBorderMode(0); myCanvas->SetFrameFillStyle(0); myCanvas->SetFrameBorderMode(0); myCanvas->cd(); Int_t ci; TFile* f = TFile::Open(infile.c_str()); s.str(""); s << "HW" << mass << "_1"; TH1* hw = (TH1*)f->Get(s.str().c_str()); s.str(""); s << "HH" << mass << "_1"; TH1* hh = (TH1*)f->Get(s.str().c_str()); TH1* data = (TH1*)f->Get("data_obs"); data->SetLineWidth(2); data->SetMarkerStyle(20); data->SetMarkerSize(1.2); TH1* ewktau = (TH1*)f->Get("EWK_Tau"); ci = TColor::GetColor("#993399"); ewktau->SetFillColor(ci); ewktau->SetLineWidth(0); TH1* ewkDY = (TH1*)f->Get("EWK_DYx"); TH1* ewkVV = (TH1*)f->Get("EWK_VVx"); ewktau->Add(ewkDY); ewktau->Add(ewkVV); //TH1* qcd = (TH1*)f->Get("QCDInv"); TH1* qcd = (TH1*)f->Get("QCD"); ci = TColor::GetColor("#ffcc33"); qcd->SetFillColor(ci); qcd->SetLineWidth(0); TH1* fakett = (TH1*)f->Get("fake_tt"); ci = TColor::GetColor("#669900"); fakett->SetFillColor(ci); fakett->SetLineWidth(0); TH1* fakeW = (TH1*)f->Get("fake_W"); ci = TColor::GetColor("#cc3300"); fakeW->SetFillColor(ci); fakeW->SetLineWidth(0); TH1* faket = (TH1*)f->Get("fake_t"); TH1F *hFrame = new TH1F("hFrame","",20,0,400); hFrame->SetMinimum(ymin); if (log) hFrame->SetMaximum(ymax*1.5); else hFrame->SetMaximum(ymax); hFrame->SetDirectory(0); hFrame->SetStats(0); hFrame->SetLineStyle(0); hFrame->SetMarkerStyle(20); hFrame->SetXTitle("Transverse mass (#tau jet, E_{T}^{miss}), (GeV/c^{2})"); if (paperStatus) hFrame->SetXTitle("Transverse mass (#tau_{h}, E_{T}^{miss}), (GeV/c^{2})"); hFrame->SetYTitle("Events / 20 GeV/c^{2}"); hFrame->GetXaxis()->SetTitleSize(0); hFrame->GetXaxis()->SetLabelSize(0); hFrame->GetYaxis()->SetTitleFont(43); hFrame->GetYaxis()->SetTitleSize(27); hFrame->GetYaxis()->SetTitleOffset(1.3); // signal hh->Scale(br*br); hw->Scale(2*br*(1.0-br)); TH1* signal = (TH1*)hh->Clone(); signal->Add(hw); ci = TColor::GetColor("#ff3399"); signal->SetLineColor(ci); signal->SetLineStyle(2); signal->SetLineWidth(2); // Fakes TH1* fakes = (TH1*)(fakett->Clone()); fakes->Add(fakeW); fakes->Add(faket); // stacked backgrounds THStack *exp = new THStack(); exp->SetName("exp"); exp->SetTitle("exp"); exp->Add(fakes); exp->Add(ewktau); exp->Add(qcd); exp->Add(signal); TH1* hExpBkg = (TH1*)fakes->Clone(); hExpBkg->Add(ewktau); hExpBkg->Add(qcd); // uncertainty TH1* uncert = (TH1*)fakeW->Clone(); uncert->Add(fakett); uncert->Add(ewktau); uncert->Add(qcd); uncert->SetFillColor(1); uncert->SetFillStyle(3344); uncert->SetLineColor(0); uncert->SetLineStyle(0); uncert->SetLineWidth(0); TH1* hExpBkgTotalUncert = (TH1*)uncert->Clone(); hExpBkgTotalUncert->SetFillStyle(3354); TH1* hAgreement = (TH1*)data->Clone(); hAgreement->Divide(hExpBkg); TGraphErrors* hAgreementRelUncert = new TGraphErrors(hAgreement->GetNbinsX()); hAgreementRelUncert->SetLineWidth(2); hAgreementRelUncert->SetLineColor(kBlack); for (int i = 1; i <= hFrame->GetNbinsX(); ++i) { double myQCDTotalUncert = TMath::Power(qcd->GetBinError(i), 2) + TMath::Power(qcd->GetBinContent(i)*myQCDRelUncert, 2); double myEWKTotalUncert = TMath::Power(ewktau->GetBinError(i), 2) + TMath::Power(ewktau->GetBinContent(i)*myEWKRelUncert, 2); double myFakesTotalUncert = TMath::Power(fakes->GetBinError(i), 2) + TMath::Power(fakes->GetBinContent(i)*myFakesRelUncert, 2); hExpBkgTotalUncert->SetBinError(i, TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert)); if (hExpBkg->GetBinContent(i) > 0) { hAgreementRelUncert->SetPoint(i-1, hExpBkg->GetBinCenter(i), data->GetBinContent(i) / hExpBkg->GetBinContent(i)); double myUncertData = 0; if (data->GetBinContent(i) > 0) myUncertData = TMath::Power(data->GetBinError(i) / data->GetBinContent(i), 2); double myUncertBkg = (myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) / TMath::Power(hExpBkg->GetBinContent(i), 2); hAgreementRelUncert->SetPointError(i-1, 0, data->GetBinContent(i) / hExpBkg->GetBinContent(i) * TMath::Sqrt(myUncertData + myUncertBkg)); } else { hAgreementRelUncert->SetPoint(i-1, hExpBkg->GetBinCenter(i), 0); hAgreementRelUncert->SetPointError(i-1, 0, 0); } if (debug) { cout << "Point: " << hAgreementRelUncert->GetX()[i-1]-10 << "-" << hAgreementRelUncert->GetX()[i-1]+10 << " GeV/c2, agreement: " << hAgreementRelUncert->GetY()[i-1] << ", uncert: " << hAgreement->GetBinError(i) << ", " << hAgreementRelUncert->GetErrorY(i-1) << endl; cout << " bkg. stat. uncert. " << hExpBkg->GetBinError(i) << " (i.e. " << hExpBkg->GetBinError(i) / hExpBkg->GetBinContent(i) * 100.0 << " %)" << ", stat+syst uncert. " << TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) << " (i.e. " << TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) / hExpBkg->GetBinContent(i) * 100.0 << " %)" << endl; } } // Agreement pad TPad* pad = new TPad("ratiopad","ratiopad",0.,0.,1.,.3); pad->Draw(); pad->cd(); pad->Range(0,0,1,1); pad->SetFillColor(0); pad->SetFillStyle(4000); pad->SetBorderMode(0); pad->SetBorderSize(2); pad->SetTickx(1); pad->SetTicky(1); pad->SetLeftMargin(0.16); pad->SetRightMargin(0.05); pad->SetTopMargin(0); pad->SetBottomMargin(0.34); pad->SetFrameFillStyle(0); pad->SetFrameBorderMode(0); // Plot here ratio if (1.0-delta > 0) hAgreement->SetMinimum(1.0-delta); else hAgreement->SetMinimum(0.); hAgreement->SetMaximum(1.0+delta); hAgreement->GetXaxis()->SetLabelOffset(0.007); hAgreement->GetXaxis()->SetLabelFont(43); hAgreement->GetXaxis()->SetLabelSize(27); hAgreement->GetYaxis()->SetLabelFont(43); hAgreement->GetYaxis()->SetLabelSize(27); hAgreement->GetYaxis()->SetLabelOffset(0.007); hAgreement->GetYaxis()->SetNdivisions(505); hAgreement->GetXaxis()->SetTitleFont(43); hAgreement->GetYaxis()->SetTitleFont(43); hAgreement->GetXaxis()->SetTitleSize(33); hAgreement->GetYaxis()->SetTitleSize(33); hAgreement->SetTitleSize(27, "xyz"); hAgreement->GetXaxis()->SetTitleOffset(3.2); hAgreement->GetYaxis()->SetTitleOffset(1.3); hAgreement->SetXTitle(hFrame->GetXaxis()->GetTitle()); hAgreement->SetYTitle("Data/#Sigmabkg"); hAgreement->Draw("e2"); // Plot line at zero TH1* hAgreementLine = dynamic_cast<TH1*>(hAgreement->Clone()); for (int i = 1; i <= hAgreementLine->GetNbinsX(); ++i) { hAgreementLine->SetBinContent(i,1.0); hAgreementLine->SetBinError(i,0.0); } hAgreementLine->SetLineColor(kRed); hAgreementLine->SetLineWidth(2); hAgreementLine->SetLineStyle(3); hAgreementLine->Draw("hist same"); hAgreement->Draw("same"); hAgreementRelUncert->Draw("[]"); pad->RedrawAxis(); myCanvas->cd(); TPad* plotpad = new TPad("plotpad", "plotpad",0,0.3,1.,1.); plotpad->Draw(); plotpad->cd(); plotpad->Range(0,0,1,1); plotpad->SetFillColor(0); plotpad->SetFillStyle(4000); plotpad->SetBorderMode(0); plotpad->SetBorderSize(2); //if (logy) // plotpad->SetLogy(); plotpad->SetTickx(1); plotpad->SetTicky(1); plotpad->SetLeftMargin(0.16); plotpad->SetRightMargin(0.05); plotpad->SetTopMargin(0.065); plotpad->SetBottomMargin(0.0); plotpad->SetFrameFillStyle(0); plotpad->SetFrameBorderMode(0); hFrame->GetXaxis()->SetTitleSize(0); hFrame->GetXaxis()->SetLabelSize(0); hFrame->GetYaxis()->SetTitleFont(43); hFrame->GetYaxis()->SetTitleSize(33); hFrame->GetYaxis()->SetTitleOffset(1.3); // Draw objects hFrame->Draw(); exp->Draw("hist same"); uncert->Draw("E2 same"); hExpBkgTotalUncert->Draw("E2 same"); // Data data->Draw("same"); //signal->Draw("same"); TLegend *leg = new TLegend(0.53,0.6,0.87,0.91,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(63); leg->SetTextSize(18); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(kWhite); //leg->SetFillStyle(4000); // enabling this will cause the plot to be erased from the pad TLegendEntry* entry = leg->AddEntry(data, "Data", "P"); s.str(""); s << "with H^{#pm}#rightarrow#tau^{#pm}#nu"; entry = leg->AddEntry(signal, s.str().c_str(), "L"); entry = leg->AddEntry(qcd, "QCD (meas.)", "F"); entry = leg->AddEntry(ewktau, "EWK genuine #tau (meas.)", "F"); entry = leg->AddEntry(fakes, "EWK fake #tau (MC)", "F"); entry = leg->AddEntry(uncert, "stat. uncert.", "F"); entry = leg->AddEntry(hExpBkgTotalUncert, "stat. #oplus syst. uncert.", "F"); leg->Draw(); string myTitle = "CMS Preliminary"; if (paperStatus) myTitle = "CMS"; TLatex *tex = new TLatex(0.62,0.945,myTitle.c_str()); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.2,0.945,"#sqrt{s} = 7 TeV"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.43,0.945,"2.2 fb^{-1}"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); s.str(""); s << "m_{H^{#pm}} = " << mass << " GeV/c^{2}"; tex = new TLatex(0.28,0.865,s.str().c_str()); tex->SetNDC(); tex->SetTextFont(63); tex->SetTextSize(20); tex->SetLineWidth(2); tex->Draw(); s.str(""); s << "BR(t#rightarrowbH^{#pm})=" << setprecision(2) << br; tex = new TLatex(0.28,0.805,s.str().c_str()); tex->SetNDC(); tex->SetTextFont(63); tex->SetTextSize(20); tex->SetLineWidth(2); tex->Draw(); plotpad->RedrawAxis(); plotpad->Modified(); s.str(""); s << "mT_datadriven_m" << mass << ".png"; myCanvas->Print(s.str().c_str()); s.str(""); s << "mT_datadriven_m" << mass << ".C"; myCanvas->Print(s.str().c_str()); s.str(""); s << "mT_datadriven_m" << mass << ".eps"; myCanvas->Print(s.str().c_str()); }
void DrawMLPoutputMovie( TFile* file, const TString& methodType, const TString& methodTitle ) { gROOT->SetBatch( 1 ); // define Canvas layout here! const Int_t width = 600; // size of canvas // this defines how many canvases we need TCanvas* c = 0; Float_t nrms = 4; Float_t xmin = -1.2; Float_t xmax = 1.2; Float_t ymin = 0; Float_t ymax = 0; Float_t maxMult = 6.0; Int_t countCanvas = 0; Bool_t first = kTRUE; TString dirname = methodType + "/" + methodTitle + "/" + "EpochMonitoring"; TDirectory *epochDir = (TDirectory*)file->Get( dirname ); if (!epochDir) { cout << "Big troubles: could not find directory \"" << dirname << "\"" << endl; exit(1); } // now read all evolution histograms TIter keyItTit(epochDir->GetListOfKeys()); TKey *titkeyTit; while ((titkeyTit = (TKey*)keyItTit())) { if (!gROOT->GetClass(titkeyTit->GetClassName())->InheritsFrom("TH1F")) continue; TString name = titkeyTit->GetName(); if (!name.BeginsWith("convergencetest___")) continue; if (!name.Contains("_train_")) continue; // only for training so far if (name.EndsWith( "_B")) continue; // must be signal histogram if (!name.EndsWith( "_S")) { cout << "Big troubles with histogram: " << name << " -> should end with _S" << endl; exit(1); } // create canvas countCanvas++; TString ctitle = Form("TMVA response %s",methodTitle.Data()); c = new TCanvas( Form("canvas%d", countCanvas), ctitle, 0, 0, width, (Int_t)width*0.78 ); TH1F* sig = (TH1F*)titkeyTit->ReadObj(); sig->SetTitle( Form("TMVA response for classifier: %s", methodTitle.Data()) ); TString dataType = (name.Contains("_train_") ? "(training sample)" : "(test sample)"); // find background TString nbn = sig->GetName(); nbn[nbn.Length()-1] = 'B'; TH1F* bgd = dynamic_cast<TH1F*>(epochDir->Get( nbn )); if (bgd == 0) { cout << "Big troubles with histogram: " << bgd << " -> cannot find!" << endl; exit(1); } cout << "sig = " << sig->GetName() << endl; cout << "bgd = " << bgd->GetName() << endl; // set the histogram style TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd ); // normalise both signal and background TMVAGlob::NormalizeHists( sig, bgd ); // set only first time, then same for all plots if (first) { if (xmin == 0 && xmax == 0) { xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(), bgd->GetMean() - nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmin() ); xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(), bgd->GetMean() + nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmax() ); } ymin = 0; ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult; first = kFALSE; } // build a frame Int_t nb = 100; TString hFrameName(TString("frame") + methodTitle); TObject *o = gROOT->FindObject(hFrameName); if(o) delete o; TH2F* frame = new TH2F( hFrameName, sig->GetTitle(), nb, xmin, xmax, nb, ymin, ymax ); frame->GetXaxis()->SetTitle( methodTitle + " response" ); frame->GetYaxis()->SetTitle("(1/N) dN^{ }/^{ }dx"); TMVAGlob::SetFrameStyle( frame ); // find epoch number (4th token) TObjArray* tokens = name.Tokenize("_"); TString es = ((TObjString*)tokens->At(4))->GetString(); if (!es.IsFloat()) { cout << "Big troubles in epoch parsing: \"" << es << "\" is not float" << endl; exit(1); } Int_t epoch = es.Atoi(); // eventually: draw the frame frame->Draw(); c->GetPad(0)->SetLeftMargin( 0.105 ); frame->GetYaxis()->SetTitleOffset( 1.2 ); // Draw legend TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12, c->GetLeftMargin() + 0.5, 1 - c->GetTopMargin() ); legend->SetFillStyle( 1 ); legend->AddEntry(sig,TString("Signal ") + dataType, "F"); legend->AddEntry(bgd,TString("Background ") + dataType, "F"); legend->SetBorderSize(1); legend->SetMargin( 0.15 ); legend->Draw("same"); TText* t = new TText(); t->SetTextSize( 0.04 ); t->SetTextColor( 1 ); t->SetTextAlign( 31 ); t->DrawTextNDC( 1 - c->GetRightMargin(), 1 - c->GetTopMargin() + 0.015, Form( "Epoch: %i", epoch) ); // overlay signal and background histograms sig->Draw("samehist"); bgd->Draw("samehist"); // save to file TString dirname = "movieplots"; TString foutname = dirname + "/" + name; foutname.Resize( foutname.Length()-2 ); foutname.ReplaceAll("convergencetest___",""); foutname += ".gif"; cout << "storing file: " << foutname << endl; c->Update(); c->Print(foutname); } }
void gyieldsp() { //=========Macro generated from canvas: c1/c1 //========= (Fri Jul 31 19:31:43 2015) by ROOT version6.05/01 TCanvas *c1 = new TCanvas("c1", "c1",0,23,600,600); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c1->Range(0,0,1,1); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.16); c1->SetRightMargin(0.04); c1->SetTopMargin(0.08); c1->SetBottomMargin(0.12); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); // ------------>Primitives in pad: pad1 TPad *pad1 = new TPad("pad1", "pad1",0,0.26,1,1); pad1->Draw(); pad1->cd(); pad1->Range(-3.5,-6.621622,2.75,158.9189); pad1->SetFillColor(0); pad1->SetBorderMode(0); pad1->SetBorderSize(2); pad1->SetTickx(1); pad1->SetTicky(1); pad1->SetLeftMargin(0.16); pad1->SetRightMargin(0.04); pad1->SetTopMargin(0.1142857); pad1->SetBottomMargin(0.04); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); Double_t Graph0_fx3021[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph0_fy3021[10] = { 103.56, 105.744, 103.4081, 100.0093, 97.03688, 94.36609, 90.5471, 82.43278, 65.82142, 43.43165}; Double_t Graph0_felx3021[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph0_fely3021[10] = { 7.299733, 7.206486, 6.824632, 6.594841, 6.406375, 6.079494, 5.746822, 5.225105, 4.165823, 2.787035}; Double_t Graph0_fehx3021[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph0_fehy3021[10] = { 5.988963, 6.218694, 6.307709, 6.368316, 5.847823, 5.655323, 5.083818, 4.561256, 3.722445, 2.542957}; TGraphAsymmErrors *grae = new TGraphAsymmErrors(10,Graph0_fx3021,Graph0_fy3021,Graph0_felx3021,Graph0_fehx3021,Graph0_fely3021,Graph0_fehy3021); grae->SetName("Graph0"); grae->SetTitle("Graph"); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#ffff00"); grae->SetFillColor(ci); ci = TColor::GetColor("#ff0000"); grae->SetLineColor(ci); grae->SetLineWidth(4); grae->SetMarkerStyle(20); grae->SetMarkerSize(0); TH1F *Graph_Graph3021 = new TH1F("Graph_Graph3021","Graph",100,-2.5,2.5); Graph_Graph3021->SetMinimum(0); Graph_Graph3021->SetMaximum(140); Graph_Graph3021->SetDirectory(0); Graph_Graph3021->SetStats(0); Graph_Graph3021->SetLineStyle(0); Graph_Graph3021->SetMarkerStyle(20); Graph_Graph3021->GetXaxis()->SetNdivisions(505); Graph_Graph3021->GetXaxis()->SetLabelFont(42); Graph_Graph3021->GetXaxis()->SetLabelOffset(0.007); Graph_Graph3021->GetXaxis()->SetLabelSize(0); Graph_Graph3021->GetXaxis()->SetTitleSize(0.07142857); Graph_Graph3021->GetXaxis()->SetTitleOffset(1.1); Graph_Graph3021->GetXaxis()->SetTitleFont(42); Graph_Graph3021->GetYaxis()->SetTitle("d#sigma (W^{+}#rightarrow#font[12]{l}^{+}#nu) / d#eta_{lab} [nb]"); Graph_Graph3021->GetYaxis()->SetLabelFont(42); Graph_Graph3021->GetYaxis()->SetLabelOffset(0.007); Graph_Graph3021->GetYaxis()->SetLabelSize(0.07142857); Graph_Graph3021->GetYaxis()->SetTitleSize(0.07142857); Graph_Graph3021->GetYaxis()->SetTitleOffset(1.05); Graph_Graph3021->GetYaxis()->SetTitleFont(42); Graph_Graph3021->GetZaxis()->SetLabelFont(42); Graph_Graph3021->GetZaxis()->SetLabelOffset(0.007); Graph_Graph3021->GetZaxis()->SetLabelSize(0.05); Graph_Graph3021->GetZaxis()->SetTitleSize(0.06); Graph_Graph3021->GetZaxis()->SetTitleFont(42); grae->SetHistogram(Graph_Graph3021); grae->Draw("a2"); Double_t Graph1_fx3022[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph1_fy3022[10] = { 103.56, 105.744, 103.4081, 100.0093, 97.03688, 94.36609, 90.5471, 82.43278, 65.82142, 43.43165}; Double_t Graph1_felx3022[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph1_fely3022[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Double_t Graph1_fehx3022[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph1_fehy3022[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; grae = new TGraphAsymmErrors(10,Graph1_fx3022,Graph1_fy3022,Graph1_felx3022,Graph1_fehx3022,Graph1_fely3022,Graph1_fehy3022); grae->SetName("Graph1"); grae->SetTitle("Graph"); ci = TColor::GetColor("#ffff00"); grae->SetFillColor(ci); ci = TColor::GetColor("#ff0000"); grae->SetLineColor(ci); grae->SetLineWidth(4); grae->SetMarkerStyle(20); grae->SetMarkerSize(0); grae->Draw("z"); Double_t Graph2_fx3023[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph2_fy3023[10] = { 91.59545, 95.26883, 95.65156, 95.47892, 95.94693, 96.02597, 93.3635, 84.56484, 65.95871, 42.11706}; Double_t Graph2_felx3023[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph2_fely3023[10] = { 8.336985, 8.261181, 7.634488, 6.438496, 6.661149, 6.164321, 6.1019, 4.954787, 4.773841, 2.599375}; Double_t Graph2_fehx3023[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph2_fehy3023[10] = { 8.262572, 7.14746, 6.62492, 6.725295, 5.946212, 5.838684, 5.077774, 5.257491, 3.443198, 2.602454}; grae = new TGraphAsymmErrors(10,Graph2_fx3023,Graph2_fy3023,Graph2_felx3023,Graph2_fehx3023,Graph2_fely3023,Graph2_fehy3023); grae->SetName("Graph2"); grae->SetTitle("Graph"); ci = TColor::GetColor("#009900"); grae->SetFillColor(ci); grae->SetFillStyle(3375); ci = TColor::GetColor("#009900"); grae->SetLineColor(ci); grae->SetLineStyle(7); grae->SetLineWidth(4); grae->SetMarkerStyle(20); TH1F *Graph_Graph3023 = new TH1F("Graph_Graph3023","Graph",100,-2.88,2.88); Graph_Graph3023->SetMinimum(33.22782); Graph_Graph3023->SetMaximum(108.7062); Graph_Graph3023->SetDirectory(0); Graph_Graph3023->SetStats(0); Graph_Graph3023->SetLineStyle(0); Graph_Graph3023->SetMarkerStyle(20); Graph_Graph3023->GetXaxis()->SetLabelFont(42); Graph_Graph3023->GetXaxis()->SetLabelOffset(0.007); Graph_Graph3023->GetXaxis()->SetLabelSize(0.05); Graph_Graph3023->GetXaxis()->SetTitleSize(0.06); Graph_Graph3023->GetXaxis()->SetTitleOffset(1.1); Graph_Graph3023->GetXaxis()->SetTitleFont(42); Graph_Graph3023->GetYaxis()->SetLabelFont(42); Graph_Graph3023->GetYaxis()->SetLabelOffset(0.007); Graph_Graph3023->GetYaxis()->SetLabelSize(0.05); Graph_Graph3023->GetYaxis()->SetTitleSize(0.06); Graph_Graph3023->GetYaxis()->SetTitleOffset(1.5); Graph_Graph3023->GetYaxis()->SetTitleFont(42); Graph_Graph3023->GetZaxis()->SetLabelFont(42); Graph_Graph3023->GetZaxis()->SetLabelOffset(0.007); Graph_Graph3023->GetZaxis()->SetLabelSize(0.05); Graph_Graph3023->GetZaxis()->SetTitleSize(0.06); Graph_Graph3023->GetZaxis()->SetTitleFont(42); grae->SetHistogram(Graph_Graph3023); grae->Draw("2"); Double_t Graph3_fx3024[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph3_fy3024[10] = { 91.59545, 95.26883, 95.65156, 95.47892, 95.94693, 96.02597, 93.3635, 84.56484, 65.95871, 42.11706}; Double_t Graph3_felx3024[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph3_fely3024[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Double_t Graph3_fehx3024[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph3_fehy3024[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; grae = new TGraphAsymmErrors(10,Graph3_fx3024,Graph3_fy3024,Graph3_felx3024,Graph3_fehx3024,Graph3_fely3024,Graph3_fehy3024); grae->SetName("Graph3"); grae->SetTitle("Graph"); ci = TColor::GetColor("#009900"); grae->SetFillColor(ci); grae->SetFillStyle(3375); ci = TColor::GetColor("#009900"); grae->SetLineColor(ci); grae->SetLineStyle(7); grae->SetLineWidth(4); grae->SetMarkerStyle(20); grae->Draw("z"); Double_t Graph4_fx1011[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph4_fy1011[10] = { 108.0732, 102.2597, 100.2246, 101.796, 105.3416, 99.73788, 98.62062, 85.94448, 62.90271, 44.47931}; Double_t Graph4_fex1011[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Double_t Graph4_fey1011[10] = { 6.667786, 4.792637, 3.765295, 3.224798, 3.479167, 3.377478, 3.07273, 3.40604, 2.800731, 2.87761}; TGraphErrors *gre = new TGraphErrors(10,Graph4_fx1011,Graph4_fy1011,Graph4_fex1011,Graph4_fey1011); gre->SetName("Graph4"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetFillStyle(0); gre->SetLineWidth(2); gre->SetMarkerStyle(20); gre->Draw("||"); Double_t gyieldsp_exp_statonly_1_fx1012[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t gyieldsp_exp_statonly_1_fy1012[10] = { 108.0732, 102.2597, 100.2246, 101.796, 105.3416, 99.73788, 98.62062, 85.94448, 62.90271, 44.47931}; Double_t gyieldsp_exp_statonly_1_fex1012[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Double_t gyieldsp_exp_statonly_1_fey1012[10] = { 2.814265, 2.293805, 2.181326, 2.056934, 2.054972, 2.059018, 2.050204, 2.01317, 1.754638, 1.667829}; gre = new TGraphErrors(10,gyieldsp_exp_statonly_1_fx1012,gyieldsp_exp_statonly_1_fy1012,gyieldsp_exp_statonly_1_fex1012,gyieldsp_exp_statonly_1_fey1012); gre->SetName("gyieldsp_exp_statonly_1"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineWidth(2); gre->SetMarkerStyle(20); gre->SetMarkerSize(1.2); TH1F *Graph_gyieldsp_exp_statonly_11012 = new TH1F("Graph_gyieldsp_exp_statonly_11012","Graph",100,-2.64,2.64); Graph_gyieldsp_exp_statonly_11012->SetMinimum(36.00388); Graph_gyieldsp_exp_statonly_11012->SetMaximum(117.6951); Graph_gyieldsp_exp_statonly_11012->SetDirectory(0); Graph_gyieldsp_exp_statonly_11012->SetStats(0); Graph_gyieldsp_exp_statonly_11012->SetLineStyle(0); Graph_gyieldsp_exp_statonly_11012->SetMarkerStyle(20); Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelFont(42); Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelOffset(0.007); Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelSize(0.05); Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleSize(0.06); Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleOffset(1.1); Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleFont(42); Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelFont(42); Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelOffset(0.007); Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelSize(0.05); Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleSize(0.06); Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleOffset(1.5); Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleFont(42); Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelFont(42); Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelOffset(0.007); Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelSize(0.05); Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetTitleSize(0.06); Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_gyieldsp_exp_statonly_11012); gre->Draw("pz"); TLegend *leg = new TLegend(0.6,0.1,0.9,0.3142857,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.05714286); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("Graph4","Data","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(20); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("Graph0","CT10","lf"); ci = TColor::GetColor("#ffff00"); entry->SetFillColor(ci); entry->SetFillStyle(1001); ci = TColor::GetColor("#ff0000"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(4); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("Graph2","CT10+EPS09","lf"); ci = TColor::GetColor("#009900"); entry->SetFillColor(ci); entry->SetFillStyle(3375); ci = TColor::GetColor("#009900"); entry->SetLineColor(ci); entry->SetLineStyle(7); entry->SetLineWidth(4); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); TPaveText *pt = new TPaveText(-2.35,125,-0.35,140,"br"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextAlign(13); pt->SetTextFont(42); pt->SetTextSize(0.05714286); TText *AText = pt->AddText("Luminosity uncertainty: 3.5%"); pt->Draw(); pt = new TPaveText(0.27,0.2,0.5,0.3428571,"brNDC"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextAlign(13); pt->SetTextFont(42); pt->SetTextSize(0.05714286); AText = pt->AddText("W^{+} #rightarrow #font[12]{l}^{+} + #nu"); AText = pt->AddText("p_{T}^{#font[12]{l}} > 25 GeV/c"); pt->Draw(); tex = new TLatex(0.96,0.9177143," #sqrt{s_{NN}} = 5.02 TeV"); tex->SetNDC(); tex->SetTextAlign(31); tex->SetTextFont(42); tex->SetTextSize(0.05714286); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.16,0.9177143,"pPb 34.6 nb^{-1}"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.05714286); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.924,0.8476571,"CMS"); tex->SetNDC(); tex->SetTextAlign(33); tex->SetTextFont(61); tex->SetTextSize(0.06857143); tex->SetLineWidth(2); tex->Draw(); TH1F *Graph_copy = new TH1F("Graph_copy","Graph",100,-2.5,2.5); Graph_copy->SetMinimum(0); Graph_copy->SetMaximum(140); Graph_copy->SetDirectory(0); Graph_copy->SetStats(0); Graph_copy->SetLineStyle(0); Graph_copy->SetMarkerStyle(20); Graph_copy->GetXaxis()->SetNdivisions(505); Graph_copy->GetXaxis()->SetLabelFont(42); Graph_copy->GetXaxis()->SetLabelOffset(0.007); Graph_copy->GetXaxis()->SetLabelSize(0); Graph_copy->GetXaxis()->SetTitleSize(0.07142857); Graph_copy->GetXaxis()->SetTitleOffset(1.1); Graph_copy->GetXaxis()->SetTitleFont(42); Graph_copy->GetYaxis()->SetTitle("d#sigma (W^{+}#rightarrow#font[12]{l}^{+}#nu) / d#eta_{lab} [nb]"); Graph_copy->GetYaxis()->SetLabelFont(42); Graph_copy->GetYaxis()->SetLabelOffset(0.007); Graph_copy->GetYaxis()->SetLabelSize(0.07142857); Graph_copy->GetYaxis()->SetTitleSize(0.07142857); Graph_copy->GetYaxis()->SetTitleOffset(1.05); Graph_copy->GetYaxis()->SetTitleFont(42); Graph_copy->GetZaxis()->SetLabelFont(42); Graph_copy->GetZaxis()->SetLabelOffset(0.007); Graph_copy->GetZaxis()->SetLabelSize(0.05); Graph_copy->GetZaxis()->SetTitleSize(0.06); Graph_copy->GetZaxis()->SetTitleFont(42); Graph_copy->Draw("sameaxis"); pad1->Modified(); c1->cd(); // ------------>Primitives in pad: pad2 TPad *pad2 = new TPad("pad2", "pad2",0,0,1,0.288); pad2->Draw(); pad2->cd(); pad2->Range(-3.5,0.35,2.75,1.35); pad2->SetFillColor(0); pad2->SetFillStyle(4000); pad2->SetBorderMode(0); pad2->SetBorderSize(2); pad2->SetTickx(1); pad2->SetTicky(1); pad2->SetLeftMargin(0.16); pad2->SetRightMargin(0.04); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.4); pad2->SetFrameFillStyle(4000); pad2->SetFrameBorderMode(0); pad2->SetFrameFillStyle(4000); pad2->SetFrameBorderMode(0); TH1F *Graph = new TH1F("Graph","Graph",100,-2.5,2.5); Graph->SetMinimum(0.75); Graph->SetMaximum(1.35); Graph->SetDirectory(0); Graph->SetStats(0); Graph->SetLineStyle(0); Graph->SetMarkerStyle(20); Graph->GetXaxis()->SetTitle("#eta_{lab}"); Graph->GetXaxis()->SetNdivisions(505); Graph->GetXaxis()->SetLabelFont(42); Graph->GetXaxis()->SetLabelOffset(0.007); Graph->GetXaxis()->SetLabelSize(0.1666667); Graph->GetXaxis()->SetTitleSize(0.1666667); Graph->GetXaxis()->SetTitleOffset(1.1); Graph->GetXaxis()->SetTitleFont(42); Graph->GetYaxis()->SetTitle("Ratio "); Graph->GetYaxis()->SetNdivisions(503); Graph->GetYaxis()->SetLabelFont(42); Graph->GetYaxis()->SetLabelOffset(0.007); Graph->GetYaxis()->SetLabelSize(0.1666667); Graph->GetYaxis()->SetTitleSize(0.1666667); Graph->GetYaxis()->SetTitleOffset(0.45); Graph->GetYaxis()->SetTitleFont(42); Graph->GetZaxis()->SetLabelFont(42); Graph->GetZaxis()->SetLabelOffset(0.007); Graph->GetZaxis()->SetLabelSize(0.05); Graph->GetZaxis()->SetTitleSize(0.06); Graph->GetZaxis()->SetTitleFont(42); Graph->Draw(""); Double_t Graph0_fx1013[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph0_fy1013[10] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; Double_t Graph0_fex1013[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph0_fey1013[10] = { 0.0644708, 0.06365122, 0.06354681, 0.06481966, 0.06320752, 0.0622177, 0.05991862, 0.05949606, 0.06001632, 0.06142499}; gre = new TGraphErrors(10,Graph0_fx1013,Graph0_fy1013,Graph0_fex1013,Graph0_fey1013); gre->SetName("Graph0"); gre->SetTitle("Graph"); ci = TColor::GetColor("#ffff00"); gre->SetFillColor(ci); ci = TColor::GetColor("#ff0000"); gre->SetLineColor(ci); gre->SetLineWidth(4); gre->SetMarkerStyle(20); gre->SetMarkerSize(0); TH1F *Graph_Graph1013 = new TH1F("Graph_Graph1013","Graph",100,-2.88,2.88); Graph_Graph1013->SetMinimum(0.9222164); Graph_Graph1013->SetMaximum(1.077784); Graph_Graph1013->SetDirectory(0); Graph_Graph1013->SetStats(0); Graph_Graph1013->SetLineStyle(0); Graph_Graph1013->SetMarkerStyle(20); Graph_Graph1013->GetXaxis()->SetLabelFont(42); Graph_Graph1013->GetXaxis()->SetLabelOffset(0.007); Graph_Graph1013->GetXaxis()->SetLabelSize(0.05); Graph_Graph1013->GetXaxis()->SetTitleSize(0.06); Graph_Graph1013->GetXaxis()->SetTitleOffset(1.1); Graph_Graph1013->GetXaxis()->SetTitleFont(42); Graph_Graph1013->GetYaxis()->SetLabelFont(42); Graph_Graph1013->GetYaxis()->SetLabelOffset(0.007); Graph_Graph1013->GetYaxis()->SetLabelSize(0.05); Graph_Graph1013->GetYaxis()->SetTitleSize(0.06); Graph_Graph1013->GetYaxis()->SetTitleOffset(1.5); Graph_Graph1013->GetYaxis()->SetTitleFont(42); Graph_Graph1013->GetZaxis()->SetLabelFont(42); Graph_Graph1013->GetZaxis()->SetLabelOffset(0.007); Graph_Graph1013->GetZaxis()->SetLabelSize(0.05); Graph_Graph1013->GetZaxis()->SetTitleSize(0.06); Graph_Graph1013->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1013); gre->Draw("2"); Double_t Graph1_fx1014[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph1_fy1014[10] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; Double_t Graph1_fex1014[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph1_fey1014[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; gre = new TGraphErrors(10,Graph1_fx1014,Graph1_fy1014,Graph1_fex1014,Graph1_fey1014); gre->SetName("Graph1"); gre->SetTitle("Graph"); ci = TColor::GetColor("#ffff00"); gre->SetFillColor(ci); ci = TColor::GetColor("#ff0000"); gre->SetLineColor(ci); gre->SetLineWidth(4); gre->SetMarkerStyle(20); gre->SetMarkerSize(0); gre->Draw("z"); Double_t Graph2_fx1015[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph2_fy1015[10] = { 0.8844678, 0.9009383, 0.9249909, 0.9547005, 0.9887677, 1.01759, 1.031104, 1.025864, 1.002086, 0.9697318}; Double_t Graph2_fex1015[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph2_fey1015[10] = { 0.05296218, 0.042007, 0.03326947, 0.02116912, 0.0170915, 0.01890429, 0.01672622, 0.01681633, 0.01541551, 0.01597539}; gre = new TGraphErrors(10,Graph2_fx1015,Graph2_fy1015,Graph2_fex1015,Graph2_fey1015); gre->SetName("Graph2"); gre->SetTitle("Graph"); ci = TColor::GetColor("#009900"); gre->SetFillColor(ci); gre->SetFillStyle(3375); ci = TColor::GetColor("#009900"); gre->SetLineColor(ci); gre->SetLineStyle(7); gre->SetLineWidth(4); gre->SetMarkerStyle(20); TH1F *Graph_Graph1015 = new TH1F("Graph_Graph1015","Graph",100,-2.88,2.88); Graph_Graph1015->SetMinimum(0.8098732); Graph_Graph1015->SetMaximum(1.069463); Graph_Graph1015->SetDirectory(0); Graph_Graph1015->SetStats(0); Graph_Graph1015->SetLineStyle(0); Graph_Graph1015->SetMarkerStyle(20); Graph_Graph1015->GetXaxis()->SetLabelFont(42); Graph_Graph1015->GetXaxis()->SetLabelOffset(0.007); Graph_Graph1015->GetXaxis()->SetLabelSize(0.05); Graph_Graph1015->GetXaxis()->SetTitleSize(0.06); Graph_Graph1015->GetXaxis()->SetTitleOffset(1.1); Graph_Graph1015->GetXaxis()->SetTitleFont(42); Graph_Graph1015->GetYaxis()->SetLabelFont(42); Graph_Graph1015->GetYaxis()->SetLabelOffset(0.007); Graph_Graph1015->GetYaxis()->SetLabelSize(0.05); Graph_Graph1015->GetYaxis()->SetTitleSize(0.06); Graph_Graph1015->GetYaxis()->SetTitleOffset(1.5); Graph_Graph1015->GetYaxis()->SetTitleFont(42); Graph_Graph1015->GetZaxis()->SetLabelFont(42); Graph_Graph1015->GetZaxis()->SetLabelOffset(0.007); Graph_Graph1015->GetZaxis()->SetLabelSize(0.05); Graph_Graph1015->GetZaxis()->SetTitleSize(0.06); Graph_Graph1015->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1015); gre->Draw("2"); Double_t Graph3_fx1016[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph3_fy1016[10] = { 0.8844678, 0.9009383, 0.9249909, 0.9547005, 0.9887677, 1.01759, 1.031104, 1.025864, 1.002086, 0.9697318}; Double_t Graph3_fex1016[10] = { 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.2}; Double_t Graph3_fey1016[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; gre = new TGraphErrors(10,Graph3_fx1016,Graph3_fy1016,Graph3_fex1016,Graph3_fey1016); gre->SetName("Graph3"); gre->SetTitle("Graph"); ci = TColor::GetColor("#009900"); gre->SetFillColor(ci); gre->SetFillStyle(3375); ci = TColor::GetColor("#009900"); gre->SetLineColor(ci); gre->SetLineStyle(7); gre->SetLineWidth(4); gre->SetMarkerStyle(20); gre->Draw("z"); Double_t Graph4_fx1017[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph4_fy1017[10] = { 1.043581, 0.9670498, 0.9692137, 1.017865, 1.085583, 1.056925, 1.089164, 1.042601, 0.9556571, 1.024122}; Double_t Graph4_fex1017[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Double_t Graph4_fey1017[10] = { 0.06438575, 0.04532301, 0.03641199, 0.03224499, 0.03585407, 0.03579123, 0.03393516, 0.041319, 0.04255045, 0.06625605}; gre = new TGraphErrors(10,Graph4_fx1017,Graph4_fy1017,Graph4_fex1017,Graph4_fey1017); gre->SetName("Graph4"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetFillStyle(0); gre->SetLineWidth(2); gre->SetMarkerStyle(20); gre->Draw("||"); Double_t Graph5_fx1018[10] = { 2.2, 1.75, 1.25, 0.75, 0.25, -0.25, -0.75, -1.25, -1.75, -2.2}; Double_t Graph5_fy1018[10] = { 1.043581, 0.9670498, 0.9692137, 1.017865, 1.085583, 1.056925, 1.089164, 1.042601, 0.9556571, 1.024122}; Double_t Graph5_fex1018[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Double_t Graph5_fey1018[10] = { 0.02717523, 0.02169205, 0.02109434, 0.02056743, 0.02117723, 0.02181947, 0.02264241, 0.02442196, 0.02665755, 0.03840124}; gre = new TGraphErrors(10,Graph5_fx1018,Graph5_fy1018,Graph5_fex1018,Graph5_fey1018); gre->SetName("Graph5"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineWidth(2); gre->SetMarkerStyle(20); TH1F *Graph_Graph1018 = new TH1F("Graph_Graph1018","Graph",100,-2.64,2.64); Graph_Graph1018->SetMinimum(0.9107189); Graph_Graph1018->SetMaximum(1.130087); Graph_Graph1018->SetDirectory(0); Graph_Graph1018->SetStats(0); Graph_Graph1018->SetLineStyle(0); Graph_Graph1018->SetMarkerStyle(20); Graph_Graph1018->GetXaxis()->SetLabelFont(42); Graph_Graph1018->GetXaxis()->SetLabelOffset(0.007); Graph_Graph1018->GetXaxis()->SetLabelSize(0.05); Graph_Graph1018->GetXaxis()->SetTitleSize(0.06); Graph_Graph1018->GetXaxis()->SetTitleOffset(1.1); Graph_Graph1018->GetXaxis()->SetTitleFont(42); Graph_Graph1018->GetYaxis()->SetLabelFont(42); Graph_Graph1018->GetYaxis()->SetLabelOffset(0.007); Graph_Graph1018->GetYaxis()->SetLabelSize(0.05); Graph_Graph1018->GetYaxis()->SetTitleSize(0.06); Graph_Graph1018->GetYaxis()->SetTitleOffset(1.5); Graph_Graph1018->GetYaxis()->SetTitleFont(42); Graph_Graph1018->GetZaxis()->SetLabelFont(42); Graph_Graph1018->GetZaxis()->SetLabelOffset(0.007); Graph_Graph1018->GetZaxis()->SetLabelSize(0.05); Graph_Graph1018->GetZaxis()->SetTitleSize(0.06); Graph_Graph1018->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1018); gre->Draw("pz"); TH1F *Graph_copy = new TH1F("Graph_copy","Graph",100,-2.5,2.5); Graph_copy->SetMinimum(0.75); Graph_copy->SetMaximum(1.35); Graph_copy->SetDirectory(0); Graph_copy->SetStats(0); Graph_copy->SetLineStyle(0); Graph_copy->SetMarkerStyle(20); Graph_copy->GetXaxis()->SetTitle("#eta_{lab}"); Graph_copy->GetXaxis()->SetNdivisions(505); Graph_copy->GetXaxis()->SetLabelFont(42); Graph_copy->GetXaxis()->SetLabelOffset(0.007); Graph_copy->GetXaxis()->SetLabelSize(0.1666667); Graph_copy->GetXaxis()->SetTitleSize(0.1666667); Graph_copy->GetXaxis()->SetTitleOffset(1.1); Graph_copy->GetXaxis()->SetTitleFont(42); Graph_copy->GetYaxis()->SetTitle("Ratio "); Graph_copy->GetYaxis()->SetNdivisions(503); Graph_copy->GetYaxis()->SetLabelFont(42); Graph_copy->GetYaxis()->SetLabelOffset(0.007); Graph_copy->GetYaxis()->SetLabelSize(0.1666667); Graph_copy->GetYaxis()->SetTitleSize(0.1666667); Graph_copy->GetYaxis()->SetTitleOffset(0.45); Graph_copy->GetYaxis()->SetTitleFont(42); Graph_copy->GetZaxis()->SetLabelFont(42); Graph_copy->GetZaxis()->SetLabelOffset(0.007); Graph_copy->GetZaxis()->SetLabelSize(0.05); Graph_copy->GetZaxis()->SetTitleSize(0.06); Graph_copy->GetZaxis()->SetTitleFont(42); Graph_copy->Draw("sameaxis"); pad2->Modified(); c1->cd(); c1->Modified(); c1->cd(); c1->SetSelected(c1); }
void plotPhotonType(char* var="(ecalRecHitSumEtConeDR04+hcalTowerSumEtConeDR04):genCalIsoDR04") { TCut allCut = simpleCut + hardScatterCut; TProfile *hTemplate; TProfile *htmp= new TProfile("htmp","",100,0,20); htmp->SetXTitle("genCalIso [GeV]"); htmp->SetYTitle("recCalIso [GeV]"); hTemplate= getPlot(htmp,var,allCut,"MPA_PhotonJetPt15_31X.root","Analysis"); hTemplate->SetName("hTemplate"); hTemplate->Draw(); gStyle->SetOptFit(11111); hTemplate->Fit("pol1","",""); TF1* f1 = hTemplate->GetFunction("pol1"); float p0 = f1->GetParameter(0); float p1 = f1->GetParameter(1); char tempName[1000]; sprintf(tempName, "((ecalRecHitSumEtConeDR04+hcalTowerSumEtConeDR04)-genCalIsoDR04*%f):((ecalRecHitSumEtConeDR04+hcalTowerSumEtConeDR04)-genCalIsoDR04*(%f))",p1,-1.0/p1); cout << tempName << endl; TProfile *hTemplate_decompos; const int nbin=50; const float min = 0.0; const float max = 10.0; TProfile *htmp2= new TProfile("htmp2","",nbin,min,max); hTemplate_decompos= getPlot(htmp2,tempName,allCut,"MPA_PhotonJetPt15_31X.root","Analysis"); hTemplate_decompos->SetName("hTemplate_decompos"); hTemplate_decompos->Draw(); hTemplate_decompos->SetYTitle(Form("recCalIso-genCalIso*%.2f",p1)); hTemplate_decompos->SetXTitle(Form("recCalIso+genCalIso*%.2f",1.0/p1)); gStyle->SetOptFit(11111); // hTemplate_decompos->Fit("pol1"); TCanvas* c1 = new TCanvas("c1","",500,1000); c1->Divide(1,2); c1->cd(1); hTemplate->Draw(""); c1->cd(2); hTemplate_decompos->SetErrorOption("S"); hTemplate_decompos->Draw(""); c1->Print("bestGenCalIsoDR04.eps"); c1->Print("bestGenCalIsoDR04.gif"); TCanvas* c2 = new TCanvas("c2","",500,1000); c2->Divide(1,2); c2->cd(1); TH1F* hMean = new TH1F("hMean","",nbin,min,max); hMean->SetXTitle(Form("recCalIso+genCalIso*%.2f",1.0/p1)); hMean->SetTitleSize(0.06,"Y"); hMean->SetTitleOffset(1.2,"Y"); hMean->SetYTitle(Form("Mean of recCalIso-genCalIso*%.2f",p1)); for(int i=1; i <= nbin; i++) hMean->SetBinContent(i,hTemplate_decompos->GetBinContent(i)); hMean->Draw(); c2->cd(2); TH1F* hRMS = new TH1F("hRMS","",nbin,min,max); hRMS->SetXTitle(Form("recCalIso+genCalIso*%.2f",1.0/p1)); hRMS->SetTitleSize(0.06,"Y"); hRMS->SetTitleOffset(1.2,"Y"); hRMS->SetYTitle(Form("RMS of recCalIso-genCalIso*%.2f",p1)); for(int i=1; i <= nbin; i++) hRMS->SetBinContent(i,hTemplate_decompos->GetBinError(i)); hRMS->Draw(); c2->Print("bestGenCalIsoDR04_sup.eps"); c2->Print("bestGenCalIsoDR04_sup.gif"); int bestDeComposXBin = 11; float bestDeComposX = hMean->GetBinCenter(bestDeComposXBin); float bestDeComposY = hMean->GetBinContent(bestDeComposXBin); cout << "bestDeComposX = " << bestDeComposX << endl; cout << "bestDeComposY = " << bestDeComposY << endl; float bestGenIso = (bestDeComposX - bestDeComposY)/((1.0)/p1 + p1); float bestRecIso = bestDeComposX - (1.0/p1) * bestGenIso; cout << "bestGenIso = " << bestGenIso << endl; cout << "bestRecIso = " << bestRecIso << endl; }
void histo_plot(void) { // Store constants for connecting to database (fill in blanks as // appropriate) const Char_t *dbusername = "******"; // username for DB access const Char_t *dbpasswd = "parity"; // password for DB access const Char_t *dbname = "pandb"; // name of DB const Char_t *dbhostname = "alquds.jlab.org"; // hostname of DB server computer // Connect to MySQL server Char_t *dburl = new Char_t[50]; sprintf(dburl,"mysql://%s/%s", dbhostname, dbname); TSQLServer *db = TSQLServer::Connect(dburl, dbusername, dbpasswd); delete []dburl; dburl=NULL; // Get name of dbtablename Char_t * dbtablename= new Char_t[50]; const Char_t *inputtable = "Please enter desired table: "; cout << inputtable; cin.getline(dbtablename, 49); cout << dbtablename << endl; // Get name of column to plot Char_t *column = new Char_t[50]; const Char_t *inputcolumn = "Please enter desired column: "; cout << inputcolumn; cin.getline(column, 49); cout << column << endl; // Construct query Char_t *sql = new Char_t[4200]; sprintf(sql, "SELECT %s FROM %s", column, dbtablename); cout << sql << endl; // start timer TStopwatch timer; timer.Start(); // Submit query to server TSQLRow *row; TSQLResult *res; res = db->Query(sql); // Process results Int_t nrows = res->GetRowCount(); cout << "Got " << nrows << " rows in result." << endl; Int_t nfields = res->GetFieldCount(); cout << "Got " << nfields << " fields in result." << endl; if (nfields != 1) { cerr << "Select only one column to average over!" << endl; exit; } // Get histogram ranges Char_t *lowrangechar = new Char_t[10]; const Char_t *lowrangemessage = "Please enter lower limit of " "the histogram range: "; cout << lowrangemessage; cin.getline(lowrangechar, 9); Float_t lowrangefloat = atof(lowrangechar); Char_t *highrangechar = new Char_t[10]; const Char_t *highrangemessage = "Please enter upper limit of " "the histogram range: "; cout << highrangemessage; cin.getline(highrangechar, 9); Float_t highrangefloat = atof(highrangechar); // Create histogram TH1F *histo = new TH1F("histo", column, 50, lowrangefloat, highrangefloat); // Fill histogram for (Int_t i = 0; i<nrows; i++) { row = res->Next(); Float_t field = atof(row->GetField(0)); delete row; histo->Fill(field); } histo->Draw(); // stop timer and print results timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); printf("\nRealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime); // Clean up delete []sql; delete []dbtablename; delete []column; delete []lowrangechar; delete []highrangechar; delete res; delete db; }
void makeFitPlotSFJVF() { gROOT->SetBatch(); gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); gROOT->ProcessLine(".x def.C"); gROOT->ProcessLine(".x common.C"); bool doSubPlot = 0; std::string sel = "MV160"; std::string var = "Sd0t1"; const int nf = 2; std::string fv[nf] = {"","_JVF0"}; double sf[100][100]; double sferr[100][100]; double sfX[100]; double sfXerr[100]; TCanvas *c1 = new TCanvas("c1","c1",0,0,600,500); c1->Draw(); c1->cd(); TPad *c1_1; if( doSubPlot ) { c1->Range(0,0,1,1); c1_1 = new TPad("c1_1","main",0.01,0.30,0.99,0.99); c1_1->Draw(); c1_1->cd(); } gStyle->SetHistTopMargin(0); TLegend *leg = new TLegend(0.70,0.90,0.90,0.70); leg->SetFillColor(253); leg->SetBorderSize(0); int nbins = 0; int im = 0; TH1F *hc; TH1F *hsf[nf]; for(int f=0;f<nf;f++) { std::string fname = "results/sfoverlay/fit_EFF_beauty_"+var+"_"+sel+fv[f]+".root"; TFile *file = new TFile(fname.c_str()); TH1F *h = (TH1F*)file->Get("h1c"); nbins = h->GetXaxis()->GetNbins(); for(int ib=1;ib<nbins+1;ib++) { double cont = h->GetBinContent(ib); double err = h->GetBinError(ib); sfXerr[ib-1] = h->GetBinWidth(ib)/2.0; sfX[ib-1] = h->GetBinLowEdge(ib) + sfXerr[ib-1]; sf[ib-1][im] = cont; sferr[ib-1][im] = err; } if( f == 0 ) {h->SetMarkerStyle(20);h->SetMarkerColor(kRed);h->SetLineColor(kRed);} if( f == 1 ) {h->SetMarkerStyle(25);h->SetMarkerColor(kBlack);h->SetLineColor(kBlack);} if( f == 2 ) {h->SetMarkerStyle(22);h->SetMarkerColor(kBlue);h->SetLineColor(kBlue);} if( f == 3 ) {h->SetMarkerStyle(23);h->SetMarkerColor(kMagenta);h->SetLineColor(kMagenta);} std::string tit = ""; if( f == 0 ) tit = "JVF > 0.5"; if( f == 1 ) tit = "JVF > 0"; if( f == 2 ) tit = "S_{d_{0}}(t_{3})"; if( f == 3 ) tit = "S_{d_{0}}(#mu)"; leg->AddEntry(h,tit.c_str(),"lep"); if( f == 0 ) h->Draw("e1"); else h->Draw("e1 same"); ATLASLabel(0.20,0.85,"Internal",1); h->GetYaxis()->SetRangeUser(0.3,1.6); h->GetXaxis()->SetRangeUser(0.0,0.04); im++; std::string hname = "hsf"+std::string(Form("%d",f)); hsf[f] = (TH1F*)h->Clone(hname.c_str()); } leg->Draw(); gPad->RedrawAxis("g"); /* if( doSubPlot ) { std::string foutStr = "results/fit_EFF_beauty_SFOVERLAY_"+sel+".root"; TFile *fout = new TFile(foutStr.c_str(),"RECREATE"); int inb = hsf[0]->GetXaxis()->GetNbins(); const int nb = inb; double av[nb]; double errSum[nb]; double absv[nb]; for(int ib=1;ib<=nb;ib++) { av[ib-1] = 0.; absv[ib-1] = 0.; errSum[ib-1] = 0.; } for(int ih=0;ih<nf;ih++) { for(int ib=1;ib<=nb;ib++) { double err = hsf[ih]->GetBinError(ib); // av[ib-1] += (err > 0) ? hsf[ih]->GetBinContent(ib)/pow(err,2) : 0.; av[ib-1] += hsf[ih]->GetBinContent(ib)/float(nf); errSum[ib-1] += (err > 0) ? 1./pow(err,2) : 0.; } } for(int ih=0;ih<nf;ih++) { for(int ib=1;ib<=nb;ib++) { double err = hsf[ih]->GetBinError(ib); absv[ib-1] += pow(err,2); } } for(int ib=1;ib<=nb;ib++) { // av[ib-1] /= errSum[ib-1]; } for(int ib=1;ib<=nb;ib++) { absv[ib-1] = sqrt(absv[ib-1])/float(nf); // absv[ib-1] = 1./sqrt(errSum[ib-1]); std::cout << av[ib-1] << " +- " << absv[ib-1] << std::endl; } c1->cd(); TPad *c1_2 = new TPad("c1_2", "ratio",0.01,0.01,0.99,0.37); c1_2->Draw(); c1_2->cd(); c1_2->SetBottomMargin(0.37); c1_2->SetGrid(0,1); TH1F *h1c = (TH1F*)hsf[0]->Clone("h1c"); for(int ib=1;ib<=nb;ib++) { h1c->SetBinContent(ib,av[ib-1]); h1c->SetBinError(ib,absv[ib-1]); } h1c->SetMarkerStyle(20); h1c->SetMarkerSize(0.8); h1c->GetYaxis()->SetNdivisions(5); h1c->GetYaxis()->SetTitle("Data/MC"); h1c->GetYaxis()->SetTitleSize((h1c->GetYaxis()->GetTitleSize())*2); h1c->GetYaxis()->SetTitleOffset(h1c->GetYaxis()->GetTitleOffset()/2); h1c->GetXaxis()->SetTitleSize((h1c->GetXaxis()->GetTitleSize())*2); h1c->GetXaxis()->SetTitleOffset(h1c->GetXaxis()->GetTitleOffset()+0.2); h1c->GetYaxis()->SetLabelSize((h1c->GetYaxis()->GetLabelSize())*2); h1c->GetXaxis()->SetLabelSize((h1c->GetXaxis()->GetLabelSize())*2); h1c->GetXaxis()->SetTitle(h1c->GetXaxis()->GetTitle()); h1c->SetLineColor(kBlack); h1c->SetMarkerColor(kBlack); h1c->Draw("e1"); h1c->GetYaxis()->SetRangeUser(0.5,1.5); c1->Update(); for(int ih=0;ih<nf;ih++) { hsf[ih]->Write(); } fout->Write(); fout->Close(); }*/ std::string fsave = "pics/fit_SFJVF_"+sel+".eps"; c1->Print(fsave.c_str()); gApplication->Terminate(); }