示例#1
0
print stackList

exit()

# reweighting of pTZ
if args.reweightPtXToSM:

    if 'ttZ' in args.processFile: varX = "%sZ_pt"%args.level
    elif 'ttW' in args.processFile: varX = "%sW_pt"%args.level
    elif 'ttgamma' in args.processFile: varX = "%sPhoton_pt"%args.level

    rwIndex = -2 if args.backgrounds else -1

    for i, param in enumerate( params[::-1] ):
        if i==0 and args.backgrounds: continue # no bg scaling
        param[0]['ptX_histo'] = ttXSample.get1DHistoFromDraw(varX, [50,0,500], selectionString = cutInterpreter.cutString(args.selection), weightString = w.get_weight_string(**param[0]['WC']))
        ptX_integral = param[0]['ptX_histo'].Integral()
        if ptX_integral > 0: param[0]['ptX_histo'].Scale(1./ptX_integral)
        param[0]['ptX_reweight_histo'] = params[rwIndex][0]['ptX_histo'].Clone()
        param[0]['ptX_reweight_histo'].Divide(param[0]['ptX_histo'])
        logger.info( 'Made reweighting histogram for ptX and param-point %r with integral %f', param[0], param[0]['ptX_reweight_histo'].Integral())

    def get_reweight( param, sample_, isSignal=True ):

        if isSignal:
            histo = param['ptX_reweight_histo']
            bsm_rw = w.get_weight_func( **param['WC'] )
            def reweight(event, sample):
                i_bin = histo.FindBin(getattr( event, varX ) )
                return histo.GetBinContent(i_bin)*bsm_rw( event, sample ) * event.ref_lumiweight1fb * float(args.luminosity) * float(sample.event_factor)
#                return histo.GetBinContent(i_bin)*bsm_rw( event, sample ) * sample_.xsec * 1000 / sample_.nEvents / event.p_C[0] * float(args.luminosity) * float(sample.event_factor)
示例#2
0
        'color': colors[i_param],
    })

#params.append( {'legendText':'ctZ 1 ctZI 1', 'WC':{'ctZ':1, 'ctZI':1}, 'color':ROOT.kRed} )
params.append({'legendText': 'SM', 'WC': {}, 'color': ROOT.kBlack})

# Make stack
stack = Stack(*[[sample] for param in params])

# reweighting of pTZ
if args.reweightPtZToSM:
    for param in params[::-1]:
        param['ptZ_histo'] = sample.get1DHistoFromDraw(
            "Z_pt", [20, 0, 500],
            selectionString=cutInterpreter.cutString(args.selection),
            weightString=w.get_weight_string(**param['WC']))
        if param['ptZ_histo'].Integral() > 0:
            param['ptZ_histo'].Scale(1. / param['ptZ_histo'].Integral())
        param['ptZ_reweight_histo'] = params[-1]['ptZ_histo'].Clone()
        param['ptZ_reweight_histo'].Divide(param['ptZ_histo'])
        logger.info(
            'Made reweighting histogram for ptZ and param-point %r with integral %f',
            param, param['ptZ_reweight_histo'].Integral())

    def get_reweight(param):
        histo = param['ptZ_reweight_histo']
        var = 'Z_pt'
        bsm_rw = w.get_weight_func(**param['WC'])

        def reweight(event, sample):
            i_bin = histo.FindBin(getattr(event, var))
示例#3
0
# reweighting of pTZ
if args.reweightPtXToSM:

    if 'ttZ' in args.processFile: varX = "%sZ_pt" % args.level
    elif 'ttW' in args.processFile: varX = "%sW_pt" % args.level
    elif 'ttgamma' in args.processFile: varX = "%sPhoton_pt" % args.level

    rwIndex = -2 if args.backgrounds else -1

    for i, param in enumerate(params[::-1]):
        if i == 0 and args.backgrounds: continue  # no bg scaling
        param[0]['ptX_histo'] = ttXSample.get1DHistoFromDraw(
            varX, [50, 0, 500],
            selectionString=cutInterpreter.cutString(args.selection),
            weightString=w.get_weight_string(**param[0]['WC']))
        ptX_integral = param[0]['ptX_histo'].Integral()
        if ptX_integral > 0: param[0]['ptX_histo'].Scale(1. / ptX_integral)
        param[0]['ptX_reweight_histo'] = params[rwIndex][0]['ptX_histo'].Clone(
        )
        param[0]['ptX_reweight_histo'].Divide(param[0]['ptX_histo'])
        logger.info(
            'Made reweighting histogram for ptX and param-point %r with integral %f',
            param[0], param[0]['ptX_reweight_histo'].Integral())

    def get_reweight(param, sample_, isSignal=True):

        if isSignal:
            histo = param['ptX_reweight_histo']
            bsm_rw = w.get_weight_func(**param['WC'])
示例#4
0
#sample = dim6top_ttZ_ll_LO_currentplane_highStat_scan

# just 1 file
sample.files = sample.files

# get TChain
c = sample.chain

w = WeightInfo(sample.reweight_pkl)
w.set_order(2)

c.Draw("Z_pt>>h_Zpt(50,0,550)")  # "weight*(%s)" % weightString(cpt=0.2)
#c.Draw("Z_pt>>h_Zpt1(50,0,550)", '(' + w.get_weight_string(cpt=vcpt, cpQM=vcpQM) + ')/p_C[0]')
c.Draw(
    "Z_pt>>h_Zptarg(50,0,550)",
    '(' + w.get_weight_string(cpt=vcpt, cpQM=vcpQM, ctZ=vctZ, ctZI=vctZI) +
    ')/p_C[0]')
c.Draw(
    "Z_pt>>h_Zptargcut(50,0,550)",
    '(' + w.get_weight_string(cpt=vcpt, cpQM=vcpQM, ctZ=vctZ, ctZI=vctZI) +
    ')/p_C[0]*(p_C[5]<' + pc5thresh + ')')

#num = []
#num_arg = []
#num_argcut = []
#for i in range(1, ROOT.h_Zptarg.GetNbinsX()+1):
#    num.append(ROOT.h_Zpt.GetBinContent(i))
#    num_arg.append(ROOT.h_Zptarg.GetBinContent(i))
#    num_argcut.append(ROOT.h_Zptargcut.GetBinContent(i))

#print(sum(num))