void drawSysBox(TGraph* gr, int fillcolor=TColor::GetColor("#ffff00"), double xwidth=0.3, double percent=0, double xshift=0) { TBox* box; for(int n=0;n<gr->GetN();n++) { double x,y; gr->GetPoint(n,x,y); //double percent=0; //if(x>=260) percent=0.074; //else if(x<260 && x>=200) percent=0.055; //else percent=0.039; double yerr = y*percent*0.01; box = new TBox(x+xshift-xwidth,y-fabs(yerr),x+xwidth,y+fabs(yerr)); //box->SetFillStyle(3001); //box->SetFillColor(fillcolor); //box->SetFillColor(2); box->SetLineWidth(0); box->SetFillColor(kGray); box->Draw("Fsame"); //box->Draw(); } }
void drawSysBoxValue(TGraph* gr, int fillcolor=TColor::GetColor("#ffff00"), double xwidth=0.3, double *percent, double xshift=0) { TBox* box; for(int n=0;n<gr->GetN();n++) { double x,y; gr->GetPoint(n,x,y); double yerr = percent[n]*1.0; box = new TBox(x+xshift-xwidth,y-fabs(yerr),x+xwidth,y+fabs(yerr)); //box->SetFillStyle(3001); //box->SetFillColor(fillcolor); //box->SetFillColor(2); box->SetLineWidth(0); box->SetFillColor(kGray); box->Draw("Fsame"); //box->Draw(); } }
//-------------------------- // DrawTargetBoundaries //-------------------------- void DrawTargetBoundaries(int color=target_color) { double Zlo = 50.0; double Zhi = Zlo + 30.0; double Rlo = 0.0; double Rhi = Rlo + 1.5; if (full) { Rlo=-1.5; Rhi=Rlo+3; } TBox *box = new TBox(Zlo, Rlo, Zhi, Rhi); box->SetLineWidth(2.0); if (fill_detectors) { box->SetFillColor(color); box->SetFillStyle(1001); } else box->SetFillStyle(0); box->SetLineColor(color); box->Draw(); TLatex *lab = new TLatex(Zlo-5, 0, "target"); if (full) lab->SetTextAlign(32); else lab->SetTextAlign(31); lab->SetTextSize(0.02); lab->SetTextColor(color); lab->Draw(); }
void createDataVsMC(TString folderName,TString histoName,int rebin,double xMin,double xMax,TString xName, TString yName, vector<TString> MCFileNames, vector<TString> MCNames, vector<int> MCColors, vector<bool> AddToBkg,vector<TString> DataFileNames,vector<TString> dataNames,vector<int> dataColors,vector<TString> SystNames,vector<int> SystColors, TCanvas *cCanvas, int padNr, bool UseLog,GlobalParameterSet Parameters) { // CREATE ALL HISTOGRAMS ======================================================== TString lumi = ""; lumi+=Parameters.intLumi; if(Parameters.GlobalLog) { UseLog = true; } // SM background histo TH1D *hSM0=0; // Create MC histos and add them SM0 vector<TH1D*> MChistos; bool noneAdded = true; float eventsMC=0; if(Parameters.MuPred){ for(unsigned int i =0;i<3;i++) { TFile* fhh = TFile::Open(MCFileNames[i],"READONLY"); TH1D *hTemp = (TH1D*)fhh->Get(folderName+"/CounterCtrl_tot"); eventsMC += hTemp->GetBinContent(1); cout << "eventsMC " <<eventsMC<< endl; //delete hTemp; // delete fhh; } TFile* fdata_test = TFile::Open(DataFileNames[0],"READONLY"); TH1D *hTempddd = (TH1D*)fdata_test->Get(folderName+"/CounterCtrl_tot"); cout << "eventsMC " << eventsMC<< " "<<hTempddd->GetBinContent(1) << endl; Parameters.intLumi = 100*hTempddd->GetBinContent(1)/eventsMC; } // delete fdata_test; // delete hTempddd; for(unsigned int i =0;i<MCFileNames.size();i++) { MChistos.push_back(plot1Dhisto(Parameters.intLumi,TFile::Open(MCFileNames[i],"READONLY"),folderName,histoName,MCColors[i],rebin,xMin,xMax,xName,yName,"MC",true)); if(noneAdded&&AddToBkg[i]) { hSM0 = (TH1D *) MChistos[i]->Clone(); noneAdded = false; } else { if(AddToBkg[i]) { hSM0->Add(MChistos[i],1); } } } hSM0->SetLineColor(2); // Create Histograms with the different systematics vector<TH1D*> SystHistos; if(Parameters.UseSystematics) { for(unsigned int i=0; i<SystNames.size(); i++) { noneAdded = true; for(unsigned int j=0; j<MCFileNames.size(); j++) { if(AddToBkg[j]) { TString SystFileName = MCFileNames[j]; SystFileName.Insert(SystFileName.Last('/'),"_"+SystNames[i]); TFile *SystMCFile = TFile::Open(SystFileName,"READONLY"); TH1D *SystHistoTemp = plot1Dhisto(Parameters.intLumi,SystMCFile,folderName,histoName,SystColors[i],rebin,xMin,xMax,xName,yName,"MC",true); SystHistoTemp->SetLineStyle(2); if(noneAdded) { SystHistos.push_back((TH1D *) SystHistoTemp->Clone()); noneAdded = false; } else { SystHistos.back()->Add(SystHistoTemp,1); } } } } } // Create Histograms for error band TH1D* hSM0allErrors = (TH1D *) hSM0->Clone(); TH1D* hSM0systErrors = (TH1D *) hSM0->Clone(); if(Parameters.UseSystematics) { for(int j = hSM0->FindBin(xMin); j<=hSM0->FindBin(xMax); j++) { double downerror=0; double uperror=0; for(unsigned int i=0; i<SystHistos.size(); i++) { double diff = SystHistos[i]->GetBinContent(j) - hSM0->GetBinContent(j); if(diff>0) uperror += diff*diff; else downerror += diff*diff; } downerror = TMath::Sqrt(downerror); uperror = TMath::Sqrt(uperror); double maxerror = TMath::Max(downerror,uperror); double staterror = hSM0->GetBinError(j); hSM0systErrors->SetBinError(j,maxerror); hSM0allErrors->SetBinError(j,TMath::Sqrt(maxerror*maxerror+staterror*staterror)); hSM0systErrors->SetFillColor(5); hSM0systErrors->SetLineColor(5); hSM0allErrors->SetLineColor(3); hSM0allErrors->SetFillColor(3); } } // Create Data Histograms vector<TH1D *> dataHistos; for(unsigned int i=0; i<DataFileNames.size();i++) { dataHistos.push_back(plot1Dhisto(Parameters.intLumi,TFile::Open(DataFileNames[i],"READONLY"),folderName,histoName,dataColors[i],rebin,xMin,xMax,xName,yName,"Data",false)); dataHistos[i]->SetMarkerSize(1.2); dataHistos[i]->SetMarkerColor(dataColors[i]); dataHistos[i]->SetMarkerStyle(20); // remove error manually if(!Parameters.ShowStatErrorbars){ NoError(dataHistos[i],xMin,xMax); } // y-axis range if (UseLog){ dataHistos[i]->GetYaxis()->SetRangeUser(1.,3.5*(dataHistos[i]->GetBinContent(dataHistos[i]->GetMaximumBin()))); } else{ float maximum = hSM0->GetMaximum(); if(maximum<dataHistos[i]->GetMaximum())maximum=dataHistos[i]->GetMaximum(); dataHistos[i]->GetYaxis()->SetRangeUser(0.,maximum*1.8); } } cCanvas->SetName(folderName+histoName); cCanvas->cd(2*padNr+1); if(UseLog) { gPad->SetLogy(); } dataHistos[0]->Draw("P E0"); //DRAW ALL HISTOGRAMS ===================================================== if(Parameters.ShowMCComposition){ for(unsigned int i=1; Parameters.StackMCComposition&&i<MChistos.size();i++) { MChistos[i]->Add(MChistos[i],MChistos[i-1]); MChistos[i]->SetFillColor(MCColors[i]); MChistos[i]->SetLineStyle(1); MChistos[i]->SetFillStyle(3004); MChistos[i-1]->SetFillStyle(3004); MChistos[i-1]->SetFillColor(MCColors[i-1]); } for(int i=MChistos.size()-1;i>=0;i--) { if(Parameters.ShowMCStatErrorbars) MChistos[i]->Draw("HIST E0 same"); else MChistos[i]->Draw("HIST same"); } } hSM0->SetLineColor(kRed); if(Parameters.ShowErrorBand) { hSM0allErrors->Draw("E2 same"); hSM0systErrors->Draw("E2 same"); } if(!Parameters.ShowMCStatErrorbars&&!Parameters.StackMCComposition) hSM0->Draw("HIST same"); if(Parameters.ShowSystematicsDetails) { for(unsigned int i=0; i<SystHistos.size();i++) { SystHistos[i]->Draw("HIST same"); } } for(int i=dataHistos.size()-1;i>=0;i--) { dataHistos[i]->Draw("P E0 same"); } if(Parameters.ShowMCStatErrorbars&&!Parameters.StackMCComposition) { hSM0->Draw("HIST same E0"); } // Draw Legend TLegend *lSamples = legendRAW(0.77,0.58,0.95,0.89); if(!Parameters.StackMCComposition) lSamples->AddEntry(hSM0,"Total MC","FL"); if(Parameters.ShowErrorBand) { lSamples->AddEntry(hSM0systErrors,"Systematic Error","FL"); lSamples->AddEntry(hSM0allErrors,"MC Syst. #oplus Stat. Error","FL"); } for(unsigned int i=0; i<dataHistos.size(); i++) { lSamples->AddEntry(dataHistos[i],dataNames[i],"PL"); } for(unsigned int i =0;i<MChistos.size()&&Parameters.ShowMCComposition;i++) { lSamples->AddEntry(MChistos[i],MCNames[i],"FL"); } for(unsigned int i =0;i<SystHistos.size()&&Parameters.ShowSystematicsDetails;i++) { lSamples->AddEntry(SystHistos[i],SystNames[i],"FL"); } lSamples->Draw("same"); TLatex *lWhichLepton; if (Parameters.electrons) { lWhichLepton = new TLatex(0.73,0.9,"Electrons"); } else { lWhichLepton = new TLatex(0.73,0.9,"Muons"); } lWhichLepton->SetNDC(); lWhichLepton->Draw("same"); TLatex *lPreliminary = new TLatex(0.19,0.96,"CMS Preliminary 2011"); // TLatex *lIntLumi = new TLatex(0.15,0.89,"#scale[0.8]{#int L dt = "+lumi+" pb^{-1}, #sqrt{s} = 7 TeV}"); TLatex *lIntLumi = new TLatex(0.22,0.88,"#scale[1.]{4.7 fb^{-1}, #sqrt{s} = 7 TeV}"); TLatex *lIntLumiB = new TLatex(0.22,0.79,"#scale[1.]{#sqrt{s} = 7 TeV}"); lPreliminary->SetNDC(); lIntLumi->SetNDC(); lIntLumiB->SetNDC(); lPreliminary->Draw("same"); lIntLumi->Draw("same"); gPad->SetFillColor(0); // lIntLumiB->Draw("same"); // gPad->SetGridx(); // gPad->SetGridy(); // --- create HT and STlep legends //"ANplots150_NOLPsecondD500" folderNames TString HT500 = "secondD500"; TString HT750 = "secondD750"; TString HT1000 = "secondD1000"; TString ST150 = "plots150"; TString ST250 = "plots250"; TString ST350 = "plots350"; TString ST450 = "plots450"; TString tmpLegendHT, tmpLegendST; if (((folderName.SubString(HT500)).Length())>0) { if (Parameters.htBins) { tmpLegendHT = "H_{T}#in[500,750]"; } else { tmpLegendHT = "H_{T}>500";} } else if (((folderName.SubString(HT750)).Length())>0) { if (Parameters.htBins) { tmpLegendHT = "H_{T}#in[750,1000]"; } else { tmpLegendHT = "H_{T}>750";} } else if (((folderName.SubString(HT1000)).Length())>0) { if (Parameters.htBins) { tmpLegendHT = "H_{T}>1000"; } else { tmpLegendHT = "H_{T}>1000";} } else { tmpLegendHT = "error"; } if (((folderName.SubString(ST150)).Length())>0) { tmpLegendST = "S^{lep}_{T}#in[150,250]"; } else if (((folderName.SubString(ST250)).Length())>0) { tmpLegendST = "S^{lep}_{T}#in[250,350]"; } else if (((folderName.SubString(ST350)).Length())>0) { tmpLegendST = "S^{lep}_{T}#in[350,450]"; } else if (((folderName.SubString(ST450)).Length())>0) { tmpLegendST = "S^{lep}_{T}>450"; } else { tmpLegendST = "error"; } TString legendHTandST = tmpLegendHT+" , "+tmpLegendST; TLatex *lHTandST = new TLatex(0.22,0.8,legendHTandST); lHTandST->SetNDC(); // lHTandST->Draw("same"); TLatex *lHT = new TLatex(0.22,0.8,tmpLegendHT); lHT->SetNDC(); lHT->Draw("same"); TLatex *lST = new TLatex(0.22,0.7,tmpLegendST); lST->SetNDC(); lST->Draw("same"); // DRAW RATIO PLOTS ============================================================================ if (Parameters.ratioplot) { vector<TH1D*> hRatio; for(unsigned int i=0; i<dataHistos.size()&&MChistos.size()>0; i++) { hRatio.push_back((TH1D*)dataHistos[i]->Clone("")); hRatio.back()->Divide(dataHistos[i],hSM0); hRatio.back()->GetYaxis()->SetTitle("Data / MC"); hRatio.back()->GetYaxis()->SetTitleSize(0.16); hRatio.back()->GetXaxis()->SetTitle(""); hRatio.back()->GetYaxis()->SetNdivisions(409); hRatio.back()->GetYaxis()->SetRangeUser(0.,2.); hRatio.back()->SetTitleSize(0.16, "XY"); hRatio.back()->SetTitleOffset(0.5, "Y"); hRatio.back()->SetLabelSize(0.165,"XY"); } for(unsigned int i=0; Parameters.UseSystematics&&Parameters.ShowSystematicsDetails&&i<SystHistos.size(); i++) { hRatio.push_back((TH1D*)SystHistos[i]->Clone("")); hRatio.back()->Divide(SystHistos[i],hSM0); hRatio.back()->GetYaxis()->SetTitle("Data&Syst/MC"); hRatio.back()->GetYaxis()->SetRangeUser(0.5,1.5); hRatio.back()->GetXaxis()->SetTitle(""); hRatio.back()->SetTitleSize(0.06, "XY"); hRatio.back()->SetTitleOffset(0.8, "Y"); hRatio.back()->SetLabelSize(0.08,"XY"); NoError(hRatio.back(),xMin,xMax); } cCanvas->cd(2*padNr+2); // TBox *unity = new TBox(xMin-0.1,0.95,xMax+0.15, 1.05); // LP TBox *unity = new TBox(xMin-0.1,0.95,xMax+0.15, 1.05); unity->SetLineWidth(2); //unity.SetLineStyle(Root.kDashed); unity->SetLineColor(2); unity->SetFillColor(2); unity->SetFillStyle(3002); // unity->Draw(); // gPad->SetGridx(); // gPad->SetGridy(); for(unsigned int i=hRatio.size()-1; i<hRatio.size(); i--) { if(i==hRatio.size()-1) { hRatio[i]->Draw(); // unity->Draw("same"); hRatio[i]->Draw("same"); } else { hRatio[i]->GetYaxis()->SetTitleSize(0.055); hRatio[i]->Draw("same"); } } } // ratio stuff close }
void Plot(TString var,TCut cut,TString bins,Double_t xmax,TString cutpoint){ setstyle(); TH1::SetDefaultSumw2(true); TCanvas *c2 = new TCanvas("canvas"+var+cutpoint,"canname"+var+cutpoint,800,800); TPad *mainPad = new TPad("","",0.01,0.25,0.99,0.99); mainPad->SetNumber(1); mainPad->Draw(); TPad *ratioPad = new TPad("","",0.01,0.01,0.99,0.25); ratioPad->SetNumber(2); ratioPad->Draw(); c2->cd(1); // if (cutpoint == "noHT"){ TCut cut = numpj; TCut cutData = numpjData;} // else if (cutpoint == "HT200"){ TCut cut = HT200; TCut cutData = HT200Data; }// // else if (cutpoint == "anoHT"){ TCut cut = anumpj; TCut cutData = anumpjData;} // else if (cutpoint == "aHT200"){ TCut cut = aHT200; TCut cutData = aHT200Data; } // else if (cutpoint == "HT300"){ TCut cut = HT300; TCut cutData = HT300Data;} // else if (cutpoint == "HT350"){ TCut cut = HT350; TCut cutData = HT350Data; } // else if (cutpoint == "aT"){ TCut cut = aT; TCut cutData = aTData;} // else if (cutpoint == "early"){TCut cut = earlyaT; TCut cutData = earlyaTData;} //else{cout << "ERRORRRR: BRaaaaaaaaaaaaaaaaaains" << endl; } TCut cutData = trig && hbhe && cut; TH1D* lm0 = GetHist("LM0",kRed,var,cut,bins,tLM0,cutpoint); /// cout << "lm0" << endl; TH1D* lm1 = GetHist("LM1",kRed,var,cut,bins,tLM1,cutpoint); // cout << "lm1" << endl; TH1D* qcd = GetHist("QCD_AllPtBins_7TeV_Pythia",kOrange+4,var,cut && mu_pt_hi,bins,tQCD,cutpoint); // cout << "qcd" << endl; TH1D* data = GetHist("Data",1,var,cutData,bins,tData,cutpoint); // cout << "data" << endl; TH1D* W = GetHist("Wjets_vols",kBlue,var,cut,bins,tW,cutpoint); //cout << "W" << endl; TH1D* tt = GetHist("ttbarTauola",kGreen,var,cut,bins,tTT,cutpoint); // cout << "tt" << endl; TH1D* Z = GetHist("ZJets_madgraph",kYellow,var,cut,bins,tZ,cutpoint); // cout << "Z" << endl; //TH1D* qcd_lo = GetHist("QCD_AllPtBins_7TeV_Pythia",kOrange+4,var,cut && mu_pt_lo,bins,tQCD,cutpoint); // qcd_lo->Scale(1.94); // qcd->Add(qcd_lo); // TH1D* SM = GetHist("SM",kGray+2,var,cut,binstLM0,cutpoint); lm1->SetLineStyle(2); W->Scale(1.29557302); tt->Scale(1.65789474); Z->Scale(3048./2400.); TH1::SetDefaultSumw2(true); TH1D *SM = (TH1D*)qcd->Clone(); SM->Add(Z); SM->Add(tt); SM->Add(W); //SM->SetLineColor(kGray+2); // SM->SetFillStyle(3001); // SM->SetFillColor(kGray+2); // SM->SetMarkerSize(0.); //for(int bnum = 1; bnum <9; bnum++){ // if(data->GetBinContent(bnum)>0){ // cout << "Bin Number " << bnum << " has qcd " << qcd->GetBinContent(bnum) << " and data " << data->GetBinContent(bnum) << " and SM " << SM->GetBinContent(bnum) << " and scale factor to QCD " << data->GetBinContent(bnum)/qcd->GetBinContent(bnum) << " and scale factor to SM " << data->GetBinContent(bnum)/SM->GetBinContent(bnum) << endl; // } // } c2->cd(1)->SetLogy(); // data->Draw("PE0"); SM->Draw("E"); THStack bkg("bkg","test stacked histograms"); bkg.Add(Z); bkg.Add(tt); bkg.Add(W); bkg.Add(qcd); bkg.Draw("HIST0SAME"); // data->Draw("PE0SAME"); //qcd->Draw("HIST0same"); /* W->Draw("HIST0same"); Z->Draw("HIST0same"); tt->Draw("HIST0same"); */ lm0->Draw("HIST0same"); lm0->SetLineColor(1); lm0->SetFillColor(0); lm1->Draw("HIST0same"); lm1->SetLineColor(1); lm1->SetFillColor(0); lm1->SetLineStyle(2); // data->Draw("EPSAME"); if(xmax == 1337){ double ymax=SM->GetMaximum()*12.6;} else{ double ymax=SM->GetMaximum()*10.6;} SM->GetYaxis()->SetRangeUser(0.05,ymax); if (var=="AlphaT_Lep") { data->GetXaxis()->SetRangeUser(0.,xmax);} SM->GetXaxis()->SetTitle(var); SM->SetTitle(); TLegend *leg = new TLegend(0.73803,0.591026,0.88137,0.880819); // leg->SetShadowColor(0); //leg->SetBorderSize(0); //leg->SetFillStyle(4100); leg->SetTextSize(0.04); leg->SetFillColor(0); leg->SetLineColor(0); // leg->AddEntry(data,"DATA","PL"); leg->AddEntry(qcd,"QCD","FL"); leg->AddEntry(W,"W","FL"); leg->AddEntry(Z,"Z","FL"); leg->AddEntry(tt,"TTbar","FL"); leg->AddEntry(lm0,"LM0","FL"); leg->AddEntry(lm1,"LM1","FL"); //leg->AddEntry(SM,"SM BKGD","FL"); leg->Draw("same"); TLatex *prelim = new TLatex(0.1152,0.81981,"CMS preliminary 2010"); TLatex *lumi = new TLatex(0.1015,.9403,"#scale[0.8]{#int L dt = " +luminum+ "pb^{-1}, #sqrt{s} = 7 TeV}"); prelim->SetNDC(); lumi->SetNDC(); // prelim->Draw("same"); lumi->Draw("same"); TH1D *RatioBottom = (TH1D*)SM->Clone("Ratiob"); TH1D *RatioTop = (TH1D*)data->Clone("Ratiot"); RatioTop->GetYaxis()->SetTitle("data / sim"); RatioTop->GetXaxis()->SetTitle(); RatioTop->Divide(RatioBottom); c2->cd(2); gPad->SetGridx(); gPad->SetGridy(); RatioTop->SetTitleSize(0.1, "XYZ"); RatioTop->SetTitleOffset(0.55, "X"); RatioTop->SetTitleOffset(0.3, "Y"); RatioTop->SetLabelSize(0.06,"XY"); RatioTop->GetYaxis()->SetRangeUser(-2.,4.0); RatioTop->Draw(); RatioTop->GetYaxis()->SetLabelSize(0.05); TBox *unity = new TBox(RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetFirst()), 0.89,RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetLast()), 1.11); unity->SetLineWidth(2); unity->SetLineColor(2); unity->SetFillColor(2); unity->SetFillStyle(3002); unity->Draw(); c2->Update(); if(cutpoint == "early"){ c2->SaveAs(plots+erlee+"Muon_ND"+selec+var+"_"+cutpoint+".png"); } else if (xmax == 90003){ c2->SaveAs(plots+"Muon_ND"+selec+"_zooomed_"+var+"_"+cutpoint+".png");} else{ c2->SaveAs(plots+"Muon_ND"+ptsec++selec+var+"_"+cutpoint+".png");} c2->Close(); }
void control(TString var,TString bin, TCut cuts, TCut cutsA, TString cutpoint,bool log,Double_t ymax){ setstyle(); TH1::SetDefaultSumw2(true); TCanvas *c2 = new TCanvas("canvas"+var+cutpoint,"canname"+var+cutpoint,700,800); TPad *mainPad = new TPad("","",0.01,0.25,0.99,0.99); mainPad->SetNumber(1); mainPad->Draw(); TPad *ratioPad = new TPad("","",0.01,0.01,0.99,0.25); ratioPad->SetNumber(2); ratioPad->Draw(); c2->cd(1); TCut lo = cuts && mu_pt_lo; TCut hi = cuts && mu_pt_hi; // TH1D *Ctrl_lo = GetHist("AS",kBlack,var,lo,bin,astQCD,cutpoint); // TH1D *Sig_lo = GetHist("S",kRed,var,lo,bin,stQCD,cutpoint); TH1D *Ctrl_hi = GetHist("AS",kBlack,var,cuts,bin,astQCD,cutpoint); TH1D *Sig_hi = GetHist("S",kRed,var,cuts,bin,stQCD,cutpoint); // Ctrl_lo->Scale(1.94); // Sig_lo->Scale(1.94); TH1D *Ctrl = Ctrl_hi->Clone(); TH1D *Sig = Sig_hi->Clone(); // Ctrl->Add(Ctrl_hi); // Sig->Add(Sig_hi); Sig->Scale(intlumi); // TH1D *Ctrl = GetHist("AS",kBlack,var,cuts,bin,astQCD,cutpoint); if(Ctrl->Integral()!=0){ Ctrl->Scale(Sig->Integral()/Ctrl->Integral()); } if(log){ c2->cd(1)->SetLogy();} TLegend *leg = new TLegend(0.564,0.719,0.775,0.875); leg->SetTextSize(0.054); leg->SetFillColor(0); leg->SetLineColor(0); // leg->AddEntry(Ctrl,"Anti-Selected","LF"); leg->AddEntry(Sig,"Selected","LF"); leg->AddEntry(Ctrl,"Anti-Selected","LF"); Ctrl->Draw("EHIST9"); Sig->Draw("E9same"); Sig->SetMarkerStyle(20); Sig->SetMarkerColor(kRed); leg->Draw("same"); Ctrl->SetTitle(); Ctrl->GetXaxis()->SetTitle(var); if(log){ Ctrl->GetYaxis()->SetRangeUser(0.001,ymax); } else{ ymax=(Ctrl->GetMaximum()*1.6); Ctrl->GetYaxis()->SetRangeUser(0.,ymax); } TH1D *RatioBottom = (TH1D*)Ctrl->Clone("Ratiob"); TH1D *RatioTop = (TH1D*)Sig->Clone("Ratiot"); RatioTop->GetYaxis()->SetTitle("Selected / Anti-Selected"); RatioTop->GetXaxis()->SetTitle(); RatioTop->SetTitle(); RatioTop->Divide(RatioBottom); c2->cd(2); gPad->SetGridx(); gPad->SetGridy(); RatioTop->SetTitleSize(0.1, "XYZ"); RatioTop->SetTitleOffset(0.55, "X"); RatioTop->SetTitleOffset(0.3, "Y"); RatioTop->SetLabelSize(0.06,"XY"); RatioTop->GetYaxis()->SetRangeUser(-2.,5.0); RatioTop->SetLineColor(kBlack); RatioTop->Draw(); TBox *unity = new TBox(RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetFirst()), 0.79,RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetLast()), 1.21); unity->SetLineWidth(2); unity->SetLineColor(2); unity->SetFillColor(2); unity->SetFillStyle(3002); unity->Draw(); c2->Update(); c2->SaveAs(plots+"SAS_Muon_10to25"+var+"_"+cutpoint+".png"); // c2->Close(); }
void DrawWaveform(char *file, int event, int col, int row, bool common_mode_subtract = false) { TFile *f1 = new TFile(file); TTree *EventTree = (TTree *) f1->Get("EventTree"); float ASIC_ADC[4][4][8][4][64]; unsigned short int ASIC_OriginWindow[4][4][8][4]; bool ASIC_TriggerStream[4][4][8][16]; EventTree->SetBranchAddress("ASIC_ADC",ASIC_ADC); EventTree->SetBranchAddress("ASIC_OriginWindow",ASIC_OriginWindow); EventTree->SetBranchAddress("ASIC_TriggerStream",ASIC_TriggerStream); TCanvas *C = new TCanvas("Waveforms","Waveforms",1024,768); C->Divide(4,2); TGraph *graph[8]; while(1) { EventTree->GetEvent(event); for (int i = 0; i < 8; ++i) { graph[i] = NULL; } for (int ch = 0; ch < 8; ++ch) { if (graph[ch]) { delete graph[ch]; } graph[ch] = new TGraph(); for (int i = 0; i < 4; ++i) { int this_origin_window = ASIC_OriginWindow[col][row][ch][i]; for (int j = 0; j < 64; ++j) { float value = ASIC_ADC[col][row][ch][i][j]; if (common_mode_subtract) { value -= ASIC_ADC[col][row][(ch+1)%8][i][j]; } graph[ch]->SetPoint(i*64+j,(float) i*64+j,value); } } C->cd(ch+1); graph[ch]->Draw("APL"); double low = graph[ch]->GetYaxis()->GetXmin(); double high = graph[ch]->GetYaxis()->GetXmax(); for (int i = 0; i < 4*2; ++i) { int offset = 2; // cout << "Checking window " << offset + i << " : " << ASIC_TriggerStream[col][row][ch][offset+i] << endl; if (ASIC_TriggerStream[col][row][ch][offset+i]) { int window = 8 - i - 1; TBox *highlight = new TBox(window*32,low,(window+1)*32,high); highlight->SetFillColor(kRed); highlight->SetLineColor(kRed); highlight->SetLineWidth(2); highlight->SetFillStyle(0); highlight->Draw(); } } bool any_hit = false; for (int i = 0; i < 16; ++i) { if (ASIC_TriggerStream[col][row][ch][offset+i]) { any_hit = true; break; } } cout << "Window begin at: " << ASIC_OriginWindow[col][row][ch][0] << endl; cout << "Hit status (from trigger stream): " << any_hit << endl; } C->Modified(); C->Update(); getchar(); event++; } }
void NuclearModificationY(){ gROOT->SetStyle("Plain"); gStyle->SetOptTitle(0); gStyle->SetOptStat(0); /* gStyle->SetPadRightMargin(0.010);//###0.020 gStyle->SetPadLeftMargin(0.165); gStyle->SetPadTopMargin(0.075); gStyle->SetPadBottomMargin(0.145); */ TFile*filePPReference=new TFile(Form("../../../fonll/output%sY.root",particle.Data())); //TFile*filePPReference=new TFile(Form("../../fonll/output%sY.root",particle.Data())); TGraphAsymmErrors*gaeBplusReference=(TGraphAsymmErrors*)filePPReference->Get(Form("gaeSigmaDecay%s",particle.Data())); gaeBplusReference->SetName(Form("gae%sReference",particle.Data())); TFile*filepPb=new TFile(Form("../Results%s_y/Sigma%s.root",particle.Data(),particle.Data())); TH1F*hSigmapPbStat=(TH1F*)filepPb->Get("hPtSigma"); double scalingfactor=1e-6; double yvalue,xvalue,yerrorhigh,yerrorlow; for (int i=0;i<nbins;i++){ hSigmapPbStat->SetBinContent(i+1,scalingfactor*hSigmapPbStat->GetBinContent(i+1)); hSigmapPbStat->SetBinError(i+1,scalingfactor*hSigmapPbStat->GetBinError(i+1)); yvalue=-1.; xvalue=-1.; yerrorhigh=-1.; yerrorlow=-1.; gaeBplusReference->GetPoint(i,xvalue,yvalue); yerrorhigh=gaeBplusReference->GetEYhigh()[i]; yerrorlow=gaeBplusReference->GetEYlow()[i]; gaeBplusReference->SetPoint(i,xvalue,yvalue*scalingfactor); gaeBplusReference->SetPointEYhigh(i,yerrorhigh*scalingfactor); gaeBplusReference->SetPointEYlow(i,yerrorlow*scalingfactor); } for (int i=0;i<nbins;i++){ hSigmapPbStat->SetBinContent(i+1,(1./tagandprobcorrection[i])*(hSigmapPbStat->GetBinContent(i+1))); hSigmapPbStat->SetBinError(i+1,(1./tagandprobcorrection[i])*(hSigmapPbStat->GetBinError(i+1))); } Double_t yRefPP[nbins]; //value y reference Double_t xRefPP[nbins]; //value x reference Double_t yPPsystFONLLhigh[nbins]; //y err syst FONLL high Double_t yPPsystFONLLlow[nbins]; //y err syst FONLL low Double_t yPercPPsystFONLLhigh[nbins]; //y percentuale err syst FONLL high Double_t yPercPPsystFONLLlow[nbins]; //y percentuale err syst FONLL low Double_t ySigmapPb[nbins]; //value y pPb Double_t xSigmapPb[nbins]; //value x pPb Double_t ySigmapPbStat[nbins]; //y err stat pPb Double_t yPercSigmapPbStat[nbins]; //y err stat pPb Double_t yFONLL[nbins]; //1 Double_t yRpA[nbins]; //value y RpA Double_t yRpAStat[nbins]; //y err stat RpA Double_t yRpAsystFONLLhigh[nbins]; //y err syst FONLL RpA high Double_t yRpAsystFONLLlow[nbins]; //y err syst FONLL RpA lzow Double_t yPercRpAsystFONLLhigh[nbins]; //y percentuale err syst FONLL RpA high Double_t yPercRpAsystFONLLlow[nbins]; //y percentuale err syst FONLL RpA low Double_t ySigmapPbSystTotHigh[nbins]; //y percentuale err syst pPb TOT Double_t ySigmapPbSystTotLow[nbins]; //y percentuale err syst pPb TOT Double_t yPercRpPbSystTotHigh[nbins]; //y percentuale err syst RpPb TOT Double_t yPercRpPbSystTotLow[nbins]; //y percentuale err syst RpPb TOT Double_t yRpPbSystTotHigh[nbins]; //y percentuale err syst RpPb TOT Double_t yRpPbSystTotLow[nbins]; //y percentuale err syst RpPb TOT Double_t yRFB[nbinsRFB]; Double_t yRFBStat[nbinsRFB]; Double_t yRFBSystTotHigh[nbinsRFB]; Double_t yRFBSystTotLow[nbinsRFB]; double x,y; for (Int_t i=0;i<nbins;i++) { gaeBplusReference->GetPoint(i,xRefPP[i],yRefPP[i]); yPPsystFONLLhigh[i]=gaeBplusReference->GetEYhigh()[i]; yPPsystFONLLlow[i]=gaeBplusReference->GetEYlow()[i]; yPercPPsystFONLLhigh[i]=yPPsystFONLLhigh[i]/yRefPP[i]; yPercPPsystFONLLlow[i]=yPPsystFONLLlow[i]/yRefPP[i]; } for(Int_t i=0;i<nbins;i++) { ySigmapPb[i]=hSigmapPbStat->GetBinContent(i+1); ySigmapPbStat[i]=hSigmapPbStat->GetBinError(i+1); yPercSigmapPbStat[i]=ySigmapPbStat[i]/ySigmapPb[i]; ySigmapPbSystTotHigh[i]=yPercSigmapPbSystTotHigh[i]*ySigmapPb[i]; ySigmapPbSystTotLow[i]=yPercSigmapPbSystTotLow[i]*ySigmapPb[i]; } for(Int_t i=0;i<nbins;i++) { yRpA[i]=ySigmapPb[i]/yRefPP[i]; yRpAStat[i]=ySigmapPbStat[i]/yRefPP[i]; yFONLL[i]=yRpA[i]; yPercRpAsystFONLLhigh[i]=(yPercPPsystFONLLlow[i]/(1-yPercPPsystFONLLlow[i])); yPercRpAsystFONLLlow[i]=(yPercPPsystFONLLhigh[i]/(1+yPercPPsystFONLLhigh[i])); yRpAsystFONLLhigh[i]=yPercRpAsystFONLLhigh[i]*yRpA[i]; yRpAsystFONLLlow[i]=yPercRpAsystFONLLlow[i]*yRpA[i]; yRpPbSystTotHigh[i]=yPercSigmapPbSystTotHigh[i]*yRpA[i]; yRpPbSystTotLow[i]=yPercSigmapPbSystTotLow[i]*yRpA[i]; std::cout << i << " , " << xbins[i] << " , " << ySigmapPb[i] << " , sta: " << ySigmapPbStat[i] << " , syslow: " << ySigmapPbSystTotLow[i] << " ,syshigh: " << ySigmapPbSystTotHigh[i] << std::endl; std::cout << "FONLL: " << yRefPP[i] << " - " << yPPsystFONLLlow[i] << " + " << yPPsystFONLLhigh[i] << std::endl; std::cout << i << " ####### " << xbins[i] << " , " << yRpA[i] << " , sta: " << yRpAStat[i] << " , syslow: " << yRpPbSystTotLow[i] << " ,syshigh: " << yRpPbSystTotHigh[i] << " ,FONLLlow: " << yRpAsystFONLLlow[i] << " , FONLLhigh: " << yRpAsystFONLLhigh[i] << std::endl; } //RFB stuff //central value yRFB[0] = ySigmapPb[3]/ySigmapPb[2]; yRFB[1] = ySigmapPb[4]/ySigmapPb[1]; //Stat. yRFBStat[0] = yRFB[0]*sqrt(pow(ySigmapPbStat[2]/ySigmapPb[2],2)+pow(ySigmapPbStat[3]/ySigmapPb[3],2)); yRFBStat[1] = yRFB[1]*sqrt(pow(ySigmapPbStat[4]/ySigmapPb[4],2)+pow(ySigmapPbStat[1]/ySigmapPb[1],2)); //Syst. yRFBSystTotHigh[0] = yRFB[0]*yRFBSystTotHighRel[0]; yRFBSystTotLow[0] = yRFB[0]*yRFBSystTotLowRel[0]; yRFBSystTotHigh[1] = yRFB[1]*yRFBSystTotHighRel[1]; yRFBSystTotLow[1] = yRFB[1]*yRFBSystTotLowRel[1]; TGraphAsymmErrors *gSigmasyst = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl2,exl2,ySigmapPbSystTotLow,ySigmapPbSystTotHigh); //###TGraphAsymmErrors *gSigmasyst = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl,exl,ySigmapPbSystTotLow,ySigmapPbSystTotHigh); gSigmasyst->SetTitle("Sigma syst uncertainty from pPb"); gSigmasyst->SetMarkerColor(1); gSigmasyst->SetLineColor(1); gSigmasyst->SetLineWidth(3); gSigmasyst->SetMarkerStyle(21); gSigmasyst->SetMarkerColor(1); gSigmasyst->SetFillColor(kYellow-7);//5 gSigmasyst->SetFillStyle(1001); TGraphAsymmErrors*gSigmasyst2=(TGraphAsymmErrors*)gSigmasyst->Clone(); gSigmasyst2->SetMarkerColor(1); gSigmasyst2->SetMarkerStyle(25); gSigmasyst2->SetFillColor(0); gSigmasyst2->SetFillStyle(0); gSigmasyst2->SetLineColor(1);//5 gSigmasyst2->SetLineStyle(1); gSigmasyst2->SetLineWidth(3); //###TGraphAsymmErrors *gSigmastat = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl,exl,ySigmapPbStat,ySigmapPbStat); TGraphAsymmErrors *gSigmastat = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl0,exl0,ySigmapPbStat,ySigmapPbStat); gSigmastat->SetTitle("Sigma stat uncertainty from pPb"); gSigmastat->SetMarkerColor(1); gSigmastat->SetLineColor(1); gSigmastat->SetLineWidth(3); gSigmastat->SetMarkerStyle(21); gSigmastat->SetMarkerColor(1); gSigmastat->SetFillColor(0); gSigmastat->SetFillStyle(0); //###TCanvas *canvasSigma=new TCanvas("canvasSigma","canvasSigma",600,500); TCanvas *canvasSigma=new TCanvas("canvasSigma","canvasSigma",500,500); canvasSigma->cd(); canvasSigma->Range(-1.989924,-0.2917772,25.49622,2.212202); canvasSigma->SetFillColor(0); canvasSigma->SetBorderMode(0); canvasSigma->SetBorderSize(2); canvasSigma->SetLeftMargin(0.200); canvasSigma->SetRightMargin(0.025); canvasSigma->SetTopMargin(0.080); canvasSigma->SetBottomMargin(0.150); canvasSigma->SetFrameBorderMode(0); TH2F* hempty=new TH2F("hempty","",10,-3.5,2.5,10,0,650.); hempty->GetXaxis()->SetTitle("y_{CM}"); hempty->GetXaxis()->CenterTitle(); hempty->GetYaxis()->CenterTitle(); //###hempty->GetYaxis()->SetTitle("d#sigma / dy_{CM}(#mub GeV^{-1}c)"); hempty->GetYaxis()->SetTitle("d#sigma / dy_{CM}(#mub)"); hempty->GetXaxis()->SetTitleOffset(0.90); hempty->GetYaxis()->SetTitleOffset(1.34); hempty->GetXaxis()->SetTitleSize(0.070);//###0.045 hempty->GetYaxis()->SetTitleSize(0.070);//###0.045 hempty->GetXaxis()->SetTitleFont(42); hempty->GetYaxis()->SetTitleFont(42); hempty->GetXaxis()->SetLabelFont(42); hempty->GetYaxis()->SetLabelFont(42); hempty->GetXaxis()->SetLabelSize(0.060);//###0.037 hempty->GetYaxis()->SetLabelSize(0.060);//###0.037 hempty->SetMaximum(2); hempty->SetMinimum(0.); hempty->Draw(); // Histogram style TH1D* hBplusReference = new TH1D("hBplusReference","",nbins,xhbins); TH1D* hBplusReferenceEYhigh = new TH1D("hBplusReferenceEYhigh","",nbins,xhbins); TH1D* hBplusReferenceEYlow = new TH1D("hBplusReferenceEYlow","",nbins,xhbins); for (int i=0;i<nbins;i++){ double xgae,ygae; gaeBplusReference->GetPoint(i,xgae,ygae); hBplusReference->SetBinContent(i+1,ygae); hBplusReferenceEYhigh->SetBinContent(i+1,ygae+gaeBplusReference->GetEYhigh()[i]); hBplusReferenceEYlow->SetBinContent(i+1,ygae-gaeBplusReference->GetEYlow()[i]); } //hBplusReference->SetMarkerColor(1); //hBplusReference->SetMarkerStyle(25); //hBplusReference->SetFillColor(kYellow-7);//5 //hBplusReference->SetFillStyle(1001); hBplusReference->SetLineColor(kAzure-3); hBplusReference->SetLineWidth(3); hBplusReferenceEYhigh->SetLineColor(kAzure-3); hBplusReferenceEYhigh->SetLineWidth(3); hBplusReferenceEYhigh->SetLineStyle(2); hBplusReferenceEYlow->SetLineColor(kAzure-3); hBplusReferenceEYlow->SetLineWidth(3); hBplusReferenceEYlow->SetLineStyle(2); for (int i=0;i<nbins;i++){ double xgae,ygae; gaeBplusReference->GetPoint(i,xgae,ygae); hBplusReference->SetBinContent(i+1,ygae); hBplusReferenceEYhigh->SetBinContent(i+1,ygae+gaeBplusReference->GetEYhigh()[i]); hBplusReferenceEYlow->SetBinContent(i+1,ygae-gaeBplusReference->GetEYlow()[i]); std::cout << "### FONLL (" << i << ") : " << ygae << " + " << gaeBplusReference->GetEYhigh()[i] << " - " << gaeBplusReference->GetEYlow()[i] << std::endl; } for (int i=0;i<nbins;i++){ double xgae,ygae; gSigmastat->GetPoint(i,xgae,ygae); std::cout << "### cross section (" << i << ") : " << ygae << " stat: " << gSigmastat->GetEYhigh()[i] << " syst: " << gSigmasyst->GetEYhigh()[i] << std::endl; } /* hBplusReference->Draw("][,same"); hBplusReferenceEYhigh->Draw("][,same"); hBplusReferenceEYlow->Draw("][,same"); */ /* gaeBplusReference->SetMarkerColor(1); gaeBplusReference->SetMarkerStyle(25); gaeBplusReference->SetFillColor(kYellow-7);//5 gaeBplusReference->SetFillStyle(1001); gaeBplusReference->SetLineColor(kAzure-3);//5 gaeBplusReference->SetLineStyle(1); gaeBplusReference->SetLineWidth(0); gaeBplusReference->Draw("2psame"); TGraphAsymmErrors*gaeBplusReference2=(TGraphAsymmErrors*)gaeBplusReference->Clone(); gaeBplusReference2->SetMarkerColor(1); gaeBplusReference2->SetMarkerStyle(25); gaeBplusReference2->SetFillColor(0); gaeBplusReference2->SetFillStyle(0); gaeBplusReference2->SetLineColor(kAzure-3);//5 gaeBplusReference2->SetLineStyle(1); gaeBplusReference2->SetLineWidth(1); gaeBplusReference2->Draw("2psame"); */ //gSigmasyst->SetFillColor(0); //gSigmasyst->SetFillStyle(0); gSigmasyst->Draw("2esame");//2same gSigmasyst2->Draw("2esame"); hBplusReference->Draw("][,same"); hBplusReferenceEYhigh->Draw("][,same"); hBplusReferenceEYlow->Draw("][,same"); gSigmastat->SetMarkerColor(1); gSigmastat->SetLineColor(1); gSigmastat->SetLineWidth(3); gSigmastat->SetMarkerStyle(21); gSigmastat->SetMarkerColor(1); gSigmastat->SetFillColor(0); gSigmastat->Draw("epsame"); //###TLegend *legendSigma=new TLegend(0.233871,0.6701903,0.5322581,0.7526427,""); //TLegend *legendSigma=new TLegend(0.40,0.60,0.70,0.78,""); TLegend *legendSigma=new TLegend(0.23,0.56,0.57,0.77,""); legendSigma->SetBorderSize(0); legendSigma->SetLineColor(0); legendSigma->SetFillColor(0); legendSigma->SetFillStyle(1001); legendSigma->SetTextFont(42); legendSigma->SetTextSize(0.055);//###0.045 /* TBox *c = new TBox(0.1,1-commonErrorN,4,1+commonErrorP); c->SetLineColor(5); c->SetFillColor(5); c->Draw(); */ gSigmastat->SetMarkerSize(1); TLegendEntry *ent_SigmapPb=legendSigma->AddEntry(gSigmastat,"pPb data","p"); ent_SigmapPb->SetTextFont(42); ent_SigmapPb->SetMarkerColor(1); ent_SigmapPb->SetMarkerStyle(25); ent_SigmapPb->SetLineColor(1); ent_SigmapPb->SetLineWidth(2); ent_SigmapPb->SetLineStyle(0); TLegendEntry *ent_SigmapPbsyst=legendSigma->AddEntry(gSigmasyst,"Syst. pPb data","f"); ent_SigmapPbsyst->SetTextFont(42); ent_SigmapPbsyst->SetMarkerColor(1); ent_SigmapPbsyst->SetMarkerStyle(25); ent_SigmapPbsyst->SetLineColor(1); ent_SigmapPbsyst->SetLineWidth(2); ent_SigmapPbsyst->SetLineStyle(0); /* /// TLegendEntry *ent_SigmapPb=legendSigma->AddEntry(gSigmasyst,"pPb","pf"); ent_SigmapPb->SetTextFont(42); ent_SigmapPb->SetLineColor(1); ent_SigmapPb->SetMarkerColor(1); ent_SigmapPb->SetMarkerStyle(25); //ent_SigmapPb->SetFillColor(kYellow-7);//5 //ent_SigmapPb->SetFillStyle(1001); ent_SigmapPb->SetLineColor(1); ent_SigmapPb->SetLineWidth(0); ent_SigmapPb->SetLineStyle(0); //// */ /* TLegendEntry *ent_Sigmapp=legendSigma->AddEntry(gaeBplusReference,"FONLL pp ref.","fp"); ent_Sigmapp->SetTextFont(42); ent_Sigmapp->SetLineColor(kAzure-3);//5 ent_Sigmapp->SetLineStyle(1); ent_Sigmapp->SetMarkerColor(1); ent_Sigmapp->SetMarkerStyle(25); */ TLegendEntry *ent_Sigmapp=legendSigma->AddEntry(hBplusReference,"Scaled FONLL pp ref.","l"); ent_Sigmapp->SetTextFont(42); ent_Sigmapp->SetLineColor(kAzure-3);//5 ent_Sigmapp->SetLineStyle(1); ent_Sigmapp->SetMarkerColor(1); ent_Sigmapp->SetMarkerStyle(21); TLegendEntry *ent_Sigmapperr=legendSigma->AddEntry(hBplusReferenceEYhigh,"FONLL pp ref. uncert.","l"); ent_Sigmapperr->SetTextFont(42); ent_Sigmapperr->SetLineColor(kAzure-3);//5 ent_Sigmapperr->SetLineStyle(2); ent_Sigmapperr->SetMarkerColor(1); ent_Sigmapperr->SetMarkerStyle(21); legendSigma->Draw("psame"); /* TBox *d = new TBox(0.1,1-commonErrorN,4,1+commonErrorP); d->SetLineColor(1); d->SetFillColor(0); d->Draw(); */ //###TLatex * tlatex1=new TLatex(0.23,0.84,"CMS"); TLatex * tlatex1=new TLatex(0.24,0.85,"CMS"); tlatex1->SetNDC(); tlatex1->SetTextColor(1); tlatex1->SetTextFont(62);//###42 tlatex1->SetTextSize(0.07);//###0.045 tlatex1->Draw(); /* TLatex * tlatex12=new TLatex(0.24,0.80,"Preliminary"); tlatex12->SetNDC(); tlatex12->SetTextColor(1); tlatex12->SetTextFont(52);//###42 tlatex12->SetTextSize(0.05);//###0.045 tlatex12->Draw(); */ TString mypar="B^{+}"; //###TLatex * tlatexlumi=new TLatex(0.671371,0.7801268,"L = 34.8 nb^{-1}"); TLatex * tlatexlumi=new TLatex(0.40,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)"); tlatexlumi->SetNDC(); tlatexlumi->SetTextColor(1); tlatexlumi->SetTextFont(42); tlatexlumi->SetTextSize(0.06);//###0.045 tlatexlumi->Draw(); //###double xpos=0.8528226; //###double ypos=0.6849894; double xpos=0.85; double ypos=0.75; TLatex * tlatex3=new TLatex(xpos,ypos,mypar.Data()); tlatex3->SetNDC(); tlatex3->SetTextColor(1); tlatex3->SetTextFont(42); tlatex3->SetTextSize(0.07);//###0.06 tlatex3->Draw(); //###TLatex * tlatex4=new TLatex(0.51,0.84,"10 < p_{T}^{B} < 60 GeV/c"); TLatex * tlatex4=new TLatex(0.51,0.84,"10 < p_{T} < 60 GeV/c"); tlatex4->SetNDC(); tlatex4->SetTextColor(1); tlatex4->SetTextFont(42); tlatex4->SetTextSize(0.06); tlatex4->Draw(); TLatex * tlatex5=new TLatex(0.62,0.20,Form("Global uncert. %2.1f%%",commonErrorP*100)); tlatex5->SetNDC(); tlatex5->SetTextColor(1); tlatex5->SetTextFont(42); tlatex5->SetTextSize(0.04); tlatex5->Draw(); canvasSigma->SaveAs(Form("../Results%s_y/canvasSigma%s.pdf",particle.Data(),particle.Data())); canvasSigma->SaveAs(Form("../Results%s_y/canvasSigma%s.png",particle.Data(),particle.Data())); canvasSigma->SaveAs(Form("../Results%s_y/canvasSigma%s.eps",particle.Data(),particle.Data())); TGraphAsymmErrors *gRpAstat = new TGraphAsymmErrors(nbins,xbins,yRpA,exl,exl,yRpAStat,yRpAStat); gRpAstat->SetTitle("RpA stat uncertainty from pPb"); gRpAstat->SetMarkerStyle(21); gRpAstat->SetMarkerColor(1); gRpAstat->SetLineColor(1); gRpAstat->SetLineWidth(3); gRpAstat->SetFillColor(0); TGraphAsymmErrors *gRpAsyst = new TGraphAsymmErrors(nbins,xbins,yRpA,exl,exl,yRpPbSystTotLow,yRpPbSystTotHigh); gRpAsyst->SetTitle("RpA syst uncertainty from pPb"); gRpAsyst->SetFillColor(kYellow-7);//###0 //gRpAsyst->SetMarkerSize(0); gRpAsyst->SetLineColor(1); gRpAsyst->SetLineWidth(3); gRpAsyst->SetFillStyle(1001); gRpAsyst->SetMarkerStyle(21); gRpAsyst->SetMarkerColor(1); TGraphAsymmErrors*gRpAsyst2=(TGraphAsymmErrors*)gRpAsyst->Clone(); gRpAsyst2->SetMarkerColor(1); gRpAsyst2->SetMarkerStyle(25); gRpAsyst2->SetFillColor(0); gRpAsyst2->SetFillStyle(0); gRpAsyst2->SetLineColor(1);//5 gRpAsyst2->SetLineStyle(1); gRpAsyst2->SetLineWidth(3); TGraphAsymmErrors *gRpAsystFONLL = new TGraphAsymmErrors(nbins,xbins,yFONLL,exl,exl,yRpAsystFONLLlow,yRpAsystFONLLhigh); gRpAsystFONLL->SetTitle("RpA syst uncertainty from FONLL reference"); gRpAsystFONLL->SetFillColor(0);//5,kYellow-7 gRpAsystFONLL->SetLineColor(kAzure-3);//5 gRpAsystFONLL->SetMarkerColor(4);//kAzure-3); gRpAsystFONLL->SetLineStyle(2);//###1 gRpAsystFONLL->SetLineWidth(3); TGraphAsymmErrors*gRpAsystFONLL2=(TGraphAsymmErrors*)gRpAsystFONLL->Clone(); gRpAsystFONLL2->SetMarkerColor(1); gRpAsystFONLL2->SetMarkerStyle(25); gRpAsystFONLL2->SetFillColor(0); gRpAsystFONLL2->SetFillStyle(0); gRpAsystFONLL2->SetLineColor(kAzure-3);//5 gRpAsystFONLL2->SetLineStyle(2);//###1 gRpAsystFONLL2->SetLineStyle(3); gRpAsystFONLL2->SetLineWidth(3); //### TBox *gRpAsystFONLL_box0 = new TBox(xbins[0]-exl[0],yFONLL[0]-yRpAsystFONLLlow[0],xbins[0]+exl[0],yFONLL[0]+yRpAsystFONLLhigh[0]); gRpAsystFONLL_box0->SetLineColor(kAzure-3); gRpAsystFONLL_box0->SetLineWidth(3); gRpAsystFONLL_box0->SetLineStyle(2); gRpAsystFONLL_box0->SetFillColor(0); gRpAsystFONLL_box0->SetFillStyle(0); TBox *gRpAsystFONLL_box1 = new TBox(xbins[1]-exl[1],yFONLL[1]-yRpAsystFONLLlow[1],xbins[1]+exl[1],yFONLL[1]+yRpAsystFONLLhigh[1]); gRpAsystFONLL_box1->SetLineColor(kAzure-3); gRpAsystFONLL_box1->SetLineWidth(3); gRpAsystFONLL_box1->SetLineStyle(2); gRpAsystFONLL_box1->SetFillColor(0); gRpAsystFONLL_box1->SetFillStyle(0); TBox *gRpAsystFONLL_box2 = new TBox(xbins[2]-exl[2],yFONLL[2]-yRpAsystFONLLlow[2],xbins[2]+exl[2],yFONLL[2]+yRpAsystFONLLhigh[2]); gRpAsystFONLL_box2->SetLineColor(kAzure-3); gRpAsystFONLL_box2->SetLineWidth(3); gRpAsystFONLL_box2->SetLineStyle(2); gRpAsystFONLL_box2->SetFillColor(0); gRpAsystFONLL_box2->SetFillStyle(0); TBox *gRpAsystFONLL_box3 = new TBox(xbins[3]-exl[3],yFONLL[3]-yRpAsystFONLLlow[3],xbins[3]+exl[3],yFONLL[3]+yRpAsystFONLLhigh[3]); gRpAsystFONLL_box3->SetLineColor(kAzure-3); gRpAsystFONLL_box3->SetLineWidth(3); gRpAsystFONLL_box3->SetLineStyle(2); gRpAsystFONLL_box3->SetFillColor(0); gRpAsystFONLL_box3->SetFillStyle(0); TBox *gRpAsystFONLL_box4 = new TBox(xbins[4]-exl[4],yFONLL[4]-yRpAsystFONLLlow[4],xbins[4]+exl[4],yFONLL[4]+yRpAsystFONLLhigh[4]); gRpAsystFONLL_box4->SetLineColor(kAzure-3); gRpAsystFONLL_box4->SetLineWidth(3); gRpAsystFONLL_box4->SetLineStyle(2); gRpAsystFONLL_box4->SetFillColor(0); gRpAsystFONLL_box4->SetFillStyle(0); // Histogram style TH1D* hRpAsystFONLL = new TH1D("hRpAsystFONLL","",nbins,xhbins); TH1D* hRpAsystFONLLEYhigh = new TH1D("hRpAsystFONLLEYhigh","",nbins,xhbins); TH1D* hRpAsystFONLLEYlow = new TH1D("hRpAsystFONLLEYlow","",nbins,xhbins); for (int i=0;i<nbins;i++){ hRpAsystFONLL->SetBinContent(i+1,yFONLL[i]); hRpAsystFONLLEYhigh->SetBinContent(i+1,yFONLL[i]+yRpAsystFONLLhigh[i]); hRpAsystFONLLEYlow->SetBinContent(i+1,yFONLL[i]-yRpAsystFONLLlow[i]); } hRpAsystFONLLEYhigh->SetLineColor(kAzure-3); hRpAsystFONLLEYhigh->SetLineWidth(3); hRpAsystFONLLEYhigh->SetLineStyle(2); hRpAsystFONLLEYhigh->SetFillColor(0); hRpAsystFONLLEYhigh->SetFillStyle(0); hRpAsystFONLLEYlow->SetLineColor(kAzure-3); hRpAsystFONLLEYlow->SetLineWidth(3); hRpAsystFONLLEYlow->SetLineStyle(2); hRpAsystFONLLEYlow->SetFillColor(0); hRpAsystFONLLEYlow->SetFillStyle(0); hRpAsystFONLLEYlow->Draw("][,same"); //###TCanvas *canvasRpA=new TCanvas("canvasRpA","canvasRpA",600,500); TCanvas *canvasRpA=new TCanvas("canvasRpA","canvasRpA",500,500); canvasRpA->Range(-1.989924,-0.2917772,25.49622,2.212202); canvasRpA->SetFillColor(0); canvasRpA->SetBorderMode(0); canvasRpA->SetBorderSize(2); canvasRpA->SetLeftMargin(0.200); canvasRpA->SetRightMargin(0.025); canvasRpA->SetTopMargin(0.080); canvasRpA->SetBottomMargin(0.150); canvasRpA->SetFrameBorderMode(0); canvasRpA->SetFrameBorderMode(0); //###TLegend *legendRpA=new TLegend(0.23,0.58,0.57,0.77,""); TLegend *legendRpA=new TLegend(0.23,0.56,0.57,0.77,""); legendRpA->SetBorderSize(0); legendRpA->SetLineColor(0); legendRpA->SetFillColor(0); legendRpA->SetFillStyle(1001); legendRpA->SetTextFont(42); legendRpA->SetTextSize(0.055);//###0.04 hempty=new TH2F("hempty","",4,-3.5,2.7,40.,0.,4.0); hempty->GetXaxis()->SetTitle("y_{CM}"); /* if(particle=="Bplus") hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA} (B^{+})"); if(particle=="Bzero") hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA} (B^{0})"); if(particle=="Bs") hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA} (B_{s})"); */ hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA}"); hempty->GetXaxis()->CenterTitle(); hempty->GetYaxis()->CenterTitle(); hempty->GetXaxis()->SetTitleOffset(0.90); hempty->GetYaxis()->SetTitleOffset(1.34); hempty->GetXaxis()->SetTitleSize(0.070);//###0.045 hempty->GetYaxis()->SetTitleSize(0.070);//###0.045 hempty->GetXaxis()->SetTitleFont(42); hempty->GetYaxis()->SetTitleFont(42); hempty->GetXaxis()->SetLabelFont(42); hempty->GetYaxis()->SetLabelFont(42); hempty->GetXaxis()->SetLabelSize(0.060);//###0.040 hempty->GetYaxis()->SetLabelSize(0.060);//###0.040 hempty->SetMaximum(4.0); hempty->SetMinimum(0.); hempty->Draw(); TLine *l = new TLine(0,1,70,1); l->SetLineStyle(2); legendRpA->Draw(); gRpAstat->SetMarkerStyle(21); gRpAstat->SetLineColor(1); gRpAstat->SetMarkerColor(1); for (int i=0;i<nbins;i++){ double xgae,ygae; gRpAstat->GetPoint(i,xgae,ygae); std::cout << "####### RpA (" << i << ") : " << ygae << " stat: " << gRpAstat->GetEYhigh()[i] << " syst: " << gRpAsyst->GetEYhigh()[i] << std::endl; std::cout << "########### FONLL (" << i << ") : " << " + " << gRpAsystFONLL->GetEYhigh()[i] << " - " << gRpAsystFONLL->GetEYlow()[i] << std:: endl; } //###gRpAsystFONLL->Draw("e2same");//###2same //###gRpAsystFONLL2->Draw("2esame");//###2same /* gRpAsystFONLL_box0->Draw("same"); gRpAsystFONLL_box1->Draw("same"); gRpAsystFONLL_box2->Draw("same"); gRpAsystFONLL_box3->Draw("same"); gRpAsystFONLL_box4->Draw("same"); */ hRpAsystFONLLEYlow->Draw("][,same"); hRpAsystFONLLEYhigh->Draw("][,same"); gRpAsyst->Draw("2esame"); gRpAsyst2->Draw("2esame"); gRpAstat->Draw("psame"); std::cout << "%%%%%%% RpA commonError " << " - " << commonErrorN << " + " << commonErrorP << std::endl; TBox *b = new TBox(-3.49,1-commonErrorN,-3.1,1+commonErrorP); b->SetLineColor(1); b->SetLineWidth(1); b->SetLineStyle(1); b->SetFillColor(kGray); b->Draw(); TBox *b2=(TBox*)b->Clone(); b2->SetFillStyle(0); b2->SetLineStyle(1); b2->SetLineWidth(1); b2->Draw(); TGraphAsymmErrors*gRpAstat2=(TGraphAsymmErrors*)gRpAstat->Clone(); gRpAstat2->SetTitle("RpA stat uncertainty from pPb"); gRpAstat2->SetMarkerStyle(21); gRpAstat2->SetMarkerColor(1); gRpAstat2->SetLineColor(1); gRpAstat2->SetLineWidth(3); gRpAstat2->SetFillColor(0); gRpAstat2->SetMarkerSize(1.5); TLegendEntry *ent_RpAstat=legendRpA->AddEntry(gRpAstat2,"R^{FONLL}_{pA}","p"); ent_RpAstat->SetTextFont(42); ent_RpAstat->SetMarkerColor(1); ent_RpAstat->SetMarkerStyle(25); ent_RpAstat->SetMarkerSize(30);//###3 //ent_RpAstat->SetFillColor(kYellow-7);//5 //ent_RpAstat->SetFillStyle(1001); ent_RpAstat->SetLineColor(1); ent_RpAstat->SetLineWidth(3); ent_RpAstat->SetLineStyle(0); //TLegendEntry *ent_RpAsyst=legendRpA->AddEntry(gRpAsyst,"R^{FONLL}_{pA}","pf"); TLegendEntry *ent_RpAsyst=legendRpA->AddEntry(gRpAsyst,"Syst. pPb data","f"); ent_RpAsyst->SetTextFont(42); ent_RpAsyst->SetMarkerColor(1); ent_RpAsyst->SetMarkerStyle(25); //ent_RpAsyst->SetFillColor(kYellow-7);//5 //ent_RpAsyst->SetFillStyle(1001); ent_RpAsyst->SetLineColor(1); ent_RpAsyst->SetLineWidth(3); ent_RpAsyst->SetLineStyle(0); TLegendEntry *ent_RpAsystFONLL=legendRpA->AddEntry(gRpAsystFONLL,"Syst. FONLL pp ref.","f"); ent_RpAsystFONLL->SetTextFont(42); ent_RpAsystFONLL->SetLineColor(kAzure-3);//###5 ent_RpAsystFONLL->SetLineStyle(1);//###0 ent_RpAsystFONLL->SetLineWidth(3); ent_RpAsystFONLL->SetMarkerColor(kYellow-7);//5 //###TLegendEntry *ent_RpAsystData=legendRpA->AddEntry(b,"Syst. int. lumi + BR","f"); TLegendEntry *ent_RpAsystData=legendRpA->AddEntry(b,"Syst. int. lumi + B","f"); ent_RpAsystData->SetTextFont(42); ent_RpAsystData->SetLineColor(2); ent_RpAsystData->SetMarkerColor(2); tlatex1->Draw(); //###tlatex12->Draw(); tlatexlumi->Draw(); tlatex3->Draw(); tlatex4->Draw(); canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.pdf",particle.Data(),particle.Data())); canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.png",particle.Data(),particle.Data())); canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.eps",particle.Data(),particle.Data())); canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.ps",particle.Data(),particle.Data())); /* TCanvas *canvasRFB=new TCanvas("canvasRFB","canvasRFB",500,500); canvasRFB->cd(); canvasRFB->Range(-1.989924,-0.2917772,25.49622,2.212202); canvasRFB->SetFillColor(0); canvasRFB->SetBorderMode(0); canvasRFB->SetBorderSize(2); canvasRFB->SetLeftMargin(0.1451613); canvasRFB->SetRightMargin(0.05443548); canvasRFB->SetTopMargin(0.08474576); canvasRFB->SetBottomMargin(0.1165254); canvasRFB->SetFrameBorderMode(0); canvasRFB->SetFrameBorderMode(0); TLegend *legendRFB=new TLegend(0.2560484,0.6490486,0.5483871,0.7716702,""); legendRFB->SetBorderSize(0); legendRFB->SetLineColor(0); legendRFB->SetFillColor(0); legendRFB->SetFillStyle(1001); legendRFB->SetTextFont(42); legendRFB->SetTextSize(0.045); TH2F* hempty=new TH2F("hempty","",4,-0.1,2.,10.,0.,2.5); hempty->GetXaxis()->SetTitle("|y_{CM}|"); hempty->GetYaxis()->SetTitle("R_{FB}"); hempty->GetXaxis()->SetTitleOffset(1.1); hempty->GetYaxis()->SetTitleOffset(1.3); hempty->GetXaxis()->SetTitleSize(0.045); hempty->GetYaxis()->SetTitleSize(0.045); hempty->GetXaxis()->SetTitleFont(42); hempty->GetYaxis()->SetTitleFont(42); hempty->GetXaxis()->SetLabelFont(42); hempty->GetYaxis()->SetLabelFont(42); hempty->GetXaxis()->SetLabelSize(0.04); hempty->GetYaxis()->SetLabelSize(0.04); hempty->GetXaxis()->CenterTitle(); hempty->GetYaxis()->CenterTitle(); hempty->SetMaximum(3); hempty->SetMinimum(0.); hempty->Draw(); legendRFB->Draw(); TGraphAsymmErrors *gRFBsyst = new TGraphAsymmErrors(nbinsRFB,xbinsRFB,yRFB,exlRFB,exlRFB,yRFBSystTotLow,yRFBSystTotHigh); gRFBsyst->SetTitle("gRFBsyst"); gRFBsyst->SetName("gRFBsyst"); gRFBsyst->SetMarkerColor(4); gRFBsyst->SetLineColor(4); gRFBsyst->SetLineWidth(2); gRFBsyst->SetMarkerStyle(0); gRFBsyst->SetMarkerColor(1); TGraphAsymmErrors *gRFBstat = new TGraphAsymmErrors(nbinsRFB,xbinsRFB,yRFB,exlRFB,exlRFB,yRFBStat, yRFBStat); gRFBstat->SetTitle("gRFBstat"); gRFBstat->SetName("gRFBstat"); gRFBstat->SetMarkerColor(1); gRFBstat->SetLineColor(1); gRFBstat->SetLineWidth(2); gRFBstat->SetMarkerStyle(21); gRFBstat->SetMarkerColor(1); gRFBstat->SetFillColor(0); gRFBstat->SetFillStyle(0); gRFBsyst->SetFillColor(0); gRFBsyst->SetFillStyle(0); gRFBsyst->Draw("2same"); gRFBstat->Draw("psame"); TLegendEntry *ent_RFB=legendRFB->AddEntry(gRFBstat,"R_{FB} stat.","pl"); ent_RFB->SetTextFont(42); ent_RFB->SetLineColor(2); ent_RFB->SetMarkerColor(2); TLegendEntry *ent_RFB=legendRFB->AddEntry(gRFBsyst,"R_{FB} syst.","l"); ent_RFB->SetTextFont(42); ent_RFB->SetLineColor(4); // ent_RFB->SetMarkerColor(2); TLatex * tlatex1=new TLatex(0.1612903,0.8625793,"CMS pPb #sqrt{s_{NN}}= 5.02 TeV"); tlatex1->SetNDC(); tlatex1->SetTextColor(1); tlatex1->SetTextFont(42); tlatex1->SetTextSize(0.045); tlatex1->Draw(); TLatex * tlatexlumi=new TLatex(0.671371,0.7801268,"L = 34.8 nb^{-1}"); tlatexlumi->SetNDC(); tlatexlumi->SetTextColor(1); tlatexlumi->SetTextFont(42); tlatexlumi->SetTextSize(0.045); tlatexlumi->Draw(); //double xpos1=0.6528226; // double ypos1=0.6849894; TLatex * tlatex3=new TLatex(xpos,ypos,mypar.Data()); tlatex3->SetNDC(); tlatex3->SetTextColor(1); tlatex3->SetTextFont(42); tlatex3->SetTextSize(0.06); tlatex3->Draw(); canvasRFB->SaveAs(Form("../Results%s_y/CanvasRDFB.pdf",particle.Data(),particle.Data())); */ // l->Draw(); // canvasRpA->SaveAs(Form("../Results%sY/canvasRpA%s.pdf",particle.Data(),particle.Data())); // canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.pdf",particle.Data(),particle.Data())); // TFile *fout=new TFile(Form("../Results%sY/fileRpA%s.root",particle.Data(),particle.Data()),"recreate"); TFile *fout=new TFile(Form("../Results%s_y/fileRpA%s.root",particle.Data(),particle.Data()),"recreate"); fout->cd(); gSigmasyst->SetName("gSigmasyst"); gSigmasyst->Write(); gaeBplusReference->Write(); hSigmapPbStat->Write(); }
void Optimize2D(TString signal, TString background, TString histname, int minxwidth = 2, int minywidth = 2, float minsigeff=0.5){ TFile *sigfile = TFile::Open(signal); TFile *bkgfile = TFile::Open(background); TH2F *sighist = (TH2F*)sigfile->Get(histname); TH2F *bkghist = (TH2F*)bkgfile->Get(histname); int nxbins = sighist->GetNbinsX(); int nybins = sighist->GetNbinsY(); if ( nxbins != bkghist->GetNbinsX() || nybins != bkghist->GetNbinsY() ) { cout << "Error! The two input histograms do not have the same number of bins!" << endl; return; } int nsigtot = sighist->Integral(1,nxbins,1,nybins); int nbkgtot = bkghist->Integral(1,nxbins,1,nybins); cout << "Total number of entries in the signal histogram: " << nsigtot << endl; cout << "Total number of entries in the bkgrnd histogram: " << nbkgtot << endl; if ( nsigtot==0 || nbkgtot==0 ) { cout << "Error! At least one of the input histograms is empty!" << endl; return; } TH1D *projx = sighist->ProjectionX("projx"); TH1D *projy = sighist->ProjectionY("projy"); float bestsob = (float)nsigtot / nbkgtot; cout << "Starting with a \"no-cuts\" s/b of " << bestsob << endl; float x1=0, y1=0, x2=0, y2=0; // corner coordinates for the window for (int i=1; i<=nxbins; ++i) for (int j=minxwidth-1; i+j<=nxbins; ++j) for (int k=1; k<=nybins; ++k) for (int l=minywidth-1; k+l<=nybins; ++l) { int nsig = sighist->Integral(i, i+j, k, k+l); if ( nsig == 0 ) continue; if ( nsig < nsigtot*minsigeff ) continue; int nbkg = bkghist->Integral(i, i+j, k, k+l); if ( nbkg == 0 ) continue; float sob = (float)nsig / nbkg; if ( (float)nsig / nbkg > bestsob ) { bestsob = sob; x1 = projx->GetBinLowEdge(i); x2 = projx->GetBinLowEdge(i+j+1); y1 = projy->GetBinLowEdge(k); y2 = projy->GetBinLowEdge(k+l+1); cout << "x-range " << i << " (" << x1 << ") to " << i+j << " (" << x2 << ") ; \t y-range " << k << " (" << y1 <<") to " << k+l << " (" << y2 << ") ; \t signal= " << nsig << " bkgrnd= " << nbkg << " s/b= " << sob << endl; } } TCanvas *cnv = TCanvas::MakeDefCanvas(); cnv->Divide(2); TBox *box = new TBox(x1, y1, x2, y2); box->SetFillStyle(0); box->SetLineColor(2); box->SetLineWidth(2); cnv->cd(1); sighist->Draw("colbox"); box->Draw(); cnv->cd(2); bkghist->Draw("colbox"); box->Draw(); cnv->SaveAs("Optimize2D"+histname+".eps"); }
void makePlotsPP(Settings s) { for(int j = 0; j<s.nTriggers; j++) { s.ppByTrigger[j]->SetLineColor(j+1); s.ppByTrigger[j]->SetLineWidth(1); s.ppByTrigger[j]->SetMarkerColor(j+1); s.ppByTrigger[j]->SetFillColor(j+1); s.ppUsedByTrigger[j]->SetLineColor(kBlack); s.ppUsedByTrigger[j]->SetLineWidth(2); s.ppUsedByTrigger[j]->SetMarkerColor(j+1); s.ppUsedByTrigger[j]->SetMarkerSize(0); s.ppUsedByTrigger[j]->SetFillColor(j+1); s.ppJetsByTrigger[j]->SetLineColor(j+1); s.ppJetsByTrigger[j]->SetLineWidth(1); s.ppJetsByTrigger[j]->SetMarkerColor(j+1); s.ppJetsByTrigger[j]->SetMarkerSize(0.8); s.ppJetsByTrigger[j]->SetFillColor(j+1); } for(int j = 0; j<s.nTriggers_trk; j++) { s.ppByTrigger_trk[j]->SetLineColor(j+1); s.ppByTrigger_trk[j]->SetLineWidth(1); s.ppByTrigger_trk[j]->SetMarkerColor(j+1); s.ppByTrigger_trk[j]->SetFillColor(j+1); s.ppUsedByTrigger_trk[j]->SetLineColor(kBlack); s.ppUsedByTrigger_trk[j]->SetLineWidth(2); s.ppUsedByTrigger_trk[j]->SetMarkerColor(j+1); s.ppUsedByTrigger_trk[j]->SetMarkerSize(0); s.ppUsedByTrigger_trk[j]->SetFillColor(j+1); s.ppMaxtrkByTrigger[j]->SetLineColor(j+1); s.ppMaxtrkByTrigger[j]->SetLineWidth(1); s.ppMaxtrkByTrigger[j]->SetMarkerColor(j+1); s.ppMaxtrkByTrigger[j]->SetMarkerSize(0.8); s.ppMaxtrkByTrigger[j]->SetFillColor(j+1); } //****************************************************************************************************************** //************************************************JET TRIGGER PLOTS********************************************************** //****************************************************************************************************************** TCanvas * c1 = new TCanvas("c1","c1",800,600); c1->SetLogy(); s.ppJets->Scale(100); float Ymin = 0.00000000001; float Ymax = 10; s.ppJets->GetYaxis()->SetRangeUser(Ymin,Ymax); s.ppJets->Draw("h"); for(int i = 0; i<s.nTriggers; i++) s.ppJetsByTrigger[i]->Draw("same"); TLegend * leg = new TLegend(0.47,0.62,0.87,0.92); leg->AddEntry(s.ppJets,"Jet Spectrum (x100)","l"); leg->AddEntry(s.ppJetsByTrigger[0],"MB (I)","p"); leg->AddEntry(s.ppJetsByTrigger[1],"jet 40 (II)","p"); leg->AddEntry(s.ppJetsByTrigger[2],"jet 60 (III)","p"); leg->AddEntry(s.ppJetsByTrigger[3],"jet 80 (IV)","p"); leg->AddEntry((TObject*)0,"ak4Calo Jets, |#eta|<2",""); leg->Draw("same"); c1->SaveAs("plots/png/ppJets_FullSpectrum.png"); c1->SaveAs("plots/pdf/ppJets_FullSpectrum.pdf"); s.ppJets->GetXaxis()->SetRangeUser(20,200); Ymin = 0.0000001; Ymax = 100; s.ppJets->GetYaxis()->SetRangeUser(0.0000001,100); s.ppJets->Draw("h"); for(int i = 0; i<s.nTriggers; i++) s.ppJetsByTrigger[i]->Draw("same"); leg->Draw("same"); TLine * l[3]; for(int i = 0; i<3; i++) { l[i] = new TLine(s.triggerBins[i+1],Ymin,s.triggerBins[i+1],Ymax); l[i]->SetLineWidth(2); l[i]->SetLineStyle(2); l[i]->SetLineColor(1); l[i]->Draw("same"); } TLatex * lat = new TLatex(1,1,"test"); lat->DrawLatex(45,Ymin*3,"I"); lat->DrawLatex(65,Ymin*3,"II"); lat->DrawLatex(85,Ymin*3,"III"); lat->DrawLatex(105,Ymin*3,"IV"); c1->SaveAs("plots/png/ppJets_FullSpectrum_XZoom.png"); c1->SaveAs("plots/pdf/ppJets_FullSpectrum_XZoom.pdf"); c1->SetLogy(0); for(int i = 0; i<s.nTriggers-1; i++) s.ppJetsByTrigger[s.nTriggers-1-i]->Divide(s.ppJetsByTrigger[s.nTriggers-2-i]); s.ppJetsByTrigger[1]->GetYaxis()->SetRangeUser(0,2); s.ppJetsByTrigger[1]->GetXaxis()->SetRangeUser(20,140); s.ppJetsByTrigger[1]->GetXaxis()->SetTitle("Leading jet p_{T}"); s.ppJetsByTrigger[1]->Draw(); s.ppJetsByTrigger[2]->Draw("same"); s.ppJetsByTrigger[3]->Draw("same"); TLegend * leg2 = new TLegend(0.2,0.6,0.5,0.9); leg2->AddEntry(s.ppJetsByTrigger[1],"Jet40/MB","p"); leg2->AddEntry(s.ppJetsByTrigger[2],"Jet60/Jet40","p"); leg2->AddEntry(s.ppJetsByTrigger[3],"Jet80/Jet60","p"); leg2->Draw("same"); c1->SaveAs("plots/png/JetRelativeTurnOnes.png"); c1->SaveAs("plots/pdf/JetRelativeTurnOnes.pdf"); c1->SetLogy(); c1->SetLogx(); s.pp->SetMarkerSize(0.8); s.pp->GetXaxis()->SetRangeUser(0.7,400); s.pp->Draw(); s.ppUsedByTrigger[0]->SetFillColor(kGray); s.ppUsedByTrigger[3]->SetFillColor(kCyan+2); s.ppUsedByTrigger[2]->Add(s.ppUsedByTrigger[3]); s.ppUsedByTrigger[1]->Add(s.ppUsedByTrigger[2]); s.ppUsedByTrigger[0]->Add(s.ppUsedByTrigger[1]); for(int i = 0; i<s.nTriggers; i++) s.ppUsedByTrigger[i]->Draw("HIST same"); s.pp->Draw("sameaxis"); s.pp->Draw("same"); leg->Clear(); leg->AddEntry(s.pp,"pp track Spectrum","p"); leg->AddEntry(s.ppUsedByTrigger[0],"MB trigger","f"); leg->AddEntry(s.ppUsedByTrigger[1],"Jet40 trigger","f"); leg->AddEntry(s.ppUsedByTrigger[2],"Jet60 trigger","f"); leg->AddEntry(s.ppUsedByTrigger[3],"Jet80 trigger","f"); leg->AddEntry((TObject*)0,"|#eta|<1",""); leg->Draw("same"); c1->SaveAs("plots/png/ppTrack_FullSpectrum.png"); c1->SaveAs("plots/pdf/ppTrack_FullSpectrum.pdf"); c1->SetLogy(0); for(int i = 0; i<s.nTriggers; i++) s.ppUsedByTrigger[i]->Divide(s.pp); s.ppUsedByTrigger[0]->GetYaxis()->SetRangeUser(0,2); s.ppUsedByTrigger[0]->GetYaxis()->SetTitle("Relative Contribution to Bin"); s.ppUsedByTrigger[0]->Draw("HIST"); for(int i = 1; i<s.nTriggers; i++) s.ppUsedByTrigger[i]->Draw("HIST same"); s.ppUsedByTrigger[0]->Draw("sameaxis"); leg->Draw("same"); c1->SaveAs("plots/png/ppTrack_FullSpectrum_relativeContribution.png"); c1->SaveAs("plots/pdf/ppTrack_FullSpectrum_relativeContribution.pdf"); c1->SetLogy(); TH1D * jtVsTrk = (TH1D*)s.pp->Clone("jtVsTrkRatio"); //xt plot TFile * outF = TFile::Open("Spectra.root","UPDATE"); TH1D * pp_perMBTrigger_xt = (TH1D*)s.pp_perMBTrigger->Clone("pp_perMBTrigger_xt"); pp_perMBTrigger_xt->Scale(TMath::Power(5020,4.9)); TH1D * pp_xt = new TH1D("ppTrackSpectrum_xt",";x_{T};#sqrt{s}^{4.9}E#frac{d^{3}#sigma}{d^{3}p} (mb/GeV^{2})",s.ntrkBins,s.xt_xtrkbins); for(int i = 1; i< pp_xt->GetSize()-1; i++){ pp_xt->SetBinContent(i,pp_perMBTrigger_xt->GetBinContent(i)); pp_xt->SetBinError(i,pp_perMBTrigger_xt->GetBinError(i)); } pp_xt->Draw(); pp_xt->Print("All"); pp_xt->Write(); c1->SaveAs("plots/png/ppTrack_xt_FullSpectrum.png"); c1->SaveAs("plots/pdf/ppTrack_xt_FullSpectrum.pdf"); outF->Close(); //RpPb bin shift correction //interpolation points float ppintyvals[37+1] = {4.1202/0.5946, 2.8116/0.6211, 1.9778/0.6552, 1.4330/0.6984, 1.0405/0.7219, 0.7719/0.7515, 0.5816/0.7809, 0.3893/0.825, 0.23381/0.866, 0.14395/0.901, 0.09103/0.925, 0.05937/0.965, 0.03906/0.984, 0.014787/1.023, 0.003806/1.052, 0.001181/1.056, 0.0004290/1.048, 0.0001787/1.054, 0.00008152/1.031, 0.00002216/1.023, 0.000004653/1.036, 0.000001402/1.054, 0.0000003180/1.072, 0.00000006850/1.142, 0.00000001971/1.189, 0.000000006013/1.259, 0.000000001910/1.308, 0.0000000007181/1.342, 0.0000000002083/1.382,0.00000000005311/1.407,0.00000000001639/1.363,0.000000000005354/1.381,0.000000000001709/1.316,0,0 };//first 2 points were 4.1202/0.5946*0.999, 2.8116/0.6211*1.003 //float ppintyvals_pPb[s.ntrkBins+1] = {4.1202*0.999, 2.8116*1.003, 1.9778*1.002, 1.4330*0.994 , 1.0405*1.002, 0.7719*1.002, 0.5816*1.002, 0.3893*1.001, 0.23381*1.000, 0.14395*1.004, 0.09103*1.005, 0.05937*0.997, 0.03906*0.998, 0.014787*1.062, 0.003806*1.042, 0.001181*1.033, 0.0004290*1.024, 0.0001787*1.018, 0.00008152*1.015, 0.00002216* 1.109, 0.000004653*1.061, 0.000001402*1.040, 0.0000003180*1.111, 0.00000006850*1.065, 0.00000001971*1.044, 0.000000006013*1.051, 0.000000001910*1.033, 0.0000000007181*1.024, 0.0000000002083*1.078,0.00000000005311*1.05,0.00000000001639*1.034386,0.000000000005354*1.047316,0.000000000001709*1.032760,0,0 }; float ppintyvals_pPb[37+1] = { 4.1202, 2.8116,1.9778, 1.4330 , 1.0405, 0.7719, 0.5816, 0.3893, 0.23381, 0.14395, 0.09103, 0.05937, 0.03906, 0.014787, 0.003806, 0.001181, 0.0004290, 0.0001787, 0.00008152, 0.00002216, 0.000004653, 0.000001402, 0.0000003180, 0.00000006850, 0.00000001971, 0.000000006013, 0.000000001910, 0.0000000007181, 0.0000000002083,0.00000000005311,0.00000000001639,0.000000000005354,0.000000000001709,0,0 };//first 2 points were 4.1202, 2.8116 float ppintyvals_RpPb[37+1] = { 0.5946, 0.6211, 0.6552, 0.6984,0.7219,0.7515, 0.7809, 0.825, 0.866, 0.901, 0.925, 0.965, 0.984, 1.023, 1.052,1.056, 1.048, 1.054, 1.031, 1.023, 1.036, 1.054, 1.072, 1.142, 1.189, 1.259, 1.308, 1.342,1.382,1.407,1.363,1.381,1.316,0,0 };//first 2 points were 0.5946, 0.6211 float ppintyerrRpPb[37+1] = {0.0027/0.5946,0.0028/0.6211, 0.0030/0.6552,0.0032/0.6984,0.0033/0.7219,0.0034/0.7515,0.0036/0.7809,0.003/0.825,0.003/0.866,0.003/0.901,0.003/0.925,0.003/0.965,0.003/0.984,0.002/1.023,0.002/1.052,0.002/1.056,0.002/1.048,0.003/1.054,0.003/1.031,0.003/1.023,0.005/1.036,0.008/1.054,0.001/1.072,0.002/1.142,0.001/1.189,0.002/1.259,0.002/1.308,0.004/1.342,0.004/1.382,0.008/1.407,0.013/1.363,0.019/1.381,0.030/1.316,0,0 };//first 2 points were 0.0027/0.5946,0.0028/0.6211 float ppintyerr_pPb[37+1] = {0.0188/4.1202,0.0128/2.8116, 0.0090/1.9778,0.0065/1.4330,0.0047/1.0405,0.0035/0.7719,0.0026/0.5816,0.0013/0.3893,0.00076/0.23381,0.00047/0.14395,0.00029/0.09103,0.00019/0.05937,0.00013/0.03906,0.000026/0.014787,0.000007/0.003806,0.000002/0.001181,0.0000009/0.0004290,0.0000004/0.0001787,0.00000025/0.00008152,0.00000025/0.00002216,0.00000006/0.000004653,0.000000023/0.000001402,0.000000011/0.0000003180,0.0000000004/0.00000006850,0.00000000011/0.00000001971,0.00000000002/0.000000006013,0.000000000009/0.000000001910,0.000000000004/0.0000000007181,0.0000000000020/0.0000000002083,0.0000000000007/0.00000000005311,0.00000000000031/0.00000000001639,0.00000000000016/0.000000000005354,0.000000000000073/0.000000000001709,0,0 };//first 2 points were 0.0188/4.1202,0.0128/2.8116 TH1D * RpPb = new TH1D("pp_interpolation",";pt;E#frac{d^{3}N}{dPtdyd#phi}",s.ntrkBins,s.xtrkbins); TH1D * RpPbSpectrum = new TH1D("RpPb_interp",";pt;RpPb",s.ntrkBins,s.xtrkbins); TH1D * pPbSpectrum = new TH1D("pPb_data",";pt;E#frac{d^{3}N}{dPtdyd#phi}",s.ntrkBins,s.xtrkbins); for(int i=1; i<s.ntrkBins+1; i++) RpPb->SetBinContent(i,ppintyvals[i-1]); for(int i=1; i<s.ntrkBins+1; i++) RpPb->SetBinError(i,TMath::Power(TMath::Abs(TMath::Power(ppintyerrRpPb[i-1],2)-TMath::Power(ppintyerr_pPb[i-1],2)),0.5)*ppintyvals[i-1]); for(int i=1; i<s.ntrkBins+1; i++) RpPbSpectrum->SetBinContent(i,ppintyvals_RpPb[i-1]); for(int i=1; i<s.ntrkBins+1; i++) RpPbSpectrum->SetBinError(i,ppintyvals_RpPb[i-1]*ppintyerrRpPb[i-1]); for(int i=1; i<s.ntrkBins+1; i++) pPbSpectrum->SetBinContent(i,ppintyvals_pPb[i-1]); for(int i=1; i<s.ntrkBins+1; i++) pPbSpectrum->SetBinError(i,ppintyvals_pPb[i-1]*ppintyerr_pPb[i-1]); //float ppScale = RpPb->GetBinContent(17)/s.pp->GetBinContent(17); //s.pp->Scale(ppScale); TFile * binShift = TFile::Open("BinningAndResolutionCorrection_TrackTrigger.root","read"); TH1D *hBinningAndResol_extendedPt = (TH1D*)binShift->Get("hPt_pseudo2_copy1"); hBinningAndResol_extendedPt->SetDirectory(0); binShift->Close(); /*TH1D *pp_BinShift = (TH1D*)s.pp->Clone("pp_BinShift"); for(int i = 2; i<hBinningAndResol_extendedPt->GetSize()+1; i++) { pp_BinShift->SetBinContent(i-1,pp_BinShift->GetBinContent(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); pp_BinShift->SetBinError(i-1,pp_BinShift->GetBinError(i-1)/hBinningAndResol_extendedPt->GetBinError(i)); }*/ TFile * outBinF = TFile::Open("Spectra.root","update"); hBinningAndResol_extendedPt->Write("RpPb_binShift_Correction"); TH1D *pp_BinShift = (TH1D*)s.pp_perMBTrigger->Clone("pp_BinShift"); TH1D *pp_BinShift_MB = (TH1D*)s.ppByTrigger[0]->Clone("pp_BinShift_MB"); for(int i = 2; i<hBinningAndResol_extendedPt->GetSize()+1; i++) { pp_BinShift->SetBinContent(i-1,pp_BinShift->GetBinContent(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); pp_BinShift->SetBinError(i-1,pp_BinShift->GetBinError(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); pp_BinShift_MB->SetBinContent(i-1,pp_BinShift_MB->GetBinContent(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); pp_BinShift_MB->SetBinError(i-1,pp_BinShift_MB->GetBinError(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); } pp_BinShift->Write(); pp_BinShift_MB->Write(); RpPbSpectrum->Write("RpPb_Published"); c1->SetLogy(0); //pPbSpectrum->Divide(s.pp); pPbSpectrum->Divide(pp_BinShift); pPbSpectrum->Scale(1.0/0.098);//<T_{pPb}> From HIN-012-017 pPbSpectrum->Print("All"); pPbSpectrum->GetYaxis()->SetTitle("RpPb"); pPbSpectrum->GetYaxis()->SetRangeUser(0.5,1.5); pPbSpectrum->Draw(); pPbSpectrum->Write("RpPb"); c1->SaveAs("plots/png/pp_RpPb.png"); c1->SaveAs("plots/png/pp_RpPb.pdf"); c1->SaveAs("plots/png/pp_RpPb.C"); /*s.pp->Divide(RpPb); s.pp->GetYaxis()->SetTitle("data/interp"); s.pp->Draw(); */ pp_BinShift->Divide(RpPb); pp_BinShift->GetYaxis()->SetTitle("data/interp"); pp_BinShift->Scale(0.098); pp_BinShift->GetYaxis()->SetRangeUser(0.5,1.5); pp_BinShift->Draw(); pp_BinShift->Write("RpPb_ppVsInterpolation"); float TAAUncert = 0.177; TBox* bTAA = new TBox(0.15,0.1,0.2,0.2); bTAA->SetFillColor(kBlue-9); bTAA->SetFillStyle(1001); bTAA->SetLineWidth(0); bTAA->DrawBox(200,1-TAAUncert,300,1+TAAUncert); c1->SaveAs("plots/png/pp_dataVsInterp.png"); c1->SaveAs("plots/pdf/pp_dataVsInterp.pdf"); c1->SaveAs("plots/png/pp_dataVsInterp.C"); pp_BinShift_MB->Divide(RpPb); pp_BinShift_MB->GetYaxis()->SetTitle("MB data/interp"); //take lumi normalization from the previous made plot (should be same at low pt) float MBScale = pp_BinShift_MB->GetBinContent(5)/pp_BinShift->GetBinContent(5); pp_BinShift_MB->Scale(1/MBScale); pp_BinShift_MB->GetYaxis()->SetRangeUser(0.5,1.5); pp_BinShift_MB->SetMarkerColor(kRed); pp_BinShift_MB->SetLineColor(kRed); pp_BinShift_MB->Draw("same"); TLegend * ppCompareLeg = new TLegend(0.2,0.2,0.5,0.5); ppCompareLeg->AddEntry(pp_BinShift,"Trigger Combined","p"); ppCompareLeg->AddEntry(pp_BinShift_MB,"Only MB","p"); ppCompareLeg->Draw("same"); c1->SaveAs("plots/png/pp_dataVsInterp_MBData_PlusTrigger.png"); c1->SaveAs("plots/pdf/pp_dataVsInterp_MBData_PlusTrigger.pdf"); c1->SaveAs("plots/png/pp_dataVsInterp_MBData_PlusTrigger.C"); delete ppCompareLeg; pp_BinShift_MB->SetMarkerColor(kBlack); pp_BinShift_MB->SetLineColor(kBlack); pp_BinShift_MB->Draw(); pp_BinShift_MB->Write("RpPb_ppVsInterpolation_MBData"); c1->SaveAs("plots/png/pp_dataVsInterp_MBData.png"); c1->SaveAs("plots/pdf/pp_dataVsInterp_MBData.pdf"); c1->SaveAs("plots/png/pp_dataVsInterp_MBData.C"); outBinF->Close(); //************************************************************************************************************ //***********************************************TRACK TRIGGER PLOTS****************************************** //************************************************************************************************************ TCanvas * c2 = new TCanvas("c2","c2",800,600); s.ppMaxtrkByTrigger[4]->SetMarkerColor(kOrange); s.ppMaxtrkByTrigger[4]->SetLineColor(kOrange); c2->SetLogy(); s.ppMaxtrk->Scale(100); Ymin = 0.00000000001; Ymax = 10; s.ppMaxtrk->GetYaxis()->SetRangeUser(Ymin,Ymax); s.ppMaxtrk->Draw("h"); for(int i = 0; i<s.nTriggers_trk; i++) s.ppMaxtrkByTrigger[i]->Draw("same"); TLegend * leg_trk = new TLegend(0.6,0.6,0.9,0.9); leg_trk->AddEntry(s.ppMaxtrk,"Leading Trk p_{T}Spectrum (x100)","l"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[0],"MB (I)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[1],"Track 18 (II)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[2],"Track 24 (III)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[3],"Track 34 (IV)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[4],"Track 45 (V)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[5],"Track 53 (VI)","p"); leg_trk->Draw("same"); c2->SaveAs("plots/png/ppMaxtrk_FullSpectrum.png"); c2->SaveAs("plots/pdf/ppMaxtrk_FullSpectrum.pdf"); s.ppMaxtrk->GetXaxis()->SetRangeUser(10,90); Ymin = 0.0000000001; Ymax = 1; s.ppMaxtrk->GetYaxis()->SetRangeUser(Ymin,Ymax); s.ppMaxtrk->Draw("h"); for(int i = 0; i<s.nTriggers_trk; i++) s.ppMaxtrkByTrigger[i]->Draw("same"); leg_trk->Draw("same"); TLine * l_trk[5]; for(int i = 0; i<5; i++) { l_trk[i] = new TLine(s.triggerBins_trk[i+1],Ymin,s.triggerBins_trk[i+1],Ymax); l_trk[i]->SetLineWidth(2); l_trk[i]->SetLineStyle(2); l_trk[i]->SetLineColor(1); l_trk[i]->Draw("same"); } lat->DrawLatex(16,Ymin*3,"I"); lat->DrawLatex(22,Ymin*3,"II"); lat->DrawLatex(28,Ymin*3,"III"); lat->DrawLatex(40,Ymin*3,"IV"); lat->DrawLatex(49,Ymin*3,"V"); lat->DrawLatex(57,Ymin*3,"VI"); c2->SaveAs("plots/png/ppMaxtrk_FullSpectrum_XZoom.png"); c2->SaveAs("plots/pdf/ppMaxtrk_FullSpectrum_XZoom.pdf"); c2->SetLogy(0); for(int i = 0; i<s.nTriggers_trk; i++) s.ppMaxtrkByTrigger[i]->Rebin(2); for(int i = 0; i<s.nTriggers_trk-1; i++) s.ppMaxtrkByTrigger[s.nTriggers_trk-1-i]->Divide(s.ppMaxtrkByTrigger[s.nTriggers_trk-2-i]); s.ppMaxtrkByTrigger[1]->GetYaxis()->SetRangeUser(0,2); s.ppMaxtrkByTrigger[1]->GetXaxis()->SetRangeUser(10,90); s.ppMaxtrkByTrigger[1]->GetXaxis()->SetTitle("Leading Track p_{T}"); s.ppMaxtrkByTrigger[1]->Draw(); s.ppMaxtrkByTrigger[2]->Draw("same"); s.ppMaxtrkByTrigger[3]->Draw("same"); s.ppMaxtrkByTrigger[4]->Draw("same"); s.ppMaxtrkByTrigger[5]->Draw("same"); TLegend * leg2_trk = new TLegend(0.2,0.6,0.5,0.9); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[1],"Trk18/MB","p"); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[2],"Trk24/Trk18","p"); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[3],"Trk34/Trk24","p"); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[4],"Trk45/Trk34","p"); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[5],"Trk53/Trk45","p"); leg2_trk->Draw("same"); c2->SaveAs("plots/png/TrackRelativeTurnOnes.png"); c2->SaveAs("plots/pdf/TrackRelativeTurnOnes.pdf"); c2->SetLogy(); c2->SetLogx(); s.pp_trk->SetMarkerSize(0.8); s.pp_trk->GetXaxis()->SetRangeUser(0.7,400); s.pp_trk->Draw(); s.ppUsedByTrigger_trk[0]->SetFillColor(kGray); s.ppUsedByTrigger_trk[3]->SetFillColor(kBlue); s.ppUsedByTrigger_trk[4]->SetFillColor(kViolet); s.ppUsedByTrigger_trk[5]->SetFillColor(kCyan+2); s.ppUsedByTrigger_trk[4]->Add(s.ppUsedByTrigger_trk[5]); s.ppUsedByTrigger_trk[3]->Add(s.ppUsedByTrigger_trk[4]); s.ppUsedByTrigger_trk[2]->Add(s.ppUsedByTrigger_trk[3]); s.ppUsedByTrigger_trk[1]->Add(s.ppUsedByTrigger_trk[2]); s.ppUsedByTrigger_trk[0]->Add(s.ppUsedByTrigger_trk[1]); for(int i = 0; i<s.nTriggers_trk; i++) s.ppUsedByTrigger_trk[i]->Draw("HIST same"); s.pp_trk->Draw("sameaxis"); s.pp_trk->Draw("same"); leg_trk->Clear(); leg_trk->AddEntry(s.pp_trk,"pp track Spectrum","p"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[0],"MB trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[1],"Track18 trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[2],"Track24 trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[3],"Track34 trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[4],"Track45 trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[5],"Track53 trigger","f"); leg_trk->AddEntry((TObject*)0,"|#eta|<1",""); leg_trk->Draw("same"); c2->SaveAs("plots/png/ppTrack_FullSpectrum_trk.png"); c2->SaveAs("plots/pdf/ppTrack_FullSpectrum_trk.pdf"); c2->SetLogy(0); for(int i = 0; i<s.nTriggers_trk; i++) s.ppUsedByTrigger_trk[i]->Divide(s.pp_trk); s.ppUsedByTrigger_trk[0]->GetYaxis()->SetRangeUser(0,2); s.ppUsedByTrigger_trk[0]->GetYaxis()->SetTitle("Relative Contribution to Bin"); s.ppUsedByTrigger_trk[0]->Draw("HIST"); for(int i = 1; i<s.nTriggers_trk; i++) s.ppUsedByTrigger_trk[i]->Draw("HIST same"); s.ppUsedByTrigger_trk[0]->Draw("sameaxis"); leg_trk->Draw("same"); c2->SaveAs("plots/png/ppTrack_FullSpectrum_trk_relativeContribution.png"); c2->SaveAs("plots/pdf/ppTrack_FullSpectrum_trk_relativeContribution.pdf"); c2->SetLogy(); c2->SetLogy(0); jtVsTrk->Divide(s.pp_trk); jtVsTrk->GetYaxis()->SetTitle("pp Jet triggers/pp Track triggers"); jtVsTrk->GetYaxis()->SetRangeUser(0.5,1.5); jtVsTrk->Draw(); TLegend *leg3 = new TLegend(0.2,0.7,0.4,0.9); leg3->AddEntry((TObject*)0,"|#eta|<1 pp",""); leg3->Draw("same"); c2->SaveAs("plots/png/pp_jetVsTrkTriggers.png"); c2->SaveAs("plots/pdf/pp_JetVsTrkTriggers.pdf"); delete c1; delete c2; delete lat; delete leg; delete leg2; delete leg3; delete leg_trk; delete leg2_trk; delete RpPb; delete RpPbSpectrum; delete pPbSpectrum; return; }
// DATA vs MC comparison void createDataVsMCcompRatio(double intLumi,TFile *fQCD,TFile *fZ,TFile *fW,TFile *fTT,TFile *flm1,TFile *fDATA,TCanvas *cCanvas,int cPad,int maxPads, TString folderName,TString histoName,int rebin,float xMin,float xMax,TString xName, TString yName,bool useLog) { ostringstream tmpLumi; tmpLumi << intLumi; TString lumi = tmpLumi.str(); cCanvas->cd(cPad); if (useLog) { gPad->SetLogy(); } // SM backgrounds TH1D *hQCD = plot1Dhisto(intLumi,fQCD,folderName,histoName,kYellow+3,rebin,xMin,xMax,xName,yName,"QCD",true); // hQCD->SetName("hQCD"); TH1D *hZ = plot1Dhisto(intLumi,fZ,folderName,histoName,kMagenta,rebin,xMin,xMax,xName,yName,"Z",true); // hQCD->SetName("hQCD"); TH1D *hW = plot1Dhisto(intLumi,fW,folderName,histoName,4,rebin,xMin,xMax,xName,yName,"W",true); // hQCD->SetName("hQCD"); TH1D *hTT = plot1Dhisto(intLumi,fTT,folderName,histoName,kGreen+2,rebin,xMin,xMax,xName,yName,"TT",true); // hQCD->SetName("hQCD"); TH1D *hSM = (TH1D*)hTT->Clone("hSM"); hSM->SetName("hSM"); hSM->Add(hW); hSM->Add(hQCD); hSM->Add(hZ); hSM->SetLineWidth(4); hSM->SetLineColor(kGray+3); hSM->SetMarkerSize(0.); // Data TH1D *hData = plot1Dhisto(intLumi,fDATA,folderName,histoName,1,rebin,xMin,xMax,xName,yName,"Data",false); // hQCD->SetName("hQCD"); hData->SetMarkerSize(1); hData->SetMarkerColor(1); hData->SetMarkerStyle(21); // Signal TH1D *hLM1 = plot1Dhisto(intLumi,flm1,folderName,histoName,2,rebin,xMin,xMax,xName,yName,"LM1",true); // hQCD->SetName("hQCD"); // y-axis range if (useLog) { hData->GetYaxis()->SetRangeUser(0.1,30.*(hData->GetBinContent(hData->GetMaximumBin()))); } else { hData->GetYaxis()->SetRangeUser(0.1,1.4*(hData->GetBinContent(hData->GetMaximumBin()))); } // Draw the histograms hData->Draw("P E0"); hSM->Draw("HIST E0 sames"); hQCD->Draw("HIST E0 sames"); hZ->Draw("HIST E0 sames"); hW->Draw("HIST E0 sames"); hTT->Draw("HIST E0 sames"); hLM1->Draw("HIST E0 sames"); hData->Draw("P E0 sames"); // re-draw to be on top // Draw Legend TLegend *lSamples = legendRAW(); lSamples->AddEntry(hData,"DATA","PL"); lSamples->AddEntry(hQCD,"QCD","FL"); lSamples->AddEntry(hZ,"Z","FL"); lSamples->AddEntry(hW,"W","FL"); lSamples->AddEntry(hTT,"TTbar","FL"); lSamples->AddEntry(hLM1,"LM1","FL"); lSamples->AddEntry(hSM,"SM","FL"); lSamples->Draw("same"); TLatex *lPreliminary = new TLatex(0.2,0.82,"Preliminary 2011"); // TLatex *lIntLumi = new TLatex(0.2,0.89,"#scale[0.8]{#int L dt = " +intLumi+"pb^{-1}, #sqrt{s} = 7 TeV}"); TLatex *lIntLumi = new TLatex(0.2,0.89,"#scale[0.8]{#int L dt = "+lumi+" pb^{-1}, #sqrt{s} = 7 TeV}"); lPreliminary->SetNDC(); lIntLumi->SetNDC(); lPreliminary->Draw("same"); lIntLumi->Draw("same"); cCanvas->cd(cPad+maxPads); // cCanvas->cd(cPad+1); gPad->SetGridx(); gPad->SetGridy(); TH1D *hRatio = (TH1D*)hData->Clone("hRatio"); // hRatio->Sumw2(); hRatio->Divide(hData,hSM); hRatio->GetYaxis()->SetTitle("DATA / MC [SM]"); hRatio->GetXaxis()->SetTitle(""); hRatio->GetYaxis()->SetRangeUser(0.,2.); hRatio->SetTitleSize(0.1, "XYZ"); hRatio->SetTitleOffset(0.65, "X"); hRatio->SetTitleOffset(0.6, "Y"); hRatio->SetLabelSize(0.08,"XY"); //Draw a line though the perfectly matching point TBox *unity = new TBox(hRatio->GetXaxis()->GetBinLowEdge(hRatio->GetXaxis()->GetFirst()), 0.89,hRatio->GetXaxis()->GetXmax(), 1.11); unity->SetLineWidth(2); //unity.SetLineStyle(Root.kDashed); unity->SetLineColor(2); unity->SetFillColor(2); unity->SetFillStyle(3002); unity->Draw(); hRatio->Draw("P E0"); unity->Draw(); cCanvas->Update(); } // ~ end of createDataVsMCcompRatio function