Esempio n. 1
0
def plot_training_phoeres_with_shape_and_fit():
    """Plot the nominal MC photon energy smearing overlayed with the pdf shape
    and fit."""
    canvases.next('TrainingPhoEResWithShapeAndFit')
    plot = phoERes.frame(roo.Range(-7.5, 5))
    plot.SetTitle("Photon energy smearing overlayed with PDF shape (blue) "
                  "and it's parametrized fit (dashed red)")
    data.plotOn(plot)
    ## Define model for the photon energy smearing function Ereco/Etrue - 1.
    phoEResPdf = ParametrizedKeysPdf('phoEResPdf', 'phoEResPdf', phoERes,
                                     phoScale, phoRes, data,
                                     ROOT.RooKeysPdf.NoMirror, 1.5)
    ## PDF shape
    phoEResPdf.shape.plotOn(plot)
    ## Parametrized fit of the PDF shape
    phoEResPdf.fitTo(data, roo.Range(-50, 50), roo.PrintLevel(-1))
    phoEResPdf.plotOn(plot, roo.LineColor(ROOT.kRed),
                      roo.LineStyle(ROOT.kDashed))
    plot.Draw()
    Latex([
        's_{shape}: %.3f %%' % phoEResPdf.shapemode,
        's_{fit}: %.3f #pm %.3f %%' % (phoScale.getVal(), phoScale.getError()),
        's_{fit} - s_{shape}: %.4f #pm %.4f %%' %
        (phoScale.getVal() - phoEResPdf.shapemode, phoScale.getError()),
        'r_{shape}: %.3f %%' % phoEResPdf.shapewidth,
        'r_{fit}: %.3f #pm %.3f %%' % (phoRes.getVal(), phoRes.getError()),
        'r_{fit} - r_{shape}: %.4f #pm %.4f %%' %
        (phoRes.getVal() - phoEResPdf.shapewidth, phoRes.getError()),
        'r_{fit}/r_{shape}: %.4f #pm %.4f' %
        (phoRes.getVal() / phoEResPdf.shapewidth,
         phoRes.getError() / phoEResPdf.shapewidth),
    ],
          position=(0.2, 0.8)).draw()
Esempio n. 2
0
def plot_nominal_mmgmass_with_shape_and_fit():
    """Plot the nominal MC mmg mass data overlayed with the pdf shape and
    fit."""
    canvases.next('NominalMmgMassWithShapeAndFit')
    plot = mmgMass.frame(roo.Range(75, 105))
    plot.SetTitle("m(#mu#mu#gamma) overlayed with PDF shape (blue) "
                  "and it's parametrized fit (dashed red)")
    data.plotOn(plot)
    ## Define the mmg mass model.
    mmgMassPdf = ParametrizedKeysPdf('mmgMassPdf', 'mmgMassPdf', mmgMass,
                                     massPeak, massWidth, data,
                                     ROOT.RooKeysPdf.NoMirror, 1.5)
    ## PDF shape
    mmgMassPdf.shape.plotOn(plot)
    ## Parametrized fit of the PDF shape
    mmgMassPdf.fitTo(data, roo.Range(60, 120), roo.PrintLevel(-1))
    mmgMassPdf.plotOn(plot, roo.LineColor(ROOT.kRed),
                      roo.LineStyle(ROOT.kDashed))
    plot.Draw()
    sshape = 100 * (mmgMassPdf.shapemode / mZ.getVal() - 1)
    rshape = 100 * mmgMassPdf.shapewidth / mmgMassPdf.shapemode
    Latex([
        's_{shape}: %.3f %%' % sshape,
        's_{fit}: %.3f #pm %.3f %%' %
        (massScale.getVal(), massScale.getError()),
        's_{fit} - s_{shape}: %.4f #pm %.4f %%' %
        (massScale.getVal() - sshape, massScale.getError()),
        'r_{shape}: %.3f %%' % rshape,
        'r_{fit}: %.3f #pm %.3f %%' % (massRes.getVal(), massRes.getError()),
        'r_{fit} - r_{shape}: %.4f #pm %.4f %%' %
        (massRes.getVal() - rshape, massRes.getError()),
        'r_{fit}/r_{shape}: %.4f #pm %.4f' %
        (massRes.getVal() / rshape, massRes.getError() / rshape),
    ],
          position=(0.2, 0.8)).draw()
