plotOpts = {"comment": False, 'SUS15004CR': True}
    regionsOrder = [
        "TTJetsDilepton", "TTJetsDileptonMultiJet", "TTJetsDileptonDiJet"
    ]
    regions = {
        "TTJetsDilepton":
        Analysis("TTJetsDilepton", tag=tag),
        "TTJetsDileptonDiJet":
        Analysis("TTJetsDilepton", tag=tag, njetsMin=2, njetsMax=3),
        "TTJetsDileptonMultiJet":
        Analysis("TTJetsDileptonMultiJet", tag=tag, njetsMin=4),
    }
    sfFilename = "data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root" % (
        tag)
    sfHists = macro.loadScaleFactorHists(
        sfFilename=sfFilename,
        processNames=regions["TTJetsDilepton"].samples,
        debugLevel=debugLevel)
    sfNJetsFile = rt.TFile.Open(
        "data/ScaleFactors/RazorMADD2015/RazorNJetsScaleFactors_%s.root" %
        (tag))
    sfHists['NJetsTTJets'] = sfNJetsFile.Get("TTJetsScaleFactors")
    sfHists['NJetsWJets'] = sfNJetsFile.Get("WJetsScaleFactors")
    outfile = rt.TFile(
        "data/ScaleFactors/RazorMADD2015/RazorTTJetsDileptonCrossCheck_%s.root"
        % (tag), "RECREATE")

    for region in regionsOrder:
        analysis = regions[region]
        analysis.weightOpts.append('ttbardileptonmt')
        analysis.dataWeightOpts.append('ttbardileptonmt')
        #make output directory
        regionsOrder.append(regionName)
        maxB = 3
        if name == 'DiJet':
            maxB = 2
        for nb in range(maxB+1):
            nbMax = nb
            if nb == maxB:
                nbMax = -1
            regionName = "GJetsInv"+name+"ClosureTest"+str(nb)+"B"
            regionsOrder.append(regionName)
            regions[regionName] = Analysis("GJetsInv",tag=tag,
                    njetsMin=jets[0], njetsMax=jets[1], nbMin=nb,
                    nbMax=nbMax, boostCuts=boostCuts)

    sfHists = macro.loadScaleFactorHists(
            sfFilename="data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s_Uncorr.root"%(tag), 
            processNames=regions.itervalues().next().samples, debugLevel=debugLevel)
    sfVars = ("MR_NoPho","Rsq_NoPho")
    sfNJetsFile = rt.TFile.Open(
            "data/ScaleFactors/RazorMADD2015/RazorNJetsScaleFactors_%s.root"%(tag))
    sfHists['NJetsInv'] = sfNJetsFile.Get("GJetsInvScaleFactors")
    razorWeights.loadPhotonPurityHists(sfHists, tag, debugLevel)
    for region in regionsOrder:
        analysis = regions[region]
        print "\nRegion:",region,"\n"
        #make output directory
        outdir = 'Plots/'+tag+'/'+region
        os.system('mkdir -p '+outdir)
        #set up analysis
        (xbins,cols) = analysis.unrollBins
        auxSFs = razorWeights.getNJetsSFs(analysis, jetName=analysis.jetVar)
                                                 nbMax=nb,
                                                 boostCuts=boostCuts)
            regionsOrder.append(regionName)
            regions[regionName + 'MRCorr'] = razor.Analysis(
                "SingleLepton",
                tag=tag,
                njetsMin=jets[0],
                njetsMax=jets[1],
                nbMin=nb,
                nbMax=nb,
                boostCuts=boostCuts)
            regionsOrder.append(regionName + 'MRCorr')

    sfHists = macro.loadScaleFactorHists(
        sfFilename="data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root"
        % (tag),
        processNames=regions.itervalues().next().samples,
        debugLevel=debugLevel)
    sfVars = ("MR", "Rsq")
    sfNJetsFile = rt.TFile.Open(
        "data/ScaleFactors/RazorMADD2015/RazorNJetsScaleFactors_%s.root" %
        (tag))
    sfHists['NJetsTTJets'] = sfNJetsFile.Get("TTJetsScaleFactors")
    sfHists['NJetsWJets'] = sfNJetsFile.Get("WJetsScaleFactors")

    for region in regionsOrder:
        print "\nRegion:", region, "\n"
        outdir = 'Plots/' + tag + '/' + region
        os.system('mkdir -p ' + outdir)
        analysis = regions[region]
        auxSFs = razorWeights.getNJetsSFs(analysis)
