Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:14:10

0001 #include "sPhenixStyle.h"
0002 #include "sPhenixStyle.C"
0003 #include "respFitterDef.h"
0004 
0005 
0006 void drawCorr(int doJesInv = 0)
0007 {
0008   SetsPhenixStyle();
0009 
0010   vector<float> etaBins;
0011   for(float i = etaStart; i <= etaEnd; i+=etaGap)
0012     {
0013       etaBins.push_back(i);
0014     }
0015   const int nEtaBins = etaBins.size() -1 + extraBins;
0016     
0017   TCanvas *cJer = new TCanvas();
0018   TCanvas *cJes = new TCanvas();
0019   TLegend *leg = new TLegend(.4,.5,.9,.9);
0020   TLegend *corr = new TLegend(0.35,0.5,0.85,0.75);
0021   corr -> SetFillStyle(0);
0022   corr -> SetBorderSize(0);
0023   leg -> SetFillStyle(0);
0024   leg -> SetBorderSize(0);
0025   TLatex tag;
0026   leg->AddEntry("","#it{#bf{sPHENIX}} Internal","");
0027   leg->AddEntry("","p+p #sqrt{s_{NN}}=200 GeV","");
0028   leg->AddEntry("","anti-#it{k}_{#it{t}} #it{R} = 0.4, |#eta_{Jet}| < 0.6","");
0029   
0030   const int nCorrStat = 2;//sizeof(corr)/sizeof(corr[0]);
0031   
0032   TGraphErrors *jes[nCorrStat][nEtaBins];
0033   TGraphErrors *jer[nCorrStat][nEtaBins];
0034   
0035   TFile *fin[nCorrStat];
0036  
0037   
0038   int colors[] = {1, 2, 4, kGreen +2, kViolet, kCyan, kOrange, kMagenta+2, kAzure-2};
0039 
0040   for(int i = 0; i < nCorrStat; i++)
0041     {
0042       if(!doJesInv)fin[i] = new TFile(Form("calibHists_hists_R04_Corr%d_isLin0_2D.root",i));
0043       else fin[i] = new TFile(Form("calibHists_hists_R04_Corr%d_isLin0_2D.root",i));
0044       
0045       for(int j = 0; j < nEtaBins-1; j++)
0046     {
0047       
0048       jes[i][j] = (TGraphErrors*)fin[i] -> Get(Form("g_jes_eta%d",j));
0049       jes[i][j] -> SetTitle(";p_{T,truth} [GeV]; #LTp_{T,reco}/p_{T,truth}#GT");
0050       
0051       jer[i][j] = (TGraphErrors*)fin[i] -> Get(Form("g_jer_eta%d",j));
0052       jer[i][j] -> SetTitle(";p_{T,truth} [GeV];#sigma(p_{T,reco}/p_{T,truth}) / #LTp_{T,reco}/p_{T,truth}#GT");
0053       
0054       
0055       jes[i][j] -> SetMarkerColor(colors[j]);
0056       jer[i][j] -> SetMarkerColor(colors[j]);
0057       if(i)
0058         {
0059           jes[i][j] -> SetMarkerStyle(20);
0060           jer[i][j] -> SetMarkerStyle(20);
0061         }
0062       else
0063         {
0064           jes[i][j] -> SetMarkerStyle(4);
0065           jer[i][j] -> SetMarkerStyle(4);
0066         }
0067      
0068       if(i)
0069         {
0070           if(j <=nEtaBins - 3)leg -> AddEntry(jes[i][j],Form("%g<#eta<%g",etaBins.at(j),etaBins.at(j+1)),"p");
0071           else leg -> AddEntry(jes[i][j],"-0.6 < #eta < 0.6","p");
0072         }
0073       else corr -> AddEntry(jes[i][j]," ","p");
0074            
0075           
0076       cJes -> cd();
0077       if(i == 0 && j == 0)
0078         {
0079           jes[i][j] -> Draw("ap");
0080           jes[i][j] -> GetYaxis() -> SetRangeUser(0.5,1.8);
0081           jes[i][j] -> GetXaxis() -> SetLimits(0,80);
0082         }
0083       else jes[i][j] -> Draw("samep");
0084       
0085       cJer -> cd();
0086       if(i == 0 && j == 0) jer[i][j] -> Draw("ap");
0087       else jer[i][j] -> Draw("samep");
0088     }
0089       
0090     }
0091   
0092   string dirPrefix = "plots";
0093   if(!doJesInv)dirPrefix=dirPrefix+"_correctionFromLin";
0094   
0095   TLine *one = new TLine(0,1,80,1);
0096   one -> SetLineStyle(8);
0097   cJes -> cd();
0098   tag.SetTextSize(0.04);
0099   tag.DrawLatexNDC(0.39,0.75,"W/  W/o");
0100   leg -> Draw("same");
0101   corr -> Draw("same");
0102   one -> Draw("same");
0103   cJes -> SaveAs(Form("%s/JES_CorrectionComp.pdf",dirPrefix.c_str()));
0104   
0105   cJer -> cd();
0106   tag.SetTextSize(0.04);
0107   tag.DrawLatexNDC(0.39,0.75,"W/  W/o");
0108   leg -> Draw("same");
0109   corr -> Draw("same");
0110   cJer -> SaveAs(Form("%s/JER_CorrectionComp.pdf",dirPrefix.c_str()));
0111 
0112   //make one with no iso cut so it's cleaner
0113   one -> SetX1(5);
0114   TCanvas *cJesClean = new TCanvas();
0115   jes[0][4] -> SetMarkerColor(1);
0116   jes[0][4] -> SetMarkerStyle(20);
0117   jes[0][4] -> GetYaxis() -> SetRangeUser(0.5,1.80);
0118   jes[0][4] -> GetXaxis() -> SetRangeUser(0,80);
0119   jes[1][4] -> GetXaxis() -> SetRangeUser(0,80);
0120   jes[0][4] -> Draw("ap");
0121   jes[1][4] -> Draw("same p");
0122   jes[1][4] -> SetMarkerStyle(20);
0123   jes[0][4] -> SetMarkerStyle(20);
0124 
0125   jes[1][4] -> SetMarkerColor(2);
0126   jes[1][4] -> SetMarkerStyle(20);
0127 
0128 
0129   one -> Draw("same");
0130   leg -> Clear();
0131   leg->AddEntry("","#it{#bf{sPHENIX}} Internal","");
0132   leg->AddEntry("","p+p #sqrt{s_{NN}}=200 GeV","");
0133   leg->AddEntry("","anti-#it{k}_{#it{t}} #it{R} = 0.4, |#eta| < 0.6","");
0134   leg -> AddEntry(jes[0][4],"Uncalibrated","p");
0135   leg -> AddEntry(jes[1][4],"Calibrated","p");
0136 
0137   leg -> Draw("same");
0138 
0139   cJesClean -> SaveAs(Form("%s/JES_CorrectionComp_EtaIntegrated.pdf",dirPrefix.c_str()));
0140 
0141   TCanvas *cJerClean = new TCanvas();
0142   jer[0][4] -> SetMarkerColor(1);
0143   jer[0][4] -> SetMarkerStyle(20);
0144   jer[0][4] -> Draw("ap");
0145   jer[1][4] -> Draw("same p");
0146   jer[1][4] -> SetMarkerStyle(20);
0147   jer[1][4] -> SetMarkerColor(2);
0148 
0149   leg -> Draw("same");
0150   
0151   cJerClean -> SaveAs(Form("%s/JER_CorrectionComp_EtaIntegrated.pdf",dirPrefix.c_str()));
0152   
0153   TCanvas *cJesCleanZoom = new TCanvas();
0154   jes[1][4] -> GetYaxis() -> SetRangeUser(0.98,1.02);
0155   jes[1][4] -> GetXaxis() -> SetRangeUser(0,80);
0156   jes[1][4] -> Draw("aP");
0157   TLine *onep1 = (TLine*)one->Clone();
0158   onep1 -> SetLineStyle(7);
0159   onep1 -> SetY1(1.01); onep1->SetY2(1.01);
0160   onep1 -> Draw("same");
0161   
0162   TLine *onep9 = (TLine*)one->Clone();
0163   onep9 -> SetLineStyle(7);
0164   onep9 -> SetY1(0.99); onep9 -> SetY2(0.99);
0165   onep9 -> Draw("same");
0166 
0167   one -> Draw("same");
0168   //gPad -> SetGridy();
0169   
0170   cJesCleanZoom -> SaveAs(Form("%s/JES_CorrectionComp_EtaIntegrated_Zoom.pdf",dirPrefix.c_str()));
0171  
0172 
0173 }
0174