Esempio n. 1
0
    # always initialize with [], elso you get in trouble with pythons references!
    plots = []
    plots += plotList
    plots += [getYieldPlot(index)]

    # Define 2l selections
    leptonSelection = cutInterpreter.cutString(mode)

    if not args.noData:
        data_sample.setSelectionString(
            [getFilterCut(2016, isData=True), leptonSelection])
    for sample in mc + signals:
        sample.setSelectionString([
            getFilterCut(2016, isData=False), leptonSelection,
            tr.getSelection("MC")
        ])

    # Overlap removal
    if any(x.name == "TTG" for x in mc) and any(x.name == "TT_pow"
                                                for x in mc):
        eval('TTG_' + str(args.year)[-2:]).addSelectionString("isTTGamma==1")
        eval('TT_pow_' +
             str(args.year)[-2:]).addSelectionString("isTTGamma==0")

    if any(x.name == "ZG" for x in mc) and any(x.name == "DY_LO" for x in mc):
        eval('ZG_' + str(args.year)[-2:]).addSelectionString("isZWGamma==1")
        eval('DY_LO_' + str(args.year)[-2:]).addSelectionString("isZWGamma==0")

    if any(x.name == "WG" for x in mc) and any(x.name == "WJets" for x in mc):
        eval('WG_' + str(args.year)[-2:]).addSelectionString("isZWGamma==1")
mcWeight = lambda event, sample: event.reweightL1Prefire * event.reweightPU * event.reweightLeptonTightSF * event.reweightLeptonTrackingTightSF * event.reweightPhotonSF * event.reweightPhotonElectronVetoSF * event.reweightBTag_SF
# a weight for all samples incluuding data is defined here
weight = lambda event, sample: event.weight

# get some additional cuts specific for MC and/or data
# MET Filter cut for data and MC
filterCutData = getFilterCut(args.year,
                             isData=True,
                             skipBadChargedCandidate=True)
filterCutMc = getFilterCut(args.year,
                           isData=False,
                           skipBadChargedCandidate=True)
# Trigger cuts for MC (already applied for Data)
tr = TriggerSelector(args.year,
                     singleLepton=True)  #single lepton trigger also for DY CR
triggerCutMc = tr.getSelection("MC")

# Sample definition
mc = [
    mc_samples.TTG, mc_samples.TT_pow, mc_samples.DY_LO, mc_samples.WJets,
    mc_samples.WG, mc_samples.ZG, mc_samples.rest
]
ttg = mc_samples.TTG

if args.noData:
    # Scale the histograms by the luminosity taken by CMS in each year
    if args.year == 2016: lumi_scale = 35.92
    elif args.year == 2017: lumi_scale = 41.53
    elif args.year == 2018: lumi_scale = 59.74
    # add all samples to the Stack
    stack = Stack(mc)
Esempio n. 3
0
Run2017.texName = "data"
Run2017.name = "data"
Run2017.style = styles.errorStyle(
    ROOT.kBlue)  #styles.fillStyle( ROOT.kOrange-3 )
Run2017.scale = 1

if args.small:
    for sample in stack.samples:
        sample.normalization = 1.
        sample.reduceFiles(factor=50)
        sample.scale /= sample.normalization

weight_ = lambda event, sample: event.weight
tr = TriggerSelector(2017, singleLepton=True)
triggerCond = tr.getSelection("SingleMuon")

# Use some defaults (set defaults before you create/import list of Plots!!)
Plot.setDefaults(stack=stack,
                 weight=staticmethod(weight_),
                 selectionString=cutInterpreter.cutString(args.selection),
                 addOverFlowBin='upper')

# Import plots list (AFTER setDefaults!!)
plotListFile = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            'plotLists', args.plotFile + '.py')
if not os.path.isfile(plotListFile):
    logger.info("Plot file not found: %s", plotListFile)
    sys.exit(1)

plotModule = imp.load_source("plotLists", os.path.expandvars(plotListFile))