replaceW = False
    osForWExtrapolation = True
    makeQCDIsoPlots = False

    # Replace W shape in VBF and 1-jet
    if isVBF or isOneJet or isBtag:
        replaceW = True

    # Use OS+SS for W extrapolation in VBF
    if isVBF:
        osForWExtrapolation = False

    embed = options.embed

    aliases = None
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config, aliases, options.embed, 'TauEle', options.higgs, isMSSM=isMSSM)

    print 'SELECTED COMPONENTS', selComps
    print 'WEIGHTS', [weights[w].GetWeight() for w in weights]
    print 'Z COMPONENTS', zComps

    dataComps = dict( (comp.name, comp) for comp in selComps.values() if comp.isData )

    # can, pad, padr = buildCanvas()
    ocan = buildCanvasOfficial()

    embedForSS = False
    if options.embed:
        print 'INFO, not using embedded samples for W estimation in sideband as per Summer 13 twiki'

    nbins = 50
        shift = 'Down'
    elif anaDir.endswith('_Up'):
        shift = 'Up'

    
    cfgFileName = args[1]
    file = open( cfgFileName, 'r' )
    cfg = imp.load_source( 'cfg', cfgFileName, file)
    embed = options.embed

    origComps = copy.deepcopy(cfg.config.components)

    comps = [comp for comp in cfg.config.components if comp.name!='W3Jets' and comp.name!='W2Jets' and  comp.name!='TTJets11']
    cfg.config.components = comps
    
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config, None, options.embed, 'TauMu', '125')


    # normalizing WJets (not WJets11 here) 
    # inclusive, iso sideband, SS
    inc_w_cut = cat_Inc
    inc_fwss, inc_fwos, inc_w_ss, inc_w_os = plot_W( anaDir, selComps, weights,
                                                     12, 70, 310, inc_w_cut,
                                                     weight=weight, embed=options.embed)

    # inclusive QCD yield in signal region
    # this yield will be multiplied by the VBF efficiency
    # import pdb; pdb.set_trace()
    insig_qcd_cut = '&&'.join([cat_Inc, options.cut])
    inc_ssign, inc_osign, inc_ssQCD, inc_osQCD = makePlotInclusive(
        options.hist, anaDir,
        if comp.name == 'WJets11': continue #PG remove me
        if options.useExcusiveVV :
            if comp.name == 'WW' : continue
            if comp.name == 'ZZ' : continue
            if comp.name == 'WZ' : continue
        else :
            if comp.name == 'WW2l2v' : continue
            if comp.name == 'WZ2l2q' : continue
            if comp.name == 'WZ3lv' : continue
            if comp.name == 'ZZ2l2q' : continue
            if comp.name == 'ZZ2l2v' : continue
            if comp.name == 'ZZ4l' : continue
        comps.append( comp )
        
    cfg.config.components = comps
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config, None, 
                                                  options.embed, 'TauEle', options.higgs)


    cutw = options.cut.replace('mt<40', '1')
    # loosen electron isolation
    # cutw = cutw.replace('l2_relIso05<0.1', 'l2_relIso05<1')    
    # loosen tau isolation


    #PG (STEP 1) evaluate the WJets contribution from high mT sideband
    #PG ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
    #PG as it is done in the analysis

    fw_ss, fw_ss_error, fw_os, fwos_error, ss, os = plot_W(anaDir, selComps, weights,
                                                        12, 60, 120, cutw,
                                                        weight = weight, 
    weight='weight'
    
    anaDir = args[0]
    cfgFileName = args[1]
    file = open( cfgFileName, 'r' )
    cfg = imp.load_source( 'cfg', cfgFileName, file)
    embed = options.embed

    origComps = copy.deepcopy(cfg.config.components)

    can, pad, padr = buildCanvas()

    # WJet normalization, done with the 2012 sample
    comps = [comp for comp in cfg.config.components if comp.name!='W3Jets' and comp.name!='TTJets11' and comp.name!='WJets11']
    cfg.config.components = comps
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config, None, options.embed, 'TauMu', '125')

    cutw = options.cut.replace('mt<40', '1')
    fwss, fwos, ss, os = plot_W( anaDir, selComps, weights,
                                 12, 70, 310, cutw,
                                 weight=weight, embed=options.embed)

    cutwss = options.cut + ' && diTau_charge!=0'
    shapess, wjyieldss = shape_and_yield('mt', anaDir, selComps['WJets'], weights,
                                         50, 0, 9999, cutwss, weight=weight,
                                         embed=options.embed)
    cutwos = options.cut + ' && diTau_charge==0'
    shapeos, wjyieldos = shape_and_yield('mt', anaDir, selComps['WJets'], weights,
                                         50, 0, 9999, cutwos, weight=weight,
                                         embed=options.embed)
        
    emb_vbf_eff = None

    anaDir = args[0].rstrip('/')
    shift = None
    if anaDir.endswith('_Down'):
        shift = 'Down'
    elif anaDir.endswith('_Up'):
        shift = 'Up'

    cfgFileName = args[1]
    file = open(cfgFileName, 'r')
    cfg = imp.load_source('cfg', cfgFileName, file)
    embed = options.embed

    selComps, weights, zComps = prepareComponents(anaDir, cfg.config, None,
                                                  options.embed, 'TauEle',
                                                  options.higgs)

    inc_fwss, inc_fwos, inc_w_mt_ratio_ss, inc_w_mt_ratio_os, inc_w_mt_ratio = handleW(
        anaDir, selComps, weights, cat_Inc, weight, options.embed, cfg.VVgroup)

    # inclusive QCD yield in signal region
    # this yield will be multiplied by the VBF efficiency
    insig_qcd_cut = '&&'.join([cat_Inc, options.cut])
    inc_ssign, inc_osign, inc_ssQCD, inc_osQCD = makePlotInclusive(
        options.hist,
        anaDir,
        selComps,
        weights,
        inc_fwss,
        inc_fwos,
    NBINS = int(options.nbins)
    XMIN = float(options.xmin)
    XMAX = float(options.xmax)

    
    # TH1.AddDirectory(False)
    dataName = 'Data'
    weight='weight'
    
    anaDir = args[0]
    cfgFileName = args[1]
    file = open( cfgFileName, 'r' )
    cfg = imp.load_source( 'cfg', cfgFileName, file)
    embed = options.embed
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config)


    can, pad, padr = buildCanvas()

    fwss, fwos, ss, os = plot_W_inclusive( options.hist, anaDir, selComps, weights,
                                           30, 60, 300, 'isSignal',
                                           weight=weight, embed=options.embed)

    ssign, osign, ssQCD, osQCD = makePlot( options.hist, weights, fwss, fwos, NBINS, XMIN, XMAX, weight=weight, embed=options.embed); draw(osQCD)
    
    # from CMGTools.H2TauTau.proto.plotter.plot_H2TauTauDataMC_TauMu_Inclusive import makePlot as makePlotInclusive

    # ssign, osign, ssQCD, osQCD = makePlotInclusive( options.hist, anaDir, selComps, weights, fwss, fwos, NBINS, XMIN, XMAX, cat_Inc + ' && mt<40', weight=weight, embed=options.embed); draw(osQCD)

    # factor_QCD_nonIsoToIso()
    # TH1.AddDirectory(False)
    dataName = 'Data'
    weight = 'weight'

    anaDir = args[0]
    cfgFileName = args[1]
    file = open(cfgFileName, 'r')
    cfg = imp.load_source('cfg', cfgFileName, file)
    embed = options.embed

    origComps = copy.deepcopy(cfg.config.components)

    cfg.config.components = [
        comp for comp in cfg.config.components if comp.name.startswith('Higgs')
    ]
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config)
    for name, wei in sorted(weights.iteritems()):
        wei.intLumi = 3840.
        wei.xSection = 1.
        wei.addWeight = 1.0
        print name, '\t:', wei

    osign = makePlot(options.hist,
                     anaDir,
                     selComps,
                     weights,
                     NBINS,
                     XMIN,
                     XMAX,
                     options.cut,
                     weight=weight,
예제 #8
0
    # Replace W shape in VBF and 1-jet
    if isVBF or isOneJet or isBtag:
        replaceW = True

    # Use OS+SS for W extrapolation in VBF
    if isVBF:
        osForWExtrapolation = False

    embed = options.embed

    aliases = None
    selComps, weights, zComps = prepareComponents(anaDir,
                                                  cfg.config,
                                                  aliases,
                                                  options.embed,
                                                  'TauEle',
                                                  options.higgs,
                                                  isMSSM=isMSSM)

    print 'SELECTED COMPONENTS', selComps
    print 'WEIGHTS', [weights[w].GetWeight() for w in weights]
    print 'Z COMPONENTS', zComps

    dataComps = dict(
        (comp.name, comp) for comp in selComps.values() if comp.isData)

    # can, pad, padr = buildCanvas()
    ocan = buildCanvasOfficial()

    embedForSS = False
예제 #9
0
    shift = None
    if anaDir.endswith('Down'):
        shift = 'Down'
    elif anaDir.endswith('Up'):
        shift = 'Up'
    
    if options.shift:
        shift = options.shift

    cfgFileName = args[1]
    file = open( cfgFileName, 'r' )
    cfg = imp.load_source( 'cfg', cfgFileName, file)
    embed = options.embed

    aliases = None
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config, aliases, options.embed,
                                                  channel=options.channel, higgsMass=options.higgs, isMSSM=isMSSM)

    filteredComps = filterComps(selComps, options.filter, options.embed)
    
    ocan = buildCanvasOfficial()

    treeName = 'H2TauTauTreeProducer' + options.channel
    osign = makePlot( options.hist, anaDir, filteredComps, weights,
                      NBINS, XMIN, XMAX,
                      options.cut, weight=weight, embed=options.embed,
                      shift=None, VVgroup=cfg.VVgroup, treeName=treeName);
    # drawOfficial(osign, options.blind)
    osign.Draw()
      
    dcchan = 'muTau'
    if options.channel == 'TauEle':
