def main(): print('Number of arguments: ', len(sys.argv), 'arguments.') print('Argument list:', str(sys.argv)) filename1 = '~/OneDrive/work/032.JTAnalysis/Unfolding/RooUnfold/CF_pPb_legotrain/legotrain_CF_pPb_CF_pPb-1209_20170807_LHC13bcde.root' filename2 = '~/OneDrive/work/032.JTAnalysis/Unfolding/RooUnfold/CF_pp_legotrain/legotrain_CF_pp_1405_20170810-7TeV_LHC10_p2_AOD147.root' print("Input file: ") print(filename1) Mixed_FullJets_R04 = datasetMixed( "FullR04", NFIN=0, range=5, filename=filename1, directory='AliJJetJtTask/AliJJetJtHistManager', directory2='AliJJetJtTask_kEMCEJE/AliJJetJtHistManager', color=2, style=24, rebin=5) pp_FullJets_R04 = dataset("ppFullR04", NFIN=0, filename=filename2, directory='AliJJetJtTask/AliJJetJtHistManager', color=1, style=24, rebin=5) fig, axs = defs.makegrid(4, 2, xlog=True, ylog=True, d=d, shareY=True) signal, jetPt = Mixed_FullJets_R04.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=True) axs = axs.reshape(8) axs[1].text(0.02, 0.0005, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n' + d['trigger'] + '\n' + Mixed_FullJets_R04.name() + '\n Jet Cone', fontsize=7) for jT, pT, ax, i in zip(signal[1:], jetPt[1:], axs, range(0, 9)): rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=Mixed_FullJets_R04.name(), fmt='o') #Plot jT histogram, ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) if (i == 0): ax.set_xlim([0.01, 20]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits axs[0].legend(loc='lower left') #plt.savefig("PythonFigures/MixedFullJetsR04JetConeJtSignal.pdf",format='pdf') #Save figure plt.show() #Draw figure on screen
def drawSignal(signals, systematics, names, colors, styles, jetPt): if (n_figs == 2): fig, axs = defs.makeRatio(xlog=True, ylog=True, d=d, shareY=False, figsize=(5, 7.5), grid=False) else: fig, axs = defs.makegrid(n_figs / 2, 2, xlog=True, ylog=True, d=d, shareY=False, figsize=(10, 7.5) if n_figs == 4 else (n_figs * 15 / 8, 7.5)) axs = axs.reshape(n_figs) if (n_figs == 2): pT = jetPt[start] print(pT) axs[0].text( 0.8, 7, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n' + d['cut'] + '\n' + r'${:02d}\:\mathrm{{GeV}} < p_{{\mathrm{{T,jet}}}} < {:02d}\:\mathrm{{GeV}}$' .format(pT[0], pT[1]), fontsize=11) else: axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n' + d['cut'], fontsize=11) for signal, system, name, color, j in zip(signals, systematics, names, colors, range(10)): print("Plot {}".format(name)) for jT, syst, pT, ax, i in zip(signal[start:], system[start:], jetPt[start:], axs[0:n_figs / 2], range(0, 9)): print(pT) jT.SetMarkerColor(color) jT.SetMarkerStyle(styles[j]) jT.SetLineColor(color) plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=name, fmt='o', fillstyle='none') #Plot jT histogram, line = plot.get_children()[0] line.set_markersize(mSize) if (styles[j] > 23): line.set_markerfacecolor('none') #line.set_markeredgecolor(color) line.set_color(color) if (n_figs > 2): ax.text( 0.5, 1e2, r'${:02d}\:\mathrm{{GeV}} < p_{{\mathrm{{T,jet}}}} < {:02d}\:\mathrm{{GeV}}$' .format(pT[0], pT[1])) ax.set_xlim([xlow, 15]) #Set x-axis limits ax.set_ylim([1e-5, 2e3]) #Set y-axis limits errorboxes = [] for box in syst: print(box) x1, x2, y1, y2, yc, error, ratio, ratioerror = box print(x1) print("{} {} {} {}".format(x1, y1, x2 - x1, y2 - y1)) rect = Rectangle((x1, y1), x2 - x1, y2 - y1) errorboxes.append(rect) pc = PatchCollection(errorboxes, facecolor=colorsBox[j], alpha=0.5, edgecolor='None') ax.add_collection(pc) ratios = [] if (j > 0): for syst, sig, div, ax in zip(system[start:], signal[start:], signals[0], axs[n_figs / 2:n_figs + 1]): ratioBoxes = [] N = div.GetNbinsX() for box, i in zip(syst, range(1, N)): y = div.GetBinContent(i) x1, x2, y1, y2, yc, error, ratio, ratioerror = box rect = Rectangle((x1, ratio - ratioerror), x2 - x1, ratioerror * 2) ratioBoxes.append(rect) pc = PatchCollection(ratioBoxes, facecolor=colorsBox[j], alpha=0.5, edgecolor='None') ax.add_collection(pc) if j > 0: for jT, div in zip(signal, signals[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[n_figs / 2].set_ylabel( 'Ratio to {}'.format(names[0]), fontsize=12 ) #Add y-axis labels to left- and righmost subfigures if (n_figs > 4): axs[-1].set_ylabel('Ratio to {}'.format(names[0]), fontsize=12) for ratio, pT, ax in zip(ratios[start:], jetPt[start:], axs[n_figs / 2:n_figs + 1]): plot = rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, ax.plot([0, 10], [1, 1], 'k--') line = plot.get_children()[0] line.set_markersize(mSize) if (styles[j] > 23): line.set_markerfacecolor('none') line.set_color(color) #if(i == 0): ax.set_yscale('linear') ax.set_xlim([xlow, 15]) #Set x-axis limits ax.set_ylim([0.1, 2.5]) #Set y-axis limits handles, labels = axs[0].get_legend_handles_labels() handles = [ container.ErrorbarContainer(h, has_xerr=False, has_yerr=True) if isinstance(h, container.ErrorbarContainer) else h for h in handles ] axs[0].legend(handles, labels, loc='lower left', numpoints=1, prop={'family': 'monospace'}) #axs[0].legend(loc = 'lower left') axs[0].text(0.11, 3e2, "ALICE", weight='bold') fig.align_labels() plt.savefig("PythonFigures/HighMJetConeJtSignalPtFrom{}To{}.pdf".format( start, end), format='pdf') #Save figure plt.show() #Draw figure on screen
def drawInclusive(incs, names, colors, styles): start = 4 end = 8 n_figs = 6 if (end > start + n_figs / 2): end = start + n_figs / 2 n_rows = 2 if (True): if (n_figs == 2): fig, axs = defs.makeRatio(xlog=True, ylog=True, d=d, shareY=False, figsize=(5, 7.5)) else: fig, axs = defs.makegrid(n_figs / 2, 2, xlog=True, ylog=True, d=d, shareY=False, figsize=(10, 7.5) if n_figs == 4 else (n_figs * 15 / 8, 7.5)) axs = axs.reshape(n_figs) axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n' + d['cut'], fontsize=11) for inc, name, color, j in zip(incs, names, colors, range(10)): print("Plot {}".format(name)) for jT, pT, ax, i in zip(inc[start:], jetPt[start:], axs[0:n_figs / 2], range(0, 9)): jT.SetMarkerColor(color) jT.SetMarkerStyle(styles[j]) jT.SetLineColor(color) plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=name, fmt='o', fillstyle='none') #Plot jT histogram, line = plot.get_children()[0] line.set_markersize(mSize) if (styles[j] > 23): line.set_markerfacecolor('none') #line.set_markeredgecolor(color) line.set_color(color) ax.text( 0.5, 1e2, r'${:02d}\:\mathrm{{GeV}} < p_\mathrm{{T,jet}} < {:02d}\:\mathrm{{GeV}}$' .format(pT[0], pT[1])) ax.set_xlim([xlow, 10]) #Set x-axis limits ax.set_ylim([5e-5, 2e3]) #Set y-axis limits #ax.set_xticklabels(ax.get_xticklabels(),horizontalalignment='left') ratios = [] if j > 0: for jT, div in zip(inc, incs[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[n_figs / 2].set_ylabel( 'Ratio to {}'.format(names[0]), fontsize=14 ) #Add y-axis labels to left- and righmost subfigures if (n_figs > 4): axs[-1].set_ylabel('Ratio to {}'.format(names[0]), fontsize=18) for ratio, pT, ax in zip(ratios[start:], jetPt[start:], axs[n_figs / 2:n_figs + 1]): plot = rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, ax.plot([0, 10], [1, 1], 'k--') line = plot.get_children()[0] line.set_markersize(mSize) if (styles[j] > 23): line.set_markerfacecolor('none') line.set_color(color) #if(i == 0): ax.set_yscale('linear') ax.set_xlim([xlow, 10]) #Set x-axis limits ax.set_ylim([0, 2.2]) #Set y-axis limits axs[0].legend(loc='lower left') plt.savefig( "PythonFigures/HighMJetConeJtInclusivePtFrom{}To{}.pdf".format( start, end), format='pdf') #Save figure plt.show() #Draw figure on screen
def drawBackgroundQA(signals, signals_randomBg, names, colors, styles): for sig1, sig2, name in zip(signals, signals_randomBg, names): start = 4 end = 8 n_figs = 6 if (end > start + n_figs / 2): end = start + n_figs / 2 n_rows = 2 if (n_figs == 2): fig, axs = defs.makeRatio(xlog=True, ylog=True, d=d, shareY=False, figsize=(5, 7.5)) else: fig, axs = defs.makegrid(n_figs / 2, 2, xlog=True, ylog=True, d=d, shareY=False, figsize=(10, 7.5) if n_figs == 4 else (n_figs * 15 / 8, 7.5)) axs = axs.reshape(n_figs) axs[1].text(0.12, 0.002, name + '\n' + d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n' + d['cut'], fontsize=11) axs[n_figs / 2].set_ylabel( 'Ratio to {}'.format(names[0]), fontsize=14) #Add y-axis labels to left- and righmost subfigures for h1, h2, pT, ax, axRatio, i in zip(sig1[start:], sig2[start:], jetPt[start:], axs[0:n_figs / 2], axs[n_figs / 2:n_figs + 1], range(0, 9)): h1.SetMarkerColor(colors[0]) h1.SetMarkerStyle(styles[0]) h1.SetLineColor(colors[0]) h2.SetMarkerColor(colors[1]) h2.SetMarkerStyle(styles[1]) h2.SetLineColor(colors[1]) plot = rplt.errorbar(h1, xerr=False, emptybins=False, axes=ax, label="Perp. cone", fmt='o', fillstyle='none') #Plot jT histogram, plot = rplt.errorbar(h2, xerr=False, emptybins=False, axes=ax, label="Random bg", fmt='o', fillstyle='none') #Plot jT histogram, ax.text( 0.5, 1e2, r'${:02d}\:\mathrm{{GeV}} < p_\mathrm{{T,jet}} < {:02d}\:\mathrm{{GeV}}$' .format(pT[0], pT[1])) ax.set_xlim([xlow, 10]) #Set x-axis limits ax.set_ylim([5e-5, 2e3]) #Set y-axis limits #ax.set_xticklabels(ax.get_xticklabels(),horizontalalignment='left') ratio = h1.Clone() ratio.Divide(h2) axRatio.plot([0, 10], [1, 1], 'k--') plot = rplt.errorbar(ratio, xerr=False, emptybins=False, axes=axRatio, label='Ratio', fmt='o') #Plot ratio histogram, axRatio.set_yscale('linear') axRatio.set_xlim([xlow, 10]) #Set x-axis limits axRatio.set_ylim([0, 2.2]) #Set y-axis limits axs[0].legend(loc='lower left') #plt.savefig("PythonFigures/HighMJetConeJtInclusivePtFrom{}To{}_{}.pdf".format(start,end,name),format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): print('Number of arguments: ', len(sys.argv), 'arguments.') print('Argument list:', str(sys.argv)) filename = sys.argv[1] if len(sys.argv) > 2: fileData = sys.argv[2] else: fileData = None print("Input file: ") print(filename) Njets = 9 if fileData is not None: fD = root_open(fileData, 'read') iS = 0 gGausRMSData = fD.Get("gGausRMS{:02d}".format(iS)) gGausRMSerrData = fD.Get("gGausRMS{:02d}_Systematics".format(iS)) gGausYieldData = fD.Get("gGausYield{:02d}".format(iS)) gGausYielderrData = fD.Get("gGausYield{:02d}_Systematics".format(iS)) gGammaRMSData = fD.Get("gGammaRMS{:02d}".format(iS)) gGammaRMSerrData = fD.Get("gGammaRMS{:02d}_Systematics".format(iS)) gGammaYieldData = fD.Get("gGammaYield{:02d}".format(iS)) gGammaYielderrData = fD.Get("gGammaYield{:02d}_Systematics".format(iS)) with root_open(filename, 'read') as f: FullJets_jT = [] colors = (1, 2, 3) for iF, c in zip((8, 6, 7), colors): jT = [ f.get( 'AliJJetJtTask/AliJJetJtHistManager/JetConeJtWeightBin/JetConeJtWeightBinNFin{:02d}JetPt{:02d}' .format(iF, ij)) for ij in range(Njets) ] bgJt = [ f.get( 'AliJJetJtTask/AliJJetJtHistManager/BgJtWeightBin/BgJtWeightBinNFin{:02d}JetPt{:02d}' .format(iF, ij)) for ij in range(Njets) ] jetPtBin = [ f.get( 'AliJJetJtTask/AliJJetJtHistManager/JetPtBin/JetPtBinNFin{:02d}JetPt{:02d}' .format(iF, ij)) for ij in range(Njets) ] nJets = [h.Integral() for h in jetPtBin] nBgs = [ f.get( 'AliJJetJtTask/AliJJetJtHistManager/BgTrkNumberBin/BgTrkNumberBinNFin{:02d}JetPt{:02d}' .format(iF, ij)).Integral() for ij in range(Njets) ] FullJets_jT.append(jT) #FullJets_bgJt.append(bgJt) #FullJets_jetPtBin.append(jetPtBin) for j, b, nj, nb in zip(jT, bgJt, nJets, nBgs): j.Rebin(2) b.Rebin(2) j.Scale(1.0 / nj, "width") b.Scale(1.0 / nb, "width") j.SetMarkerColor(c) b.SetMarkerColor(c) j.Add(b, -1.0) jetPt = [ (int( re.search(r'p_{T,jet} : ([\d]*)\.[\d] - ([\d]*).[\d]*', h.GetTitle(), re.M | re.I).group(1)), int( re.search(r'p_{T,jet} : ([\d]*)\.[\d] - ([\d]*).[\d]*', h.GetTitle(), re.M | re.I).group(2))) for h in FullJets_jT[0] ] #Use regular expressions to extract jet pT range from histogram titles jetPtCenter = array('d', [(a + b) / 2.0 for a, b in jetPt]) jetPtErrors = array('d', [(b - a) / 2.0 for a, b in jetPt]) print(jetPt, type(jetPt)) print(jetPtCenter, type(jetPtCenter)) print(jetPtErrors, type(jetPtErrors)) FullJets_fit = [] FullJets_parameters = [] FullJets_gausRMS = [] FullJets_gammaRMS = [] FullJets_gausYield = [] FullJets_gammaYield = [] for jT in FullJets_jT: gausRMS = [] gammaRMS = [] gausRMSe = [] gammaRMSe = [] gausYield = [] gammaYield = [] gausYielde = [] gammaYielde = [] fits = [] parameters = [] for h, i in zip(jT, range(Njets)): fit, d = fitJtHisto(h, '', 1, i, 8) fits.append(fit) parameters.append(d) gausRMS.append(d['gausRMS']) gausRMSe.append(d['gausRMSe']) gammaRMS.append(d['gammaRMS']) gammaRMSe.append(d['gammaRMSe']) gausYield.append(d['gausYield']) gausYielde.append(d['gausYielde']) gammaYield.append(d['gammaYield']) gammaYielde.append(d['gammaYielde']) gausRMSg = Graph(len(gausRMS) - 2) gammaRMSg = Graph(len(gammaRMS) - 2) gausYieldg = Graph(len(gausYield) - 2) gammaYieldg = Graph(len(gammaYield) - 2) for h, he, g in zip((gausYield, gammaYield), (gausYielde, gammaYielde), (gausYieldg, gammaYieldg)): for x, xe, a, e, i in zip(jetPtCenter[2:], jetPtErrors[2:], h[2:], he[2:], range(len(gausRMS) - 2)): g.SetPoint(i, x, a) g.SetPointError(i, xe, xe, e, e) for a, b, c, d, e, f, i in zip(gausRMS[2:], gammaRMS[2:], gausRMSe[2:], gammaRMSe[2:], jetPtCenter[2:], jetPtErrors[2:], range(len(gausRMS) - 2)): gausRMSg.SetPoint(i, e, a) gausRMSg.SetPointError(i, f, f, c, c) gammaRMSg.SetPoint(i, e, b) gammaRMSg.SetPointError(i, f, f, d, d) FullJets_gausRMS.append(gausRMSg) FullJets_gammaRMS.append(gammaRMSg) FullJets_gausYield.append(gausYieldg) FullJets_gammaYield.append(gammaYieldg) FullJets_fit.append(fits) FullJets_parameters.append(parameters) if fileData is not None: FullJets_gausRMS.append(gGausRMSData) FullJets_gammaRMS.append(gGammaRMSData) FullJets_gausYield.append(gGausYieldData) FullJets_gammaYield.append(gGammaYieldData) fig, axs = plt.subplots(2, 1, figsize=(7, 7)) ax = axs[0] ax.set_xlim([0.1, 15]) ax.set_ylim([5e-6, 2e3]) ax.set_xlabel(r'$j_{T}\left(GeV/c\right)$', fontsize=labelsize) ax.set_ylabel(r'$\frac{1}{N_{jets}}\frac{dN}{j_{T}dj_{T}}$', fontsize=labelsize) ratios = [] ax.set_xscale('log') ax.set_yscale('log') for h, c, R in zip(FullJets_jT, (0, 1, 2, 3), Rs): h[6].SetMarkerColor(colors[c]) h[6].SetMarkerStyle(styles[c]) h[6].SetLineColor(colors[c]) ratio = h[6].Clone() ratio.Divide(FullJets_jT[1][6]) ratios.append(ratio) plot = rplt.errorbar(h[6], xerr=False, emptybins=False, label='R = {:.1f}'.format(R), axes=ax, fmt='+') line = plot.get_children()[0] line.set_markersize(mSize) if (styles[c] > 23): line.set_markerfacecolor('none') #line.set_markeredgecolor(color) line.set_color(colors[c]) ax.text( 0.15, 0.001, 'Pythia \n Full Jets\n' + r'Anti-$k_T$' + '\n' + r'$p_{{T,\mathrm{{jet}}}}$: {:02d}-{:02d} GeV/c'.format(60, 80), fontsize=10) handles, labels = ax.get_legend_handles_labels() handles = [ container.ErrorbarContainer(h, has_xerr=False, has_yerr=True) if isinstance(h, container.ErrorbarContainer) else h for h in handles ] ax.legend(handles, labels, loc='upper right', numpoints=1, prop={'family': 'monospace'}) #ax.legend(loc = 'upper right') ax.set_xlim([0.1, 15]) ax.set_ylim([5e-6, 2e3]) ax.grid(True) ax = axs[1] ax.grid(True) ax.set_xlabel(r'$j_{T}\left[GeV\right]$', fontsize=labelsize) ax.set_ylabel('Ratio', fontsize=labelsize) #Add x-axis labels for bottom row for ratio, c in zip(ratios, (0, 1, 2, 3)): #ratio.SetMarkerColor(c) #ratio.SetMarkerStyle(24) plot = rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax) line = plot.get_children()[0] line.set_markersize(mSize) if (styles[c] > 23): line.set_markerfacecolor('none') #line.set_markeredgecolor(color) line.set_color(colors[c]) ax.set_xlim([0.1, 15]) ax.set_ylim([0.1, 3]) ax.set_xscale('log') plt.tight_layout() plt.subplots_adjust(wspace=0, hspace=0) #Set space between subfigures to 0 plt.savefig("PythonFigures/RcomparisonSignalPt6080.pdf".format(file), format='pdf') #Save figure plt.show() #Draw figure on screen drawWithErrors2Combined(FullJets_gausRMS, FullJets_gammaRMS, 15, 500, 1, 0, 1.65, 0, r'jet $p_T (GeV/c)$', r'$\sqrt{\left<j_T^2\right>}$', 'Pythia', 'PythonFigures/RcomparisonRMS', separate=True) return drawWithErrors2Combined( FullJets_gausYield, FullJets_gammaYield, 15, 500, 1, 0, 10, 0, r'jet $p_T$', r'Yield', 'Pythia', 'PythonFigures/RcomparisonYield', ) ratios = [] for hists in FullJets_jT: if hists is not None: ratio = [] for h, true in zip(hists, FullJets_jT[1]): h2 = h.Clone() h2.Divide(true) ratio.append(h2) else: ratio = None ratios.append(ratio) fig, axs = defs.makegrid(4, 2, xlog=True, ylog=False, d=d, shareY=False) axs = axs.reshape(8) axs[4].set_ylabel("Ratio to R = 0.4", fontsize=labelsize) axs[7].set_ylabel("Ratio to R = 0.4", fontsize=labelsize) axs[1].text( 0.02, 0.005, 'Pythia\n' r'pPb $\sqrt{s_{NN}} = 5.02 \mathrm{TeV}$' '\n Full jets \n' r'Anti-$k_T$', fontsize=7 ) #Add text to second subfigure, first parameters are coordinates in the drawn scale/units for hists, R in zip(FullJets_jT, Rs): for jT, ax, i, pT in zip(hists[2:], axs[0:4], range(0, 9), jetPt[2:]): rplt.errorbar(jT, emptybins=False, xerr=False, label="R = {:.1f}".format(R), axes=ax, fmt='o') #Plot jT histogram, ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ax.set_xlim([0.01, 20]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.set_yscale('log') ax.grid(True) for ratio in ratios: for r, ax in zip(ratio[2:], axs[4:8]): rplt.errorbar(r, axes=ax, emptybins=False, xerr=False) ax.set_xlim([0.01, 20]) ax.set_ylim([0.1, 3]) ax.grid(True) axs[0].legend(loc='lower left') plt.savefig("PythonFigures/RcomparisonSignal.pdf", format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): print('Number of arguments: ', len(sys.argv), 'arguments.') print('Argument list:', str(sys.argv)) filename1 = "Pythia/pythia8226_pp5TeV_Monash2013_clusterCorr100_9000.root" filename2 = "Pythia/pythia8226_pp5TeV_Monash2013_clusterCorr98_6800.root" filename3 = "Pythia/pythia8226_pp5TeV_Monash2013_clusterCorr102_5000.root" filename4 = "Pythia/pythia8226_pp5TeV_Monash2013_JetScaleUp_4000.root" filename5 = "Pythia/pythia8226_pp5TeV_Monash2013_JetScaleDown_2000.root" filename_default = "JetJtAna_Default_20190121_153453.root" filename_hadcorr = "JetJtAna_HadCorr_20190121_152726.root" # if(len(sys.argv) > 3): # start = int(sys.argv[3]) # else: # start = 1 start = 2 Default_data = dataset("LHC13b_default", NFIN=0, range=(0, 6), filename=filename_default, directory='AliJJetJtTask/AliJJetJtHistManager', color=2, style=24, rebin=4) HadCorr_data = dataset("LHC13b_hadcorr", NFIN=0, range=(0, 6), filename=filename_hadcorr, directory='AliJJetJtTask/AliJJetJtHistManager', color=2, style=24, rebin=4) Default = dataset("Default", NFIN=0, range=(0, 8), filename=filename1, directory='JCDijetBaseTask/jcdijet', color=2, style=24, rebin=4) HadCorr_high = dataset("-2%", NFIN=0, range=(0, 8), filename=filename2, directory='JCDijetBaseTask/jcdijet', color=2, style=24, rebin=4) HadCorr_low = dataset("+2%", NFIN=0, range=(0, 8), filename=filename3, directory='JCDijetBaseTask/jcdijet', color=2, style=24, rebin=4) JetScale_up = dataset("-2%", NFIN=0, range=(0, 8), filename=filename4, directory='JCDijetBaseTask/jcdijet', color=2, style=24, rebin=4) #JetScale_down = dataset("-2%",NFIN=0,range=(0,8),filename=filename5,directory='JCDijetBaseTask/jcdijet',color=2,style=24,rebin=4) LHC13b = [Default_data, HadCorr_data] LHC13b_signal = [ x.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=False) for x in LHC13b ] jetPt = Default_data.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=True)[1] LHC13b_graphs = [x.getGraphs() for x in LHC13b] LHC13b_gausRMS = [x[0] for x in LHC13b_graphs] LHC13b_gammaRMS = [x[1] for x in LHC13b_graphs] LHC13b_gausYield = [x[2] for x in LHC13b_graphs] LHC13b_gammaYield = [x[3] for x in LHC13b_graphs] LHC13b_systGausRMS_rel = defs.makeSystError(LHC13b_gausRMS[0], LHC13b_gausRMS[1], rel=True) LHC13b_systGausRMS_rel.SetName("GausRMS_hadcorrSystematics_relative") LHC13b_systGammaRMS_rel = defs.makeSystError(LHC13b_gammaRMS[0], LHC13b_gammaRMS[1], rel=True) LHC13b_systGammaRMS_rel.SetName("GammaRMS_hadcorrSystematics_relative") defs.drawErrors2( LHC13b_systGausRMS_rel, 20, 150, 0, -0.10, 0.10, 0, "Narrow RMS", "HadCorr", "_data", "SystematicErrors/SystematicErrorsGausRMS_EmcalHadCorr.pdf", 0, 0, 0.02) defs.drawErrors2( LHC13b_systGammaRMS_rel, 20, 150, 0, -0.10, 0.10, 0, "Wide RMS", "HadCorr", "_data", "SystematicErrors/SystematicErrorsGammaRMS_EmcalHadCorr.pdf", 0, 0, 0.02) colors = [1, 2, 3, 4] names = ["Default", "HadCorr"] n_figs = 8 n_rows = 2 fig, axs = defs.makegrid(4, n_figs // 4, xlog=True, ylog=True, d=d, shareY=False, figsize=(15, 7.5)) axs = axs.reshape(8) axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone' + '\n Inclusive jT' + '\n', fontsize=7) for signal, name, color, j in zip(LHC13b_signal, names, colors, range(10)): print("Plot {}".format(name)) for jT, pT, ax, i in zip(signal[start:], jetPt[start:], axs[0:4], range(0, 9)): print(i) jT.SetMarkerColor(color) jT.SetLineColor(color) plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=name, fmt='o', fillstyle='none', ecolor='blue') #Plot jT histogram, ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ax.set_xlim([0.1, 22]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(), horizontalalignment='left') ratios = [] if j > 0: for jT, div in zip(signal, LHC13b_signal[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[4].set_ylabel( 'Ratio', fontsize=9 ) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio', fontsize=9) for ratio, pT, ax in zip(ratios[start:], jetPt[start:], axs[4:9]): rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, print("Draw {}".format(ratio.GetName())) #if(i == 0): ax.set_yscale('linear') ax.set_xlim([0.1, 20]) #Set x-axis limits ax.set_ylim([0.95, 1.05]) #Set y-axis limits axs[0].legend(loc='lower left') plt.savefig( "SystematicErrors/LHC13bHadCorrComparisonJetPt{}To{}.pdf".format( start, start + 4), format='pdf') #Save figure plt.show() #Draw figure on screen return start = 4 datasets = [Default, HadCorr_high, HadCorr_low, JetScale_up] signal, jetPt = Default.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=True) signal2 = HadCorr_high.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=False) signal3 = HadCorr_low.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=False) signal4 = JetScale_up.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=False) #signal5 = JetScale_down.getSubtracted('JetConeJtWeightBin','BgJtWeightBin',jetpt = False) signals = [signal, signal2, signal3, signal4] names = ["Default", "-2%", "+2%", "Jet pT +2%"] if (True): graphs = [data.getGraphs() for data in datasets] gausRMS = [x[0] for x in graphs] gammaRMS = [x[1] for x in graphs] gausYield = [x[2] for x in graphs] gammaYield = [x[3] for x in graphs] systGausRMS = defs.makeSystError(gausRMS[0], gausRMS[1]) systGausRMS.SetName("GausRMS_emcalSystematics") systGammaRMS = defs.makeSystError(gammaRMS[0], gammaRMS[1]) systGammaRMS.SetName("GammaRMS_emcalSystematics") systGausRMS_abs = defs.makeSystError(gausRMS[0], gausRMS[1], abs=True) systGausRMS_abs.SetName("GausRMS_emcalSystematics_absolute") systGammaRMS_abs = defs.makeSystError(gammaRMS[0], gammaRMS[1], abs=True) systGammaRMS_abs.SetName("GammaRMS_emcalSystematics_absolute") systGausRMS_rel = defs.makeSystError(gausRMS[0], gausRMS[1], rel=True) systGausRMS_rel.SetName("GausRMS_emcalSystematics_relative") systGausRMS_rel2 = defs.makeSystError(gausRMS[0], gausRMS[2], rel=True) systGausRMS_rel2.SetName("GausRMS_emcalSystematics_relative2") systGammaRMS_rel = defs.makeSystError(gammaRMS[0], gammaRMS[1], rel=True) systGammaRMS_rel.SetName("GammaRMS_emcalSystematics_relative") systGammaRMS_rel2 = defs.makeSystError(gammaRMS[0], gammaRMS[2], rel=True) systGammaRMS_rel2.SetName("GammaRMS_emcalSystematics_relative2") systGausRMS_rel3 = defs.makeSystError(gausRMS[0], gausRMS[3], rel=True) systGausRMS_rel3.SetName("GausRMS_emcalSystematics_relative") #systGausRMS_rel4 = defs.makeSystError(gausRMS[0],gausRMS[4],rel=True) #systGausRMS_rel4.SetName("GausRMS_emcalSystematics_relative2") systGammaRMS_rel3 = defs.makeSystError(gammaRMS[0], gammaRMS[3], rel=True) systGammaRMS_rel3.SetName("GammaRMS_emcalSystematics_relative") #systGammaRMS_rel4 = defs.makeSystError(gammaRMS[0],gammaRMS[4],rel=True) #systGammaRMS_rel4.SetName("GammaRMS_emcalSystematics_relative2") defs.drawErrors2(systGausRMS_rel, 20, 150, 0, -0.04, 0.04, 0, "Narrow RMS", "-2%", "_data", "SystematicErrors/SystematicErrorsGausRMS_Emcal.pdf", 0, 0, 0.01, error2=systGausRMS_rel2, title3="+2%") defs.drawErrors2(systGammaRMS_rel, 20, 150, 0, -0.04, 0.04, 0, "Wide RMS", "-2%", "_data", "SystematicErrors/SystematicErrorsGammaRMS_Emcal.pdf", 0, 0, 0.01, error2=systGammaRMS_rel2, title3="+2%") defs.drawErrors2( systGausRMS_rel3, 20, 150, 0, -0.04, 0.04, 0, "Narrow RMS", "jet pT -2%", "_data", "SystematicErrors/SystematicErrorsGausRMS_jetScale.pdf", 0, 0, 0.01) defs.drawErrors2( systGammaRMS_rel3, 20, 150, 0, -0.04, 0.04, 0, "Wide RMS", "jet pT -2%", "_data", "SystematicErrors/SystematicErrorsGammaRMS_jetScale.pdf", 0, 0, 0.01) colors = [1, 2, 3, 4] n_figs = 8 n_rows = 2 fig, axs = defs.makegrid(4, n_figs // 4, xlog=True, ylog=True, d=d, shareY=False, figsize=(15, 7.5)) axs = axs.reshape(8) axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone' + '\n Inclusive jT' + '\n', fontsize=7) for signal, name, color, j in zip(signals, names, colors, range(10)): print("Plot {}".format(name)) for jT, pT, ax, i in zip(signal[start:], jetPt[start:], axs[0:4], range(0, 9)): print(i) jT.SetMarkerColor(color) jT.SetLineColor(color) plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=name, fmt='o', fillstyle='none', ecolor='blue') #Plot jT histogram, ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ax.set_xlim([0.1, 22]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(), horizontalalignment='left') ratios = [] if j > 0: for jT, div in zip(signal, signals[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[4].set_ylabel( 'Ratio', fontsize=9 ) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio', fontsize=9) for ratio, pT, ax in zip(ratios[start:], jetPt[start:], axs[4:9]): rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, print("Draw {}".format(ratio.GetName())) #if(i == 0): ax.set_yscale('linear') ax.set_xlim([0.1, 20]) #Set x-axis limits ax.set_ylim([0.95, 1.05]) #Set y-axis limits axs[0].legend(loc='lower left') plt.savefig("SystematicErrors/HadCorrComparisonJetPt{}To{}.pdf".format( start, start + 4), format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): Rebin = 4 colors = [7, 1, 2, 4, 6] Pythia = dataset( "EFf 100", NFIN=1, range=(2, 8), filename="Pythia/pythia8226_pp5TeV_Monash2013_Rbinned.root", directory='/JCDijetBaseTask/jcdijet', color=2, style=24, rebin=Rebin) Pythia2 = dataset( "Eff 97", NFIN=1, range=(2, 8), filename="Pythia/pythia8226_pp5TeV_Monash2013_eff97_14k.root", directory='/JCDijetBaseTask/jcdijet', color=3, style=24, rebin=Rebin) inclusive, jetPt = Pythia.getHist('JetConeJtWeightBin', jetpt=True) datasets = [Pythia] datasets.append(Pythia2) incs = [inclusive] outputfile = "TrackingSyst.root" for data in datasets[1:]: incs.append(data.getHist('JetConeJtWeightBin', jetpt=False)) names = [data.name() for data in datasets] signals = [ data.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=False) for data in datasets ] graphs = [data.getGraphs() for data in datasets] gausRMS = [x[0] for x in graphs] gammaRMS = [x[1] for x in graphs] gausYield = [x[2] for x in graphs] gammaYield = [x[3] for x in graphs] systGausRMS = defs.makeSystError(gausRMS[0], gausRMS[1]) systGausRMS.SetName("GausRMS_trackingSystematics") systGammaRMS = defs.makeSystError(gammaRMS[0], gammaRMS[1]) systGammaRMS.SetName("GammaRMS_trackingSystematics") systGausRMS_abs = defs.makeSystError(gausRMS[0], gausRMS[1], abs=True) systGausRMS_abs.SetName("GausRMS_trackingSystematics_absolute") systGammaRMS_abs = defs.makeSystError(gammaRMS[0], gammaRMS[1], abs=True) systGammaRMS_abs.SetName("GammaRMS_trackingSystematics_absolute") systGausRMS_rel = defs.makeSystError(gausRMS[0], gausRMS[1], rel=True) systGausRMS_rel.SetName("GausRMS_trackingSystematics_relative") systGammaRMS_rel = defs.makeSystError(gammaRMS[0], gammaRMS[1], rel=True) systGammaRMS_rel.SetName("GammaRMS_trackingSystematics_relative") defs.drawErrors2(systGausRMS_rel, 40, 150, 0, -0.1, 0.1, 0, "Narrow RMS", "Tracking", "_data", "SystematicErrors/SystematicErrorsGausRMS_Tracking.pdf", 0, 0, 0.04) defs.drawErrors2(systGammaRMS_rel, 40, 150, 0, -0.15, 0.15, 0, "Wide RMS", "Tracking", "_data", "SystematicErrors/SystematicErrorsGammaRMS_Tracking.pdf", 0, 0, 0.05) with root_open(outputfile, 'recreate') as f: f.cd() systGausRMS.Write() systGammaRMS.Write() systGausRMS_abs.Write() systGammaRMS_abs.Write() systGausRMS_rel.Write() systGammaRMS_rel.Write() start = 2 end = 7 n_figs = 8 n_rows = 2 fig, axs = defs.makegrid(4, n_figs // 4, xlog=True, ylog=True, d=d, shareY=False, figsize=(15, 7.5)) axs = axs.reshape(n_figs) axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone' + '\n Inclusive jT', fontsize=7) for inc, name, color, j in zip(incs, names, colors, range(10)): print("Plot {}".format(name)) for jT, pT, ax, i in zip(inc[start:], jetPt[start:], axs[0:4], range(0, 9)): jT.SetMarkerColor(color) jT.SetLineColor(color) plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=name, fmt='o', fillstyle='none', ecolor='blue') #Plot jT histogram, ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ax.set_xlim([0.1, 22]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(), horizontalalignment='left') ratios = [] if j > 0: for jT, div in zip(inc, incs[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[4].set_ylabel( 'Ratio', fontsize=9 ) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio', fontsize=9) for ratio, pT, ax in zip(ratios[start:], jetPt[start:], axs[4:9]): rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, #if(i == 0): ax.set_yscale('linear') ax.set_xlim([0.1, 20]) #Set x-axis limits ax.set_ylim([0.8, 1.2]) #Set y-axis limits axs[0].legend(loc='lower left') plt.savefig( "PythonFigures/TrackingR04JetConeJtInclusivePtFrom{}To{}.pdf".format( start, end), format='pdf') #Save figure plt.show() #Draw figure on screen fig, axs = defs.makegrid(4, n_figs // 4, xlog=True, ylog=True, d=d, shareY=False, figsize=(15, 7.5)) axs = axs.reshape(n_figs) axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone' + '\n Subtracted jT', fontsize=7) for signal, name, color, j in zip(signals, names, colors, range(10)): print("Plot {}".format(name)) for jT, pT, ax, i in zip(signal[start:], jetPt[start:], axs[0:4], range(0, 9)): jT.SetMarkerColor(color) jT.SetLineColor(color) plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=name, fmt='o', fillstyle='none', ecolor='blue') #Plot jT histogram, ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ax.set_xlim([0.1, 22]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(), horizontalalignment='left') ratios = [] if j > 0: for jT, div in zip(signal, signals[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[4].set_ylabel( 'Ratio', fontsize=9 ) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio', fontsize=9) for ratio, pT, ax in zip(ratios[start:], jetPt[start:], axs[4:9]): rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, #if(i == 0): ax.set_yscale('linear') ax.set_xlim([0.1, 20]) #Set x-axis limits ax.set_ylim([0.8, 1.2]) #Set y-axis limits axs[0].legend(loc='lower left') plt.savefig( "PythonFigures/TrackingR04JetConeJtSignalPtFrom{}To{}.pdf".format( start, end), format='pdf') #Save figure plt.show() #Draw figure on screen drawWithErrors2Combined(gausRMS, gammaRMS, 15, 500, 1, 0, 1.65, 0, r'jet $p_T$', r'$\sqrt{\left<j_T^2\right>}$', 'Pythia', 'PythonFigures/TrackingSystematicsRMS', separate=True)
def main(): print('Number of arguments: ', len(sys.argv), 'arguments.') print('Argument list:', str(sys.argv)) filename = sys.argv[1] print("Input file: ") print(filename) #FullJets_R04 = dataset("FullR04",NFIN=0,filename=filename,directory='AliJJetJtTask_kEMCEJE/AliJJetJtHistManager',color=2,style=24,rebin=5) Mixed_FullJets_R04 = datasetMixed( "FullR04", NFIN=0, range=5, filename=filename, directory='AliJJetJtTask/AliJJetJtHistManager', directory2='AliJJetJtTask_kEMCEJE/AliJJetJtHistManager', color=2, style=24, rebin=5) bgname = 'BgJtWeightBin' rndmbgname = 'BgRndmJtWeightBin' print("Get Inclusive histograms") inclusive, jetPt = Mixed_FullJets_R04.getHist('JetConeJtWeightBin', jetpt=True) print("Get random background histograms") rndmbgHistos = Mixed_FullJets_R04.getHist(rndmbgname, jetpt=True, isRndmBg=True) print("Get perpendicular cone background histograms") perpbgHistos = Mixed_FullJets_R04.getHist(bgname, jetpt=True, isBg=True) print("Get perpendicular cone bg subtracted signal histograms") signalPerp, jetPt = Mixed_FullJets_R04.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=True) print("Get random bg subtracted signal histograms") signalRand, jetPt = Mixed_FullJets_R04.getSubtracted('JetConeJtWeightBin', 'BgRndmJtWeightBin', jetpt=True, randomBG=True) fig, axs = defs.makegrid(4, 2, xlog=True, ylog=True, d=d, shareY=False) axs = axs.reshape(8) axs[1].text(0.02, 0.005, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n' + d['trigger'] + '\n' + Mixed_FullJets_R04.name(), fontsize=7) for rand, perp, pT, ax, j in zip(rndmbgHistos[0][1::2], perpbgHistos[0][1::2], rndmbgHistos[1][1::2], axs[0:4], range(0, 5)): rplt.errorbar(rand, xerr=False, emptybins=False, axes=ax, label='Random BG', fmt='o') #Plot rand histogram, rplt.errorbar(perp, xerr=False, emptybins=False, axes=ax, label='Perp. Cone BG', fmt='o') #Plot perp histogram, ax.set_xlim([0.01, 20]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ratios = [] for rand, bg in zip(rndmbgHistos[0], perpbgHistos[0]): h = bg.Clone() h.Divide(rand) ratios.append(h) axs[4].set_ylabel( 'Ratio \n Perp/Random', fontsize=9) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio \n Perp/Random', fontsize=9) for ratio, pT, ax, j in zip(ratios[1::2], rndmbgHistos[1][1::2], axs[4:9], range(0, 5)): rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, #if(i == 0): ax.set_xlim([0.01, 20]) #Set x-axis limits ax.set_ylim([0.43, 1.3]) #Set y-axis limits ax.set_yscale('linear') axs[0].legend(loc='lower left') plt.savefig("PythonFigures/MixedFullJetsR04BackgroundComparison.pdf", format='pdf') #Save figure plt.show() #Draw figure on screen fig, axs = defs.makegrid(4, 2, xlog=True, ylog=True, d=d, shareY=False) axs = axs.reshape(8) axs[1].text(0.02, 0.005, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n' + d['trigger'] + '\n' + Mixed_FullJets_R04.name(), fontsize=7) for rand, perp, randBg, inc, pT, ax, j in zip(signalRand[1::2], signalPerp[1::2], rndmbgHistos[0][1::2], inclusive[1::2], jetPt[1::2], axs[0:4], range(0, 5)): rand.SetMarkerColor(2) perp.SetMarkerColor(3) randBg.SetMarkerColor(1) inc.SetMarkerColor(4) rplt.errorbar(rand, xerr=False, emptybins=False, axes=ax, label='Random BG signal', fmt='o') #Plot rand histogram, rplt.errorbar(perp, xerr=False, emptybins=False, axes=ax, label='Perp. Cone BG signal', fmt='o') #Plot jT histogram, ax.set_xlim([0.01, 20]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ratios = [] for rand, perp in zip(signalRand, signalPerp): h = perp.Clone() h.Divide(rand) ratios.append(h) axs[4].set_ylabel( 'Ratio \n Perp/Random', fontsize=9) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio \n Perp/Random', fontsize=9) for ratio, pT, ax, j in zip(ratios[1::2], jetPt[1::2], axs[4:9], range(0, 5)): rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, #if(i == 0): ax.set_xlim([0.01, 20]) #Set x-axis limits ax.set_ylim([0.85, 1.3]) #Set y-axis limits ax.set_yscale('linear') axs[0].legend(loc='lower left') plt.savefig("PythonFigures/MixedFullJetsR04SignalBackgroundComparison.pdf", format='pdf') #Save figure plt.show() #Draw figure on screen fig, axs = defs.makegrid(4, 2, xlog=True, ylog=True, d=d, shareY=False) axs = axs.reshape(8) axs[1].text(0.02, 0.005, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n' + d['trigger'] + '\n' + Mixed_FullJets_R04.name(), fontsize=7) for rand, perp, randBg, inc, pT, ax, j in zip(signalRand[1::2], signalPerp[1::2], rndmbgHistos[0][1::2], inclusive[1::2], jetPt[1::2], axs[0:4], range(0, 5)): rand.SetMarkerColor(2) perp.SetMarkerColor(3) randBg.SetMarkerColor(1) inc.SetMarkerColor(4) rplt.errorbar(rand, xerr=False, emptybins=False, axes=ax, label='Random BG signal', fmt='o') #Plot rand histogram, rplt.errorbar(perp, xerr=False, emptybins=False, axes=ax, label='Perp. Cone BG signal', fmt='o') #Plot jT histogram, rplt.errorbar(randBg, xerr=False, emptybins=False, axes=ax, label='Random BG', fmt='o') #Plot jT histogram, rplt.errorbar(inc, xerr=False, emptybins=False, axes=ax, label='Inclusive', fmt='o') #Plot jT histogram, ax.set_xlim([0.01, 20]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ratiosRand = [] ratiosPerp = [] ratiosBg = [] for rand, perp, bg, inc in zip(signalRand, signalPerp, rndmbgHistos[0], inclusive): h1 = rand.Clone() h1.Divide(inc) ratiosRand.append(h1) h2 = perp.Clone() h2.Divide(inc) ratiosPerp.append(h2) h3 = bg.Clone() h3.Divide(inc) ratiosBg.append(h3) axs[4].set_ylabel( 'Ratio \n Perp/Random', fontsize=9) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio \n Perp/Random', fontsize=9) for ratioRand, ratioPerp, ratioBg, pT, ax, j in zip( ratiosRand[1::2], ratiosPerp[1::2], ratiosBg[1::2], jetPt[1::2], axs[4:9], range(0, 5)): ratioRand.SetMarkerColor(2) ratioPerp.SetMarkerColor(3) ratioBg.SetMarkerColor(1) rplt.errorbar(ratioRand, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, rplt.errorbar(ratioBg, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, rplt.errorbar(ratioBg, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, #if(i == 0): ax.set_xlim([0.01, 20]) #Set x-axis limits ax.set_ylim([0, 1.05]) #Set y-axis limits ax.set_yscale('linear') axs[0].legend(loc='lower left') plt.savefig("PythonFigures/MixedFullJetsR04QABackgroundComparison.pdf", format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): print('Number of arguments: ', len(sys.argv), 'arguments.') print('Argument list:',str(sys.argv)) filename = sys.argv[1] separate = int(sys.argv[2]) if(len(sys.argv) > 3): start = int(sys.argv[3]) end = int(sys.argv[4]) else: start = 1 end = 6 n_figs = end-start print("Number of figs: {}".format(n_figs)) print("Input file: ") print(filename) FullJets_R04 = dataset('Full jets R=0.4',NFIN=0,range=(start,end),filename=filename,directory='AliJJetJtTask/AliJJetJtHistManager',color=2,style=24,rebin=2) #Mixed_FullJets_R04 = datasetMixed("Full jets R=0.4",NFIN=0,range=5,filename=filename,directory='AliJJetJtTask/AliJJetJtHistManager',directory2='AliJJetJtTask_kEMCEJE/AliJJetJtHistManager',color=2,style=24,rebin=2) #signal,jetPt = FullJets_R04.getHist('JtWeightBin',jetpt = True) #signal2 = FullJets_R04.getHist('JtWeightLeadingRefBin',jetpt=False) compareHistsWithRatio(FullJets_R04,['JtWeightBin','JtWeightLeadingRefBin','JtWeightLeadingRefBin','JtWeightLeadingRefBin','JtWeightLeadingRefBin'],['Jet axis ref.','leading ref. (xlong 0.0-0.2)','leading ref. (xlong 0.2-0.4)','leading ref. (xlong 0.4-0.6)','leading ref. (xlong 0.6-1.0)'],step=1,extras=['','Xlong00','Xlong01','Xlong02','Xlong03']) plt.savefig("PythonFigures/JetVsLeadingRefConst.pdf",format='pdf') #Save figure plt.show() sets = compareHistsWithRatio(FullJets_R04,['JetConeJtWeightBin','JetConeJtWeightLeadingRefBin','JetConeJtWeightLeadingRefBin','JetConeJtWeightLeadingRefBin','JetConeJtWeightLeadingRefBin'],['Jet axis ref.','leading ref.(xlong 0.0-0.2)','leading ref.(xlong 0.2-0.4)','leading ref.(xlong 0.4-0.6)','leading ref. (xlong 0.6-1.0)'],step=1,extras=['','Xlong00','Xlong01','Xlong02','Xlong03']) plt.savefig("PythonFigures/JetVsLeadingRefJetCone.pdf",format='pdf') #Save figure plt.show() JtJet = sets[0][0] JtLeadingxlong00 = sets[1][0] JtLeadingxlong01 = sets[2][0] JtLeadingxlong02 = sets[3][0] JtLeadingxlong03 = sets[4][0] JtLeading = [h.clone() for h in sets[1][0]] for h,s,s2,s3 in zip(JtLeading,sets[2][0],sets[3][0],sets[4][0]): h.Add(s,1) h.Add(s2,1) h.Add(s3,1) # print(JtLeading) # for set in sets[2:]: # for h,s in zip(JtLeading,set[0]): # print(s) # h.Add(s,1) jetPt = sets[0][1] jetPtCenter = array('d',[(a+b)/2.0 for a,b in jetPt]) jetPtErrors = array('d',[(b-a)/2.0 for a,b in jetPt]) FullJets_fit = [] FullJets_parameters = [] FullJets_gausRMS = [] FullJets_gammaRMS = [] FullJets_gausYield = [] FullJets_gammaYield = [] for jT,title in zip((JtJet,JtLeading,JtLeadingxlong00,JtLeadingxlong01,JtLeadingxlong02),("Jet ref.","Leading ref","Leading ref.(xlong 0.0-0.2)","Leading ref.(xlong 0.2-0.4)","Leading ref.(xlong 0.4-0.6)","Leading ref.(xlong 0.6-1.0)")): gausRMS = [] gammaRMS = [] gausRMSe = [] gammaRMSe = [] gausYield = [] gammaYield = [] gausYielde = [] gammaYielde = [] fits = [] parameters = [] for h,i in zip(jT,range(Njets)): fit,d = defs.fitJtHisto(h,'',1,i,8,title,draw=False) fits.append(fit) parameters.append(d) gausRMS.append(d['gausRMS']) gausRMSe.append(d['gausRMSe']) gammaRMS.append(d['gammaRMS']) gammaRMSe.append(d['gammaRMSe']) gausYield.append(d['gausYield']) gausYielde.append(d['gausYielde']) gammaYield.append(d['gammaYield']) gammaYielde.append(d['gammaYielde']) gausRMSg = Graph(len(gausRMS)-2) gammaRMSg = Graph(len(gammaRMS)-2) gausYieldg = Graph(len(gausYield) -2) gammaYieldg = Graph(len(gammaYield)-2) for h,he,g in zip((gausYield,gammaYield),(gausYielde,gammaYielde),(gausYieldg,gammaYieldg)): for x,xe,a,e,i in zip(jetPtCenter[2:],jetPtErrors[2:],h[2:],he[2:],range(len(gausRMS)-2)): g.SetPoint(i,x,a) g.SetPointError(i,xe,xe,e,e) for a,b,c,d,e,f,i in zip(gausRMS[2:],gammaRMS[2:],gausRMSe[2:],gammaRMSe[2:],jetPtCenter[2:],jetPtErrors[2:],range(len(gausRMS)-2)): gausRMSg.SetPoint(i,e,a) gausRMSg.SetPointError(i,f,f,c,c) gammaRMSg.SetPoint(i,e,b) gammaRMSg.SetPointError(i,f,f,d,d) FullJets_gausRMS.append(gausRMSg) FullJets_gammaRMS.append(gammaRMSg) FullJets_gausYield.append(gausYieldg) FullJets_gammaYield.append(gammaYieldg) FullJets_fit.append(fits) FullJets_parameters.append(parameters) print(gausRMS[2:]) print(gammaRMS[2:]) print(jetPtCenter[2:]) drawWithErrors2Combined(FullJets_gausRMS,FullJets_gammaRMS,["Jet ref.","Leading ref.","Leading ref.(xlong 0.0-0.2)","Leading ref.(xlong 0.2-0.4)","Leading ref.(xlong 0.4-0.6)"],15,500,1,0,1.85,0,r'jet $p_T$',r'$\sqrt{\left<j_T^2\right>}$','Pythia','PythonFigures/JetVsLeadingRefJetConeFits') return if(separate > 0): fig = plt.figure(1) ax = fig.add_subplot(1,1,1) ax.set_xscale('log') ax.set_yscale('log') ax.text(0.2,0.0005,d['system'] +'\n'+ d['jettype'] +'\n'+ d['jetalg'] + '\n Jet Cone',fontsize = 7) rplt.errorbar(signal[separate],xerr=False,emptybins=False,axes=ax,label="Jet axis reference",fmt='o') #Plot jT histogram, rplt.errorbar(signal2[separate],xerr=False,emptybins=False,axes=ax,label="Leading track reference",fmt='o') ax.text(0.3,1e2,r'$p_{{T,\mathrm{{jet}}}}$:''\n'r' {:02d}-{:02d} GeV'.format(jetPt[separate][0],jetPt[separate][1])) ax.set_xlim([0.1,12]) ax.set_ylim([5e-6,1.5e3]) ax.legend(loc = 'lower left') plt.savefig("PythonFigures/MixedFullJetsR04JetConeJtLeadingRefJetPt{0}.pdf".format(separate),format='pdf') #Save figure plt.show() #Draw figure on screen else: n_rows = n_figs//4 print(n_rows) fig, axs = defs.makegrid(4,n_figs//4,xlog=True,ylog=True,d=d,shareY=True,figsize=(10,5)) axs = axs.reshape(n_figs) axs[1].text(0.12,0.002,d['system'] +'\n'+ d['jettype'] +'\n'+ d['jetalg'] + '\n Jet Cone',fontsize = 7) for jT,jT2,pT,ax,i in zip(signal[start:],signal2[start:],jetPt[start:],axs,range(0,9)): jT.SetMarkerColor(1) jT2.SetMarkerColor(2) plot = rplt.errorbar(jT,xerr=False,emptybins=False,axes=ax,label="Jet axis reference",fmt='o',fillstyle='none',ecolor='black') #Plot jT histogram, plot = rplt.errorbar(jT2,xerr=False,emptybins=False,axes=ax,label="Leading track reference",fmt='o',fillstyle='none',ecolor='red') #Plot jT histogram, ax.text(0.3,1e2,r'$p_{{T,\mathrm{{jet}}}}$:''\n'r' {:02d}-{:02d} GeV'.format(pT[0],pT[1])) ax.set_xlim([0.1,22]) #Set x-axis limits ax.set_ylim([5e-4,2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(),horizontalalignment='left') axs[0].legend(loc = 'lower left') plt.savefig("PythonFigures/MixedFullJetsR04JetConeJtLeadingRefPtFrom{}To{}.pdf".format(start,end),format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): print('Number of arguments: ', len(sys.argv), 'arguments.') print('Argument list:', str(sys.argv)) filename = "rootFiles/legotrain_CF_pPb_2305_20190109_LHC13bcde_minimal.root" separate = 0 start = 2 end = 6 n_figs = end - start Mixed_FullJets_R04 = datasetMixed( "Full jets R=0.4", NFIN=0, range=(1, 5), filename=filename, directory='AliJJetJtTask/AliJJetJtHistManager', directory2='AliJJetJtTask_kEMCEJE/AliJJetJtHistManager', color=2, style=24, rebin=2) compareHistsWithRatio( Mixed_FullJets_R04, ['JtWeightBin', 'JtWeightLeadingRefBin', 'JtWeightLeadingRefBin'], [ 'Jet axis ref.', 'leading ref. (xlong 0.0-0.2)', 'leading ref. (xlong 0.2-0.4)' ], step=1, start=1, extras=['', 'Xlong00', 'Xlong01']) plt.savefig("PythonFigures/JetVsLeadingRefConst.pdf", format='pdf') #Save figure plt.show() sets = compareHistsWithRatio( Mixed_FullJets_R04, [ 'JetConeJtWeightBin', 'JetConeJtWeightLeadingRefBin', 'JetConeJtWeightLeadingRefBin', 'JetConeJtWeightLeadingRefBin', 'JetConeJtWeightLeadingRefBin' ], [ 'Jet axis ref.', 'leading ref.(xlong 0.0-0.2)', 'leading ref.(xlong 0.2-0.4)', 'leading ref.(xlong 0.4-0.6)', 'leading ref. (xlong 0.6-1.0)' ], step=1, extras=['', 'Xlong00', 'Xlong01', 'Xlong02', 'Xlong03']) plt.savefig("PythonFigures/JetVsLeadingRefJetCone.pdf", format='pdf') #Save figure plt.show() JtJet = sets[0][0] JtLeadingxlong00 = sets[1][0] JtLeadingxlong01 = sets[2][0] JtLeadingxlong02 = sets[3][0] JtLeadingxlong03 = sets[4][0] JtLeading = [h.clone() for h in sets[1][0]] for h, s, s2, s3 in zip(JtLeading, sets[2][0], sets[3][0], sets[4][0]): h.Add(s, 1) h.Add(s2, 1) h.Add(s3, 1) jetPt = sets[0][1] jetPtCenter = array('d', [(a + b) / 2.0 for a, b in jetPt]) jetPtErrors = array('d', [(b - a) / 2.0 for a, b in jetPt]) FullJets_fit = [] FullJets_parameters = [] FullJets_gausRMS = [] FullJets_gammaRMS = [] FullJets_gausYield = [] FullJets_gammaYield = [] for jT, title in zip( (JtJet, JtLeading, JtLeadingxlong00, JtLeadingxlong01, JtLeadingxlong02), ("Jet ref.", "Leading ref", "Leading ref.(xlong 0.0-0.2)", "Leading ref.(xlong 0.2-0.4)", "Leading ref.(xlong 0.4-0.6)", "Leading ref.(xlong 0.6-1.0)")): gausRMS = [] gammaRMS = [] gausRMSe = [] gammaRMSe = [] gausYield = [] gammaYield = [] gausYielde = [] gammaYielde = [] fits = [] parameters = [] for h, i in zip(jT, range(Njets)): fit, d = defs.fitJtHisto(h, '', 1, i, 8, title, draw=False) fits.append(fit) parameters.append(d) gausRMS.append(d['gausRMS']) gausRMSe.append(d['gausRMSe']) gammaRMS.append(d['gammaRMS']) gammaRMSe.append(d['gammaRMSe']) gausYield.append(d['gausYield']) gausYielde.append(d['gausYielde']) gammaYield.append(d['gammaYield']) gammaYielde.append(d['gammaYielde']) gausRMSg = Graph(len(gausRMS) - 2) gammaRMSg = Graph(len(gammaRMS) - 2) gausYieldg = Graph(len(gausYield) - 2) gammaYieldg = Graph(len(gammaYield) - 2) for h, he, g in zip((gausYield, gammaYield), (gausYielde, gammaYielde), (gausYieldg, gammaYieldg)): for x, xe, a, e, i in zip(jetPtCenter[2:], jetPtErrors[2:], h[2:], he[2:], range(len(gausRMS) - 2)): g.SetPoint(i, x, a) g.SetPointError(i, xe, xe, e, e) for a, b, c, d, e, f, i in zip(gausRMS[2:], gammaRMS[2:], gausRMSe[2:], gammaRMSe[2:], jetPtCenter[2:], jetPtErrors[2:], range(len(gausRMS) - 2)): gausRMSg.SetPoint(i, e, a) gausRMSg.SetPointError(i, f, f, c, c) gammaRMSg.SetPoint(i, e, b) gammaRMSg.SetPointError(i, f, f, d, d) FullJets_gausRMS.append(gausRMSg) FullJets_gammaRMS.append(gammaRMSg) FullJets_gausYield.append(gausYieldg) FullJets_gammaYield.append(gammaYieldg) FullJets_fit.append(fits) FullJets_parameters.append(parameters) print(gausRMS[2:]) print(gammaRMS[2:]) print(jetPtCenter[2:]) drawWithErrors2Combined(FullJets_gausRMS, FullJets_gammaRMS, [ "Jet ref.", "Leading ref.", "Leading ref.(xlong 0.0-0.2)", "Leading ref.(xlong 0.2-0.4)", "Leading ref.(xlong 0.4-0.6)" ], 15, 500, 1, 0, 1.85, 0, r'jet $p_T$', r'$\sqrt{\left<j_T^2\right>}$', 'Pythia', 'PythonFigures/JetVsLeadingRefJetConeFits') if (separate > 0): fig = plt.figure(1) ax = fig.add_subplot(1, 1, 1) ax.set_xscale('log') ax.set_yscale('log') ax.text(0.2, 0.0005, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone', fontsize=7) rplt.errorbar(signal[separate], xerr=False, emptybins=False, axes=ax, label="Jet axis reference", fmt='o') #Plot jT histogram, rplt.errorbar(signal2[separate], xerr=False, emptybins=False, axes=ax, label="Leading track reference", fmt='o') ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(jetPt[separate][0], jetPt[separate][1])) ax.set_xlim([0.1, 12]) ax.set_ylim([5e-6, 1.5e3]) ax.legend(loc='lower left') plt.savefig( "PythonFigures/MixedFullJetsR04JetConeJtLeadingRefJetPt{0}.pdf". format(separate), format='pdf') #Save figure plt.show() #Draw figure on screen else: n_rows = n_figs // 4 print(n_rows) fig, axs = defs.makegrid(4, 2, xlog=True, ylog=True, d=d, shareY=False, figsize=(10, 5)) axs = axs.reshape(8) #axs[1].text(0.12,0.002,d['system'] +'\n'+ d['jettype'] +'\n'+ d['jetalg'] + '\n Jet Cone',fontsize = 7) ratios = [] for jT, jT2, pT, ax, i in zip(JtJet[start:], JtLeading[start:], jetPt[start:], axs[0:4], range(0, 9)): jT.SetMarkerColor(1) jT.SetMarkerStyle(24) jT.SetLineColor(1) #jT.SetMarkerSize(mSize) jT2.SetMarkerColor(2) jT2.SetMarkerStyle(25) #jT2.SetMarkerSize(mSize) jT2.SetLineColor(2) ratio = jT2.Clone() ratio.Divide(jT) ratios.append(ratio) plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label="Jet axis reference", fmt='o', fillstyle='none', ecolor='black') #Plot jT histogram, line = plot.get_children()[0] line.set_markersize(mSize) line.set_markerfacecolor('none') plot = rplt.errorbar(jT2, xerr=False, emptybins=False, axes=ax, label="Leading track reference", fmt='o', fillstyle='none', ecolor='red') #Plot jT histogram, line = plot.get_children()[0] line.set_markersize(mSize) line.set_markerfacecolor('none') #line.set_color(color) ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ax.set_xlim([0.1, 22]) #Set x-axis limits ax.set_ylim([5e-5, 2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(), horizontalalignment='left') for ratio, ax, i in zip(ratios, axs[4:], range(0, 9)): plot = rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, fmt='o', fillstyle='none', ecolor='black') #Plot jT histogram, line = plot.get_children()[0] line.set_markersize(mSize) line.set_markerfacecolor('none') ax.set_yscale('linear') ax.set_xlim([0.1, 22]) #Set x-axis limits ax.set_ylim([0, 5]) #Set y-axis limits handles, labels = axs[0].get_legend_handles_labels() handles = [ container.ErrorbarContainer(h, has_xerr=False, has_yerr=True) if isinstance(h, container.ErrorbarContainer) else h for h in handles ] axs[0].legend(handles, labels, loc='lower left', numpoints=1) axs[4].set_ylabel('Ratio') axs[7].set_ylabel('Ratio') plt.savefig( "PythonFigures/MixedFullJetsR04JetConeJtLeadingRefPtFrom{}To{}.pdf" .format(start, end), format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): start = 4 end = 8 n_figs = end - start title = "Full jets R=0.4" if (os.path.exists('./RootFiles/Fig0.root')): inFile = "RootFiles/Fig0.root" inF = root_open(inFile, 'r') signal = [inF.Get("jTSignalJetPt{:02d}".format(i)) for i in range(8)] jetPt = [ (int( re.search(r'p_{T,jet} : ([\d]*)\.[\d] - ([\d]*).[\d]*', h.GetTitle(), re.M | re.I).group(1)), int( re.search(r'p_{T,jet} : ([\d]*)\.[\d] - ([\d]*).[\d]*', h.GetTitle(), re.M | re.I).group(2))) for h in signal ] #Use regular expressions to extract jet pT range from histogram titles else: filename = "CF_pPb_legotrain/legotrain_CF_pPb_1839_20180613_LHC13bcde.root" print("Number of figs: {}".format(n_figs)) print("Input file: ") print(filename) Mixed_FullJets_R04 = datasetMixed( title, NFIN=0, range=(1, 5), filename=filename, directory='AliJJetJtTask/AliJJetJtHistManager', directory2='AliJJetJtTask_kEMCEJE/AliJJetJtHistManager', color=2, style=24, rebin=2) signal, jetPt = Mixed_FullJets_R04.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=True) outFile = "Fig0.root" outF = root_open(outFile, "w+") for s, i in zip(signal, range(10)): s.SetName("jTSignalJetPt{:02d}".format(i)) s.Write() outF.Close() n_rows = n_figs // 4 fig, axs = defs.makegrid(4, n_figs // 4, xlog=True, ylog=True, d=d, shareY=True, figsize=(10, 2.5)) axs = axs.reshape(n_figs) axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone', fontsize=7) for jT, pT, ax, i in zip(signal[start:], jetPt[start:], axs, range(0, 9)): plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=title, fmt='o', fillstyle='none', ecolor='blue') #Plot jT histogram, line = plot.get_children()[0] #line.set_markerfacecolor('none') #line.set_markeredgecolor('red') ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ax.set_xlim([0.1, 22]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(), horizontalalignment='left') plt.savefig( "PythonFigures/MixedFullJetsR04JetConeJtSignalPtFrom{}To{}.pdf".format( start, end), format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): print('Number of arguments: ', len(sys.argv), 'arguments.') print('Argument list:', str(sys.argv)) filename = sys.argv[1] separate = int(sys.argv[2]) if (len(sys.argv) > 3): start = int(sys.argv[3]) end = int(sys.argv[4]) else: start = 1 end = 9 n_figs = end - start print("Number of figs: {}".format(n_figs)) print("Input file: ") print(filename) Mixed_FullJets_R04 = datasetMixed( "Full jets R=0.4", NFIN=0, range=(1, 5), filename=filename, directory='AliJJetJtTask/AliJJetJtHistManager', directory2='AliJJetJtTask_kEMCEJE/AliJJetJtHistManager', color=2, style=24, rebin=2) signal, jetPt = Mixed_FullJets_R04.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=True) if (False): if (separate > 0): fig = plt.figure(1) ax = fig.add_subplot(1, 1, 1) ax.set_xscale('log') ax.set_yscale('log') ax.text(0.2, 0.0005, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone', fontsize=7) rplt.errorbar(signal[separate], xerr=False, emptybins=False, axes=ax, label=Mixed_FullJets_R04.name(), fmt='o') #Plot jT histogram, ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(jetPt[separate][0], jetPt[separate][1])) ax.set_xlim([0.1, 12]) ax.set_ylim([5e-6, 1.5e3]) ax.legend(loc='lower left') plt.savefig( "PythonFigures/MixedFullJetsR04JetConeJtSignalJetPt{0}.pdf". format(separate), format='pdf') #Save figure plt.show() #Draw figure on screen else: n_rows = n_figs // 4 print(n_rows) fig, axs = defs.makegrid(4, n_figs // 4, xlog=True, ylog=True, d=d, shareY=True, figsize=(10, 2.5)) axs = axs.reshape(n_figs) axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone', fontsize=7) for jT, pT, ax, i in zip(signal[start:], jetPt[start:], axs, range(0, 9)): plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=Mixed_FullJets_R04.name(), fmt='o', fillstyle='none', ecolor='blue') #Plot jT histogram, line = plot.get_children()[0] #line.set_markerfacecolor('none') #line.set_markeredgecolor('red') ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ax.set_xlim([0.1, 22]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(), horizontalalignment='left') #axs[0].legend(loc = 'lower left') plt.savefig( "PythonFigures/MixedFullJetsR04JetConeJtSignalPtFrom{}To{}.pdf" .format(start, end), format='pdf') #Save figure plt.show() #Draw figure on screen fig, axs = defs.makeRatio(xlog=True, ylog=True, d=d, shareY=False, figsize=(10, 10)) axs = axs.reshape(2) ax = axs[0] for jT, pT, i in zip(signal[start:], jetPt[start:], range(0, 9)): h = jT.Clone() h.Scale(10**i) h.SetMarkerColor(i) label = r'${:02d}\:\mathrm{{GeV}} < p_{{T,\mathrm{{jet}}}} < {:02d}\:\mathrm{{GeV}} \left(\times 10^{:01d}\right)$'.format( pT[0], pT[1], i) plot = rplt.errorbar(h, xerr=False, emptybins=False, axes=ax, label=label, fmt='o', fillstyle='none') #Plot jT histogram, ax.set_xlim([0.1, 22]) ax.set_ylim([5e-4, 2e8]) ax.set_xticklabels(ax.get_xticklabels(), horizontalalignment='left') ax.legend(loc='lower left') plt.show() #Draw figure on screen
def main(): print("Number of arguments: ", len(sys.argv), "arguments.") print("Argument list:", str(sys.argv)) filename = sys.argv[1] separate = int(sys.argv[2]) print("Input file: ") print(filename) full_jets_r04 = dataset( "Full jets R=0.4", NFIN=0, filename=filename, directory="MBDataUnfolder/BayesSubUnfolding", color=2, style=24, rebin=1, isWeight=True, ) # The histograms have already been scaled correctly # Thus no further scaling is needed signal, jetPt = full_jets_r04.getSubtracted( "JetConeJtWeightBin", "BgJtWeightBin", jetpt=True, isWeight=True, ) if not os.path.exists('PythonFigures'): os.makedirs('PythonFigures') if separate > 0: fig = plt.figure(1) ax = fig.add_subplot(1, 1, 1) ax.set_xscale("log") ax.set_yscale("log") ax.text( 0.2, 0.0005, d["system"] + "\n" + d["jettype"] + "\n" + d["jetalg"] + "\n Jet Cone", fontsize=7, ) rplt.errorbar( signal[separate], xerr=False, emptybins=False, axes=ax, label=full_jets_r04.name(), fmt="o", ) # Plot jT histogram, ax.text( 0.3, 1e2, r"$p_{{T,\mathrm{{jet}}}}$:" "\n" r" {:02d}-{:02d} GeV".format(jetPt[separate][0], jetPt[separate][1]), ) ax.set_xlim([0.1, 12]) ax.set_ylim([5e-6, 1.5e3]) ax.legend(loc="lower left") plt.savefig( "PythonFigures/UnfoldedFullJetsR04JetConeJtFinalJetPt{0}.pdf". format(separate), format="pdf", ) # Save figure plt.show() # Draw figure on screen else: fig, axs = defs.makegrid(4, 2, xlog=True, ylog=True, d=d, shareY=True) axs = axs.reshape(8) axs[1].text( 0.12, 0.002, d["system"] + "\n" + d["jettype"] + "\n" + d["jetalg"] + "\n Jet Cone", fontsize=7, ) for jT, pT, ax, i in zip(signal[1:], jetPt[1:], axs, range(0, 9)): rplt.errorbar( jT, xerr=False, emptybins=False, axes=ax, label=full_jets_r04.name(), fmt="o", ) # Plot jT histogram, ax.text( 0.3, 1e2, r"$p_{{T,\mathrm{{jet}}}}$:" "\n" r" {:02d}-{:02d} GeV".format(pT[0], pT[1]), ) ax.set_xlim([0.1, 13]) # Set x-axis limits ax.set_ylim([5e-4, 2e3]) # Set y-axis limits # axs[0].legend(loc = 'lower left') plt.savefig("PythonFigures/UnfoldedFullJetsR04JetConeJtFinal.pdf", format="pdf") # Save figure plt.show() # Draw figure on screen
def main(): print('Number of arguments: ', len(sys.argv), 'arguments.') print('Argument list:', str(sys.argv)) filename = sys.argv[1] print("Input file: ") print(filename) MC_FullJets_R04 = dataset("FullR04", NFIN=0, range=(0, 9), filename=filename, directory='AliJJetJtTask/AliJJetJtHistManager', color=2, style=24, rebin=1) response, jetPt = MC_FullJets_R04.get2DHist( 'TrackJtCorrBin', dir='AliJJetJtTask/AliJJetJtMCHistManager', jetpt=True) ROOT.gStyle.SetOptStat(0) ROOT.gStyle.SetOptTitle(0) linear = ROOT.TF1("linear", "x", 0, 10) linear.SetLineColor(1) linear.SetLineWidth(2) linear.SetLineStyle(2) x = linspace(0, 10, 50) y = linspace(0, 10, 50) #response[1].Draw('colz') #linear.Draw('Same') ij = 3 rplt.hist2d(response[ij], label=MC_FullJets_R04.name(), norm=LogNorm(), colorbar=True) ax = plt.gca() ax.set_xlim([0, 4]) ax.set_ylim([0, 4]) ax.set_xlabel( r'$j_{T,true}\left[GeV\right]$') #Add x-axis labels for bottom row ax.set_ylabel( r'$j_{T,obs}\left[GeV\right]$') #Add x-axis labels for bottom row plt.plot(x, y, '-r') ax.text(0.5, 2.8, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone \n' + r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(jetPt[ij][0], jetPt[ij][1]), fontsize=10, bbox=dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8), alpha=0.8)) plt.savefig("PythonFigures/ResponseMatrixNFin00JetPt03.pdf", format='pdf') #Save figure d['system'] = r'pPb MC$\sqrt{s_{NN}} = 5.02 \mathrm{TeV}$' fig, axs = defs.makegrid(4, 2, xlog=False, ylog=False, d=d, shareY=True, xtitle=r'$j_{T,true}\left[GeV\right]$', ytitle=r'$j_{T,obs}\left[GeV\right]$') axs = axs.reshape(8) axs[1].text(0.5, 5, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone', fontsize=7, bbox=dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8), alpha=0.7)) for r, pT, ax, i in zip(response[1:], jetPt[1:], axs, range(0, 9)): rplt.hist2d(r, axes=ax, label=MC_FullJets_R04.name(), norm=LogNorm()) x1 = linspace(0, 10, 50) y1 = linspace(0, 10, 50) plt.plot(x1, y1, '-r') ax.text(3.5, 0.5, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1]), bbox=dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8), alpha=0.7)) ax.set_xlim([0, 6.5]) #Set x-axis limits ax.set_ylim([0, 6.5]) #Set y-axis limits axs[0].legend(loc='lower left') #plt.savefig("PythonFigures/MixedFullJetsR04JetConeJtSignal.pdf",format='pdf') #Save figure plt.savefig("PythonFigures/ResponseMatrixNFin00.pdf", format='pdf') #Save figure plt.show() #Draw figure on screen
def drawBackground(background, names, colors, styles): if (n_figs == 2): fig, axs = defs.makeRatio(xlog=True, ylog=True, d=d, shareY=False, figsize=(5, 7.5)) else: fig, axs = defs.makegrid(n_figs / 2, 2, xlog=True, ylog=True, d=d, shareY=False, figsize=(10, 7.5) if n_figs == 4 else (n_figs * 15 / 8, 7.5)) axs = axs.reshape(n_figs) axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n' + d['cut'], fontsize=11) for signal, name, color, j in zip(background, names, colors, range(10)): print("Plot {}".format(name)) for jT, pT, ax, i in zip(signal[start:], jetPt[start:], axs[0:n_figs / 2], range(0, 9)): jT.SetMarkerColor(color) jT.SetMarkerStyle(styles[j]) jT.SetLineColor(color) plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=name, fmt='o', fillstyle='none') #Plot jT histogram, line = plot.get_children()[0] line.set_markersize(mSize) if (styles[j] > 23): line.set_markerfacecolor('none') #line.set_markeredgecolor(color) line.set_color(color) # line.set_markerfacecolor('none') # line.set_markeredgecolor(colors[c]) # line.set_markerfacecolor('none') # line.set_markeredgecolor('none') # line.set_drawstyle('default') # line.set_linestyle('dashed') # line.set_color(colors[c]) ax.text( 0.5, 1e2, r'${:02d}\:\mathrm{{GeV}} < p_{{T,\mathrm{{jet}}}} < {:02d}\:\mathrm{{GeV}}$' .format(pT[0], pT[1])) ax.set_xlim([xlow, 22]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits #ax.set_xticklabels(ax.get_xticklabels(),horizontalalignment='left') ratios = [] if j > 0: for jT, div in zip(signal, background[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[n_figs / 2].set_ylabel( 'Ratio to {}'.format(names[0]), fontsize=18 ) #Add y-axis labels to left- and righmost subfigures if (n_figs > 4): axs[-1].set_ylabel('Ratio to {}'.format(names[0]), fontsize=18) for ratio, pT, ax in zip(ratios[start:], jetPt[start:], axs[n_figs / 2:n_figs + 1]): plot = rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, line = plot.get_children()[0] line.set_markersize(mSize) if (styles[j] > 23): line.set_markerfacecolor('none') line.set_color(color) #if(i == 0): ax.set_yscale('linear') ax.set_xlim([xlow, 9]) #Set x-axis limits ax.set_ylim([0, 2.2]) #Set y-axis limits handles, labels = axs[0].get_legend_handles_labels() handles = [ container.ErrorbarContainer(h, has_xerr=False, has_yerr=True) if isinstance(h, container.ErrorbarContainer) else h for h in handles ] axs[0].legend(handles, labels, loc='lower left', numpoints=1) #axs[0].legend(loc = 'lower left') plt.savefig( "PythonFigures/HighMJetConeJtBackgroundPtFrom{}To{}.pdf".format( start, end), format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): Rebin = 2 Mixed_FullJets_R04 = datasetMixed("pPb Full jets R=0.4",NFIN=0,range=(1,5),filename="CF_pPb_legotrain/legotrain_CF_pPb_1839_20180613_LHC13bcde.root",directory='AliJJetJtTask/AliJJetJtHistManager',directory2='AliJJetJtTask_kEMCEJE/AliJJetJtHistManager',color=colors[0],style=24,rebin=Rebin) Pythia = dataset("Pythia8 4C",NFIN=0,range=(1,8),filename="Pythia/Grid_Monash.root",directory='/JCDijetBaseTask/jcdijet',color=colors[1],style=24,rebin=Rebin) Pythia2 = dataset("Pythia8 Monash",NFIN=0,range=(1,8),filename="Pythia/Grid_Tune4c.root",directory='/JCDijetBaseTask/jcdijet',color=colors[2],style=24,rebin=Rebin) Herwig = dataset("Herwig 7.0",NFIN=0,range=(1,8),filename="Herwig/Herwig-LHCtest.root",directory='/JJetJt',color=colors[3],style=24,rebin=Rebin) Pythia_ALICE = dataset("ALICE Pythia6 Perugia2011",NFIN=0,range=(1,8),filename="CF_pPb_MC_legotrain/legotrain_610_20181010-1926_LHCb4_fix_CF_pPb_MC_ptHardMerged.root",directory='AliJJetJtTask/AliJJetJtHistManager',color=colors[4],style=24,rebin=Rebin) #datasets = [Pythia] #inclusive,jetPt = Pythia.getHist('JetConeJtWeightBin',jetpt = True) #datasets.append(Mixed_FullJets_R04) inclusive,jetPt = Mixed_FullJets_R04.getHist('JetConeJtWeightBin',jetpt = True) datasets = [Mixed_FullJets_R04] incs = [inclusive] datasets.append(Pythia) datasets.append(Pythia2) datasets.append(Herwig) datasets.append(Pythia_ALICE) for data in datasets[1:]: incs.append(data.getHist('JetConeJtWeightBin',jetpt = False)) names = [data.name() for data in datasets] signals = [data.getSubtracted('JetConeJtWeightBin','BgJtWeightBin',jetpt = False) for data in datasets] graphs = [data.getGraphs() for data in datasets] gausRMS = [x[0] for x in graphs] gammaRMS = [x[1] for x in graphs] gausYield = [x[2] for x in graphs] gammaYield = [x[3] for x in graphs] drawWithErrors2Combined(gausRMS,gammaRMS,names,30,150,0,0,1.45,0,r'jet $p_T$',r'$\sqrt{\left<j_T^2\right>}$','Pythia','PythonFigures/RMScomparison',separate=True) start = 3 end = 8 n_figs = 8 n_rows = 2 fig, axs = defs.makegrid(4,n_figs//4,xlog=True,ylog=True,d=d,shareY=False,figsize=(15,7.5)) axs = axs.reshape(n_figs) axs[1].text(0.12,0.002,d['system'] +'\n'+ d['jettype'] +'\n'+ d['jetalg'] + '\n Jet Cone' + '\n Inclusive jT',fontsize = 7) for inc,name,color,j in zip(incs,names,colors,range(10)): print("Plot {}".format(name)) for jT,pT,ax,i in zip(inc[start:],jetPt[start:],axs[0:4],range(0,9)): jT.SetMarkerColor(color) jT.SetMarkerStyle(styles[j]) jT.SetLineColor(color) plot = rplt.errorbar(jT,xerr=False,emptybins=False,axes=ax,label=name,fmt='o',fillstyle='none',ecolor='blue') #Plot jT histogram, line = plot.get_children()[0] line.set_markersize(mSize) if(styles[j] > 23): line.set_markerfacecolor('none') #line.set_markeredgecolor(color) line.set_color(color) ax.text(0.3,1e2,r'$p_{{T,\mathrm{{jet}}}}$:''\n'r' {:02d}-{:02d} GeV'.format(pT[0],pT[1])) ax.set_xlim([0.1,22]) #Set x-axis limits ax.set_ylim([5e-4,2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(),horizontalalignment='left') ratios = [] if j > 0: for jT,div in zip(inc,incs[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[4].set_ylabel('Ratio to {}'.format(names[0]),fontsize=9) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio to {}'.format(names[0]),fontsize=9) for ratio,pT,ax in zip(ratios[start:],jetPt[start:],axs[4:9]): plot = rplt.errorbar(ratio,xerr=False,emptybins=False,axes=ax,label='Ratio',fmt='o') #Plot ratio histogram, line = plot.get_children()[0] line.set_markersize(mSize) if(styles[j] > 23): line.set_markerfacecolor('none') line.set_color(color) #if(i == 0): ax.set_yscale('linear') ax.set_xlim([0.1,20]) #Set x-axis limits ax.set_ylim([0,2.2]) #Set y-axis limits axs[0].legend(loc = 'lower left') plt.savefig("PythonFigures/PythiaR04JetConeJtInclusivePtFrom{}To{}.pdf".format(start,end),format='pdf') #Save figure plt.show() #Draw figure on screen fig, axs = defs.makegrid(4,n_figs//4,xlog=True,ylog=True,d=d,shareY=False,figsize=(15,7.5)) axs = axs.reshape(n_figs) axs[1].text(0.12,0.002,d['system'] +'\n'+ d['jettype'] +'\n'+ d['jetalg'] + '\n Jet Cone' + '\n Subtracted jT',fontsize = 7) for signal,name,color,j in zip(signals,names,colors,range(10)): print("Plot {}".format(name)) for jT,pT,ax,i in zip(signal[start:],jetPt[start:],axs[0:4],range(0,9)): jT.SetMarkerColor(color) jT.SetMarkerStyle(styles[j]) jT.SetLineColor(color) plot = rplt.errorbar(jT,xerr=False,emptybins=False,axes=ax,label=name,fmt='o',fillstyle='none',ecolor='blue') #Plot jT histogram, line = plot.get_children()[0] line.set_markersize(mSize) if(styles[j] > 23): line.set_markerfacecolor('none') #line.set_markeredgecolor(color) line.set_color(color) # line.set_markerfacecolor('none') # line.set_markeredgecolor(colors[c]) # line.set_markerfacecolor('none') # line.set_markeredgecolor('none') # line.set_drawstyle('default') # line.set_linestyle('dashed') # line.set_color(colors[c]) ax.text(0.3,1e2,r'$p_{{T,\mathrm{{jet}}}}$:''\n'r' {:02d}-{:02d} GeV'.format(pT[0],pT[1])) ax.set_xlim([0.1,22]) #Set x-axis limits ax.set_ylim([5e-4,2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(),horizontalalignment='left') ratios = [] if j > 0: for jT,div in zip(signal,signals[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[4].set_ylabel('Ratio to {}'.format(names[0]),fontsize=9) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio to {}'.format(names[0]),fontsize=9) for ratio,pT,ax in zip(ratios[start:],jetPt[start:],axs[4:9]): plot = rplt.errorbar(ratio,xerr=False,emptybins=False,axes=ax,label='Ratio',fmt='o') #Plot ratio histogram, line = plot.get_children()[0] line.set_markersize(mSize) if(styles[j] > 23): line.set_markerfacecolor('none') line.set_color(color) #if(i == 0): ax.set_yscale('linear') ax.set_xlim([0.1,20]) #Set x-axis limits ax.set_ylim([0,2.2]) #Set y-axis limits axs[0].legend(loc = 'lower left') plt.savefig("PythonFigures/PythiaR04JetConeJtSignalPtFrom{}To{}.pdf".format(start,end),format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): print('Number of arguments: ', len(sys.argv), 'arguments.') print('Argument list:', str(sys.argv)) filename = sys.argv[1] filename2 = sys.argv[2] comment = sys.argv[3] if (len(sys.argv) > 4): start = int(sys.argv[4]) else: start = 1 print("Input file: ") print(filename) LHC13d_FullJets = dataset( "LHC13d", NFIN=0, range=(0, 8), filename=filename, directory='AliJJetJtTask_kEMCEJE_{}/AliJJetJtHistManager'.format( comment), color=2, style=24, rebin=2) LHC13e_FullJets = dataset( "LHC13e", NFIN=0, range=(0, 8), filename=filename2, directory='AliJJetJtTask_kEMCEJE_{}/AliJJetJtHistManager'.format( comment), color=2, style=24, rebin=2) signal, jetPt = LHC13d_FullJets.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=True) signal2 = LHC13e_FullJets.getSubtracted('JetConeJtWeightBin', 'BgJtWeightBin', jetpt=False) signals = [signal, signal2] names = ["LHC13d", "LHC13e"] colors = [1, 2] n_figs = 8 n_rows = 2 fig, axs = defs.makegrid(4, n_figs // 4, xlog=True, ylog=True, d=d, shareY=False, figsize=(15, 7.5)) axs = axs.reshape(8) axs[1].text(0.12, 0.002, d['system'] + '\n' + d['jettype'] + '\n' + d['jetalg'] + '\n Jet Cone' + '\n Inclusive jT' + '\n' + comment, fontsize=7) for signal, name, color, j in zip(signals, names, colors, range(10)): print("Plot {}".format(name)) for jT, pT, ax, i in zip(signal[start:], jetPt[start:], axs[0:4], range(0, 9)): print(i) jT.SetMarkerColor(color) jT.SetLineColor(color) plot = rplt.errorbar(jT, xerr=False, emptybins=False, axes=ax, label=name, fmt='o', fillstyle='none', ecolor='blue') #Plot jT histogram, ax.text( 0.3, 1e2, r'$p_{{T,\mathrm{{jet}}}}$:' '\n' r' {:02d}-{:02d} GeV'.format(pT[0], pT[1])) ax.set_xlim([0.1, 22]) #Set x-axis limits ax.set_ylim([5e-4, 2e3]) #Set y-axis limits ax.set_xticklabels(ax.get_xticklabels(), horizontalalignment='left') ratios = [] if j > 0: for jT, div in zip(signal, signals[0]): h = jT.Clone() h.Divide(div) ratios.append(h) axs[4].set_ylabel( 'Ratio e/d', fontsize=9 ) #Add y-axis labels to left- and righmost subfigures axs[-1].set_ylabel('Ratio e/d', fontsize=9) for ratio, pT, ax in zip(ratios[start:], jetPt[start:], axs[4:9]): rplt.errorbar(ratio, xerr=False, emptybins=False, axes=ax, label='Ratio', fmt='o') #Plot ratio histogram, print("Draw {}".format(ratio.GetName())) #if(i == 0): ax.set_yscale('linear') ax.set_xlim([0.1, 20]) #Set x-axis limits ax.set_ylim([0.8, 1.2]) #Set y-axis limits axs[0].legend(loc='lower left') plt.savefig( "PythonFigures/ACsideComparison/ACsideJetConeJtInclusivePtFrom{}To{}{}.pdf" .format(start, start + 4, comment), format='pdf') #Save figure plt.show() #Draw figure on screen
def main(): print("Number of arguments: ", len(sys.argv), "arguments.") print("Argument list:", str(sys.argv)) filename = sys.argv[1] if len(sys.argv) > 2: fileData = sys.argv[2] else: fileData = None print("Input file: ") print(filename) Njets = 9 # FullJets_R04 = dataset("FullR04",NFIN=6,filename=filename,directory='AliJJetJtTask/AliJJetJtHistManager',color=2,style=24,rebin=5) # FullJets_R05 = dataset("FullR05",NFIN=7,filename=filename,directory='AliJJetJtTask/AliJJetJtHistManager',color=3,style=24,rebin=5) # FullJets_R03 = dataset("FullR06",NFIN=8,filename=filename,directory='AliJJetJtTask/AliJJetJtHistManager',color=4,style=24,rebin=5) if fileData is not None: fD = root_open(fileData, "read") iS = 0 gGausRMSData = fD.Get("gGausRMS{:02d}".format(iS)) gGausRMSerrData = fD.Get("gGausRMS{:02d}_Systematics".format(iS)) gGausYieldData = fD.Get("gGausYield{:02d}".format(iS)) gGausYielderrData = fD.Get("gGausYield{:02d}_Systematics".format(iS)) gGammaRMSData = fD.Get("gGammaRMS{:02d}".format(iS)) gGammaRMSerrData = fD.Get("gGammaRMS{:02d}_Systematics".format(iS)) gGammaYieldData = fD.Get("gGammaYield{:02d}".format(iS)) gGammaYielderrData = fD.Get("gGammaYield{:02d}_Systematics".format(iS)) # errGraph = [fD.Get('JetConeJtWeightBinNFin{:02d}JetPt{:02d}_Systematics'.format(iS,i)) for i in range(2,Njets)] #Get jT histograms from file an array # hJtSignalGraph = [fD.Get('JetConeJtWeightBinNFin{:02d}JetPt{:02d}_Statistics'.format(iS,i)) for i in range(2,Njets)] #Get jT histograms from file an array with root_open(filename, "read") as fin: FullJets_jT = [] FullJets_fit = [] FullJets_parameters = [] FullJets_gausRMS = [] FullJets_gammaRMS = [] FullJets_gausYield = [] FullJets_gammaYield = [] colors = (1, 2, 3) for iF in (6, 7, 8): # iF = 8 c = 1 jT = [ fin.get( "AliJJetJtTask/AliJJetJtHistManager/JetConeJtWeightBin/JetConeJtWeightBinNFin{:02d}JetPt{:02d}" .format(iF, ij)) for ij in range(Njets) ] bgJt = [ fin.get( "AliJJetJtTask/AliJJetJtHistManager/BgJtWeightBin/BgJtWeightBinNFin{:02d}JetPt{:02d}" .format(iF, ij)) for ij in range(Njets) ] jetPtBin = [ fin.get( "AliJJetJtTask/AliJJetJtHistManager/JetPtBin/JetPtBinNFin{:02d}JetPt{:02d}" .format(iF, ij)) for ij in range(Njets) ] nJets = [h.Integral() for h in jetPtBin] nBgs = [ fin.get( "AliJJetJtTask/AliJJetJtHistManager/BgTrkNumberBin/BgTrkNumberBinNFin{:02d}JetPt{:02d}" .format(iF, ij)).Integral() for ij in range(Njets) ] FullJets_jT.append(jT) for j, b, nj, nb in zip(jT, bgJt, nJets, nBgs): j.Rebin(4) b.Rebin(4) j.Scale(1.0 / nj, "width") b.Scale(1.0 / nb, "width") j.SetMarkerColor(c) b.SetMarkerColor(c) j.Add(b, -1.0) print(h.GetTitle()) jetPt = [ ( int( re.search( r"p_{T,jet} : ([\d]*)\.[\d] - ([\d]*).[\d]*", h.GetTitle(), re.M | re.I, ).group(1)), int( re.search( r"p_{T,jet} : ([\d]*)\.[\d] - ([\d]*).[\d]*", h.GetTitle(), re.M | re.I, ).group(2)), ) for h in FullJets_jT[0] ] # Use regular expressions to extract jet pT range from histogram titles jetPtCenter = array("d", [(a + b) / 2.0 for a, b in jetPt]) jetPtErrors = array("d", [(b - a) / 2.0 for a, b in jetPt]) print(jetPt, type(jetPt)) print(jetPtCenter, type(jetPtCenter)) print(jetPtErrors, type(jetPtErrors)) for i, jT in enumerate(FullJets_jT): print(i) print(jT) gausRMS = [] gammaRMS = [] gausRMSe = [] gammaRMSe = [] gausYield = [] gammaYield = [] gausYielde = [] gammaYielde = [] fits = [] parameters = [] for h, i in zip(jT, range(Njets)): fit, d = fitJtHisto(h, "", 1, i, 8) fits.append(fit) parameters.append(d) gausRMS.append(d["gausRMS"]) gausRMSe.append(d["gausRMSe"]) gammaRMS.append(d["gammaRMS"]) gammaRMSe.append(d["gammaRMSe"]) gausYield.append(d["gausYield"]) gausYielde.append(d["gausYielde"]) gammaYield.append(d["gammaYield"]) gammaYielde.append(d["gammaYielde"]) gausRMSg = Graph(len(gausRMS) - 2) gammaRMSg = Graph(len(gammaRMS) - 2) gausYieldg = Graph(len(gausYield) - 2) gammaYieldg = Graph(len(gammaYield) - 2) for h, he, g in zip( (gausYield, gammaYield), (gausYielde, gammaYielde), (gausYieldg, gammaYieldg), ): for x, xe, a, e, i in zip( jetPtCenter[2:], jetPtErrors[2:], h[2:], he[2:], range(len(gausRMS) - 2), ): g.SetPoint(i, x, a) g.SetPointError(i, xe, xe, e, e) for a, b, c, d, e, f, i in zip( gausRMS[2:], gammaRMS[2:], gausRMSe[2:], gammaRMSe[2:], jetPtCenter[2:], jetPtErrors[2:], range(len(gausRMS) - 2), ): gausRMSg.SetPoint(i, e, a) gausRMSg.SetPointError(i, f, f, c, c) gammaRMSg.SetPoint(i, e, b) gammaRMSg.SetPointError(i, f, f, d, d) FullJets_gausRMS.append(gausRMSg) print(len(FullJets_gausRMS)) FullJets_gammaRMS.append(gammaRMSg) FullJets_gausYield.append(gausYieldg) FullJets_gammaYield.append(gammaYieldg) FullJets_fit.append(fits) FullJets_parameters.append(parameters) if fileData is not None: FullJets_gausRMS.append(gGausRMSData) FullJets_gammaRMS.append(gGammaRMSData) FullJets_gausYield.append(gGausYieldData) FullJets_gammaYield.append(gGammaYieldData) print(len(FullJets_gausRMS)) drawWithErrors2Combined( FullJets_gausRMS, FullJets_gammaRMS, 15, 500, 1, 0, 1.65, 0, r"$p_\mathrm{T,jet}$", r"$\sqrt{\left<j_\mathrm{T}^2\right>}$", "Pythia Truth", "PythonFigures/RcomparisonRMS", ) drawWithErrors2Combined( FullJets_gausYield, FullJets_gammaYield, 15, 500, 1, 0, 10, 0, r"$p_\mathrm{T,jet}$", r"Yield", "Pythia Truth", "PythonFigures/RcomparisonYield", ) ratios = [] for hists in FullJets_jT: if hists is not None: ratio = [] for h, true in zip(hists, FullJets_jT[1]): h2 = h.Clone() h2.Divide(true) ratio.append(h2) else: ratio = None ratios.append(ratio) fig, axs = defs.makegrid(4, 2, xlog=True, ylog=False, d=d, shareY=False) axs = axs.reshape(8) axs[4].set_ylabel("Ratio to R = 0.4") axs[7].set_ylabel("Ratio to R = 0.4") axs[1].text( 0.02, 0.005, "Pythia\n" r"pPb $\sqrt{s_{NN}} = 5.02 \mathrm{TeV}$" "\n Full jets \n" r"Anti-$k_\mathrm{T}$", fontsize=7, ) # Add text to second subfigure, first parameters are coordinates in the drawn scale/units for hists, R in zip(FullJets_jT, Rs): for jT, ax, i, pT in zip(hists[2:], axs[0:4], range(0, 9), jetPt[2:]): rplt.errorbar( jT, emptybins=False, xerr=False, label="R = {:.1f}".format(R), axes=ax, fmt="o", ) # Plot jT histogram, ax.text( 0.3, 1e2, r"$p_\mathrm{T,jet}$:" "\n" r" {:02d}-{:02d} GeV".format(pT[0], pT[1]), ) ax.set_xlim([0.01, 20]) # Set x-axis limits ax.set_ylim([5e-4, 2e3]) # Set y-axis limits ax.set_yscale("log") ax.grid(True) for ratio in ratios: for r, ax in zip(ratio[2:], axs[4:8]): rplt.errorbar(r, axes=ax, emptybins=False, xerr=False) ax.set_xlim([0.01, 20]) ax.set_ylim([0.1, 3]) ax.grid(True) axs[0].legend(loc="lower left") plt.savefig("PythonFigures/RcomparisonSignal.pdf", format="pdf") # Save figure plt.show() # Draw figure on screen