void JetResponseMacro_Pt(){ TH1::SetDefaultSumw2(); TH2::SetDefaultSumw2(); // gROOT->ProcessLine(".x rootlogon.C"); gROOT->ProcessLine(".L format1Dhisto.C"); gROOT->ProcessLine(".L formatTGraph.C"); // gROOT->ProcessLine(".x betterColors.C"); //TFile *FileA = TFile::Open(Form("correctedFileForBtag.root")); TFile *FileA = TFile::Open(Form("../corrected_dijet_pp_mergedpthatbins_2013MCV3.root")); // TFile *FileA = TFile::Open(Form("/Users/ymao/group/CMS/anaOutputs/pPb/JEC/dijet_pp_mergedpthatbins_2012MC.root")); TString outname = "JetResponse_Plots.root"; // TFile* outf = new TFile(outname,"recreate"); TString plotsdir = "/Users/ymao/group/CMS/plots/pA"; TString canv_name = "c1"; const Double_t kw = 1300; const Double_t kh = 480; c1 = new TCanvas(canv_name," ",10,10,kw,kh); makeMultiPanelCanvas(c1,nBin/2,2,0.0,0.0,0.1,0.2,0.05); gStyle->SetOptStat(0); gStyle->SetPadBottomMargin(0.12); gStyle->SetPadTopMargin (0.025); gStyle->SetPadLeftMargin (0.15); gStyle->SetPadRightMargin (0.025); gStyle->SetPadTickX (1); gStyle->SetPadTickY (1); TLegend *t1=new TLegend(0.2,0.75,0.8,0.92); // TLegend *t1=new TLegend(0.25,0.6,0.8,0.92); t1->SetFillColor(0); t1->SetBorderSize(0); t1->SetFillStyle(0); t1->SetTextFont(63); t1->SetTextSize(15); TLegend *t2=new TLegend(0.20,0.45,0.35,0.6); t2->SetFillColor(0); t2->SetBorderSize(0); t2->SetFillStyle(0); t2->SetTextFont(63); t2->SetTextSize(17); TH1F * dummy = new TH1F("dummy", "dummy", 500, 0., 500.); dummy->SetAxisRange(0., 500., "X") ; dummy->GetXaxis()->SetTitle("p_{T}^{ref} (GeV/c)"); // const char* AlgoNames[] = {"ak3PF"}; // TCanvas *c1 = new TCanvas("c1","c1",1100,700); //makeMultiPanelCanvas(c1,3,2,0.0,0.0,0.2,0.15,0.07); //TCanvas *c1B = new TCanvas("c1B","c1B",1100,700); //makeMultiPanelCanvas(c1B,3,2,0.0,0.0,0.2,0.15,0.07); //TCanvas *c1C = new TCanvas("c1C","c1C",1100,700); //makeMultiPanelCanvas(c1C,3,2,0.0,0.0,0.2,0.15,0.07); const int cCanDiv = nBin; // makeMultiPanelCanvas(c1,cCanDiv,2,0.0,0.0,0.2,0.15,0.07); int nCanvDiv = cCanDiv; const int CnXbins = nJetPtBin; int nXbins = CnXbins; TH2D* iHistoCorrPt[cCanDiv]; TH2D* iHistoRefPt[cCanDiv]; TH2D* iHistoJtPt[cCanDiv]; TH2D* iHistoRawPt[cCanDiv]; TH1D* h1[cCanDiv][CnXbins]; TF1* Gauss6[cCanDiv][CnXbins]; double mean[cCanDiv][CnXbins]; double sigma[cCanDiv][CnXbins]; double meanErr[cCanDiv][CnXbins]; double sigmaErr[cCanDiv][CnXbins]; double xPoint[cCanDiv][CnXbins]; double xPointErr[cCanDiv][CnXbins]; TLegend* leg[cCanDiv]; // Int_t i = 2 ; for(int i =0; i<nCanvDiv; i++) // for(int i =1; i<nCanvDiv-1; i++) { c1->cd(i+1); TTree* t = (TTree*)FileA->Get(Form("%sJetAnalyzer/t", AlgoNames[i])); leg[i]= new TLegend(0.22,0.63,0.45,0.90);//top right leg[i]->SetFillColor(0); leg[i]->SetTextSize(0.05); leg[i]->SetBorderSize(0); iHistoCorrPt[i] = new TH2D(Form("%s_CorrPt",AlgoNames[i]),Form("%s_CorrPt",AlgoNames[i]),nXbins,0,500,500,0,5); iHistoCorrPt[i]->Sumw2(); t->Draw(Form("corrpt/refpt:refpt>>%s_CorrPt",AlgoNames[i]),"weight*(refpt>-99 && corrpt>0 && fabs(jteta)<3.0 && rawpt>15.)","goff"); // t->Draw(Form("corrpt/refpt:refpt>>%s_CorrPt",AlgoNames[i]),Form("corrpt>0 && fabs(jteta)<3.0"),"goff"); iHistoCorrPt[i]->Draw("colz"); leg[i]->AddEntry(iHistoCorrPt[i],Form("%s |#eta|<3.0",AlgoNames[i]),""); leg[i]->AddEntry(iHistoCorrPt[i],Form("Jet p_{T}^{corrected}/p_{T}^{ref}"),""); format1Dhisto(*iHistoCorrPt[i],250,-1,2,20,2,1,"Jet p_{T}^{ref} (GeV/c)","Corrected p_{T}/ ref p_{T}");//Red leg[i]->Draw(); for(int iX=iHistoCorrPt[i]->GetXaxis()->GetFirst(); iX<iHistoCorrPt[i]->GetXaxis()->GetLast(); iX++ ) // for(int iX=0; iX<nJetPtBin; iX++ ) { //cout<<"bin ( "<<iX<<" ) --limits ["<<iHistoCorrPt[i]->GetXaxis()->GetBinLowEdge(iX)<<" , "<<iHistoCorrPt[i]->GetXaxis()->GetBinUpEdge(iX)<<" ] "<<endl; h1[i][iX] = new TH1D(Form("h1_%d_%d_py",i,iX),Form("h1_%d_%d_py",i,iX),500,0,5); h1[i][iX] =(TH1D*)iHistoCorrPt[i]->ProjectionY(Form("h1_%d_%d_py",i,iX),iX,iX,"e"); // h1[i][iX] =(TH1D*)iHistoCorrPt[i]->ProjectionY(Form("h1_%s_Pt%f_%f_py",AlgoNames[i],jetPtBin[iX],jetPtBin[iX+1]),iHistoCorrPt[i]->GetXaxis()->FindBin(jetPtBin[iX]),iHistoCorrPt[i]->GetXaxis()->FindBin(jetPtBin[iX+1])-1,"e"); Gauss6[i][iX] = new TF1(Form("F6_c%d_d%d",i,iX),"gaus",0,3); Gauss6[i][iX]->SetParLimits(1,0.7,1.5); h1[i][iX]->Fit(Form("F6_c%d_d%d",i,iX),"R0WL", "", 0.7, 1.5); // h1[i][iX]->Fit(Gauss6[i][iX],"0Q"); if(DoGausFit){ mean[i][iX] = Gauss6[i][iX]->GetParameter(1); sigma[i][iX] = Gauss6[i][iX]->GetParameter(2); meanErr[i][iX] = Gauss6[i][iX]->GetParError(1); sigmaErr[i][iX] = Gauss6[i][iX]->GetParError(2); } else { mean[i][iX] = h1[i][iX]->GetMean(); sigma[i][iX]= h1[i][iX]->GetRMS(); meanErr[i][iX] = h1[i][iX]->GetMeanError(); sigmaErr[i][iX] =h1[i][iX]->GetRMSError(); } xPoint[i][iX] =iHistoCorrPt[i]->GetXaxis()->GetBinCenter(iX); xPointErr[i][iX] = 0; if(i==2 && iX==3)//Just to test { cout<<"bin ( "<<iX<<" ) --limits ["<<iHistoCorrPt[i]->GetXaxis()->GetBinLowEdge(iX)<<" , "<<iHistoCorrPt[i]->GetXaxis()->GetBinUpEdge(iX)<<" ] "<<endl; TCanvas *c11 = new TCanvas("c11","c11",500,500); c11->cd(); h1[i][iX]->Draw(); Gauss6[i][iX]->Draw("same"); } } } if(SavePlot){ c1->Print(Form("CorrectedOverRefJet.pdf")); } c1->Update(); TLegend* leg2B[cCanDiv]; TLegend* leg2A[cCanDiv]; TGraphErrors *CorrPt_Mean[cCanDiv]; TCanvas *c2 = new TCanvas("c2","c2",10,10,kw,kh); makeMultiPanelCanvas(c2,nBin/2,2,0.0,0.0,0.1,0.2,0.05); //makeMultiPanelCanvas(c2,3,2,0.0,0.0,0.2,0.15,0.07); //TCanvas *c2B = new TCanvas("c2B","c2B",1100,700); //makeMultiPanelCanvas(c2B,3,2,0.0,0.0,0.2,0.15,0.07); //TCanvas *c2C = new TCanvas("c2C","c2C",1100,700); //makeMultiPanelCanvas(c2C,3,2,0.0,0.0,0.2,0.15,0.07); TGraphErrors *CorrPt_Sigma[cCanDiv]; TCanvas *c3 = new TCanvas("c3","c3",10,10,kw,kh); makeMultiPanelCanvas(c3,nBin/2,2,0.0,0.0,0.1,0.2,0.05); //makeMultiPanelCanvas(c3,3,2,0.0,0.0,0.2,0.15,0.07); //TCanvas *c3B = new TCanvas("c3B","c3B",1100,700); //makeMultiPanelCanvas(c3B,3,2,0.0,0.0,0.2,0.15,0.07); //TCanvas *c3C = new TCanvas("c3C","c3C",1100,700); //makeMultiPanelCanvas(c3C,3,2,0.0,0.0,0.2,0.15,0.07); for(int i2 =0; i2<nCanvDiv; i2++) { leg2A[i2]= new TLegend(0.22,0.73,0.45,0.95);//top right leg2A[i2]->SetFillColor(0); leg2A[i2]->SetTextSize(0.05); leg2A[i2]->SetBorderSize(0); leg2B[i2]= new TLegend(0.22,0.73,0.45,0.95);//top right leg2B[i2]->SetFillColor(0); leg2B[i2]->SetTextSize(0.05); leg2B[i2]->SetBorderSize(0); double xLoc[CnXbins]; double y2Loc[CnXbins]; double y3Loc[CnXbins]; double xLocErr[CnXbins]; double y2LocErr[CnXbins]; double y3LocErr[CnXbins]; for(int iBin=0; iBin<nXbins; iBin++) { xLoc[iBin] = xPoint[i2][iBin]; xLocErr[iBin] = xPointErr[i2][iBin]; y2Loc[iBin] = mean[i2][iBin]; y2LocErr[iBin] = meanErr[i2][iBin]; y3Loc[iBin] = sigma[i2][iBin]; y3LocErr[iBin] = sigmaErr[i2][iBin]; } // if(i2<=5)c2->cd(i2+1); // if(i2>5 && i2<12)c2B->cd(i2-5); // if(i2>=12)c2C->cd(i2-12); c2->cd(i2+1); CorrPt_Mean[i2] = new TGraphErrors(nXbins,xLoc,y2Loc,xLocErr,y2LocErr); formatTGraph(*CorrPt_Mean[i2],250,-1,1,20,1,1,"p_{T}^{ref} (GeV/c)","#mu "); leg2A[i2]->AddEntry(CorrPt_Mean[i2],Form("%s |#eta|<2.0",AlgoNames[i2]),""); leg2A[i2]->AddEntry(CorrPt_Mean[i2],Form("p_{T}^{corrected}/p_{T}^{ref}"),"lp"); CorrPt_Mean[i2]->SetMaximum(1.1); CorrPt_Mean[i2]->SetMinimum(0.9); CorrPt_Mean[i2]->Draw("AP"); leg2A[i2]->Draw(); regSun(20.,1.,400.,1.,1, 1); // if(i2<=5)c3->cd(i2+1); // if(i2>5 && i2<12)c3B->cd(i2-5); // if(i2>=12)c3C->cd(i2-12); c3->cd(i2+1); CorrPt_Sigma[i2] = new TGraphErrors(nXbins,xLoc,y3Loc,xLocErr,y3LocErr); formatTGraph(*CorrPt_Sigma[i2],250,-1,1,20,1,1,"p_{T}^{ref} (GeV/c)","#sigma "); leg2B[i2]->AddEntry(CorrPt_Sigma[i2],Form("%s |#eta|<2.0",AlgoNames[i2]),""); leg2B[i2]->AddEntry(CorrPt_Sigma[i2],Form("p_{T}^{corrected}/p_{T}^{ref}"),"lp"); CorrPt_Sigma[i2]->SetMaximum(0.4); CorrPt_Sigma[i2]->SetMinimum(0.); CorrPt_Sigma[i2]->Draw("AP"); leg2B[i2]->Draw(); regSun(20.,1.,400.,1.,1, 1); } if(SavePlot){ c2->Print(Form("CorrectedOverRefJetMean.pdf")); c3->Print(Form("CorrectedOverRefJetSigma.pdf")) ; } c2->Update(); c3->Update(); }
void JetResponseMacro_TheDeadlyEagle_Eta(){ gROOT->ProcessLine(".x rootlogon.C"); gROOT->ProcessLine(".L format1Dhisto.C"); gROOT->ProcessLine(".L formatTGraph.C"); gROOT->ProcessLine(".x betterColors.C"); TFile *FileA = TFile::Open(Form("../JEC/Corrected_dijet_pp_mergedpthatbins_2013MCV2.root")); //TFile *FileA = TFile::Open(Form("~/rootFiles/JEC/Files/20120521/Correcteddijet_pp_mergedpthatbins_2012MC.root")); TString outname = "JetResponse_Plots.root"; TFile* outf = new TFile(outname,"recreate"); const char* AlgoNames[] = {"ak1PF","ak2PF","ak3PF","ak4PF","ak5PF","ak6PF","ak1Calo","ak2Calo","ak3Calo","ak4Calo","ak5Calo","ak6Calo","icPu5"}; TCanvas *c1 = new TCanvas("c1","c1",1100,700); makeMultiPanelCanvas(c1,3,2,0.0,0.0,0.2,0.15,0.07); TCanvas *c1B = new TCanvas("c1B","c1B",1100,700); makeMultiPanelCanvas(c1B,3,2,0.0,0.0,0.2,0.15,0.07); TCanvas *c1C = new TCanvas("c1C","c1C",1100,700); makeMultiPanelCanvas(c1C,3,2,0.0,0.0,0.2,0.15,0.07); const int cCanDiv = 13; int nCanvDiv = cCanDiv; const int CnXbins = 30; int nXbins = CnXbins; TH2D* iHistoCorrEta[cCanDiv]; TH2D* iHistoRefEta[cCanDiv]; TH2D* iHistoJtEta[cCanDiv]; TH2D* iHistoRawEta[cCanDiv]; TH1D* h1[cCanDiv][CnXbins]; TF1* Gauss6[cCanDiv][CnXbins]; double mean[cCanDiv][CnXbins]; double sigma[cCanDiv][CnXbins]; double meanErr[cCanDiv][CnXbins]; double sigmaErr[cCanDiv][CnXbins]; double xPoint[cCanDiv][CnXbins]; double xPointErr[cCanDiv][CnXbins]; TLegend* leg[cCanDiv]; for(int i =0; i<nCanvDiv; i++) { if(i==0 || i==6) continue;//skip the ak1 algos if(i==12) continue;//skip the icpU5 algos if(i<=5)c1->cd(i+1); if(i>5 && i<12)c1B->cd(i-5); if(i>=12)c1C->cd(i-12); if(i==0) TTree* t = (TTree*)FileA->Get("ak1PFJetAnalyzer/t"); if(i==1) TTree* t = (TTree*)FileA->Get("ak2PFJetAnalyzer/t"); if(i==2) TTree* t = (TTree*)FileA->Get("ak3PFJetAnalyzer/t"); if(i==3) TTree* t = (TTree*)FileA->Get("ak4PFJetAnalyzer/t"); if(i==4) TTree* t = (TTree*)FileA->Get("ak5PFJetAnalyzer/t"); if(i==5) TTree* t = (TTree*)FileA->Get("ak6PFJetAnalyzer/t"); if(i==6) TTree* t = (TTree*)FileA->Get("ak1CaloJetAnalyzer/t"); if(i==7) TTree* t = (TTree*)FileA->Get("ak2CaloJetAnalyzer/t"); if(i==8) TTree* t = (TTree*)FileA->Get("ak3CaloJetAnalyzer/t"); if(i==9) TTree* t = (TTree*)FileA->Get("ak4CaloJetAnalyzer/t"); if(i==10) TTree* t = (TTree*)FileA->Get("ak5CaloJetAnalyzer/t"); if(i==11) TTree* t = (TTree*)FileA->Get("ak6CaloJetAnalyzer/t"); if(i==12) TTree* t = (TTree*)FileA->Get("icPu5JetAnalyzer/t"); leg[i]= new TLegend(0.22,0.63,0.45,0.90);//top right leg[i]->SetFillColor(0); leg[i]->SetTextSize(0.05); leg[i]->SetBorderSize(0); iHistoCorrEta[i] = new TH2D(Form("%s_CorrEta",AlgoNames[i]),Form("%s_CorrEta",AlgoNames[i]),nXbins,-2,2,500,0,5); //t->Draw(Form("corrpt/refpt:jteta>>%s_CorrEta",AlgoNames[i]),Form("corrpt>0 && fabs(jteta)<2.0"),"goff"); t->Draw(Form("corrpt/refpt:jteta>>%s_CorrEta",AlgoNames[i]),Form("corrpt>5 && refpt>5 && fabs(jteta)<2.0"),"goff"); iHistoCorrEta[i]->Draw("colz"); leg[i]->AddEntry(iHistoCorrEta[i],Form("%s |#eta|<2.0",AlgoNames[i]),""); leg[i]->AddEntry(iHistoCorrEta[i],Form("Corrected / ref p_{T}"),""); format1Dhisto(*iHistoCorrEta[i],250,-1,2,20,2,1,"Jet #eta","Corrected p_{T}/ ref p_{T}");//Red leg[i]->Draw(); for(int iX=iHistoCorrEta[i]->GetXaxis()->GetFirst(); iX<iHistoCorrEta[i]->GetXaxis()->GetLast(); iX++ ) { //cout<<"bin ( "<<iX<<" ) --limits ["<<iHistoCorrEta[i]->GetXaxis()->GetBinLowEdge(iX)<<" , "<<iHistoCorrEta[i]->GetXaxis()->GetBinUpEdge(iX)<<" ] "<<endl; h1[i][iX] = new TH1D(Form("h1_%d_%d_py",i,iX),Form("h1_%d_%d_py",i,iX),500,0,5); h1[i][iX] =(TH1D*)iHistoCorrEta[i]->ProjectionY(Form("h1_%d_%d_py",i,iX),iX,iX,"e"); Gauss6[i][iX] = new TF1(Form("F6_c%d_d%d",i,iX),"gaus",0,5); Gauss6[i][iX]->SetParLimits(1,0.7,1.5); h1[i][iX]->Fit(Form("F6_c%d_d%d",i,iX),"0Q"); mean[i][iX] = Gauss6[i][iX]->GetParameter(1); sigma[i][iX] = Gauss6[i][iX]->GetParameter(2); meanErr[i][iX] = Gauss6[i][iX]->GetParError(1); sigmaErr[i][iX] = Gauss6[i][iX]->GetParError(2); xPoint[i][iX] =iHistoCorrEta[i]->GetXaxis()->GetBinCenter(iX); xPointErr[i][iX] = 0; if(i==0 && iX==1)//Just to test { TCanvas *c11 = new TCanvas("c11","c11",500,400); c11->cd(); h1[i][iX]->Draw(); Gauss6[i][iX]->Draw("same"); } } } TLegend* leg2B[cCanDiv]; TLegend* leg2A[cCanDiv]; TGraphErrors *CorrEta_Mean[cCanDiv]; TCanvas *c2 = new TCanvas("c2","c2",1100,700); makeMultiPanelCanvas(c2,3,2,0.0,0.0,0.2,0.15,0.07); TCanvas *c2B = new TCanvas("c2B","c2B",1100,700); makeMultiPanelCanvas(c2B,3,2,0.0,0.0,0.2,0.15,0.07); TCanvas *c2C = new TCanvas("c2C","c2C",1100,700); makeMultiPanelCanvas(c2C,3,2,0.0,0.0,0.2,0.15,0.07); TGraphErrors *CorrEta_Sigma[cCanDiv]; TCanvas *c3 = new TCanvas("c3","c3",1100,700); makeMultiPanelCanvas(c3,3,2,0.0,0.0,0.2,0.15,0.07); TCanvas *c3B = new TCanvas("c3B","c3B",1100,700); makeMultiPanelCanvas(c3B,3,2,0.0,0.0,0.2,0.15,0.07); TCanvas *c3C = new TCanvas("c3C","c3C",1100,700); makeMultiPanelCanvas(c3C,3,2,0.0,0.0,0.2,0.15,0.07); for(int i2 =0; i2<nCanvDiv; i2++) { leg2A[i2]= new TLegend(0.22,0.18,0.45,0.35);//top right leg2A[i2]->SetFillColor(0); leg2A[i2]->SetTextSize(0.05); leg2A[i2]->SetBorderSize(0); leg2B[i2]= new TLegend(0.22,0.18,0.45,0.35);//top right leg2B[i2]->SetFillColor(0); leg2B[i2]->SetTextSize(0.05); leg2B[i2]->SetBorderSize(0); double xLoc[CnXbins]; double y2Loc[CnXbins]; double y3Loc[CnXbins]; double xLocErr[CnXbins]; double y2LocErr[CnXbins]; double y3LocErr[CnXbins]; for(int iBin=0; iBin<nXbins; iBin++) { xLoc[iBin] = xPoint[i2][iBin]; xLocErr[iBin] = xPointErr[i2][iBin]; y2Loc[iBin] = mean[i2][iBin]; y2LocErr[iBin] = meanErr[i2][iBin]; y3Loc[iBin] = sigma[i2][iBin]; y3LocErr[iBin] = sigmaErr[i2][iBin]; } if(i2<=5)c2->cd(i2+1); if(i2>5 && i2<12)c2B->cd(i2-5); if(i2>=12)c2C->cd(i2-12); CorrEta_Mean[i2] = new TGraphErrors(nXbins,xLoc,y2Loc,xLocErr,y2LocErr); formatTGraph(*CorrEta_Mean[i2],250,-1,1,20,1,1,"Jet #eta","#mu "); leg2A[i2]->AddEntry(CorrEta_Mean[i2],Form("%s |#eta|<2.0",AlgoNames[i2]),""); leg2A[i2]->AddEntry(CorrEta_Mean[i2],Form("Corrected p_{T}/ ref p_{T}"),"lp"); CorrEta_Mean[i2]->SetMaximum(1.15); CorrEta_Mean[i2]->SetMinimum(0.90); CorrEta_Mean[i2]->Draw("AP"); leg2A[i2]->Draw(); if(i2<=5)c3->cd(i2+1); if(i2>5 && i2<12)c3B->cd(i2-5); if(i2>=12)c3C->cd(i2-12); CorrEta_Sigma[i2] = new TGraphErrors(nXbins,xLoc,y3Loc,xLocErr,y3LocErr); formatTGraph(*CorrEta_Sigma[i2],250,-1,1,20,1,1,"Jet #eta","#sigma "); leg2B[i2]->AddEntry(CorrEta_Sigma[i2],Form("%s |#eta|<2.0",AlgoNames[i2]),""); leg2B[i2]->AddEntry(CorrEta_Sigma[i2],Form("Corrected p_{T}/ ref p_{T}"),"lp"); CorrEta_Sigma[i2]->SetMaximum(0.6); CorrEta_Sigma[i2]->SetMinimum(-0.2); CorrEta_Sigma[i2]->Draw("AP"); leg2B[i2]->Draw(); } c1->Print("plots/pPb2013_0126/EtaCorrection2D_AKPF.pdf"); c1B->Print("plots/pPb2013_0126/EtaCorrection2D_AKCalo.pdf"); c1C->Print("plots/pPb2013_0126/EtaCorrection2D_IC.pdf"); c2->Print("plots/pPb2013_0126/EtaCorrection1DMean_AKPF.pdf"); c2B->Print("plots/pPb2013_0126/EtaCorrection1DMean_AKCalo.pdf"); c2C->Print("plots/pPb2013_0126/EtaCorrection1DMean_IC.pdf"); c3->Print("plots/pPb2013_0126/EtaCorrection1DSigma_AKPF.pdf"); c3B->Print("plots/pPb2013_0126/EtaCorrection1DSigma_AKCalo.pdf"); c3C->Print("plots/pPb2013_0126/EtaCorrection1DSigma_IC.pdf"); }