Exemplo n.º 4
0
             tag=tag,boostCuts=boostCuts),
         "DYJetsDileptonInv":Analysis("DYJetsDileptonInv",
             tag=tag,boostCuts=boostCuts),
         "DYJetsDileptonInvDiJet":Analysis("DYJetsDileptonInv",
             tag=tag,njetsMin=2,njetsMax=3, boostCuts=boostCuts),
         "DYJetsDileptonInvMultiJet":Analysis("DYJetsDileptonInvMultiJet",
             tag=tag,njetsMin=4,njetsMax=6, boostCuts=boostCuts),
         "DYJetsDileptonInvSevenJet":Analysis("DYJetsDileptonInvMultiJet",
             tag=tag,njetsMin=7, boostCuts=boostCuts),
         "DYJetsDileptonInvNoSFs":Analysis("DYJetsDileptonInv",
             tag=tag,boostCuts=boostCuts),
         }
 sfFilename="data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root"%(tag)
 #make two dictionaries of scale factor histograms, one with GJets and one with WJets corrections
 sfHists = macro.loadScaleFactorHists( sfFilename=sfFilename,
         processNames=regions["DYJetsDileptonInvDiJet"].samples, 
         scaleFactorNames={ "DYJetsInv":"GJetsInv" }, debugLevel=debugLevel )
 sfNJetsFile = rt.TFile.Open(
         "data/ScaleFactors/RazorMADD2015/RazorNJetsScaleFactors_%s.root"%(tag))
 for d in [sfHists]:
     d['NJetsTTJets'] = sfNJetsFile.Get("TTJetsScaleFactors")
     d['NJetsWJets'] = sfNJetsFile.Get("WJetsScaleFactors")
     d['NJetsInv'] = sfNJetsFile.Get("GJetsInvScaleFactors")
     d['NJetsWJetsInv'] = sfNJetsFile.Get("WJetsInvScaleFactors")
     bclosure.loadScaleFactors(d, tag=tag)
     bclosure.loadScaleFactors(d, tag=tag, gjets=True)
 sfVars = { "WJets":("MR","Rsq"), "TTJets":("MR","Rsq"), "DYJetsInv":("MR_NoZ","Rsq_NoZ") }
 if not args.noSave:
     outfile = rt.TFile(
         "data/ScaleFactors/RazorMADD2015/RazorDYJetsDileptonInvCrossCheck_%s.root"%(tag), "RECREATE")
 #optionally inflate scale factor uncertainties to cover difference between G+jets and W+jets SFs
 regionsOrder = ["GJetsInvForNJets", "TTJetsForNJets", 
         "WJetsForNJets", "WJetsInvForNJets"]
 regions = {
         "GJetsInvForNJets":Analysis("GJetsInv",tag=tag,boostCuts=boostCuts),
         "TTJetsForNJets":Analysis("TTJetsSingleLepton",tag=tag,nbMin=1,boostCuts=boostCuts),
         "WJetsForNJets":Analysis("WJetsSingleLepton",tag=tag,nbMax=0,boostCuts=boostCuts),
         "WJetsInvForNJets":Analysis("WJetsSingleLeptonInv",tag=tag,nbMax=0,boostCuts=boostCuts),
         }
 sfVars = {
         "GJetsInvForNJets":("MR_NoPho","Rsq_NoPho"),
         "TTJetsForNJets":("MR","Rsq"),
         "WJetsForNJets":("MR","Rsq"),
         "WJetsInvForNJets":("MR_NoW","Rsq_NoW"),
         }
 sfHists = macro.loadScaleFactorHists(
         sfFilename="data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root"%(tag), 
         processNames=regions["TTJetsForNJets"].samples+["GJetsInv",'WJetsInv'], 
         debugLevel=debugLevel)
 sfNames = { 
         "GJetsInvForNJets":"GJetsInv", 
         "TTJetsForNJets":"TTJets", 
         "WJetsForNJets":"WJets", 
         "WJetsInvForNJets":"WJetsInv", 
         }
 njetsNames = {
         "GJetsInvForNJets":"NJets_NoPho",
         "TTJetsForNJets":"NJets40",
         "WJetsForNJets":"NJets40",
         "WJetsInvForNJets":"NJets_NoW",
         }
 outfile_name = "data/ScaleFactors/RazorMADD2015/RazorNJetsScaleFactors_%s.root"%(tag)
 if args.tightCuts:
    regionsOrder = wjetsRegionNames + dyjetsRegionNames
    regions = {
            "WJetsSingleLeptonInvNLO":Analysis("WJetsSingleLeptonInv", 
                nbMax=0, tag=tag, boostCuts=boostCuts),
            "WJetsSingleLeptonInvNLOForNJets":Analysis("WJetsSingleLeptonInv", 
                nbMax=0, tag=tag, boostCuts=boostCuts),
            "DYJetsDileptonInvNLO":Analysis("DYJetsDileptonInv",
                tag=tag,boostCuts=boostCuts),
            "DYJetsDileptonInvNLODiJet":Analysis("DYJetsDileptonInv",
                tag=tag, njetsMin=2, njetsMax=3, boostCuts=boostCuts),
            "DYJetsDileptonInvNLOMultiJet":Analysis("DYJetsDileptonInvMultiJet",
                tag=tag, njetsMin=4, boostCuts=boostCuts),
            }
    sfFilename="data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root"%(tag)
    sfHists = macro.loadScaleFactorHists( sfFilename=sfFilename,
            processNames=regions["DYJetsDileptonInvNLO"].samples, 
            debugLevel=debugLevel )
    sfNJetsFile = rt.TFile.Open(
            "data/ScaleFactors/RazorMADD2015/RazorNJetsScaleFactors_%s.root"%(tag))
    sfHists['NJetsTTJets'] = sfNJetsFile.Get("TTJetsScaleFactors")
    sfHists['NJetsWJets'] = sfNJetsFile.Get("WJetsScaleFactors")
    sfVars = { "WJets":("MR","Rsq"), "TTJets":("MR","Rsq"), 
            "DYJetsInv":("MR_NoZ","Rsq_NoZ"), "WJetsInv":("MR_NoW", "Rsq_NoW") }

    # We need to recompute the W+jets invisible scale factors 
    # using the NLO sample.
    for reg in wjetsRegionNames:
        regions[reg].filenames['WJetsInv'] = regions[reg].filenames[
                'WJetsInv'].replace('WJets_', 'WJetsPtBinned_')
    for reg in dyjetsRegionNames:
        regions[reg].filenames['DYJetsInv'] = regions[reg].filenames[
     "OneLeptonForNJets": Analysis("SingleLepton", tag=tag),
     "OneLeptonInvForNJets": Analysis("SingleLeptonInv", tag=tag),
     "GJetsInvForNJets": Analysis("GJetsInv", tag=tag),
 }
 sfVars = {
     "OneLeptonForNJets": ("MR", "Rsq"),
     "OneLeptonInvForNJets": {
         "WJetsInv": ("MR_NoW", "Rsq_NoW"),
         "TTJets": ("MR", "Rsq")
     },
     "GJetsInvForNJets": ("MR_NoPho", "Rsq_NoPho")
 }
 sfHists = {
     region: macro.loadScaleFactorHists(
         sfFilename=
         "data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root" %
         (tag),
         processNames=regions[region].samples,
         debugLevel=debugLevel)
     for region in regions
 }
 sfNames = {
     "OneLeptonForNJets": "NJetsCorrection",
     "OneLeptonInvForNJets": "NJetsNoWCorrection",
     "GJetsInvForNJets": "NJetsNoPhoCorrection",
 }
 njetsNames = {
     "OneLeptonForNJets": "NJets40",
     "OneLeptonInvForNJets": "NJets_NoW",
     "GJetsInvForNJets": "NJets_NoPho",
 }
 outfile = rt.TFile(
def loadAllScaleFactorHists(tag, args, processNames, debugLevel=0):
    #scale factor file names
    sfdir = "data/ScaleFactors/RazorMADD2015/"
    sfFile = sfdir+'/RazorScaleFactors_%s.root'%(tag)
    sfFile_nJets = sfdir+'/RazorNJetsScaleFactors_%s.root'%(tag)
    vetolepFile = sfdir+'/RazorVetoLeptonClosureTests_%s.root'%(tag)
    ttFile = sfdir+'/RazorTTJetsDileptonCrossCheck_%s.root'%(tag)
    dyFile = sfdir+'/RazorDYJetsDileptonInvCrossCheck_%s.root'%(tag)
    dybFile = sfdir+'/RazorDYJetsDileptonInvBCheck_%s.root'%(tag)
    btagFile = sfdir+'/RazorBTagScaleFactors_%s.root'%(tag)
    dynloFile = sfdir+'/RazorDYJetsDileptonInvNLOCrossCheck_%s.root'%(tag)

    #get MR-Rsq scale factor histograms
    sfNames={
            "ZInv":"GJetsInv",
            "TTJets1L":"TTJets",
            "TTJets2L":"TTJets",
            }
    sfHists = macro.loadScaleFactorHists(sfFilename=sfFile, processNames=processNames, 
            scaleFactorNames=sfNames, debugLevel=debugLevel)
    bclosure.loadScaleFactors(sfHists, tag=tag)
    bclosure.loadScaleFactors(sfHists, tag=tag, gjets=True)
    #reopen the file and grab the ZNuNu up/down histograms
    #down scale factors are (gjets - (wjets-gjets))
    sfTFile = rt.TFile.Open(sfFile)
    sfHists['ZInvUp'] = sfTFile.Get('WJetsInvScaleFactors')
    sfHists['ZInvDown'] = sfTFile.Get('GJetsInvScaleFactors_Down') 
    #get njets scale factor histogram
    sfNJetsFile = rt.TFile.Open(sfFile_nJets)
    sfHists['NJetsTTJets'] = sfNJetsFile.Get("TTJetsScaleFactors")
    sfHists['NJetsWJets'] = sfNJetsFile.Get("WJetsScaleFactors")
    sfHists['NJetsInv'] = sfNJetsFile.Get("GJetsInvScaleFactors")
    #nb double ratio scale factors
    dybTFile = rt.TFile.Open(dybFile)
    sfHists['NBTagsInv'] = dybTFile.Get("DYJetsDileptonInvBCheckScaleFactors")
    #get veto lepton/tau, DYJets, and TTBar Dilepton cross check scale factor histograms
    #and b-tag closure results
    vlFile = rt.TFile.Open(vetolepFile)
    ttTFile = rt.TFile.Open(ttFile)
    dyTFile = rt.TFile.Open(dyFile)
    btagTFile = rt.TFile.Open(btagFile)
    dynloTFile = rt.TFile.Open(dynloFile)
    if args.nloZInv:
        sfHists['ZInv'] = dynloTFile.Get("WJetsSingleLeptonInvNLOScaleFactors")
        sfHists['NJetsInv'] = dynloTFile.Get("WJetsSingleLeptonInvNLOForNJetsScaleFactors")
    for jtype in ['DiJet','MultiJet','SevenJet']:
        sfHists['TTJetsDilepton'+jtype+'Up'] = ttTFile.Get("TTJetsDilepton"+jtype+"ScaleFactors")
        sfHists['TTJetsDilepton'+jtype+'Down'] = macro.invertHistogram(
                sfHists['TTJetsDilepton'+jtype+'Up'])
        sfHists['DYJetsInvMR'+jtype+'Up'] = dyTFile.Get('DYJetsDileptonInv'+jtype+'MRScaleFactors')
        sfHists['DYJetsInvRsq'+jtype+'Up'] = dyTFile.Get('DYJetsDileptonInv'+jtype+'RsqScaleFactors')
        if args.nloZInv:
            sfHists['DYJetsInvMR'+jtype+'Up'] = dynloTFile.Get("DYJetsDileptonInvNLO"+jtype+"MRScaleFactors")
            sfHists['DYJetsInvRsq'+jtype+'Up'] = dynloTFile.Get("DYJetsDileptonInvNLO"+jtype+"RsqScaleFactors")
        sfHists['DYJetsInvMR'+jtype+'Down'] = macro.invertHistogram(
                sfHists['DYJetsInvMR'+jtype+'Up'])
        sfHists['DYJetsInvRsq'+jtype+'Down'] = macro.invertHistogram(
                sfHists['DYJetsInvRsq'+jtype+'Up'])
        for ltype in ['VetoLepton','VetoTau']:
            name = jtype+'For'+ltype
            sfHists[ltype+jtype+'PtUp'] = vlFile.Get(name+'ScaleFactors')
            sfHists[ltype+jtype+'PtDown'] = macro.invertHistogram(sfHists[ltype+jtype+'PtUp'])
            sfHists[ltype+jtype+'EtaUp'] = vlFile.Get(name+'PtCorrScaleFactors')
            sfHists[ltype+jtype+'EtaDown'] = macro.invertHistogram(sfHists[ltype+jtype+'EtaUp'])
        for b in range(4):
            if jtype == 'DiJet' and b > 2: continue
            bs = str(b)
            sfHists['Rsq'+jtype+bs+'BUp'] = btagTFile.Get(
                    'Rsq'+jtype+bs+'B')
            sfHists['Rsq'+jtype+bs+'BDown'] = macro.invertHistogram(sfHists['Rsq'+jtype+bs+'BUp'])
            if b > 2: continue
            sfHists['ZInv'+jtype+bs+'BUp'] = btagTFile.Get(
                    'RsqInv'+jtype+bs+'B')
            sfHists['ZInv'+jtype+bs+'BDown'] = macro.invertHistogram(
                    sfHists['ZInv'+jtype+bs+'BUp'])

    #check that everything came out correctly
    for h,hist in sfHists.iteritems():
        if debugLevel > 0:
            print "Checking scale factor histogram:",h
        #assert hist
        #hist.SetDirectory(0)
        if hist:
            hist.SetDirectory(0)
        elif 'MultiJet' not in h and 'DiJet' not in h:
            raise ValueError("Hist {} is null".format(h))
    return sfHists
            regionDphiHists[sigR] = dphiHists[ltype+"Pt"]
            #veto lepton/tau control region
            regionsOrder.append(ltype+jtype+"PtCorr") 
            regions[ltype+jtype+"PtCorr"] = Analysis(ltype+"ControlRegion",tag=tag,
                    njetsMin=jets[0],njetsMax=jets[1],boostCuts=boostCuts)
            #corresponding signal region 
            sigRPtCorr = jtype+"For"+ltype+"PtCorr"
            regionsOrder.append(sigRPtCorr) 
            regions[sigRPtCorr] = Analysis(sigR+"ControlRegion",
                    tag=tag,njetsMin=jets[0],njetsMax=jets[1],boostCuts=boostCuts)
            regionsCorrespondence[sigRPtCorr] = ltype+jtype+"PtCorr"
            regionMtHists[sigRPtCorr] = mtHists[ltype+"Eta"]
            regionDphiHists[sigRPtCorr] = dphiHists[ltype+"Eta"]

    sfHists = macro.loadScaleFactorHists(
            sfFilename="data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root"%(tag), 
            processNames=regions["VetoLeptonSevenJet"].samples, scaleFactorNames={ "ZInv":"GJetsInv" },
            debugLevel=debugLevel)
    sfHistsSignal = macro.loadScaleFactorHists(
            sfFilename="data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root"%(tag),
            processNames=regions["SevenJetForVetoLepton"].samples, scaleFactorNames={ "ZInv":"GJetsInv", "TTJets1L":"TTJets", "TTJets2L":"TTJets" }, debugLevel=debugLevel)
    sfNJetsFile = rt.TFile.Open(
            "data/ScaleFactors/RazorMADD2015/RazorNJetsScaleFactors_%s.root"%(tag))
    for h in [sfHists, sfHistsSignal]:
        h['NJetsTTJets'] = sfNJetsFile.Get("TTJetsScaleFactors")
        h['NJetsWJets'] = sfNJetsFile.Get("WJetsScaleFactors")
        h['NJetsInv'] = sfNJetsFile.Get("GJetsInvScaleFactors")
        bclosure.loadScaleFactors(h, tag=tag)
    sfVars = ("MR","Rsq")
    if not args.noSave:
        #recreate output file to avoid confusion
        outfile = rt.TFile("data/ScaleFactors/RazorMADD2015/RazorVetoLeptonClosureTests_%s.root"%(tag), "RECREATE")
Exemplo n.º 10
0
                                                         njetsMin=jets[0],
                                                         njetsMax=jets[1])
            #corresponding signal region
            sigRPtCorr = jtype + "For" + ltype + "PtCorr"
            regionsOrder.append(sigRPtCorr)
            regions[sigRPtCorr] = Analysis(sigR + "ControlRegion",
                                           tag=tag,
                                           njetsMin=jets[0],
                                           njetsMax=jets[1])
            regionsCorrespondence[sigRPtCorr] = ltype + jtype + "PtCorr"
            regionMtHists[sigRPtCorr] = mtHists[ltype + "Eta"]
            regionDphiHists[sigRPtCorr] = dphiHists[ltype + "Eta"]

    sfHists = macro.loadScaleFactorHists(
        sfFilename="data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root"
        % (tag),
        processNames=regions["VetoLeptonDiJet"].samples,
        scaleFactorNames={"ZInv": "GJetsInv"},
        debugLevel=debugLevel)
    sfHistsSignal = macro.loadScaleFactorHists(
        sfFilename="data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root"
        % (tag),
        processNames=regions["DiJetForVetoLepton"].samples,
        scaleFactorNames={
            "ZInv": "GJetsInv",
            "TTJets1L": "TTJets",
            "TTJets2L": "TTJets"
        },
        debugLevel=debugLevel)
    sfNJetsFile = rt.TFile.Open(
        "data/ScaleFactors/RazorMADD2015/RazorNJetsScaleFactors_%s.root" %
        (tag))