예제 #10
0
    replaceW = True
    useW11 = False
    
    anaDir = args[0].rstrip('/')
    shift = None
    if anaDir.endswith('_Down'):
        shift = 'Down'
    elif anaDir.endswith('_Up'):
        shift = 'Up'
        
    cfgFileName = args[1]
    file = open( cfgFileName, 'r' )
    cfg = imp.load_source( 'cfg', cfgFileName, file)
    embed = options.embed

    aliases = None
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config, aliases, options.embed, channel='TauEle', higgsMass=options.higgs)

    # can, pad, padr = buildCanvas()
    ocan = buildCanvasOfficial()
    
    fwss, fwos, w_mt_ratio_ss, w_mt_ratio_os, w_mt_ratio = handleW(
        anaDir, selComps, weights,
        options.cut, weight, options.embed, cfg.VVgroup
        )
    
    ssign, osign, ssQCD, osQCD = makePlot( options.hist, anaDir, selComps, weights, fwss, fwos, w_mt_ratio_ss, w_mt_ratio_os, w_mt_ratio, NBINS, XMIN, XMAX, options.cut, weight=weight, embed=options.embed, shift=shift, replaceW=replaceW, VVgroup=cfg.VVgroup, antiEleIsoForQCD=antiEleIsoForQCD);
    drawOfficial(osQCD, options.blind)
      
    datacards(osQCD, cutstring, shift, 'eleTau')
