void photon_JEC() { TH1::SetDefaultSumw2(); Double_t alphabins[] = {0.075, 0.125, 0.175, .25, .35}; TH1D *RdRmcalpha[nptbins]; TProfile *Ratio[2][nptbins]; for(int i = 0; i < nptbins; i++) { TString name; name = "RdRmcalpha_"; name += ptbins[i]; RdRmcalpha[i] = new TH1D(name,name+";#alpha;R_{data}/R_{MC}",4,alphabins); name = "Rd_"; name += ptbins[i]; Ratio[0][i] = new TProfile(name,"",4,alphabins); name = "Rmc_"; name += ptbins[i]; Ratio[1][i] = new TProfile(name,"",4,alphabins); } TH1D *alphas = new TH1D("alphas",";#alpha = p_{T}^{Jet3}/p_{T}^{#gamma}",100,0,0.8); TH1D *hPhotonPt[2]; hPhotonPt[0] = new TH1D("hPhotonPt_data",";photon p_{T}",200,0,400); hPhotonPt[1] = (TH1D*)hPhotonPt[0]->Clone("hPhotonPt_mc"); TH1D *hPhotonEta[2]; hPhotonEta[0] = new TH1D("hPhotonEta_data",";photon #eta",26,-3,3); hPhotonEta[1] = (TH1D*)hPhotonEta[0]->Clone("hPhotonEta_mc"); TH1D *hJet2Pt[2]; hJet2Pt[0] = new TH1D("hJet2Pt_data",";jet 2 p_{T}",200,0,400); hJet2Pt[1] = (TH1D*)hJet2Pt[0]->Clone("hJet2Pt_mc"); TH1D *hJet2Eta[2]; hJet2Eta[0] = new TH1D("hJet2Eta_data",";jet 2 #eta",26,-3,3); hJet2Eta[1] = (TH1D*)hJet2Eta[0]->Clone("hJet2Eta_mc"); TH1D *hJet3Pt[2]; hJet3Pt[0] = new TH1D("hJet3Pt_data",";jet 3 p_{T}",200,0,400); hJet3Pt[1] = (TH1D*)hJet3Pt[0]->Clone("hJet3Pt_mc"); TH1D *hJet3Eta[2]; hJet3Eta[0] = new TH1D("hJet3Eta_data",";jet 3 #eta",26,-3,3); hJet3Eta[1] = (TH1D*)hJet3Eta[0]->Clone("hJet3Eta_mc"); TString files[2]; files[0] = "/mnt/hadoop/cms/store/user/luck/pA2013_forests/PA2013_HiForest_PromptReco_HLT_Photon40.root"; files[1] = "/mnt/hadoop/cms/store/user/luck/pA2013_MC/HiForest2_QCDPhoton30_5020GeV_100k.root"; bool montecarlo[2] = {false, true}; //loop over files //do the smaller MC file first, for some reason I have segfaults when I process the MC second. for(int ii = 1; ii > -1; ii--) { HiForest *c = new HiForest(files[ii], "Forest", cPPb, montecarlo[ii]); c->InitTree(); //loop over events in each file int nentries = c->GetEntries(); for(int jentry = 0; jentry<nentries; jentry++) { if (jentry% 1000 == 0) { printf("%d / %d\n",jentry,nentries); } c->GetEntry(jentry); //collision selection if( !((montecarlo[ii] || c->skim.pHBHENoiseFilter) && c->skim.phfPosFilter1 && c->skim.phfNegFilter1 && c->skim.phltPixelClusterShapeFilter && c->skim.pprimaryvertexFilter) ) continue; if(c->photon.nPhotons == 0) continue; //loop over photons in the event Float_t leadingPt = 40; //minPt is 40GeV Int_t leadingIndex = -1; for(int i = 0; i<c->photon.nPhotons; i++) { if(c->photon.pt[i] > leadingPt) { leadingPt = c->photon.pt[i]; leadingIndex = i; } } if(leadingIndex == -1) // no photons above minPt continue; if ( TMath::Abs(c->photon.eta[leadingIndex]) > 1.3 ) // barrel photons only continue; if(c->photon.ecalRecHitSumEtConeDR04[leadingIndex] > TMath::Min(3., 0.05*c->photon.energy[leadingIndex]) ) continue; if(c->photon.hcalTowerSumEtConeDR04[leadingIndex] > TMath::Min(2.4, 0.05*c->photon.energy[leadingIndex]) ) continue; //if(c->photon.trkSumPtHollowConeDR04[leadingIndex] > 0.10*leadingPt ) //continue; //if ( (c->photon.sigmaIetaIeta[leadingIndex] < 0.15) || (c->photon.sigmaIetaIeta[leadingIndex] > 0.35) ) //continue; //if ( (c->photon.sigmaIphiIphi[leadingIndex] < 0.15) || (c->photon.sigmaIphiIphi[leadingIndex] > 0.30) ) //continue; if ( c->photon.sigmaIetaIeta[leadingIndex] > 0.01 ) continue; //loop over 'away' jets int jet2index = -1; double jet2pt = 0; int jet3index = -1; double jet3pt = 0; for(int i = 0; i<c->akPu3PF.nref; i++) { if( TMath::Abs(c->akPu3PF.jteta[i]) > 3.0) continue; Double_t dphi = TMath::ACos(TMath::Cos(c->photon.phi[leadingIndex] - c->akPu3PF.jtphi[i])); if(dphi < TMath::Pi()/2) continue; if(c->akPu3PF.jtpt[i] > jet2pt) { jet3pt = jet2pt; jet3index = jet2index; jet2pt = c->akPu3PF.jtpt[i]; jet2index = i; } else if(c->akPu3PF.jtpt[i] > jet3pt) { jet3pt = c->akPu3PF.jtpt[i]; jet3index = i; } } if(jet3index == -1) //no 3rd jet means alpha = 0, we don't care continue; if( TMath::Abs(c->akPu3PF.jteta[jet2index]) > 1.3 ) continue; Double_t dphi = TMath::ACos(TMath::Cos(c->photon.phi[leadingIndex] - c->akPu3PF.jtphi[jet2index])); if( dphi < 2.7 ) continue; Double_t alpha = jet3pt/leadingPt; Double_t ratio = jet2pt/leadingPt; int ptbin = returnPtBin(leadingPt); if(ptbin != -1) Ratio[ii][ptbin]->Fill(alpha,ratio); alphas->Fill(alpha); hPhotonPt[ii]->Fill(leadingPt); hPhotonEta[ii]->Fill( c->photon.eta[leadingIndex] ); hJet2Pt[ii]->Fill(jet2pt); hJet2Eta[ii]->Fill( c->akPu3PF.jteta[jet2index] ); hJet3Pt[ii]->Fill(jet3pt); hJet3Eta[ii]->Fill( c->akPu3PF.jteta[jet3index] ); } } TCanvas *canvas[nptbins]; for(int i = 0; i < nptbins; i++) { TH1D *hRatiod = Ratio[0][i]->ProjectionX(); TH1D *hRatiomc = Ratio[1][i]->ProjectionX(); RdRmcalpha[i]->Divide(hRatiod,hRatiomc,1,1); canvas[i] = new TCanvas(); RdRmcalpha[i]->Draw(); } TCanvas *danvas = new TCanvas(); alphas->Draw(); danvas->SaveAs("alpha_counts.gif"); hPhotonPt[0]->Scale( 1./hPhotonPt[0]->GetEntries() ); hPhotonPt[1]->Scale( 1./hPhotonPt[1]->GetEntries() ); TCanvas *d1 = new TCanvas(); hPhotonPt[0]->Draw(); hPhotonPt[1]->SetMarkerColor(kRed); hPhotonPt[1]->Draw("same"); d1->SetLogy(); TLegend *leg = new TLegend(0.75,0.75,0.9,0.9); leg->SetFillColor(0); leg->AddEntry(hPhotonPt[0], "Data","P"); leg->AddEntry(hPhotonPt[1], "MC", "P"); leg->DrawClone(); d1->SaveAs("photon_pt.gif"); hPhotonEta[0]->Scale( 1./hPhotonEta[0]->GetEntries() ); hPhotonEta[1]->Scale( 1./hPhotonEta[1]->GetEntries() ); TCanvas *d2 = new TCanvas(); hPhotonEta[0]->Draw(); hPhotonEta[1]->SetMarkerColor(kRed); hPhotonEta[1]->Draw("same"); leg->DrawClone(); d2->SaveAs("photon_eta.gif"); hJet2Pt[0]->Scale( 1./hJet2Pt[0]->GetEntries() ); hJet2Pt[1]->Scale( 1./hJet2Pt[1]->GetEntries() ); TCanvas *d3 = new TCanvas(); hJet2Pt[0]->Draw(); hJet2Pt[1]->SetMarkerColor(kRed); hJet2Pt[1]->Draw("same"); d3->SetLogy(); leg->DrawClone(); d3->SaveAs("jet2_pt.gif"); hJet2Eta[0]->Scale( 1./hJet2Eta[0]->GetEntries() ); hJet2Eta[1]->Scale( 1./hJet2Eta[1]->GetEntries() ); TCanvas *d4 = new TCanvas(); hJet2Eta[0]->Draw(); hJet2Eta[1]->SetMarkerColor(kRed); hJet2Eta[1]->Draw("same"); leg->DrawClone(); d4->SaveAs("jet2_eta.gif"); hJet3Pt[0]->Scale( 1./hJet3Pt[0]->GetEntries() ); hJet3Pt[1]->Scale( 1./hJet3Pt[1]->GetEntries() ); TCanvas *d5 = new TCanvas(); hJet3Pt[0]->Draw(); hJet3Pt[1]->SetMarkerColor(kRed); hJet3Pt[1]->Draw("same"); d5->SetLogy(); leg->DrawClone(); d5->SaveAs("jet3_pt.gif"); hJet3Eta[0]->Scale( 1./hJet3Eta[0]->GetEntries() ); hJet3Eta[1]->Scale( 1./hJet3Eta[1]->GetEntries() ); TCanvas *d6 = new TCanvas(); hJet3Eta[0]->Draw(); hJet3Eta[1]->SetMarkerColor(kRed); hJet3Eta[1]->Draw("same"); leg->DrawClone(); d6->SaveAs("jet3_eta.gif"); }
void drawSignalBGData( const std::string& dirName, const std::string& channel, const std::string& var, const std::string& varName, const std::string& units, int nBins, float xMin, float xMax, TTree* tree_sig, TTree* tree_bg, TTree* tree_data, const std::string& fullSelection, const std::string& fullSelection_sidebands, const std::string& suffix ) { DrawBase* db = new DrawBase("sigbfdata" ); TH1D* h1_data = new TH1D("data", "", nBins, xMin, xMax ); TH1D* h1_sig = new TH1D("sig", "", nBins, xMin, xMax ); TH1D* h1_bg = new TH1D("bg", "", nBins, xMin, xMax ); h1_data->Sumw2(); h1_sig->Sumw2(); h1_bg->Sumw2(); h1_sig->SetFillColor(46); h1_bg->SetFillColor(38); h1_sig->SetLineColor(46); h1_bg->SetLineColor(38); h1_sig->SetFillStyle(3004); h1_bg->SetFillStyle(3005); if( BLINDED ) tree_data->Project( "data", var.c_str(), fullSelection_sidebands.c_str() ); else tree_data->Project( "data", var.c_str(), fullSelection.c_str() ); tree_sig->Project( "sig", var.c_str(), fullSelection.c_str() ); tree_bg ->Project( "bg", var.c_str(), fullSelection.c_str() ); float data_integral = h1_data->Integral(); if( data_integral < 2 ) data_integral=3.; h1_sig->Scale( data_integral/h1_sig->Integral() ); h1_bg->Scale( data_integral/h1_bg->Integral() ); TGraphAsymmErrors* gr_data = fitTools::getGraphPoissonErrors( h1_data, false ); gr_data->SetMarkerStyle(20); gr_data->SetMarkerSize(1.3); TString category_tstr(channel); bool isLeptonic = category_tstr.Contains("leptonic"); std::string channelName_legend = (isLeptonic) ? "Leptonic Channel" : "Hadronic Channel"; TLegend* legend = new TLegend( 0.55, 0.66, 0.9, 0.92, channelName_legend.c_str() ); legend->SetTextFont(42); legend->SetFillColor(kWhite); legend->SetTextSize(0.038); legend->SetTextColor(kBlack); if( useCS ) legend->AddEntry( gr_data, "Data Control Sample", "P" ); else { if( BLINDED ) { legend->AddEntry( gr_data, "Sidebands Data", "P" ); } else { legend->AddEntry( gr_data, "Sidebands Data", "P" ); } } legend->AddEntry( h1_sig, "tHq (125)", "F" ); legend->AddEntry( h1_bg, "ttH (125)", "F" ); float yMax = 0.; float yMax_data = h1_data->GetMaximum(); if( yMax_data>0. ) { if( yMax_data < 1.5 ) yMax=3.5; else if( yMax_data < 2.5 ) yMax=6.; else yMax=yMax_data*2.; } else { float yMax_mc = h1_sig->GetMaximum()*1.2; yMax = 1.8*yMax_mc; } TH2D* h2_axes = new TH2D( "axes", "", 10, xMin, xMax, 10, 0., yMax); std::string xTitle = varName; if( units!="" ) xTitle = xTitle + " [" + units + "]"; h2_axes->SetXTitle(xTitle.c_str()); h2_axes->SetYTitle( "Arbitrary Units" ); TCanvas* c1 = new TCanvas("c1", "", 600, 600); c1->cd(); TPaveText* labelTop = db->get_labelTop(); h2_axes->Draw(); legend->Draw("same"); labelTop->Draw("same"); h1_bg->Draw("h same"); h1_sig->Draw("h same"); gr_data->Draw("p same"); gPad->RedrawAxis(); std::string canvasName = dirName + "/" + channel + "/" + var + "_SignalBGData_" + channel; if( suffix!="" ) canvasName = canvasName + "_" + suffix; std::string canvasName_eps = canvasName + ".eps"; std::string canvasName_png = canvasName + ".png"; c1->SaveAs(canvasName_eps.c_str()); c1->SaveAs(canvasName_png.c_str()); delete h1_data; delete h1_sig; delete h1_bg; delete h2_axes; delete legend; delete c1; }
void DrawNCLUSTER() { //=========Macro generated from canvas: r1/Energy //========= (Fri Apr 6 17:14:48 2012) by ROOT version5.28/00g TCanvas *r1 = new TCanvas("r1", "Ncluster",12,24,550,741); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetFrameLineWidth(1); r1->Range(0,0,1,1); r1->SetFillColor(0); r1->SetBorderMode(0); r1->SetBorderSize(0); r1->SetTickx(1); r1->SetTicky(1); r1->SetLeftMargin(0.16); r1->SetRightMargin(0.01); r1->SetTopMargin(0.0256917); r1->SetBottomMargin(0.07692308); r1->SetFrameBorderMode(); // ------------>Primitives in pad: r1_1 TPad *r1_1 = new TPad("r1_1", "Energy_1",0.02,0.37,0.95,0.99); r1_1->Draw(); r1_1->cd(); r1_1->Range(-19,0.01,95,95); r1_1->SetFillColor(0); r1_1->SetBorderMode(0); r1_1->SetBorderSize(2); r1_1->SetTickx(1); r1_1->SetTicky(1); r1_1->SetLeftMargin(0.16); r1_1->SetRightMargin(0.01); r1_1->SetTopMargin(0.02); r1_1->SetBottomMargin(0); r1_1->SetFrameBorderMode(0); r1_1->SetFrameBorderMode(0); TH1D *he = new TH1D("he"," ",55,0,55); he->SetMinimum(0.01); he->SetMaximum(70); he->SetStats(0); he->GetXaxis()->SetTitle("E_{beam} [GeV]"); he->GetXaxis()->SetLabelFont(43); he->GetXaxis()->SetLabelSize(0); he->GetXaxis()->SetTitleFont(43); he->GetXaxis()->SetTitleSize(0); he->GetYaxis()->SetTitle("<N_{cluster}>"); he->GetYaxis()->SetLabelFont(43); he->GetYaxis()->SetTitleSize(30); he->GetYaxis()->SetLabelSize(20); he->GetYaxis()->SetTitleFont(43); he->GetYaxis()->SetTitleOffset(1.7); he->GetZaxis()->SetLabelFont(42); he->GetZaxis()->SetTitleSize(0.05); he->GetZaxis()->SetTitleFont(42); he->Draw(""); std::vector<result> resultData=readTXT(std::string("ncluster_augsep2012_electron.txt")); TGraphErrors *gre = new TGraphErrors(resultData.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); gre->SetLineColor(1); gre->SetFillStyle(1); gre->SetFillColor(1); gre->SetLineWidth(2); gre->SetMarkerColor(1); gre->SetMarkerStyle(34); gre->SetMarkerSize(1.2); for(unsigned int i=0; i<resultData.size(); i++){ gre->SetPoint(i,resultData.at(i).ebeam,resultData.at(i).ncluster); gre->SetPointError(i,0,resultData.at(i).nclusterError); } TH1F *Graph_Graph3 = new TH1F("Graph_Graph3","Graph",100,0,87.5); Graph_Graph3->SetMinimum(0); Graph_Graph3->SetMaximum(1193.483); Graph_Graph3->SetDirectory(0); Graph_Graph3->SetStats(0); Graph_Graph3->GetXaxis()->SetLabelFont(42); Graph_Graph3->GetXaxis()->SetTitleSize(0.05); Graph_Graph3->GetXaxis()->SetTitleFont(42); Graph_Graph3->GetYaxis()->SetLabelFont(42); Graph_Graph3->GetYaxis()->SetTitleSize(0.05); Graph_Graph3->GetYaxis()->SetTitleFont(42); Graph_Graph3->GetZaxis()->SetLabelFont(42); Graph_Graph3->GetZaxis()->SetTitleSize(0.05); Graph_Graph3->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph3); gre->Draw("p"); std::vector<result> resultFTFP=readTXT(std::string("ncluster_ftfp_bert_hp_electron.txt")); gre = new TGraphErrors(resultFTFP.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); gre->SetFillColor(kRed-3); gre->SetMarkerColor(kRed-3); gre->SetLineWidth(2); gre->SetMarkerStyle(20); for(unsigned int i=0; i<resultFTFP.size(); i++){ gre->SetPoint(i,resultFTFP.at(i).ebeam,resultFTFP.at(i).ncluster); gre->SetPointError(i,0,resultFTFP.at(i).nclusterError); } TH1F *Graph1 = new TH1F("Graph1","Graph",100,0,87.17072); Graph1->SetMinimum(2.655724); Graph1->SetMaximum(88.56778); Graph1->SetDirectory(0); Graph1->SetStats(0); Graph1->GetXaxis()->SetLabelFont(42); Graph1->GetXaxis()->SetTitleSize(0.05); Graph1->GetXaxis()->SetTitleFont(42); Graph1->GetYaxis()->SetLabelFont(42); Graph1->GetYaxis()->SetTitleSize(0.05); Graph1->GetYaxis()->SetTitleFont(42); Graph1->GetZaxis()->SetLabelFont(42); Graph1->GetZaxis()->SetTitleSize(0.05); Graph1->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph1); gre->Draw("p"); std::vector<result> resultQGSP=readTXT(std::string("ncluster_qgsp_bert_hp_electron.txt")); gre = new TGraphErrors(resultQGSP.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); gre->SetFillColor(kBlue-6); gre->SetMarkerColor(kBlue-6); gre->SetLineWidth(2); gre->SetMarkerStyle(25); for(unsigned int i=0; i<resultQGSP.size(); i++){ gre->SetPoint(i,resultQGSP.at(i).ebeam,resultQGSP.at(i).ncluster); gre->SetPointError(i,0,resultQGSP.at(i).nclusterError); } TH1F *Graph_Graph2 = new TH1F("Graph_Graph2","Graph",100,0,87.5); Graph_Graph2->SetMinimum(0); Graph_Graph2->SetMaximum(1193.483); Graph_Graph2->SetDirectory(0); Graph_Graph2->SetStats(0); Graph_Graph2->GetXaxis()->SetLabelFont(42); Graph_Graph2->GetXaxis()->SetTitleSize(0.05); Graph_Graph2->GetXaxis()->SetTitleFont(42); Graph_Graph2->GetYaxis()->SetLabelFont(42); Graph_Graph2->GetYaxis()->SetTitleSize(0.05); Graph_Graph2->GetYaxis()->SetTitleFont(42); Graph_Graph2->GetZaxis()->SetLabelFont(42); Graph_Graph2->GetZaxis()->SetTitleSize(0.05); Graph_Graph2->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph2); gre->Draw("p"); TLegend *leg = new TLegend(0.15,0.7,0.75,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); TLegendEntry *entry=leg->AddEntry("Graph_Graph3","SDHCAL DATA (H6 Cern SPS)","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(34); entry->SetMarkerSize(1.2); entry=leg->AddEntry("Graph1","FTFP_BERT_HP","p"); entry->SetLineColor(kRed-3); entry->SetLineStyle(kRed-3); entry->SetLineWidth(kRed-3); entry->SetMarkerColor(kRed-3); entry->SetMarkerStyle(20); entry->SetMarkerSize(1.0); entry=leg->AddEntry("Graph_Graph2","QGSP_BERT_HP","p"); entry->SetLineColor(kBlue-6); entry->SetLineStyle(kBlue-6); entry->SetLineWidth(kBlue-6); entry->SetMarkerColor(kBlue-6); entry->SetMarkerStyle(25); entry->SetMarkerSize(0.9); leg->Draw(); TText *tex=new TText(); tex->SetTextSize(0.05); tex->SetTextColor(kGray+2); //tex->DrawTextNDC(0.5,0.05,"SDHCAL Preliminary"); tex->DrawTextNDC(0.3,0.05,"CALICE Fe-SDHCAL Preliminary"); r1_1->Modified(); r1->cd(); // ------------>Primitives in pad: r1_2 TPad *r1_2 = new TPad("r1_2", "Energy_2",0.02,0.0,0.95,0.38); r1_2->Draw(); r1_2->cd(); r1_2->Range(-19,-0.06545455,95,0.048); r1_2->SetFillColor(0); r1_2->SetBorderMode(0); r1_2->SetBorderSize(2); r1_2->SetTickx(1); r1_2->SetTicky(1); r1_2->SetLeftMargin(0.16); r1_2->SetRightMargin(0.01); r1_2->SetTopMargin(0.0); r1_2->SetBottomMargin(0.23); r1_2->SetFrameBorderMode(0); r1_2->SetFrameBorderMode(0); TH1D *hd = new TH1D("hd"," ",55,0,55); hd->SetMinimum(-0.20); hd->SetMaximum(0.20); hd->SetStats(0); hd->GetXaxis()->SetTitle("E_{beam} [GeV]"); hd->GetXaxis()->SetLabelFont(43); hd->GetXaxis()->SetLabelSize(20); hd->GetXaxis()->SetTitleFont(43); hd->GetXaxis()->SetTitleSize(30); hd->GetXaxis()->SetTitleOffset(2.); hd->GetYaxis()->SetTitle("(#DeltaN_{cluster})/N_{data}"); hd->GetYaxis()->SetLabelFont(43); hd->GetYaxis()->SetLabelSize(20); hd->GetYaxis()->SetTitleSize(30); hd->GetYaxis()->SetTitleOffset(1.7); hd->GetYaxis()->SetTitleFont(43); hd->GetYaxis()->SetNdivisions(505); hd->GetZaxis()->SetLabelFont(42); hd->GetZaxis()->SetTitleSize(0.05); hd->GetZaxis()->SetTitleFont(42); hd->Draw(""); float deltaError; float delta; gre = new TGraphErrors(resultQGSP.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); for(unsigned int i=0; i<resultQGSP.size(); i++){ delta=(resultQGSP.at(i).ncluster-resultData.at(i).ncluster)/resultData.at(i).ncluster; deltaError=1/resultData.at(i).ncluster* sqrt(pow(resultQGSP.at(i).nclusterError,2) + pow(resultQGSP.at(i).ncluster/resultData.at(i).ncluster*resultData.at(i).nclusterError,2)); gre->SetPoint(i,resultQGSP.at(i).ebeam,delta); gre->SetPointError(i,0,deltaError); } gre->SetLineWidth(2); gre->SetLineColor(kBlue-6); gre->SetMarkerColor(kBlue-6); gre->SetMarkerSize(1.0); gre->SetMarkerStyle(25); gre->Draw("p"); gre = new TGraphErrors(resultFTFP.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); for(unsigned int i=0; i<resultFTFP.size(); i++){ delta=(resultFTFP.at(i).ncluster-resultData.at(i).ncluster)/resultData.at(i).ncluster; deltaError=1/resultData.at(i).ncluster* sqrt(pow(resultFTFP.at(i).nclusterError,2) + pow(resultFTFP.at(i).ncluster/resultData.at(i).ncluster*resultData.at(i).nclusterError,2)); gre->SetPoint(i,resultFTFP.at(i).ebeam,delta); gre->SetPointError(i,0,deltaError); } gre->SetLineWidth(2); gre->SetLineColor(kRed-3); gre->SetMarkerColor(kRed-3); gre->SetMarkerSize(1.0); gre->SetMarkerStyle(20); gre->Draw("p"); TF1 *lin1 = new TF1("lin1","0",-0.01,95); lin1->SetFillColor(19); lin1->SetFillStyle(0); lin1->SetLineWidth(1); lin1->SetLineStyle(1); lin1->SetLineColor(1); lin1->GetXaxis()->SetLabelFont(42); lin1->GetXaxis()->SetTitleSize(0.05); lin1->GetXaxis()->SetTitleFont(42); lin1->GetYaxis()->SetLabelFont(42); lin1->GetYaxis()->SetTitleSize(0.05); lin1->GetYaxis()->SetTitleFont(42); lin1->Draw("same"); lin1 = new TF1("lin1","0.1",0.01,95); lin1->SetFillColor(1); lin1->SetFillStyle(0); lin1->SetLineWidth(1); lin1->SetLineStyle(2); lin1->SetLineColor(17); lin1->GetXaxis()->SetLabelFont(42); lin1->GetXaxis()->SetTitleSize(0.05); lin1->GetXaxis()->SetTitleFont(42); lin1->GetYaxis()->SetLabelFont(42); lin1->GetYaxis()->SetTitleSize(0.05); lin1->GetYaxis()->SetTitleFont(42); lin1->Draw("same"); lin1 = new TF1("lin1","-0.1",0.01,95); lin1->SetFillColor(1); lin1->SetFillStyle(0); lin1->SetLineWidth(1); lin1->SetLineStyle(2); lin1->SetLineColor(17); lin1->GetXaxis()->SetLabelFont(42); lin1->GetXaxis()->SetTitleSize(0.05); lin1->GetXaxis()->SetTitleFont(42); lin1->GetYaxis()->SetLabelFont(42); lin1->GetYaxis()->SetTitleSize(0.05); lin1->GetYaxis()->SetTitleFont(42); lin1->Draw("same"); r1_2->Modified(); r1->cd(); r1->Modified(); r1->cd(); r1->SetSelected(r1); r1->SaveAs("../plots/NCLUSTERELECTRON.pdf"); }
void tnpScale( bool printplot = false ) { //---------------------------------------- // Files //---------------------------------------- char* version = (char*) "V00-00-00"; TChain *chmc = new TChain("leptons"); TChain *chdata = new TChain("leptons"); char* suffix = ""; //char* suffix = "_2jets"; chmc-> Add(Form("smurf/ZJets_V00-00-01/merged%s.root" ,suffix)); chdata->Add(Form("smurf/SingleMu2012A_V00-00-01/merged%s.root",suffix)); chdata->Add(Form("smurf/SingleMu2012B_V00-00-01/merged%s.root",suffix)); chdata->Add(Form("smurf/SingleMu2012C_V00-00-01/merged%s.root",suffix)); chdata->Add(Form("smurf/SingleEl2012A_V00-00-01/merged%s.root",suffix)); chdata->Add(Form("smurf/SingleEl2012B_V00-00-01/merged%s.root",suffix)); chdata->Add(Form("smurf/SingleEl2012C_V00-00-01/merged%s.root",suffix)); //---------------------------------------- // bins //---------------------------------------- //float ptbin[] = {10., 15., 20., 30., 40., 50., 7000.}; float ptbin[] = {10., 15., 20., 30., 40., 50., 60. , 70. , 80.0 , 100.0 , 7000.}; float etabin[] = {0, 0.8, 1.479, 2.0, 2.5}; int nptbin=10; int netabin=4; // // histogram // //deno TH2F *hmcid_deno = new TH2F("hmcid_deno", "hmcid_deno", nptbin, ptbin, netabin, etabin); TH2F *hmciso_deno = new TH2F("hmciso_deno", "hmciso_deno", nptbin, ptbin, netabin, etabin); TH2F *hdataid_deno = new TH2F("hdataid_deno", "hdataid_deno", nptbin, ptbin, netabin, etabin); TH2F *hdataiso_deno = new TH2F("hdataiso_deno", "hdataiso_deno", nptbin, ptbin, netabin, etabin); hmcid_deno->Sumw2(); hmciso_deno->Sumw2(); hdataid_deno->Sumw2(); hdataiso_deno->Sumw2(); //num TH2F *hmcid_num = new TH2F("hmcid_num", "hmcid_num", nptbin, ptbin, netabin, etabin); TH2F *hmciso_num = new TH2F("hmciso_num", "hmciso_num", nptbin, ptbin, netabin, etabin); TH2F *hdataid_num = new TH2F("hdataid_num", "hdataid_num", nptbin, ptbin, netabin, etabin); TH2F *hdataiso_num = new TH2F("hdataiso_num", "hdataiso_num", nptbin, ptbin, netabin, etabin); hmcid_num->Sumw2(); hmciso_num->Sumw2(); hdataid_num->Sumw2(); hdataiso_num->Sumw2(); // eff TH2F *hmcid = new TH2F("hmcid", "hmcid", nptbin, ptbin, netabin, etabin); TH2F *hmciso = new TH2F("hmciso", "hmciso", nptbin, ptbin, netabin, etabin); TH2F *hdataid = new TH2F("hdataid", "hdataid", nptbin, ptbin, netabin, etabin); TH2F *hdataiso = new TH2F("hdataiso", "hdataiso", nptbin, ptbin, netabin, etabin); hmcid->Sumw2(); hmciso->Sumw2(); hdataid->Sumw2(); hdataiso->Sumw2(); // SF TH2F *hsfid = new TH2F("hsfid", "hsfid", nptbin, ptbin, netabin, etabin); TH2F *hsfiso = new TH2F("hsfiso", "hsfiso", nptbin, ptbin, netabin, etabin); hsfid->Sumw2(); hsfiso->Sumw2(); //--------------------------- // tag cuts //--------------------------- TCut zmass("abs(tagAndProbeMass-91)<15"); TCut eltnp("(eventSelection&1)==1"); TCut mutnp("(eventSelection&2)==2"); TCut os("qProbe*qTag<0"); TCut tag_eta21("abs(tag->eta())<2.1"); TCut tag_eta25("abs(tag->eta())<2.5"); TCut njets1("njets>=1"); TCut njets2("njets>=2"); TCut njets3("njets>=3"); TCut njets4("njets>=4"); TCut tag_pt30("tag->pt()>30.0"); TCut met30("met<30"); TCut met20("met<20"); TCut nbm0("nbm==0"); TCut nbl0("nbl==0"); TCut mt30("mt<30"); TCut eltnptrig("HLT_Ele27_WP80_tag > 0"); TCut mutnptrig("HLT_IsoMu24_tag > 0"); //--------------------------- // tag cuts //--------------------------- TCut mufo = "(leptonSelection&32768)==32768"; // mu fo TCut muid = "(leptonSelection&65536)==65536"; // mu id TCut muiso = "(leptonSelection&131072)==131072"; // mu iso TCut elfo = "(leptonSelection&4)==4"; // ele fo TCut elid = "(leptonSelection&8)==8"; // ele id TCut eliso = "(leptonSelection&16)==16"; // ele iso TCut probept = "probe->pt()>30"; // probe pt TCut drprobe = "drprobe<0.05"; // dR(probe,pfcandidate) TCut eltnpcut; eltnpcut += zmass; eltnpcut += os; eltnpcut += eltnp; eltnpcut += tag_eta21; //eltnpcut += njets2; eltnpcut += tag_pt30; eltnpcut += eltnptrig; eltnpcut += met30; // eltnpcut += mt30; eltnpcut += nbl0; eltnpcut += elid; eltnpcut += probept; eltnpcut += drprobe; TCut mutnpcut; mutnpcut += zmass; mutnpcut += os; mutnpcut += mutnp; mutnpcut += tag_eta21; //mutnpcut += njets2; mutnpcut += tag_pt30; mutnpcut += mutnptrig; mutnpcut += met30; // mutnpcut += mt30; mutnpcut += nbl0; mutnpcut += muid; mutnpcut += probept; mutnpcut += drprobe; //eltnpcut += njets2; //eltnpcut += njets3; //eltnpcut += nbm0; //eltnpcut += mt30; //eltnpcut += met20; //TCut eltnpcut = "abs(tagAndProbeMass-91)<15 && (eventSelection&1)==1 && qProbe*qTag<0 && abs(tag->eta())<2.5 && njets>=4 && tag->pt()>30.0 && met<30.0 && nbm==0 && mt<30"; //TCut mutnpcut = "abs(tagAndProbeMass-91)<15 && (eventSelection&2)==2 && HLT_IsoMu30_eta2p1_tag>0 && qProbe*qTag<0 && abs(tag->eta())<2.1 && njets>=4 && tag->pt()>30.0"; TCut vtxweight = "vtxweight"; cout << "Electrons:" << endl; cout << "Selection : " << eltnpcut.GetTitle() << endl; cout << "Total MC yields : " << chmc->GetEntries(eltnpcut) << endl; cout << "Total DATA yields : " << chdata->GetEntries(eltnpcut) << endl; cout << "Muons:" << endl; cout << "Selection : " << mutnpcut.GetTitle() << endl; cout << "Total MC yields : " << chmc->GetEntries(mutnpcut) << endl; cout << "Total DATA yields : " << chdata->GetEntries(mutnpcut) << endl; //TCut njets = "njets>=2"; TCut tkisoold = "tkisoold/probe->pt()>0.1"; TCut tkisonew = "tkisonew/probe->pt()>0.1"; //----------------------------------------- // check nvtx data vs. MC //----------------------------------------- TH1F *hnvtx_mc = new TH1F("hnvtx_mc" ,"",30,0,30); TH1F *hnvtx_data = new TH1F("hnvtx_data","",30,0,30); hnvtx_mc->Sumw2(); hnvtx_data->Sumw2(); chdata->Draw("nvtx>>hnvtx_data",(eltnpcut||mutnpcut)); chmc->Draw("nvtx>>hnvtx_mc",(eltnpcut||mutnpcut)*vtxweight); TCanvas *c1 = new TCanvas(); c1->cd(); hnvtx_mc->SetLineColor(2); hnvtx_mc->SetMarkerColor(2); hnvtx_data->SetLineColor(4); hnvtx_data->SetMarkerColor(4); hnvtx_data->GetXaxis()->SetTitle("N_{VTX}"); hnvtx_data->DrawNormalized(); hnvtx_mc->DrawNormalized("same"); TLegend *leg = new TLegend(0.6,0.6,0.8,0.8); leg->AddEntry(hnvtx_data,"data","lp"); leg->AddEntry(hnvtx_mc,"MC","lp"); leg->SetFillColor(0); leg->SetBorderSize(0); leg->Draw(); if( printplot ) c1->Print("plots/nvtx.pdf"); //-------------------------- // absolute track isolation //-------------------------- bool residual = true; bool log = true; char* var = "tkisonewnoveto"; plotDistribution( chdata , chmc , TCut(eltnpcut) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "el_tkiso_0j" , printplot , residual , log ); plotDistribution( chdata , chmc , TCut(mutnpcut) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "mu_tkiso_0j" , printplot , residual , log ); plotDistribution( chdata , chmc , TCut(eltnpcut+njets1) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "el_tkiso_1j" , printplot , residual , log ); plotDistribution( chdata , chmc , TCut(mutnpcut+njets1) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "mu_tkiso_1j" , printplot , residual , log ); plotDistribution( chdata , chmc , TCut(eltnpcut+njets2) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "el_tkiso_2j" , printplot , residual , log ); plotDistribution( chdata , chmc , TCut(mutnpcut+njets2) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "mu_tkiso_2j" , printplot , residual , log ); plotDistribution( chdata , chmc , TCut(eltnpcut+njets3) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "el_tkiso_3j" , printplot , residual , log ); plotDistribution( chdata , chmc , TCut(mutnpcut+njets3) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "mu_tkiso_3j" , printplot , residual , log ); plotDistribution( chdata , chmc , TCut(eltnpcut+njets4) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "el_tkiso_4j" , printplot , residual , log ); plotDistribution( chdata , chmc , TCut(mutnpcut+njets4) , vtxweight , var , 10 , 0 , 10 , "abs tkiso [GeV]" , "mu_tkiso_4j" , printplot , residual , log ); //-------------------------- // relative track isolation //-------------------------- // plotDistribution( chdata , chmc , TCut(eltnpcut) , vtxweight , "tkisonew/probe->pt()" , 10 , 0 , 1 , "rel tkiso [GeV]" , "el_tkrliso_2j" , printplot ); // plotDistribution( chdata , chmc , TCut(mutnpcut) , vtxweight , "tkisonew/probe->pt()" , 10 , 0 , 1 , "rel tkiso [GeV]" , "mu_tkrliso_2j" , printplot ); // plotDistribution( chdata , chmc , TCut(eltnpcut+njets3) , vtxweight , "tkisonew/probe->pt()" , 10 , 0 , 1 , "rel tkiso [GeV]" , "el_tkrliso_3j" , printplot ); // plotDistribution( chdata , chmc , TCut(mutnpcut+njets3) , vtxweight , "tkisonew/probe->pt()" , 10 , 0 , 1 , "rel tkiso [GeV]" , "mu_tkrliso_3j" , printplot ); // plotDistribution( chdata , chmc , TCut(eltnpcut+njets4) , vtxweight , "tkisonew/probe->pt()" , 10 , 0 , 1 , "rel tkiso [GeV]" , "el_tkrliso_4j" , printplot ); // plotDistribution( chdata , chmc , TCut(mutnpcut+njets4) , vtxweight , "tkisonew/probe->pt()" , 10 , 0 , 1 , "rel tkiso [GeV]" , "mu_tkrliso_4j" , printplot ); // plotDistribution( chdata , chmc , TCut(eltnpcut) , vtxweight , "tkisoold" , 10 , 0 , 10 , "trkiso (old) [GeV]" , "el_tkiso_old" , printplot ); // plotDistribution( chdata , chmc , TCut(mutnpcut) , vtxweight , "tkisoold" , 10 , 0 , 10 , "trkiso (old) [GeV]" , "mu_tkiso_old" , printplot ); //printHisto( chdata , chmc , TCut(muiso) , TCut(tnpcut+muid) , "probe.pt()" , 10 , 0.0 , 100.0 , "lepton p_{T} [GeV]" , "iso efficiency" ); //printHisto( chdata , chmc , tkisoold , TCut(tnpcut+muid+njets) , "probe.pt()" , 10 , 0.0 , 100.0 , "lepton p_{T} [GeV]" , "tkiso(old) efficiency" ); //printHisto( chdata , chmc , tkisonew , TCut(tnpcut+muid+njets) , "probe.pt()" , 10 , 0.0 , 100.0 , "lepton p_{T} [GeV]" , "tkiso(new) efficiency" ); /* // // Fill histograms // // chmc->Draw("abs(probe->eta()):probe->pt()>>hmcid_deno", tnpcut+"&&"+eliso, "goff"); // chmc->Draw("abs(probe->eta()):probe->pt()>>hmcid_num", tnpcut+"&&"+eliso+"&&"+elid, "goff"); // chmc->Draw("abs(probe->eta()):probe->pt()>>hmciso_deno", tnpcut+"&&"+elid, "goff"); // chmc->Draw("abs(probe->eta()):probe->pt()>>hmciso_num", tnpcut+"&&"+elid+"&&"+eliso, "goff"); // chdata->Draw("abs(probe->eta()):probe->pt()>>hdataid_deno", tnpcut+"&&"+eliso, "goff"); // chdata->Draw("abs(probe->eta()):probe->pt()>>hdataid_num", tnpcut+"&&"+eliso+"&&"+elid, "goff"); // chdata->Draw("abs(probe->eta()):probe->pt()>>hdataiso_deno", tnpcut+"&&"+elid, "goff"); // chdata->Draw("abs(probe->eta()):probe->pt()>>hdataiso_num", tnpcut+"&&"+elid+"&&"+eliso, "goff"); TCut tnpcut = "abs(tagAndProbeMass-91)<15 && (eventSelection&2)==2 && HLT_IsoMu30_eta2p1_tag>0 && qProbe*qTag<0 && abs(tag->eta())<2.1 && njets>=4 && tag->pt()>30.0"; chmc->Draw("abs(probe->eta()):probe->pt()>>hmcid_deno", tnpcut+muiso, "goff"); chmc->Draw("abs(probe->eta()):probe->pt()>>hmcid_num", tnpcut+muiso+muid, "goff"); chmc->Draw("abs(probe->eta()):probe->pt()>>hmciso_deno", tnpcut+muid, "goff"); chmc->Draw("abs(probe->eta()):probe->pt()>>hmciso_num", tnpcut+muid+muiso, "goff"); chdata->Draw("abs(probe->eta()):probe->pt()>>hdataid_deno", tnpcut+muiso, "goff"); chdata->Draw("abs(probe->eta()):probe->pt()>>hdataid_num", tnpcut+muiso+muid, "goff"); chdata->Draw("abs(probe->eta()):probe->pt()>>hdataiso_deno", tnpcut+muid, "goff"); chdata->Draw("abs(probe->eta()):probe->pt()>>hdataiso_num", tnpcut+muid+muiso, "goff"); // get efficiencies // hmcid->Divide(hmcid_num,hmcid_deno,1,1,"B"); // hmciso->Divide(hmciso_num,hmciso_deno,1,1,"B"); // hdataid->Divide(hdataid_num,hdataid_deno,1,1,"B"); // hdataiso->Divide(hdataiso_num,hdataiso_deno,1,1,"B"); hmcid->Divide(hmcid_num,hmcid_deno,1,1); hmciso->Divide(hmciso_num,hmciso_deno,1,1); hdataid->Divide(hdataid_num,hdataid_deno,1,1); hdataiso->Divide(hdataiso_num,hdataiso_deno,1,1); // get scale factors hsfid->Divide(hdataid, hmcid, 1, 1); hsfiso->Divide(hdataiso, hmciso, 1, 1); // Draw histograms //hmcid->Draw("text"); */ /* // print table cout << " ------ MC ID ----- " << endl; printline(hmcid); cout << " ------ MC ISO ----- " << endl; printline(hmciso); cout << " ------ DATA ID ----- " << endl; printline(hdataid); cout << " ------ DATA ISO ----- " << endl; printline(hdataiso); cout << " ------ Scale Factor ID ----- " << endl; printline(hsfid); cout << " ------ Scale Factor ISO ----- " << endl; printline(hsfiso); */ }
void compareSystVariable( const std::string& dirName, const std::string& channel, const std::string& dataset, TTree* tree_central, TFile* file_systUp, TFile* file_systDown, const std::string& fullSelection, const std::string& systName, const std::string& varName, const std::string& axisTitle, const std::string& units, int nBins, float xMin, float xMax, const std::string& suffix) { DrawBase* db = new DrawBase("syst" ); TTree* tree_systUp = (TTree*)file_systUp->Get(dataset.c_str()); TTree* tree_systDown = (file_systDown!=0) ? (TTree*)file_systDown->Get(dataset.c_str()) : 0; TH1D* h1_central = new TH1D("central", "", nBins, xMin, xMax); TH1D* h1_systUp = new TH1D("systUp", "", nBins, xMin, xMax); TH1D* h1_systDown = new TH1D("systDown", "", nBins, xMin, xMax); h1_central->Sumw2(); h1_systUp->Sumw2(); h1_systDown->Sumw2(); tree_central->Project( "central", varName.c_str(), fullSelection.c_str() ); tree_systUp->Project( "systUp", varName.c_str(), fullSelection.c_str() ); if( tree_systDown!=0 ) tree_systDown->Project( "systDown", varName.c_str(), fullSelection.c_str() ); h1_central ->SetLineColor(kBlack); h1_systUp ->SetLineColor(kGreen); h1_systDown->SetLineColor(kRed); h1_central ->SetLineWidth(2); h1_systUp ->SetLineWidth(2); h1_systDown->SetLineWidth(2); //h1_systUp ->SetLineStyle(2); //h1_systDown->SetLineStyle(2); TLegend* legend = new TLegend( 0.6, 0.66, 0.9, 0.92, dataset.c_str() ); legend->SetTextFont(42); legend->SetFillColor(kWhite); legend->SetTextSize(0.038); legend->SetTextColor(kBlack); legend->AddEntry( h1_central, "Central", "L" ); std::string systUp_text = systName + " +1#sigma"; std::string systDown_text = systName + " -1#sigma"; legend->AddEntry( h1_systUp, systUp_text.c_str(), "L" ); if( tree_systDown!=0 ) legend->AddEntry( h1_systDown, systDown_text.c_str(), "L" ); float yMax = 1.6*h1_central->GetMaximum(); TH2D* h2_axes = new TH2D( "axes", "", 10, xMin, xMax, 10, 0., yMax); std::string xTitle = axisTitle; if( units!="" ) xTitle = xTitle + " [" + units + "]"; h2_axes->SetXTitle(xTitle.c_str()); h2_axes->SetYTitle( "Events" ); TCanvas* c1 = new TCanvas("c1", "", 600, 600); c1->cd(); TPaveText* labelTop = db->get_labelTop(); h2_axes->Draw(); legend->Draw("same"); labelTop->Draw("same"); h1_central->Draw("h same"); h1_systUp->Draw("h same"); if( tree_systDown!=0 ) h1_systDown->Draw("h same"); gPad->RedrawAxis(); std::string canvasName = dirName + "/" + channel + "/syst" + systName + "_" + varName + "_" + dataset + "_" + channel; if( suffix!="" ) canvasName = canvasName + "_" + suffix; std::string canvasName_eps = canvasName + ".eps"; std::string canvasName_png = canvasName + ".png"; c1->SaveAs(canvasName_eps.c_str()); c1->SaveAs(canvasName_png.c_str()); delete db; delete h1_central; delete h1_systUp; delete h1_systDown; delete h2_axes; delete legend; delete c1; }
void vs_PlotQCDcomp() { Bool_t saveC = false; Bool_t diJets = true; Bool_t isMC = false; TString vsSave; vsSave = "_T07w"; TString jSave; if(diJets) jSave = "2j"; else jSave = "3j"; TString sample; if(diJets) sample = "select_1ph_2jets"; else sample = "select_1ph_3jets"; TString FOtag; if(isMC) FOtag = "_FO_CorrMC"; // else FOtag = "_FO_Corr"; else FOtag = "_FO"; TString sysu = "SYSTUP_"; TString sysd = "SYSTDOWN_"; TString outDir; outDir = "Plots_PhotonSusyAnalysis/QCDweights/"; // string inputFile1 = "/data/user/vsola/CMSSW_Releases/CMSSW_5_3_9/src/Plots_PhotonSusyAnalysis/Merged_QCD_PhotonJet_T07w_PAT/mergedHistos.root"; // string inputFile1 = "/data/user/vsola/CMSSW_Releases/CMSSW_5_3_9/src/Plots_PhotonSusyAnalysis/Merged_Data_V05w_PAT/mergedHistos.root"; string inputFile1 = "/data/user/vsola/CMSSW_Releases/CMSSW_5_3_9/src/Plots_PhotonSusyAnalysis/PhotonHadReReco_22Jan2013_V05_PAT/mergedHistos.root"; setMyTDRStyle(); gROOT->SetStyle("mytdrStyle"); // gStyle->SetHistMinimumZero(); // gStyle->SetPaintTextFormat("4.2f"); gStyle->SetHistLineWidth(2); gStyle->UseCurrentStyle(); // gStyle->SetPadTopMargin(1.0); // gStyle->SetPadLeftMargin(3.2); // gStyle->SetPadRightMargin(4.5); // gStyle->SetPadBottomMargin(3.2); gROOT->ForceStyle(1); static const Int_t nHt = 7; static const Int_t nPt = 13; static const Int_t nMet = 16; static const Int_t nJet = 15; Double_t binPt[nPt+1] = {0.,75.,90.,120.,160.,210.,260.,320.,400.,500.,650.,800.,1000.,1500.}; Double_t binHt[nHt+1] = {0.,400.,450.,550.,700.,900.,1200.,1500.}; Double_t binMet[nMet+1] = {0.,10.,20.,30.,40.,50.,60.,70.,80.,90.,100.,120.,160.,200.,270.,350.,500.}; Double_t binJet[nJet+1] = {0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15}; TLatex *as = new TLatex(); as->SetNDC(true); as->SetTextColor(12); as->SetTextFont(43); as->SetTextSize(19); TLegend *legend = new TLegend(0.60, 0.70, 0.75, 0.85, ""); legend->SetFillColor(10); legend->SetFillStyle(1001); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetShadowColor(0); std::string outLumi = "CMS Work in Progress - QCD MC #sqrt{s} = 8 TeV - #geq 1 #gamma, #geq 2 j"; TFile* f1 = TFile::Open( inputFile1.c_str() ); //photon Pt TCanvas * cPt = new TCanvas("cPt","cPt"); TH1F* hpt = (TH1F*) f1->Get( sample+"/PreselCut_photonPt" ); TH1F* hptFO = (TH1F*) f1->Get( sample+FOtag+"/PreselCut_photonPt" ); TH1F *hptR = (TH1F*) hpt->Rebin(nPt,hpt->GetTitle(),binPt); if (hptR->GetSumw2N() == 0) hptR->Sumw2(); TH1F *hptFOR = (TH1F*) hptFO->Rebin(nPt,hptFO->GetTitle(),binPt); if (hptFOR->GetSumw2N() == 0) hptFOR->Sumw2(); TH1F* hptSU = (TH1F*) f1->Get( sample+FOtag+"/PreselCut_"+sysu+"photonPt" ); TH1F* hptSD = (TH1F*) f1->Get( sample+FOtag+"/PreselCut_"+sysd+"photonPt" ); TH1F *hptSUR = (TH1F*) hptSU->Rebin(nPt,hptSU->GetTitle(),binPt); if (hptSUR->GetSumw2N() == 0) hptSUR->Sumw2(); TH1F *hptSDR = (TH1F*) hptSD->Rebin(nPt,hptSD->GetTitle(),binPt); if (hptSDR->GetSumw2N() == 0) hptSDR->Sumw2(); if ( hptFOR != 0 ) { for (int b = 0; b < hptFOR->GetNbinsX(); b++) { Double_t mainHistoContent = hptFOR->GetBinContent(b); Double_t systUpHistoContent = hptSUR->GetBinContent(b); Double_t systDnHistoContent = hptSDR->GetBinContent(b); Double_t systDiffUp = fabs( (double) systUpHistoContent - mainHistoContent ); Double_t systDiffDn = fabs( (double) mainHistoContent - systDnHistoContent ); // use average error for histogram Double_t systDiff = ( systDiffUp + systDiffDn ) / 2.; Double_t statErr = hptFOR->GetBinError(b); Double_t combError = sqrt( systDiff * systDiff + statErr * statErr ); hptFOR->SetBinError(b, combError); } //for }//if cPt->SetLogy(1); gPad->Update(); cPt->Update(); // hptR->Scale(1,"width"); // hptR->SetMinimum(0.02); // hptR->SetMaximum(1000); hptR->GetXaxis()->SetTitle("1^{st} photon p_{T} [GeV]"); hptR->GetYaxis()->SetTitle("Number of Events / GeV"); if(isMC) hptR->SetMarkerSize(0); if(isMC) hptR->Draw("histE"); else hptR->Draw("E X0"); hptFOR->SetMarkerSize(0); hptFOR->SetLineColor(2); hptFOR->SetFillColor(2); hptFOR->SetFillStyle(3004); hptFOR->Draw("same hist ][ E2"); legend->Clear(); if(isMC) legend->SetHeader("#gamma/QCD (Sim)"); else legend->SetHeader("#gamma/QCD (Data)"); if(isMC) legend->AddEntry(hptR, "#gamma", "l"); else legend->AddEntry(hptR, "#gamma", "p"); legend->AddEntry(hptFOR, "Pred (from #gamma_{jet})", "f"); legend->Draw(); as->DrawLatex(0.17, 0.93, outLumi.c_str() ); cPt->Update(); cPt->SetBottomMargin(0.2 + 0.8 * cPt->GetBottomMargin() - 0.2 * cPt->GetTopMargin()); TPad *ratioPt = new TPad("BottomPad", "", 0, 0, 1, 1); ratioPt->SetTopMargin(0.8 - 0.8 * ratioPt->GetBottomMargin() + 0.2 * ratioPt->GetTopMargin()); ratioPt->SetFillStyle(0); ratioPt->SetFrameFillColor(10); ratioPt->SetFrameBorderMode(0); ratioPt->Draw(); ratioPt->cd(); ratioPt->SetLogy(0); TH1F *hptRat = (TH1F*) divideHistosForRatio(hptR,hptFOR); hptRat->SetMinimum(0.); hptRat->SetMaximum(10.); hptRat->GetXaxis()->SetNdivisions(505); if(isMC) hptRat->GetYaxis()->SetTitle("Sim/Pred"); else hptRat->GetYaxis()->SetTitle("Data/Pred"); hptRat->GetYaxis()->SetTitleSize(0.04); hptRat->GetYaxis()->SetLabelSize(0.03); hptRat->GetYaxis()->SetTitleOffset(1.3); hptRat->GetYaxis()->SetNdivisions(505); hptRat->SetMarkerStyle(20); hptRat->SetMarkerSize(1); hptRat->SetMarkerColor(1); hptRat->SetLineColor(1); hptRat->Draw("E X0"); TH1F *hptFRat = (TH1F*) getSystErrForRatio(hptFOR); hptFRat->SetLineColor(2); hptFRat->SetFillColor(2); hptFRat->SetFillStyle(3004); hptFRat->Draw("same hist ][ E2"); TLine * line = new TLine( hptRat->GetXaxis()->GetXmin(), 1., hptRat->GetXaxis()->GetXmax(), 1. ); line->SetLineColor(1); line->SetLineWidth(0.5); line->SetLineStyle(1); line->Draw("same"); hptR->GetXaxis()->SetLabelSize(0); hptR->GetXaxis()->SetTitle(""); cPt->RedrawAxis(); gPad->Update(); cPt->Update(); return; }
int makePWhisto(TString filename_MC="/home/jpavel/analysis/CMS/ZHtautau/histos/2012ABCD/mc/20130114_AnalFullMC_DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball/20130114_AnalFullMC_DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball_histo.root",TString filename_data="/home/jpavel/analysis/CMS/ZHtautau/ZHtautauAnalysis/config/dataPileUpHistogramABCD_True_2012.root") { gROOT->Reset(); SetAtlasStyle(); gStyle->SetPalette(1); TFile *f = TFile::Open(filename_MC); if(!f) { std::cerr << "Error: file " << filename_MC << " could not be opened." << std::endl; return 1; } else std::cout << "File " << filename_MC << " succesfully opened!" << std::endl; TFile *g = TFile::Open(filename_data); if(!f) { std::cerr << "Error: file " << filename_data << " could not be opened." << std::endl; return 1; } else std::cout << "File " << filename_data << " succesfully opened!" << std::endl; TH1F* mu_orig_import= (TH1F*)f->Get("h_nPU_raw"); TH1F* mu_RW_import= (TH1F*)f->Get("h_nPU_reweight"); TH1F* mu_data= (TH1F*)g->Get("pileup"); mu_orig_import->Draw(); TH1F* mu_orig_mine = new TH1F("mu_orig_mine","#mu distribution before reweighting;#mu;fraction of events",21,-0.5,20.5); TH1F* mu_RW_mine = new TH1F("mu_RW_mine","#mu distribution after reweighting;#mu;fraction of events",21,-0.5,20.5); TH1F* mu_data_mine = new TH1F("mu_data_mine","#mu distribution in data;#mu;fraction of events",21,-0.5,20.5); for(int iBin = 1; iBin <= mu_orig_mine->GetNbinsX(); iBin++) { mu_orig_mine->SetBinContent(iBin,mu_orig_import->GetBinContent(iBin)); mu_RW_mine->SetBinContent(iBin,mu_RW_import->GetBinContent((iBin-1)*5+1)); float dataMuLowEdge = mu_orig_mine->GetBinLowEdge(iBin); float dataMuHighEdge = mu_orig_mine->GetBinLowEdge(iBin) + mu_orig_mine->GetBinWidth(iBin); int dataBinNumberLowEdge = mu_data->GetXaxis()->FindFixBin(dataMuLowEdge); int dataBinNumberHighEdge = mu_data->GetXaxis()->FindFixBin(dataMuHighEdge); float dataBinContent = mu_data->Integral( dataBinNumberLowEdge, dataBinNumberHighEdge-1 ); mu_data_mine->SetBinContent(iBin,dataBinContent); } mu_orig_mine->SetBinContent(1,mu_orig_import->GetBinContent(101)); mu_orig_import->Scale(1./mu_orig_import->GetSumOfWeights()); mu_RW_import->Scale(1./mu_RW_import->GetSumOfWeights()); mu_data->Scale(1./mu_data->GetSumOfWeights()); //mu_data->Scale(10./mu_data->GetSumOfWeights()); TCanvas* c1 = new TCanvas("c1","c1", 800,600); mu_orig_import->Draw(); c1->Print("mu_mc.png"); c1->Print("mu_mc.eps"); mu_data->GetXaxis()->SetTitle("#mu"); mu_data->GetYaxis()->SetTitle("fraction of events"); mu_data->Draw(); c1->Print("mu_data.png"); c1->Print("mu_data.eps"); float myMax[] = {mu_RW_import->GetMaximum(),mu_data->GetMaximum()}; float Max_h = *max_element(myMax,myMax+2); mu_RW_import->SetMaximum(1.2*Max_h); mu_RW_import->SetMarkerStyle(25); mu_RW_import->SetMarkerSize(1.5); mu_RW_import->GetXaxis()->SetTitle("True number of interactions per event"); mu_RW_import->GetXaxis()->SetRangeUser(0,60); mu_RW_import->GetYaxis()->SetTitle("Fraction of events"); mu_RW_import->Draw("phist"); //~ //~ //mu_data->SetLineColor(kRed); //~ //mu_data->Draw("same"); mu_data->SetLineColor(kGreen); mu_data->SetMarkerStyle(22); mu_data->SetMarkerSize(1.5); mu_data->SetMarkerColor(kGreen); mu_data->Draw("phistsame"); mu_data->Draw("same"); mu_RW_import->Draw("same"); mu_orig_import->SetLineColor(kRed); mu_orig_import->Draw("histsame"); gPad->RedrawAxis(); TLegend* leg = new TLegend(0.6,0.7,0.8,0.93); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(legend_size); leg->AddEntry(mu_RW_import,"re-weighted MC","p"); leg->AddEntry(mu_data,"data 2012ABCD","lp"); leg->AddEntry(mu_orig_import,"Summer12 53x MC","l"); leg->Draw(); c1->Print("mu_reweight.png"); c1->Print("mu_reweight.eps"); c1->SetLogy(); mu_RW_import->SetMaximum(1200*Max_h); c1->Print("mu_reweight_log.png"); c1->Print("mu_reweight_log.eps"); //~ return 0; }
void ZinvEstimate(){//main programme //Set Canvas Style TStyle *gStyle = new TStyle("gStyle","Style for P-TDR"); SetStyle st; st.SetPars(gStyle); //finished setting canvas style DataMC plot; //Important //In kevins v3 production due to a bug puWeight is divided to all standard MC weights ...this should be removed //from the code if you are using it for version otherthan V3 TString InputFilePathV4="/eos/uscms/store/user/pedrok/SUSY2015/Analysis/Skims/Run2ProductionV4/"; TString InputFilePathV3="/eos/uscms/store/user/pedrok/SUSY2015/Analysis/Skims/Run2ProductionV3/"; TString InputFilePathV2="/eos/uscms/store/user/pedrok/SUSY2015/Analysis/Skims/Run2ProductionV2/"; TChain* tZinv = new TChain("tree"); tZinv->Add(InputFilePathV4+"tree_signal/tree_ZJetsToNuNu_HT*.root"); ReadTree Zinv(tZinv); //reading the GJets MC TChain* tGJets = new TChain("tree"); tGJets->Add(InputFilePathV4+"tree_GJet_CleanVars/tree_GJets_HT-*.root"); ReadTree GJets(tGJets); //reading QCD MC TChain* tQCD = new TChain("tree"); tQCD->Add(InputFilePathV4+"tree_GJet_CleanVars/tree_QCD_HT*.root"); ReadTree QCD(tQCD); //reading Single photon Data TChain* tData = new TChain("tree"); tData->Add(InputFilePathV4+"tree_GJet_CleanVars/tree_SinglePhoton_*.root"); ReadTree Data(tData); double Lumi=1280.23; int nBinsHT=13; int nBinsMHT=7; int nBinsPt=8; int nBinsNJ=6; int nBinsS=25; double HTbins[14]={500.,600.,700,800,900,1000.,1100,1200.,1300,1400,1500,1700,2000,3000}; double MHTbins[8]={200.,300,400,500.,600,750.,1000,1500.}; double Ptbins[9]={100,200.,300,400,500.,600,750.,1000,1500.}; double NJetsbins[7]={4,5,6,7,8,9,12}; /////////Three MHT Bins double MHTbin1Min=200; double MHTbin1Max=350; double MHTbin2Min=350; double MHTbin2Max=500; double MHTbin3Min=500; double MHTbin3Max=1500; ///////////Three MHT Bins int nBinAN=18; double nBinANmax=18.5; /////////////////////////////////////////////////////////////////////////////All user input changes above TH1F *hHT_Zinv=new TH1F("hHT_Zinv","hHT_Zinv",nBinsHT,HTbins); TH1F *hMHT_Zinv=new TH1F("hMHT_Zinv","hMHT_Zinv",nBinsMHT,MHTbins); TH1F *hNJets_Zinv=new TH1F("hNJets_Zinv","hNJets_Zinv",nBinsNJ,NJetsbins); TH1F *hHT_GJets=new TH1F("hHT_GJets","hHT_GJets",nBinsHT,HTbins); TH1F *hMHT_GJets=new TH1F("hMHT_GJets","hMHT_GJets",nBinsMHT,MHTbins); TH1F *hNJets_GJets=new TH1F("hNJets_GJets","hNJets_GJets",nBinsNJ,NJetsbins); TH1F *hSieta_GJetsEB=new TH1F("hSieta_GJetsEB","hSieta_GJetsEB",nBinsS,0.006,0.0107); TH1F *hSieta_GJetsEC=new TH1F("hSieta_GJetsEC","hSieta_GJetsEC",nBinsS,0.01,0.0272); TH1F *hSieta_GJetsEBLow=new TH1F("hSieta_GJetsEBLow","hSieta_GJetsEBLow",nBinsS,0.006,0.0107); TH1F *hSieta_GJetsECLow=new TH1F("hSieta_GJetsECLow","hSieta_GJetsECLow",nBinsS,0.01,0.0272); TH1F *hSieta_GJetsEBMed=new TH1F("hSieta_GJetsEBMed","hSieta_GJetsEBMed",nBinsS,0.006,0.0107); TH1F *hSieta_GJetsECMed=new TH1F("hSieta_GJetsECMed","hSieta_GJetsECMed",nBinsS,0.01,0.0272); TH1F *hSieta_GJetsEBHigh=new TH1F("hSieta_GJetsEBHigh","hSieta_GJetsEBHigh",nBinsS,0.006,0.0107); TH1F *hSieta_GJetsECHigh=new TH1F("hSieta_GJetsECHigh","hSieta_GJetsECHigh",nBinsS,0.01,0.0272); TH1F *hPhPt_GJetsEB=new TH1F("hPhPt_GJetsEB","hPhPt_GJetsEB",nBinsPt,Ptbins); TH1F *hPhPt_GJetsEC=new TH1F("hPhPt_GJetsEC","hPhPt_GJetsEC",nBinsPt,Ptbins); TH1F *hHT_QCD=new TH1F("hHT_QCD","hHT_QCD",nBinsHT,HTbins); TH1F *hMHT_QCD=new TH1F("hMHT_QCD","hMHT_QCD",nBinsMHT,MHTbins); TH1F *hNJets_QCD=new TH1F("hNJets_QCD","hNJets_QCD",nBinsNJ,NJetsbins); TH1F *hSieta_QCDEB=new TH1F("hSieta_QCDEB","hSieta_QCDEB",nBinsS,0.006,0.0107); TH1F *hSieta_QCDEC=new TH1F("hSieta_QCDEC","hSieta_QCDEC",nBinsS,0.01,0.0272); TH1F *hSieta_QCDEBLow=new TH1F("hSieta_QCDEBLow","hSieta_QCDEBLow",nBinsS,0.006,0.0107); TH1F *hSieta_QCDECLow=new TH1F("hSieta_QCDECLow","hSieta_QCDECLow",nBinsS,0.01,0.0272); TH1F *hSieta_QCDEBMed=new TH1F("hSieta_QCDEBMed","hSieta_QCDEBMed",nBinsS,0.006,0.0107); TH1F *hSieta_QCDECMed=new TH1F("hSieta_QCDECMed","hSieta_QCDECMed",nBinsS,0.01,0.0272); TH1F *hSieta_QCDEBHigh=new TH1F("hSieta_QCDEBHigh","hSieta_QCDEBHigh",nBinsS,0.006,0.0107); TH1F *hSieta_QCDECHigh=new TH1F("hSieta_QCDECHigh","hSieta_QCDECHigh",nBinsS,0.01,0.0272); TH1F *hPhPt_QCDEB=new TH1F("hPhPt_QCDEB","hPhPt_QCDEB",nBinsPt,Ptbins); TH1F *hPhPt_QCDEC=new TH1F("hPhPt_QCDEC","hPhPt_QCDEC",nBinsPt,Ptbins); TH1F *hHT_Data=new TH1F("hHT_Data","hHT_Data",nBinsHT,HTbins); TH1F *hMHT_Data=new TH1F("hMHT_Data","hMHT_Data",nBinsMHT,MHTbins); TH1F *hNJets_Data=new TH1F("hNJets_Data","hNJets_Data",nBinsNJ,NJetsbins); TH1F *hSieta_DataEB=new TH1F("hSieta_DataEB","hSieta_DataEB",nBinsS,0.006,0.0107); TH1F *hSieta_DataEC=new TH1F("hSieta_DataEC","hSieta_DataEC",nBinsS,0.01,0.0272);; TH1F *hSieta_DataEBLow=new TH1F("hSieta_DataEBLow","hSieta_DataEBLow",nBinsS,0.006,0.0107); TH1F *hSieta_DataECLow=new TH1F("hSieta_DataECLow","hSieta_DataECLow",nBinsS,0.01,0.0272); TH1F *hSieta_DataEBMed=new TH1F("hSieta_DataEBMed","hSieta_DataEBMed",nBinsS,0.006,0.0107); TH1F *hSieta_DataECMed=new TH1F("hSieta_DataECMed","hSieta_DataECMed",nBinsS,0.01,0.0272); TH1F *hSieta_DataEBHigh=new TH1F("hSieta_DataEBHigh","hSieta_DataEBHigh",nBinsS,0.006,0.0107); TH1F *hSieta_DataECHigh=new TH1F("hSieta_DataECHigh","hSieta_DataECHigh",nBinsS,0.01,0.0272); TH1F *hPhPt_DataEB=new TH1F("hPhPt_DataEB","hPhPt_DataEB",nBinsPt,Ptbins); TH1F *hPhPt_DataEC=new TH1F("hPhPt_DataEC","hPhPt_DataEC",nBinsPt,Ptbins); TH1F *h_NZinv18bin=new TH1F("h_NZinv18bin","h_NZinv18bin",nBinAN,0.5,nBinANmax); // TH1F *h_NZinv18binC=new TH1F("h_NZinv18binC","h_NZinv18binC",nBinAN,0.5,nBinANmax); //TH1F *EBestimate=new TH1F("EBestimate","EBestimate",18,0.5,18.5); //TH1F *ECestimate=new TH1F("ECestimate","ECestimate",18,0.5,18.5); TH1F *ZinvEstimate=new TH1F("ZinvEstimate","ZinvEstimate",nBinAN,0.5,nBinANmax); TH1F *h_NGJets18bin=new TH1F("h_NGJets18binC","h_NGJets18binC",nBinAN,0.5,nBinANmax); TH1F *h_NGJets18binEB=new TH1F("h_NGJets18binEB","h_NGJets18binEB",nBinAN,0.5,nBinANmax); TH1F *h_NGJets18binEC=new TH1F("h_NGJets18binEC","h_NGJets18binEC",nBinAN,0.5,nBinANmax); TH1F *h_NQCD18binEB=new TH1F("h_NQCD18binEB","h_NQCD18binEB",nBinAN,0.5,nBinANmax); TH1F *h_NQCD18binEC=new TH1F("h_NQCD18binEC","h_NQCD18binEC",nBinAN,0.5,nBinANmax); TH1F *h_Ndata18binEB=new TH1F("h_Ndata18binEB","h_Ndata18binEB",nBinAN,0.5,nBinANmax); TH1F *h_Ndata18binEC=new TH1F("h_Ndata18binEC","h_Ndata18binEC",nBinAN,0.5,nBinANmax); TH1F *h_ZgammaR18bin=new TH1F("h_ZgammaR18bin","h_ZgammmaR18bin",nBinAN,0.5,nBinANmax); TH1F *h_ZgammaRWSF=new TH1F("h_ZgammaRWSF","h_ZgammmaRWSF",nBinAN,0.5,nBinANmax); int maxEvents_Zinv=tZinv->GetEntries(); cout<<"maxEventsZinv: "<<maxEvents_Zinv<<endl; for(int iEv=0;iEv<maxEvents_Zinv;iEv++){//Looping over Zinv MC/////////////////////////////////////// tZinv->GetEntry(iEv); if(iEv % 1000000==0){cout<<"Event no Zinv : "<<iEv<<endl;} int binNumber_Zinv = computeBin( Zinv.MHTclean, Zinv.HTclean, Zinv.NJetsclean, k13TeV); double weight=0; if(binNumber_Zinv >-1 && Zinv.BTagsclean==0){//Filling Yield(N_Obsereved) in Zinv h_NZinv18bin->Fill(binNumber_Zinv,(Lumi*Zinv.Weight)); h_NZinv18binC->Fill(binNumber_Zinv,(Lumi*Zinv.Weight)); } }//Lopping over Zinv MC////////////////////////////////////////////////////////// cout<<"Zinv Observed MC: "<<h_NZinv18bin->Integral()<<endl; cout<<"First bin: "<<h_NZinv18bin->GetBinContent(0)<<endl; for(int i=1;i<19;i++){ cout<<"Zinv Bin Content: "<<h_NZinv18bin->GetBinContent(i)<<endl; } int maxEvents_GJets=tGJets->GetEntries(); cout<<"maxEventsGJets: "<<maxEvents_GJets<<endl; for(int iEv=0;iEv<maxEvents_GJets;iEv++){//Looping over GJets MC/////////////////////////////////////// tGJets->GetEntry(iEv); if(iEv % 1000000==0){cout<<"Event no GJets : "<<iEv<<endl;} int binNumber_GJets = computeBin( GJets.MHTclean, GJets.HTclean, GJets.NJetsclean, k13TeV); int index=GJets.photonIndex(); if(binNumber_GJets >-1 && GJets.BTagsclean==0 && index !=-1 && GJets.photon_nonPrompt->at(index) !=1){//Filling Yield(N_Obsereved) in GJets MC hHT_GJets->Fill(GJets.HTclean,Lumi*GJets.Weight); hMHT_GJets->Fill(GJets.MHTclean,Lumi*GJets.Weight); hNJets_GJets->Fill(GJets.NJetsclean,Lumi*GJets.Weight); h_NGJets18bin->Fill(binNumber_GJets,Lumi*GJets.Weight); if(fabs(GJets.bestPhoton->at(0).Eta())< 1.4442){//barrel hSieta_GJetsEB->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight); h_NGJets18binEB->Fill(binNumber_GJets,Lumi*GJets.Weight); hPhPt_GJetsEB->Fill(GJets.photonCands->at(index).Pt(),Lumi*GJets.Weight); ////////////////////////////////////Sieta in MHT bins if(GJets.MHTclean >MHTbin1Min && GJets.MHTclean< MHTbin1Max){ hSieta_GJetsEBLow->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight); } if(GJets.MHTclean >MHTbin2Min && GJets.MHTclean< MHTbin2Max){ hSieta_GJetsEBMed->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight); } if(GJets.MHTclean >MHTbin3Min && GJets.MHTclean< MHTbin3Max){ hSieta_GJetsEBHigh->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight); } /////////////////////////Sieta in MHT bins }//barrel if(fabs(GJets.bestPhoton->at(0).Eta())> 1.566 && fabs(GJets.bestPhoton->at(0).Eta())< 2.5){//endcap hSieta_GJetsEC->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight); h_NGJets18binEC->Fill(binNumber_GJets,Lumi*GJets.Weight); hPhPt_GJetsEC->Fill(GJets.photonCands->at(index).Pt(),Lumi*GJets.Weight); ////////////////////////////////////Sieta in MHT bins if(GJets.MHTclean >MHTbin1Min && GJets.MHTclean< MHTbin1Max){ hSieta_GJetsECLow->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight); } if(GJets.MHTclean >MHTbin2Min && GJets.MHTclean< MHTbin2Max){ hSieta_GJetsECMed->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight); } if(GJets.MHTclean >MHTbin3Min && GJets.MHTclean< MHTbin3Max){ hSieta_GJetsECHigh->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight); } /////////////////////////Sieta in MHT bins }//endcap }//Filling Yield(N_Obsereved) in GJets MC }//Looping over GJets MC////////////////////////////////////////////////////////////////////////// cout<<"Total GJets Events: "<<hHT_GJets->Integral(); int maxEvents_QCD=tQCD->GetEntries(); cout<<"maxEventsQCD: "<<maxEvents_QCD<<endl; for(int iEv=0;iEv<maxEvents_QCD;iEv++){//Looping over QCD MC tQCD->GetEntry(iEv); if(iEv % 1000000==0){cout<<"Event no QCD : "<<iEv<<endl;} int binNumber_QCD = computeBin( QCD.MHTclean, QCD.HTclean, QCD.NJetsclean, k13TeV); int index=QCD.photonIndex(); if(binNumber_QCD >-1 && QCD.BTagsclean==0 && index !=-1 && QCD.photon_nonPrompt->at(index) ==1 ){//Filling Yield(N_Obsereved) in QCD MC hHT_QCD->Fill(QCD.HTclean,Lumi*QCD.Weight); hMHT_QCD->Fill(QCD.MHTclean,Lumi*QCD.Weight); hNJets_QCD->Fill(QCD.NJetsclean,Lumi*QCD.Weight); if(fabs(QCD.bestPhoton->at(0).Eta())< 1.4442){//barrel hSieta_QCDEB->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight); h_NQCD18binEB->Fill(binNumber_QCD,Lumi*QCD.Weight); hPhPt_QCDEB->Fill(QCD.photonCands->at(index).Pt(),Lumi*QCD.Weight); ////////////////////////////////////Sieta in MHT bins if(QCD.MHTclean >MHTbin1Min && QCD.MHTclean< MHTbin1Max){ hSieta_QCDEBLow->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight); } if(QCD.MHTclean >MHTbin2Min && QCD.MHTclean< MHTbin2Max){ hSieta_QCDEBMed->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight); } if(QCD.MHTclean >MHTbin3Min && QCD.MHTclean< MHTbin3Max){ hSieta_QCDEBHigh->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight); } /////////////////////////Sieta in MHT bins }//barrel if(fabs(QCD.bestPhoton->at(0).Eta())> 1.566 && abs(QCD.bestPhoton->at(0).Eta()) <2.5 ){//endcap hSieta_QCDEC->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight); h_NQCD18binEC->Fill(binNumber_QCD,Lumi*QCD.Weight); hPhPt_QCDEC->Fill(QCD.photonCands->at(index).Pt(),Lumi*QCD.Weight); }//endcap ////////////////////////////////////Sieta in MHT bins if(QCD.MHTclean >MHTbin1Min && QCD.MHTclean< MHTbin1Max){ hSieta_QCDECLow->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight); } if(QCD.MHTclean >MHTbin2Min && QCD.MHTclean< MHTbin2Max){ hSieta_QCDECMed->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight); } if(QCD.MHTclean >MHTbin3Min && QCD.MHTclean< MHTbin3Max){ hSieta_QCDECHigh->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight); } /////////////////////////Sieta in MHT bins }//Filling Yield(N_Obsereved) in QCD MC }//Looping over QCD MC int maxEvents_Data=tData->GetEntries(); //cout<<"maxEvents in Single Photon Data: "<<maxEvents_Data<<endl; for(int iEv=0;iEv<maxEvents_Data;iEv++){//Data tData->GetEntry(iEv); if(iEv % 1000000==0){cout<<"Event no Data : "<<iEv<<endl;} //cout<<"Event no: "<<iEv<<endl; int binNumber_Data = computeBin( Data.MHTclean, Data.HTclean, Data.NJetsclean, k13TeV); int index=Data.photonIndex(); if(binNumber_Data >-1 && Data.BTagsclean==0 && index !=-1){//Filling Yield(N_Obsereved) in Data bool PassTrigger=false; for(int itr=0;itr<Data.TriggerNames->size();itr++){ //cout<<"trigger size: "<<Data.TriggerNames->at(itr)<<endl; if(Data.TriggerNames->at(itr)=="HLT_Photon90_CaloIdL_PFHT500_v3" && Data.TriggerPass->at(itr)==1){ PassTrigger=true; } } if(PassTrigger==true){//trigger pass hHT_Data->Fill(Data.HTclean); hMHT_Data->Fill(Data.MHTclean); hNJets_Data->Fill(Data.NJetsclean); if(fabs(Data.bestPhoton->at(0).Eta())< 1.4442){//barrel h_Ndata18binEB->Fill(binNumber_Data); hSieta_DataEB->Fill(Data.photon_sigmaIetaIeta->at(index)); hPhPt_DataEB->Fill(Data.photonCands->at(index).Pt()); ////////////////////////////////////Sieta in MHT bins if(Data.MHTclean >MHTbin1Min && Data.MHTclean< MHTbin1Max){ hSieta_DataEBLow->Fill(Data.photon_sigmaIetaIeta->at(index)); } if(Data.MHTclean >MHTbin2Min && Data.MHTclean< MHTbin2Max){ hSieta_DataEBMed->Fill(Data.photon_sigmaIetaIeta->at(index)); } if(Data.MHTclean >MHTbin3Min && Data.MHTclean< MHTbin3Max){ hSieta_DataEBHigh->Fill(Data.photon_sigmaIetaIeta->at(index)); } /////////////////////////Sieta in MHT bins }//barrel if(fabs(Data.bestPhoton->at(0).Eta())> 1.566 && fabs(Data.bestPhoton->at(0).Eta())< 2.5 ){//endcap h_Ndata18binEC->Fill(binNumber_Data); hSieta_DataEC->Fill(Data.photon_sigmaIetaIeta->at(index)); hPhPt_DataEC->Fill(Data.photonCands->at(index).Pt()); ////////////////////////////////////Sieta in MHT bins if(Data.MHTclean >MHTbin1Min && Data.MHTclean< MHTbin1Max){ hSieta_DataECLow->Fill(Data.photon_sigmaIetaIeta->at(index)); } if(Data.MHTclean >MHTbin2Min && Data.MHTclean< MHTbin2Max){ hSieta_DataECMed->Fill(Data.photon_sigmaIetaIeta->at(index)); } if(Data.MHTclean >MHTbin3Min && Data.MHTclean< MHTbin3Max){ hSieta_DataECHigh->Fill(Data.photon_sigmaIetaIeta->at(index)); } /////////////////////////Sieta in MHT bins }//endcap }//trigger pass }//Filling Yield(N_Obsereved) in Data }//Data //trigger efficiency ///////////////////////////defining legend char Legname1[100]; TLegend *leg[24]; for(int k0=0;k0<24;k0++){ sprintf(Legname1,"leg_1D%i",k0); leg[k0]=new TLegend(0.5,0.7,0.80,0.89); leg[k0]->SetTextFont(62); leg[k0]->SetLineColor(1); leg[k0]->SetLineStyle(1); leg[k0]->SetLineWidth(3); leg[k0]->SetFillColor(0); leg[k0]->SetFillStyle(1001); leg[k0]->SetShadowColor(0); leg[k0]->SetDrawOption(0); leg[k0]->SetBorderSize(0); leg[k0]->SetTextSize(0.03); } ///////////////////////////////ZinvMC Yield //TCanvas *ZinvMCYield=new TCanvas("ZinvMC","ZinvMC"); //ZinvMCYield->SetLogy(); h_NZinv18bin->Sumw2(); h_NZinv18bin->SetFillColor(1); h_NZinv18bin->SetFillStyle(1000); h_NZinv18bin->GetXaxis()->SetTitle("bin Number"); h_NZinv18bin->GetYaxis()->SetTitle("Z/Gamma Ratio"); //h_NZinv18bin->Draw("hist"); //////////////////////////////////////////////Calculating Zgamma Ratio start TPaveText *tpav1 = new TPaveText(0.1956522,0.6247818,0.729097,0.8970332,"brNDC"); tpav1->SetBorderSize(0); tpav1->SetFillStyle(0); tpav1->SetTextAlign(11); tpav1->SetTextFont(42); tpav1->SetTextSize(0.04); tpav1->AddText("HT >500"); tpav1->AddText("#gamma p_{T} > 100 "); tpav1->AddText("NJets >=4"); tpav1->AddText("MHT>200"); tpav1->AddText("Btags=0"); tpav1->AddText("#Delta #Phi_{1,2,3,4}>(0.5,0.5,0.3,0.3)"); TPaveText *pCMS1 = new TPaveText(0.132107,0.9308003,0.8327759,0.9923583,"brNDC"); pCMS1->SetBorderSize(0); pCMS1->SetFillStyle(0); pCMS1->SetTextAlign(11); pCMS1->SetTextFont(42); pCMS1->SetTextSize(0.04); pCMS1->AddText("CMS #it{Preliminary} #sqrt{s}= 13 TeV"); TCanvas *cZgammaR=new TCanvas("cZGammaR","cZGammaR"); TH1F *h_ZgR = (TH1F*)h_NZinv18bin->Clone("h_ZgR"); h_ZgR->Divide(h_NGJets18bin); cZgammaR->cd(); h_ZgR->Draw("E2"); tpav1->Draw(); pCMS1->Draw(); cZgammaR->SaveAs("ZgammaRatioWOSF.png"); cZgammaR->SaveAs("ZgammaRatioWOSF.pdf"); cZgammaR->SaveAs("ZgammaRatioWOSF.gif"); ///////////////////////////////////Calculating ZGamma ratio end /////////////////////////////////////////////////////Dealing with Data barrel TH1F *h_DataSimEB = (TH1F*)h_Ndata18binEB->Clone("h_DataSimEB"); TH1F *h_DataSimEC = (TH1F*)h_Ndata18binEC->Clone("h_DataSimEC"); TH1F *h_DataSimEBforErr = (TH1F*)h_NGJets18binEB->Clone("h_DataSimEBforErr"); TH1F *h_DataSimECforErr = (TH1F*)h_NGJets18binEB->Clone("h_DataSimECforErr"); h_DataSimEBforErr->Scale((1/h_DataSimEBforErr->Integral())*h_Ndata18binEB->Integral()); h_DataSimECforErr->Scale((1/h_DataSimECforErr->Integral())*h_Ndata18binEC->Integral()); /////////////////////Fill the empty bins with simulated data for(int i=1;i<(nBinAN+1);i++){//loop over bins h_DataSimEB->SetBinError(i,0.); h_DataSimEC->SetBinError(i,0.); }//loop over bins TH1F *hEBPurity=new TH1F("hEBPurity","hEBPurity",nBinAN,0.5,nBinANmax); TH1F *hECPurity=new TH1F("hECPurity","hECPurity",nBinAN,0.5,nBinANmax); TH1F *hEBfrag=new TH1F("hEBfrag","hEBfrag",nBinAN,0.5,nBinANmax); TH1F *hECfrag=new TH1F("hECfrag","hECfrag",nBinAN,0.5,nBinANmax); //uncorel //corel double ebpErr=sqrt((0.009*0.009)+(0.03*0.03)); double ecpErr=sqrt((0.016*0.016)+(0.046*0.046)); double ebpErrCorel=0.03; double ebpErrUnCorel=0.009; double ecpErrCorel=0.046; double ecpErrUnCorel=0.016; for(int i=1;i<(nBinAN+1);i++){//set purity stuff hEBPurity->SetBinContent(i,0.967); hEBPurity->SetBinError(i,ebpErr); hECPurity->SetBinContent(i,0.956); hECPurity->SetBinError(i,ecpErr); hEBfrag->SetBinContent(i,0.92); hEBfrag->SetBinError(i,0.04); hECfrag->SetBinContent(i,0.92); hECfrag->SetBinError(i,0.04); }//set purity stuff const Int_t NumBins= nBinAN; double binNumber[nBinAN]; double YieldEstimated[nBinAN]; double YieldErrUp_Estimated[nBinAN]; double YieldErrLow_Estimated[nBinAN]; double YieldPredMC[nBinAN]; double YieldErrUp_PredMC[nBinAN]; double YieldErrLow_PredMC[nBinAN]; double XErrLow[nBinAN]; double XErrUp[nBinAN]; double ZgRwSF[nBinAN]; double ZgRwSF_sys_ErrUp[nBinAN]; double ZgRwSF_sys_ErrLow[nBinAN]; double ZgRwSF_stat_Err[nBinAN]; for(int ibin=1;ibin<(nBinAN+1);ibin++){//loop over bin error calculation double SF=0.98; double SFup=1.03; double SFlow=0.93; double ZgRcentral=h_ZgR->GetBinContent(ibin)/0.98; double ZgRup=h_ZgR->GetBinContent(ibin)/1.03; double ZgRlow=h_ZgR->GetBinContent(ibin)/0.93; double ZgRcorelErrup=fabs(ZgRcentral-ZgRlow); double ZgRcorelErrlow=fabs(ZgRcentral-ZgRup); double ZgRsymErr=0.5*(sqrt((ZgRcorelErrup*ZgRcorelErrup)+(ZgRcorelErrlow*ZgRcorelErrlow))); double ZgRcorel_Rel_Errup=ZgRcorelErrup/ZgRcentral; double ZgRcorel_Rel_Errlow=ZgRcorelErrlow/ZgRcentral; //double ZgRcorelErr=sqrt((ZgRcorelErrup*ZgRcorelErrup)+(ZgRcorelErrlow*ZgRcorelErrlow)); double ZgRuncorelErr=h_ZgR->GetBinError(ibin)/SF; double ZgRuncorel_Rel_Err=ZgRuncorelErr/ZgRcentral; double ZgRsymErrStat=h_ZgR->GetBinError(ibin)/SF;//h_ZgR->GetBinError(ibin); double ZgRallSymErr=sqrt((ZgRsymErr*ZgRsymErr)+(ZgRsymErrStat*ZgRsymErrStat)); //important lines to be changed double ZgR=ZgRcentral; double ZgRerr=ZgRallSymErr; double ZgRerrUp=sqrt((ZgRcorelErrup*ZgRcorelErrup)+(ZgRuncorelErr*ZgRuncorelErr)); double ZgRerrLow=sqrt((ZgRcorelErrlow*ZgRcorelErrlow)+(ZgRuncorelErr*ZgRuncorelErr)); ////////////////////////////////////barrel starts int EBobs=h_DataSimEB->GetBinContent(ibin); double EBobsErr=h_DataSimEB->GetBinError(ibin); double pEB=hEBPurity->GetBinContent(ibin); double pEBerr=hEBPurity->GetBinError(ibin); double pEB_Rel_err=pEBerr/pEB; int ECobs=h_DataSimEC->GetBinContent(ibin); double ECobsErr=h_DataSimEC->GetBinError(ibin); double pEC=hECPurity->GetBinContent(ibin); double pECerr=hECPurity->GetBinError(ibin); double pEC_Rel_err=pECerr/pEC; double f=0.92; double ferr=0.04; double f_Rel_err=ferr/f; double YieldTotal=ZgR*(EBobs*pEB+ECobs*pEC)*f; double YieldTotalErr=0; double YieldTotal_Rel_Err=0; double YieldTotalErrUp=0; double YieldTotal_Rel_ErrUp=0; double YieldTotalErrLow=0; double YieldTotal_Rel_ErrLow=0; int Nobserved=EBobs+ECobs; double totalPurity=0; double totalPurityErr=0; double totalPurity_Rel_Err=0; double ZinvMCYield=h_NZinv18binC->GetBinContent(ibin); double ZinvMCYieldErr=h_NZinv18binC->GetBinError(ibin); double ZinvMCYield_Rel_Err=ZinvMCYieldErr/ZinvMCYield; if(Nobserved !=0){ totalPurity=((EBobs*pEB+ECobs*pEC)*f)/Nobserved; double totalPurityErr1=(EBobs*pEBerr+ECobs*pECerr)/Nobserved; double totalPurityErr2=ferr; totalPurityErr=sqrt((totalPurityErr1*totalPurityErr1)+(totalPurityErr2*totalPurityErr2)); totalPurity_Rel_Err=totalPurityErr/totalPurity; YieldTotalErr=Nobserved*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerr*ZgRerr))); YieldTotal_Rel_Err=YieldTotalErr/YieldTotal; YieldTotalErrUp=Nobserved*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerrUp*ZgRerrUp))); YieldTotal_Rel_ErrUp=YieldTotalErrUp/YieldTotal; YieldTotalErrLow=Nobserved*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerrLow*ZgRerrLow))); YieldTotal_Rel_ErrLow=YieldTotalErrLow/YieldTotal; } if(Nobserved ==0){ double NobservedNew=h_DataSimEBforErr->GetBinContent(ibin)+h_DataSimECforErr->GetBinContent(ibin); double EBobsNew=h_DataSimEBforErr->GetBinContent(ibin); double ECobsNew=h_DataSimECforErr->GetBinContent(ibin); totalPurity=((EBobsNew*pEB+ECobsNew*pEC)*f)/NobservedNew; double totalPurityErr1=(EBobsNew*pEBerr+ECobsNew*pECerr)/NobservedNew; double totalPurityErr2=ferr; totalPurityErr=sqrt((totalPurityErr1*totalPurityErr1)+(totalPurityErr2*totalPurityErr2)); totalPurity_Rel_Err=totalPurityErr/totalPurity; YieldTotalErr=NobservedNew*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerr*ZgRerr))); double YieldTotalNew=ZgR*(EBobsNew*pEB+ECobsNew*pEC)*f; YieldTotal_Rel_Err=YieldTotalErr/YieldTotalNew; YieldTotalErrUp=NobservedNew*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerrUp*ZgRerrUp))); YieldTotal_Rel_ErrUp=YieldTotalErrUp/YieldTotalNew; YieldTotalErrLow=NobservedNew*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerrLow*ZgRerrLow))); YieldTotal_Rel_ErrLow=YieldTotalErrLow/YieldTotalNew; } double YieldErrWithStat=0; double YieldErrWithStatUp=0; double YieldErrWithStatLow=0; double NobsErr=sqrt(Nobserved); YieldErrWithStat=sqrt((ZgR*totalPurity*NobsErr)*(ZgR*totalPurity*NobsErr) + (Nobserved*totalPurity*ZgRerr)*(Nobserved*totalPurity*ZgRerr) + (Nobserved*ZgR*totalPurityErr)*(Nobserved*ZgR*totalPurityErr)); YieldErrWithStatUp=sqrt((ZgR*totalPurity*NobsErr)*(ZgR*totalPurity*NobsErr) + (Nobserved*totalPurity*ZgRerrUp)*(Nobserved*totalPurity*ZgRerrUp) + (Nobserved*ZgR*totalPurityErr)*(Nobserved*ZgR*totalPurityErr)); YieldErrWithStatLow=sqrt((ZgR*totalPurity*NobsErr)*(ZgR*totalPurity*NobsErr) + (Nobserved*totalPurity*ZgRerrLow)*(Nobserved*totalPurity*ZgRerrLow) + (Nobserved*ZgR*totalPurityErr)*(Nobserved*ZgR*totalPurityErr)); ZgRwSF[ibin-1]=ZgR; ZgRwSF_sys_ErrUp[ibin-1]=ZgRcorelErrup; ZgRwSF_sys_ErrLow[ibin-1]=ZgRcorelErrlow; ZgRwSF_stat_Err[ibin-1]=ZgRuncorelErr; binNumber[ibin-1]=ibin; YieldEstimated[ibin-1]=YieldTotal; YieldErrUp_Estimated[ibin-1]=YieldErrWithStatUp; YieldErrLow_Estimated[ibin-1]=YieldErrWithStatLow; YieldPredMC[ibin-1]=ZinvMCYield; YieldErrUp_PredMC[ibin-1]=ZinvMCYieldErr; YieldErrLow_PredMC[ibin-1]=ZinvMCYieldErr; XErrLow[ibin-1]=0.5; XErrUp[ibin-1]=0.5; printf(" %i :%i |%i| %4.3f(%4.3f) |%i| %4.3f(%4.3f) |%4.3f(%4.3f,+%4.3f-%4.3f)| %4.3f(%4.3f) |%4.3f(%4.3f)| %4.3f(+%4.3f-%4.3f) |%4.3f(%4.3f)",ibin,Nobserved, EBobs,pEB,pEB_Rel_err,ECobs,pEC,pEC_Rel_err, ZgR,ZgRuncorel_Rel_Err,ZgRcorel_Rel_Errup,ZgRcorel_Rel_Errlow,f,f_Rel_err,totalPurity,totalPurity_Rel_Err,YieldTotal,YieldTotal_Rel_ErrUp,YieldTotal_Rel_ErrLow,ZinvMCYield,ZinvMCYield_Rel_Err); //printf("%4.3f",ZinvMCYield); //printf("bin %i :%i | %4.3f(%4.3f) | %4.3f(%4.3f) | %4.2f(%4.3f) ",ibin,Nobserved,ZgR,ZgRerr,totalPurity,totalPurityErr,YieldTotal,YieldTotalErr); //printf("bin %i :%i | %4.3f(%4.3f,+%4.3f-%4.3f) | %4.3f(%4.3f) | %4.2f(+%4.3f-%4.3f) ",ibin,Nobserved,ZgR,ZgRuncorel_Rel_Err,ZgRcorel_Rel_Errup,ZgRcorel_Rel_Errlow,totalPurity,totalPurity_Rel_Err,YieldTotal,YieldTotal_Rel_ErrUp,YieldTotal_Rel_ErrLow); cout<<endl; double Percent=(int)round(100*(YieldTotalErr/YieldTotal)); double maxErrorYield=max(YieldErrWithStatUp,YieldErrWithStatLow); ZinvEstimate->SetBinContent(ibin,YieldTotal); ZinvEstimate->SetBinError(ibin,maxErrorYield); /////////////////endcap ends }//loop over bin error calculation ////////////////////////Pred vs Estimated TPaveText *tpa = new TPaveText(0.5056522,0.6247818,0.829097,0.8970332,"brNDC"); tpa->SetBorderSize(0); tpa->SetFillStyle(0); tpa->SetTextAlign(11); tpa->SetTextFont(42); tpa->SetTextSize(0.04); tpa->AddText("HT >500"); tpa->AddText("N_{jets} >=4"); tpa->AddText("MHT>200"); tpa->AddText("Btags=0"); tpa->AddText("#Delta #Phi_{1,2,3,4}>(0.5,0.5,0.3,0.3)"); TPaveText *pCMS = new TPaveText(0.132107,0.9308003,0.8327759,0.9923583,"brNDC"); pCMS->SetBorderSize(0); pCMS->SetFillStyle(0); pCMS->SetTextAlign(11); pCMS->SetTextFont(42); pCMS->SetTextSize(0.04); pCMS->AddText("CMS #it{Preliminary} 1.3 fb^{-1} #sqrt{s}= 13 TeV"); TLegend *legP = new TLegend(0.2173913,0.2478185,0.5167224,0.4363002,NULL,"brNDC"); legP->SetBorderSize(0); legP->SetTextFont(62); legP->SetTextSize(0.03); legP->SetLineColor(1); legP->SetLineStyle(1); legP->SetLineWidth(3); legP->SetFillColor(0); legP->SetFillStyle(1001); cout<<"Est: "<<ZinvEstimate->Integral()<<endl; cout<<"Pred: "<<h_NZinv18binC->Integral()<<endl; //////////////////////////////////ZGammaRatio c_ZgRwSF = new TCanvas("c_ZgRwSF","c_ZgRwSF"); c_ZgRwSF->cd(); gr_ZgRwSFsys = new TGraphAsymmErrors(NumBins,binNumber,ZgRwSF,XErrLow,XErrUp,ZgRwSF_sys_ErrLow,ZgRwSF_sys_ErrUp); gr_ZgRwSFsys->SetTitle("ZgammaRatio"); gr_ZgRwSFsys->SetMarkerColor(4); gr_ZgRwSFsys->SetLineColor(4); gr_ZgRwSFsys->SetMarkerStyle(21); gr_ZgRwSFstat = new TGraphAsymmErrors(NumBins,binNumber,ZgRwSF,XErrLow,XErrUp,ZgRwSF_stat_Err,ZgRwSF_stat_Err); gr_ZgRwSFstat->SetTitle("ZgammaRatio"); gr_ZgRwSFstat->SetMarkerColor(2); gr_ZgRwSFstat->SetLineColor(2); gr_ZgRwSFstat->SetMarkerStyle(21); TLegend *legPZgR = new TLegend(0.2173913,0.7478185,0.5167224,0.8563002,NULL,"brNDC"); legPZgR->SetBorderSize(0); legPZgR->SetTextFont(62); legPZgR->SetTextSize(0.03); legPZgR->SetLineColor(1); legPZgR->SetLineStyle(1); legPZgR->SetLineWidth(3); legPZgR->SetFillColor(0); legPZgR->SetFillStyle(1001); legPZgR->AddEntry(gr_ZgRwSFsys,"Sys Error","l"); legPZgR->AddEntry(gr_ZgRwSFstat,"Stat Error","l"); TMultiGraph *mgZgR=new TMultiGraph(); mgZgR->SetTitle(" ;ith Bin ; Z/#gamma Ratio "); mgZgR->Add(gr_ZgRwSFstat); mgZgR->Add(gr_ZgRwSFsys); mgZgR->Draw("AP"); tpa->Draw(); pCMS->Draw(); legPZgR->Draw(); c_ZgRwSF->SaveAs("ZGammaRatioWSF.png"); c_ZgRwSF->SaveAs("ZGammaRatioWSF.pdf"); c_ZgRwSF->SaveAs("ZGammaRatioWSF.gif"); ///////////////////////////////ZGammaRatio cPredVsEstimated = new TCanvas("estvspred","estvspred"); TPad *pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0); pad1->SetBottomMargin(0); // Upperand lower plot are joined pad1->Draw(); // Draw the upper pad: pad1 gPad->Update(); pad1->cd(); // pad1 becomes the current pad gPad->DrawFrame(0.5, 0.01, 18.5, 2000, "PredVsEst;ith Bin;Events"); gPad->SetLogy(); gr_estimated = new TGraphAsymmErrors(NumBins,binNumber,YieldEstimated,XErrLow,XErrUp,YieldErrLow_Estimated,YieldErrUp_Estimated); gr_estimated->SetTitle("Estimated"); gr_estimated->SetMarkerColor(4); gr_estimated->SetLineColor(4); gr_estimated->SetMarkerStyle(21); gr_mcPred = new TGraphAsymmErrors(NumBins,binNumber,YieldPredMC,XErrLow,XErrUp,YieldErrLow_PredMC,YieldErrUp_PredMC); gr_mcPred->SetTitle("MC predicted"); gr_mcPred->SetMarkerColor(2); gr_mcPred->SetLineColor(2); gr_mcPred->SetMarkerStyle(8); legP->AddEntry(gr_mcPred,"Zinv MC Pred ","P"); legP->AddEntry(gr_estimated,"Estimated(from #gamma +Jets)","P"); char TMgname1[100]; TMultiGraph *TMg_1D[2]; for(int k0=0;k0<2;k0++){ sprintf(TMgname1,"TMg_1D%i",k0); TMg_1D[k0]=new TMultiGraph(); } for(int j0=0;j0<2;j0++){ TMg_1D[j0]->SetMinimum(0.01); TMg_1D[j0]->SetMaximum(2000); } TMg_1D[0]->SetTitle(" ;ith Bin ; Events "); TMg_1D[0]->Add(gr_mcPred); TMg_1D[0]->Add(gr_estimated); TMg_1D[0]->Draw("AP"); TMg_1D[0]->GetXaxis()->SetLimits(0.5,18.5); tpa->Draw(); pCMS->Draw(); legP->Draw(); TGaxis *axis = new TGaxis( -5, 20, -5, 220, 20,220,510,""); axis->SetLabelFont(43); // Absolute font size in pixel (precision 3) axis->SetLabelSize(15); axis->Draw(); cPredVsEstimated->cd(); TPad *pad2 = new TPad("pad2", "pad2", 0, 0.05, 1, 0.3); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.2); pad2->SetGridy(); // vertical grid pad2->Draw(); pad2->cd(); // pad2 becomes the current pad TH1F *h3 = (TH1F*)h_NZinv18binC->Clone("h3"); h3->SetLineColor(kBlack); h3->SetMinimum(-1); // Define Y .. h3->SetMaximum(3); // .. range h3->Sumw2(); h3->SetStats(0); // No statistics on lower plot h3->Divide(ZinvEstimate); h3->SetMarkerStyle(21); h3->SetMarkerColor(1); h3->Draw("ep"); // Draw the r h3->GetXaxis()->SetTitle("ith Bin"); // Remove the ratio title // Y axis ratio plot settings h3->GetYaxis()->SetTitle("Pred/Est"); h3->GetYaxis()->SetNdivisions(505); h3->GetYaxis()->SetTitleSize(20); h3->GetYaxis()->SetTitleFont(43); h3->GetYaxis()->SetTitleOffset(1.55); h3->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3) h3->GetYaxis()->SetLabelSize(15); // X axis ratio plot settings h3->GetXaxis()->SetTitleSize(20); h3->GetXaxis()->SetTitleFont(43); h3->GetXaxis()->SetTitleOffset(3.); h3->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3) h3->GetXaxis()->SetLabelSize(15); cPredVsEstimated->SaveAs("PredVsEstimated.png"); cPredVsEstimated->SaveAs("PredVsEstimated.gif"); cPredVsEstimated->SaveAs("ZPredVsEstimated.pdf"); /////////////////////////////Fill the empty bins with simulated data TCanvas *c[20]; int a; double promptfrac=hSieta_GJetsEB->Integral()/(hSieta_GJetsEB->Integral()+hSieta_QCDEB->Integral()); cout<<"prompt fraction: "<<promptfrac<<endl; plot.plotHist(hHT_Data,hHT_GJets,hHT_QCD,c[0],"","Data","MC","HT"); plot.plotHist(hMHT_Data,hMHT_GJets,hMHT_QCD,c[1],"","Data","MC","MHT"); plot.plotHist(hNJets_Data,hNJets_GJets,hNJets_QCD,c[2],"","Data","MC","Njets"); plot.plotHist(hSieta_DataEB,hSieta_GJetsEB,hSieta_QCDEB,c[3],"EB","Data","MC","SigmaIetaIeta_EB"); plot.plotHist(hSieta_DataEBLow,hSieta_GJetsEBLow,hSieta_QCDEBLow,c[4],"Low-MHT-EB","Data","MC","SigmaIetaIeta_EB"); plot.plotHist(hSieta_DataEBMed,hSieta_GJetsEBMed,hSieta_QCDEBMed,c[5],"Med-MHT-EB","Data","MC","SigmaIetaIeta_EB"); plot.plotHist(hSieta_DataEBHigh,hSieta_GJetsEBHigh,hSieta_QCDEBHigh,c[6],"High-MHT-EB","Data","MC","SigmaIetaIeta_EB"); plot.plotHist(hSieta_DataEC,hSieta_GJetsEC,hSieta_QCDEC,c[7],"EE","Data","MC","SigmaIetaIeta_EE"); plot.plotHist(hSieta_DataECLow,hSieta_GJetsECLow,hSieta_QCDECLow,c[8],"Low-MHT-EE","Data","MC","SigmaIetaIeta_EE"); plot.plotHist(hSieta_DataECMed,hSieta_GJetsECMed,hSieta_QCDECMed,c[9],"Med-MHT-EE","Data","MC","SigmaIetaIeta_EE"); plot.plotHist(hSieta_DataECHigh,hSieta_GJetsECHigh,hSieta_QCDECHigh,c[10],"High-MHT-EE","Data","MC","SigmaIetaIeta_EE"); plot.plotHist(hPhPt_DataEB,hPhPt_GJetsEB,hPhPt_QCDEB,c[11],"EB","Data","MC","PhotonPt_EB"); plot.plotHist(hPhPt_DataEC,hPhPt_GJetsEC,hPhPt_QCDEC,c[12],"EE","Data","MC","PhotonPt_EE"); plot.plotHist(h_Ndata18binEB,h_NGJets18binEB,h_NQCD18binEB,c[13],"EB","Data","MC","ith-Bin-EB"); plot.plotHist(h_Ndata18binEC,h_NGJets18binEC,h_NQCD18binEC,c[14],"EE","Data","MC","ith-Bin-EE"); }//main programme
void drawSingleLimitPlot( const ZGConfig& cfg, const std::string& limitsFile, float eff, const std::string& cat, const std::string& width, bool onlyExpected ) { std::string axisName; if( cat=="fit_v0") axisName = "95\% CL UL on #sigma #times BR(Q#rightarrowq#gamma) [fb]"; else if (cat=="fit_em") axisName = "95\% CL UL on #sigma #times BR(Q#rightarrowqZ) [fb]"; else { std::cout << "Unknown category " << cat << " !!! Exiting!" << std::endl; exit(1); } TGraph* gr_obs = new TGraph(0); TGraph* gr_exp = new TGraph(0); TGraphAsymmErrors* gr_exp_1sigma = new TGraphAsymmErrors(0); TGraphAsymmErrors* gr_exp_2sigma = new TGraphAsymmErrors(0); std::ifstream ifs(limitsFile.c_str()); std::cout << "-> Opened file: " << limitsFile << std::endl; int iPointExp = 0; int iPointObs = 0; float lastMass = -1; float lastObs = -1; while( ifs.good() ) { float m, obs, exp, exp_m1s, exp_m2s, exp_p1s, exp_p2s; std::string s_m, s_obs, s_exp, s_exp_m1s, s_exp_m2s, s_exp_p1s, s_exp_p2s; ifs >> s_m >> m >> s_obs >> obs >> s_exp >> exp >> s_exp_m1s >> exp_m1s >> s_exp_m2s >> exp_m2s >> s_exp_p1s >> exp_p1s >> s_exp_p2s >> exp_p2s; TString m_tstr(s_m); if( m_tstr.BeginsWith("#") ) continue; if( m==lastMass ) continue; float conversion = eff*cfg.lumi(); obs /=conversion; exp /=conversion; exp_m1s/=conversion; exp_m2s/=conversion; exp_p1s/=conversion; exp_p2s/=conversion; std::cout << "m: " << m << " obs: " << obs << " exp: " << exp << " exp_m1s: " << exp_m1s << " exp_m2s: " << exp_m2s << " exp_p1s: " << exp_p1s << " exp_p2s: " << exp_p2s << std::endl; bool okForObs = true; if( obs*conversion>0.1 && okForObs ) { gr_obs ->SetPoint( iPointObs, m, obs ); iPointObs++; } bool okForExp = true; if( okForExp ) { gr_exp ->SetPoint( iPointExp, m, exp ); gr_exp_1sigma->SetPoint( iPointExp, m, exp ); gr_exp_2sigma->SetPoint( iPointExp, m, exp ); gr_exp_1sigma->SetPointError( iPointExp, 0., 0., exp-exp_m1s, exp_p1s-exp ); gr_exp_2sigma->SetPointError( iPointExp, 0., 0., exp-exp_m2s, exp_p2s-exp ); iPointExp++; } lastMass = m; lastObs = obs; } gr_obs->SetLineWidth(2); gr_exp->SetLineWidth(2); gr_exp->SetLineStyle(2); gr_exp_1sigma->SetLineWidth(0); gr_exp_1sigma->SetFillColor(8); gr_exp_2sigma->SetLineWidth(0); gr_exp_2sigma->SetFillColor(219); TCanvas* c1 = new TCanvas( "c1", "", 600, 600 ); c1->cd(); float yMax = (cat=="fit_v0") ? 100. : 200.; TH2D* h2_axes = new TH2D("axes", "", 10, 400., 1000., 10, 0., yMax ); h2_axes->SetYTitle( axisName.c_str() ); //h2_axes->SetYTitle( "95\% CL UL on #sigma #times BR(A#rightarrowZ#gamma#rightarrowl^{+}l^{-}#gamma) [fb]"); h2_axes->SetXTitle( "Resonance Mass [GeV]"); h2_axes->Draw(); gr_exp_2sigma->Draw("E3 same"); gr_exp_1sigma->Draw("E3 same"); gr_exp ->Draw("L same"); if( !onlyExpected ) gr_obs ->Draw("L same"); gr_exp_1sigma->SetLineWidth(2); gr_exp_1sigma->SetLineStyle(2); gr_exp_2sigma->SetLineWidth(2); gr_exp_2sigma->SetLineStyle(2); TLegend* legend; std::string title = ""; //if( width=="0p014" ) title = "W = 0.014%"; //if( width=="5p6" ) title = "W = 5.6%"; if( onlyExpected ) legend = new TLegend( 0.55, 0.65, 0.9, 0.9 ); else legend = new TLegend( 0.55, 0.6 , 0.9, 0.9 ); legend->SetFillColor(0); legend->SetTextSize(0.038); legend->SetTextFont(42); if( title!= "" ) legend->SetHeader(title.c_str()); //legend->AddEntry( gr_exp, "Expected", "L" ); if( !onlyExpected ) legend->AddEntry( gr_obs, "Observed", "L" ); legend->AddEntry( gr_exp_1sigma, "Expected #pm 1#sigma", "LF" ); legend->AddEntry( gr_exp_2sigma, "Expected #pm 2#sigma", "LF" ); legend->Draw("same"); if( onlyExpected ) ZGDrawTools::addLabels( c1, cfg.lumi(), "CMS Simulation"); else ZGDrawTools::addLabels( c1, cfg.lumi(), "CMS Preliminary"); gPad->RedrawAxis(); if( onlyExpected ) { c1->SaveAs( Form("%s/limitExp_w%s_%s.eps", cfg.getEventYieldDir().c_str(), width.c_str(), cat.c_str()) ); c1->SaveAs( Form("%s/limitExp_w%s_%s.pdf", cfg.getEventYieldDir().c_str(), width.c_str(), cat.c_str()) ); } else { c1->SaveAs( Form("%s/limit_w%s_%s.eps", cfg.getEventYieldDir().c_str(), width.c_str(), cat.c_str()) ); c1->SaveAs( Form("%s/limit_w%s_%s.pdf", cfg.getEventYieldDir().c_str(), width.c_str(), cat.c_str()) ); } c1->Clear(); TH2D* h2_axes_long = new TH2D("axes_long", "", 10, 350., 2000., 10, 0., yMax ); h2_axes_long->SetYTitle( axisName.c_str() ); h2_axes_long->SetXTitle( "Resonance Mass [GeV]"); h2_axes_long->Draw(); gr_exp_2sigma->Draw("E3 same"); gr_exp_1sigma->Draw("E3 same"); gr_exp ->Draw("L same"); if( !onlyExpected ) gr_obs ->Draw("L same"); legend->Draw("same"); if( onlyExpected ) ZGDrawTools::addLabels( c1, cfg.lumi(), "CMS Simulation"); else ZGDrawTools::addLabels( c1, cfg.lumi(), "CMS Preliminary"); gPad->RedrawAxis(); if( onlyExpected ) { c1->SaveAs( Form("%s/limitExp_w%s_%s_long.eps", cfg.getEventYieldDir().c_str(), width.c_str(), cat.c_str()) ); c1->SaveAs( Form("%s/limitExp_w%s_%s_long.pdf", cfg.getEventYieldDir().c_str(), width.c_str(), cat.c_str()) ); } else { c1->SaveAs( Form("%s/limit_w%s_%s_long.eps", cfg.getEventYieldDir().c_str(), width.c_str(), cat.c_str()) ); c1->SaveAs( Form("%s/limit_w%s_%s_long.pdf", cfg.getEventYieldDir().c_str(), width.c_str(), cat.c_str()) ); } delete c1; delete h2_axes; delete h2_axes_long; }
void phimetphimu2b3() { //=========Macro generated from canvas: b3/phimetphimu2b3/b3/phimetphimu2b3 //========= (Tue Nov 24 14:24:06 2015) by ROOT version6.02/05 TCanvas *b3/phimetphimu2b3 = new TCanvas("b3/phimetphimu2b3", "b3/phimetphimu2b3",380,402,700,700); b3/phimetphimu2b3->Range(0,0,1,1); b3/phimetphimu2b3->SetFillColor(0); b3/phimetphimu2b3->SetBorderMode(0); b3/phimetphimu2b3->SetBorderSize(2); b3/phimetphimu2b3->SetLogy(); b3/phimetphimu2b3->SetFrameBorderMode(0); b3/phimetphimu2b3->SetFrameBorderMode(0); THStack *b3/phimetphimu2b3 = new THStack(); b3/phimetphimu2b3->SetName("b3/phimetphimu2b3"); b3/phimetphimu2b3->SetTitle("b3/phimetphimu2b3"); TH1F *b3/phimetphimu2b3_stack_20 = new TH1F("b3/phimetphimu2b3_stack_20","b3/phimetphimu2b3",20,-3.141593,3.141593); b3/phimetphimu2b3_stack_20->SetMinimum(-0); b3/phimetphimu2b3_stack_20->SetMaximum(-nan); b3/phimetphimu2b3_stack_20->SetDirectory(0); b3/phimetphimu2b3_stack_20->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); b3/phimetphimu2b3_stack_20->SetLineColor(ci); b3/phimetphimu2b3_stack_20->GetXaxis()->SetTitle("b3/phimetphimu2b3"); b3/phimetphimu2b3_stack_20->GetXaxis()->SetLabelFont(42); b3/phimetphimu2b3_stack_20->GetXaxis()->SetLabelSize(0.035); b3/phimetphimu2b3_stack_20->GetXaxis()->SetTitleSize(0.035); b3/phimetphimu2b3_stack_20->GetXaxis()->SetTitleFont(42); b3/phimetphimu2b3_stack_20->GetYaxis()->SetTitle("Events/pb"); b3/phimetphimu2b3_stack_20->GetYaxis()->SetLabelFont(42); b3/phimetphimu2b3_stack_20->GetYaxis()->SetLabelSize(0.035); b3/phimetphimu2b3_stack_20->GetYaxis()->SetTitleSize(0.035); b3/phimetphimu2b3_stack_20->GetYaxis()->SetTitleFont(42); b3/phimetphimu2b3_stack_20->GetZaxis()->SetLabelFont(42); b3/phimetphimu2b3_stack_20->GetZaxis()->SetLabelSize(0.035); b3/phimetphimu2b3_stack_20->GetZaxis()->SetTitleSize(0.035); b3/phimetphimu2b3_stack_20->GetZaxis()->SetTitleFont(42); b3/phimetphimu2b3->SetHistogram(b3/phimetphimu2b3_stack_20); TH1D *phimetphimu2b396 = new TH1D("phimetphimu2b396"," #Delta_{#phi}[#mu2,MET]",20,-3.141593,3.141593); ci = TColor::GetColor("#00cc00"); phimetphimu2b396->SetFillColor(ci); ci = TColor::GetColor("#00cc00"); phimetphimu2b396->SetLineColor(ci); ci = TColor::GetColor("#00cc00"); phimetphimu2b396->SetMarkerColor(ci); phimetphimu2b396->SetMarkerStyle(22); phimetphimu2b396->GetXaxis()->SetTitle("phimetphimu2b3"); phimetphimu2b396->GetXaxis()->SetLabelFont(42); phimetphimu2b396->GetXaxis()->SetLabelSize(0.035); phimetphimu2b396->GetXaxis()->SetTitleSize(0.035); phimetphimu2b396->GetXaxis()->SetTitleFont(42); phimetphimu2b396->GetYaxis()->SetTitle("Events/pb"); phimetphimu2b396->GetYaxis()->SetLabelFont(42); phimetphimu2b396->GetYaxis()->SetLabelSize(0.035); phimetphimu2b396->GetYaxis()->SetTitleSize(0.035); phimetphimu2b396->GetYaxis()->SetTitleFont(42); phimetphimu2b396->GetZaxis()->SetLabelFont(42); phimetphimu2b396->GetZaxis()->SetLabelSize(0.035); phimetphimu2b396->GetZaxis()->SetTitleSize(0.035); phimetphimu2b396->GetZaxis()->SetTitleFont(42); b3/phimetphimu2b3->Add(phimetphimu2b3,""); TH1D *phimetphimu2b397 = new TH1D("phimetphimu2b397"," #Delta_{#phi}[#mu2,MET]",20,-3.141593,3.141593); ci = TColor::GetColor("#00ffff"); phimetphimu2b397->SetFillColor(ci); ci = TColor::GetColor("#00ffff"); phimetphimu2b397->SetLineColor(ci); ci = TColor::GetColor("#00ffff"); phimetphimu2b397->SetMarkerColor(ci); phimetphimu2b397->SetMarkerStyle(20); phimetphimu2b397->GetXaxis()->SetTitle("phimetphimu2b3"); phimetphimu2b397->GetXaxis()->SetLabelFont(42); phimetphimu2b397->GetXaxis()->SetLabelSize(0.035); phimetphimu2b397->GetXaxis()->SetTitleSize(0.035); phimetphimu2b397->GetXaxis()->SetTitleFont(42); phimetphimu2b397->GetYaxis()->SetTitle("Events/pb"); phimetphimu2b397->GetYaxis()->SetLabelFont(42); phimetphimu2b397->GetYaxis()->SetLabelSize(0.035); phimetphimu2b397->GetYaxis()->SetTitleSize(0.035); phimetphimu2b397->GetYaxis()->SetTitleFont(42); phimetphimu2b397->GetZaxis()->SetLabelFont(42); phimetphimu2b397->GetZaxis()->SetLabelSize(0.035); phimetphimu2b397->GetZaxis()->SetTitleSize(0.035); phimetphimu2b397->GetZaxis()->SetTitleFont(42); b3/phimetphimu2b3->Add(phimetphimu2b3,""); TH1D *phimetphimu2b398 = new TH1D("phimetphimu2b398"," #Delta_{#phi}[#mu2,MET]",20,-3.141593,3.141593); ci = TColor::GetColor("#ffcc00"); phimetphimu2b398->SetFillColor(ci); ci = TColor::GetColor("#ffcc00"); phimetphimu2b398->SetLineColor(ci); ci = TColor::GetColor("#ffcc00"); phimetphimu2b398->SetMarkerColor(ci); phimetphimu2b398->SetMarkerStyle(21); phimetphimu2b398->GetXaxis()->SetTitle("phimetphimu2b3"); phimetphimu2b398->GetXaxis()->SetLabelFont(42); phimetphimu2b398->GetXaxis()->SetLabelSize(0.035); phimetphimu2b398->GetXaxis()->SetTitleSize(0.035); phimetphimu2b398->GetXaxis()->SetTitleFont(42); phimetphimu2b398->GetYaxis()->SetTitle("Events/pb"); phimetphimu2b398->GetYaxis()->SetLabelFont(42); phimetphimu2b398->GetYaxis()->SetLabelSize(0.035); phimetphimu2b398->GetYaxis()->SetTitleSize(0.035); phimetphimu2b398->GetYaxis()->SetTitleFont(42); phimetphimu2b398->GetZaxis()->SetLabelFont(42); phimetphimu2b398->GetZaxis()->SetLabelSize(0.035); phimetphimu2b398->GetZaxis()->SetTitleSize(0.035); phimetphimu2b398->GetZaxis()->SetTitleFont(42); b3/phimetphimu2b3->Add(phimetphimu2b3,""); TH1D *phimetphimu2b399 = new TH1D("phimetphimu2b399"," #Delta_{#phi}[#mu2,MET]",20,-3.141593,3.141593); ci = TColor::GetColor("#ff0000"); phimetphimu2b399->SetFillColor(ci); ci = TColor::GetColor("#ff0000"); phimetphimu2b399->SetLineColor(ci); ci = TColor::GetColor("#ff0000"); phimetphimu2b399->SetMarkerColor(ci); phimetphimu2b399->SetMarkerStyle(20); phimetphimu2b399->GetXaxis()->SetTitle("phimetphimu2b3"); phimetphimu2b399->GetXaxis()->SetLabelFont(42); phimetphimu2b399->GetXaxis()->SetLabelSize(0.035); phimetphimu2b399->GetXaxis()->SetTitleSize(0.035); phimetphimu2b399->GetXaxis()->SetTitleFont(42); phimetphimu2b399->GetYaxis()->SetTitle("Events/pb"); phimetphimu2b399->GetYaxis()->SetLabelFont(42); phimetphimu2b399->GetYaxis()->SetLabelSize(0.035); phimetphimu2b399->GetYaxis()->SetTitleSize(0.035); phimetphimu2b399->GetYaxis()->SetTitleFont(42); phimetphimu2b399->GetZaxis()->SetLabelFont(42); phimetphimu2b399->GetZaxis()->SetLabelSize(0.035); phimetphimu2b399->GetZaxis()->SetTitleSize(0.035); phimetphimu2b399->GetZaxis()->SetTitleFont(42); b3/phimetphimu2b3->Add(phimetphimu2b3,""); TH1D *phimetphimu2b3100 = new TH1D("phimetphimu2b3100"," #Delta_{#phi}[#mu2,MET]",20,-3.141593,3.141593); ci = TColor::GetColor("#0000ff"); phimetphimu2b3100->SetFillColor(ci); ci = TColor::GetColor("#0000ff"); phimetphimu2b3100->SetLineColor(ci); ci = TColor::GetColor("#0000ff"); phimetphimu2b3100->SetMarkerColor(ci); phimetphimu2b3100->SetMarkerStyle(21); phimetphimu2b3100->GetXaxis()->SetTitle("phimetphimu2b3"); phimetphimu2b3100->GetXaxis()->SetLabelFont(42); phimetphimu2b3100->GetXaxis()->SetLabelSize(0.035); phimetphimu2b3100->GetXaxis()->SetTitleSize(0.035); phimetphimu2b3100->GetXaxis()->SetTitleFont(42); phimetphimu2b3100->GetYaxis()->SetTitle("Events/pb"); phimetphimu2b3100->GetYaxis()->SetLabelFont(42); phimetphimu2b3100->GetYaxis()->SetLabelSize(0.035); phimetphimu2b3100->GetYaxis()->SetTitleSize(0.035); phimetphimu2b3100->GetYaxis()->SetTitleFont(42); phimetphimu2b3100->GetZaxis()->SetLabelFont(42); phimetphimu2b3100->GetZaxis()->SetLabelSize(0.035); phimetphimu2b3100->GetZaxis()->SetTitleSize(0.035); phimetphimu2b3100->GetZaxis()->SetTitleFont(42); b3/phimetphimu2b3->Add(phimetphimu2b3,""); b3/phimetphimu2b3->Draw("nostack"); TLegend *leg = new TLegend(0.54023,0.639881,0.938218,0.924107,NULL,"brNDC"); leg->SetBorderSize(1); leg->SetTextSize(0.034965); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("phimetphimu2b3","b3/phimetphimu2b3_QCD_b3/","lp"); ci = TColor::GetColor("#00cc00"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#00cc00"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(22); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("phimetphimu2b3","b3/phimetphimu2b3_WJetsToLNu_b3/","lp"); ci = TColor::GetColor("#00ffff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#00ffff"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(20); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("phimetphimu2b3","b3/phimetphimu2b3_ZJetsToNuNu_b3/","lp"); ci = TColor::GetColor("#ffcc00"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#ffcc00"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("phimetphimu2b3","b3/phimetphimu2b3_signal_b3/","lp"); ci = TColor::GetColor("#ff0000"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#ff0000"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(20); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("phimetphimu2b3","b3/phimetphimu2b3_ttbar_b3/","lp"); ci = TColor::GetColor("#0000ff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#0000ff"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); b3/phimetphimu2b3->Modified(); b3/phimetphimu2b3->cd(); b3/phimetphimu2b3->SetSelected(b3/phimetphimu2b3); }
void plot_Asymptotic_ForCombination(TString outputdir, TString channel) { bool obs=false; TString outfilename = outputdir + ".root"; TFile *fout = new TFile(outfilename,"RECREATE"); bool useNewStyle = true; if (useNewStyle) setFPStyle(); // gROOT->LoadMacro("CMS_lumi.C"); TFile *fFREQ[nXm]; TTree *t[nXm]; int Xmass[nXm]={600,800,1000,1200,1700,2000,2500}; vector<double> v_mh, v_median, v_68l, v_68h, v_95l, v_95h, v_obs; for(int n=0;n<nXm;n++) { char limitfilename[100]; if (Xmass[n] == 0) continue; sprintf(limitfilename,"combine_" + channel + "/higgsCombineTest.Asymptotic.mH%d.4.root",Xmass[n]); TString limitfile = /*outputdir+"/"+*/limitfilename; fFREQ[n] = new TFile(limitfile, "READ"); cout<<" Read limit file: "<<limitfile<<endl; t[n] = (TTree*)fFREQ[n]->Get("limit"); double mh, limit; float quant; t[n]->SetBranchAddress("mh", &mh); t[n]->SetBranchAddress("limit", &limit); t[n]->SetBranchAddress("quantileExpected", &quant); //int iMH = 0; //while (iMH < n) { for (int i = 0; i < t[n]->GetEntries(); i++) { t[n]->GetEntry(i); cout<<" quant : "<<quant<<" limit : " <<limit<<endl; /// Map: mh --> observed, 95low, 68low, expected, 68hi, 95hi, xsec if (quant > -1.01 && quant < -0.99) { v_obs.push_back(limit); } else if (quant > 0.02 && quant < 0.03) { v_95l.push_back(limit); } else if (quant > 0.15 && quant < 0.17) { v_68l.push_back(limit); } else if (quant > 0.49 && quant < 0.51) { v_median.push_back(limit); v_mh.push_back(mh); } else if (quant > 0.83 && quant < 0.85) { v_68h.push_back(limit); } else if (quant > 0.965 && quant < 0.98) { v_95h.push_back(limit); } else { cout << "Error! Quantile = " << quant << endl; } } //iMH++; // }//end while loop }//file loop std::cout<<" extraction done "<<std::endl; //string xsect_file_th = dirXSect + "xsec_MonoHTheory_ForComparison.txt"; //string xsect_file_th = dirXSect + "xsec_MonoHTheory_ForBBResolved.txt"; //string xsect_file_th = dirXSect + "xsec_MonoHTheory_ForZZ.txt"; //string xsect_file_th = dirXSect + "xsec_MonoHTheory_comb.txt"; string xsect_file_th = dirXSect + "xsec_MonoHTheory.txt"; std::cout<<" debug_1"<<std::endl; ifstream xsect_file(xsect_file_th.c_str(), ios::in); if (! xsect_file.is_open()) { cout << "Failed to open file with xsections: " << xsect_file_th << endl; } std::cout<<" debug_2<"<<std::endl; float mH, CS; vector<float> v_mhxs, v_xs, v_toterrh, v_toterrl; while (xsect_file.good()) { xsect_file >> mH >> CS; std::cout<<" debug_3"<<std::endl; v_mhxs.push_back(mH); std::cout<<" debug_4"<<std::endl; v_xs.push_back(CS);//*BRZZ2l2q (multyply by BRZZ2l2q only if exp rates in cards are for process X->ZZ->2l2q !) std::cout<<" mH = "<<mH <<" CS = "<<CS <<std::endl; //unavailable theory errors for graviton float tot_err_p = 0.0; float tot_err_m = 0.0; v_toterrh.push_back(1.0 + (tot_err_p)); v_toterrl.push_back(1.0 - (tot_err_m)); } cout << "Size of theory xsects vector" << v_mhxs.size() << endl; xsect_file.close(); /////////////////////////// // END THEORY INPUT PART // /////////////////////////// /// Here we multiply the limits in terms of signal strength by the cross-section. /// There are also some hooks to exclude sick mass points. double mass[nXm], obs_lim_cls[nXm]; double medianD[nXm]; double up68err[nXm], down68err[nXm], up95err[nXm], down95err[nXm]; double xs[nXm], xs_uperr[nXm], xs_downerr[nXm]; double xs10[nXm], xs10_uperr[nXm], xs10_downerr[nXm]; int nMassEff = 0; for (int im = 0; im < nXm; im++) { std::cout<<" im = "<<im<<" "<<v_xs.at(im)<<std::endl; double fl_xs = double(v_xs.at(im)); //*1000.0 std::cout<<" debug 0 "<<std::endl; double fl_xs10 = 0;//double(v_xs10.at(ind)); //*1000.0 // fl_xs = (fl_xs); //fl_xs10 = (fl_xs10); std::cout<<" Xmass = "<<Xmass[im]<<std::endl; mass[nMassEff] = Xmass[im]; /// This is the part where we multiply the limits in terms of signal strength /// by the cross-section, in order to have limits in picobarns. //std::cerr << mass[nMassEff] << ":" << v_obs.at(im) << std::endl; // std::cout<<" v_obs.at = "<<v_obs.at(im)<<std::endl; std::cout<<" fl_xs = "<<fl_xs<<std::endl; if(obs) obs_lim_cls[nMassEff] = v_obs.at(im) * fl_xs; std::cout<<" debug 1 "<<std::endl; medianD[nMassEff] = v_median.at(im) * fl_xs; up68err[nMassEff] = (v_68h.at(im) - v_median.at(im)) * fl_xs; down68err[nMassEff] = (v_median.at(im) - v_68l.at(im)) * fl_xs; //scale factor 100 for making the xsect visible xs[nMassEff] = fl_xs; //*100.0; xs_uperr[nMassEff] = double(v_toterrh.at(im)) * xs[nMassEff] - xs[nMassEff]; xs_downerr[nMassEff] = xs[nMassEff] - double(v_toterrl.at(im)) * xs[nMassEff]; std::cout<<" debug 2 "<<std::endl; xs10[nMassEff] = fl_xs10; //*100.0; xs10_uperr[nMassEff] = double(v_toterrh.at(im)) * xs10[nMassEff] - xs10[nMassEff]; xs10_downerr[nMassEff] = xs10[nMassEff] - double(v_toterrl.at(im)) * xs10[nMassEff]; up95err[nMassEff] = (v_95h.at(im) - v_median.at(im)) * fl_xs; down95err[nMassEff] = (v_median.at(im) - v_95l.at(im)) * fl_xs; if(obs) cout<<"fl_xs:"<<fl_xs<<" v_obs"<<v_obs.at(im)<<" obs_lim_cls: "<<obs_lim_cls[nMassEff] <<medianD[nMassEff] <<" mass: "<<mass[nMassEff]<<endl; nMassEff++; }//end loop over im (mass points) /// The TGraphs themselves. //cout<<"Working on TGraph"<<endl; TGraphAsymmErrors *grobslim_cls; if(obs){ grobslim_cls = new TGraphAsymmErrors(nMassEff, mass, obs_lim_cls); grobslim_cls->SetName("LimitObservedCLs"); } TGraphAsymmErrors *grmedian_cls = new TGraphAsymmErrors(nMassEff, mass, medianD); grmedian_cls->SetName("LimitExpectedCLs"); TGraphAsymmErrors *gr68_cls = new TGraphAsymmErrors(nMassEff, mass, medianD, 0, 0, down68err, up68err); gr68_cls->SetName("Limit68CLs"); TGraphAsymmErrors *gr95_cls = new TGraphAsymmErrors(nMassEff, mass, medianD, 0, 0, down95err, up95err); gr95_cls->SetName("Limit95CLs"); // TGraphAsymmErrors *grthSM=new TGraphAsymmErrors(nMassEff1,mass1,xs,0,0,0,0);//xs_downerr,xs_uperr); TGraph *grthSM=new TGraph(nMassEff,mass,xs);//xs_downerr,xs_uperr); grthSM->SetName("SMXSection"); // TGraphAsymmErrors *grthSM10=new TGraphAsymmErrors(nMassEff1,mass1,xs10,0,0,0,0); TGraph *grthSM10=new TGraph(nMassEff,mass,xs10); grthSM10->SetName("SMXSection_2nd"); // double fr_left = 590.0, fr_down = 1E-5, fr_right = 2000.0, fr_up = 0.5; double fr_left = 590.0, fr_down = 0.00001, fr_right = 2500.0, fr_up = 5; TCanvas *cMCMC = new TCanvas("c_lim_Asymptotic", "canvas with limits for Asymptotic CLs", 630, 600); cMCMC->cd(); cMCMC->SetGridx(1); cMCMC->SetGridy(1); // draw a frame to define the range TH1F *hr = cMCMC->DrawFrame(fr_left, fr_down, fr_right, fr_up, ""); TString VV = "ZH"; hr->SetXTitle("M_{Zp} [GeV]"); hr->SetYTitle("#sigma_{95%} [pb]"); // #rightarrow 2l2q hr->SetMinimum(0.0001); hr->SetMaximum(100.0); gr95_cls->SetFillColor(kYellow); gr95_cls->SetFillStyle(1001);//solid gr95_cls->SetLineStyle(kDashed); gr95_cls->SetLineWidth(3); gr95_cls->GetXaxis()->SetTitle("M_{V'} [GeV]"); gr95_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(V' #rightarrow " + VV + ") [pb]"); // #rightarrow 2l2q gr95_cls->GetXaxis()->SetRangeUser(fr_left, fr_right); gr95_cls->Draw("3"); // gr95_cls->SetMinimum(0.00001); //gr95_cls->SetMaximum(1000.0); //grmedian_cls->SetMinimum(0.00001); //grmedian_cls->SetMaximum(1000.0); gr68_cls->SetFillColor(kGreen); gr68_cls->SetFillStyle(1001);//solid gr68_cls->SetLineStyle(kDashed); gr68_cls->SetLineWidth(3); gr68_cls->Draw("3same"); grmedian_cls->GetXaxis()->SetTitle("M_{V'} [GeV]"); grmedian_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(V' #rightarrow " + VV + ") [pb]"); // #rightarrow 2l2q grmedian_cls->SetMarkerStyle(24);//25=hollow squre grmedian_cls->SetMarkerColor(kBlack); grmedian_cls->SetLineStyle(2); grmedian_cls->SetLineWidth(3); if(obs){ grobslim_cls->SetMarkerColor(kBlack); grobslim_cls->SetMarkerStyle(21);//24=hollow circle grobslim_cls->SetMarkerSize(1.0); grobslim_cls->SetLineStyle(1); grobslim_cls->SetLineWidth(3); } grthSM->SetLineColor(kRed); grthSM->SetLineWidth(2); grthSM->SetLineStyle(kSolid); grthSM->SetFillColor(kRed); grthSM->SetFillStyle(3344); grthSM10->SetLineColor(kRed); grthSM10->SetLineWidth(2); grthSM10->SetLineStyle(1); grthSM10->SetLineStyle(kDashed); grthSM10->SetFillColor(kRed); grthSM10->SetFillStyle(3344); grthSM->Draw("L3"); grmedian_cls->Draw("L"); // observed limit //grobslim_cls->Draw("LP"); /* TFile *fUnMPlus=new TFile("AsymptoticCLs_UnmatchedPlus_TGraph.root","READ"); TGraph *grobs_ump=(TGraph*)fUnMPlus->Get("LimitObservedCLs"); TGraph *grmedian_ump=(TGraph*)fUnMPlus->Get("LimitExpectedCLs"); grobs_ump->SetName("LimitObs_UnmatchedPlus"); grmedian_ump->SetName("LimitExp_UnmatchedPlus"); grobs_ump->SetMarkerColor(kBlue); grobs_ump->SetLineColor(kBlue); grobs_ump->SetMarkerStyle(25); grmedian_ump->SetMarkerColor(kBlue); grmedian_ump->SetLineColor(kBlue); grmedian_ump->SetMarkerStyle(25); grobs_ump->Draw("P"); grmedian_ump->Draw("L"); */ //draw grid on top of limits gStyle->SetOptStat(0); TH1D* postGrid = new TH1D("postGrid", "", 1, fr_left, fr_right); postGrid->GetYaxis()->SetRangeUser(fr_down, fr_up); postGrid->Draw("AXIGSAME"); //more graphics TLegend *leg = new TLegend(.30, .65, .85, .90); // TLegend *leg = new TLegend(.35,.71,.90,.90); leg->SetFillColor(0); leg->SetShadowColor(0); leg->SetTextFont(42); leg->SetTextSize(0.03); // leg->SetBorderMode(0); if(obs) leg->AddEntry(grobslim_cls, "Frequentist CL_{S} Observed", "LP"); leg->AddEntry(gr68_cls, "Frequentist CL_{S} Expected #pm 1#sigma", "LF"); leg->AddEntry(gr95_cls, "Frequentist CL_{S} Expected #pm 2#sigma", "LF"); leg->AddEntry(grthSM, "#sigma_{TH}", "L"); // leg->AddEntry(grthSM, "#sigma_{TH} x BR(Z' #rightarrow " + VV + "), #tilde{k}=0.50", "L"); // #rightarrow 2l2q // leg->AddEntry(grthSM10, "#sigma_{TH} x BR(Z' #rightarrow " + VV + "), #tilde{k}=0.20", "L"); // #rightarrow 2l2q leg->Draw(); TLatex * latex = new TLatex(); latex->SetNDC(); latex->SetTextSize(0.04); latex->SetTextAlign(31); latex->SetTextAlign(11); // align left latex->DrawLatex(0.18, 0.96, "CMS preliminary 2016"); latex->DrawLatex(0.60, 0.96, Form("%.1f fb^{-1} at #sqrt{s} = 13 TeV", intLumi)); // cMCMC->RedrawAxis(""); gPad->RedrawAxis(""); // hr->GetYaxis()->DrawClone(); cMCMC->Update(); TString fnam; //string outputname="shape2d"; //string outputname="shape1d"; //string outputname="counting"; gPad->SetLogy(); fnam = "MonoHCombined_12fbInv_" + outputdir + "_Asymptotic_log_" + channel + ".png"; // sprintf(fnam, "MonoHCombined_12fbInv_%s_Asymptotic_log.png", outputdir.data()); cMCMC->SaveAs(fnam); /* sprintf(fnam, "XZHllbb_%s_Asymptotic.root",outputdir.data() ); cMCMC->SaveAs(fnam); sprintf(fnam, "XZHllbb_%s_Asymptotic.eps", outputdir.data()); cMCMC->SaveAs(fnam); sprintf(fnam, "XZHllbb_%s_Asymptotic.png", outputdir.data()); cMCMC->SaveAs(fnam); sprintf(fnam, "XZHllbb_%s_Asymptotic.pdf", outputdir.data()); cMCMC->SaveAs(fnam); gPad->SetLogy(); sprintf(fnam, "XZHllbb_%s_Asymptotic_log.eps", outputdir.data()); cMCMC->SaveAs(fnam); sprintf(fnam, "XZHllbb_%s_Asymptotic_log.png", outputdir.data()); cMCMC->SaveAs(fnam); sprintf(fnam, "XZHllbb_%s_Asymptotic_log.pdf", outputdir.data()); cMCMC->SaveAs(fnam); */ cMCMC->Draw(); fout->cd(); grmedian_cls->Write(); fout->Close(); }//end main
void drawGraphs(TGraphErrors* data, TGraphErrors* mc, const std::string& method, const std::string& xTitle, const std::string& yTitle, const std::string& legendTitle, double lumi, const std::string& outputName, int dataMarkerStyle = 20, int dataMarkerColor = kBlack, int mcMarkerStyle = 29, int mcMarkerColor = kBlue) { data->SetMarkerSize(1.5); data->SetMarkerStyle(dataMarkerStyle); data->SetMarkerColor(dataMarkerColor); data->SetLineColor(dataMarkerColor); mc->SetMarkerSize(1.5); mc->SetMarkerStyle(mcMarkerStyle); mc->SetMarkerColor(mcMarkerColor); mc->SetLineColor(mcMarkerColor); // Fit TF1* data_fct = nullptr; TF1* mc_fct = nullptr; TH1D* errors_data = new TH1D("errors_data", "errors", 100, 0, 1); errors_data->SetStats(false); errors_data->SetFillColor(LIGHT_GRAY); //errors_data->SetLineColor(kRed); errors_data->SetFillStyle(1001); TH1D* errors_mc = (TH1D*) errors_data->Clone("errors_mc"); errors_mc->SetFillColor(LIGHT_BLUE); if (method == "Balancing") { data_fct = new TF1("data_fct", "[0] - x*x*[1]", 0, 1); data_fct->SetLineColor(dataMarkerColor); data_fct->SetLineWidth(1); data_fct->SetLineStyle(2); data->Fit(data_fct, "RQN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_data, 0.68); mc_fct = new TF1("mc_fct", "[0] - x*x*[1]", 0, 1); mc_fct->SetLineColor(mcMarkerColor); mc_fct->SetLineWidth(1); mc_fct->SetLineStyle(2); mc->Fit(mc_fct, "RQN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_mc, 0.68); } else { data_fct = new TF1("data_fct", "[0] + x*[1]", 0, 1); data_fct->SetLineColor(dataMarkerColor); data_fct->SetLineWidth(1); data_fct->SetLineStyle(2); data->Fit(data_fct, "RQN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_data, 0.68); mc_fct = new TF1("mc_fct", "[0] + x*[1]", 0, 1); mc_fct->SetLineColor(mcMarkerColor); mc_fct->SetLineWidth(1); mc_fct->SetLineStyle(2); mc->Fit(mc_fct, "RQN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_mc, 0.68); } data_fct->SetRange(0, 1); mc_fct->SetRange(0, 1); TMultiGraph* mg = new TMultiGraph(); mg->Add(data); mg->Add(mc); TString title = TString::Format(";%s;%s", xTitle.c_str(), yTitle.c_str()); mg->SetTitle(title); TCanvas* canvas = new TCanvas("canvas", "", 800, 800); mg->Draw("ap"); errors_data->Draw("e3 same"); errors_mc->Draw("e3 same"); data_fct->Draw("same"); mc_fct->Draw("same"); mg->Draw("ap same"); TLegend* legend = new TLegend(0.18, 0.18, 0.55, 0.35); legend->SetTextFont(42); legend->SetFillColor(kWhite); legend->SetFillStyle(0); legend->SetTextSize(0.035); legend->SetBorderSize(1); TString legendTitleWithPtCut = TString::Format("%s, p_{T}^{#gamma} #geq 170 GeV", legendTitle.c_str()); legend->SetHeader(legendTitleWithPtCut); legend->AddEntry(data, TString::Format("%s (data)", method.c_str()), "p"); legend->AddEntry(mc, TString::Format("%s (MC)", method.c_str()), "p"); legend->Draw(); TLatex tl; tl.SetNDC(); tl.SetTextSize(0.035); tl.SetTextFont(42); // Luminosity TString sLumi = TString::Format("L = %.02f fb^{-1}", lumi); tl.DrawLatex(0.18, 0.96, sLumi); // Energy tl.DrawLatex(0.80, 0.96, "#sqrt{s} = 8 TeV"); canvas->Print(outputName.c_str()); delete canvas; delete mg; delete errors_data; delete errors_mc; }
void drawCombinedGraphs(TGraphErrors* balancingData, TGraphErrors* balancingMC, TGraphErrors* mpfData, TGraphErrors* mpfMC, const std::string& xTitle, const std::string& yTitle, const std::string& legendTitle, double lumi, const std::string& outputName) { balancingData->SetMarkerSize(1.5); balancingData->SetMarkerStyle(20); balancingData->SetMarkerColor(kBlack); balancingData->SetLineColor(kBlack); mpfData->SetMarkerSize(1.5); mpfData->SetMarkerStyle(20); mpfData->SetMarkerColor(kRed); mpfData->SetLineColor(kRed); balancingMC->SetMarkerSize(1.5); balancingMC->SetMarkerStyle(29); balancingMC->SetMarkerColor(kBlue); balancingMC->SetLineColor(kBlue); mpfMC->SetMarkerSize(1.5); mpfMC->SetMarkerStyle(29); mpfMC->SetMarkerColor(46); mpfMC->SetLineColor(46); TH1D* errors_bal_data = new TH1D("errors_bal_data", "errors", 100, 0, 1); errors_bal_data->SetStats(false); errors_bal_data->SetFillColor(LIGHT_GRAY); errors_bal_data->SetFillStyle(1001); TH1D* errors_bal_mc = (TH1D*) errors_bal_data->Clone("errors_bal_mc"); errors_bal_mc->SetFillColor(LIGHT_BLUE); TH1D* errors_mpf_data = new TH1D("errors_mpf_data", "errors", 100, 0, 1); errors_mpf_data->SetStats(false); errors_mpf_data->SetFillColor(LIGHT_RED); errors_mpf_data->SetFillStyle(1001); TH1D* errors_mpf_mc = (TH1D*) errors_bal_data->Clone("errors_mpf_mc"); errors_mpf_mc->SetFillColor(LIGHT_MARRON); TF1* balancingData_fct = new TF1("balancingData_fct", "[0] - x*x*[1]", 0, 1); balancingData_fct->SetLineColor(kBlack); balancingData_fct->SetLineWidth(1); balancingData_fct->SetLineStyle(2); balancingData->Fit(balancingData_fct, "QRN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_bal_data, 0.68); TF1* balancingMC_fct = new TF1("mc_fct", "[0] - x*x*[1]", 0, 1); balancingMC_fct->SetLineColor(kBlue); balancingMC_fct->SetLineWidth(1); balancingMC_fct->SetLineStyle(2); balancingMC->Fit(balancingMC_fct, "QRN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_bal_mc, 0.68); TF1* mpfData_fct = new TF1("mpfData_fct", "[0] + x*[1]", 0, 1); mpfData_fct->SetLineColor(kRed); mpfData_fct->SetLineWidth(1); mpfData_fct->SetLineStyle(2); mpfData->Fit(mpfData_fct, "QRN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_mpf_data, 0.68); TF1* mpfMC_fct = new TF1("mc_fct", "[0] + x*[1]", 0, 1); mpfMC_fct->SetLineColor(46); mpfMC_fct->SetLineWidth(1); mpfMC_fct->SetLineStyle(2); mpfMC->Fit(mpfMC_fct, "QRN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_mpf_mc, 0.68); TString balancing_ratio_legend = TString::Format("#color[4]{#scale[1]{r_{bal} = %.03f #pm %.03f}}", balancingData_fct->GetParameter(0) / balancingMC_fct->GetParameter(0), sqrt(pow(balancingData_fct->GetParError(0), 2) + pow(balancingMC_fct->GetParError(0), 2))); TString mpf_ratio_legend = TString::Format("#color[2]{#scale[1]{r_{MPF} = %.03f #pm %.03f}}", mpfData_fct->GetParameter(0) / mpfMC_fct->GetParameter(0), sqrt(pow(mpfData_fct->GetParError(0), 2) + pow(mpfMC_fct->GetParError(0), 2))); TMultiGraph* mg = new TMultiGraph(); mg->Add(balancingData); mg->Add(balancingMC); mg->Add(mpfData); mg->Add(mpfMC); TString title = TString::Format(";%s;%s", xTitle.c_str(), yTitle.c_str()); mg->SetTitle(title); TCanvas* canvas = new TCanvas("canvas", "", 800, 800); mg->Draw("ap"); balancingData_fct->SetRange(0, 1); balancingMC_fct->SetRange(0, 1); mpfData_fct->SetRange(0, 1); mpfMC_fct->SetRange(0, 1); errors_bal_data->Draw("e3 same"); errors_bal_mc->Draw("e3 same"); errors_mpf_data->Draw("e3 same"); errors_mpf_mc->Draw("e3 same"); mg->Draw("ap same"); balancingData_fct->Draw("same"); balancingMC_fct->Draw("same"); mpfData_fct->Draw("same"); mpfMC_fct->Draw("same"); TLegend* legend = new TLegend(0.18, 0.18, 0.55, 0.45); legend->SetTextFont(42); legend->SetFillColor(kWhite); legend->SetFillStyle(0); legend->SetTextSize(0.035); legend->SetBorderSize(1); TString legendTitleWithPtCut = TString::Format("%s, p_{T}^{#gamma} #geq 170 GeV", legendTitle.c_str()); legend->SetHeader(legendTitleWithPtCut); legend->AddEntry(balancingData, "Balancing (data)", "p"); legend->AddEntry(balancingMC, "Balancing (MC)", "p"); legend->AddEntry(mpfData, "MPF (data)", "p"); legend->AddEntry(mpfMC, "MPF (MC)", "p"); legend->Draw(); TLatex tl; tl.SetNDC(); tl.SetTextSize(0.035); tl.SetTextFont(42); // Luminosity TString sLumi = TString::Format("L = %.02f fb^{-1}", lumi); tl.DrawLatex(0.18, 0.96, sLumi); // Energy tl.DrawLatex(0.80, 0.96, "#sqrt{s} = 8 TeV"); // Ratios tl.DrawLatex(0.18, 0.515, balancing_ratio_legend); tl.DrawLatex(0.18, 0.47, mpf_ratio_legend); canvas->Print((outputName + ".pdf").c_str()); delete legend; delete canvas; delete errors_bal_data; delete errors_bal_mc; delete errors_mpf_data; delete errors_mpf_mc; // Do now data / MC plots TH1D* errors_bal = new TH1D("errors_bal", "errors", 100, 0, 1); errors_bal->SetStats(false); errors_bal->SetFillColor(LIGHT_BLUE); errors_bal->SetFillStyle(1001); TH1D* errors_mpf = (TH1D*) errors_bal->Clone("errors_mpf"); errors_mpf->SetFillColor(LIGHT_RED); TGraphErrors* balancing_ratio = fitTools::get_graphRatio(balancingData, balancingMC); balancing_ratio->SetMarkerSize(1.5); balancing_ratio->SetMarkerColor(kBlue); balancing_ratio->SetLineColor(kBlue); balancing_ratio->SetMarkerStyle(20); TGraphErrors* mpf_ratio = fitTools::get_graphRatio(mpfData, mpfMC); mpf_ratio->SetMarkerSize(1.5); mpf_ratio->SetMarkerColor(kRed); mpf_ratio->SetLineColor(kRed); mpf_ratio->SetMarkerStyle(20); TF1* balancingRatio_fct = new TF1("balancingRatio_fct", "[0] + x*[1]", 0, 1); balancingRatio_fct->SetLineColor(kBlue); balancingRatio_fct->SetLineWidth(1); balancingRatio_fct->SetLineStyle(2); balancing_ratio->Fit(balancingRatio_fct, "QRN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_bal, 0.68); balancing_ratio_legend = TString::Format("#color[4]{#splitline{#scale[1.2]{r = %.03f #pm %.03f}}{#scale[0.8]{#chi^{2} / NDF: %.02f / %d}}}", balancingRatio_fct->GetParameter(0), balancingRatio_fct->GetParError(0), balancingRatio_fct->GetChisquare(), balancingRatio_fct->GetNDF()); TF1* mpfRatio_fct = new TF1("mpfRatio_fct", "[0] + x*[1]", 0, 1); mpfRatio_fct->SetLineColor(kRed); mpfRatio_fct->SetLineWidth(1); mpfRatio_fct->SetLineStyle(2); mpf_ratio->Fit(mpfRatio_fct, "QRN"); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_mpf, 0.68); mpf_ratio_legend = TString::Format("#color[2]{#splitline{#scale[1.2]{r = %.03f #pm %.03f}}{#scale[0.8]{#chi^{2} / NDF: %.02f / %d}}}", mpfRatio_fct->GetParameter(0), mpfRatio_fct->GetParError(0), mpfRatio_fct->GetChisquare(), mpfRatio_fct->GetNDF()); TMultiGraph* mg2 = new TMultiGraph(); mg2->Add(balancing_ratio); mg2->Add(mpf_ratio); title = TString::Format(";%s;Data / MC ratio", xTitle.c_str()); mg2->SetTitle(title); canvas = new TCanvas("canvas", "", 800, 800); mg2->Draw("ap"); balancingRatio_fct->SetRange(0, 1); mpfRatio_fct->SetRange(0, 1); errors_bal->Draw("e3 same"); errors_mpf->Draw("e3 same"); mg2->Draw("ap same"); balancingRatio_fct->Draw("same"); mpfRatio_fct->Draw("same"); legend = new TLegend(0.18, 0.18, 0.50, 0.35); legend->SetTextFont(42); legend->SetFillColor(kWhite); legend->SetFillStyle(0); legend->SetTextSize(0.035); legend->SetBorderSize(1); legend->SetHeader(legendTitleWithPtCut); legend->AddEntry(balancing_ratio, "Balancing", "p"); legend->AddEntry(mpf_ratio, "MPF", "p"); legend->Draw(); // Luminosity tl.DrawLatex(0.18, 0.96, sLumi); // Energy tl.DrawLatex(0.80, 0.96, "#sqrt{s} = 8 TeV"); // Fit tl.DrawLatex(0.18, 0.47, balancing_ratio_legend); tl.DrawLatex(0.18, 0.38, mpf_ratio_legend); canvas->Print((outputName + "_ratio.pdf").c_str()); delete legend; delete canvas; delete mg; delete mg2; delete errors_bal; delete errors_mpf; }
void bigmatrix_corr(std::string eikoName="h_jety", bool update=false, bool acceptanceCorr=true, double correlation=1.0, bool logScale=false ) { // declare histograms TH1D* h_e; TH1D* h_ejes; TH1D* h_ejesup; TH1D* h_ejesdn; TH1D* heff_e; TH1F* h_mu; TH1F* h_mujes; TH1F* h_mujesup; TH1F* h_mujesdn; TH1D* heff_mu; TH1D* h_combine; // for combining electron and muon channels TH1D* h_corr; // for correction of acceptance std::string remword3 ="h_"; std::string corrName = eikoName; size_t pos3 = corrName.find(remword3); if(pos3!= std::string::npos) corrName.replace(pos3,remword3.length(),""); // acceptance correction for electrons TFile f_crack("mainCore/ave_sherpamadgraph.root"); if (f_crack.IsZombie()) { cout << endl << "Error opening file" << f_crack.GetName() << endl; return; } else cout << endl << "Opened " << f_crack.GetName() << endl << endl; h_corr = (TH1D*)(f_crack.Get(Form("have_%s",corrName.data()))); // for debugging if( !acceptanceCorr ) h_corr->Reset(); for(int i=1; i<= h_corr->GetNbinsX(); i++) { if( !acceptanceCorr ) { h_corr->SetBinContent(i,1.0); h_corr->SetBinError(i,1e-6); } cout << "Correction for bin " << i << " = " << h_corr->GetBinContent(i) << " +- " << h_corr->GetBinError(i) << endl; } //================================================================ // efficiency errors //================================================================ std::string xtitle; std::string muName; std::string kengName; std::string effElectronName; std::string effMuonName; if(eikoName=="h_ystar") { xtitle = "0.5|Y_{Z}-Y_{jet}|"; muName = "YDiff"; kengName = "DEta_per2_Z1jets_BE"; effElectronName = "EfficienyVsYdif"; effMuonName = "EffCorr_Ydiff"; } else if(eikoName=="h_yB") { xtitle = "0.5|Y_{Z}+Y_{jet}|"; muName = "YSum"; kengName = "SumEta_per2_Z1jets_BE"; effElectronName = "EfficienyVsYsum"; effMuonName = "EffCorr_Ysum"; } else if(eikoName=="h_jety") { xtitle = "|Y(jet)|"; muName = "Yjet"; kengName = "Z1jets_1jeta_BE"; effElectronName = "EfficienyVsYjet"; effMuonName = "EffCorr_Yjet"; } else if(eikoName=="h_zy") { xtitle = "|Y(Z)|"; muName = "YZ"; kengName ="dimuoneta1jet_BE"; effElectronName = "EfficienyVsYz"; effMuonName = "EffCorr_Yz"; } TFile f_eff_electron("mainCore/EffiZCut_Jer0.root"); if(f_eff_electron.IsZombie()){ cout << endl << "Error opening file" << f_eff_electron.GetName() << endl << endl; return; } else cout << endl << "Opened " << f_eff_electron.GetName() << endl << endl; heff_e = (TH1D*)(f_eff_electron.Get(effElectronName.data())); heff_e -> SetName(Form("heff_e_%s",corrName.data())); TFile f_eff_muon("mainCore/EffCorr_root_091912.root"); if(f_eff_muon.IsZombie()){ cout << endl << "Error opening file" << f_eff_muon.GetName() << endl << endl; return; } else cout << endl << "Opened " << f_eff_muon.GetName() << endl << endl; heff_mu = (TH1D*)(f_eff_muon.Get(effMuonName.data())); heff_mu -> SetName(Form("heff_mu_%s",corrName.data())); //=========================================================== // electron channel //=========================================================== TFile f_e("mainCore/cts_CorrectedPlotsZCut.root"); if (f_e.IsZombie()) { cout << endl << "Error opening file" << f_e.GetName() << endl << endl; return; } else cout << endl << "Opened " << f_e.GetName() << endl << endl; h_e = (TH1D*)(f_e.Get(eikoName.data())); h_e -> SetName(Form("h_e_%s",corrName.data())); h_e -> SetTitle(""); h_e -> Sumw2(); //------------------------------------------------------------------- // use electron channel to count the number of non-zero bins // so to avoid singular error matrix int nbins = 0; const double threshold = 1.0; for(int ie=1; ie<= h_e->GetNbinsX(); ie++) if(h_e->GetBinContent(ie)> threshold)nbins++; cout << "There are " << nbins << " bins with non-zero content" << endl; //------------------------------------------------------------------- h_e -> Divide(h_corr); h_e -> Scale(1.0/h_e->Integral()); h_e -> SetYTitle("Arbitrary Unit"); h_e -> SetTitleOffset(2.0,"Y"); h_e -> GetYaxis()->SetDecimals(); h_e -> GetXaxis()->SetDecimals(); h_e -> SetLineColor(kBlue-7); h_e -> SetMarkerColor(kBlue-7); h_e -> SetMarkerSize(1); h_e -> SetMarkerStyle(24); cout << "h_e integral = " << h_e->Integral() << endl; h_ejes= (TH1D*)(f_e.Get(eikoName.data())); h_ejes -> SetName("h_ejes"); h_ejes -> Sumw2(); h_ejes -> Scale(1.0/h_ejes->Integral()); cout << "h_ejes integral = " << h_ejes->Integral() << endl; TFile f_ejesup("mainCore/cts_CorrectedPlotsZCut_JesUp_NoBkgSub.root"); if (f_ejesup.IsZombie()) { cout << endl << "Error opening file" << f_ejesup.GetName() << endl << endl; return; } else cout << endl << "Opened " << f_ejesup.GetName() << endl << endl; h_ejesup = (TH1D*)(f_ejesup.Get(eikoName.data())); h_ejesup -> SetName("h_ejesup"); h_ejesup -> SetTitle(""); h_ejesup -> Sumw2(); h_ejesup -> Scale(1.0/h_ejesup->Integral()); cout << "h_ejesup integral = " << h_ejesup->Integral() << endl; TFile f_ejesdn("mainCore/cts_CorrectedPlotsZCut_JesDn_NoBkgSub.root"); if (f_ejesdn.IsZombie()) { cout << endl << "Error opening file" << f_ejesdn.GetName() << endl << endl; return; } else cout << endl << "Opened " << f_ejesdn.GetName() << endl << endl; h_ejesdn = (TH1D*)(f_ejesdn.Get(eikoName.data())); h_ejesdn -> SetName("h_ejesdn"); h_ejesdn -> SetTitle(""); h_ejesdn -> Sumw2(); h_ejesdn -> Scale(1.0/h_ejesdn->Integral()); cout << "h_ejesdn integral = " << h_ejesdn->Integral() << endl; h_combine= (TH1D*)h_e->Clone(Form("h_combine_%s",corrName.data())); h_combine -> Reset(); h_combine -> SetTitle(""); h_combine -> SetLineColor(1); h_combine -> SetMarkerColor(1); h_combine -> SetMarkerSize(1); h_combine -> SetMarkerStyle(8); //=========================================================== // muon channel //=========================================================== TFile f_mu("mainCore/DoubleMu2011_EffCorr_091812.root"); if (f_mu.IsZombie()) { cout << endl << "Error opening file" << f_mu.GetName() << endl << endl; return; } else cout << endl << "Opened " << f_mu.GetName() << endl << endl; h_mu = (TH1F*)(f_mu.Get(muName.data())); h_mu -> Sumw2(); h_mu -> SetName(Form("h_mu_%s",corrName.data())); h_mu -> SetTitle(""); h_mu -> Scale(1.0/h_mu->Integral()); h_mu -> SetLineColor(kRed-7); h_mu -> SetMarkerColor(kRed-7); h_mu -> SetMarkerSize(1); h_mu -> SetMarkerStyle(21); cout << "h_mu integral = " << h_mu->Integral() << endl; TFile f_jetsys_mu("mainCore/DoubleMu2011_JESuncertainty_JetY_061712.root"); if (f_jetsys_mu.IsZombie()) { cout << endl << "Error opening file" << f_jetsys_mu.GetName() << endl << endl; return; } else cout << endl << "Opened " << f_jetsys_mu.GetName() << endl << endl; h_mujes = (TH1F*)(f_jetsys_mu.Get(kengName.data())); h_mujes -> Sumw2(); h_mujes -> Scale(1.0/h_mujes->Integral()); cout << "h_mujes integral = " << h_mujes->Integral() << endl; h_mujesup = (TH1F*)(f_jetsys_mu.Get(Form("%sUp",kengName.data()))); h_mujesup -> Sumw2(); h_mujesup -> Scale(1.0/h_mujesup->Integral()); cout << "h_mujesup integral = " << h_mujesup->Integral() << endl; h_mujesdn = (TH1F*)(f_jetsys_mu.Get(Form("%sDn",kengName.data()))); h_mujesdn -> Sumw2(); h_mujesdn -> Scale(1.0/h_mujesdn->Integral()); cout << "h_mujesdn integral = " << h_mujesdn->Integral() << endl; // declare the big matrix const int NELE=2*nbins; TMatrixD errorM(NELE,NELE); TMatrixD U(NELE,nbins); for(int irow=0; irow < NELE; irow++) for(int icol=0; icol < nbins; icol++) U(irow,icol) = ( (irow== icol) || (irow== icol+nbins) )? 1:0; // debug // dumpElements(U); TMatrixD transposeU(nbins,NELE); transposeU.Transpose(U); // dumpElements(transposeU); TVectorD measurement(NELE); // jet energy scale for electron channel TVectorD jesSys_ele(nbins); TVectorD jesSys_muo(nbins); // now loop over bins to set the matrix content for(int ibin=0; ibin<nbins; ibin++){ // electron channel double value_e = h_e->GetBinContent(ibin+1); if(value_e < 1e-10)continue; double stat_mc_eff_e = heff_e->GetBinContent(ibin+1)<1e-6? 0: value_e*heff_e->GetBinError(ibin+1)/heff_e->GetBinContent(ibin+1); double stat_e = sqrt( pow(h_e->GetBinError(ibin+1),2) + pow(stat_mc_eff_e,2)); double value_e_jes = h_ejes->GetBinContent(ibin+1); if(value_e_jes <1e-10)continue; double rel_syse_up = fabs(h_ejesup->GetBinContent(ibin+1) - value_e_jes)/value_e_jes; double rel_syse_dn = fabs(h_ejesdn->GetBinContent(ibin+1) - value_e_jes)/value_e_jes; double rel_syse = rel_syse_up > rel_syse_dn? rel_syse_up: rel_syse_dn; double sys_e = value_e*rel_syse; jesSys_ele(ibin) = sys_e; double total_e_2 = stat_e*stat_e+ sys_e*sys_e; // muon channel double value_m = h_mu->GetBinContent(ibin+1); if(value_m < 1e-10)continue; double stat_mc_eff_m = heff_mu->GetBinContent(ibin+1)<1e-6? 0: value_m*heff_mu->GetBinError(ibin+1)/heff_mu->GetBinContent(ibin+1); double stat_m = sqrt( pow(h_mu->GetBinError(ibin+1),2) + pow(stat_mc_eff_m,2)); double value_m_jes = h_mujes->GetBinContent(ibin+1); if(value_m_jes <1e-10)continue; double rel_sysm_up = fabs(h_mujesup->GetBinContent(ibin+1) - value_m_jes)/value_m_jes; double rel_sysm_dn = fabs(h_mujesdn->GetBinContent(ibin+1) - value_m_jes)/value_m_jes; double rel_sysm = rel_sysm_up > rel_sysm_dn? rel_sysm_up: rel_sysm_dn; double sys_m = value_m*rel_sysm; jesSys_muo(ibin) = sys_m; double total_m_2 = stat_m*stat_m+ sys_m*sys_m; measurement(ibin) = value_e; measurement(nbins+ibin) = value_m; // first put electron error matrix component errorM(ibin,ibin) = total_e_2; // then muon errorM(nbins+ibin,nbins+ibin) = total_m_2; errorM(ibin,nbins+ibin) = errorM(nbins+ibin,ibin) = correlation*sys_e*sys_m; } // loop over the number of bins // debug dumpElements(jesSys_ele); dumpElements(jesSys_muo); // print out measurement value // dumpElements(measurement); // // print out error matrix component dumpElements(errorM); // assign the correlation between different bins due to JES // 100% correlation for(int ibin=0; ibin < nbins; ibin++){ for(int jbin=0; jbin<nbins; jbin++) { if(jbin!=ibin){ // electron channel errorM(ibin,jbin)= correlation*jesSys_ele(ibin)*jesSys_ele(jbin); // muon channel errorM(nbins+ibin,nbins+jbin)= correlation*jesSys_muo(ibin)* jesSys_muo(jbin); // electron-muon channel errorM(ibin,nbins+jbin)= correlation*jesSys_ele(ibin)*jesSys_muo(jbin); // muon-electron channel errorM(nbins+ibin,jbin)= correlation*jesSys_muo(ibin)*jesSys_ele(jbin); } } } dumpElements(errorM); TMatrixD errorInverse = errorM; double* det; errorInverse.Invert(det); dumpElements(errorInverse); // TMatrixD Unit = errorInverse*errorM; // dumpElements(Unit); TMatrixD matrixRight(nbins,NELE); matrixRight = transposeU*errorInverse; // dumpElements(matrixRight); TMatrixD matrixLeft(nbins,nbins); matrixLeft = transposeU*(errorInverse*U); // dumpElements(matrixLeft); TMatrixD matrixLeftInverse = matrixLeft; double* det2; matrixLeftInverse.Invert(det2); // dumpElements(matrixLeftInverse); TMatrixD lambda(nbins,NELE); lambda= matrixLeftInverse*matrixRight; // dumpElements(lambda); TMatrixD transposeLambda(NELE,nbins); transposeLambda.Transpose(lambda); // dumpElements(transposeLambda); // dumpElements(lambda); TVectorD combined_value(nbins); combined_value = lambda*measurement; // dumpElements(combined_value); TMatrixD combined_error(nbins,nbins); combined_error = lambda*(errorM*transposeLambda); // after all matrix operation, now set the histogram for(int i=0; i<nbins;i++){ h_combine->SetBinContent(i+1, combined_value(i)); double error = combined_error(i,i); if(error>1e-10)error = sqrt(error); else error=1e-10; h_combine->SetBinError(i+1,error); } for(int i=1; i <= h_combine->GetNbinsX(); i++){ if(h_combine->GetBinContent(i)>1e-10) cout << "Bin " << i << ": " << h_combine->GetBinContent(i) << " +- " << h_combine->GetBinError(i) << "\t" << "rele = " << (h_combine->GetBinError(i)/h_combine->GetBinContent(i)) << endl; } h_e ->SetXTitle(xtitle.data()); h_mu ->SetXTitle(xtitle.data()); h_combine->SetXTitle(xtitle.data()); std::string command = "recreate"; if(update)command="update"; TFile* outFile = new TFile("bigmatrix_corr.root", command.data()); h_e ->Write(); h_mu ->Write(); h_combine->Write(); heff_e ->Write(); heff_mu ->Write(); outFile->Close(); TCanvas* c1 = new TCanvas("c1","",500,500); if(logScale) c1->SetLogy(1); float x1NDC = 0.67; float y1NDC = 0.764831; float x2NDC = 0.830; float y2NDC = 0.908898; h_e->Draw("e"); h_mu->Draw("esame"); h_combine->Draw("e1same"); TLegend* leg = new TLegend(x1NDC,y1NDC,x2NDC,y2NDC); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetTextSize(0.05); leg->SetBorderSize(0); leg->AddEntry(h_combine, "combined"); leg->AddEntry(h_e, "e"); leg->AddEntry(h_mu, "#mu"); leg->Draw("same"); std::string remword ="h_"; std::string remword2 ="h"; size_t pos = eikoName.find(remword); if(pos!= std::string::npos) eikoName.replace(pos,remword2.length(),""); string dirName = "fig"; gSystem->mkdir(dirName.data()); string fileName = dirName + "/" + "final_emu" + eikoName; c1->Print(Form("%s.eps",fileName.data())); c1->Print(Form("%s.gif",fileName.data())); c1->Print(Form("%s.pdf",fileName.data())); }
int main() { ModTDRStyle(); std::vector<Scan> scans; //scans.push_back({"higgsCombinefullScan.MultiDimFit.mH125.root", "with syst.", 1, nullptr}); //scans.push_back({"higgsCombinefastScan.MultiDimFit.mH125.root", "no syst.", 32, nullptr}); //scans.push_back({"higgsCombinenoBBBScan.MultiDimFit.mH125.root", "no bbb syst.", 38, nullptr}); // scans.push_back({"thesis/higgsCombineFullScan.MultiDimFit.mH125.root", "Stat+Syst+Theory", 1, nullptr}); scans.push_back({"higgsCombineFullScan.MultiDimFit.mH125.root", "Mass Scan", kAzure-4, nullptr}); // scans.push_back({"higgsCombineStatOnly.MultiDimFit.mH125.root", "Stat Only", kBlue+1, nullptr}); //scans.push_back({"thesis/higgsCombineStatAndTh.MultiDimFit.mH125.root", "Stat+Theory", 39, nullptr}); TCanvas c1("canvas","canvas"); std::vector<TLine *> lines; TLegend *leg = new TLegend(0.37,0.65,0.73,0.9,"","brNDC"); unsigned counter = 0; for (auto & sc : scans) { TFile f1(sc.file.c_str()); TTree *t1 = dynamic_cast<TTree*>(f1.Get("limit")); double best1 = 0.0; sc.gr = new TGraph(ExtractGraph(t1, best1)); auto x1 = GetCrossings(*(sc.gr), 1.0); TString res; if (x1.size() == 2) { double err = (x1[1]-x1[0])/2.0; std::cout << "Best fit is: " << best1 << " +/- " << err << std::endl; lines.push_back(new TLine(x1[0],0,x1[0],1.0)); lines.back()->SetLineColor(sc.color); lines.back()->SetLineWidth(2); lines.push_back(new TLine(x1[1],0,x1[1],1.0)); lines.back()->SetLineColor(sc.color); lines.back()->SetLineWidth(2); res = TString::Format("%.1f#pm%.1f",best1,err); } sc.gr->SetLineColor(sc.color); sc.gr->SetLineWidth(3); sc.gr->Draw(counter ? "LSAME" : "AL"); TString leg_text = "#splitline{"+sc.label+"}{"+res+"}"; leg->AddEntry(sc.gr, leg_text, "L"); counter++; } // c1.cd(); // // g1.Print(); // g1.SetLineColor(1); // g1.SetLineWidth(2); // // g1.SetMarkerColor(7); // g1.Draw("AC"); scans[0].gr->SetMaximum(4); scans[0].gr->GetXaxis()->SetRangeUser(110, 130); // scans[0].gr->GetXaxis()->SetTitle("Signal Strength, #mu"); scans[0].gr->GetXaxis()->SetTitle("m_{H} [GeV]"); scans[0].gr->GetYaxis()->SetTitle("-2 #Delta ln L"); scans[0].gr->GetXaxis()->SetTitleFont(62); scans[0].gr->GetYaxis()->SetTitleFont(62); leg->SetBorderSize(1); leg->SetTextFont(42); leg->SetTextSize(0.03); leg->SetLineColor(0); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); leg->Draw(); lines.push_back(new TLine(110,1,130,1)); lines.back()->SetLineColor(2); for (auto l : lines) l->Draw(); TLatex *title_latex = new TLatex(); title_latex->SetNDC(); title_latex->SetTextSize(0.035); title_latex->SetTextFont(62); title_latex->SetTextAlign(31); double height = 0.94; title_latex->DrawLatex(0.95,height,"19.7 fb^{-1} (8 TeV) + 4.9 fb^{-1} (7 TeV)"); title_latex->SetTextAlign(11); title_latex->DrawLatex(0.17,height,"H#rightarrow#tau#tau"); title_latex->SetTextSize(0.08); title_latex->DrawLatex(0.21, 0.25, "#mu#tau_{h}"); c1.Update(); c1.SaveAs("scan.pdf"); return 0; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // DY // // channel = SF, MuMu, EE // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void DY(Double_t &yield, Double_t &statError, Double_t &systError, Double_t &scaleFactor, Int_t njet, TString channel, TString directory, Bool_t useDataDriven, Int_t printLevel, Bool_t drawR = false) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Input files // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TString path = Form("%s/%djet/%s/", directory.Data(), njet, channel.Data()); TFile* inputDYSF = new TFile(path + "DY.root"); TFile* inputZZSF = new TFile(path + "ZZ.root"); TFile* inputWZSF = new TFile(path + "WZ.root"); TFile* inputDataSF = new TFile(path + "DataRun2012_Total.root"); TFile* inputDataOF = new TFile(Form("%s/%djet/OF/DataRun2012_Total.root", directory.Data(), njet)); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Input histograms // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TH1F* hNinDYSF [numberMetCuts]; TH1F* hNinWZSF [numberMetCuts]; TH1F* hNinZZSF [numberMetCuts]; TH1F* hNinDataSF[numberMetCuts]; TH1F* hNinDataOF[numberMetCuts]; TH1F* hNoutDYSF [numberMetCuts]; TH1F* hNoutWZSF [numberMetCuts]; TH1F* hNoutZZSF [numberMetCuts]; TH1F* hNoutDataSF[numberMetCuts]; TH1F* hNoutDataOF[numberMetCuts]; for (UInt_t nC=0; nC<numberMetCuts; nC++) { hNinDYSF [nC] = (TH1F*)inputDYSF ->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNinWZSF [nC] = (TH1F*)inputWZSF ->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNinZZSF [nC] = (TH1F*)inputZZSF ->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNinDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNinDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNoutDYSF [nC] = (TH1F*)inputDYSF ->Get(Form("hNoutZevents%.2f", MetCuts[nC])); hNoutWZSF [nC] = (TH1F*)inputWZSF ->Get(Form("hNoutZevents%.2f", MetCuts[nC])); hNoutZZSF [nC] = (TH1F*)inputZZSF ->Get(Form("hNoutZevents%.2f", MetCuts[nC])); hNoutDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNoutZevents%.2f", MetCuts[nC])); hNoutDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNoutZevents%.2f", MetCuts[nC])); } // Histogram at analysis level //---------------------------------------------------------------------------- TH1F* hExpectedDYSF = (TH1F*)inputDYSF->Get("hWTopTagging"); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // k estimation // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TFile* inputDYmumu = new TFile(Form("%s/%djet/MuMu/DY.root", directory.Data(), njet)); TFile* inputDYee = new TFile(Form("%s/%djet/EE/DY.root", directory.Data(), njet)); TH1F* hNinDYmumu = (TH1F*)inputDYmumu->Get("hNinLooseZevents20.00"); TH1F* hNinDYee = (TH1F*)inputDYee ->Get("hNinLooseZevents20.00"); Double_t NinDYmumu = hNinDYmumu->GetBinContent(2); Double_t NinDYee = hNinDYee ->GetBinContent(2); Double_t k = 0.5 * (sqrt(NinDYmumu / NinDYee) + sqrt(NinDYee / NinDYmumu)); Double_t errk = errkSF(NinDYmumu, NinDYee); if (channel == "MuMu") { k = 0.5 * sqrt(NinDYmumu / NinDYee); errk = errkFunction(NinDYmumu, NinDYee); } else if (channel == "EE") { k = 0.5 * sqrt(NinDYee / NinDYmumu); errk = errkFunction(NinDYee, NinDYmumu); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Counters // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Double_t NinDYSF [numberMetCuts]; Double_t NinWZSF [numberMetCuts]; Double_t NinZZSF [numberMetCuts]; Double_t NinDataSF[numberMetCuts]; Double_t NinDataOF[numberMetCuts]; Double_t NoutDYSF [numberMetCuts]; Double_t NoutWZSF [numberMetCuts]; // Not used for now Double_t NoutZZSF [numberMetCuts]; // Not used for now Double_t NoutDataSF[numberMetCuts]; Double_t NoutDataOF[numberMetCuts]; for (UInt_t nC=0; nC<numberMetCuts-1; nC++) { NinDYSF [nC] = hNinDYSF [nC]->GetBinContent(2); NinWZSF [nC] = hNinWZSF [nC]->GetBinContent(2); NinZZSF [nC] = hNinZZSF [nC]->GetBinContent(2); NinDataSF [nC] = hNinDataSF [nC]->GetBinContent(2); NinDataOF [nC] = hNinDataOF [nC]->GetBinContent(2); NoutDYSF [nC] = hNoutDYSF [nC]->GetBinContent(2); NoutWZSF [nC] = hNoutWZSF [nC]->GetBinContent(2); NoutZZSF [nC] = hNoutZZSF [nC]->GetBinContent(2); NoutDataSF[nC] = hNoutDataSF[nC]->GetBinContent(2); NoutDataOF[nC] = hNoutDataOF[nC]->GetBinContent(2); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // R estimation // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Double_t R [numberMetCuts]; Double_t RData [numberMetCuts]; Double_t errR [numberMetCuts]; Double_t errRData[numberMetCuts]; // Loop over the met cuts //---------------------------------------------------------------------------- for (UInt_t nC=0; nC<numberMetCuts-1; nC++) { R [nC] = NoutDYSF[nC] / NinDYSF[nC]; errR[nC] = errRFunction(NoutDYSF[nC], NinDYSF[nC]); RData [nC] = RDataFunction (NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k); errRData[nC] = errRDataFunction(NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k, errk); if (printLevel > 2) { printf("\n %.0f < mpmet < %.0f GeV\n", MetCuts[nC], MetCuts[nC+1]); printf(" -------------------------------------------------\n"); printf(" N^{MC}_{out,SF} = %6.1f\n", NoutDYSF[nC]); printf(" N^{MC}_{in, SF} = %6.1f\n", NinDYSF[nC]); printf(" N^{data}_{out,SF} = %4.0f\n", NoutDataSF[nC]); printf(" N^{data}_{out,OF} = %4.0f\n", NoutDataOF[nC]); printf(" N^{data}_{in, SF} = %4.0f\n", NinDataSF[nC]); printf(" N^{data}_{in, OF} = %4.0f\n", NinDataOF[nC]); printf(" k = % 5.3f +- %5.3f\n", k, errk); printf(" R^{MC} = % 5.3f +- %5.3f\n", R[nC], errR[nC]); printf(" R^{data} = % 5.3f +- %5.3f\n", RData[nC], errRData[nC]); } } // Estimate the R systematic as the difference between R[2] and R[3] //---------------------------------------------------------------------------- Int_t iMaxR = 0; Int_t iMinR = 0; for (UInt_t nC=0; nC<numberMetCuts-1; nC++) { if (R[nC] > 0 && R[nC] > R[iMaxR]) iMaxR = nC; if (R[nC] > 0 && R[nC] < R[iMinR]) iMinR = nC; } Int_t theR = 2; Int_t sysR = 3; Double_t RelDiffR = (R[theR] > 0) ? fabs(R[theR] - R[sysR]) / R[theR] : -999; if (printLevel > 0) { printf("\n [%s] R systematic uncertainty\n", channel.Data()); printf(" -------------------------------------------------\n"); printf(" min R = %5.3f\n", R[iMinR]); printf(" max R = %5.3f\n", R[iMaxR]); printf(" R[%d] = %5.3f\n", theR, R[theR]); printf(" R[%d] = %5.3f\n", sysR, R[sysR]); printf(" |R[%d]-R[%d]| / R[%d] = %.1f%s\n", theR, sysR, theR, 1e2*RelDiffR, "%"); printf("\n"); } // Estimate Nout //---------------------------------------------------------------------------- Double_t NinCountedSFWZ = NinWZSF [sysR]; Double_t NinCountedSFZZ = NinZZSF [sysR]; Double_t NinCountedSFData = NinDataSF[sysR]; Double_t NinCountedOFData = NinDataOF[sysR]; Double_t NinEstSFFinal = NinCountedSFData - k*NinCountedOFData; Double_t errNinEstSFFinal = errNinEstFunction(NinCountedSFData, NinCountedOFData, k, errk); Double_t NestSFFinal = R[theR] * NinEstSFFinal; Double_t errNestSFFinal = errNestFunction(NestSFFinal, R[theR], errR[theR], NinEstSFFinal, errNinEstSFFinal); Double_t NinEstSFNoDibosonFinal = NinEstSFFinal - NinCountedSFWZ - NinCountedSFZZ; Double_t errNinEstSFNoDibosonFinal = errNinEstNoDibosonFunction(NinCountedSFData, k, errk, NinCountedOFData, NinCountedSFWZ, NinCountedSFZZ); Double_t NestSFNoDibosonFinal = R[theR] * NinEstSFNoDibosonFinal; Double_t errNestSFNoDibosonFinal = errNestFunction(NestSFNoDibosonFinal, R[theR], errR[theR], NinEstSFNoDibosonFinal, errNinEstSFNoDibosonFinal); Double_t totalError = sqrt(errNestSFNoDibosonFinal*errNestSFNoDibosonFinal + (RelDiffR*NestSFNoDibosonFinal)*(RelDiffR*NestSFNoDibosonFinal)); Double_t SFsf = NestSFNoDibosonFinal / hExpectedDYSF->GetBinContent(2); if (printLevel > 1) { printf("\n Analysis results\n"); printf(" -------------------------------------------------\n"); printf(" N^{data}_{in,SF} = %4.0f\n", NinCountedSFData); printf(" N^{data}_{in,OF} = %4.0f\n", NinCountedOFData); printf(" k = %5.3f +- %5.3f\n", k, errk); printf(" R[%d] = %5.3f +- %5.3f\n", theR, R[theR], errR[theR]); printf(" N^{WZ}_{in,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n", NinCountedSFWZ, sqrt(NinCountedSFWZ), 0.1*NinCountedSFWZ); printf(" N^{ZZ}_{in,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n", NinCountedSFZZ, sqrt(NinCountedSFZZ), 0.1*NinCountedSFZZ); printf(" N^{est}_{in, SF} = %7.2f +- %6.2f\n", NinEstSFFinal, errNinEstSFFinal); printf(" N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n", NestSFFinal, errNestSFFinal, RelDiffR*NestSFFinal); printf(" -------------------------------------------------\n"); printf(" [no VZ] N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.) = %7.2f +- %6.2f (stat. + syst.)\n", NestSFNoDibosonFinal, errNestSFNoDibosonFinal, RelDiffR*NestSFNoDibosonFinal, NestSFNoDibosonFinal, totalError); printf(" N^{MC}_{out,SF} = %7.2f +- %6.2f\n", hExpectedDYSF->GetBinContent(2), hExpectedDYSF->GetBinError(2)); printf(" *** scale factor = %.3f\n\n", SFsf); } // Save the result //---------------------------------------------------------------------------- yield = (useDataDriven) ? NestSFNoDibosonFinal : hExpectedDYSF->GetBinContent(2); statError = errNestSFNoDibosonFinal; systError = RelDiffR*NestSFNoDibosonFinal; scaleFactor = yield / hExpectedDYSF->GetBinContent(2); // For the note //---------------------------------------------------------------------------- if (printLevel > 0) { printf("\n [%s] DY values for the note\n", channel.Data()); printf(" -------------------------------------------------\n"); printf(" final state & R_{MC} & N^{control,data} & N_{DY}^{data} & N_{DY}^{MC} & data/MC\n"); printf(" same flavour & %5.3f $\\pm$ %5.3f & %4.0f & %5.1f $\\pm$ %4.1f & %5.1f $\\pm$ %4.1f & %4.1f\n\n", R[theR], errR[theR], NinCountedSFData, yield, statError, hExpectedDYSF->GetBinContent(2), hExpectedDYSF->GetBinError(2), scaleFactor); printf("\n [%s] DY relative systematic uncertainties\n", channel.Data()); printf(" -------------------------------------------------\n"); printf(" DY normalisation = %.0f (stat.) $\\bigoplus$ %.0f (syst.)\n\n", 1e2*statError/yield, 1e2*systError/yield); } // Check //---------------------------------------------------------------------------- Double_t check = hExpectedDYSF->GetBinContent(2) - NoutDYSF[sysR]; if (check != 0) printf(" WARNING: DY yields do not much by %f\n\n", check); // Draw histograms //---------------------------------------------------------------------------- if (drawR) { Double_t absoluteMin = 999; TGraphErrors* gR = new TGraphErrors(numberMetCuts-1); TGraphErrors* gRdata = new TGraphErrors(numberMetCuts-1); for (UInt_t i=0; i<numberMetCuts-1; i++) { gR->SetPoint (i, 0.5 * (MetDraw[i+1] + MetDraw[i]), R[i]); gR->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errR[i]); gRdata->SetPoint (i, 0.5 * (MetDraw[i+1] + MetDraw[i]), RData[i]); gRdata->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errRData[i]); if (absoluteMin > (R[i] - errR[i])) absoluteMin = R[i] - errR[i]; if (absoluteMin > (RData[i] - errRData[i])) absoluteMin = RData[i] - errRData[i]; } if (absoluteMin > 0) absoluteMin = 0; // Cosmetics //-------------------------------------------------------------------------- gR->SetMarkerSize (0.9); gR->SetMarkerStyle(kFullCircle); gRdata->SetLineColor (kRed+1); gRdata->SetMarkerColor(kRed+1); gRdata->SetMarkerSize (0.9); gRdata->SetMarkerStyle(kFullCircle); // Draw //-------------------------------------------------------------------------- canvas = new TCanvas(); TMultiGraph *mgR = new TMultiGraph(); mgR->Add(gRdata); mgR->Add(gR); mgR->Draw("ap"); mgR->GetYaxis()->SetTitle("R^{out/in}"); mgR->GetXaxis()->SetTitle("mpmet (GeV)"); mgR->SetMinimum(absoluteMin - 0.1); mgR->SetMaximum(1.0); // Legend //-------------------------------------------------------------------------- TLegend* lmgR = new TLegend(0.72, 0.68, 0.92, 0.88); lmgR->AddEntry(gR, " DY MC", "lp"); lmgR->AddEntry(gRdata," data", "lp"); lmgR->SetFillColor(0); lmgR->SetTextAlign(12); lmgR->SetTextFont (42); lmgR->SetTextSize (0.04); if (channel == "SF") lmgR->SetHeader("ee + #mu#mu"); else if (channel == "EE") lmgR->SetHeader("ee"); else if (channel == "MuMu") lmgR->SetHeader("#mu#mu"); lmgR->Draw("same"); // Line at zero //-------------------------------------------------------------------------- TLine* zeroLine = new TLine(canvas->GetUxmin(), 0.0, canvas->GetUxmax(), 0.0); zeroLine->SetLineStyle(3); zeroLine->SetLineWidth(2); zeroLine->Draw("same"); mgR->Draw("p,same"); // Save //-------------------------------------------------------------------------- canvas->SaveAs("R_" + channel + ".png"); } }
void makePlots( const char * model, const char * src, const char * infile , const char * option ) { //Output path TString path("./paper01-plots/probs/"); TString dataPee = TString( model ) + TString("_") + TString( src ) + TString("_Pee/data"); TString dataPem = TString( model ) + TString("_") + TString( src ) + TString("_Pem/data"); TString dataPet = TString( model ) + TString("_") + TString( src ) + TString("_Pet/data"); TString dataAPee = TString( model ) + TString("_") + TString( src ) + TString("_aPee/data"); TString dataAPem = TString( model ) + TString("_") + TString( src ) + TString("_aPem/data"); TString dataAPet = TString( model ) + TString("_") + TString( src ) + TString("_aPet/data"); TList * v_Labels = new TList(); TObjString *label; label = new TObjString( "Pee" ); v_Labels->Add( label ); label = new TObjString( "Pe#mu" ); v_Labels->Add( label ); label = new TObjString( "Pe#tau" ); v_Labels->Add( label ); TFile * f1 = new TFile(infile); f1->cd(); TTree * PeeTreeNu = (TTree*)gDirectory->Get( dataPee.Data() ); TTree * PemTreeNu = (TTree*)gDirectory->Get( dataPem.Data() ); TTree * PetTreeNu = (TTree*)gDirectory->Get( dataPet.Data() ); TTree * PeeTreeANu = (TTree*)gDirectory->Get( dataAPee.Data() ); TTree * PemTreeANu = (TTree*)gDirectory->Get( dataAPem.Data() ); TTree * PetTreeANu = (TTree*)gDirectory->Get( dataAPet.Data() ); //Branches double xx = 0.0; double yy = 0.0; TCanvas * c1 = new TCanvas(model, "Oscillation probabilities", 184, 60, 861, 670); c1->Divide(1,3); TGraph * ProbNu[3]; ProbNu[0] = new TGraph(); ProbNu[1] = new TGraph(); ProbNu[2] = new TGraph(); TGraph * ProbANu[3]; ProbANu[0] = new TGraph(); ProbANu[1] = new TGraph(); ProbANu[2] = new TGraph(); TGraph * Psum = new TGraph(); TGraph * aPsum = new TGraph(); TLegend * leg = new TLegend(0.14,0.69,0.24,0.85); PeeTreeNu->SetBranchAddress("Ex",&xx); PeeTreeNu->SetBranchAddress("Pb",&yy); Long64_t nentries = PeeTreeNu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PeeTreeNu->GetEntry(i); ProbNu[0]->SetPoint( i, xx, yy); } PeeTreeANu->SetBranchAddress("Ex",&xx); PeeTreeANu->SetBranchAddress("Pb",&yy); nentries = PeeTreeANu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PeeTreeANu->GetEntry(i); ProbANu[0]->SetPoint( i, xx, yy); } ///Pem PemTreeNu->SetBranchAddress("Ex",&xx); PemTreeNu->SetBranchAddress("Pb",&yy); nentries = PemTreeNu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PemTreeNu->GetEntry(i); ProbNu[1]->SetPoint( i, xx, yy); } PemTreeANu->SetBranchAddress("Ex",&xx); PemTreeANu->SetBranchAddress("Pb",&yy); nentries = PemTreeANu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PemTreeANu->GetEntry(i); ProbANu[1]->SetPoint( i, xx, yy); } ///Pet PetTreeNu->SetBranchAddress("Ex",&xx); PetTreeNu->SetBranchAddress("Pb",&yy); nentries = PetTreeNu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PetTreeNu->GetEntry(i); ProbNu[2]->SetPoint( i, xx, yy); } PetTreeANu->SetBranchAddress("Ex",&xx); PetTreeANu->SetBranchAddress("Pb",&yy); nentries = PetTreeANu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PetTreeANu->GetEntry(i); ProbANu[2]->SetPoint( i, xx, yy); } for( int k=0; k < 3; ++k) { ProbNu[k]->SetLineColor(4); ProbNu[k]->SetMarkerColor(4); ProbNu[k]->SetMarkerStyle(7); ProbNu[k]->SetFillColor(10); ProbNu[k]->SetMaximum(1.0); ProbNu[k]->SetMinimum(0.0); TString yaxis = ((TObjString*)v_Labels->At(k))->GetString(); ProbNu[k]->GetYaxis()->SetTitle( yaxis.Data() ); ProbNu[k]->GetXaxis()->SetTitle("E [eV]"); ProbNu[k]->GetYaxis()->CenterTitle(true); ProbNu[k]->GetXaxis()->CenterTitle(true); ProbNu[k]->GetXaxis()->SetLabelOffset(0.007); ProbNu[k]->GetXaxis()->SetLabelSize(0.08); ProbNu[k]->GetXaxis()->SetTitleSize(0.07); ProbNu[k]->GetXaxis()->SetTitleOffset(0.9); ProbNu[k]->GetXaxis()->SetLabelFont(42); ProbNu[k]->GetYaxis()->SetLabelOffset(0.007); ProbNu[k]->GetYaxis()->SetLabelSize(0.08); ProbNu[k]->GetYaxis()->SetLabelFont(42); ProbNu[k]->GetYaxis()->SetTitleSize(0.09); ProbNu[k]->GetYaxis()->SetTitleOffset(0.45); ProbNu[k]->GetYaxis()->SetTitleFont(42); ProbANu[k]->SetMarkerColor(42); ProbANu[k]->SetMarkerStyle(23); ProbANu[k]->SetMarkerSize(0.3); ProbANu[k]->SetFillColor(10); ProbANu[k]->SetMaximum(1.0); ProbANu[k]->SetMinimum(0.0); } leg->AddEntry( ProbNu[0], "#nu"); leg->AddEntry( ProbANu[0], "#bar{#nu}"); leg->SetBorderSize(0); leg->SetTextSize(0.1); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); c1->cd(1); gPad->SetGridx(); gPad->SetGridy(); gPad->SetLogx(); if ( std::string(model).compare("EarthB") == 0 ) ProbNu[0]->GetXaxis()->SetLimits(0.98e9, 1.0e10); ProbNu[0]->Draw("APL"); ProbANu[0]->Draw("PL"); topTitle(model); leg->DrawClone(); c1->cd(2); gPad->SetGridx(); gPad->SetGridy(); gPad->SetLogx(); if ( std::string(model).compare("EarthB") == 0 ) ProbNu[1]->GetXaxis()->SetLimits(0.98e9, 1.0e10); ProbNu[1]->Draw("APL"); ProbANu[1]->Draw("PL"); leg->DrawClone(); c1->cd(3); gPad->SetGridx(); gPad->SetGridy(); gPad->SetLogx(); if ( std::string(model).compare("EarthB") == 0 ) ProbNu[2]->GetXaxis()->SetLimits(0.98e9, 1.0e10); ProbNu[2]->Draw("APL"); ProbANu[2]->Draw("PL"); leg->DrawClone(); c1->cd(); std::stringstream saveAs; saveAs.str(""); saveAs << path << model << "/pdf/" << "nueosc_probs_" << model << "_" << option << ".pdf"; c1->SaveAs( saveAs.str().c_str() ); saveAs.str(""); saveAs << path << model << "/png/" << "nueosc_probs_" << model << "_" << option << ".png"; c1->SaveAs( saveAs.str().c_str() ); saveAs.str(""); saveAs << path << model << "/eps/" << "nueosc_probs_" << model << "_" << option << ".eps"; c1->SaveAs( saveAs.str().c_str() ); TH1D * h_Psum = new TH1D("Psum.Histo","",100, 0.99999, 1.0001); TH1D * h_aPsum = h_Psum->Clone("aPsum.Histo"); for (Long64_t i=0;i<nentries;i++) { double xx = 0.0; double yy = 0.0; double p1 = 0.0; double p2 = 0.0; double p3 = 0.0; ProbNu[0]->GetPoint(i, xx, p1); ProbNu[1]->GetPoint(i, xx, p2); ProbNu[2]->GetPoint(i, xx, p3); yy = p1 + p2 + p3; if ( xx < 1.0e14 ) { Psum->SetPoint( i, xx, yy); h_Psum->Fill( yy ); } else break; } for (Long64_t i=0;i<nentries;i++) { double xx = 0.0; double yy = 0.0; double p1 = 0.0; double p2 = 0.0; double p3 = 0.0; ProbANu[0]->GetPoint(i, xx, p1); ProbANu[1]->GetPoint(i, xx, p2); ProbANu[2]->GetPoint(i, xx, p3); yy = p1 + p2 + p3; if ( xx < 1.0e14 ) { aPsum->SetPoint( i, xx, yy); h_aPsum->Fill( yy ); } else break; } TCanvas * c2 = new TCanvas("Sums", "Oscillation probabilities - SUMS", 184,112,394,472); c2->Divide(2,2); c2->cd(1); gPad->SetLogx(); Psum->SetMaximum(1.1); Psum->SetMinimum(0.0); Psum->SetMarkerStyle(21); Psum->SetMarkerSize(0.2); if ( std::string(model).compare("EarthB") == 0 ) Psum->GetXaxis()->SetLimits(0.98e9, 1.0e10); Psum->Draw("APL"); TLatex * tex = new TLatex(1.823945e+11,0.8753448,"Nu"); tex->SetLineWidth(2); tex->Draw(); c2->Modified(); c2->cd(); //Now the histogram c2->cd(2); // h_Psum->GetXaxis()->SetRange(6,14); h_Psum->GetXaxis()->SetNdivisions(501); h_Psum->GetXaxis()->SetLabelFont(42); h_Psum->GetXaxis()->SetLabelOffset(0.007); h_Psum->GetXaxis()->SetLabelSize(0.05); h_Psum->GetXaxis()->SetTitleSize(0.06); h_Psum->GetXaxis()->SetTitleOffset(0.9); h_Psum->GetXaxis()->SetTitleFont(42); h_Psum->Draw(""); h_Psum->Draw(); ///// c2->cd(3); gPad->SetLogx(); aPsum->SetMaximum(1.1); aPsum->SetMinimum(0.0); aPsum->SetMarkerStyle(21); aPsum->SetMarkerSize(0.2); aPsum->SetMarkerColor(2); aPsum->GetXaxis()->SetTitle("E [eV]"); aPsum->GetXaxis()->CenterTitle(true); aPsum->GetXaxis()->SetLabelFont(42); aPsum->GetXaxis()->SetLabelOffset(0.007); aPsum->GetXaxis()->SetLabelSize(0.05); aPsum->GetXaxis()->SetTitleSize(0.06); aPsum->GetXaxis()->SetTitleOffset(1.06); if ( std::string(model).compare("EarthB") == 0 ) aPsum->GetXaxis()->SetLimits(0.98e9, 1.0e10); aPsum->Draw("APL"); tex = new TLatex(1.56236e+11,0.8214771,"anti-Nu"); tex->SetLineWidth(2); tex->Draw(); //Now the histogram c2->cd(4); h_aPsum->Draw(); ///// c2->Modified(); c2->cd(); saveAs.str(""); saveAs << path << model << "/png/" << "nueosc_sum_of_probs_" << model << "_" << option << ".png"; c2->SaveAs( saveAs.str().c_str() ); }
void TrackClusterDistanceCut_Zuds91_totalRecoEnergy() { //=========Macro generated from canvas: c1/A Simple Graph Example //========= (Mon Mar 5 13:11:08 2018) by ROOT version6.08/00 TCanvas *c1 = new TCanvas("c1", "A Simple Graph Example",2,51,800,700); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c1->SetHighLightColor(2); c1->Range(-27.2,-290.1405,132.8,1321.751); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetPhi(150); c1->SetLeftMargin(0.17); c1->SetRightMargin(0.08); c1->SetTopMargin(0.08); c1->SetBottomMargin(0.18); c1->SetFrameLineWidth(2); c1->SetFrameBorderMode(0); c1->SetFrameLineWidth(2); c1->SetFrameBorderMode(0); TH1F *hist_pfoEnergyTotal__6 = new TH1F("hist_pfoEnergyTotal__6","hist_pfoEnergyTotal",500,0,500); hist_pfoEnergyTotal__6->SetBinContent(19,1); hist_pfoEnergyTotal__6->SetBinContent(22,1); hist_pfoEnergyTotal__6->SetBinContent(28,2); hist_pfoEnergyTotal__6->SetBinContent(33,1); hist_pfoEnergyTotal__6->SetBinContent(35,2); hist_pfoEnergyTotal__6->SetBinContent(37,1); hist_pfoEnergyTotal__6->SetBinContent(38,1); hist_pfoEnergyTotal__6->SetBinContent(40,1); hist_pfoEnergyTotal__6->SetBinContent(41,1); hist_pfoEnergyTotal__6->SetBinContent(42,1); hist_pfoEnergyTotal__6->SetBinContent(44,2); hist_pfoEnergyTotal__6->SetBinContent(45,1); hist_pfoEnergyTotal__6->SetBinContent(46,2); hist_pfoEnergyTotal__6->SetBinContent(48,1); hist_pfoEnergyTotal__6->SetBinContent(49,2); hist_pfoEnergyTotal__6->SetBinContent(50,2); hist_pfoEnergyTotal__6->SetBinContent(51,4); hist_pfoEnergyTotal__6->SetBinContent(53,1); hist_pfoEnergyTotal__6->SetBinContent(54,2); hist_pfoEnergyTotal__6->SetBinContent(55,4); hist_pfoEnergyTotal__6->SetBinContent(56,5); hist_pfoEnergyTotal__6->SetBinContent(57,5); hist_pfoEnergyTotal__6->SetBinContent(58,2); hist_pfoEnergyTotal__6->SetBinContent(59,5); hist_pfoEnergyTotal__6->SetBinContent(60,2); hist_pfoEnergyTotal__6->SetBinContent(61,2); hist_pfoEnergyTotal__6->SetBinContent(62,4); hist_pfoEnergyTotal__6->SetBinContent(63,3); hist_pfoEnergyTotal__6->SetBinContent(64,5); hist_pfoEnergyTotal__6->SetBinContent(65,7); hist_pfoEnergyTotal__6->SetBinContent(66,6); hist_pfoEnergyTotal__6->SetBinContent(67,4); hist_pfoEnergyTotal__6->SetBinContent(68,13); hist_pfoEnergyTotal__6->SetBinContent(69,2); hist_pfoEnergyTotal__6->SetBinContent(70,12); hist_pfoEnergyTotal__6->SetBinContent(71,7); hist_pfoEnergyTotal__6->SetBinContent(72,2); hist_pfoEnergyTotal__6->SetBinContent(73,7); hist_pfoEnergyTotal__6->SetBinContent(74,11); hist_pfoEnergyTotal__6->SetBinContent(75,11); hist_pfoEnergyTotal__6->SetBinContent(76,12); hist_pfoEnergyTotal__6->SetBinContent(77,29); hist_pfoEnergyTotal__6->SetBinContent(78,27); hist_pfoEnergyTotal__6->SetBinContent(79,37); hist_pfoEnergyTotal__6->SetBinContent(80,42); hist_pfoEnergyTotal__6->SetBinContent(81,64); hist_pfoEnergyTotal__6->SetBinContent(82,112); hist_pfoEnergyTotal__6->SetBinContent(83,132); hist_pfoEnergyTotal__6->SetBinContent(84,184); hist_pfoEnergyTotal__6->SetBinContent(85,266); hist_pfoEnergyTotal__6->SetBinContent(86,365); hist_pfoEnergyTotal__6->SetBinContent(87,528); hist_pfoEnergyTotal__6->SetBinContent(88,744); hist_pfoEnergyTotal__6->SetBinContent(89,896); hist_pfoEnergyTotal__6->SetBinContent(90,1094); hist_pfoEnergyTotal__6->SetBinContent(91,1136); hist_pfoEnergyTotal__6->SetBinContent(92,1054); hist_pfoEnergyTotal__6->SetBinContent(93,857); hist_pfoEnergyTotal__6->SetBinContent(94,660); hist_pfoEnergyTotal__6->SetBinContent(95,495); hist_pfoEnergyTotal__6->SetBinContent(96,313); hist_pfoEnergyTotal__6->SetBinContent(97,245); hist_pfoEnergyTotal__6->SetBinContent(98,171); hist_pfoEnergyTotal__6->SetBinContent(99,101); hist_pfoEnergyTotal__6->SetBinContent(100,78); hist_pfoEnergyTotal__6->SetBinContent(101,51); hist_pfoEnergyTotal__6->SetBinContent(102,39); hist_pfoEnergyTotal__6->SetBinContent(103,27); hist_pfoEnergyTotal__6->SetBinContent(104,19); hist_pfoEnergyTotal__6->SetBinContent(105,24); hist_pfoEnergyTotal__6->SetBinContent(106,9); hist_pfoEnergyTotal__6->SetBinContent(107,7); hist_pfoEnergyTotal__6->SetBinContent(108,8); hist_pfoEnergyTotal__6->SetBinContent(109,2); hist_pfoEnergyTotal__6->SetBinContent(110,3); hist_pfoEnergyTotal__6->SetBinContent(111,2); hist_pfoEnergyTotal__6->SetBinContent(112,2); hist_pfoEnergyTotal__6->SetBinContent(113,5); hist_pfoEnergyTotal__6->SetBinContent(114,6); hist_pfoEnergyTotal__6->SetBinContent(115,1); hist_pfoEnergyTotal__6->SetBinContent(117,2); hist_pfoEnergyTotal__6->SetBinContent(122,1); hist_pfoEnergyTotal__6->SetBinContent(132,1); hist_pfoEnergyTotal__6->SetBinContent(156,1); hist_pfoEnergyTotal__6->SetEntries(10000); hist_pfoEnergyTotal__6->SetStats(0); hist_pfoEnergyTotal__6->SetLineWidth(2); hist_pfoEnergyTotal__6->SetMarkerStyle(0); hist_pfoEnergyTotal__6->SetMarkerSize(1.2); hist_pfoEnergyTotal__6->GetXaxis()->SetTitle("Energy [GeV]"); hist_pfoEnergyTotal__6->GetXaxis()->SetRange(1,120); hist_pfoEnergyTotal__6->GetXaxis()->SetNdivisions(506); hist_pfoEnergyTotal__6->GetXaxis()->SetLabelFont(42); hist_pfoEnergyTotal__6->GetXaxis()->SetLabelOffset(0.015); hist_pfoEnergyTotal__6->GetXaxis()->SetLabelSize(0.06); hist_pfoEnergyTotal__6->GetXaxis()->SetTitleSize(0.07); hist_pfoEnergyTotal__6->GetXaxis()->SetTitleFont(42); hist_pfoEnergyTotal__6->GetYaxis()->SetTitle("Counts"); hist_pfoEnergyTotal__6->GetYaxis()->SetNdivisions(506); hist_pfoEnergyTotal__6->GetYaxis()->SetLabelFont(42); hist_pfoEnergyTotal__6->GetYaxis()->SetLabelOffset(0.015); hist_pfoEnergyTotal__6->GetYaxis()->SetLabelSize(0.06); hist_pfoEnergyTotal__6->GetYaxis()->SetTitleSize(0.07); hist_pfoEnergyTotal__6->GetYaxis()->SetTitleOffset(1.2); hist_pfoEnergyTotal__6->GetYaxis()->SetTitleFont(42); hist_pfoEnergyTotal__6->GetZaxis()->SetLabelFont(42); hist_pfoEnergyTotal__6->GetZaxis()->SetLabelOffset(0.015); hist_pfoEnergyTotal__6->GetZaxis()->SetLabelSize(0.06); hist_pfoEnergyTotal__6->GetZaxis()->SetTitleSize(0.07); hist_pfoEnergyTotal__6->GetZaxis()->SetTitleOffset(1.2); hist_pfoEnergyTotal__6->GetZaxis()->SetTitleFont(42); hist_pfoEnergyTotal__6->Draw("HIST"); TH1F *hist_pfoEnergyTotal__7 = new TH1F("hist_pfoEnergyTotal__7","hist_pfoEnergyTotal",500,0,500); hist_pfoEnergyTotal__7->SetBinContent(16,1); hist_pfoEnergyTotal__7->SetBinContent(24,1); hist_pfoEnergyTotal__7->SetBinContent(28,1); hist_pfoEnergyTotal__7->SetBinContent(30,1); hist_pfoEnergyTotal__7->SetBinContent(31,1); hist_pfoEnergyTotal__7->SetBinContent(33,1); hist_pfoEnergyTotal__7->SetBinContent(34,1); hist_pfoEnergyTotal__7->SetBinContent(36,2); hist_pfoEnergyTotal__7->SetBinContent(38,2); hist_pfoEnergyTotal__7->SetBinContent(39,1); hist_pfoEnergyTotal__7->SetBinContent(42,1); hist_pfoEnergyTotal__7->SetBinContent(43,2); hist_pfoEnergyTotal__7->SetBinContent(45,2); hist_pfoEnergyTotal__7->SetBinContent(46,1); hist_pfoEnergyTotal__7->SetBinContent(47,2); hist_pfoEnergyTotal__7->SetBinContent(48,2); hist_pfoEnergyTotal__7->SetBinContent(49,3); hist_pfoEnergyTotal__7->SetBinContent(50,2); hist_pfoEnergyTotal__7->SetBinContent(51,2); hist_pfoEnergyTotal__7->SetBinContent(53,1); hist_pfoEnergyTotal__7->SetBinContent(55,7); hist_pfoEnergyTotal__7->SetBinContent(56,1); hist_pfoEnergyTotal__7->SetBinContent(57,1); hist_pfoEnergyTotal__7->SetBinContent(59,5); hist_pfoEnergyTotal__7->SetBinContent(61,4); hist_pfoEnergyTotal__7->SetBinContent(62,5); hist_pfoEnergyTotal__7->SetBinContent(63,2); hist_pfoEnergyTotal__7->SetBinContent(64,6); hist_pfoEnergyTotal__7->SetBinContent(65,8); hist_pfoEnergyTotal__7->SetBinContent(66,2); hist_pfoEnergyTotal__7->SetBinContent(67,5); hist_pfoEnergyTotal__7->SetBinContent(68,8); hist_pfoEnergyTotal__7->SetBinContent(69,11); hist_pfoEnergyTotal__7->SetBinContent(70,11); hist_pfoEnergyTotal__7->SetBinContent(71,6); hist_pfoEnergyTotal__7->SetBinContent(72,9); hist_pfoEnergyTotal__7->SetBinContent(73,10); hist_pfoEnergyTotal__7->SetBinContent(74,16); hist_pfoEnergyTotal__7->SetBinContent(75,11); hist_pfoEnergyTotal__7->SetBinContent(76,22); hist_pfoEnergyTotal__7->SetBinContent(77,21); hist_pfoEnergyTotal__7->SetBinContent(78,40); hist_pfoEnergyTotal__7->SetBinContent(79,27); hist_pfoEnergyTotal__7->SetBinContent(80,45); hist_pfoEnergyTotal__7->SetBinContent(81,79); hist_pfoEnergyTotal__7->SetBinContent(82,107); hist_pfoEnergyTotal__7->SetBinContent(83,152); hist_pfoEnergyTotal__7->SetBinContent(84,202); hist_pfoEnergyTotal__7->SetBinContent(85,266); hist_pfoEnergyTotal__7->SetBinContent(86,396); hist_pfoEnergyTotal__7->SetBinContent(87,536); hist_pfoEnergyTotal__7->SetBinContent(88,766); hist_pfoEnergyTotal__7->SetBinContent(89,869); hist_pfoEnergyTotal__7->SetBinContent(90,1082); hist_pfoEnergyTotal__7->SetBinContent(91,1242); hist_pfoEnergyTotal__7->SetBinContent(92,1051); hist_pfoEnergyTotal__7->SetBinContent(93,848); hist_pfoEnergyTotal__7->SetBinContent(94,612); hist_pfoEnergyTotal__7->SetBinContent(95,477); hist_pfoEnergyTotal__7->SetBinContent(96,315); hist_pfoEnergyTotal__7->SetBinContent(97,204); hist_pfoEnergyTotal__7->SetBinContent(98,146); hist_pfoEnergyTotal__7->SetBinContent(99,97); hist_pfoEnergyTotal__7->SetBinContent(100,59); hist_pfoEnergyTotal__7->SetBinContent(101,47); hist_pfoEnergyTotal__7->SetBinContent(102,40); hist_pfoEnergyTotal__7->SetBinContent(103,21); hist_pfoEnergyTotal__7->SetBinContent(104,16); hist_pfoEnergyTotal__7->SetBinContent(105,13); hist_pfoEnergyTotal__7->SetBinContent(106,8); hist_pfoEnergyTotal__7->SetBinContent(107,4); hist_pfoEnergyTotal__7->SetBinContent(108,3); hist_pfoEnergyTotal__7->SetBinContent(109,8); hist_pfoEnergyTotal__7->SetBinContent(110,3); hist_pfoEnergyTotal__7->SetBinContent(112,1); hist_pfoEnergyTotal__7->SetBinContent(113,2); hist_pfoEnergyTotal__7->SetBinContent(114,3); hist_pfoEnergyTotal__7->SetBinContent(115,4); hist_pfoEnergyTotal__7->SetBinContent(116,2); hist_pfoEnergyTotal__7->SetBinContent(117,1); hist_pfoEnergyTotal__7->SetBinContent(119,1); hist_pfoEnergyTotal__7->SetBinContent(120,1); hist_pfoEnergyTotal__7->SetBinContent(126,1); hist_pfoEnergyTotal__7->SetBinContent(168,1); hist_pfoEnergyTotal__7->SetBinContent(218,1); hist_pfoEnergyTotal__7->SetEntries(10000); hist_pfoEnergyTotal__7->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#ff6666"); hist_pfoEnergyTotal__7->SetLineColor(ci); hist_pfoEnergyTotal__7->SetLineWidth(2); ci = TColor::GetColor("#ff6666"); hist_pfoEnergyTotal__7->SetMarkerColor(ci); hist_pfoEnergyTotal__7->SetMarkerStyle(0); hist_pfoEnergyTotal__7->SetMarkerSize(1.2); hist_pfoEnergyTotal__7->GetXaxis()->SetRange(1,1000); hist_pfoEnergyTotal__7->GetXaxis()->SetNdivisions(506); hist_pfoEnergyTotal__7->GetXaxis()->SetLabelFont(42); hist_pfoEnergyTotal__7->GetXaxis()->SetLabelOffset(0.015); hist_pfoEnergyTotal__7->GetXaxis()->SetLabelSize(0.06); hist_pfoEnergyTotal__7->GetXaxis()->SetTitleSize(0.07); hist_pfoEnergyTotal__7->GetXaxis()->SetTitleFont(42); hist_pfoEnergyTotal__7->GetYaxis()->SetNdivisions(506); hist_pfoEnergyTotal__7->GetYaxis()->SetLabelFont(42); hist_pfoEnergyTotal__7->GetYaxis()->SetLabelOffset(0.015); hist_pfoEnergyTotal__7->GetYaxis()->SetLabelSize(0.06); hist_pfoEnergyTotal__7->GetYaxis()->SetTitleSize(0.07); hist_pfoEnergyTotal__7->GetYaxis()->SetTitleOffset(1.2); hist_pfoEnergyTotal__7->GetYaxis()->SetTitleFont(42); hist_pfoEnergyTotal__7->GetZaxis()->SetLabelFont(42); hist_pfoEnergyTotal__7->GetZaxis()->SetLabelOffset(0.015); hist_pfoEnergyTotal__7->GetZaxis()->SetLabelSize(0.06); hist_pfoEnergyTotal__7->GetZaxis()->SetTitleSize(0.07); hist_pfoEnergyTotal__7->GetZaxis()->SetTitleOffset(1.2); hist_pfoEnergyTotal__7->GetZaxis()->SetTitleFont(42); hist_pfoEnergyTotal__7->Draw("HISTsame"); TH1F *hist_pfoEnergyTotal__8 = new TH1F("hist_pfoEnergyTotal__8","hist_pfoEnergyTotal",500,0,500); hist_pfoEnergyTotal__8->SetBinContent(24,1); hist_pfoEnergyTotal__8->SetBinContent(26,1); hist_pfoEnergyTotal__8->SetBinContent(27,1); hist_pfoEnergyTotal__8->SetBinContent(29,1); hist_pfoEnergyTotal__8->SetBinContent(33,1); hist_pfoEnergyTotal__8->SetBinContent(34,1); hist_pfoEnergyTotal__8->SetBinContent(37,1); hist_pfoEnergyTotal__8->SetBinContent(39,3); hist_pfoEnergyTotal__8->SetBinContent(40,1); hist_pfoEnergyTotal__8->SetBinContent(41,2); hist_pfoEnergyTotal__8->SetBinContent(43,2); hist_pfoEnergyTotal__8->SetBinContent(45,3); hist_pfoEnergyTotal__8->SetBinContent(46,3); hist_pfoEnergyTotal__8->SetBinContent(48,1); hist_pfoEnergyTotal__8->SetBinContent(49,1); hist_pfoEnergyTotal__8->SetBinContent(50,2); hist_pfoEnergyTotal__8->SetBinContent(51,1); hist_pfoEnergyTotal__8->SetBinContent(52,2); hist_pfoEnergyTotal__8->SetBinContent(54,1); hist_pfoEnergyTotal__8->SetBinContent(55,4); hist_pfoEnergyTotal__8->SetBinContent(56,2); hist_pfoEnergyTotal__8->SetBinContent(57,1); hist_pfoEnergyTotal__8->SetBinContent(58,4); hist_pfoEnergyTotal__8->SetBinContent(59,2); hist_pfoEnergyTotal__8->SetBinContent(60,2); hist_pfoEnergyTotal__8->SetBinContent(61,4); hist_pfoEnergyTotal__8->SetBinContent(62,3); hist_pfoEnergyTotal__8->SetBinContent(63,4); hist_pfoEnergyTotal__8->SetBinContent(64,8); hist_pfoEnergyTotal__8->SetBinContent(65,8); hist_pfoEnergyTotal__8->SetBinContent(66,8); hist_pfoEnergyTotal__8->SetBinContent(67,5); hist_pfoEnergyTotal__8->SetBinContent(68,2); hist_pfoEnergyTotal__8->SetBinContent(69,4); hist_pfoEnergyTotal__8->SetBinContent(70,6); hist_pfoEnergyTotal__8->SetBinContent(71,11); hist_pfoEnergyTotal__8->SetBinContent(72,7); hist_pfoEnergyTotal__8->SetBinContent(73,10); hist_pfoEnergyTotal__8->SetBinContent(74,8); hist_pfoEnergyTotal__8->SetBinContent(75,18); hist_pfoEnergyTotal__8->SetBinContent(76,16); hist_pfoEnergyTotal__8->SetBinContent(77,15); hist_pfoEnergyTotal__8->SetBinContent(78,41); hist_pfoEnergyTotal__8->SetBinContent(79,27); hist_pfoEnergyTotal__8->SetBinContent(80,48); hist_pfoEnergyTotal__8->SetBinContent(81,77); hist_pfoEnergyTotal__8->SetBinContent(82,110); hist_pfoEnergyTotal__8->SetBinContent(83,144); hist_pfoEnergyTotal__8->SetBinContent(84,210); hist_pfoEnergyTotal__8->SetBinContent(85,261); hist_pfoEnergyTotal__8->SetBinContent(86,402); hist_pfoEnergyTotal__8->SetBinContent(87,544); hist_pfoEnergyTotal__8->SetBinContent(88,744); hist_pfoEnergyTotal__8->SetBinContent(89,954); hist_pfoEnergyTotal__8->SetBinContent(90,1083); hist_pfoEnergyTotal__8->SetBinContent(91,1208); hist_pfoEnergyTotal__8->SetBinContent(92,1099); hist_pfoEnergyTotal__8->SetBinContent(93,820); hist_pfoEnergyTotal__8->SetBinContent(94,609); hist_pfoEnergyTotal__8->SetBinContent(95,437); hist_pfoEnergyTotal__8->SetBinContent(96,316); hist_pfoEnergyTotal__8->SetBinContent(97,206); hist_pfoEnergyTotal__8->SetBinContent(98,132); hist_pfoEnergyTotal__8->SetBinContent(99,97); hist_pfoEnergyTotal__8->SetBinContent(100,68); hist_pfoEnergyTotal__8->SetBinContent(101,41); hist_pfoEnergyTotal__8->SetBinContent(102,37); hist_pfoEnergyTotal__8->SetBinContent(103,24); hist_pfoEnergyTotal__8->SetBinContent(104,19); hist_pfoEnergyTotal__8->SetBinContent(105,15); hist_pfoEnergyTotal__8->SetBinContent(106,11); hist_pfoEnergyTotal__8->SetBinContent(107,5); hist_pfoEnergyTotal__8->SetBinContent(108,4); hist_pfoEnergyTotal__8->SetBinContent(109,8); hist_pfoEnergyTotal__8->SetBinContent(110,4); hist_pfoEnergyTotal__8->SetBinContent(111,3); hist_pfoEnergyTotal__8->SetBinContent(112,1); hist_pfoEnergyTotal__8->SetBinContent(113,2); hist_pfoEnergyTotal__8->SetBinContent(114,1); hist_pfoEnergyTotal__8->SetBinContent(115,1); hist_pfoEnergyTotal__8->SetBinContent(118,2); hist_pfoEnergyTotal__8->SetBinContent(119,1); hist_pfoEnergyTotal__8->SetBinContent(123,1); hist_pfoEnergyTotal__8->SetBinContent(167,1); hist_pfoEnergyTotal__8->SetBinContent(170,1); hist_pfoEnergyTotal__8->SetEntries(10000); hist_pfoEnergyTotal__8->SetStats(0); ci = TColor::GetColor("#0000ff"); hist_pfoEnergyTotal__8->SetLineColor(ci); hist_pfoEnergyTotal__8->SetLineWidth(2); ci = TColor::GetColor("#0000ff"); hist_pfoEnergyTotal__8->SetMarkerColor(ci); hist_pfoEnergyTotal__8->SetMarkerStyle(0); hist_pfoEnergyTotal__8->SetMarkerSize(1.2); hist_pfoEnergyTotal__8->GetXaxis()->SetRange(1,1000); hist_pfoEnergyTotal__8->GetXaxis()->SetNdivisions(506); hist_pfoEnergyTotal__8->GetXaxis()->SetLabelFont(42); hist_pfoEnergyTotal__8->GetXaxis()->SetLabelOffset(0.015); hist_pfoEnergyTotal__8->GetXaxis()->SetLabelSize(0.06); hist_pfoEnergyTotal__8->GetXaxis()->SetTitleSize(0.07); hist_pfoEnergyTotal__8->GetXaxis()->SetTitleFont(42); hist_pfoEnergyTotal__8->GetYaxis()->SetNdivisions(506); hist_pfoEnergyTotal__8->GetYaxis()->SetLabelFont(42); hist_pfoEnergyTotal__8->GetYaxis()->SetLabelOffset(0.015); hist_pfoEnergyTotal__8->GetYaxis()->SetLabelSize(0.06); hist_pfoEnergyTotal__8->GetYaxis()->SetTitleSize(0.07); hist_pfoEnergyTotal__8->GetYaxis()->SetTitleOffset(1.2); hist_pfoEnergyTotal__8->GetYaxis()->SetTitleFont(42); hist_pfoEnergyTotal__8->GetZaxis()->SetLabelFont(42); hist_pfoEnergyTotal__8->GetZaxis()->SetLabelOffset(0.015); hist_pfoEnergyTotal__8->GetZaxis()->SetLabelSize(0.06); hist_pfoEnergyTotal__8->GetZaxis()->SetTitleSize(0.07); hist_pfoEnergyTotal__8->GetZaxis()->SetTitleOffset(1.2); hist_pfoEnergyTotal__8->GetZaxis()->SetTitleFont(42); hist_pfoEnergyTotal__8->Draw("HISTsame"); TLegend *leg = new TLegend(0.2,0.6,0.6,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(2); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("hist_pfoEnergyTotal","Nominal (89.96 GeV)","lp"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerSize(1.2); entry->SetTextFont(62); entry=leg->AddEntry("hist_pfoEnergyTotal","20mm cut (89.76 GeV)","lp"); ci = TColor::GetColor("#ff6666"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); ci = TColor::GetColor("#ff6666"); entry->SetMarkerColor(ci); entry->SetMarkerSize(1.2); entry->SetTextFont(62); entry=leg->AddEntry("hist_pfoEnergyTotal","50mm cut (89.76 GeV)","lp"); ci = TColor::GetColor("#0000ff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); ci = TColor::GetColor("#0000ff"); entry->SetMarkerColor(ci); entry->SetMarkerSize(1.2); entry->SetTextFont(62); leg->Draw(); c1->Modified(); c1->cd(); c1->SetSelected(c1); }
void hPYphocalc(){ gStyle->SetOptStat(kFALSE); const int maxNpart = 100; int sth=0, Gth=0; TFile *f = TFile::Open(outG); if(sth==0){TString dirname = "std";} else if(sth==1){TString dirname ="Gri055";} else {TString dirname ="Gri101";} TObjString* dataname = (TObjString*)f->Get(Form("dataname")); TObjString* histoname = (TObjString*)f->Get(Form("histoname")); TFile *fdata = TFile::Open(dataname->GetName()); TString name; if(Gth==0) name = "G0"; else if(Gth<nGlau) name = Form("Glau_%d",Gth); else name = Form("bin_%d",Gth-nGlau+1); TObjString* Glaubername = (TObjString*)f->Get(Form("%s/%s/Glaubername",dirname.Data(),name.Data())); TVectorD* k0 = (TVectorD*)f->Get(Form("%s/%s/k0",dirname.Data(),name.Data())); TVectorD* theta0 = (TVectorD*)f->Get(Form("%s/%s/theta0",dirname.Data(),name.Data())); TVectorD* xmin = (TVectorD*)f->Get(Form("%s/%s/xmin",dirname.Data(),name.Data())); TVectorD* xmax = (TVectorD*)f->Get(Form("%s/%s/xmax",dirname.Data(),name.Data())); TVectorD* thetabest = (TVectorD*)f->Get(Form("%s/%s/thetabest",dirname.Data(),name.Data())); TVectorD* kbest = (TVectorD*)f->Get(Form("%s/%s/kbest",dirname.Data(),name.Data())); TVectorD* kpoint = (TVectorD*)f->Get(Form("%s/%s/kpoint",dirname.Data(),name.Data())); TVectorD* NcollAver = (TVectorD*)f->Get(Form("%s/%s/NcollAver",dirname.Data(),name.Data())); TVectorD* centbin = (TVectorD*)f->Get(Form("%s/%s/centbin",dirname.Data(),name.Data())); TFile *fGlauber = TFile::Open(Glaubername->GetName()); //(*k0)[0]=1.39; (*kbest)[0]=0.425; //(*theta0)[0]=3.41; (*thetabest)[0]=1.30; TF1 *gammafun[maxNpart]; TF1 *gammafunevt[maxNpart]; TF1 *gammafunnucl[maxNpart]; TF1 *gammafunnuclNcoll[maxNpart]; double kevt = (*k0)[0]-(*kbest)[0]; for(int iNpart=0;iNpart<maxNpart;iNpart++){ gammafun[iNpart] = new TF1("gammafun","TMath::GammaDist(x,[0],0,[1])",0,200); gammafunevt[iNpart] = new TF1("gammafunevt","TMath::GammaDist(x,[0],0,[1])",0,200); gammafunnucl[iNpart] = new TF1("gammafunnucl","TMath::GammaDist(x,[0],0,[1])",0,200); gammafunnuclNcoll[iNpart] = new TF1("gammafunnuclNcoll","TMath::GammaDist(x,[0],0,[1])",0,200); double k_=(*k0)[0]+(*kbest)[0]*(iNpart-2); double theta_=(*theta0)[0]+(*thetabest)[0]*TMath::Log(iNpart-1); gammafun[iNpart]->SetParameter(0,k_); //[1]: k value gammafun[iNpart]->SetParameter(1,theta_); //[2]: theta value gammafunevt[iNpart]->SetParameter(0,kevt); gammafunevt[iNpart]->SetParameter(1,theta_); gammafunnucl[iNpart]->SetParameter(0,(*kbest)[0]); gammafunnucl[iNpart]->SetParameter(1,theta_); gammafunnuclNcoll[iNpart]->SetParameter(0,(*kbest)[0]*(iNpart-1)); gammafunnuclNcoll[iNpart]->SetParameter(1,theta_); if(iNpart==2){ gammafunnuclNcoll[iNpart]->SetNpx(1e4); gammafunnuclNcoll[iNpart]->SetRange(1e-11,200); } } TTree *t = (TTree*)fGlauber->Get("nt_p_Pb"); Float_t Ncoll, Npart, B; Long_t Nevent; t->SetBranchAddress("Ncoll",&Ncoll); t->SetBranchAddress("Npart",&Npart); t->SetBranchAddress("B",&B); Nevent = (Long_t) t->GetEntries(); Long_t Ev; Int_t Bino; Double_t Para, Para_nucl, Para_p, Para_evt, Bi_Para_nucl, Bi_Para_evt; double yUCM[8]={}; double yPCM[8]={}; double yVCM[8]={}; double yUCM_[200]={}; double yPCM_[200]={}; double yVCM_[200]={}; double C=1e-4; double PNcoll[maxNpart]={}; TH1D *histo_obs = (TH1D*)fdata->Get(histoname->GetName()); TH1D *histo_obs_norm = (TH1D*)histo_obs->Clone(); histo_obs_norm->Scale(1/histo_obs->Integral()); TH1D* hUCM = new TH1D("hUCM","hUCM",200,0,200); TH1D* hPCM = new TH1D("hPCM","hPCM",200,0,200); TH1D* hVCM = new TH1D("hVCM","hVCM",200,0,200); TH2D* NcollvsET = new TH2D("NcollvsET","NcollvsET",100,0,100,2000,0,400); for(Ev=0;Ev<Nevent;Ev++){ t->GetEntry(Ev); PNcoll[(int)Ncoll]++; } for(int i=0;i<maxNpart;i++){ PNcoll[i]/=Nevent; cout<<PNcoll[i]<<"\t"; } cout<<endl; for(Ev=0;Ev<Nevent;Ev++){ if(Ev%100000==0) cout<<"\t"<<"Have run "<<Ev<<" events"<<endl; t->GetEntry(Ev); Para = gammafun[(int)Npart]->GetRandom(); Para_nucl = gammafunnuclNcoll[(int)Npart]->GetRandom(); Para_p = gammafunnuclNcoll[(int)Npart]->GetRandom(); Para_evt = 0; for(int i=0;i<N-1;i++) if(Para>=(*kpoint)[i] && Para<(*kpoint)[i+1]) int ibin = i; for(int Bino=0;Bino<Ncoll;Bino++){ Bi_Para_evt = gammafunevt[(int)Npart]->GetRandom(); Para_evt += Bi_Para_evt; } double PNcollET = gammafun[(int)Npart]->Eval(Para); // double k = gammafun[(int)Npart]->GetParameter(0); double theta=(*theta0)[0]+(*thetabest)[0]*TMath::Log(Npart-1); double YNcollUCM = C*Ncoll; double YNcollPCM = C/1.0/(*kbest)[0]/theta*(Para_nucl); double YNcollVCM = C/2.0*(Para_nucl/(*kbest)[0]/theta+Ncoll); yUCM[ibin] += PNcoll[(int)Ncoll]*PNcollET*YNcollUCM; yPCM[ibin] += PNcoll[(int)Ncoll]*PNcollET*YNcollPCM; yVCM[ibin] += PNcoll[(int)Ncoll]*PNcollET*YNcollVCM; yUCM_[(int)Para] += PNcoll[(int)Ncoll]*PNcollET*YNcollUCM; yPCM_[(int)Para] += PNcoll[(int)Ncoll]*PNcollET*YNcollPCM; yVCM_[(int)Para] += PNcoll[(int)Ncoll]*PNcollET*YNcollVCM; NcollvsET->Fill(Ncoll,Para); } for(int ibin=1;ibin<hUCM->GetNbinsX();ibin++){ hUCM->SetBinContent(ibin,yUCM_[ibin-1]); hPCM->SetBinContent(ibin,yPCM_[ibin-1]); hVCM->SetBinContent(ibin,yVCM_[ibin-1]); } TCanvas *c1 = new TCanvas(); TCanvas *c2 = new TCanvas(); c1->SetLogy(); c2->SetLogx(); c2->SetLogy(); c2->SetLogz(); c1->cd(); TH1D* hFrame = new TH1D("","",200,0,200); hFrame->SetTitle(""); hFrame->GetXaxis()->SetTitle("HF #Sigma E_{T} |#eta|>4"); hFrame->GetYaxis()->SetTitle("Yield no units"); hFrame->GetXaxis()->SetRangeUser(0,150); hFrame->GetYaxis()->SetRangeUser(1e-6,1); hFrame->Draw(); histo_obs_norm->SetMarkerStyle(20); histo_obs_norm->SetMarkerSize(1.0); histo_obs_norm->SetMarkerColor(1); histo_obs_norm->Draw("Psame"); hUCM->SetMarkerStyle(24); hUCM->SetMarkerSize(1.0); hUCM->SetMarkerColor(2); hPCM->SetMarkerStyle(29); hPCM->SetMarkerSize(1.0); hPCM->SetMarkerColor(4); hVCM->SetMarkerStyle(34); hVCM->SetMarkerSize(1.0); hVCM->SetMarkerColor(5); hUCM->Draw("Psame"); hPCM->Draw("Psame"); hVCM->Draw("Psame"); TLegend *leg = new TLegend(0.1,0.2,0.5,0.45); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetTextFont(42); leg->SetTextSize(0.03); leg->AddEntry(histo_obs_norm,"minimum bias events","lp"); leg->AddEntry(hUCM,"hard scattering events(UCM)","lp"); leg->AddEntry(hPCM,"hard scattering events(PCM)","lp"); leg->AddEntry(hVCM,"hard scattering events(VCM)","lp"); leg->Draw("same"); c1->Print("paperfig3_CMS.png"); c2->cd(); gStyle->SetOptStat("nemr"); NcollvsET->GetXaxis()->SetTitle("Ncoll"); NcollvsET->GetYaxis()->SetTitle("HF #Sigma E_{T} |#eta|>4"); NcollvsET->Draw("colz"); c2->Print("NcollvsET2D.png"); ofstream fstr("result_CMS.dat"); fstr<<"i"<<"\t"<<"centbin"<<"\t"<<"kpoint"<<"\t"<<"NcollAver"<<"\t"<<"UCM"<<"\t"<<"PCM"<<"\t"<<"VCM"<<"\t"<<"pho1"<<"\t"<<"pho2"<<"\t"<<"MB"<<endl; for(int i=0;i<N-1;i++){ fstr<<i<<"\t"<<(*centbin)[i]*100<<"% to "<<(*centbin)[i+1]*100<<"% \t"<<(*kpoint)[i]<<" to "<<(*kpoint)[i+1]<<"\t"<<(*NcollAver)[i]<<"\t"<<yUCM[i]<<"\t"<<yPCM[i]<<"\t"<<yVCM[i]<<"\t"<<yPCM[i]/yUCM[i]<<"\t"<<yVCM[i]/yUCM[i]<<"\t"<<"undetermined"<<endl; } }
void PlotWrite(TFile* input, TFile* output, TString output_folder, TString canvas, TString Hist_data, TString Hist_emu, TString XAxisLabel, TString YAxisLabel="Events", int rebin, int xAxisRange, TString Opt="") { // Setup the canvas TCanvas *c1= new TCanvas(canvas,canvas,800,700); c1->SetLogy(1); // Get the histograms from the files if(Opt == "eta" || Opt == "phi") { if(Opt == "eta") { TH2F *Data2 = (TH2F*)input->Get(Hist_data); TH1D *Data = Data2->ProjectionX(); if(rebin>0) Data->Rebin(rebin); if(xAxisRange>0) Data->GetXaxis()->SetRangeUser(0,xAxisRange); TH2F *Emu2 = (TH2F*)input->Get(Hist_emu); TH1D *Emu = Emu2->ProjectionX(); if(rebin>0) Emu->Rebin(rebin); if(xAxisRange>0) Emu->GetXaxis()->SetRangeUser(0,xAxisRange); } if(Opt == "phi") { TH2F *Data2 = (TH2F*)input->Get(Hist_data); TH1D *Data = Data2->ProjectionY(); if(rebin>0) Data->Rebin(rebin); if(xAxisRange>0) Data->GetXaxis()->SetRangeUser(0,xAxisRange); TH2F *Emu2 = (TH2F*)input->Get(Hist_emu); TH1D *Emu = Emu2->ProjectionY(); if(rebin>0) Emu->Rebin(rebin); if(xAxisRange>0) Emu->GetXaxis()->SetRangeUser(0,xAxisRange); } } else { TH1D *Data = (TH1D*)input->Get(Hist_data); if(rebin>0) Data->Rebin(rebin); if(xAxisRange>0) Data->GetXaxis()->SetRangeUser(0,xAxisRange); TH1D *Emu = (TH1D*)input->Get(Hist_emu); if(rebin>0) Emu->Rebin(rebin); if(xAxisRange>0) Emu->GetXaxis()->SetRangeUser(0,xAxisRange); } // Add the X axis label Emu->GetXaxis()->SetTitle(XAxisLabel); Emu->GetYaxis()->SetTitle(YAxisLabel); Emu->GetYaxis()->SetTitleSize(0.06); Emu->GetXaxis()->SetTitleSize(0.06); Emu->SetLineWidth(2); Emu->SetTitleOffset(1.10,"y"); Emu->SetTitleOffset(0.80,"x"); // Marker type for data Data->SetMarkerStyle(20); Data->SetMarkerColor(kRed); // plot them if (gPad->GetLogy()){ Emu->SetMaximum(TMath::Max(Emu->GetMaximum(),Data->GetMaximum())*5); } else { Emu->SetMaximum(TMath::Max(Emu->GetMaximum(),Data->GetMaximum())*1.75); } Emu->DrawCopy("hist"); Data->DrawCopy("psame"); //make Legend TLegend * aLegend = new TLegend(0.646,0.768,0.746,0.868,NULL,"brNDC"); aLegend->SetFillColor(0); aLegend->SetLineColor(0); aLegend->SetTextSize(0.05); aLegend->AddEntry(Emu,TString("Emulator"), "L"); aLegend->AddEntry(Data,TString("Hardware"), "P"); aLegend->DrawClone("same"); gPad->RedrawAxis(); //write canvas as png c1->Print(TString(output_folder+canvas+".png")); //write canvas to output file output->cd(); c1->Write(); return; }
void draw(std::vector<TH1F*> h, TString name, TString xTitle, double xmin, double xmax, double ymin, double ymax, TString legHeader = "", bool legRIGHT = true, bool legTOP = true, bool logX = false, bool logY = false, bool stat = false, double scale = -9., int rebin = -1, int orbin = -1, TString option = "", int nclus = 99) { //double ymin_ratio, double ymax_ratio, TCanvas* can = new TCanvas(name,name,900,900); can->cd(); if (logX) gPad->SetLogx(); if (logY) gPad->SetLogy(); double legymax, legymin, legxmin, legxmax; if(legHeader == "BENCHMARKS COMPARISON") { legxmin = (legRIGHT ? 0.58 : 0.18); legxmax = legxmin+0.20; legymax = (legTOP ? 0.90 : 0.15); legymin = legymax-0.35; } TLegend* leg = new TLegend(legxmin,legymin,legxmax,legymax); leg->SetTextSize(0.024); leg->SetFillColor(0); leg->SetLineColor(0); TString options = (option=="" ? "pe" : option); //normalize and set y range ymax=0.; h[0]->Sumw2(); double norm = 10000.; for (size_t i=0; i<h.size(); i++) { if(h[i]->GetNbinsX() != orbin) cout << "WARNING: orbin for " << h[i]->GetName() << " are " << h[i]->GetNbinsX() << endl; //debug - shift of h[][] wrt clu[][] if (rebin>0) h[i]->Rebin(rebin); scale = norm/(h[i]->Integral()); h[i]->Scale(scale); if (h[i]->GetMaximum() > ymax) ymax = h[i]->GetMaximum(); } ymax = ymax*1.2; for (size_t i=0; i<h.size(); i++) { h[i]->GetXaxis()->SetRangeUser(xmin,xmax); h[i]->GetXaxis()->SetTitle(xTitle); h[i]->SetMinimum(ymin); h[i]->SetMaximum(ymax); h[i]->GetYaxis()->SetLabelSize(0.03); h[i]->GetYaxis()->SetTitleOffset(1); h[i]->GetYaxis()->SetTitleSize(0.04); string nam = ""; if(legHeader == "BENCHMARKS COMPARISON"){ if(i==(h.size()-1)){ nam = translate(clu[nclus][0].c_str()); leg->AddEntry(h[i],nam.c_str(),"l"); //to print all for bench comp } else { nam = translate(clu[nclus][i+1].c_str()); leg->AddEntry(h[i],nam.c_str(),"l"); //to print all for bench comp } } else if(i==(h.size()-1)) { h[i]->SetLineColor(kRed); //to print benchmark always red. nam = translate(clu[nclus][0].c_str()); leg->AddEntry(h[i],nam.c_str(),"l"); //to print only benchmark } if (i==1) options = options + (stat ? "sames" : "same"); //once is enought h[i]->Draw(options); } leg->Draw("same"); drawPrivate(0.025); //Ncl.. can->Update(); can->SaveAs(Outfolder+name+".png"); }
void plotgvsr(){ int xbin=0; //xbin<1 int xpt=0; int xtheta=0; //xtheta<5 TFile *f = TFile::Open("mergedV_Sum.root"); TFile *fProd = TFile::Open("mergedV_Prod.root"); TVectorD *vecDr = f->Get(Form("D_%d/r",xbin)); TVectorD *vecDg2 = f->Get(Form("D_%d/D_%d/D_%d/G2",xbin,xpt,xtheta)); TVectorD *vecDsigma2 = f->Get(Form("D_%d/D_%d/sigma2",xbin,xpt)); TVectorD *vecDV = f->Get(Form("D_%d/D_%d/V",xbin,xpt)); TVectorD *vecDavgmult = f->Get(Form("D_%d/avgmult",xbin)); TVectorD *vecDr_ = fProd->Get(Form("D_%d/r",xbin)); TVectorD *vecDg2_ = fProd->Get(Form("D_%d/D_%d/D_%d/G2",xbin,xpt,xtheta)); TVectorD *vecDsigma2_ = fProd->Get(Form("D_%d/D_%d/sigma2",xbin,xpt)); TVectorD *vecDV_ = fProd->Get(Form("D_%d/D_%d/V",xbin,xpt)); TVectorD *vecDavgmult_ = fProd->Get(Form("D_%d/avgmult",xbin)); double *r = vecDr->GetMatrixArray(); double *g2 = vecDg2->GetMatrixArray(); double *sigma2 = vecDsigma2->GetMatrixArray(); double *V = vecDV->GetMatrixArray(); double *avgmult = vecDavgmult->GetMatrixArray(); double *r_ = vecDr_->GetMatrixArray(); double *g2_ = vecDg2_->GetMatrixArray(); double *sigma2_ = vecDsigma2_->GetMatrixArray(); double *V_ = vecDV_->GetMatrixArray(); double *avgmult_ = vecDavgmult_->GetMatrixArray(); TCanvas *c1 = new TCanvas; c1->SetLogy(); TGraph *gr=new TGraph(nstepr,r,g2); TGraph *grProd=new TGraph(nstepr,r_,g2_); gr->GetXaxis()->SetTitle("r"); gr->GetYaxis()->SetTitle("|G^{#theta}(ir)|"); gr->GetXaxis()->SetRangeUser(0.1,0.4); gr->GetYaxis()->SetRangeUser(1e-8,2); gr->SetTitle(""); gr->SetMarkerSize(1); gr->SetMarkerColor(1); grProd->SetMarkerColor(4); gr->SetMarkerStyle(20); grProd->SetMarkerStyle(29); gr->Draw("AP"); grProd->Draw("Psame"); TLatex *t= new TLatex(); t->SetNDC(); if(xtheta==0) t->DrawLatex(0.2,0.8,Form("%d < mult <%d, theta = %d", trkbin[xbin+1],trkbin[xbin],xtheta)); else t->DrawLatex(0.2,0.8,Form("%d < mult <%d, theta = #frac{%d}{%d}#pi", trkbin[xbin+1],trkbin[xbin],xtheta,ntheta*nn)); double inV2 = 5.81474986447428899e-02; TF1 *gcl = new TF1("gcl","TMath::Power(exp(-[0]*x*x/4)*TMath::BesselJ0([1]*x),2)",0,1); TF1 *gclProd = new TF1("gclProd","TMath::Power(exp(-[0]*x*x/4)*TMath::BesselJ0([1]*x),2)",0,1); //gcl->SetParameters(sigma2[xtheta],V[xtheta]*sigma2[xtheta]); //gcl->SetParameters(300,0.065*300); cout<<sigma2[xtheta]<<"\t"<<V[xtheta]<<"\t"<<avgmult[xbin]<<endl; gcl->SetParameters(sigma2[xtheta]+V[xtheta]*V[xtheta]*avgmult[xbin]*avgmult[xbin]-inV2*inV2*avgmult[xbin]*avgmult[xbin],inV2*avgmult[xbin]); gclProd->SetParameters(sigma2_[xtheta]+V_[xtheta]*V_[xtheta]*avgmult_[xbin]*avgmult_[xbin]-inV2*inV2*avgmult_[xbin]*avgmult_[xbin],inV2*avgmult_[xbin]); gcl->SetLineColor(2); gclProd->SetLineColor(3); TLegend *leg = new TLegend(0.6,0.45,0.8,0.65); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.04); leg->AddEntry(gr,"LYZ Sum Analysis result","P"); leg->AddEntry(grProd,"LYZ Prod Analysis result","P"); leg->AddEntry(gcl,"theoretical prediction","L"); leg->Draw("same"); gcl->Draw("same"); c1->Print("gvsr.png"); f->Close(); }
void plotDistribution( TChain* data , TChain *mc , TCut sel , TCut vtxweight , char* var , int nbins , float xmin , float xmax , char* xtitle , char* plottitle = "" , bool printplot = false , bool residual = false , bool log = false ){ //-------------------------------------- // define histograms and TGraphs //-------------------------------------- TH1F* hdata = new TH1F(Form("hdata_%i" , iplot),Form("hdata_%i" , iplot),nbins,xmin,xmax); TH1F* hmc = new TH1F(Form("hmc_%i" , iplot),Form("hmc_%i" , iplot),nbins,xmin,xmax); TH1F* hmc_novtx = new TH1F(Form("hmc_novtx_%i" , iplot),Form("hmc_novtx%i" , iplot),nbins,xmin,xmax); hdata->Sumw2(); hmc->Sumw2(); TGraphAsymmErrors* grdata = new TGraphAsymmErrors(); TGraphAsymmErrors* grmc = new TGraphAsymmErrors(); TH1F* hdata_denom = new TH1F(Form("hdata_denom_%i",iplot),"",nbins,xmin,xmax); TH1F* hmc_denom = new TH1F(Form("hmc_denom_%i" ,iplot),"",nbins,xmin,xmax); //-------------------------------------- // set up canvas and pads //-------------------------------------- TCanvas *can = new TCanvas(Form("can_%i",iplot),Form("can_%i",iplot),600,600); can->cd(); if( log ) gPad->SetLogy(); TPad *mainpad = new TPad("mainpad","mainpad",0.0,0.0,1.0,0.8); if( residual ){ mainpad->Draw(); mainpad->cd(); if( log ) mainpad->SetLogy(); } //-------------------------------------- // fill histos and TGraphs //-------------------------------------- data->Draw(Form("min(%s,%f)>>hdata_%i" , var,xmax-0.0001,iplot),sel); mc ->Draw(Form("min(%s,%f)>>hmc_%i" , var,xmax-0.0001,iplot),sel*vtxweight); mc ->Draw(Form("min(%s,%f)>>hmc_novtx_%i" , var,xmax-0.0001,iplot),sel); for( int ibin = 1 ; ibin <= nbins ; ibin++ ){ hdata_denom->SetBinContent(ibin,hdata->Integral()); hmc_denom->SetBinContent(ibin,hmc->Integral()); } grdata->BayesDivide(hdata,hdata_denom); grmc->BayesDivide(hmc_novtx,hmc_denom); //-------------------------------------- // get efficiencies and errors //-------------------------------------- /* float ndata1 = (float) hdata->GetBinContent(1); float ndata = (float) hdata->Integral(); float effdata = 1-ndata1 / ndata; // TGraphAsymmErrors* grdata_temp = new TGraphAsymmErrors(); // TH1F* hdata_num_temp = new TH1F(Form("hdata_num_temp_%i",iplot),"",1,0,1); // TH1F* hdata_den_temp = new TH1F(Form("hdata_den_temp_%i",iplot),"",1,0,1); // hdata_num_temp->SetBinContent(1,ndata-ndata1); // hdata_den_temp->SetBinContent(1,ndata); // grdata_temp->BayesDivide(hdata_num_temp,hdata_den_temp); //float effdataerr = sqrt(ndata1) / ndata; float effdataerr = 0.5 * ( grdata->GetErrorYlow(0) + grdata->GetErrorYhigh(0) ); //float effdataerr = 0.5 * ( grdata_temp->GetErrorYlow(0) + grdata_temp->GetErrorYhigh(0) ); float nmc1 = (float) hmc->GetBinContent(1); float nmc = (float) hmc->Integral(); float effmc = 1-nmc1 / nmc; //float effmcerr = hmc->GetBinError(1) / nmc; float effmcerr = 0.5 * ( grmc->GetErrorYlow(0) + grmc->GetErrorYhigh(0) ); float datatot = hdata->Integral(); float mctot = hmc->Integral(); cout << endl; cout << plottitle << endl; cout << "Data eff " << Form("%.2f +/- %.3f",effdata,effdataerr) << endl; cout << "MC eff " << Form("%.2f +/- %.3f",effmc ,effmcerr) << endl; cout << "Data/MC " << Form("%.2f +/- %.2f",ratio ,ratioerr) << endl; */ float ndata = hdata->Integral(); float ndata1 = hdata->Integral(2,20); float ndata2 = hdata->Integral(3,20); float ndata3 = hdata->Integral(4,20); float ndata4 = hdata->Integral(5,20); float ndata5 = hdata->Integral(6,20); float nmc = hmc->Integral(); float nmc1 = hmc->Integral(2,20); float nmc2 = hmc->Integral(3,20); float nmc3 = hmc->Integral(4,20); float nmc4 = hmc->Integral(5,20); float nmc5 = hmc->Integral(6,20); float effdata1 = ndata1/ndata; float effdata2 = ndata2/ndata; float effdata3 = ndata3/ndata; float effdata4 = ndata4/ndata; float effdata5 = ndata5/ndata; float effmc1 = nmc1/nmc; float effmc2 = nmc2/nmc; float effmc3 = nmc3/nmc; float effmc4 = nmc4/nmc; float effmc5 = nmc5/nmc; float effdata1err = getBinomialError(ndata1,ndata); float effdata2err = getBinomialError(ndata2,ndata); float effdata3err = getBinomialError(ndata3,ndata); float effdata4err = getBinomialError(ndata4,ndata); float effdata5err = getBinomialError(ndata5,ndata); float effmc1err = getBinomialError(nmc1,nmc); float effmc2err = getBinomialError(nmc2,nmc); float effmc3err = getBinomialError(nmc3,nmc); float effmc4err = getBinomialError(nmc4,nmc); float effmc5err = getBinomialError(nmc5,nmc); float ratio1 = effdata1/effmc1; float ratio2 = effdata2/effmc2; float ratio3 = effdata3/effmc3; float ratio4 = effdata4/effmc4; float ratio5 = effdata5/effmc5; float ratio1err = ratio1 * sqrt(pow(effdata1err/effdata1,2)+pow(effmc1err/effmc1,2)); float ratio2err = ratio2 * sqrt(pow(effdata2err/effdata2,2)+pow(effmc2err/effmc2,2)); float ratio3err = ratio3 * sqrt(pow(effdata3err/effdata3,2)+pow(effmc3err/effmc3,2)); float ratio4err = ratio4 * sqrt(pow(effdata4err/effdata4,2)+pow(effmc4err/effmc4,2)); float ratio5err = ratio5 * sqrt(pow(effdata5err/effdata5,2)+pow(effmc5err/effmc5,2)); //cout << endl << endl << plottitle << endl; int left = 20; // char* delimstart = "|"; // char* delim = "|"; // char* delimend = "|"; // char* pm = "+/-"; char* delimstart = ""; char* delim = "&"; char* delimend = "\\\\"; char* pm = "$\\pm$"; char* hline = "\\hline"; cout << endl; cout << hline << endl; cout << hline << endl; cout << delimstart << setw(10) << histLabel(plottitle) << setw(4) << delim << setw(left) << "$>$ 1 GeV" << setw(4) << delim << setw(left) << "$>$ 2 GeV" << setw(4) << delim << setw(left) << "$>$ 3 GeV" << setw(4) << delim << setw(left) << "$>$ 4 GeV" << setw(4) << delim << setw(left) << "$>$ 5 GeV" << setw(4) << delimend << endl; cout << hline << endl; cout << delimstart << setw(10) << "data" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata1,pm,effdata1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata2,pm,effdata2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata3,pm,effdata3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata4,pm,effdata4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata5,pm,effdata5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "mc" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc1,pm,effmc1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc2,pm,effmc2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc3,pm,effmc3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc4,pm,effmc4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc5,pm,effmc5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "data/mc" << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio1,pm,ratio1err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio2,pm,ratio2err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio3,pm,ratio3err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio4,pm,ratio4err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio5,pm,ratio5err) << setw(4) << delimend << endl; //-------------------------------------- // draw stuff //-------------------------------------- hdata->Scale(1.0/hdata->Integral()); hmc->Scale(1.0/hmc->Integral()); if( log ) hmc->GetYaxis()->SetRangeUser(0.0001,5); else hmc->GetYaxis()->SetRangeUser(0.0,1); hmc->GetXaxis()->SetTitle(xtitle); hmc->SetLineColor(2); hmc->SetMarkerColor(2); hmc->DrawNormalized("hist"); hmc->DrawNormalized("sameE1"); hdata->SetLineColor(4); hdata->SetMarkerColor(4); hdata->Draw("sameE1"); grdata->SetLineColor(6); grmc->SetLineColor(7); //grdata->Draw("sameP"); //grmc->Draw("sameP"); TLegend *leg = new TLegend(0.6,0.7,0.8,0.9); leg->AddEntry(hdata , "data" , "lp"); leg->AddEntry(hmc , "MC" , "lp"); leg->SetBorderSize(0); leg->SetFillColor(0); leg->Draw(); TLatex *t = new TLatex(); t->SetNDC(); if( TString(plottitle).Contains("el") ) t->DrawLatex(0.6,0.6,"electrons"); if( TString(plottitle).Contains("mu") ) t->DrawLatex(0.6,0.6,"muons"); if( TString(plottitle).Contains("0j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 0"); if( TString(plottitle).Contains("1j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 1"); if( TString(plottitle).Contains("2j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 2"); if( TString(plottitle).Contains("3j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 3"); if( TString(plottitle).Contains("4j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 4"); //-------------------------------------- // draw residual plots //-------------------------------------- if( residual ){ can->cd(); TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0); respad->Draw(); respad->cd(); respad->SetGridy(); TH1F* hratio = (TH1F*) hdata->Clone(Form("hratio_%i",iplot)); hratio->Divide(hmc); hratio->SetMarkerColor(1); hratio->SetLineColor(1); hratio->Draw(); hratio->GetYaxis()->SetRangeUser(0.5,1.5); hratio->GetYaxis()->SetNdivisions(5); hratio->GetYaxis()->SetLabelSize(0.2); hratio->GetXaxis()->SetLabelSize(0.0); TLine line; line.DrawLine(xmin,1.0,xmax,1.0); } //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel+"tkisonew>20"); //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel); if( printplot ) can->Print(Form("plots/%s.pdf",plottitle)); iplot++; // TCanvas *c2 = new TCanvas(); // c2->cd(); // grdata->Draw("AP"); }
void JER_FCCee_vs_CLIC_conformal_Zuds100_myCLIC() { //=========Macro generated from canvas: c1/A Simple Graph Example //========= (Thu May 17 12:00:25 2018) by ROOT version6.08/00 TCanvas *c1 = new TCanvas("c1", "A Simple Graph Example",2,51,800,700); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c1->SetHighLightColor(2); c1->Range(-0.2266667,1.283784,1.106667,8.040541); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetPhi(150); c1->SetLeftMargin(0.17); c1->SetRightMargin(0.08); c1->SetTopMargin(0.08); c1->SetBottomMargin(0.18); c1->SetFrameLineWidth(2); c1->SetFrameBorderMode(0); c1->SetFrameLineWidth(2); c1->SetFrameBorderMode(0); Double_t xAxis11[14] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.925, 0.95, 0.975, 1}; TH1F *ResVsCosTheta__11 = new TH1F("ResVsCosTheta__11","RMS_{90}(E_{j}) / Mean_{90}(E_{j}) vs |cos(#theta)|",13, xAxis11); ResVsCosTheta__11->SetBinContent(1,4.720301); ResVsCosTheta__11->SetBinContent(2,4.735073); ResVsCosTheta__11->SetBinContent(3,4.429979); ResVsCosTheta__11->SetBinContent(4,4.161036); ResVsCosTheta__11->SetBinContent(5,4.56193); ResVsCosTheta__11->SetBinContent(6,4.619762); ResVsCosTheta__11->SetBinContent(7,4.61053); ResVsCosTheta__11->SetBinContent(8,4.636955); ResVsCosTheta__11->SetBinContent(9,4.862062); ResVsCosTheta__11->SetBinContent(10,4.842597); ResVsCosTheta__11->SetBinContent(11,6.005219); ResVsCosTheta__11->SetBinContent(12,8.532589); ResVsCosTheta__11->SetBinContent(13,20.53576); ResVsCosTheta__11->SetBinError(1,0.1808823); ResVsCosTheta__11->SetBinError(2,0.1746558); ResVsCosTheta__11->SetBinError(3,0.1531225); ResVsCosTheta__11->SetBinError(4,0.1448687); ResVsCosTheta__11->SetBinError(5,0.1546639); ResVsCosTheta__11->SetBinError(6,0.1508406); ResVsCosTheta__11->SetBinError(7,0.1406199); ResVsCosTheta__11->SetBinError(8,0.1358532); ResVsCosTheta__11->SetBinError(9,0.1328214); ResVsCosTheta__11->SetBinError(10,0.2715593); ResVsCosTheta__11->SetBinError(11,0.3160641); ResVsCosTheta__11->SetBinError(12,0.438869); ResVsCosTheta__11->SetBinError(13,1.057646); ResVsCosTheta__11->SetMinimum(2.5); ResVsCosTheta__11->SetMaximum(7.5); ResVsCosTheta__11->SetEntries(13); ResVsCosTheta__11->SetStats(0); ResVsCosTheta__11->SetLineWidth(2); ResVsCosTheta__11->SetMarkerStyle(24); ResVsCosTheta__11->SetMarkerSize(1.2); ResVsCosTheta__11->GetXaxis()->SetTitle("|cos(#theta)|"); ResVsCosTheta__11->GetXaxis()->SetNdivisions(506); ResVsCosTheta__11->GetXaxis()->SetLabelFont(42); ResVsCosTheta__11->GetXaxis()->SetLabelOffset(0.015); ResVsCosTheta__11->GetXaxis()->SetLabelSize(0.06); ResVsCosTheta__11->GetXaxis()->SetTitleSize(0.07); ResVsCosTheta__11->GetXaxis()->SetTitleFont(42); ResVsCosTheta__11->GetYaxis()->SetTitle("RMS_{90}(E_{j}) / Mean_{90}(E_{j}) [%]"); ResVsCosTheta__11->GetYaxis()->SetNdivisions(506); ResVsCosTheta__11->GetYaxis()->SetLabelFont(42); ResVsCosTheta__11->GetYaxis()->SetLabelOffset(0.015); ResVsCosTheta__11->GetYaxis()->SetLabelSize(0.06); ResVsCosTheta__11->GetYaxis()->SetTitleSize(0.07); ResVsCosTheta__11->GetYaxis()->SetTitleOffset(0.95); ResVsCosTheta__11->GetYaxis()->SetTitleFont(42); ResVsCosTheta__11->GetZaxis()->SetLabelFont(42); ResVsCosTheta__11->GetZaxis()->SetLabelOffset(0.015); ResVsCosTheta__11->GetZaxis()->SetLabelSize(0.06); ResVsCosTheta__11->GetZaxis()->SetTitleSize(0.07); ResVsCosTheta__11->GetZaxis()->SetTitleOffset(1.2); ResVsCosTheta__11->GetZaxis()->SetTitleFont(42); ResVsCosTheta__11->Draw(""); Double_t xAxis12[14] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.925, 0.95, 0.975, 1}; TH1F *ResVsCosTheta__12 = new TH1F("ResVsCosTheta__12","RMS_{90}(E_{j}) / Mean_{90}(E_{j}) vs |cos(#theta)|",13, xAxis12); ResVsCosTheta__12->SetBinContent(1,4.40504); ResVsCosTheta__12->SetBinContent(2,4.35462); ResVsCosTheta__12->SetBinContent(3,4.454359); ResVsCosTheta__12->SetBinContent(4,4.18309); ResVsCosTheta__12->SetBinContent(5,4.366775); ResVsCosTheta__12->SetBinContent(6,4.006863); ResVsCosTheta__12->SetBinContent(7,4.36426); ResVsCosTheta__12->SetBinContent(8,4.475314); ResVsCosTheta__12->SetBinContent(9,4.870826); ResVsCosTheta__12->SetBinContent(10,5.268826); ResVsCosTheta__12->SetBinContent(11,6.97412); ResVsCosTheta__12->SetBinContent(12,10.08); ResVsCosTheta__12->SetBinContent(13,21.51662); ResVsCosTheta__12->SetBinError(1,0.1701815); ResVsCosTheta__12->SetBinError(2,0.1620622); ResVsCosTheta__12->SetBinError(3,0.154987); ResVsCosTheta__12->SetBinError(4,0.1468882); ResVsCosTheta__12->SetBinError(5,0.1491662); ResVsCosTheta__12->SetBinError(6,0.1323183); ResVsCosTheta__12->SetBinError(7,0.1341105); ResVsCosTheta__12->SetBinError(8,0.1320847); ResVsCosTheta__12->SetBinError(9,0.1342177); ResVsCosTheta__12->SetBinError(10,0.2959268); ResVsCosTheta__12->SetBinError(11,0.3691096); ResVsCosTheta__12->SetBinError(12,0.5212247); ResVsCosTheta__12->SetBinError(13,1.109635); ResVsCosTheta__12->SetMinimum(0); ResVsCosTheta__12->SetMaximum(10); ResVsCosTheta__12->SetEntries(13); ResVsCosTheta__12->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#ff6666"); ResVsCosTheta__12->SetLineColor(ci); ResVsCosTheta__12->SetLineWidth(2); ci = TColor::GetColor("#ff6666"); ResVsCosTheta__12->SetMarkerColor(ci); ResVsCosTheta__12->SetMarkerStyle(25); ResVsCosTheta__12->SetMarkerSize(1.2); ResVsCosTheta__12->GetXaxis()->SetTitle("|cos(#theta)|"); ResVsCosTheta__12->GetXaxis()->SetNdivisions(506); ResVsCosTheta__12->GetXaxis()->SetLabelFont(42); ResVsCosTheta__12->GetXaxis()->SetLabelOffset(0.015); ResVsCosTheta__12->GetXaxis()->SetLabelSize(0.06); ResVsCosTheta__12->GetXaxis()->SetTitleSize(0.07); ResVsCosTheta__12->GetXaxis()->SetTitleFont(42); ResVsCosTheta__12->GetYaxis()->SetTitle("RMS_{90}(E_{j}) / Mean_{90}(E_{j}) [%]"); ResVsCosTheta__12->GetYaxis()->SetNdivisions(506); ResVsCosTheta__12->GetYaxis()->SetLabelFont(42); ResVsCosTheta__12->GetYaxis()->SetLabelOffset(0.015); ResVsCosTheta__12->GetYaxis()->SetLabelSize(0.06); ResVsCosTheta__12->GetYaxis()->SetTitleSize(0.07); ResVsCosTheta__12->GetYaxis()->SetTitleOffset(0.95); ResVsCosTheta__12->GetYaxis()->SetTitleFont(42); ResVsCosTheta__12->GetZaxis()->SetLabelFont(42); ResVsCosTheta__12->GetZaxis()->SetLabelOffset(0.015); ResVsCosTheta__12->GetZaxis()->SetLabelSize(0.06); ResVsCosTheta__12->GetZaxis()->SetTitleSize(0.07); ResVsCosTheta__12->GetZaxis()->SetTitleOffset(1.2); ResVsCosTheta__12->GetZaxis()->SetTitleFont(42); ResVsCosTheta__12->Draw("same"); TLegend *leg = new TLegend(0.2,0.7,0.58,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(2); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("ResVsCosTheta","FCCee","lp"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(24); entry->SetMarkerSize(1.2); entry->SetTextFont(62); entry=leg->AddEntry("ResVsCosTheta","CLIC","lp"); ci = TColor::GetColor("#ff6666"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); ci = TColor::GetColor("#ff6666"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(25); entry->SetMarkerSize(1.2); entry->SetTextFont(62); leg->Draw(); c1->Modified(); c1->cd(); c1->SetSelected(c1); }
void drawMassPlot( const std::string& dirName, const std::string& category, TH1D* h1_data, TH1D* h1_thq, TH1D* h1_ggh, TH1D* h1_vbf, TH1D* h1_wzh, TH1D* h1_tth, const std::string& suffix ) { DrawBase* db = new DrawBase("mgg"); db->set_lumi(19700.); TFile* dummyFile = TFile::Open("dummy.root", "recreate"); db->add_dataFile(dummyFile, "Data"); TGraphAsymmErrors* gr_data = fitTools::getGraphPoissonErrors( h1_data, false ); gr_data->SetMarkerStyle(20); gr_data->SetMarkerSize(1.3); h1_thq->SetFillColor(kWhite); h1_tth->SetFillColor(kGray); h1_wzh->SetFillColor(28); h1_vbf->SetFillColor(90); h1_ggh->SetFillColor(46); h1_thq->SetLineColor(kBlack); h1_tth->SetLineColor(kBlack); h1_wzh->SetLineColor(kBlack); h1_vbf->SetLineColor(kBlack); h1_ggh->SetLineColor(kBlack); TString category_tstr(category); bool isLeptonic = category_tstr.Contains("leptonic"); THStack stack; if( !isLeptonic ) { stack.Add(h1_ggh); stack.Add(h1_vbf); } stack.Add(h1_wzh); stack.Add(h1_tth); stack.Add(h1_thq); std::string channelName_legend = (isLeptonic) ? "Leptonic Channel" : "Hadronic Channel"; float yMin_leg = (isLeptonic) ? 0.9-4.*0.07 : 0.9-6.*0.07; TLegend* legend = new TLegend( 0.62, yMin_leg, 0.9, 0.92, channelName_legend.c_str() ); legend->SetTextFont(42); legend->SetFillColor(kWhite); legend->SetTextSize(0.038); legend->SetTextColor(kBlack); if( useCS ) legend->AddEntry( gr_data, "Data CS", "P" ); else legend->AddEntry( gr_data, "Data", "P" ); legend->AddEntry( h1_thq, "tHq (Ct = -1)", "F" ); legend->AddEntry( h1_tth, "ttH (125)", "F" ); legend->AddEntry( h1_wzh, "VH (125)", "F" ); if( !isLeptonic ) { legend->AddEntry( h1_vbf, "VBF H (125)", "F" ); legend->AddEntry( h1_ggh, "ggF H (125)", "F" ); } float yMax = 0.; float yMax_data = h1_data->GetMaximum(); if( yMax_data>0. ) { if( yMax_data < 1.5 ) yMax=3.5; else if( yMax_data < 2.5 ) yMax=6.; else yMax=yMax_data*2.; } else { float yMax_mc = h1_thq->GetMaximum()*1.2; yMax = 1.8*yMax_mc; } TH2D* h2_axes = new TH2D( "axes", "", 10, 100., 180., 10, 0., yMax); h2_axes->SetXTitle( "Diphoton Mass [GeV]"); h2_axes->SetYTitle( "Events / (1 GeV)"); TCanvas* c1 = new TCanvas("c1", "", 600, 600); c1->cd(); TPaveText* labelTop = db->get_labelTop(); h2_axes->Draw(); legend->Draw("same"); labelTop->Draw("same"); stack.Draw("histo same"); if( BLINDED ) { TLine* lineBlind_low = new TLine( 115., 0., 115., yMax ); TLine* lineBlind_hi = new TLine( 135., 0., 135., yMax ); lineBlind_low->SetLineColor(46); lineBlind_hi ->SetLineColor(46); lineBlind_low->SetLineStyle(2); lineBlind_hi ->SetLineStyle(2); lineBlind_low->SetLineWidth(2); lineBlind_hi ->SetLineWidth(2); lineBlind_low->Draw("same"); lineBlind_hi ->Draw("same"); } gr_data->Draw("p same"); gPad->RedrawAxis(); std::string canvasName = dirName + "/" + category + "/mggPlot_" + category; if( suffix!="" ) canvasName = canvasName + "_" + suffix; std::string canvasName_eps = canvasName + ".eps"; std::string canvasName_png = canvasName + ".png"; c1->SaveAs(canvasName_eps.c_str()); c1->SaveAs(canvasName_png.c_str()); delete c1; delete h2_axes; delete legend; }
//================================================ void SignalShape(const int savePlot = 1) { const int icent = 0; const int nfiles = 2; const char *filename[nfiles] = {"Pico.Run13.pp500.jpsi.pt1.5.pt1.0.yield.root","Pico.Run13.pp500.jpsi.VtxCut.pt1.5.pt1.0.yield.root"}; const TString legName[nfiles] = {"W/o vtx cut","W/ vtx cut"}; const char *saveTitle = "Run13_VtxCut"; TFile *file[nfiles]; TH1F *hInvMass[nfiles][nPtBins]; TH1F *hMean[nfiles]; TH1F *hSigma[nfiles]; TH1F *hYield[nfiles]; for(int i=0; i<nfiles; i++) { file[i] = TFile::Open(Form("Rootfiles/%s",filename[i]),"read"); hMean[i] = (TH1F*)file[i]->Get(Form("Jpsi_FitMean_cent%s",cent_Title[icent])); hMean[i]->SetName(Form("%s_%d",hMean[i]->GetName(),i)); hSigma[i] = (TH1F*)file[i]->Get(Form("Jpsi_FitSigma_cent%s",cent_Title[icent])); hSigma[i]->SetName(Form("%s_%d",hSigma[i]->GetName(),i)); hYield[i] = (TH1F*)file[i]->Get(Form("Jpsi_BinCountYield_cent%s",cent_Title[icent])); hYield[i]->SetName(Form("%s_%d",hYield[i]->GetName(),i)); for(int ipt=0; ipt<nPtBins; ipt++) { hInvMass[i][ipt] = (TH1F*)file[i]->Get(Form("Jpsi_Signal_cent%s_pt%s_save",cent_Title[icent],pt_Name[ipt])); hInvMass[i][ipt]->SetName(Form("%s_%d",hInvMass[i][ipt]->GetName(),i)); } } // invariant mass distribution TCanvas *c = new TCanvas("InvMass","InvMass",1200,700); c->Divide(nPtBins/2+nPtBins%2,2); TLegend *leg = new TLegend(0.6,0.65,0.85,0.85); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.05); for(int ipt=0; ipt<nPtBins; ipt++) { c->cd(ipt+1); SetPadMargin(gPad,0.13, 0.13, 0.03, 0.1); for(int i=0; i<nfiles; i++) { int bin = hInvMass[i][ipt]->FindFixBin(3.09); hInvMass[i][ipt]->Scale(1./hInvMass[i][ipt]->GetBinContent(bin)); hInvMass[i][ipt]->SetMaximum(1.5); hInvMass[i][ipt]->SetMarkerStyle(21+i*4); hInvMass[i][ipt]->SetMarkerColor(color[i]); hInvMass[i][ipt]->SetLineColor(color[i]); hInvMass[i][ipt]->SetYTitle("a.u."); ScaleHistoTitle(hInvMass[i][ipt],0.05,1,0.035,0.05,1.4,0.035,62); if(i==0) hInvMass[i][ipt]->Draw(); else hInvMass[i][ipt]->Draw("sames"); if(ipt==0) leg->AddEntry(hInvMass[i][ipt],legName[i].Data(),"PL"); } TPaveText *t1 = GetTitleText(Form("%1.0f < p_{T,#mu#mu} < %1.0f GeV/c",ptBins_low[ipt],ptBins_high[ipt]),0.06); t1->Draw(); } c->cd(1); leg->Draw(); if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/comp_JpsiSig/%s_InvMass_cent%s.pdf",run_type,saveTitle,cent_Title[icent])); // mean & sigma TList *list = new TList; for(int i=0; i<nfiles; i++) { hMean[i]->SetMarkerStyle(21+i*4); hMean[i]->SetMarkerColor(color[i]); hMean[i]->SetLineColor(color[i]); list->Add(hMean[i]); } c = drawHistos(list,"mean","Mean of J/#Psi mass peak",false,0,10,false,2.5,3.5,false,true,legName,true,"",0.5,0.7,0.3,0.5,true,0.04,0.04,false,1,false,false); if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/comp_JpsiSig/%s_JpsiMean_cent%s.pdf",run_type,saveTitle,cent_Title[icent])); list->Clear(); for(int i=0; i<nfiles; i++) { hSigma[i]->SetMarkerStyle(21+i*4); hSigma[i]->SetMarkerColor(color[i]); hSigma[i]->SetLineColor(color[i]); list->Add(hSigma[i]); } c = drawHistos(list,"sigma","Width of J/#Psi mass peak",false,0,10,false,2.5,3.5,false,true,legName,true,"",0.55,0.75,0.2,0.4,true,0.04,0.04,false,1,false,false); if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/comp_JpsiSig/%s_JpsiSigma_cent%s.pdf",run_type,saveTitle,cent_Title[icent])); list->Clear(); for(int i=0; i<nfiles; i++) { hYield[i]->Scale(1./hYield[i]->Integral()); hYield[i]->SetMarkerStyle(21+i*4); hYield[i]->SetMarkerColor(color[i]); hYield[i]->SetLineColor(color[i]); list->Add(hYield[i]); } c = drawHistos(list,"yield","Raw distribution of J/#Psi signal;p_{T} (GeV/c);Prob.",false,0,10,true,0,0.4,false,true,legName,true,"",0.55,0.75,0.6,0.8,true,0.04,0.04,false,1,false,false); if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/comp_JpsiSig/%s_RawCounts_cent%s.pdf",run_type,saveTitle,cent_Title[icent])); }
void compareMet(){ gStyle->SetOptStat(0); bool isData = true; char* file = "output/v8/ZJets_baby.root"; if( isData ) file = "../../metTemplate/output/v8/lepdata_skim_baby.root"; //if( isData ) file = "../output/V00-00-00/lepdata_skim_baby.root"; //if( isData ) file = "output/uaf/lepdata_skim_baby.root"; //if( isData ) file = "output/v8/lepdata_skim_nov4_baby_nov4json.root"; //if( isData ) file = "output/uaf/lepdata_skim_baby.root"; //if( isData ) file = "lepdata_skim_Nov4_baby.root"; cout << "Adding " << file << endl; TFile *f = TFile::Open( file ); TH1F* hee = new TH1F("hee","",75,0,150); TH1F* hmm = new TH1F("hmm","",75,0,150); TH1F* hem = new TH1F("hem","",75,0,150); TCut sel("njets>-1"); TCut ee("leptype==0&&jetptll-ptll>-5&&jetptlt-ptlt>-5&&dilmass>81&&dilmass<101"); //TCut ee("leptype==0&&dilmass>81&&dilmass<101"); TCut mm("leptype==1&&nmatchedpfmuons==2&&dilmasspf>81&&dilmasspf<101"); TCut em("leptype==2&&nmatchedpfmuons==1&&dilmass>81&&dilmass<101"); //TCut ee("leptype==0&&jetptll-ptll>-5&&jetptlt-ptlt>-5"); //TCut mm("leptype==1&&nmatchedpfmuons==2"); //TCut em("leptype==2&&nmatchedpfmuons==1"); //TCut weight("weight"); TCut weight("1"); TCanvas *c1 = new TCanvas(); c1->cd(); TPad *plotpad = new TPad("plotpad","plotpad",0.0,0.0,1.0,0.8); plotpad->Draw(); plotpad->cd(); TTree* T1 = (TTree*) f->Get("T1"); T1->Draw("TMath::Min(pfmet,149.99)>>hee",(sel+ee)*weight); T1->Draw("TMath::Min(pfmet,149.99)>>hmm",(sel+mm)*weight); T1->Draw("TMath::Min(pfmet,149.99)>>hem",(sel+em)*weight); hee->Sumw2(); hmm->Sumw2(); hem->Sumw2(); hmm->Draw(); hmm->GetXaxis()->SetTitle("pfmet (GeV)"); hee->SetLineColor(2); hee->SetMarkerColor(2); hem->SetLineColor(4); hem->SetMarkerColor(4); hmm->SetMarkerStyle(20); hem->SetMarkerStyle(24); hmm->SetMarkerSize(0.7); hee->Draw("samehist"); hem->Draw("same"); gPad->SetLogy(1); TLegend *leg = new TLegend(0.6,0.65,0.8,0.85); leg->AddEntry(hee,"ee","l"); leg->AddEntry(hmm,"#mu#mu"); leg->AddEntry(hem,"e#mu"); leg->SetFillColor(0); leg->SetBorderSize(1); leg->Draw(); // TLatex *t = new TLatex(); // t->SetNDC(); // if( isData ){ // t->DrawLatex(0.4,0.6, "CMS"); // //t->DrawLatex(0.4,0.53, "Selected Z+#geq2jet Events (DATA)"); // t->DrawLatex(0.4,0.53, "Selected Z Events (DATA)"); // t->DrawLatex(0.4,0.46, "34.0 pb^{-1} at #sqrt{s} = 7 TeV"); // }else{ // t->DrawLatex(0.4,0.6, "CMS"); // t->DrawLatex(0.4,0.53,"Selected Z+0jet Events (Z+jets MC)"); // } c1->cd(); TPad *pullpad = new TPad("pullpad","pullpad",0.0,0.8,1.0,1.0); pullpad->Draw(); pullpad->cd(); TH1F* hratio = (TH1F*) hmm->Clone(); hratio->Divide(hee); hratio->Draw(); gPad->SetGridy(); hratio->SetMinimum(0.8); hratio->SetMaximum(1.6); hratio->GetYaxis()->SetLabelSize(0.15); hratio->GetYaxis()->SetNdivisions(7); hratio->GetYaxis()->SetTitle("#mu#mu / ee "); hratio->GetXaxis()->SetTitle(""); hratio->GetYaxis()->SetTitleSize(0.2); hratio->GetYaxis()->SetTitleOffset(0.2); float cut1 = 30; float cut2 = 60; float cut3 = 120; int bin1 = hee->FindBin(cut1); int bin2 = hee->FindBin(cut2); int bin3 = hee->FindBin(cut3); cout << "ee tot " << hee->Integral() << endl; cout << "ee met>30 GeV " << hee->Integral(bin1,1000) << endl; cout << "ee met>60 GeV " << hee->Integral(bin2,1000) << endl; cout << "ee met>120 GeV " << hee->Integral(bin3,1000) << endl; cout << "mm tot " << hmm->Integral() << endl; cout << "mm met>30 GeV " << hmm->Integral(bin1,1000) << endl; cout << "mm met>60 GeV " << hmm->Integral(bin2,1000) << endl; cout << "mm met>120 GeV " << hmm->Integral(bin3,1000) << endl; int width1 = 15; int width2 = 5; cout << "|" << setw(width1) << "" << setw(width2) << "|" << setw(width1) << Form("N(met>%.0f GeV)",cut1) << setw(width2) << "|" << setw(width1) << Form("N(met>%.0f GeV)",cut2) << setw(width2) << "|" << setw(width1) << Form("N(met>%.0f GeV)",cut3) << setw(width2) << "|" << endl; cout << "|" << setw(width1) << "ee" << setw(width2) << "|" << setw(width1) << hee->Integral(bin1,1000) << setw(width2) << "|" << setw(width1) << hee->Integral(bin2,1000) << setw(width2) << "|" << setw(width1) << hee->Integral(bin3,1000) << setw(width2) << "|" << endl; cout << "|" << setw(width1) << "mm" << setw(width2) << "|" << setw(width1) << hmm->Integral(bin1,1000) << setw(width2) << "|" << setw(width1) << hmm->Integral(bin2,1000) << setw(width2) << "|" << setw(width1) << hmm->Integral(bin3,1000) << setw(width2) << "|" << endl; cout << "|" << setw(width1) << "em" << setw(width2) << "|" << setw(width1) << hem->Integral(bin1,1000) << setw(width2) << "|" << setw(width1) << hem->Integral(bin2,1000) << setw(width2) << "|" << setw(width1) << hem->Integral(bin3,1000) << setw(width2) << "|" << endl; }
//================================================ void All(const int compCount = 1, const int compEff = 1, const int compRef = 1, const int savePlot = 1) { const char* dataType[2] = {"New","Old"}; // Jpsi efficiency vs. pT const int nPtBins = nPtBins_pt; const double* ptBins_low = ptBins_low_pt; const double* ptBins_high = ptBins_high_pt; const char** ptName = pt_Name_pt; const int nCentBins = nCentBins_pt; const int* centBins_low = centBins_low_pt; const int* centBins_high = centBins_high_pt; const char** cent_Name = cent_Name_pt; const char** cent_Title = cent_Title_pt; const int kNCent = nCentBins_npart[0]; const int nbins = nPtBins -1; double xbins[nbins+1]; for(int i=0; i<nbins; i++) xbins[i] = ptBins_low[i+1]; xbins[nbins] = ptBins_high[nbins]; TList *list = new TList; if(compCount) { TFile *fSig[2]; fSig[0] = TFile::Open(Form("Rootfiles/%s.JpsiYield.pt%1.1f.pt%1.1f.root",run_type,pt1_cut,pt2_cut),"read"); fSig[1] = TFile::Open(Form("Rootfiles/old.%s.JpsiYield.pt%1.1f.pt%1.1f.root",run_type,pt1_cut,pt2_cut),"read"); TH1F *hJpsiCounts[2][7]; TCanvas *c = new TCanvas("comp_JpsiCounts", "comp_JpsiCounts", 1100, 500); c->Divide(4,2); TLegend *leg = new TLegend(0.3,0.3,0.6,0.6); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextFont(62); leg->SetTextSize(0.08); for(int k=0; k<7; k++) { for(int j=0; j<2; j++) { if(k<5) hJpsiCounts[j][k] = (TH1F*)fSig[j]->Get(Form("Jpsi_FitYield_cent%s_weight",cent_Title[k])); else hJpsiCounts[j][k] = (TH1F*)fSig[j]->Get(Form("Jpsi_FitYield_pt%s_weight",pt_Name_npart[k-5])); hJpsiCounts[j][k]->SetName(Form("%s_%d",hJpsiCounts[j][k]->GetName(),j)); hJpsiCounts[j][k]->SetMarkerStyle(21+j*4); hJpsiCounts[j][k]->SetMarkerColor(j+1); hJpsiCounts[j][k]->SetLineColor(j+1); c->cd(k+1); gPad->SetLogy(); if(k==2 || k==3) hJpsiCounts[j][k]->GetXaxis()->SetRangeUser(0.5,10); if(k==4) hJpsiCounts[j][k]->GetXaxis()->SetRangeUser(0.5,6); hJpsiCounts[j][k]->SetTitle(";;Counts"); if(k<5) hJpsiCounts[j][k]->SetXTitle("p_{T} [GeV/c]"); if(j==0) hJpsiCounts[j][k]->Draw(); else hJpsiCounts[j][k]->Draw("sames"); if(k==0) leg->AddEntry(hJpsiCounts[j][k], dataType[j], "P"); } if(k<5) TPaveText *t1 = GetTitleText(Form("%s: %s%%",run_type,cent_Name[k]),0.06); else TPaveText *t1 = GetTitleText(Form("%s: %s",run_type,pt_Title_npart[k-5]),0.06); t1->Draw(); } c->cd(8); leg->Draw(); if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_CompAll/Compare_JpsiCounts.pdf",run_type)); } if(compEff) { const char *trkEffType[6] = {"MC","Tpc","MtdMth","MuonPid","MtdTrig","TrigUnit"}; TFile *fEff[2]; fEff[0] = TFile::Open(Form("Rootfiles/%s.EmbJpsiEff.pt%1.1f.pt%1.1f.root",run_type,pt1_cut,pt2_cut),"read"); fEff[1] = TFile::Open(Form("Rootfiles/old.%s.EmbJpsiEff.pt%1.1f.pt%1.1f.root",run_type,pt1_cut,pt2_cut),"read"); const int nHistos = 6; TH1F *hJpsiPt[2][nHistos][nCentBins]; TH1F *hJpsiPtEffs[2][nHistos][nCentBins]; for(int j=0; j<2; j++) { for(int i=0; i<nHistos; i++) { for(int k=0; k<nCentBins; k++) { hJpsiPt[j][i][k] = (TH1F*)fEff[j]->Get(Form("hJpsiPt_%s_cent%s",trkEffType[i],cent_Title[k])); hJpsiPt[j][i][k]->SetName(Form("%s_file%d",hJpsiPt[j][i][k]->GetName(),j)); hJpsiPt[j][i][k]->Rebin(4); int index = i-1; if(i==0) index = 0; hJpsiPtEffs[j][i][k] = DivideTH1ForEff(hJpsiPt[j][i][k],hJpsiPt[j][index][k],Form("hJpsiPtEff_%s_cent%s_file%d",trkEffType[i],cent_Title[k],j)); } } } // various efficiency const int kcent = 0; for(int i=1; i<nHistos; i++) { hJpsiPtEffs[0][i][kcent]->Divide(hJpsiPtEffs[1][i][kcent]); list->Add(hJpsiPtEffs[0][i][kcent]); } TString legName2[5] = {"TPC tracking + p_{T,#mu} cut","MTD acceptance & response","Muon PID","MTD triggering","Trigger unit"}; c = drawHistos(list,"JpsiEff_AllEffs",Form("%s: efficiencies for J/#psi ;p_{T} (GeV/c);New/Old",run_type),true,0,15,true,0.8,1.2,false,kTRUE,legName2,true,Form("%s%%",cent_Name[kcent]),0.2,0.4,0.63,0.88,kTRUE,0.04,0.035); if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_CompAll/Compare_JpsiEff_AllTypes.pdf",run_type)); list->Clear(); } if(compRef) { TFile *fpp[2]; fpp[0] = TFile::Open(Form("Rootfiles/Paper.%s.Jpsi.root",run_type),"read"); fpp[1] = TFile::Open(Form("Rootfiles/Comb2.Paper.%s.Jpsi.root",run_type),"read"); TGraphAsymmErrors *hppJpsiVsPt[2]; TGraphAsymmErrors *hppJpsiVsCent[2]; double x, y, x1, y1; for(int j=0; j<2; j++) { hppJpsiVsPt[j] = (TGraphAsymmErrors*)fpp[j]->Get("hpp200JpsiVsPtFinalSys"); hppJpsiVsPt[j]->SetName(Form("%s_%d",hppJpsiVsPt[j]->GetName(),j)); hppJpsiVsPt[j]->SetMarkerStyle(21+j*4); hppJpsiVsPt[j]->SetMarkerColor(j+1); hppJpsiVsPt[j]->SetLineColor(j+1); offset_x(hppJpsiVsPt[j], 0.1*j); hppJpsiVsCent[j] = (TGraphAsymmErrors*)fpp[j]->Get("hpp200JpsiVsCentFinalSys"); hppJpsiVsCent[j]->SetName(Form("%s_%d",hppJpsiVsCent[j]->GetName(),j)); hppJpsiVsCent[j]->SetMarkerStyle(21+j*4); hppJpsiVsCent[j]->SetMarkerColor(j+1); hppJpsiVsCent[j]->SetLineColor(j+1); offset_x(hppJpsiVsCent[j], 0.1*j); } for(int j=0; j<2; j++) { for(int ipoint=0; ipoint<hppJpsiVsPt[j]->GetN(); ipoint++) { hppJpsiVsPt[1]->GetPoint(ipoint, x, y); hppJpsiVsPt[j]->GetPoint(ipoint, x1, y1); hppJpsiVsPt[j]->SetPoint(ipoint, x1, y1/y); hppJpsiVsPt[j]->SetPointError(ipoint, hppJpsiVsPt[j]->GetErrorXlow(ipoint), hppJpsiVsPt[j]->GetErrorXhigh(ipoint), hppJpsiVsPt[j]->GetErrorYlow(ipoint)/y, hppJpsiVsPt[j]->GetErrorYhigh(ipoint)/y); } for(int ipoint=0; ipoint<hppJpsiVsCent[j]->GetN(); ipoint++) { hppJpsiVsCent[1]->GetPoint(ipoint, x, y); hppJpsiVsCent[j]->GetPoint(ipoint, x1, y1); hppJpsiVsCent[j]->SetPoint(ipoint, x1, y1/y); hppJpsiVsCent[j]->SetPointError(ipoint, hppJpsiVsCent[j]->GetErrorXlow(ipoint), hppJpsiVsCent[j]->GetErrorXhigh(ipoint), hppJpsiVsCent[j]->GetErrorYlow(ipoint)/y, hppJpsiVsCent[j]->GetErrorYhigh(ipoint)/y); } } hppJpsiVsPt[1]->GetYaxis()->SetRangeUser(0.5,1.5); c = drawGraph(hppJpsiVsPt[1],"Ratio of pp reference;p_{T} [GeV/c];Ratio"); hppJpsiVsPt[0]->Draw("samesPEZ"); TLegend *leg = new TLegend(0.6,0.7,0.8,0.85); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextFont(62); leg->SetTextSize(0.035); leg->AddEntry(hppJpsiVsPt[0], "(STAR+PHENIX)/STAR", "P"); leg->AddEntry(hppJpsiVsPt[1], "STAR/STAR", "P"); leg->Draw(); if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_CompAll/Compare_ppRefVsPt.pdf",run_type)); hppJpsiVsCent[1]->GetXaxis()->SetRangeUser(-0.5,6.5); hppJpsiVsCent[1]->GetYaxis()->SetRangeUser(0.5,1.5); c = drawGraph(hppJpsiVsCent[1],"Ratio of pp reference;;Ratio"); hppJpsiVsCent[0]->Draw("samesPEZ"); leg->Draw(); if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_CompAll/Compare_ppRefVsCent.pdf",run_type)); } }
TEfficiency* CalcEfficHadrons(const char* fileName, Bool_t makeDraw=kFALSE) { // open the input file TFile *file = new TFile(fileName); // ******************************************** // parameters to check before running the macro // ******************************************** const Int_t NHISTS = 4; // Check the number of histograms for different particle species const Int_t NOUTPUTS = 3; const Int_t NHISTOUT[NOUTPUTS] = {1,1,1}; const Int_t IHISTOUT[NOUTPUTS][NHISTS] = {{0,-1,-1,-1},{1,-1,-1,-1},{2,-1,-1,-1}}; const Float_t CUT_RES = 0.02; Int_t style[NOUTPUTS] = {20,21,22}; Int_t color[NOUTPUTS] = {1,2,4}; const Int_t fgNumOfPtBins = 111; // Check the number of eta bins in the histograms const Int_t fgNumOfEtaBins = 16; // Check the number of E bins in the histograms const Int_t fgNumOfRBins = 45; Double_t fgPtAxis[117]= {0.0,0.01,0.02,0.03,0.04, 0.05, 0.06,0.07,0.08,0.09, 0.10,0.11, .12,0.13, .14,0.15, .16,0.17, .18,0.19, 0.2, .22, .24, .26, .28, 0.30, 0.32, .34, .36, .38, 0.40, .42, .44, .46, .48, 0.5, .52, .54, .56, .58, 0.60, 0.62, .64, .66, .68, 0.70, .72, .74, .76, .78, .80, .82, .84, .86, .88, 0.90, 0.92, .94, .96, .98, 1.00,1.05, 1.1,1.15, 1.2, 1.25, 1.3,1.35,1.40,1.45, 1.50, 1.55, 1.6,1.65, 1.7, 1.75, 1.8,1.85, 1.9,1.95, 2.0, 2.2, 2.4, 2.6, 2.8, 3.00, 3.20, 3.4, 3.6, 3.8, 4.00, 4.2, 4.4, 4.6, 4.8, 5.0, 5.5, 6.0, 6.5, 7.0, 7.50, 8.00, 8.5, 9.0, 9.5, 10.0,12.0,14.0,16.0,18.0, 20.0,25.0,30.0,35.0,40.0, 45.0, 50.0}; // declare histograms and graphs TH2F *histNum[NHISTS]; TH2F *histDen[NHISTS]; TGraphErrors *graph[NOUTPUTS]; TH1D* projYNum; TEfficiency *effic[NOUTPUTS]; char efficName[50]; // retrieve the input list of histogram. Check the TList name in the input file. TList *list = (TList*) file->Get("out1"); // retrieve the histograms in the list. Check the name of the histograms histNum[0] = (TH2F*)list->FindObject("fHistPionRec_ResPt_EmcalMC"); histNum[1] = (TH2F*)list->FindObject("fHistKaonRec_ResPt_EmcalMC"); histNum[2] = (TH2F*)list->FindObject("fHistProtonRec_ResPt_EmcalMC"); histNum[3] = (TH2F*)list->FindObject("fHistMuonRec_ResPt_EmcalMC"); // retrieve the histograms in the list. Check the name of the histograms histDen[0] = (TH2F*)list->FindObject("fHistPionAcc_EtaPt_EmcalMC"); histDen[1] = (TH2F*)list->FindObject("fHistKaonAcc_EtaPt_EmcalMC"); histDen[2] = (TH2F*)list->FindObject("fHistProtonAcc_EtaPt_EmcalMC"); histDen[3] = (TH2F*)list->FindObject("fHistMuonAcc_EtaPt_EmcalMC"); // ******************************************** Float_t x[fgNumOfPtBins]={0}, ex[fgNumOfPtBins]={0}; Float_t y[fgNumOfPtBins]={0}, ey[fgNumOfPtBins]={0}; Float_t num=0, den=0; //Int_t num=0, den=0; Float_t Res=0; // loop over different desired outputs for (int iOut=0; iOut<NOUTPUTS; iOut++) { sprintf(efficName,"effic_%d",iOut); effic[iOut] = new TEfficiency(efficName,efficName,fgNumOfPtBins,fgPtAxis); // loop over E bins for (int ix=0; ix<fgNumOfPtBins; ix++) { // initialize ET variables for a new particle species x[ix]=histNum[0]->GetXaxis()->GetBinCenter(ix+1); y[ix]=0; ex[ix]=0; ey[ix]=0; num = 0; den = 0; // loop over eta bins for (int iy=0; iy<fgNumOfEtaBins; iy++) { for (int iHist=0; iHist<NHISTOUT[iOut]; iHist++) { den += histDen[IHISTOUT[iOut][iHist]]->GetBinContent(ix+1,iy+1); // sum over all E bins in order to get total ET } } // loop over residual bins for (int iHist=0; iHist<NHISTOUT[iOut]; iHist++) { projYNum = histNum[IHISTOUT[iOut][iHist]]->ProjectionY(); for (int iy=0; iy<fgNumOfRBins; iy++) { Res = projYNum->GetBinCenter(iy+1); if (Res<CUT_RES) num += histNum[IHISTOUT[iOut][iHist]]->GetBinContent(ix+1,iy+1); // sum over all E bins in order to get total ET } } if ((num>0) && (den>0)) { effic[iOut]->SetTotalEvents(ix,den); effic[iOut]->SetPassedEvents(ix,num); y[ix] = num/den; ey[ix] = y[ix]*sqrt(1/num+1/den); //ey[ix] = ((num+1)*(num+2))/((den+2)*(den+3))-((num+1)*(num+1))/((den+2)*(den+2)); } else { y[ix] = 0; ey[ix] = 0; } } // end of loop over E bins graph[iOut] = new TGraphErrors(fgNumOfPtBins,x,y,ex,ey); // graphic of ET(>E_cut)/ET(total) for a given particle species and E cut } // end of loop over different outputs // Draw the plot if (makeDraw) { gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *c = new TCanvas("c","c",500,400); //c->SetTopMargin(0.04); //c->SetRightMargin(0.04); //c->SetLeftMargin(0.181452); //c->SetBottomMargin(0.134409); c->SetBorderSize(0); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillColor(0); c->SetFrameBorderMode(0); /* for (int i=0; i<NOUTPUTS; i++) { graph[i]->SetMarkerStyle(style[i]); graph[i]->SetMarkerColor(color[i]); graph[i]->SetLineColor(color[i]); graph[i]->SetFillColor(0); if (i == 0) { graph[i]->GetXaxis()->SetTitle("E (GeV)"); graph[i]->GetYaxis()->SetTitle("effic"); graph[i]->SetMaximum(1.0); graph[i]->SetMinimum(0.0); graph[i]->Draw("AP"); } else graph[i]->Draw("P"); } */ for (int i=0; i<NOUTPUTS; i++) { effic[i]->SetMarkerStyle(style[i]); effic[i]->SetMarkerColor(color[i]); effic[i]->SetLineColor(color[i]); effic[i]->SetFillColor(0); effic[i]->SetTitle("efficiency; p_{T} (GeV/c); #epsilon"); if (i == 0) { effic[i]->Draw(); } else effic[i]->Draw("Psame"); } TLegend *leg = new TLegend(0.65,0.2,0.95,0.5); leg->AddEntry(effic[0],"pions"); leg->AddEntry(effic[1],"kaons"); leg->AddEntry(effic[2],"protons"); //leg->AddEntry(effic[3],"muons"); leg->SetFillStyle(0); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetTextSize(0.03); leg->Draw(); } return effic[0]; }
void MakeATGCRatioHistograms() { char* dir = "/uscms_data/d2/andersj/Wjj/2012/data/Moriond2013/ReducedTrees/"; TFile* fSM = new TFile((dir + string("Lambda00_Kappa00_G00.root")).c_str()); TFile* fSM2 = new TFile((string("Lambda00_Kappa00_G00.root")).c_str()); TFile* f_L01K00G00 = new TFile((string("Lambda01_Kappa00_G00.root")).c_str()); TFile* f_L03K00G00 = new TFile((string("Lambda03_Kappa00_G00.root")).c_str()); TFile* f_L05K00G00 = new TFile((string("Lambda05_Kappa00_G00.root")).c_str()); TFile* f_L07K00G00 = new TFile((dir + string("Lambda07_Kappa00_G00.root")).c_str()); TFile* f_L09K00G00 = new TFile((dir + string("Lambda09_Kappa00_G00.root")).c_str()); TFile* f_L11K00G00 = new TFile((dir + string("Lambda11_Kappa00_G00.root")).c_str()); TFile* f_L00K05G00 = new TFile((string("Lambda00_Kappa05_G00.root")).c_str()); TFile* f_L00K11G00 = new TFile((dir + string("Lambda00_Kappa11_G00.root")).c_str()); TFile* f_L00K16G00 = new TFile((dir + string("Lambda00_Kappa16_G00.root")).c_str()); TFile* f_L00K20G00 = new TFile((dir + string("Lambda00_Kappa20_G00.root")).c_str()); TFile* f_L00K00G11 = new TFile((dir + string("Lambda00_Kappa00_G11.root")).c_str()); TFile* f_L00K00G40 = new TFile((dir + string("Lambda00_Kappa00_G40.root")).c_str()); TFile* f_L00K00G60 = new TFile((dir + string("Lambda00_Kappa00_G60.root")).c_str()); TTree* trSM = (TTree*) fSM->Get("WJet"); TTree* trSM2 = (TTree*) fSM2->Get("WJet"); TTree* tr_L01K00G00 = (TTree*) f_L01K00G00->Get("WJet"); TTree* tr_L03K00G00 = (TTree*) f_L03K00G00->Get("WJet"); TTree* tr_L05K00G00 = (TTree*) f_L05K00G00->Get("WJet"); TTree* tr_L07K00G00 = (TTree*) f_L07K00G00->Get("WJet"); TTree* tr_L09K00G00 = (TTree*) f_L09K00G00->Get("WJet"); TTree* tr_L11K00G00 = (TTree*) f_L11K00G00->Get("WJet"); TTree* tr_L00K05G00 = (TTree*) f_L00K05G00->Get("WJet"); TTree* tr_L00K11G00 = (TTree*) f_L00K11G00->Get("WJet"); TTree* tr_L00K16G00 = (TTree*) f_L00K16G00->Get("WJet"); TTree* tr_L00K20G00 = (TTree*) f_L00K20G00->Get("WJet"); TTree* tr_L00K00G11 = (TTree*) f_L00K00G11->Get("WJet"); TTree* tr_L00K00G40 = (TTree*) f_L00K00G40->Get("WJet"); TTree* tr_L00K00G60 = (TTree*) f_L00K00G60->Get("WJet"); char* dijetPt = "sqrt(JetPFCor_Pt[0]**2+JetPFCor_Pt[1]**2+2*JetPFCor_Pt[0]*JetPFCor_Pt[1]*cos(JetPFCor_Phi[0]-JetPFCor_Phi[1]))"; trSM->SetAlias("dijetPt", dijetPt); trSM2->SetAlias("dijetPt", dijetPt); tr_L01K00G00->SetAlias("dijetPt", dijetPt); tr_L03K00G00->SetAlias("dijetPt", dijetPt); tr_L05K00G00->SetAlias("dijetPt", dijetPt); tr_L07K00G00->SetAlias("dijetPt", dijetPt); tr_L09K00G00->SetAlias("dijetPt", dijetPt); tr_L11K00G00->SetAlias("dijetPt", dijetPt); tr_L00K05G00->SetAlias("dijetPt", dijetPt); tr_L00K11G00->SetAlias("dijetPt", dijetPt); tr_L00K16G00->SetAlias("dijetPt", dijetPt); tr_L00K20G00->SetAlias("dijetPt", dijetPt); tr_L00K00G11->SetAlias("dijetPt", dijetPt); tr_L00K00G40->SetAlias("dijetPt", dijetPt); tr_L00K00G60->SetAlias("dijetPt", dijetPt); // char* cutsNoBoost = "(effwt*puwt)*((W_pt<200.) && (dijetPt>70.) && (event_met_pfmet >25) &&(abs(W_muon_eta)<2.1) && (W_muon_pt>25.) && (abs(JetPFCor_Eta[0])<2.4) && (abs(JetPFCor_Eta[1])<2.4) && (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.5) &&(abs(JetPFCor_dphiMET[0])>0.4) &&(W_mt>30.) &&(JetPFCor_Pt[0]>40.) &&(JetPFCor_Pt[1]>35.) &&(JetPFCor_Pt[2]<30.) &&(JetPFCor_bDiscriminatorCSV[0]<0.244) &&(JetPFCor_bDiscriminatorCSV[1]<0.244) && (Mass2j_PFCor>70. && Mass2j_PFCor<100.))"; // char* cutsBoosted = "(effwt*puwt)*((W_pt>200.) && (event_met_pfmet >50) &&(abs(W_muon_eta)<2.1) && (W_muon_pt>30.) && (GroomedJet_CA8_pt[0]>200.) &&(abs(GroomedJet_CA8_eta[0])<2.4) &&(JetPFCor_bDiscriminatorCSV[0]<0.244) &&(GroomedJet_numberbjets <1)&&(ggdboostedWevt==1) && (GroomedJet_CA8_tau2tau1[0]<0.55) && (GroomedJet_CA8_mass[0]>70. && GroomedJet_CA8_mass[0]<100.))"; char* cutsNoBoost = "(effwt*puwt)*((W_pt<200.) && (dijetPt>70.) && (event_met_pfmet >25) && (abs(JetPFCor_Eta[0])<2.4) && (abs(JetPFCor_Eta[1])<2.4) && (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.5) &&(abs(JetPFCor_dphiMET[0])>0.4) &&(W_mt>30.) &&(JetPFCor_Pt[0]>40.) &&(JetPFCor_Pt[1]>35.) &&(JetPFCor_Pt[2]<30.) )"; char* cutsBoosted = "(effwt*puwt)*((W_pt>200.) && (event_met_pfmet >50) && (GroomedJet_CA8_pt[0]>200.) &&(abs(GroomedJet_CA8_eta[0])<2.4) )"; char* cutsNoBoostWt = "(effwt*puwt*weight)*((W_pt<200.) && (dijetPt>70.) && (event_met_pfmet >25) && (abs(JetPFCor_Eta[0])<2.4) && (abs(JetPFCor_Eta[1])<2.4) && (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.5) &&(abs(JetPFCor_dphiMET[0])>0.4) &&(W_mt>30.) &&(JetPFCor_Pt[0]>40.) &&(JetPFCor_Pt[1]>35.) &&(JetPFCor_Pt[2]<30.) )"; char* cutsBoostedWt = "(effwt*puwt*weight)*((W_pt>200.) && (event_met_pfmet >50) && (GroomedJet_CA8_pt[0]>200.) &&(abs(GroomedJet_CA8_eta[0])<2.4) )"; ///// ----- Create all the histograms ---------- double xbins[] = {100., 110., 120., 130., 140., 150., 160., 180., 200., 220., 240., 260., 300., 340., 380., 420., 500., 600.}; TH1D* hSMNoBoost = new TH1D("hSMNoBoost", "", sizeof(xbins)/ sizeof(xbins[0])-1, xbins); hSMNoBoost->Sumw2(); hSMNoBoost->SetLineWidth(2); hSMNoBoost->GetXaxis()->SetTitle("dijet p_{T} (GeV)"); hSMNoBoost->GetYaxis()->SetTitle("Ratio over SM"); TH1D* hSMNoBoost2 = hSMNoBoost->Clone("hSMNoBoost2"); TH1D* h_L01K00G00_NoBoost = hSMNoBoost->Clone("h_L01K00G00_NoBoost"); TH1D* h_L03K00G00_NoBoost = hSMNoBoost->Clone("h_L03K00G00_NoBoost"); TH1D* h_L05K00G00_NoBoost = hSMNoBoost->Clone("h_L05K00G00_NoBoost"); TH1D* h_L07K00G00_NoBoost = hSMNoBoost->Clone("h_L07K00G00_NoBoost"); TH1D* h_L09K00G00_NoBoost = hSMNoBoost->Clone("h_L09K00G00_NoBoost"); TH1D* h_L11K00G00_NoBoost = hSMNoBoost->Clone("h_L11K00G00_NoBoost"); TH1D* h_L00K05G00_NoBoost = hSMNoBoost->Clone("h_L00K05G00_NoBoost"); TH1D* h_L00K11G00_NoBoost = hSMNoBoost->Clone("h_L00K11G00_NoBoost"); TH1D* h_L00K16G00_NoBoost = hSMNoBoost->Clone("h_L00K16G00_NoBoost"); TH1D* h_L00K20G00_NoBoost = hSMNoBoost->Clone("h_L00K20G00_NoBoost"); TH1D* h_L00K00G11_NoBoost = hSMNoBoost->Clone("h_L00K00G11_NoBoost"); TH1D* h_L00K00G40_NoBoost = hSMNoBoost->Clone("h_L00K00G40_NoBoost"); TH1D* h_L00K00G60_NoBoost = hSMNoBoost->Clone("h_L00K00G60_NoBoost"); TH1D* hSMBoosted = hSMNoBoost->Clone("hSMBoosted"); TH1D* hSMBoosted2 = hSMNoBoost->Clone("hSMBoosted2"); TH1D* h_L01K00G00_Boosted = hSMNoBoost->Clone("h_L01K00G00_Boosted"); TH1D* h_L03K00G00_Boosted = hSMNoBoost->Clone("h_L03K00G00_Boosted"); TH1D* h_L05K00G00_Boosted = hSMNoBoost->Clone("h_L05K00G00_Boosted"); TH1D* h_L07K00G00_Boosted = hSMNoBoost->Clone("h_L07K00G00_Boosted"); TH1D* h_L09K00G00_Boosted = hSMNoBoost->Clone("h_L09K00G00_Boosted"); TH1D* h_L11K00G00_Boosted = hSMNoBoost->Clone("h_L11K00G00_Boosted"); TH1D* h_L00K05G00_Boosted = hSMNoBoost->Clone("h_L00K05G00_Boosted"); TH1D* h_L00K11G00_Boosted = hSMNoBoost->Clone("h_L00K11G00_Boosted"); TH1D* h_L00K16G00_Boosted = hSMNoBoost->Clone("h_L00K16G00_Boosted"); TH1D* h_L00K20G00_Boosted = hSMNoBoost->Clone("h_L00K20G00_Boosted"); TH1D* h_L00K00G11_Boosted = hSMNoBoost->Clone("h_L00K00G11_Boosted"); TH1D* h_L00K00G40_Boosted = hSMNoBoost->Clone("h_L00K00G40_Boosted"); TH1D* h_L00K00G60_Boosted = hSMNoBoost->Clone("h_L00K00G60_Boosted"); ///// ----- fill the unboosted histograms ----------- trSM->Draw("dijetPt>>hSMNoBoost", cutsNoBoost,"goff"); trSM2->Draw("dijetPt>>hSMNoBoost2", cutsNoBoostWt,"goff"); tr_L01K00G00->Draw("dijetPt>>h_L01K00G00_NoBoost", cutsNoBoostWt,"goff"); tr_L03K00G00->Draw("dijetPt>>h_L03K00G00_NoBoost", cutsNoBoostWt,"goff"); tr_L05K00G00->Draw("dijetPt>>h_L05K00G00_NoBoost", cutsNoBoostWt,"goff"); tr_L07K00G00->Draw("dijetPt>>h_L07K00G00_NoBoost", cutsNoBoost,"goff"); tr_L09K00G00->Draw("dijetPt>>h_L09K00G00_NoBoost", cutsNoBoost,"goff"); tr_L11K00G00->Draw("dijetPt>>h_L11K00G00_NoBoost", cutsNoBoost,"goff"); tr_L00K05G00->Draw("dijetPt>>h_L00K05G00_NoBoost", cutsNoBoostWt,"goff"); tr_L00K11G00->Draw("dijetPt>>h_L00K11G00_NoBoost", cutsNoBoost,"goff"); tr_L00K16G00->Draw("dijetPt>>h_L00K16G00_NoBoost", cutsNoBoost,"goff"); tr_L00K20G00->Draw("dijetPt>>h_L00K20G00_NoBoost", cutsNoBoost,"goff"); tr_L00K00G11->Draw("dijetPt>>h_L00K00G11_NoBoost", cutsNoBoost,"goff"); tr_L00K00G40->Draw("dijetPt>>h_L00K00G40_NoBoost", cutsNoBoost,"goff"); tr_L00K00G60->Draw("dijetPt>>h_L00K00G60_NoBoost", cutsNoBoost,"goff"); ///// ----- now fill the boosted histograms ----------- trSM->Draw("GroomedJet_CA8_pt[0]>>hSMBoosted", cutsBoosted,"goff"); trSM2->Draw("GroomedJet_CA8_pt[0]>>hSMBoosted2", cutsBoostedWt,"goff"); tr_L01K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L01K00G00_Boosted", cutsBoostedWt,"goff"); tr_L03K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L03K00G00_Boosted", cutsBoostedWt,"goff"); tr_L05K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L05K00G00_Boosted", cutsBoostedWt,"goff"); tr_L07K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L07K00G00_Boosted", cutsBoosted,"goff"); tr_L09K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L09K00G00_Boosted", cutsBoosted,"goff"); tr_L11K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L11K00G00_Boosted", cutsBoosted,"goff"); tr_L00K05G00->Draw("GroomedJet_CA8_pt[0]>>h_L00K05G00_Boosted", cutsBoostedWt,"goff"); tr_L00K11G00->Draw("GroomedJet_CA8_pt[0]>>h_L00K11G00_Boosted", cutsBoosted,"goff"); tr_L00K16G00->Draw("GroomedJet_CA8_pt[0]>>h_L00K16G00_Boosted", cutsBoosted,"goff"); tr_L00K20G00->Draw("GroomedJet_CA8_pt[0]>>h_L00K20G00_Boosted", cutsBoosted,"goff"); tr_L00K00G11->Draw("GroomedJet_CA8_pt[0]>>h_L00K00G11_Boosted", cutsBoosted,"goff"); tr_L00K00G40->Draw("GroomedJet_CA8_pt[0]>>h_L00K00G40_Boosted", cutsBoosted,"goff"); tr_L00K00G60->Draw("GroomedJet_CA8_pt[0]>>h_L00K00G60_Boosted", cutsBoosted,"goff"); // --- normalization scales ------ const double SM_scale = 2.729 / 149395; // SM: lambda=0, dkappa=0, dg1=0 const double L01K00G00_scale = 2.730 / 90562; const double L03K00G00_scale = 2.736 / 136932; const double L05K00G00_scale = 2.760 / 137481; const double L07K00G00_scale = 2.793 / 146345; const double L09K00G00_scale = 2.830 / 136427; const double L11K00G00_scale = 2.890 / 138886; const double L00K11G00_scale = 2.760 / 130403; const double L00K16G00_scale = 2.848 / 139865; const double L00K20G00_scale = 2.947 / 129415; const double L00K00G11_scale = 2.729 / 129386; const double L00K00G40_scale = 2.792 / 124954; const double L00K00G60_scale = 2.940 / 127922; hSMNoBoost->Scale(SM_scale); // h_L01K00G00_NoBoost->Scale(L01K00G00_scale); // h_L03K00G00_NoBoost->Scale(L03K00G00_scale); // h_L05K00G00_NoBoost->Scale(L05K00G00_scale); h_L07K00G00_NoBoost->Scale(L07K00G00_scale); h_L09K00G00_NoBoost->Scale(L09K00G00_scale); h_L11K00G00_NoBoost->Scale(L11K00G00_scale); h_L00K11G00_NoBoost->Scale(L00K11G00_scale); h_L00K16G00_NoBoost->Scale(L00K16G00_scale); h_L00K20G00_NoBoost->Scale(L00K20G00_scale); h_L00K00G11_NoBoost->Scale(L00K00G11_scale); h_L00K00G40_NoBoost->Scale(L00K00G40_scale); h_L00K00G60_NoBoost->Scale(L00K00G60_scale); hSMBoosted->Scale(SM_scale); // h_L01K00G00_Boosted->Scale(L01K00G00_scale); // h_L03K00G00_Boosted->Scale(L03K00G00_scale); // h_L05K00G00_Boosted->Scale(L05K00G00_scale); float kscale = 3.; // h_L01K00G00_Boosted->Scale(kscale); // h_L03K00G00_Boosted->Scale(kscale); // h_L05K00G00_Boosted->Scale(kscale); h_L07K00G00_Boosted->Scale(L07K00G00_scale); h_L09K00G00_Boosted->Scale(L09K00G00_scale); h_L11K00G00_Boosted->Scale(L11K00G00_scale); h_L00K11G00_Boosted->Scale(L00K11G00_scale); h_L00K16G00_Boosted->Scale(L00K16G00_scale); h_L00K20G00_Boosted->Scale(L00K20G00_scale); h_L00K00G11_Boosted->Scale(L00K00G11_scale); h_L00K00G40_Boosted->Scale(L00K00G40_scale); h_L00K00G60_Boosted->Scale(L00K00G60_scale); //----- combine boosted & unboosted histograms ------ /* TH1D* hSM = hSMBoosted->Clone("hSM"); TH1D* hSM2 = hSMBoosted2->Clone("hSM2"); TH1D* h_L01K00G00 = h_L01K00G00_Boosted->Clone("h_L01K00G00"); TH1D* h_L03K00G00 = h_L03K00G00_Boosted->Clone("h_L03K00G00"); TH1D* h_L05K00G00 = h_L05K00G00_Boosted->Clone("h_L05K00G00"); TH1D* h_L07K00G00 = h_L07K00G00_Boosted->Clone("h_L07K00G00"); TH1D* h_L09K00G00 = h_L09K00G00_Boosted->Clone("h_L09K00G00"); TH1D* h_L11K00G00 = h_L11K00G00_Boosted->Clone("h_L11K00G00"); TH1D* h_L00K11G00 = h_L00K11G00_Boosted->Clone("h_L00K11G00"); TH1D* h_L00K16G00 = h_L00K16G00_Boosted->Clone("h_L00K16G00"); TH1D* h_L00K20G00 = h_L00K20G00_Boosted->Clone("h_L00K20G00"); TH1D* h_L00K00G11 = h_L00K00G11_Boosted->Clone("h_L00K00G11"); TH1D* h_L00K00G40 = h_L00K00G40_Boosted->Clone("h_L00K00G40"); TH1D* h_L00K00G60 = h_L00K00G60_Boosted->Clone("h_L00K00G60"); TH1D* hSM = hSMNoBoost->Clone("hSM"); TH1D* hSM2 = hSMBoosted2->Clone("hSM2"); TH1D* h_L01K00G00 = h_L01K00G00_NoBoost->Clone("h_L01K00G00"); TH1D* h_L03K00G00 = h_L03K00G00_NoBoost->Clone("h_L03K00G00"); TH1D* h_L05K00G00 = h_L05K00G00_NoBoost->Clone("h_L05K00G00"); TH1D* h_L07K00G00 = h_L07K00G00_NoBoost->Clone("h_L07K00G00"); TH1D* h_L09K00G00 = h_L09K00G00_NoBoost->Clone("h_L09K00G00"); TH1D* h_L11K00G00 = h_L11K00G00_NoBoost->Clone("h_L11K00G00"); TH1D* h_L00K11G00 = h_L00K11G00_NoBoost->Clone("h_L00K11G00"); TH1D* h_L00K16G00 = h_L00K16G00_NoBoost->Clone("h_L00K16G00"); TH1D* h_L00K20G00 = h_L00K20G00_NoBoost->Clone("h_L00K20G00"); TH1D* h_L00K00G11 = h_L00K00G11_NoBoost->Clone("h_L00K00G11"); TH1D* h_L00K00G40 = h_L00K00G40_NoBoost->Clone("h_L00K00G40"); TH1D* h_L00K00G60 = h_L00K00G60_NoBoost->Clone("h_L00K00G60"); hSM->Add(hSMBoosted); hSM2->Add(hSMBoosted2); h_L01K00G00->Add(h_L01K00G00_Boosted); h_L03K00G00->Add(h_L03K00G00_Boosted); h_L05K00G00->Add(h_L05K00G00_Boosted); h_L07K00G00->Add(h_L07K00G00_Boosted); h_L09K00G00->Add(h_L09K00G00_Boosted); h_L11K00G00->Add(h_L11K00G00_Boosted); h_L00K11G00->Add(h_L00K11G00_Boosted); h_L00K16G00->Add(h_L00K16G00_Boosted); h_L00K20G00->Add(h_L00K20G00_Boosted); h_L00K00G11->Add(h_L00K00G11_Boosted); h_L00K00G40->Add(h_L00K00G40_Boosted); h_L00K00G60->Add(h_L00K00G60_Boosted); */ // --- divide aTGC histograms by the SM histogram ------ h_L01K00G00_NoBoost->Divide(hSMNoBoost2); h_L03K00G00_NoBoost->Divide(hSMNoBoost2); h_L05K00G00_NoBoost->Divide(hSMNoBoost2); h_L07K00G00_NoBoost->Divide(hSMNoBoost); h_L09K00G00_NoBoost->Divide(hSMNoBoost); h_L11K00G00_NoBoost->Divide(hSMNoBoost); h_L00K05G00_NoBoost->Divide(hSMNoBoost); h_L00K11G00_NoBoost->Divide(hSMNoBoost); h_L00K16G00_NoBoost->Divide(hSMNoBoost); h_L00K20G00_NoBoost->Divide(hSMNoBoost); h_L00K00G11_NoBoost->Divide(hSMNoBoost); h_L00K00G40_NoBoost->Divide(hSMNoBoost); h_L00K00G60_NoBoost->Divide(hSMNoBoost); h_L01K00G00_Boosted->Divide(hSMBoosted2); h_L03K00G00_Boosted->Divide(hSMBoosted2); h_L05K00G00_Boosted->Divide(hSMBoosted2); h_L07K00G00_Boosted->Divide(hSMBoosted); h_L09K00G00_Boosted->Divide(hSMBoosted); h_L11K00G00_Boosted->Divide(hSMBoosted); h_L00K05G00_Boosted->Divide(hSMBoosted); h_L00K11G00_Boosted->Divide(hSMBoosted); h_L00K16G00_Boosted->Divide(hSMBoosted); h_L00K20G00_Boosted->Divide(hSMBoosted); h_L00K00G11_Boosted->Divide(hSMBoosted); h_L00K00G40_Boosted->Divide(hSMBoosted); h_L00K00G60_Boosted->Divide(hSMBoosted); TH1D* h_L01K00G00 = getWeightedAverage(h_L01K00G00_NoBoost, h_L01K00G00_Boosted,"h_L01K00G00"); TH1D* h_L03K00G00 = getWeightedAverage(h_L03K00G00_NoBoost, h_L03K00G00_Boosted, "h_L03K00G00"); TH1D* h_L05K00G00 = getWeightedAverage(h_L05K00G00_NoBoost, h_L05K00G00_Boosted, "h_L05K00G00"); TH1D* h_L07K00G00 = getWeightedAverage(h_L07K00G00_NoBoost, h_L07K00G00_Boosted, "h_L07K00G00"); TH1D* h_L09K00G00 = getWeightedAverage(h_L09K00G00_NoBoost, h_L09K00G00_Boosted, "h_L09K00G00"); TH1D* h_L11K00G00 = getWeightedAverage(h_L11K00G00_NoBoost, h_L11K00G00_Boosted, "h_L11K00G00"); TH1D* h_L00K05G00 = getWeightedAverage(h_L00K05G00_NoBoost, h_L00K05G00_Boosted, "h_L00K05G00"); TH1D* h_L00K11G00 = getWeightedAverage(h_L00K11G00_NoBoost, h_L00K11G00_Boosted, "h_L00K11G00"); TH1D* h_L00K16G00 = getWeightedAverage(h_L00K16G00_NoBoost, h_L00K16G00_Boosted, "h_L00K16G00"); TH1D* h_L00K20G00 = getWeightedAverage(h_L00K20G00_NoBoost, h_L00K20G00_Boosted, "h_L00K20G00"); TH1D* h_L00K00G11 = getWeightedAverage(h_L00K00G11_NoBoost, h_L00K00G11_Boosted, "h_L00K00G11"); TH1D* h_L00K00G40 = getWeightedAverage(h_L00K00G40_NoBoost, h_L00K00G40_Boosted, "h_L00K00G40"); TH1D* h_L00K00G60 = getWeightedAverage(h_L00K00G60_NoBoost, h_L00K00G60_Boosted, "h_L00K00G60"); // h_L01K00G00->Divide(hSM2); // h_L03K00G00->Divide(hSM2); // h_L05K00G00->Divide(hSM2); // h_L07K00G00->Divide(hSM); // h_L09K00G00->Divide(hSM); // h_L11K00G00->Divide(hSM); // h_L00K11G00->Divide(hSM); // h_L00K16G00->Divide(hSM); // h_L00K20G00->Divide(hSM); // h_L00K00G11->Divide(hSM); // h_L00K00G40->Divide(hSM); // h_L00K00G60->Divide(hSM); // --- plot histograms ------ gROOT->ProcessLine(".L ~/tdrstyle.C"); setTDRStyle(); tdrStyle->SetErrorX(0.5); tdrStyle->SetPadLeftMargin(0.18); tdrStyle->SetPadRightMargin(0.08); tdrStyle->SetLegendBorderSize(0); tdrStyle->SetTitleYOffset(1.3); tdrStyle->SetOptStat(0); tdrStyle->SetOptFit(0); // --- Plot non-boosted events ------ TCanvas* can00 = new TCanvas("can00","",500,500); h_L01K00G00_NoBoost->GetYaxis()->SetRangeUser(0.3, 80); h_L01K00G00_NoBoost->GetXaxis()->SetMoreLogLabels(); h_L01K00G00_NoBoost->GetXaxis()->SetNoExponent(); h_L05K00G00_NoBoost->SetLineColor(4); h_L05K00G00_NoBoost->SetMarkerColor(4); h_L11K00G00_NoBoost->SetLineColor(2); h_L11K00G00_NoBoost->SetMarkerColor(2); h_L00K11G00_NoBoost->SetMarkerStyle(22); h_L00K16G00_NoBoost->SetMarkerStyle(22); h_L00K11G00_NoBoost->SetMarkerSize(1.3); h_L00K16G00_NoBoost->SetMarkerSize(1.3); h_L00K11G00_NoBoost->SetLineStyle(2); h_L00K16G00_NoBoost->SetLineStyle(2); h_L00K11G00_NoBoost->SetLineColor(4); h_L00K11G00_NoBoost->SetMarkerColor(4); h_L00K16G00_NoBoost->SetLineColor(2); h_L00K16G00_NoBoost->SetMarkerColor(2); h_L00K00G40_NoBoost->SetMarkerStyle(21); h_L00K00G60_NoBoost->SetMarkerStyle(21); h_L00K00G40_NoBoost->SetLineStyle(3); h_L00K00G60_NoBoost->SetLineStyle(3); h_L00K00G40_NoBoost->SetLineColor(4); h_L00K00G40_NoBoost->SetMarkerColor(4); h_L00K00G60_NoBoost->SetLineColor(2); h_L00K00G60_NoBoost->SetMarkerColor(2); h_L01K00G00_NoBoost->Draw(); h_L05K00G00_NoBoost->Draw("same"); h_L11K00G00_NoBoost->Draw("same"); h_L00K11G00_NoBoost->Draw("same"); h_L00K16G00_NoBoost->Draw("same"); h_L00K00G40_NoBoost->Draw("same"); h_L00K00G60_NoBoost->Draw("same"); TLegend* legend = new TLegend(0.24,0.55,0.64,0.9); legend->SetFillColor(0); legend->AddEntry(h_L01K00G00_NoBoost, "#lambda = 0.01", "PL"); legend->AddEntry(h_L05K00G00_NoBoost, "#lambda = 0.05", "PL"); legend->AddEntry(h_L11K00G00_NoBoost, "#lambda = 0.11", "PL"); legend->AddEntry(h_L00K11G00_NoBoost, "#Delta#kappa = 0.11", "PL"); legend->AddEntry(h_L00K16G00_NoBoost, "#Delta#kappa = 0.16", "PL"); legend->AddEntry(h_L00K00G40_NoBoost, "#Deltag_{1} = 0.40", "PL"); legend->AddEntry(h_L00K00G60_NoBoost, "#Deltag_{1} = 0.60", "PL"); legend->Draw(); can00->SetLogx(1); can00->SetLogy(1); can00->SaveAs("Fig_aTGC_NoBoost.png"); can00->SaveAs("Fig_aTGC_NoBoost.pdf"); // --- Plot boosted events ------ TCanvas* can11 = new TCanvas("can11","",500,500); h_L01K00G00_Boosted->GetXaxis()->SetTitle("Jet p_{T} (GeV)"); h_L01K00G00_Boosted->GetYaxis()->SetRangeUser(0.3, 500); h_L01K00G00_Boosted->GetXaxis()->SetMoreLogLabels(); h_L01K00G00_Boosted->GetXaxis()->SetNoExponent(); h_L05K00G00_Boosted->SetLineColor(4); h_L05K00G00_Boosted->SetMarkerColor(4); h_L11K00G00_Boosted->SetLineColor(2); h_L11K00G00_Boosted->SetMarkerColor(2); h_L00K11G00_Boosted->SetMarkerStyle(22); h_L00K16G00_Boosted->SetMarkerStyle(22); h_L00K11G00_Boosted->SetMarkerSize(1.3); h_L00K16G00_Boosted->SetMarkerSize(1.3); h_L00K11G00_Boosted->SetLineStyle(2); h_L00K16G00_Boosted->SetLineStyle(2); h_L00K11G00_Boosted->SetLineColor(4); h_L00K11G00_Boosted->SetMarkerColor(4); h_L00K16G00_Boosted->SetLineColor(2); h_L00K16G00_Boosted->SetMarkerColor(2); h_L00K00G40_Boosted->SetMarkerStyle(21); h_L00K00G60_Boosted->SetMarkerStyle(21); h_L00K00G40_Boosted->SetLineStyle(3); h_L00K00G60_Boosted->SetLineStyle(3); h_L00K00G40_Boosted->SetLineColor(4); h_L00K00G40_Boosted->SetMarkerColor(4); h_L00K00G60_Boosted->SetLineColor(2); h_L00K00G60_Boosted->SetMarkerColor(2); h_L01K00G00_Boosted->Draw(); h_L05K00G00_Boosted->Draw("same"); h_L11K00G00_Boosted->Draw("same"); h_L00K11G00_Boosted->Draw("same"); h_L00K16G00_Boosted->Draw("same"); h_L00K00G40_Boosted->Draw("same"); h_L00K00G60_Boosted->Draw("same"); TLegend* legend = new TLegend(0.24,0.55,0.64,0.9); legend->SetFillColor(0); legend->AddEntry(h_L01K00G00_Boosted, "#lambda = 0.01", "PL"); legend->AddEntry(h_L05K00G00_Boosted, "#lambda = 0.05", "PL"); legend->AddEntry(h_L11K00G00_Boosted, "#lambda = 0.11", "PL"); legend->AddEntry(h_L00K11G00_Boosted, "#Delta#kappa = 0.11", "PL"); legend->AddEntry(h_L00K16G00_Boosted, "#Delta#kappa = 0.16", "PL"); legend->AddEntry(h_L00K00G40_Boosted, "#Deltag_{1} = 0.40", "PL"); legend->AddEntry(h_L00K00G60_Boosted, "#Deltag_{1} = 0.60", "PL"); legend->Draw(); can11->SetLogx(1); can11->SetLogy(1); can11->SaveAs("Fig_aTGC_Boosted.png"); can11->SaveAs("Fig_aTGC_Boosted.pdf"); ///---- combine the boosted & unboosted events ---- TCanvas* can22 = new TCanvas("can22","",500,500); h_L01K00G00->GetXaxis()->SetTitle("Hadronic W p_{T} (GeV)"); h_L01K00G00->GetYaxis()->SetRangeUser(0.3, 90); h_L01K00G00->GetXaxis()->SetMoreLogLabels(); h_L01K00G00->GetXaxis()->SetNoExponent(); h_L05K00G00->SetLineColor(4); h_L05K00G00->SetMarkerColor(4); h_L11K00G00->SetLineColor(2); h_L11K00G00->SetMarkerColor(2); h_L00K11G00->SetMarkerStyle(22); h_L00K16G00->SetMarkerStyle(22); h_L00K11G00->SetMarkerSize(1.3); h_L00K16G00->SetMarkerSize(1.3); h_L00K11G00->SetLineStyle(2); h_L00K16G00->SetLineStyle(2); h_L00K11G00->SetLineColor(4); h_L00K11G00->SetMarkerColor(4); h_L00K16G00->SetLineColor(2); h_L00K16G00->SetMarkerColor(2); h_L00K00G40->SetMarkerStyle(21); h_L00K00G60->SetMarkerStyle(21); h_L00K00G40->SetLineStyle(3); h_L00K00G60->SetLineStyle(3); h_L00K00G40->SetLineColor(4); h_L00K00G40->SetMarkerColor(4); h_L00K00G60->SetLineColor(2); h_L00K00G60->SetMarkerColor(2); // --- Fit to a quadratic function ------ // TF1 *func = new TF1("func", "1.+ [0]*x +[1]*x*x", 100., 500.); // TF1 *func = new TF1("func", "[0]+[1]*x*x", 100., 500.); TF1 *func = new TF1("func", "[0]+[1]*x+[2]*x*x", 50., 1500.); TF1 *func2 = new TF1("func2", "[0]+[1]*x*x", 50., 1500.); func->SetLineWidth(3); func->SetLineColor(1); h_L01K00G00->Fit("func","I",""); h_L03K00G00->Fit("func","I0",""); func->SetLineColor(4); h_L05K00G00->Fit("func","I","same"); h_L07K00G00->Fit("func","I0",""); h_L09K00G00->Fit("func","I0",""); func->SetLineColor(2); h_L11K00G00->Fit("func","I","same"); func->SetLineStyle(2); func->SetLineColor(4); h_L00K11G00->Fit("func","I","same"); func->SetLineColor(2); h_L00K16G00->Fit("func","I","same"); h_L00K20G00->Fit("func","I0",""); h_L00K00G11->Fit("func","I0",""); //-- looks pretty flat --- func->SetLineStyle(3); func->SetLineColor(4); h_L00K00G40->Fit("func","I","same"); func->SetLineColor(2); h_L00K00G60->Fit("func","I","same"); TLegend* legend = new TLegend(0.24,0.55,0.64,0.9); legend->SetFillColor(0); legend->AddEntry(h_L01K00G00, "#lambda = 0.01", "PL"); legend->AddEntry(h_L05K00G00, "#lambda = 0.05", "PL"); legend->AddEntry(h_L11K00G00, "#lambda = 0.11", "PL"); legend->AddEntry(h_L00K11G00, "#Delta#kappa = 0.11", "PL"); legend->AddEntry(h_L00K16G00, "#Delta#kappa = 0.16", "PL"); legend->AddEntry(h_L00K00G40, "#Deltag_{1} = 0.40", "PL"); legend->AddEntry(h_L00K00G60, "#Deltag_{1} = 0.60", "PL"); legend->Draw(); can22->SetLogx(1); can22->SetLogy(1); can22->SaveAs("Fig_aTGC.png"); can22->SaveAs("Fig_aTGC.pdf"); //------- Read C0, C1, C2 for all points ----------- const int numLambdaBins = 6; const int numKappaBins = 3; const int numG1Bins = 3; TF1 fit_L[numLambdaBins]; TF1 fit_K[numKappaBins]; TF1 fit_G1[numG1Bins]; fit_L[0] = h_L01K00G00->GetFunction("func"); fit_L[1] = h_L03K00G00->GetFunction("func"); fit_L[2] = h_L05K00G00->GetFunction("func"); fit_L[3] = h_L07K00G00->GetFunction("func"); fit_L[4] = h_L09K00G00->GetFunction("func"); fit_L[5] = h_L11K00G00->GetFunction("func"); fit_K[0] = h_L00K11G00->GetFunction("func"); fit_K[1] = h_L00K16G00->GetFunction("func"); fit_K[2] = h_L00K20G00->GetFunction("func"); fit_G1[0] = h_L00K00G11->GetFunction("func"); fit_G1[1] = h_L00K00G40->GetFunction("func"); fit_G1[2] = h_L00K00G60->GetFunction("func"); //------- Lambda values and errors --------- float Lambda[] = {0.01, 0.03, 0.05, 0.07, 0.09, 0.11}; float errLambda[] = {0., 0., 0., 0., 0., 0.}; float L_C0val[numLambdaBins]; float L_C0err[numLambdaBins]; float L_C1val[numLambdaBins]; float L_C1err[numLambdaBins]; float L_C2val[numLambdaBins]; float L_C2err[numLambdaBins]; for(int i=0; i<numLambdaBins; ++i) { L_C0val[i] = fit_L[i]->GetParameter(0); L_C0err[i] = fit_L[i]->GetParError(0); L_C1val[i] = fit_L[i]->GetParameter(1); L_C1err[i] = fit_L[i]->GetParError(1); L_C2val[i] = fit_L[i]->GetParameter(2); L_C2err[i] = fit_L[i]->GetParError(2); } //------- Kappa values and errors --------- float Kappa[] = {0.11, 0.16, 0.20}; float errKappa[] = {0., 0., 0.}; float K_C0val[numKappaBins]; float K_C0err[numKappaBins]; float K_C1val[numKappaBins]; float K_C1err[numKappaBins]; float K_C2val[numKappaBins]; float K_C2err[numKappaBins]; for(int i=0; i<numKappaBins; ++i) { K_C0val[i] = fit_K[i]->GetParameter(0); K_C0err[i] = fit_K[i]->GetParError(0); K_C1val[i] = fit_K[i]->GetParameter(1); K_C1err[i] = fit_K[i]->GetParError(1); K_C2val[i] = fit_K[i]->GetParameter(2); K_C2err[i] = fit_K[i]->GetParError(2); } //------- G1 values and errors --------- float G1[] = {0.11, 0.40, 0.60}; float errG1[] = {0., 0., 0.}; float G1_C0val[numG1Bins]; float G1_C0err[numG1Bins]; float G1_C1val[numG1Bins]; float G1_C1err[numG1Bins]; float G1_C2val[numG1Bins]; float G1_C2err[numG1Bins]; for(int i=0; i<numG1Bins; ++i) { G1_C0val[i] = fit_G1[i]->GetParameter(0); G1_C0err[i] = fit_G1[i]->GetParError(0); G1_C1val[i] = fit_G1[i]->GetParameter(1); G1_C1err[i] = fit_G1[i]->GetParError(1); G1_C2val[i] = fit_G1[i]->GetParameter(2); G1_C2err[i] = fit_G1[i]->GetParError(2); } //------- Graph of Lambda C0, C1, C2 --------- cout << "=============================================" << endl; cout << "------ Graph of Lambda ------" << endl; cout << "=============================================" << endl; TGraphErrors* grLC0 = new TGraphErrors( numLambdaBins, Lambda, L_C0val, errLambda, L_C0err); TGraphErrors* grLC1 = new TGraphErrors( numLambdaBins, Lambda, L_C1val, errLambda, L_C1err); grLC1->SetMarkerStyle(4); TGraphErrors* grLC2 = new TGraphErrors( numLambdaBins, Lambda, L_C2val, errLambda, L_C2err); grLC2->SetMarkerStyle(22); TCanvas* can33 = new TCanvas("can33","",500,500); grLC0->GetYaxis()->SetRangeUser(5e-09, 50.); grLC0->GetXaxis()->SetTitle("#lambda"); grLC0->GetYaxis()->SetTitle("C_{i}"); grLC0->Draw("ap"); grLC0->Fit("func2","",""); grLC1->Draw("p"); grLC1->Fit("func2","",""); grLC2->Draw("p"); grLC2->Fit("func2","",""); TLegend* legend = new TLegend(0.7,0.16,0.88,0.35); legend->SetFillColor(0); legend->AddEntry(grLC0, "C0", "P"); legend->AddEntry(grLC1, "C1", "P"); legend->AddEntry(grLC2, "C2", "P"); legend->Draw(); can33->SetLogy(1); can33->SaveAs("Fig_lambda.png"); can33->SaveAs("Fig_lambda.pdf"); //------- Graph of Kappa C0, C1, C2 --------- cout << "=============================================" << endl; cout << "------ Graph of Kappa C0, C1, C2 ------" << endl; cout << "=============================================" << endl; TGraphErrors* grKC0 = new TGraphErrors( numKappaBins, Kappa, K_C0val, errKappa, K_C0err); TGraphErrors* grKC1 = new TGraphErrors( numKappaBins, Kappa, K_C1val, errKappa, K_C1err); grKC1->SetMarkerStyle(4); TGraphErrors* grKC2 = new TGraphErrors( numKappaBins, Kappa, K_C2val, errKappa, K_C2err); grKC2->SetMarkerStyle(22); TCanvas* can44 = new TCanvas("can44","",500,500); grKC0->GetYaxis()->SetRangeUser(5e-09, 50.); grKC0->GetXaxis()->SetTitle("#Delta_{#kappa}"); grKC0->GetYaxis()->SetTitle("C_{i}'"); grKC0->Draw("ap"); grKC0->Fit("func2","",""); grKC1->Draw("p"); grKC1->Fit("func2","",""); grKC2->Draw("p"); grKC2->Fit("func2","",""); TLegend* legend = new TLegend(0.7,0.16,0.88,0.35); legend->SetFillColor(0); legend->AddEntry(grKC0, "C0'", "P"); legend->AddEntry(grKC1, "C1'", "P"); legend->AddEntry(grKC2, "C2'", "P"); legend->Draw(); can44->SetLogy(1); can44->SaveAs("Fig_kappa.png"); can44->SaveAs("Fig_kappa.pdf"); //------- Graph of G1 C0, C1, C2 --------- cout << "=============================================" << endl; cout << "------ Graph of G1 C0, C1, C2 ------" << endl; cout << "=============================================" << endl; TGraphErrors* grG1C0 = new TGraphErrors( numG1Bins, G1, G1_C0val, errG1, G1_C0err); TGraphErrors* grG1C1 = new TGraphErrors( numG1Bins, G1, G1_C1val, errG1, G1_C1err); grG1C1->SetMarkerStyle(4); TGraphErrors* grG1C2 = new TGraphErrors( numG1Bins, G1, G1_C2val, errG1, G1_C2err); grG1C2->SetMarkerStyle(22); TCanvas* can55 = new TCanvas("can55","",500,500); grG1C0->GetYaxis()->SetRangeUser(5e-09, 50.); grG1C0->GetXaxis()->SetTitle("#Delta_{g1}"); grG1C0->GetYaxis()->SetTitle("C_{i}''"); grG1C0->Draw("ap"); grG1C0->Fit("func2","",""); grG1C1->Draw("p"); grG1C1->Fit("func2","",""); grG1C2->Draw("p"); grG1C2->Fit("func2","",""); TLegend* legend = new TLegend(0.7,0.16,0.88,0.35); legend->SetFillColor(0); legend->AddEntry(grG1C0, "C0''", "P"); legend->AddEntry(grG1C1, "C1''", "P"); legend->AddEntry(grG1C2, "C2''", "P"); legend->Draw(); can55->SetLogy(1); can55->SaveAs("Fig_g1.png"); can55->SaveAs("Fig_g1.pdf"); // cout << "p0 = " << fit_L01K00G00_C0 << " +- " << fit_L01K00G00_C0err << endl; // cout << "p1 = " << fit_L01K00G00_C1 << " +- " << fit_L01K00G00_C0err << endl; // cout << "p2 = " << fit_L01K00G00_C2 << " +- " << fit_L01K00G00_C2err << endl; }