コード例 #1
0
    modeString = ''
elif fitterPars.includeMuons:
    modeString = 'Muon'
elif fitterPars.includeElectrons:
    modeString = 'Electron'
else:
    modeString = ''

theFitter = RooWjjMjjFitter(fitterPars)

if opts.compile:
    print 'compile complete'
    assert(False)

#theFitter.getWorkSpace().Print()
theFitter.makeFitter((opts.ParamWpJ>=0))

totalPdf = theFitter.getWorkSpace().pdf('totalPdf')
#theFitter.getWorkSpace().Print()
theFitter.getWorkSpace().var('nDiboson').setConstant(False)

# if opts.ParamWpJ < 0:
#     theFitter.getWorkSpace().var('fMU').setConstant(True)
#     theFitter.getWorkSpace().var('fSU').setConstant(True)

# theFitter.getWorkSpace().var('nDiboson').setConstant()
#theFitter.getWorkSpace().var('nTTbar').setConstant()
# theFitter.getWorkSpace().var('nSingleTop').setConstant()
# theFitter.getWorkSpace().var('nZjets').setConstant()
#theFitter.getWorkSpace().var('nWjets').setConstant()
theFitter.getWorkSpace().var('nQCD').setConstant()
コード例 #2
0
    parser.add_option("--NP", action="store_true", dest="NP", default=False, help="put NP on the plot")
    parser.add_option("--Err", dest="Err", default=-1.0, type="float", help="error band level")
    (opts, args) = parser.parse_args()

    import pyroot_logon

    config = __import__(opts.modeConfig)

    from ROOT import TFile, Double, Long, gROOT, TCanvas

    ## gROOT.ProcessLine('.L RooWjjFitterParams.h+');
    gROOT.ProcessLine(".L EffTableReader.cc+")
    gROOT.ProcessLine(".L EffTableLoader.cc+")
    gROOT.ProcessLine(".L RooWjjFitterUtils.cc+")
    gROOT.ProcessLine(".L RooWjjMjjFitter.cc+")
    from ROOT import RooWjjMjjFitter, RooFit, RooMsgService, RooArgList, RooArgSet
    from math import sqrt

    RooMsgService.instance().setGlobalKillBelow(RooFit.WARNING)

    fitterPars = config.theConfig(opts.Nj, opts.mcdir, opts.startingFile, opts.toydataFile)

    theFitter = RooWjjMjjFitter(fitterPars)

    theFitter.makeFitter(False)
    theFitter.loadData()

    theFitter.loadParameters(opts.startingFile)

    (frames, cans) = plot2BodyDist(theFitter, fitterPars, 0, 3, opts.Err, opts.NP)
コード例 #3
0
    modeString = ''
elif fitterPars.includeMuons:
    modeString = 'Muon'
elif fitterPars.includeElectrons:
    modeString = 'Electron'
else:
    modeString = ''

theFitter = RooWjjMjjFitter(fitterPars)

if opts.compile:
    print 'compile complete'
    assert(False)

#theFitter.getWorkSpace().Print()
theFitter.makeFitter((opts.ParamWpJ>=0))

totalPdf = theFitter.getWorkSpace().pdf('totalPdf')
#theFitter.getWorkSpace().Print()
theFitter.getWorkSpace().var('nDiboson').setConstant(False)

# if opts.ParamWpJ < 0:
#     theFitter.getWorkSpace().var('fMU').setConstant(True)
#     theFitter.getWorkSpace().var('fSU').setConstant(True)

# theFitter.getWorkSpace().var('nDiboson').setConstant()
#theFitter.getWorkSpace().var('nTTbar').setConstant()
# theFitter.getWorkSpace().var('nSingleTop').setConstant()
# theFitter.getWorkSpace().var('nZjets').setConstant()
#theFitter.getWorkSpace().var('nWjets').setConstant()
theFitter.getWorkSpace().var('nQCD').setConstant()
コード例 #4
0
    modeString = 'Muon'
elif fitterPars.includeElectrons:
    modeString = 'Electron'
else:
    modeString = ''

dibosonParameterize = 0
if opts.btag:
    dibosonParameterize = 2
    fitterPars.constrainWpJShape = True
    fitterPars.constrainDibosonShape = True

theFitter = RooWjjMjjFitter(fitterPars)

theFitter.makeDibosonPdf(dibosonParameterize)
theFitter.makeFitter((opts.ParamWpJ>=0))

#theFitter.getWorkSpace().Print()
fr = theFitter.fit()

# chi2 = Double(0.)
#ndf = Long(2)
extraNdf = 0
if not opts.btag:
    extraNdf = 2
## if (fitterPars.doNewPhysics):
##     extraNdf += 1
## if not fitterPars.constrainDiboson:
##     extraNdf += 1
## ndf = Long(3+extraNdf)
ndf = Long(1+extraNdf)
コード例 #5
0
RooMsgService.instance().setGlobalKillBelow(RooFit.WARNING)