Esempio n. 3
0
def plot_nominal_and_smeared_mmgmass():
    canvases.next('SmearedMMGMass').SetGrid()
    plot = mmgMass.frame(roo.Range(76, 106))
    plot.SetTitle("Nominal (black) and smeared (red) mmg mass")
    data.plotOn(plot)
    datasmeared.plotOn(plot, roo.MarkerColor(ROOT.kRed),
                       roo.LineColor(ROOT.kRed))
    plot.Draw()
    Latex([
        's_{0}: %.2g %%, s: %.2g %%' % (phoScaleRef, targets),
        'r_{0}: %.2g %%, r: %.2g %%' % (phoResRef, targetr)
    ],
          position=(0.2, 0.8)).draw()
Esempio n. 4
0
def plot_sanity_checks(data):
    pdfname = '_'.join(['bananaPdf', data.GetName()])
    pdf = ROOT.RooNDKeysPdf(pdfname, pdfname, ROOT.RooArgList(mmMass, mmgMass),
                            data, "a", 1.5)

    canvases.next(pdf.GetName() + '_mmgMassProj')
    plot = mmgMass.frame(roo.Range(60, 120))
    data.plotOn(plot)
    pdf.plotOn(plot)
    plot.Draw()

    canvases.next(pdf.GetName() + '_mmMassProj')
    plot = mmMass.frame(roo.Range(10, 120))
    data.plotOn(plot)
    pdf.plotOn(plot)
    plot.Draw()

    canvases.next(pdf.GetName()).SetGrid()
    h_pdf = pdf.createHistogram('h_' + pdf.GetName(), mmMass,
                                roo.Binning(40, 40, 80),
                                roo.YVar(mmgMass, roo.Binning(40, 70, 110)))
    h_pdf.Draw("cont1")

    canvases.next(data.GetName()).SetGrid()
    h_data = data.createHistogram(mmMass, mmgMass, 130, 100, '',
                                  'h_' + data.GetName())
    h_data.GetXaxis().SetRangeUser(40, 80)
    h_data.GetYaxis().SetRangeUser(70, 110)
    h_data.Draw("cont1")

    canvases.next('_'.join([pdf.GetName(), 'mmgMassSlices']))
    plot = mmgMass.frame(roo.Range(60, 120))
    for mmmassval, color in zip([55, 60, 65, 70],
                                'Red Orange Green Blue'.split()):
        mmMass.setVal(mmmassval)
        color = getattr(ROOT, 'k' + color)
        pdf.plotOn(plot, roo.LineColor(color))

    plot.Draw()
    canvases.update()
Esempio n. 5
0
def plot_training_phoeres_with_shape_and_fit():
    canvases.next('TrainingSampleWithShapeAndFit')
    plot = phoERes.frame(roo.Range(-7.5, 7.5))
    plot.SetTitle(
        "MC overlayed with PDF shape (blue) and it's parametrized fit"
        "(dashed red)")
    data.plotOn(plot)
    phoEResPdf.shape.plotOn(plot)
    phoEResPdf.plotOn(plot, roo.LineColor(ROOT.kRed),
                      roo.LineStyle(ROOT.kDashed))
    plot.Draw()
    Latex([
        's_{shape}: %.3f %%' % phoEResPdf.shapemode,
        's_{fit}: %.3f #pm %.3f %%' % (phoScale.getVal(), phoScale.getError()),
        's_{fit} - s_{shape}: %.4f #pm %.4f' %
        (phoScale.getVal() - phoEResPdf.shapemode, phoScale.getError()),
        'r_{shape}: %.3f %%' % phoEResPdf.shapewidth,
        'r_{fit}: %.3f #pm %.3f %%' % (phoRes.getVal(), phoRes.getError()),
        'r_{fit}/r_{shape}: %.4f #pm %.4f' %
        (phoRes.getVal() / phoEResPdf.shapewidth,
         phoRes.getError() / phoEResPdf.shapewidth),
    ],
          position=(0.2, 0.75)).draw()