예제 #11
0
    weight = 'weight'

    anaDir = args[0].rstrip('/')

    cfgFileName = args[1]
    file = open(cfgFileName, 'r')
    cfg = imp.load_source('cfg', cfgFileName, file)
    embed = options.embed

    treeName = 'ZJetsTreeProducer'

    aliases = None
    selComps, weights, zComps = prepareComponents(anaDir,
                                                  cfg.config,
                                                  aliases,
                                                  options.embed,
                                                  channel=options.channel,
                                                  higgsMass=options.higgs,
                                                  forcedLumi=5000.)

    normalizeDY(selComps)

    ocan = buildCanvasOfficial()

    osign = plot(options.hist, options.cut, NBINS, XMIN, XMAX)

##     osign = makePlot( options.hist, anaDir, selComps, weights,
##                       NBINS, XMIN, XMAX,
##                       options.cut, weight=weight,
##                       VVgroup=cfg.VVgroup, treeName=treeName);
##     # drawOfficial(osign, options.blind)
예제 #12
0
    #WARNING!
    weight='weight'
    
    anaDir = args[0].rstrip('/')

        
    cfgFileName = args[1]
    file = open( cfgFileName, 'r' )
    cfg = imp.load_source( 'cfg', cfgFileName, file)
    embed = options.embed

    treeName = 'ZJetsTreeProducer'

    aliases = None
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config, aliases,
                                                  options.embed,
                                                  channel=options.channel, higgsMass=options.higgs,
                                                  forcedLumi = 5000.)


    normalizeDY( selComps )
    
    ocan = buildCanvasOfficial()
    
    osign = plot(options.hist, options.cut, NBINS, XMIN, XMAX)
    