fitterPars = config.theConfig(opts.Nj, opts.mcdir, opts.startingFile, opts.toydataFile, opts.TTbarMUSUsystopt, opts.e_minT, opts.e_maxT)
if fitterPars.includeMuons and fitterPars.includeElectrons:
    modeString = ''
elif fitterPars.includeMuons:
    modeString = 'Muon'
elif fitterPars.includeElectrons:
    modeString = 'Electron'
else:
    modeString = ''

theFitter = RooWjjMjjFitter(fitterPars)

theFitter.makeFitter(False)

#theFitter.getWorkSpace().Print()
fr = theFitter.fit()

extraNdf = 0
if not fitterPars.constrainDiboson:
    extraNdf += 1
ndf = Long(fr.floatParsFinal().getSize()-5+extraNdf)
chi2 = theFitter.computeChi2(ndf)
# chi2frame.Draw()

# assert False, "fit done"

yields = fr.floatParsFinal()
mass = theFitter.getWorkSpace().var(fitterPars.var)
コード例 #6
0
def qPlot(fitterPars):
    from ROOT import kRed, kBlack, kGreen, kOrange, kMagenta, kCyan, THStack, \
         RooWjjMjjFitter, RooWjjFitterUtils, TCanvas
    
    fitUtils = RooWjjFitterUtils(fitterPars)
    theFitter = RooWjjMjjFitter(fitterPars)

    thePdf = theFitter.makeFitter(False)
    theFitter.loadParameters(fitterPars.initParamsFile)

    theFitter.getWorkSpace().Print()

    q = theFitter.getWorkSpace().var(fitterPars.var)
    q.SetTitle("Q = m_{l#nujj}-m_{jj}-M_{W}")

    pdfs = thePdf.pdfList()
    coefs = thePdf.coefList()
    shapeHist = THStack('shapeHist', 'shapeHist')

    sumYield = 0.
    for i in range(pdfs.getSize()-1, -1, -1):
        tmpHist = pdfs[i].createHistogram('h_' + pdfs[i].GetName(), q)
        theName = pdfs[i].GetName()[:3]
        tmpHist.SetFillStyle(1001)
        if theName == 'dib':
            tmpHist.SetFillColor(kOrange)
            tmpHist.SetLineColor(kOrange)
        elif theName == 'WpJ':
            tmpHist.SetFillColor(kRed)
            tmpHist.SetLineColor(kRed)
        elif theName == 'ttP':
            tmpHist.SetFillColor(kBlack)
            tmpHist.SetLineColor(kBlack)
        elif theName == 'stP':
            tmpHist.SetFillColor(kBlack)
            tmpHist.SetLineColor(kBlack)
        elif theName == 'qcd':
            tmpHist.SetFillColor(kGreen)
            tmpHist.SetLineColor(kGreen)
        elif theName == 'ZpJ':
            tmpHist.SetFillColor(kMagenta)
            tmpHist.SetLineColor(kMagenta)
        
##         tmpHist.Draw()
##         gPad.Update()
##         gPad.WaitPrimitive()

        tmpHist.Scale(coefs[i].getVal())
        sumYield += coefs[i].getVal()
        if (coefs[i].getVal() > 0.):
            shapeHist.Add(tmpHist)

    totalShapeHist = thePdf.createHistogram("totalShapeHist", q)
    totalShapeHist.Print()

    dataHist = fitUtils.newEmptyHist("theData")
    if fitterPars.includeMuons:
        tmpHist = fitUtils.File2Hist(fitterPars.DataDirectory+fitterPars.muonData,
                                     "tmpData", False, 0, False, 1.0,
                                     fitUtils.fullCuts())
        dataHist.Add(tmpHist)

    if fitterPars.includeElectrons:
        tmpHist = fitUtils.File2Hist(fitterPars.DataDirectory+fitterPars.electronData,
                                     "tmpData", True, 0, False, 1.0,
                                     fitUtils.fullCuts())
        dataHist.Add(tmpHist)

    totalShapeHist.Scale(sumYield)
##     shapeHist.SetLineColor(kCyan+3)
##     shapeHist.SetMarkerColor(kCyan+3)

    cq = TCanvas('cq', 'Q')
    shapeHist.Draw('')
    shapeHist.GetXaxis().SetTitle(q.GetTitle() + ' (GeV)')
    shapeHist.GetYaxis().SetTitle('Events / (%0.0f GeV)' % ((fitterPars.maxMass-fitterPars.minMass)/fitterPars.nbins))
    dataHist.Draw('same')
    cq.Modified()
    #totalShapeHist.Draw('same')
    dataHist.Chi2Test(totalShapeHist,"UUNORMP")
    print "KS test:",dataHist.KolmogorovTest(totalShapeHist)
    return (cq, shapeHist, totalShapeHist)