Esempio n. 6
0
                          rho=1.5)

## Build the model for fT(t|s,r) = fT1(t1) * fT2(t2|s,r)
t.setRange(5, 10)
t.setBins(1000, "cache")
tpdf = ROOT.RooFFTConvPdf('tpdf', 'tpdf', t, t1pdf, t2pdf)
tpdf.setBufferFraction(0.1)

## Plot fT1(t1) with training data.
canvases.next('t1pdf').SetGrid()
t.setRange(5, 10)
t.SetTitle('log(m_{#mu#mu#gamma,E_{gen}^{#gamma}}^{2} - m_{#mu#mu}^{2})')
plot = t.frame(roo.Range(6, 9))
t1data.plotOn(plot)
t1pdf.shape.plotOn(plot)
t1pdf.plotOn(plot, roo.LineColor(ROOT.kRed), roo.LineStyle(ROOT.kDashed))
plot.Draw()
Latex([
    's_{shape}: %.3f' % t1pdf.shapemode,
    's_{fit}: %.3f #pm %.3f' % (t1mode.getVal(), t1mode.getError()),
    's_{fit} - s_{shape}: %.4f #pm %.4f' %
    (t1mode.getVal() - t1pdf.shapemode, t1mode.getError()),
    'r_{shape}: %.3f' % t1pdf.shapewidth,
    'r_{fit}: %.3f #pm %.3f' % (t1width.getVal(), t1width.getError()),
    'r_{fit} - r_{shape}: %.4f #pm %.4f' %
    (t1width.getVal() - t1pdf.shapewidth, t1width.getError()),
    'r_{fit}/r_{shape}: %.4f #pm %.4f' %
    (t1width.getVal() / t1pdf.shapewidth,
     t1width.getError() / t1pdf.shapewidth),
],
      position=(0.2, 0.8)).draw()
Esempio n. 7
0
## Model for the reconstructed mmg mass of the ISR through transformation
# mmgMassIsrPdf = ROOT.RooFFTConvPdf('mmgMassIsrPdf', 'mmgMassIsrPdf', mmMassFunc,
#                                    mmMass, zmmGenShape, mmMassRes)
mmgMassPdf = w.factory('Voigtian::mmgMassPdf(mmMassFunc, mmMean, GZ, mmRes)')

## Plot the mmg mass data and model overlaid without fitting (!)
mmgPlot = mmgMass.frame(roofit.Range(60, 200))
isrData.plotOn(mmgPlot)
isrData_m1gOplusM2g = isrData.reduce(ROOT.RooArgSet(m1gOplusM2g))
isrData_m1gOplusM2g_binned = isrData_m1gOplusM2g.binnedClone()
isrData_m1gOplusM2g.get().find('m1gOplusM2g').setBins(40)
isrData_m1gOplusM2g_binned2 = isrData_m1gOplusM2g.binnedClone()

# mmgMassPdf.plotOn(mmgPlot, roofit.ProjWData(isrData_m1gOplusM2g),
#                  roofit.LineColor(ROOT.kRed))
mmgMassPdf.plotOn(mmgPlot, roofit.ProjWData(isrData_m1gOplusM2g_binned),
                  roofit.LineColor(ROOT.kRed))
mmgMassPdf.plotOn(mmgPlot, roofit.ProjWData(isrData_m1gOplusM2g_binned2),
                  roofit.LineStyle(ROOT.kDashed))
canvases.next('mmgMass')
mmgPlot.Draw()

for c in canvases.canvases:
    c.Update()

canvases.make_plots()

if __name__ == '__main__':
    import user