def generate(outdir, Nj, mode="HWWconfig"):
    config = __import__(mode)
    from ROOT import gROOT
    gROOT.ProcessLine('.L RooWjjFitterUtils.cc+')
    from ROOT import RooWjjFitterUtils, TH1, TH1D
    fitParams = config.theConfig(Nj)
    fitUtils = RooWjjFitterUtils(fitParams)
    ##     fitUtils.setJES_scale(0, fitParams.JES_scale1);
    ##     fitUtils.setJES_scale(0, fitParams.JES_scale2);

    theModes = [
        "WpJ_CMSSW428.root", "WpJmatchingup_CMSSW428.root",
        "WpJmatchingdown_CMSSW428.root", "WpJscaleup_CMSSW428.root",
        "WpJscaledown_CMSSW428.root"
    ]
    theChannels = ["mu", "el"]

    for mode in theModes:
        for chan in theChannels:
            outfname = chan + '_' + mode
            infname = fitParams.WpJDirectory + outfname
            outfname = outdir + outfname

            sampleName = mode.split('_')[0] + '_' + chan
            print infname, '->', outfname
            theHist = fitUtils.File2Hist(infname, sampleName, 1)
            ## print theHist
            if (theHist):
                ## theHist.Print()
                fitUtils.hist2RandomTree(theHist, outfname)
def generate (outdir, Nj, mode = "HWWconfig"):
    config = __import__(mode)
    from ROOT import gROOT
    gROOT.ProcessLine('.L RooWjjFitterUtils.cc+');
    from ROOT import RooWjjFitterUtils, TH1, TH1D
    fitParams = config.theConfig(Nj)
    fitUtils = RooWjjFitterUtils(fitParams);
##     fitUtils.setJES_scale(0, fitParams.JES_scale1);
##     fitUtils.setJES_scale(0, fitParams.JES_scale2);

    theModes = ["WpJ_CMSSW428.root", "WpJmatchingup_CMSSW428.root",
                "WpJmatchingdown_CMSSW428.root", "WpJscaleup_CMSSW428.root",
                "WpJscaledown_CMSSW428.root"]
    theChannels = ["mu", "el"]

    for mode in theModes:
        for chan in theChannels:
            outfname = chan + '_' + mode
            infname = fitParams.WpJDirectory + outfname
            outfname = outdir + outfname

            sampleName = mode.split('_')[0] + '_' + chan
            print infname, '->', outfname
            theHist = fitUtils.File2Hist(infname, sampleName, 1);
            ## print theHist
            if (theHist):
                ## theHist.Print()
                fitUtils.hist2RandomTree(theHist, outfname)
                  'example.  Use the file name minus the .py extension.')
(opts, args) = parser.parse_args()

import pyroot_logon
config = __import__(opts.modeConfig)

from ROOT import gPad, 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+');
from ROOT import RooWjjFitterUtils, kCyan, kYellow, kMagenta, kSolid, kDashed,\
     kDashDotted, TH1D, TF1, kBlue

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

if fitterPars.includeMuons and fitterPars.includeElectrons:
    modeString = ''
elif fitterPars.includeMuons:
    modeString = 'Muon'
elif fitterPars.includeElectrons:
    modeString = 'Electron'
else:
    modeString = ''