Exemplo n.º 11
0
    debugLevel = args.verbose + 2 * args.debug
    tag = args.tag
    boostCuts = not args.noBoostCuts

    #initialize
    plotOpts = {"comment": False, 'SUS15004CR': True}
    regionsOrder = ["DYJetsDileptonInvBCheck"]
    regions = {
        "DYJetsDileptonInvBCheck":
        Analysis("DYJetsDileptonInv", tag=tag, boostCuts=boostCuts)
    }
    sfFilename = "data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root" % (
        tag)
    sfHists = macro.loadScaleFactorHists(
        sfFilename=sfFilename,
        processNames=regions["DYJetsDileptonInvBCheck"].samples,
        scaleFactorNames={"DYJetsInv": "GJetsInv"},
        debugLevel=debugLevel)
    sfNJetsFile = rt.TFile.Open(
        "data/ScaleFactors/RazorMADD2015/RazorNJetsScaleFactors_%s.root" %
        (tag))
    for d in [sfHists]:
        d['NJetsTTJets'] = sfNJetsFile.Get("TTJetsScaleFactors")
        d['NJetsWJets'] = sfNJetsFile.Get("WJetsScaleFactors")
        d['NJetsInv'] = sfNJetsFile.Get("GJetsInvScaleFactors")
        d['NJetsWJetsInv'] = sfNJetsFile.Get("WJetsInvScaleFactors")
        bclosure.loadScaleFactors(d, tag=tag)
        bclosure.loadScaleFactors(d, tag=tag, gjets=True)
    sfVars = {
        "WJets": ("MR", "Rsq"),
        "TTJets": ("MR", "Rsq"),
Exemplo n.º 12
0
    os.system('mkdir -p '+outDir)

    for curBox in boxList:
        btagsMax = getMaxBtags(curBox)

        # retrieve binning and other info
        analyses = []
        unrollBins = []
        for nb in range(btagsMax + 1):
            analyses.append(Analysis(curBox, args.tag, nbMin=nb))
            unrollBins.append(analyses[-1].unrollBins)
        lumi = analyses[0].lumi
        sfNames = { "TTJets1L":"TTJets", "TTJets2L":"TTJets", 
                "ZInv":"GJetsInv" }
        sfHists = macro.loadScaleFactorHists(
            "data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root"%(args.tag), 
            processNames=["TTJets1L","TTJets2L","WJets","ZInv"], 
            scaleFactorNames=sfNames, debugLevel=debugLevel)
        sfFileNameBClosure = 'data/ScaleFactors/RazorMADD2015/RazorBTagScaleFactors_%s.root'%(args.tag)
        sfFileBClosure = rt.TFile.Open(sfFileNameBClosure)
        sfHistsForUncorrSFs1D = {}
        sfHistsForUncorrSFs1DMR = {}
        jets = 'MultiJet'
        if curBox in ['DiJet', 'LeptonJet']:
            jets = 'DiJet'
        elif curBox in ['SevenJet', 'LeptonSevenJet']:
            jets = 'SevenJet'
        for name in ['TTJets1L', 'TTJets2L', 'WJets']:
            sfHistsForUncorrSFs1D[name] = sfFileBClosure.Get("Rsq{}0B".format(jets))
            assert(sfHistsForUncorrSFs1D[name])
            sfHistsForUncorrSFs1DMR[name] = sfFileBClosure.Get("MR{}0B".format(jets))
            assert(sfHistsForUncorrSFs1DMR[name])
Exemplo n.º 13
0
    sfFile_nJets = sfdir + '/RazorNJetsScaleFactors_%s.root' % (tag)
    vetolepFile = sfdir + '/RazorVetoLeptonClosureTests_%s.root' % (tag)
    ttFile = sfdir + '/RazorTTJetsDileptonCrossCheck_%s.root' % (tag)
    dyFile = sfdir + '/RazorDYJetsDileptonInvCrossCheck_%s.root' % (tag)
    btagFile = sfdir + '/RazorBTagClosureTests_%s.root' % (tag)
    gjetsbtagFile = sfdir + '/RazorGJetsBTagClosureTests_%s.root' % (tag)

    #get MR-Rsq scale factor histograms
    sfNames = {
        "ZInv": "GJetsInv",
        "TTJets1L": "TTJets",
        "TTJets2L": "TTJets",
    }
    processNames = regions.itervalues().next().samples
    sfHists = macro.loadScaleFactorHists(sfFilename=sfFile,
                                         processNames=processNames,
                                         scaleFactorNames=sfNames,
                                         debugLevel=debugLevel)
    #reopen the file and grab the ZNuNu up/down histograms
    #down scale factors are (gjets - (wjets-gjets))
    sfTFile = rt.TFile.Open(sfFile)
    sfHists['ZInvUp'] = sfTFile.Get('WJetsInvScaleFactors')
    sfHists['ZInvDown'] = sfTFile.Get('GJetsInvScaleFactors_Down')
    #get njets scale factor histogram
    sfNJetsFile = rt.TFile.Open(sfFile_nJets)
    sfHists['NJetsTTJets'] = sfNJetsFile.Get("TTJetsScaleFactors")
    sfHists['NJetsWJets'] = sfNJetsFile.Get("WJetsScaleFactors")
    sfHists['NJetsInv'] = sfNJetsFile.Get("GJetsInvScaleFactors")
    #get veto lepton/tau, DYJets, and TTBar Dilepton cross check scale factor histograms
    #and b-tag closure results
    vlFile = rt.TFile.Open(vetolepFile)
    ttTFile = rt.TFile.Open(ttFile)