##     osign = makePlot( options.hist, anaDir, selComps, weights,
##                       NBINS, XMIN, XMAX,
##                       options.cut, weight=weight,
##                       VVgroup=cfg.VVgroup, treeName=treeName);
##     # drawOfficial(osign, options.blind)
예제 #13
0
    shift = None
    if anaDir.endswith('Down'):
        shift = 'Down'
    elif anaDir.endswith('Up'):
        shift = 'Up'
    
    if options.shift:
        shift = options.shift

    cfgFileName = args[1]
    file = open( cfgFileName, 'r' )
    cfg = imp.load_source( 'cfg', cfgFileName, file)
    embed = options.embed

    aliases = None
    selComps, weights, zComps = prepareComponents(anaDir, cfg.config, aliases, options.embed,
                                                  channel=options.channel, higgsMass=options.higgs, isMSSM=isMSSM)

    filteredComps = filterComps(selComps, options.filter, options.embed)
    
    ocan = buildCanvasOfficial()

    treeName = 'H2TauTauTreeProducer' + options.channel
    osign = makePlot( options.hist, anaDir, filteredComps, weights,
                      NBINS, XMIN, XMAX,
                      options.cut, weight=weight, embed=options.embed,
                      shift=None, VVgroup=cfg.VVgroup, treeName=treeName);
    # drawOfficial(osign, options.blind)
    osign.Draw()
      
    dcchan = 'muTau'
    if options.channel == 'TauEle':
    anaDir = args[0].rstrip("/")
    shift = None
    if anaDir.endswith("_Down"):
        shift = "Down"
    elif anaDir.endswith("_Up"):
        shift = "Up"

    cfgFileName = args[1]
    file = open(cfgFileName, "r")
    cfg = imp.load_source("cfg", cfgFileName, file)
    embed = options.embed

    aliases = None
    selComps, weights, zComps = prepareComponents(
        anaDir, cfg.config, aliases, options.embed, channel="TauEle", higgsMass=options.higgs
    )

    # can, pad, padr = buildCanvas()
    ocan = buildCanvasOfficial()

    fwss, fwos, w_mt_ratio_ss, w_mt_ratio_os, w_mt_ratio = handleW(
        anaDir, selComps, weights, options.cut, weight, options.embed, cfg.VVgroup
    )

    ssign, osign, ssQCD, osQCD = makePlot(
        options.hist,
        anaDir,
        selComps,
        weights,
        fwss,
예제 #15
0
    anaDir = args[0].rstrip('/')
    shift = None
    if anaDir.endswith('_Down'):
        shift = 'Down'
    elif anaDir.endswith('_Up'):
        shift = 'Up'

    treeName = 'H2TauTauTreeProducer' + options.channel
    
    cfgFileName = args[1]
    file = open( cfgFileName, 'r' )
    cfg = imp.load_source( 'cfg', cfgFileName, file)


    selComps, weights, zComps = prepareComponents(
        anaDir, cfg.config, None, True, options.channel,
        options.higgs)

    filteredComps = filterComps(selComps, options.filter)
    
    can, pad, padr = buildCanvas()
    # shift is now done at the skim level
    plot = H2TauTauMC( options.hist, anaDir, filteredComps,
                       weights, NBINS, XMIN, XMAX, options.cut,
                       weight=weight, shift=None,
                       treeName=treeName)
    plot.Draw()

    dcchan = None
    if options.channel == 'TauEle':
        dcchan = 'eleTau'