def __draw(self): from ROOT import kDashed, kRed, kGreen, kBlue, kBlack from ROOT import TCanvas from ROOT import TPaveText self.__year_label = TPaveText(0.71, 0.72, 0.89, 0.85, "NDC") self.__year_label.SetFillColor(0) self.__year_label.AddText(self.__year) self.__year_label.SetBorderSize(0) obs = self.__masses.values() self.__canvas = TCanvas('wpv_canvas', 'wpv_canvas', len(obs) * 600, 533) for (p,o) in zip(self.__canvas.pads(len(obs)), obs): from P2VV.Utilities.Plotting import plot plot(p, o, pdf = self.__pdf, data = self._data , dataOpts = dict(MarkerSize = 0.8, MarkerColor = kBlack, Binning = 50) , pdfOpts = dict(LineWidth = 2) , plotResidHist = 'BX' , xTitle = 'M_{#mu^{+}#mu^{-}} [MeV/c^{2}]' , yTitle = 'Candidates / (%2.1f MeV/c^{2})' % ((o.getMax() - o.getMin()) / float(50)) , components = { 'wpv_bkg_*' : dict( LineColor = kRed, LineStyle = kDashed ) , 'wpv_psi_*' : dict( LineColor = kGreen, LineStyle = kDashed ) , 'wpv_sig_*' : dict( LineColor = kBlue, LineStyle = kDashed ) } ) self.__canvas.cd(1) self.__year_label.Draw() self.__canvas.Update() self.__draw_time() if self.__t_diff: self.__draw_t_diff()
def splot( pdf, sdata ) : # switch off all yields, except current one from contextlib import contextmanager @contextmanager def __select_component( i, yields ): orig = dict( (j,j.getVal()) for j in yields ) [ j.setVal(0) for j in orig.iterkeys() if j!=i ] try : yield finally : [ j.setVal(v) for (j,v) in orig.iteritems() ] from ROOT import TCanvas, kDashed, kRed, kGreen, kBlue, kBlack canvas = TCanvas(pdf.GetName() + '_splot') obs = [ o for o in pdf.Observables() if hasattr(o,'frame') and o not in sdata.usedObservables() ] for (p,o) in zip( canvas.pads(len(obs)), obs ) : # select yields _yields = [ y for y in pdf.Parameters() if y.getAttribute('Yield') ] # loop over components for (pp,i) in zip( p.pads(1,len(_yields)), _yields ) : # switch off all yields, except current one with __select_component( i, _yields ) : # plot both weighed data and PDF # TODO: add the same color coding as above... c_name = i.GetName()[2:] c_opts = { 'signal' : dict( LineColor = kGreen ) , 'psi_background' : dict( LineColor = kRed ) , 'cmb_background' : dict( LineColor = kBlue ) } from P2VV.Utilities.Plotting import plot plot( pp, o, sdata.data( c_name ), pdf, pdfOpts = c_opts[c_name] if c_name in c_opts else {}) return canvas
def __draw_time(self): from ROOT import kDashed, kRed, kGreen, kBlue, kBlack from ROOT import TCanvas from itertools import product self.__time_canvases = [] t = self.__time from P2VV.Utilities.Plotting import plot from ROOT import RooArgSet for logy, (c, shape) in product((True, False), self.__shapes.items()): cn = 'wpv_time_%s' % c.GetName() if logy: cn += '_log' p = TCanvas(cn, cn, 600, 400) self.__time_canvases.append(p) nBins = 80 frame = plot(p, t, pdf = shape, data = self.__sdatas[c] , frameOpts = dict(Title = c.GetName()) , dataOpts = dict(MarkerSize = 0.8, Binning = nBins, MarkerColor = kBlack) , pdfOpts = dict(LineWidth = 2) , logy = logy, yScale = (1 if logy else 0, None) , plotResidHist = False)[0] frame.GetXaxis().SetTitle('t [ps]') if logy: frame.GetYaxis().SetRangeUser(1, 7000 if self.__year == '2012' else 5000) frame.GetYaxis().SetTitle('Candidates / (%3.2f ps)' % ((t.getMax() - t.getMin()) / float(nBins))) self.__year_label.Draw() from P2VV.Utilities.Resolution import plot_dir p.Print(os.path.join(plot_dir, 'wpv_time_%s_%s_%s.pdf' % (c.GetName()[4:], self.__year, 'log' if logy else 'linear')), EmbedFonts = True)
def Oldsplot( canv, sdata, pdf, frameOpts = dict(), dataOpts = dict() , pdfOpts = dict() ) : obs = [ o for o in pdf.Observables() if hasattr(o,'frame') and o not in sdata.usedObservables() ] for (p,o) in zip( canv.pads(len(obs)), obs ) : # snapshot yeilds _yields = dict( (p,p.getVal()) for p in pdf.Parameters() if p.getAttribute('Yield') ) # loop over components for (pp,i) in zip( p.pads(1,len(_yields)), _yields.iterkeys() ) : # switch off all yields, except current one for j in filter( lambda x: x!=i, _yields.iterkeys() ) : j.setVal(0) # and plot both weighed data and PDF from P2VV.Utilities.Plotting import plot c_name = i.GetName()[2:] if 'Title' not in frameOpts : frameOpts['Title'] = '%s : %s' % ( c_name , o.GetTitle() ) plot( pp, o, sdata.data( c_name ), pdf , pdfOpts = pdfOpts[c_name] if c_name in pdfOpts else {} , frameOpts = frameOpts , dataOpts = dataOpts ) # and put back the original value! for (i,v) in _yields.iteritems() : i.setVal(v)
def __draw_t_diff(self): from ROOT import kDashed, kRed, kGreen, kBlue, kBlack from ROOT import TCanvas self.__diff_canvases = [] t_diff = self.__t_diff from ROOT import RooArgSet for c, shape in self.__diff_shapes.iteritems(): name = 'wpv_diff_%s' % c.GetName() canvas = TCanvas(name, name, 600, 400) p = canvas.cd() self.__diff_canvases.append(canvas) from P2VV.Utilities.Plotting import plot plot(p, t_diff, pdf = shape, data = self.__sdatas[c] , dataOpts = dict(MarkerSize = 0.8, Binning = 80, MarkerColor = kBlack) , pdfOpts = dict(LineWidth = 2) , xTitle = 't_{rec} - t_{true} [ps]' , yTitle = 'Candidates / (12.5 fs)' , logy = False , plotResidHist = False) self.__year_label.Draw() from P2VV.Utilities.Resolution import plot_dir canvas.Print(os.path.join(plot_dir, 'wpv_tdiff_%s_%s_linear.pdf' % (c.GetName()[4:], self.__year)), EmbedFonts = True)
def plot_mass(data, prefix = ''): nBins = 100 from ROOT import kDashed, kRed, kGreen, kBlue, kBlack from ROOT import TCanvas mass_canvas = TCanvas('%smass_canvas' % prefix, '%smass_canvas' % prefix, 600, 530) __canvases.append(mass_canvas) from P2VV.Utilities.Plotting import plot frames = plot(mass_canvas, m, pdf = mass_pdf, data = data , dataOpts = dict(MarkerSize = 0.8, MarkerColor = kBlack, Binning = nBins) , pdfOpts = dict(LineWidth = 2) , frameOpts = dict(Title = dataSample) , plotResidHist = True , components = { 'bkg_*' : dict( LineColor = kRed, LineStyle = kDashed ) , 'psi_*' : dict( LineColor = kGreen, LineStyle = kDashed ) , 'sig_*' : dict( LineColor = kBlue, LineStyle = kDashed ) }) frames[1].GetXaxis().SetTitle('M_{J/#psi K^{+}K^{-}} [MeV/c^2]') frames[0].GetYaxis().SetTitle('Candidates / (%3.2f MeV/c^2)' % ((m.getMax() - m.getMin()) / float(nBins)))
canv = TCanvas( '%sCanv' % plotVar ) canv.SetLeftMargin(0.18) canv.SetRightMargin(0.05) canv.SetBottomMargin(0.18) canv.SetTopMargin(0.05) print 'makeProjectionPlot: plotting variable "%s" for component "%s"' % ( plotVar, plotComp ) binWidth = ( xMax - xMin ) / float( numBins[plotVar] ) / ( pi if plotVar == 'phi' else 1. ) from P2VV.Utilities.Plotting import plot #redDataSet = dataSet.reduce( ArgSet = [ ws['time'], ws['helcosthetaK'], ws['helcosthetaL'], ws['helphi'] ] ) #plots = plot( canv, obs, redDataSet, plotPdf plots = plot( canv, obs, dataSet, plotPdf , xTitle = obsXTitles[plotVar] , yTitle = obsYTitles[plotVar] % binWidth, logy = True if plotVar == 'timeLog' else False , xTitleOffset = xTitleOffset , yTitleOffset = yTitleOffsets[plotVar] , frameOpts = dict( Range = rangeName, Bins = numBins[plotVar], Title = '' ) , dataOpts = dict( MarkerStyle = markStyle, MarkerSize = markSize, LineWidth = markLineWidth ) , pdfOpts = dict( LineColor = lineColor, LineWidth = lineWidth, LineStyle = lineStyle ) ) from ROOT import TLatex label = TLatex() label.SetTextAlign(32) label.SetTextSize(0.072) drawLabel = label.DrawLatexNDC( LHCbCoords[plotVar][0], LHCbCoords[plotVar][1], LHCbLabel ) plotsFile.Add(drawLabel) canv.Print(plotsFilePath) from ROOT import TObject plotsFile.Write( ROOTFilePath, TObject.kOverwrite )
print '\n\nP2VV - INFO: Plotting decay time and angular distributions of ' + bin dataSlice = sigData.reduce('KKMassCat==KKMassCat::' + bin) pdfSlice = pdfsDict[bin]['total'] binIdx = binNames.index(bin) for ( pad, obs, nBins, xTitle, yScaleRel, logY )\ in zip( [ TCanvas(o.GetName()+bin) for o in observables ] , observables , numBins , ( observables[0].GetTitle()+' [ps]', angleNames[0][1], angleNames[1][1], angleNames[2][1] ) , 2 *(( 1., 1.2 ),) + 2 *(( 1. , 1.2 ),) , ( True, ) + 3 * ( False, ) ) : plot( pad, obs, dataSlice, pdfSlice, xTitle=xTitle, yScaleRel=yScaleRel, logy=logY , frameOpts = dict( Bins = nBins, Name = bin + obs.GetName() + 'Histo' ) , dataOpts = dict( MarkerStyle = markStyle, MarkerSize = markSize ) , pdfOpts = PDFoptsNOBin[bin] if obs==observables[0] else PDFoptsBin[bin] , addPDFs = [ pdfsDict[bin][c] for c in CPcomps ] , addPDFsOpts = [addPDFotpsNOBin[binIdx][c] for c in CPcomps ] if obs==observables[0]\ else [addPDFotpsBin[binIdx][c] for c in CPcomps ] ) lhcbName.Draw() ## print canvas to file fName = bin + '_' + obs.GetName() + '_sFit.ps' pad.Print(fName) # Save all the plots in a root file as RooPlot objects. from P2VV.Utilities.Plotting import _P2VVPlotStash as rooplots from ROOT import TFile plotsFile = TFile('RooPlots6x4.root','recreate') for plot in rooplots: plot.Write() plotsFile.Close()
from P2VV.Load import LHCbStyle from P2VV.Utilities.Plotting import plot from ROOT import TCanvas, kBlue, kRed, kGreen # plot efficiency effCanv = TCanvas( 'effCanv', 'Efficiency' ) for ( pad, obs, func, norm, xTitle )\ in zip( effCanv.pads( 2, 2 ) , obsSet[ 1 : 4 ] , [ effFuncCtk, effFuncCtl, effFuncPhi ] , [ 1. / 4. / pi, 1. / 4. / pi, 1. / 4. ] , angleNames ) : plot( pad, obs, None, func, addPDFs = [ effFunc ] , yScale = ( 0.85, 1.15 ) , pdfOpts = dict( LineColor = kBlue, LineWidth = 2, Normalization = norm ) , addPDFsOpts = [ dict( LineColor = kRed, LineWidth = 2 ) ] ) # plot lifetime and angles timeAnglesCanv = TCanvas( 'timeAnglesCanv', 'Lifetime and Decay Angles' ) for ( pad, obs, nBins, plotTitle, xTitle )\ in zip( timeAnglesCanv.pads( 2, 2 ) , obsSet[ 1 : 4 ] , numBins , [ var.GetTitle() for var in obsSet[ 1 : 4 ] ] , angleNames ) : plot( pad, obs, data, pdf, xTitle = xTitle , frameOpts = dict( Bins = nBins, Title = plotTitle ) , dataOpts = dict( MarkerStyle = markStyle, MarkerSize = markSize )
from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kOrange from ROOT import TCanvas if options.plot: mass_canvas = TCanvas('mass_canvas', 'mass_canvas', 600, 530) from P2VV.Utilities.Plotting import plot pdfOpts = dict() if signal_MC: mass_obs = m else: mass_obs = mpsi ps = plot(mass_canvas.cd(), mass_obs, pdf = mass_pdf, data = data, dataOpts = dict(MarkerSize = 0.8, MarkerColor = kBlack, Binning = 50), pdfOpts = dict(LineWidth = 2, **pdfOpts), plotResidHist = 'BX', xTitle = 'M_{#mu^{+}#mu^{-}} [MeV/c^{2}]', yTitle = 'Candidates / (%3.2f MeV/c^{2})' % ((mass_obs.getMax() - mass_obs.getMin()) / 50), yTitleOffset = 1 / 0.7) plots[''].append(ps) from P2VV.Utilities.Resolution import plot_dir if signal_MC: plot_name = 'prescaled_%s_B_mass.pdf' else: plot_name = 'prescaled_%s_Jpsi_mass.pdf' mass_canvas.Print(os.path.join(plot_dir, plot_name % args[0]), EmbedFonts = True) from P2VV.Utilities.SWeights import SData from P2VV.Utilities.DataHandling import correctWeights data_clone = data.Clone(data.GetName())
from P2VV.Load import LHCbStyle from P2VV.Utilities.Plotting import plot from ROOT import TCanvas # plot lifetime and angles timeAnglesCanv = TCanvas( 'timeAnglesCanv', 'Lifetime and Decay Angles' ) for ( pad, obs, nBins, plotTitle, xTitle )\ in zip( timeAnglesCanv.pads( 2, 2 ) , observables[ : -1 ] , numBins , [ var.GetTitle() for var in observables[ : -1 ] ] , ( '', ) + angleNames ) : plot( pad, obs, data, pdf, xTitle = xTitle , frameOpts = { 'Bins' : nBins, 'Title' : plotTitle } , dataOpts = { 'MarkerStyle' : markStyle, 'MarkerSize' : markSize, 'XErrorSize' : 0 } , pdfOpts = { 'LineWidth' : lineWidth } ) # plot lifetime timePlotTitles = tuple( [ time.GetTitle() + str for str in ( ' - B (linear)' , ' - B (logarithmic)' , ' - #bar{B} (linear)' , ' - #bar{B} (logarithmic)' ) ] ) timeCanv = TCanvas( 'timeCanv', 'Lifetime' ) for ( pad, nBins, plotTitle, dataCuts, pdfCuts, logY )\ in zip( timeCanv.pads( 2, 2 ) , 2 * numTimeBins , timePlotTitles
directory = '1bin_%4.2ffs_simple/%s' % (1000 * (t.getMax() - t.getMin()), hd) cache = Cache(input_data[years]['cache'].rsplit('/', 1), directory) data, sdatas = cache.read_data() if component == 'signal': data = single_bin_sig_sdata = sdatas['sig_sdata'] else: data = single_bin_bkg_sdata = sdatas['bkg_sdata'] ## Fit options fitOpts = dict(NumCPU = 4, Timer = 1, Save = True, Verbose = False, Optimize = 2, Minimizer = 'Minuit2') from P2VV.Parameterizations.SigmatPDFs import DoubleLogNormal dln = DoubleLogNormal(st) ln = dln.pdf() # Fit result = ln.fitTo(data, **fitOpts) # Plot from ROOT import TCanvas canvas = TCanvas('canvas', 'canvas', 600, 400) p = canvas.cd(1) from P2VV.Utilities.Plotting import plot from ROOT import kBlack, kBlue plot(p, st, pdf = ln, data = data, dataOpts = dict(MarkerSize = 0.8, MarkerColor = kBlack, Binning = 60), pdfOpts = dict(LineWidth = 3), xTitle = 'estimated decay-time error [ps]', yTitle = 'Candidates / (0.002 ps)')
for ( pad, func, angle, xTitle, yTitle, yScale, norm, nBins )\ in zip( canvs[ : 3 ] , effInts , angles , angleNames , effLabels , [ ( 0.88, 1.12 ), ( 0.9328, 1.1872 ), ( 0.88, 1.12 ) ] , [ 1. / 4. / pi, 1. / 4. / pi, 1. / 4. ] , numEffBins ) : pad.SetLeftMargin(0.28) plot( pad, angle, weightedData, func , xTitle = xTitle , yTitle = yTitle , yScale = yScale , yTitleOffset = 1.0 , frameOpts = dict( Title = angle.GetTitle(), Bins = nBins ) , dataOpts = dict( MarkerStyle = kFullDotLarge, MarkerSize = 0.9, LineWidth = 3 , Rescale = norm * float(nBins) / ( angle.getMax() - angle.getMin() ) ) , pdfOpts = dict( LineColor = kBlue, LineWidth = 4, Normalization = norm ) ) LHCbText.Draw() if physPdf : # plot lifetime and angles canvs.append( TCanvas( 'ctkCanv', 'cos(theta_K)' ) ) canvs.append( TCanvas( 'ctlCanv', 'cos(theta_l)' ) ) canvs.append( TCanvas( 'phiCanv', 'phi' ) ) for ( pad, obs, nBins, plotTitle, xTitle )\ in zip( canvs[ -3 : ] , obsSet[ 1 : 5 ] , numDistrBins
##Plot and Save for ( pad, obs, nBins, xTitle, yTitle, yScale, logY )\ in zip( [ TCanvas(o.GetName()) for o in observables ] , observables , numBins , ( angleNames[0][1], angleNames[1][1], angleNames[2][1], 'B_{s}^{0} decay time [ps]' ) , yTitles , 3 * ( ( None, 1400 ), ) + ( ( 0.1, 10e4 ), ) , 3 * ( False, ) + ( True, ) ) : print '\n\n\n Ploting Observable ' + obs.GetName() + ' {0}/{1} '.format(observables.index(obs)+1, len(observables)) + '\n\n\n' plot( pad, obs, sigData, pdf, xTitle=xTitle, yTitle=yTitle, yScale=yScale, logy=logY , frameOpts = dict( Bins = nBins, Name = obs.GetName() + 'Histo' ) , dataOpts = dict( MarkerStyle = markStyle, MarkerSize = markSize ) , pdfOpts = CpPlotsKit.getPdfOpts(BinData=False) if 'time' in obs.GetName()\ else CpPlotsKit.getPdfOpts(BinData=True ) , addPDFs = CpPlotsKit.getAddPdfs() , addPDFsOpts = CpPlotsKit.getAddPdfsOpts(BinData=False) if 'time' in obs.GetName()\ else CpPlotsKit.getAddPdfsOpts(BinData=True ) ) lhcbName.Draw() filename = obs.GetName() + '_sFit.ps' pad.Print(filename) #Save all the plots in a root file as RooPlot objects. from P2VV.Utilities.Plotting import _P2VVPlotStash as rooplots from ROOT import TFile plotsFile = TFile('RooPlotsFinal.root','recreate') for plot in rooplots: plot.Write() plotsFile.Close()
, angles , xLabels , yLabels[0] , [ ( 0.84, 1.08 ), ( 0.96, 1.20 ), ( 0.86, 1.10 ) ] if not transAngles\ else [ ( 1.01, 1.25 ), ( 0.96, 1.20 ), ( 0.97, 1.21 ) ] ) : pad.SetLeftMargin(0.28) pad.SetRightMargin(0.05) pad.SetBottomMargin(0.18) pad.SetTopMargin(0.05) plot( pad, angle, None, momFunc #, addPDFs = [ momFunc1, momFunc2 ] , xTitle = xTitle , yTitle = yTitle , yScale = yScale , xTitleOffset = 1.1 , yTitleOffset = 1.0 , frameOpts = dict( Title = angle.GetTitle() ) , pdfOpts = dict( LineColor = kBlue, LineWidth = 3 ) #, addPDFsOpts = [ dict( LineColor = kRed, LineWidth = 3 ), dict( LineColor = kGreen + 2, LineWidth = 3 ) ] ) if LHCbLabel : LHCbText.Draw() # plot efficiency function integrals from ROOT import RooArgSet canvs += [ TCanvas( 'cpsiIntCanv', 'Angular Efficiency' ) , TCanvas( 'cthetaIntCanv', 'Angular Efficiency' ) , TCanvas( 'phiIntCanv', 'Angular Efficiency' ) ] integrals = [ momFunc.createIntegral( RooArgSet( angles[1]._var, angles[2]._var ) ) , momFunc.createIntegral( RooArgSet( angles[0]._var, angles[2]._var ) )
g.GetYaxis().SetRangeUser(-0.12, 0) from ROOT import kBlue l.SetLineColor(kBlue) l.Draw('same') year_label.Draw() plot_name = 'mean_res_st_ttrue_' + args[0][pos : -5] + '.pdf' canvas.Print(os.path.join(plot_dir, plot_name), EmbedFonts = True) else: from ROOT import kGreen, kDashed from P2VV.Utilities.Plotting import plot from ROOT import TCanvas for i in range(3): result = model.fitTo(sdata, SumW2Error = False, **fitOpts) if result.status() == 0 and abs(result.minNll()) < 5e5: break canvas = TCanvas("canvas", "canvas", 600, 400) plot(canvas, t_diff_st, pdf = model, data = sdata, logy = True, frameOpts = dict(Range = (-20, 20)), yTitle = 'Candidates / (0.5)', dataOpts = dict(Binning = 80), xTitle = '(t - t_{true}) / #sigma_{t}', yScale = (1, 400000), pdfOpts = dict(ProjWData = (RooArgSet(st), sdata, True)), components = {'gexps' : dict(LineColor = kGreen, LineStyle = kDashed)}) year_label.Draw() plot_name = 'tdiff_sigmat_' + args[0][pos : -5] + '.pdf' canvas.Print(os.path.join(plot_dir, plot_name), EmbedFonts = True)
if makePlots : # import ROOT plot style from P2VV.Load import LHCbStyle # create canvas from ROOT import TCanvas anglesCanv = TCanvas( 'anglesCanv', 'Angles' ) # make plots from P2VV.Utilities.Plotting import plot from ROOT import RooFit, RooCmdArg for ( pad, obs, nBins, plotTitle, xTitle ) in zip( anglesCanv.pads(2, 2) , angles , numBins , tuple( [ angle.GetTitle() for angle in angles ] ) , angleTitles ) : plot( pad, obs, data, momPDF0, xTitle = xTitle, addPDFs = [ momPDF1, momPDF, coefPDF, pdf ] , frameOpts = dict( Bins = nBins, Title = plotTitle ) , dataOpts = dict( MarkerStyle = markStyle, MarkerSize = markSize ) , pdfOpts = dict( LineWidth = lineWidth, LineColor = RooFit.kBlack ) , addPDFsOpts = [ dict( LineWidth = lineWidth, LineColor = RooFit.kGreen + 2 ) , dict( LineWidth = lineWidth, LineColor = RooFit.kMagenta ) , dict( LineWidth = lineWidth, LineColor = RooFit.kRed ) , dict( LineWidth = lineWidth, LineColor = RooFit.kBlue ) ] ) anglesCanv.Print(plotsFile)
from ROOT import TCanvas canvs = [ TCanvas( 'bkgAngles1D_ctk' ) , TCanvas( 'bkgAngles1D_ctl' ) , TCanvas( 'bkgAngles1D_phi' ) , TCanvas( 'bkgAngles2D_ctk_ctl' ) , TCanvas( 'bkgAngles2D_ctk_phi' ) , TCanvas( 'bkgAngles2D_phi_ctl' ) ] # plot background angles from P2VV.Utilities.Plotting import plot from ROOT import kBlue for ( name, canv ) in zip( [ 'cpsi', 'ctheta', 'phi' ], canvs[ : 3 ] ) : plot( canv, observables[name], cbkgData, cbkgAnglePDF, xTitle = angleTitles[name], yTitleOffset = 1.5 , frameOpts = dict( Bins = nBins[name], Title = observables[name].GetTitle() ) , dataOpts = dict( MarkerStyle = 8, MarkerSize = 0.4 ) , pdfOpts = dict( LineColor = kBlue, LineWidth = 3 ) ) # plot 2-D angular distributions from P2VV.Utilities.Plotting import _P2VVPlotStash for angle0, angle1, canv in [ ( 'ctheta', 'cpsi', canvs[3] ), ( 'phi', 'cpsi', canvs[4] ), ( 'ctheta', 'phi', canvs[5] ) ] : bkgAngHist = cbkgData.createHistogram( observables[angle0]._var, observables[angle1]._var, nBins[angle0], nBins[angle1] ) _P2VVPlotStash.append(bkgAngHist) bkgAngHist.SetStats(False) bkgAngHist.SetTitle( '%s vs. %s' % ( angleTitles[angle0], angleTitles[angle1] ) ) bkgAngHist.SetMinimum(0.) bkgAngHist.GetXaxis().SetTitle( angleTitles[angle0] ) bkgAngHist.GetYaxis().SetTitle( angleTitles[angle1] ) bkgAngHist.GetXaxis().SetLabelOffset(0.01) bkgAngHist.GetYaxis().SetLabelOffset(0.008)
canvsOS = [ TCanvas( 'estWTagCanvOS%d' % it ) for it in range(3) ] for ( canv, data, nBins, norm ) in zip( canvsOS , [ fullData, sigData, cbkgData ] , 3 * [ numEstWTagBins ] , [ 1. - untagFracOS, 1. - untagFracSigOS, 1. - untagFracBkgOS ] ) : canv.SetLeftMargin(0.18) canv.SetRightMargin(0.05) canv.SetBottomMargin(0.18) canv.SetTopMargin(0.05) #plot( canv, estWTagOS, data, tagPdfOS plot( canv, estWTagOS, data, yScale = ( 0., None ), xTitleOffset = 1.10, yTitleOffset = 1.15 , xTitle = '#eta^{OS}' , yTitle = 'Candidates / %.2f' % ( 0.499999 / float(nBins) ) , frameOpts = dict( Bins = nBins, Range = ( 0., 0.499999 ), Name = estWTagOS.GetName() ) , dataOpts = dict( MarkerStyle = kFullDotLarge, MarkerSize = 0.7, LineWidth = 3 ) #, pdfOpts = dict( LineColor = kBlue, LineWidth = 3, Normalization = norm ) ) canvsSS = [ TCanvas( 'estWTagCanvSS%d' % it ) for it in range(3) ] for ( canv, data, nBins, norm ) in zip( canvsSS , [ fullData, sigData, cbkgData ] , 3 * [ numEstWTagBins ] , [ 1. - untagFracSS, 1. - untagFracSigSS, 1. - untagFracBkgSS ] ) : canv.SetLeftMargin(0.18) canv.SetRightMargin(0.05) canv.SetBottomMargin(0.18) canv.SetTopMargin(0.05)
break assert(mass_result.status() == 0) # Plot mass pdf from ROOT import kDashed, kRed, kGreen, kBlue, kBlack from ROOT import TCanvas canvas = TCanvas('mass_canvas', 'mass_canvas', 600, 530) obs = [m] for (p,o) in zip(canvas.pads(len(obs)), obs): from P2VV.Utilities.Plotting import plot pdfOpts = dict() plot(p, o, pdf = mass_pdf, data = data , dataOpts = dict(MarkerSize = 0.8, MarkerColor = kBlack) , pdfOpts = dict(LineWidth = 2, **pdfOpts) , plotResidHist = True , components = { 'bkg_*' : dict( LineColor = kRed, LineStyle = kDashed ), ## 'psi_*' : dict( LineColor = kGreen, LineStyle = kDashed ), 'sig_*' : dict( LineColor = kBlue, LineStyle = kDashed ) } ) # Do the sWeights # make sweighted dataset. TODO: use mumu mass as well... from P2VV.Utilities.SWeights import SData for p in mass_pdf.Parameters() : p.setConstant( not p.getAttribute('Yield') ) splot = SData(Pdf = mass_pdf, Data = data, Name = 'MassSplot') data = splot.data('signal') ## psi_sdata = splot.data('psi_background') bkg_sdata = splot.data('background') if 'MC' in args[0]: