fitterPars.minMass = fitterPars.binEdges[0]
    fitterPars.minFit = fitterPars.minMass

if opts.lumi:
    fitterPars.intLumi = opts.lumi
    
if fitterPars.includeMuons and fitterPars.includeElectrons:
    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)
示例#2
0
import pyroot_logon
config = __import__(opts.modeConfig)
from ROOT import gROOT
## 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, RooFitResult, \
     RooMsgService, RooFit

RooMsgService.instance().setGlobalKillBelow(RooFit.WARNING)
tmpInitFile = opts.startingFile

fitterPars = config.theConfig(opts.Nj, opts.mcdir, tmpInitFile)
theFitter = RooWjjMjjFitter(fitterPars)


def writeValToFile(optVar, newVal, filename, outname=None, theVars=optVars):
    if outname == None:
        outname = filename
    newStart = open(filename).readlines()
    for tmpVar in theVars:
        compliment = tmpVar.replace('U', 'D')
        if optVar == tmpVar:
            theVal = newVal
        else:
            theVal = theVars[tmpVar]
        if (theVal >= 0):
            newStart = [re.sub('^{0} = [ ]*[-0-9\.]*'.format(tmpVar),
                               '{0} = {1:.3f}'.format(tmpVar, theVal), x) \
示例#3
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)