scalingPb = 1000.
models = [('mu_ZprimeMadGraph_CMSSW428.root', 'el_ZprimeMadGraph_CMSSW428.root', 1.72, "Z'", 'Zprime', kCyan+2, 49998),
          ('mu_TechnicolorPythia_CMSSW428.root', 'el_TechnicolorPythia_CMSSW428.root', 1.58, 'Technicolor', 'Technicolor', kYellow+2, 49800),
          ('mu_WH150qq_CMSSW428.root', 'el_WH150qq_CMSSW428.root', 0.0125, 'WH/ZH', 'WH', kMagenta+2, 50000*1.24669/1.45611),
fitter4.loadData()
fitter4.make4BodyPdf(theFitter)
fitter4.loadParameters(sigYieldFilename)

## assert(False)

mf4 = fitter4.stackedPlot(False, RooWjjMjjFitter.mlnujj)
mf4.SetName("Mlvjj_Stacked")
## sf4 = fitter4.residualPlot(mf4, "h_background", "dibosonPdf", False)
# pf4 = fitter4.residualPlot(mf4, "h_total", "", True)
pf4 = pulls.createPull(mf4.getHist('theData'), mf4.getCurve('h_total'))
pf4.SetName("Mlvjj_Pull")
lf4 = fitter4.stackedPlot(True, RooWjjMjjFitter.mlnujj)
lf4.SetName("Mlvjj_log")

fitUtils = RooWjjFitterUtils(pars4)
iwt = 0
if (opts.mH >= 500):
    iwt = 1
sigHists = HWWSignalShapes.GenHiggsHists(pars4, opts.mH, fitUtils, iwt = iwt)

extraFactor = 2.
otherdata = HWWSignalShapes.NgenHiggs(opts.mH, 'HWW')
SigVisual = TH1D(sigHists['HWW'])
SigVisual.Print()
SigVisual.SetName('SigVisual')
SigVisual.SetLineColor(kBlue)
SigVisual.SetLineWidth(3)
SigVisual.Scale(pars4.intLumi*extraFactor*otherdata[1]*otherdata[2]/2.)
SigVisual.Print()
SigVisualLog = TH1D(SigVisual)
fitter4.loadData()
fitter4.make4BodyPdf(theFitter)
fitter4.loadParameters('lastSigYield.txt')

## assert(False)
## fitter4.getWorkSpace().Print()

mf4 = fitter4.stackedPlot(False, RooWjjMjjFitter.mlnujj)
mf4.SetName("Mlvjj_Stacked")
## sf4 = fitter4.residualPlot(mf4, "h_background", "dibosonPdf", False)
pf4 = fitter4.residualPlot(mf4, "h_total", "", True)
pf4.SetName("Mlvjj_Pull")
lf4 = fitter4.stackedPlot(True, RooWjjMjjFitter.mlnujj)
lf4.SetName("Mlvjj_log")

fitUtils = RooWjjFitterUtils(pars4)
HiggsHist = fitUtils.newEmptyHist('HWW%i_%s_shape' % (opts.mH,modeString))
VBFHiggsHist = fitUtils.newEmptyHist('VBFHWW%i_%s_shape' % (opts.mH,
                                                            modeString))
TauNuHiggsHist = fitUtils.newEmptyHist('HWWTauNu%i_%s_shape' % (opts.mH,
                                                                modeString))

if pars4.includeMuons:
    thehist = fitUtils.File2Hist(fitterPars.MCDirectory + \
                                 'mu_HWWMH%i_CMSSW428.root' % (opts.mH),
                                 'HWW%i_mu' % (opts.mH), False, 1, False)
    HiggsHist.Add(thehist)
    thehist = fitUtils.File2Hist(fitterPars.MCDirectory + \
                                 'mu_VBFHWWMH%i_CMSSW428.root' % (opts.mH),
                                 'VBFHWW%i_mu' % (opts.mH), False, 1, False)
    VBFHiggsHist.Add(thehist)
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)
Esempio n. 7
0
                  'example.  Use the file name minus the .py extension.')
(opts, args) = parser.parse_args()

import pyroot_logon
config = __import__(opts.modeConfig)

from ROOT import gPad, 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+')
from ROOT import RooWjjFitterUtils, kCyan, kYellow, kMagenta, kSolid, kDashed,\
     kDashDotted, TH1D, TF1, kBlue

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

if fitterPars.includeMuons and fitterPars.includeElectrons:
    modeString = ''
elif fitterPars.includeMuons:
    modeString = 'Muon'
elif fitterPars.includeElectrons:
    modeString = 'Electron'
else:
    modeString = ''

scalingPb = 1000.
models = [
    ('mu_ZprimeMadGraph_CMSSW428.root', 'el_ZprimeMadGraph_CMSSW428.root',
     1.72, "Z'", 'Zprime', kCyan + 2, 49998),
    ('mu_TechnicolorPythia_CMSSW428.root',
Esempio n. 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)