コード例 #7
0
                      help='error band level')
    (opts, args) = parser.parse_args()

    import pyroot_logon
    config = __import__(opts.modeConfig)

    from ROOT import TFile, Double, Long, gROOT, TCanvas
    ## gROOT.ProcessLine('.L RooWjjFitterParams.h+');
    gROOT.ProcessLine('.L EffTableReader.cc+')
    gROOT.ProcessLine('.L EffTableLoader.cc+')
    gROOT.ProcessLine('.L RooWjjFitterUtils.cc+')
    gROOT.ProcessLine('.L RooWjjMjjFitter.cc+')
    from ROOT import RooWjjMjjFitter, RooFit, \
         RooMsgService, RooArgList, RooArgSet
    from math import sqrt

    RooMsgService.instance().setGlobalKillBelow(RooFit.WARNING)

    fitterPars = config.theConfig(opts.Nj, opts.mcdir, opts.startingFile,
                                  opts.toydataFile )

    theFitter = RooWjjMjjFitter(fitterPars)

    theFitter.makeFitter(False)
    theFitter.loadData()

    theFitter.loadParameters(opts.startingFile)

    (frames, cans) = plot2BodyDist(theFitter, fitterPars,
                                   0, 3, opts.Err, opts.NP)
コード例 #8
0
def qPlot(fitterPars):
    from ROOT import kRed, kBlack, kGreen, kOrange, kMagenta, kCyan, THStack, \
         RooWjjMjjFitter, RooWjjFitterUtils, TCanvas

    fitUtils = RooWjjFitterUtils(fitterPars)
    theFitter = RooWjjMjjFitter(fitterPars)

    thePdf = theFitter.makeFitter(False)
    theFitter.loadParameters(fitterPars.initParamsFile)

    theFitter.getWorkSpace().Print()

    q = theFitter.getWorkSpace().var(fitterPars.var)
    q.SetTitle("Q = m_{l#nujj}-m_{jj}-M_{W}")

    pdfs = thePdf.pdfList()
    coefs = thePdf.coefList()
    shapeHist = THStack('shapeHist', 'shapeHist')

    sumYield = 0.
    for i in range(pdfs.getSize() - 1, -1, -1):
        tmpHist = pdfs[i].createHistogram('h_' + pdfs[i].GetName(), q)
        theName = pdfs[i].GetName()[:3]
        tmpHist.SetFillStyle(1001)
        if theName == 'dib':
            tmpHist.SetFillColor(kOrange)
            tmpHist.SetLineColor(kOrange)
        elif theName == 'WpJ':
            tmpHist.SetFillColor(kRed)
            tmpHist.SetLineColor(kRed)
        elif theName == 'ttP':
            tmpHist.SetFillColor(kBlack)
            tmpHist.SetLineColor(kBlack)
        elif theName == 'stP':
            tmpHist.SetFillColor(kBlack)
            tmpHist.SetLineColor(kBlack)
        elif theName == 'qcd':
            tmpHist.SetFillColor(kGreen)
            tmpHist.SetLineColor(kGreen)
        elif theName == 'ZpJ':
            tmpHist.SetFillColor(kMagenta)
            tmpHist.SetLineColor(kMagenta)


##         tmpHist.Draw()
##         gPad.Update()
##         gPad.WaitPrimitive()

        tmpHist.Scale(coefs[i].getVal())
        sumYield += coefs[i].getVal()
        if (coefs[i].getVal() > 0.):
            shapeHist.Add(tmpHist)

    totalShapeHist = thePdf.createHistogram("totalShapeHist", q)
    totalShapeHist.Print()

    dataHist = fitUtils.newEmptyHist("theData")
    if fitterPars.includeMuons:
        tmpHist = fitUtils.File2Hist(
            fitterPars.DataDirectory + fitterPars.muonData, "tmpData", False,
            0, False, 1.0, fitUtils.fullCuts())
        dataHist.Add(tmpHist)

    if fitterPars.includeElectrons:
        tmpHist = fitUtils.File2Hist(
            fitterPars.DataDirectory + fitterPars.electronData, "tmpData",
            True, 0, False, 1.0, fitUtils.fullCuts())
        dataHist.Add(tmpHist)

    totalShapeHist.Scale(sumYield)
    ##     shapeHist.SetLineColor(kCyan+3)
    ##     shapeHist.SetMarkerColor(kCyan+3)

    cq = TCanvas('cq', 'Q')
    shapeHist.Draw('')
    shapeHist.GetXaxis().SetTitle(q.GetTitle() + ' (GeV)')
    shapeHist.GetYaxis().SetTitle(
        'Events / (%0.0f GeV)' %
        ((fitterPars.maxMass - fitterPars.minMass) / fitterPars.nbins))
    dataHist.Draw('same')
    cq.Modified()
    #totalShapeHist.Draw('same')
    dataHist.Chi2Test(totalShapeHist, "UUNORMP")
    print "KS test:", dataHist.KolmogorovTest(totalShapeHist)
    return (cq, shapeHist, totalShapeHist)