コード例 #1
0
    def harvestEm(self,channel='wenu',charge='both'):
        cmb = ch.CombineHarvester()

        # Read all the cards.
        # CH stores metadata about each object (Observation, Process, Systematic),
        # this is extracted from the card names with some regex
        for card in glob.glob(self.bindir+('/%s_mass*.txt' % channel)):
            cmb.QuickParseDatacard(card, """%s_mass(?<MASS>\d+)_$CHANNEL.card.txt""" % channel)

        # Need a unqiue bin name for each plus/minus,pt and eta combination
        # We extracted this part of the datacard name into the channel variable above,
        # so can just copy it and override the specific bin name that was in all the cards
        cmb.ForEachObj(lambda obj: obj.set_bin(obj.channel()))

        # We'll have three copies of the observation, one for each mass point.
        # Filter all but one copy.
        cmb.FilterObs(lambda obj: obj.mass() != '%d' % self.mwcentral)

        # Create workspace to hold the morphing pdfs and the mass
        w = ROOT.RooWorkspace('morph', 'morph')
        mass = w.factory('mw[{mwrange}]'.format(mwrange=self.mwrange))

        # BuildRooMorphing will dump a load of debug plots here
        debug = ROOT.TFile(self.bindir+'/debug.root', 'RECREATE')

        # Run for each bin,process combination (only for signal!)
        for b in cmb.bin_set():
            for p in cmb.cp().bin([b]).signals().process_set():
                morphing.BuildRooMorphing(w, cmb, b, p, mass, verbose=True, file=debug)

        # Just to be safe
        mass.setConstant(True)

        # Now the workspace is copied into the CH instance and the pdfs attached to the processes
        # (this relies on us knowing that BuildRooMorphing will name the pdfs in a particular way)
        cmb.AddWorkspace(w, True)
        cmb.cp().process(['W']).ExtractPdfs(cmb, 'morph', '$BIN_$PROCESS_morph', '')

        # Adjust the rateParams a bit - we currently have three for each bin (one for each mass),
        # but we only want one. Easiest to drop the existing ones completely and create new ones
        cmb.syst_type(['rateParam'], False)
        cmb.cp().process(['W']).AddSyst(cmb, 'norm_$BIN', 'rateParam', ch.SystMap()(1.00))

        # Have to set the range by hand
        for sys in cmb.cp().syst_type(['rateParam']).syst_name_set():
            cmb.GetParameter(sys).set_range(0.5, 1.5)

        # Print the contents of the model
        cmb.PrintAll()

        # Write out the cards, one per bin
        outdir=self.bindir+'/wenu_cards_morphed_{charge}'.format(charge=charge)
        writer = ch.CardWriter('$TAG/$BIN.txt', '$TAG/shapes.root')
        writer.SetVerbosity(1)
        writer.WriteCards(outdir, cmb)
コード例 #2
0
def addRateSystematics(cb, json_path, sub_folder=None, factTheory=None):
    # JSON is encoded as UTF8 by default, and that messes with the combineHarvester bindings
    def ascii_encode_dict(data):
        def ascii_encode(x):
            if isinstance(x, unicode): return x.encode('ascii')
            else: return x
        return dict(map(ascii_encode, pair) for pair in data.items())

    with open(json_path) as _f:
        systs = json.load(_f, object_hook=ascii_encode_dict)

    if sub_folder is not None:
        systs = systs[sub_folder]

    # Load all systematics in easier order
    # i.e. newSysts[systematic] = [ (cat, proc, (down, up)), ... ]
    newSysts = {}
    for cat in systs.keys():
        for sys in systs[cat].keys():
            sys_dict = newSysts.setdefault(sys, [])
            proc_up = set(systs[cat][sys]["Up"].keys())
            proc_down = set(systs[cat][sys]["Down"].keys())
            assert(proc_up == proc_down)
            for proc in proc_up:
                value_up = systs[cat][sys]["Up"][proc]
                value_down = systs[cat][sys]["Down"][proc]
                sys_dict.append( (cat, proc, (value_down, value_up)) )

    # Re-create systematics for those we want factorised among ttbar components
    # expects definitions.FactorisedTheory object
    if factTheory is not None:
        for name, syst in newSysts.items():
            if name in factTheory.factorised_uncertainties:
                newSysts[name] = []
                for entry in syst:
                    newSysts.setdefault(factTheory.getNewNuisance(name, entry[1]), []).append(entry)
                # So that the returned list of systematics makes sense:
                if len(newSysts[name]) == 0:
                    newSysts.pop(name)

    # print(newSysts)

    for name, syst in newSysts.items():
        cm = ch.SystMap('bin', 'process')
        for entry in syst:
            cm = cm([entry[0]], [entry[1]], entry[2])
        cb.cp().AddSyst(cb, name, 'lnN', cm)

    return newSysts.keys()
コード例 #3
0
ファイル: setup-TauTP.py プロジェクト: senka/HTT_20162017
                    help='Directory where the output cards should be written')
args = parser.parse_args()

cb = ch.CombineHarvester()

procs = {'sig': ['ZTT'], 'bkg': ['ZL', 'ZJ', 'W', 'QCD', 'TT', 'VV']}

cats = [(0, 'fail'), (1, 'pass')]

cb.AddObservations(['*'], ['tauTP'], ["13TeV"], ['mt'], cats)
cb.AddProcesses(['*'], ['tauTP'], ["13TeV"], ['mt'], procs['bkg'], cats, False)
cb.AddProcesses(['*'], ['tauTP'], ["13TeV"], ['mt'], procs['sig'], cats, True)

print '>> Adding systematic uncertainties...'
# cb.SetFlag('filters-use-regex', True)
cb.cp().AddSyst(cb, 'CMS_scale_t_$PROCESS_$BIN', 'shape', ch.SystMap()(1.00))
cb.syst_name(['blah'])

cb.cp().process(['QCD', 'TT', 'VV']).AddSyst(cb, 'norm_$PROCESS_$BIN', 'lnN',
                                             ch.SystMap()(1.10))

cb.cp().process(['ZL', 'ZJ']).AddSyst(cb, 'norm_$PROCESS_$BIN', 'lnN',
                                      ch.SystMap()(1.20))

cb.cp().process(['ZTT', 'ZL', 'ZJ', 'W', 'TT',
                 'VV']).AddSyst(cb, 'CMS_eff_m', 'lnN',
                                ch.SystMap()(1.02))

cb.cp().process(['ZTT', 'ZL', 'ZJ', 'W', 'TT',
                 'VV']).AddSyst(cb, 'lumi_13TeV_2016', 'lnN',
                                ch.SystMap()(1.062))
コード例 #4
0
ファイル: zp.py プロジェクト: amkalsi/hlim
def add_systematics(cb):
    print '>> Adding systematic uncertainties...'

    signal = cb.cp().signals().process_set()
    mc_nw = ['ZTT', 'TT', 'VV']
    mc = mc_nw + ['W']
    dd = ['QCD']

    # common
    lumiName = "CMS_lumi_%s" % era
    lumiVal = 1.027
    cb.cp().process(signal + mc).channel(['tt', 'em'
                                          ]).AddSyst(cb, lumiName, "lnN",
                                                     ch.SystMap()(lumiVal))
    cb.cp().process(signal + mc_nw).channel(['mt', 'et']).AddSyst(
        cb, lumiName, "lnN",
        ch.SystMap()(lumiVal))
    cb.cp().process(["TT"]).AddSyst(cb, "CMS_zp_TT_xs_%s" % era, "lnN",
                                    ch.SystMap()(1.08))
    cb.cp().process(["VV"]).AddSyst(cb, "CMS_zp_VV_xs_%s" % era, "lnN",
                                    ch.SystMap()(1.15))

    # em/et (norm)
    cb.cp().process(["ZTT"]).channel(['em',
                                      'et']).AddSyst(cb,
                                                     "CMS_zp_ZTT_xs_%s" % era,
                                                     "lnN",
                                                     ch.SystMap()(1.10))

    # em/et (shape)
    cb.cp().process(signal + mc + dd).channel(['em']).AddSyst(
        cb, "CMS_zp_scale_j_%s" % era, "shape",
        ch.SystMap()(1.0))
    cb.cp().process(signal + mc_nw).channel(['et']).AddSyst(
        cb, "CMS_zp_scale_j_%s" % era, "shape",
        ch.SystMap()(1.0))  # no ddW variations
    cb.cp().process(signal + mc + dd).channel(['em']).AddSyst(
        cb, "CMS_zp_scale_btag_%s" % era, "shape",
        ch.SystMap()(1.0))
    cb.cp().process(signal + mc_nw).channel(['et']).AddSyst(
        cb, "CMS_zp_scale_btag_%s" % era, "shape",
        ch.SystMap()(1.0))  # no ddW variations
    cb.cp().process(signal).channel(['em', 'et']).AddSyst(
        cb, "CMS_zp_pdf_%s" % era, "shape",
        ch.SystMap()(0.3))  # the template represent 3.x sigma variations

    # em (norm)
    cb.cp().process(["QCD"]).channel(['em'
                                      ]).AddSyst(cb,
                                                 "CMS_zp_em_QCD_LT_%s" % era,
                                                 "lnN",
                                                 ch.SystMap()(1.37))
    cb.cp().process(["W"]).channel(['em']).AddSyst(cb,
                                                   "CMS_zp_em_W_LT_%s" % era,
                                                   "lnN",
                                                   ch.SystMap()(1.41))

    # em (shape)
    cb.cp().process(["TT"]).channel(['em']).AddSyst(cb,
                                                    "CMS_zp_topPt_%s" % era,
                                                    "shape",
                                                    ch.SystMap()(1.0))

    # et (norm)
    # cb.cp().process(["QCD"]).channel(['et']).AddSyst(cb, "CMS_zp_et_QCD_LT_%s" % era, "lnN", ch.SystMap()(1.164))  # May 5/6
    cb.cp().process(["QCD"]).channel(['et']).AddSyst(
        cb, "CMS_zp_et_QCD_LT_%s" % era, "lnN",
        ch.SystMap()(1.18))  # May 18 onward
    cb.cp().process(["W"]).channel(['et']).AddSyst(cb,
                                                   "CMS_zp_et_W_LT_%s" % era,
                                                   "lnN",
                                                   ch.SystMap()(1.096))

    # et (shape)
    # cb.cp().process(mc + dd).channel(['et']).AddSyst(cb, "CMS_zp_scale_W_%s" % era, "shape", ch.SystMap()(1.0))          # only for MC-W
    # cb.cp().process(signal + mc + dd).channel(['et']).AddSyst(cb, "CMS_zp_scale_t_%s" % era, "shape", ch.SystMap()(1.0))
    # cb.cp().process(signal + mc + dd).channel(['et']).AddSyst(cb, "CMS_zp_id_t_%s" % era, "shape", ch.SystMap()(1.0))
    cb.cp().process(signal + mc_nw).channel(['et']).AddSyst(
        cb, "CMS_zp_scale_t_%s" % era, "shape",
        ch.SystMap()(1.0))  # no ddW variations
    cb.cp().process(signal + mc_nw).channel(['et']).AddSyst(
        cb, "CMS_zp_id_t_%s" % era, "shape",
        ch.SystMap()(1.0))  # no ddW variations

    # BSM3G codes
    #
    # (0/mt  1/et 2/tt 3/em)
    # (0/Zp  1/W  2/Z  3/TT  4/VV  5/QCD  6/H)
    #
    # e.g. Trig10 is intended to apply to et/Zp
    #
    #
    # NOTES
    # - bbb shapes supersede STMC
    # - bID handled by shape above (losing correlation with mutau)
    # - TES handled by shape above
    # - mt: TES,JES included for backgrounds within bbb

    # et
    cb.cp().process(signal + mc_nw).channel(['et']).AddSyst(
        cb, "Trig10", "lnN",
        ch.SystMap()(1.01))

    cb.cp().process(signal + ["ZTT"]).channel(['et']).AddSyst(
        cb, "ElID10", "lnN",
        ch.SystMap()(1.06))
    # cb.cp().process(["W"]           ).channel(['et']).AddSyst(cb, "ElID11",  "lnN", ch.SystMap()(1.01))
    cb.cp().process(["TT",
                     "VV"]).channel(['et']).AddSyst(cb, "ElID13", "lnN",
                                                    ch.SystMap()(1.06))
    cb.cp().process(signal + mc_nw).channel(['et']).AddSyst(
        cb, "EES10", "lnN",
        ch.SystMap()(1.01))

    cb.cp().process(signal + ["ZTT"]).channel(['et']).AddSyst(
        cb, "TaID00", "lnN",
        ch.SystMap()(1.06))  # mt
    # cb.cp().process(["W"]           ).channel(['et']).AddSyst(cb, "TaID11",  "lnN", ch.SystMap()(1.06))
    cb.cp().process(["TT",
                     "VV"]).channel(['et']).AddSyst(cb, "TaID03", "lnN",
                                                    ch.SystMap()(1.06))  # mt

    # em
    cb.cp().process(signal + mc).channel(['em']).AddSyst(
        cb, "Trig10", "lnN",
        ch.SystMap()(1.01))  # et (SingleEle)

    cb.cp().process(signal + ["ZTT"]).channel(['em']).AddSyst(
        cb, "ElID10", "lnN",
        ch.SystMap()(1.06))  # et
    cb.cp().process(["W"]).channel(['em']).AddSyst(cb, "ElID11", "lnN",
                                                   ch.SystMap()(1.06))  # et
    cb.cp().process(["TT",
                     "VV"]).channel(['em']).AddSyst(cb, "ElID13", "lnN",
                                                    ch.SystMap()(1.06))  # et
    cb.cp().process(signal + mc).channel(['em'
                                          ]).AddSyst(cb, "EES10", "lnN",
                                                     ch.SystMap()(1.01))  # et

    cb.cp().process(signal + mc).channel(['em'
                                          ]).AddSyst(cb, "MuID00", "lnN",
                                                     ch.SystMap()(1.07))  # mt
    cb.cp().process(signal + mc).channel(['em'
                                          ]).AddSyst(cb, "MMS00", "lnN",
                                                     ch.SystMap()(1.01))  # mt

    # mt
    cb.cp().process(signal + mc_nw).channel(['mt']).AddSyst(
        cb, "Trig00", "lnN",
        ch.SystMap()(1.01))

    cb.cp().process(signal + ["ZTT"]).channel(['mt']).AddSyst(
        cb, "TaID00", "lnN",
        ch.SystMap()(1.06))
    cb.cp().process(["TT",
                     "VV"]).channel(['mt']).AddSyst(cb, "TaID03", "lnN",
                                                    ch.SystMap()(1.06))

    cb.cp().process(signal + ["ZTT"]).channel(['mt']).AddSyst(
        cb, "bID00", "lnN",
        ch.SystMap()(1.03))
    cb.cp().process(["TT"]).channel(['mt']).AddSyst(cb, "bID03", "lnN",
                                                    ch.SystMap()(1.12))
    cb.cp().process(["VV"]).channel(['mt']).AddSyst(cb, "bID04", "lnN",
                                                    ch.SystMap()(1.03))

    cb.cp().process(signal + mc_nw).channel(['mt']).AddSyst(
        cb, "MuID00", "lnN",
        ch.SystMap()(1.07))
    cb.cp().process(signal + mc_nw).channel(['mt']).AddSyst(
        cb, "MMS00", "lnN",
        ch.SystMap()(1.01))

    cb.cp().process(signal).channel(['mt']).AddSyst(cb, "TES00", "lnN",
                                                    ch.SystMap()(1.03))
    # cb.cp().process(["ZTT"]         ).channel(['mt']).AddSyst(cb, "TES02",   "lnN", ch.SystMap()(1.07)) # bbb
    # cb.cp().process(["TT", "VV"]    ).channel(['mt']).AddSyst(cb, "TES03",   "lnN", ch.SystMap()(1.09)) # bbb

    cb.cp().process(signal).channel(['mt']).AddSyst(cb, "JES00", "lnN",
                                                    ch.SystMap()(1.02))

    cb.cp().process(["W"]).channel(['mt']).AddSyst(cb, "Close01", "lnN",
                                                   ch.SystMap()(1.08))
    cb.cp().process(["ZTT"]).channel(['mt']).AddSyst(cb, "Close02", "lnN",
                                                     ch.SystMap()(1.07))
    cb.cp().process(["QCD"]).channel(['mt']).AddSyst(cb, "Close05", "lnN",
                                                     ch.SystMap()(1.68))

    # tt
    cb.cp().process(signal + mc).channel(['tt'
                                          ]).AddSyst(cb, "Trig20", "lnN",
                                                     ch.SystMap()(1.10))

    cb.cp().process(signal + ["ZTT"]).channel(['tt']).AddSyst(
        cb, "TaID00", "lnN",
        ch.SystMap()(1.12))  # mt
    cb.cp().process(["W"]).channel(['tt']).AddSyst(cb, "TaID11", "lnN",
                                                   ch.SystMap()(1.30))  # et
    cb.cp().process(["TT",
                     "VV"]).channel(['tt']).AddSyst(cb, "TaID03", "lnN",
                                                    ch.SystMap()(1.12))  # mt

    cb.cp().process(signal + ["ZTT"]).channel(['tt']).AddSyst(
        cb, "bID20", "lnN",
        ch.SystMap()(1.03))
    cb.cp().process(["W"]).channel(['tt']).AddSyst(cb, "bID21", "lnN",
                                                   ch.SystMap()(1.10))
    cb.cp().process(["TT"]).channel(['tt']).AddSyst(cb, "bID23", "lnN",
                                                    ch.SystMap()(1.10))
    cb.cp().process(["VV"]).channel(['tt']).AddSyst(cb, "bID24", "lnN",
                                                    ch.SystMap()(1.03))

    cb.cp().process(signal).channel(['tt']).AddSyst(cb, "TES20", "lnN",
                                                    ch.SystMap()(1.03))
    cb.cp().process(["W"]).channel(['tt']).AddSyst(cb, "TES21", "lnN",
                                                   ch.SystMap()(1.11))
    cb.cp().process(["ZTT"]).channel(['tt']).AddSyst(cb, "TES22", "lnN",
                                                     ch.SystMap()(1.11))
    cb.cp().process(["TT"]).channel(['tt']).AddSyst(cb, "TES23", "lnN",
                                                    ch.SystMap()(1.11))
    cb.cp().process(["VV"]).channel(['tt']).AddSyst(cb, "TES24", "lnN",
                                                    ch.SystMap()(1.08))

    cb.cp().process(signal).channel(['tt']).AddSyst(cb, "JES20", "lnN",
                                                    ch.SystMap()(1.02))
    cb.cp().process(["W"]).channel(['tt']).AddSyst(cb, "JES21", "lnN",
                                                   ch.SystMap()(1.12))
    cb.cp().process(["ZTT"]).channel(['tt']).AddSyst(cb, "JES22", "lnN",
                                                     ch.SystMap()(1.08))
    cb.cp().process(["TT"]).channel(['tt']).AddSyst(cb, "JES23", "lnN",
                                                    ch.SystMap()(1.12))
    cb.cp().process(["VV"]).channel(['tt']).AddSyst(cb, "JES24", "lnN",
                                                    ch.SystMap()(1.08))

    cb.cp().process(["W"]).channel(['tt']).AddSyst(cb, "Close21", "lnN",
                                                   ch.SystMap()(1.05))
    cb.cp().process(["ZTT"]).channel(['tt']).AddSyst(cb, "Close22", "lnN",
                                                     ch.SystMap()(1.19))
    cb.cp().process(["QCD"]).channel(['tt']).AddSyst(cb, "Close25", "lnN",
                                                     ch.SystMap()(1.226))
コード例 #5
0
	def __init__(self, higgs_masses=["125"], ttbarFit=False, mmFit=False, year="", noJECuncSplit=False, cb=None, signal_processes=None):
		super(SMHttDatacards, self).__init__(cb)

		if cb is None:
			if signal_processes is None:
				signal_processes = ["ggH", "qqH", "WH", "ZH"]

			background_processes_mt = ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"]
			background_processes_et = ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"]
			background_processes_tt = ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VVT", "VVJ", "W", "QCD"]
			background_processes_em = ["ZTT", "ZLL", "EWKZ", "TT", "VV", "hww_gg125", "hww_qq125", "W", "QCD"]
			background_processes_mm = ["ZLL", "TT", "VV", "W"]
			background_processes_ttbar = ["ZTT", "ZLL", "EWKZ", "TT", "VV", "W", "QCD"]

			all_mc_bkgs = ["ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "TTJJ", "VV", "VVT", "VVJ", "W", "hww_gg125", "hww_qq125"]
			all_mc_bkgs_no_W = ["ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "TTJJ", "VV", "VVT", "VVJ", "hww_gg125", "hww_qq125"]
			all_mc_bkgs_no_TTJ = ["ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "VV", "VVT", "VVJ", "W", "hww_gg125", "hww_qq125"]
			
			# Lists of categories
			CP_categories = ["Vbf3D", "Vbf3D_CP", "Vbf3D_CP_jdeta", "Vbf3D_mela_GGH_DCPPlus", "Vbf3D_mela_GGH_DCPMinus", "Vbf4D_mela_GGH", "dijet_lowMjj", "dijet_lowM", "dijet_boosted", "dijet_highM"]
			sm_categories = ["ZeroJet2D", "Boosted2D", "Vbf2D"]
			##Generate instance of systematic libary, in which the relevant information about the systematics are safed

			systematics_list = SystLib.SystematicLibary()	

			# list of JEC uncertainties
			jecUncertNames = [
				"AbsoluteFlavMap",
				"AbsoluteMPFBias",
				"AbsoluteScale",
				"AbsoluteStat",
				"FlavorQCD",
				"Fragmentation",
				"PileUpDataMC",
				"PileUpPtBB",
				"PileUpPtEC1",
				"PileUpPtEC2",
				"PileUpPtHF",
				"PileUpPtRef",
				"RelativeBal",
				"RelativeFSR",
				"RelativeJEREC1",
				"RelativeJEREC2",
				"RelativeJERHF",
				"RelativePtBB",
				"RelativePtEC1",
				"RelativePtEC2",
				"RelativePtHF",
				"RelativeStatEC",
				"RelativeStatFSR",
				"RelativeStatHF",
				"SinglePionECAL",
				"SinglePionHCAL",
				"TimePtEta"
			]

			# ======================================================================
			# MT channel
			self.add_processes(
					channel="mt",
					categories=Categories.CategoriesDict().getCategories(["mt"])["mt"],
					bkg_processes=background_processes_mt,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_syst_args)
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.muon_efficiency2016_syst_args)
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_syst_args)
			else:
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)
				self.cb.cp().channel(["mt"]).process(signal_processes+["ZTT", "TTT", "VVT"]).AddSyst(self.cb, *systematics_list.tau_efficiency_syst_args)

			# mu->tau fake ES
			self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.zl_shape_1prong_syst_args)
			self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.zl_shape_1prong1pizero_syst_args)

			# mu->tau fake rate
			if year == "2016":
				self.cb.cp().channel(["mt"]).process(["ZL"]).bin(["mt_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.mFakeTau_1prong_syst_args)
				self.cb.cp().channel(["mt"]).process(["ZL"]).bin(["mt_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.mFakeTau_1prong1pizero_syst_args)
			else:
				self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.muFakeTau_syst_args)

			# decay mode reweighting
			self.cb.cp().channel(["mt"]).process(["ZTT"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_1prong_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["mt"]).process(["ZTT"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_1prong1pizero_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["mt"]).process(["ZTT"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_3prong_13TeV", "shape", ch.SystMap()(1.0))

			# ======================================================================
			# ET channel
			self.add_processes(
					channel="et",
					categories=Categories.CategoriesDict().getCategories(["et"])["et"],
					bkg_processes=background_processes_et,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_syst_args)
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.electron_efficiency2016_syst_args)
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_syst_args)
			else:
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.electron_efficiency_syst_args)
				self.cb.cp().channel(["et"]).process(signal_processes+["ZTT", "TTT", "VVT"]).AddSyst(self.cb, *systematics_list.tau_efficiency_syst_args)

			# e->tau fake ES
			self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.zl_shape_1prong_syst_args)
			self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.zl_shape_1prong1pizero_syst_args)

			# e->tau fake rate
			if year == "2016":
				self.cb.cp().channel(["et"]).process(["ZL"]).bin(["et_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.eFakeTau_1prong_syst_args)
				self.cb.cp().channel(["et"]).process(["ZL"]).bin(["et_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.eFakeTau_1prong1pizero_syst_args)
			else:
				self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.eFakeTau_tight_syst_args)

			# decay mode reweighting
			self.cb.cp().channel(["et"]).process(["ZTT"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_1prong_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et"]).process(["ZTT"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_1prong1pizero_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et"]).process(["ZTT"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_3prong_13TeV", "shape", ch.SystMap()(1.0))

			# ======================================================================
			# EM channel
			self.add_processes(
					channel="em",
					categories=Categories.CategoriesDict().getCategories(["em"])["em"],
					bkg_processes=background_processes_em,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_em_syst_args)
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.electron_efficiency2016_syst_args)
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency2016_syst_args)
			else:
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.electron_efficiency_syst_args)
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)

			# B-Tag
			if year == "2016":
				self.cb.cp().channel(["em"]).process(["TT", "VV"]).bin(["em_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.btag_efficiency2016_syst_args)

			# electron ES
			self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs+["QCD"]).AddSyst(self.cb, *systematics_list.ele_es_syst_args)

			# ======================================================================
			# TT channel
			self.add_processes(
					channel="tt",
					categories=Categories.CategoriesDict().getCategories(["tt"])["tt"],
					bkg_processes=background_processes_tt,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)


			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_syst_args)
				self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_tt_syst_args)
			else:
				self.cb.cp().channel(["tt"]).process(signal_processes+["ZTT", "TTT", "VVT"]).AddSyst(self.cb, *systematics_list.tau_efficiency_syst_args)

			# ======================================================================
			# MM channel
			self.add_processes(
					channel="mm",
					categories=Categories.CategoriesDict().getCategories(["mm"])["mm"],
					bkg_processes=background_processes_mm,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["mm"]).process(all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency2016_syst_args)
			else:
				self.cb.cp().channel(["mm"]).process(all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)

			# ======================================================================
			# ttbar "channel" to extract normalization of ttbar process
			self.add_processes(
					channel="ttbar",
					categories=Categories.CategoriesDict().getCategories(["ttbar"])["ttbar"],
					bkg_processes=background_processes_ttbar,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			if year == "2016":
				self.cb.cp().channel(["ttbar"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_em_syst_args)
				self.cb.cp().channel(["ttbar"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.electron_efficiency2016_syst_args)
				self.cb.cp().channel(["ttbar"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency2016_syst_args)

			self.cb.cp().channel(["ttbar"]).bin(["ttbar_TTbarCR"]).process(all_mc_bkgs).AddSyst(self.cb, "CMS_htt_scale_met_13TeV", "lnN", ch.SystMap()(1.01))

			# ======================================================================
			# All channels

			# ======================================================================
			# lumi
			if year == "2016":
				self.cb.cp().process(signal_processes+["VV", "VVT", "VVJ", "hww_gg125", "hww_qq125"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
				if not ttbarFit:
					self.cb.cp().process(["TT", "TTT", "TTJJ"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
				if mmFit:
					self.cb.cp().channel(["mt", "et", "tt", "em", "ttbar"]).process(["ZL", "ZJ", "ZLL"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
					self.cb.cp().channel(["mt", "et"]).process(["ZTT"]).bin([channel + "_" + category + "_" + cr for channel in ["mt", "et"] for category in ["ZeroJet2D", "Boosted2D"] for cr in ["WJCR", "QCDCR"]]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
					self.cb.cp().channel(["tt"]).process(["ZTT"]).bin(["tt_" + category + "_QCDCR" for category in sm_categories]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
					self.cb.cp().channel(["ttbar"]).process(["ZTT"]).bin(["ttbar_TTbarCR"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
					self.cb.cp().channel(["mm"]).process(["ZTT"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
				self.cb.cp().process(["W"]).channel(["em", "tt", "mm", "ttbar"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
			else:
				self.cb.cp().process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.lumi_syst_args)
				self.cb.cp().process(["W"]).channel(["em", "tt", "mm"]).AddSyst(self.cb, *systematics_list.lumi_syst_args)

			# ======================================================================
			# cross section
			if mmFit:
				self.cb.cp().channel(["mt", "et", "tt", "em", "ttbar"]).process(["ZL", "ZJ", "ZLL"]).AddSyst(self.cb, *systematics_list.ztt_cross_section_syst_args)
				# add uncertainty for ZTT only in control regions
				self.cb.cp().channel(["mt", "et"]).process(["ZTT"]).bin([channel + "_" + category + "_" + cr for channel in ["mt", "et"] for category in ["ZeroJet2D", "Boosted2D"] for cr in ["WJCR", "QCDCR"]]).AddSyst(self.cb, *systematics_list.ztt_cross_section_syst_args)
				self.cb.cp().channel(["tt"]).process(["ZTT"]).bin(["tt_" + category + "_QCDCR" for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]]).AddSyst(self.cb, *systematics_list.ztt_cross_section_syst_args)
				self.cb.cp().channel(["ttbar"]).process(["ZTT"]).bin(["ttbar_TTbarCR"]).AddSyst(self.cb, *systematics_list.ztt_cross_section_syst_args)
			else:
				self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin(["em_ZeroJet2D"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_em_13TeV", "lnN", ch.SystMap()(1.07))
				self.cb.cp().channel(["tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["tt_ZeroJet2D", "tt_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_tt_13TeV", "lnN", ch.SystMap()(1.07))
				self.cb.cp().channel(["mt", "et"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["mt_ZeroJet2D", "mt_ZeroJet2D_WJCR", "mt_ZeroJet2D_QCDCR", "et_ZeroJet2D", "et_ZeroJet2D_WJCR", "et_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_lt_13TeV", "lnN", ch.SystMap()(1.07))

				self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin(["em_Boosted2D"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_em_13TeV", "lnN", ch.SystMap()(1.07))
				self.cb.cp().channel(["tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["tt_Boosted2D", "tt_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_tt_13TeV", "lnN", ch.SystMap()(1.07))
				self.cb.cp().channel(["mt", "et"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["mt_Boosted2D", "mt_Boosted2D_WJCR", "mt_Boosted2D_QCDCR", "et_Boosted2D", "et_Boosted2D_WJCR", "et_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_lt_13TeV", "lnN", ch.SystMap()(1.07))

				self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin(["em_Vbf2D"]+["em_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_em_13TeV", "lnN", ch.SystMap()(1.15))
				self.cb.cp().channel(["tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["tt_Vbf2D", "tt_Vbf2D_QCDCR"]+["tt_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_tt_13TeV", "lnN", ch.SystMap()(1.15))
				self.cb.cp().channel(["mt", "et"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["et_Vbf2D"]+["et_"+category for category in CP_categories]+["mt_Vbf2D"]+["mt_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_lt_13TeV", "lnN", ch.SystMap()(1.10))

				self.cb.cp().channel(["mt", "et", "tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin([channel + "_Vbf2D" for channel in ["mt", "et", "tt"]]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["tt_Vbf2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).bin(["em_Vbf2D"]+["em_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV", "shape", ch.SystMap()(1.0))
			if not ttbarFit:
				self.cb.cp().process(["TT", "TTT", "TTJJ"]).channel(["mt", "et", "em", "tt"]).AddSyst(self.cb, *systematics_list.ttj_cross_section_syst_args)
			if year == "2016":
				self.cb.cp().process(["VV", "VVT", "VVJ"]).AddSyst(self.cb, *systematics_list.vv_cross_section2016_syst_args)
			else:
				self.cb.cp().process(["VV", "VVT", "VVJ"]).AddSyst(self.cb, *systematics_list.vv_cross_section_syst_args)
			self.cb.cp().process(["W"]).channel(["em"]).AddSyst(self.cb, *systematics_list.htt_jetFakeLep_syst_args)
			self.cb.cp().process(["W"]).channel(["tt", "mm"]).AddSyst(self.cb, *systematics_list.wj_cross_section_syst_args)

			# ======================================================================
			# tau id efficiency
			if year == "2016":
				self.cb.cp().channel(["mt", "et"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_corr_syst_args)
				self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_tt_corr_syst_args)
			else:
				self.cb.cp().channel(["mt", "et", "tt"]).process(signal_processes+["ZTT", "TTT", "VVT"]).AddSyst(self.cb, *systematics_list.tau_efficiency_corr_syst_args)

			# ======================================================================
			# energy scales

			# tau ES
			self.cb.cp().channel(["mt", "et", "tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.scale_t_1prong_syst_args)
			self.cb.cp().channel(["mt", "et", "tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.scale_t_3prong_syst_args)
			self.cb.cp().channel(["mt", "et", "tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.scale_t_1prong1pizero_syst_args)

			# jet ES
			# TODO: use mix of lnN/shape systematics as done in official analysis?
			if noJECuncSplit:
				self.cb.cp().process(signal_processes+all_mc_bkgs+["QCD"]).bin([channel+"_"+category for channel in ["et", "mt", "tt", "em"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs).bin(["mt_ZeroJet2D_WJCR", "mt_Boosted2D_WJCR", "mt_ZeroJet2D_QCDCR", "mt_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs).bin(["et_ZeroJet2D_WJCR", "et_Boosted2D_WJCR", "et_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_TTJ).bin(["et_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).bin(["tt_ZeroJet2D_QCDCR", "tt_Boosted2D_QCDCR", "tt_Vbf2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
			else:
				for jecUncert in jecUncertNames:
					self.cb.cp().process(signal_processes+all_mc_bkgs+["QCD"]).bin([channel+"_"+category for channel in ["et", "mt", "tt", "em"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))
					self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs).bin(["mt_ZeroJet2D_WJCR", "mt_Boosted2D_WJCR", "mt_ZeroJet2D_QCDCR", "mt_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))
					self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs).bin(["et_ZeroJet2D_WJCR", "et_Boosted2D_WJCR", "et_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))
					self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_TTJ).bin(["et_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))
					self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).bin(["tt_ZeroJet2D_QCDCR", "tt_Boosted2D_QCDCR", "tt_Vbf2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))

			# jet->tau fake ES
			if year == "2016":
				self.cb.cp().channel(["et", "mt", "tt"]).process(["ZJ", "TTJJ", "VVJ"]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["et", "mt", "tt"]).process(["W"]).bin([channel+"_"+category for channel in ["et", "mt", "tt"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+"_"+category for channel in ["et", "mt"] for category in ["ZeroJet2D_QCDCR", "Boosted2D_QCDCR"]]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape", ch.SystMap()(1.0))
			else:
				self.cb.cp().channel(["et", "mt", "tt"]).process(["ZJ", "W", "TTJJ", "VVJ"]).AddSyst(self.cb, *systematics_list.jetFakeTau_syst_args)

			# MET ES
			self.cb.cp().channel(["et", "mt", "tt", "em"]).process(signal_processes+all_mc_bkgs).bin([channel+"_"+category for channel in ["et", "mt", "tt", "em"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_met_clustered_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt", "tt", "em"]).process(signal_processes+all_mc_bkgs).bin([channel+"_"+category for channel in ["et", "mt", "tt", "em"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_met_unclustered_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(all_mc_bkgs).bin([channel+"_"+category for channel in ["et", "mt"] for category in ["ZeroJet2D_WJCR", "ZeroJet2D_QCDCR", "Boosted2D_WJCR", "Boosted2D_QCDCR"]]).AddSyst(self.cb, "CMS_scale_met_clustered_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(all_mc_bkgs).bin([channel+"_"+category for channel in ["et", "mt"] for category in ["ZeroJet2D_WJCR", "ZeroJet2D_QCDCR", "Boosted2D_WJCR", "Boosted2D_QCDCR"]]).AddSyst(self.cb, "CMS_scale_met_unclustered_13TeV", "shape", ch.SystMap()(1.0))

			# ======================================================================
			# W+jets and QCD estimation uncertainties

			# QCD normalization
			self.cb.cp().channel(["em"]).process(["QCD"]).bin(["em_ZeroJet2D"]).AddSyst(self.cb, *systematics_list.htt_QCD_0jet_syst_args)
			self.cb.cp().channel(["em"]).process(["QCD"]).bin(["em_Boosted2D"]).AddSyst(self.cb, *systematics_list.htt_QCD_boosted_syst_args)
			self.cb.cp().channel(["em"]).process(["QCD"]).bin(["em_Vbf2D"]+["em_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_QCD_VBF_em_13TeV", "lnN", ch.SystMap()(1.20))

			self.cb.cp().channel(["tt"]).process(["QCD"]).bin(["tt_ZeroJet2D"]).AddSyst(self.cb, "CMS_htt_QCD_0jet_tt_13TeV", "lnN", ch.SystMap()(1.027))
			self.cb.cp().channel(["tt"]).process(["QCD"]).bin(["tt_Boosted2D"]).AddSyst(self.cb, "CMS_htt_QCD_boosted_tt_13TeV", "lnN", ch.SystMap()(1.027))
			self.cb.cp().channel(["tt"]).process(["QCD"]).bin(["tt_Vbf2D"]+["tt_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_QCD_VBF_tt_13TeV", "lnN", ch.SystMap()(1.15))

			self.cb.cp().channel(["mt"]).process(["QCD"]).bin(["mt_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.QCD_Extrap_Iso_nonIso_syst_args)
			self.cb.cp().channel(["et"]).process(["QCD"]).bin(["et_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.QCD_Extrap_Iso_nonIso_syst_args)

			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_ZeroJet2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WSFUncert_0jet_syst_args)			
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_Boosted2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WSFUncert_boosted_syst_args)
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_Vbf2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WSFUncert_Vbf_syst_args)
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_dijet_boosted" for channel in ["et", "mt"]]).AddSyst(self.cb, "WSFUncert_$CHANNEL_dijet_boosted_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_dijet_lowM" for channel in ["et", "mt"]]).AddSyst(self.cb, "WSFUncert_$CHANNEL_dijet_lowM_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_dijet_highM" for channel in ["et", "mt"]]).AddSyst(self.cb, "WSFUncert_$CHANNEL_dijet_highM_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_dijet_lowMjj" for channel in ["et", "mt"]]).AddSyst(self.cb, "WSFUncert_$CHANNEL_dijet_lowMjj_13TeV", "shape", ch.SystMap()(1.0))
			# W+jets high->low mt extrapolation uncertainty
			self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+"_ZeroJet2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WHighMTtoLowMT_0jet_syst_args)
			self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+"_Boosted2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WHighMTtoLowMT_boosted_syst_args)
			self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+"_Vbf2D" for channel in ["et", "mt"]]).AddSyst(self.cb, "WHighMTtoLowMT_vbf_13TeV", "lnN", ch.SystMap()(1.10))
			self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+category for category in CP_categories for channel in ["et", "mt"]]).AddSyst(self.cb, "WHighMTtoLowMT_vbf_13TeV", "lnN", ch.SystMap()(1.10))

			# ======================================================================
			# pt reweighting uncertainties

			# ttbar shape
			self.cb.cp().channel(["et", "mt", "em", "tt"]).process(["TTT", "TTJJ"]).AddSyst(self.cb, *systematics_list.ttj_syst_args)
			self.cb.cp().channel(["em"]).process(["TT"]).AddSyst(self.cb, *systematics_list.ttj_syst_args)

			# dy shape
			self.cb.cp().channel(["et", "mt", "tt"]).process(["ZTT", "ZL", "ZJ"]).AddSyst(self.cb, *systematics_list.dy_shape_syst_args)
			self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).AddSyst(self.cb, *systematics_list.dy_shape_syst_args)

			# ======================================================================
			# Theory uncertainties
			self.cb.cp().channel(["mt", "et", "tt", "em"]).process(["ggH", "ggHsm", "ggHps", "ggHmm"]).bin([channel+"_"+category for channel in ["et", "mt", "em", "tt"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_gg_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().process(["qqH", "qqHsm", "qqHps", "qqHmm"]).AddSyst(self.cb, *systematics_list.htt_qcd_scale_qqh_syst_args)
			self.cb.cp().process(["ggH", "ggHsm", "ggHps", "ggHmm", "qqH", "qqHsm", "qqHps", "qqHmm"]).AddSyst(self.cb, *systematics_list.htt_pdf_scale_smhtt_syst_args)
			self.cb.cp().process(["ggH", "ggHsm", "ggHps", "ggHmm", "qqH", "qqHsm", "qqHps", "qqHmm"]).AddSyst(self.cb, *systematics_list.htt_ueps_smhtt_syst_args)

			# Uncertainty on BR of HTT @ 125 GeV
			self.cb.cp().signals().AddSyst(self.cb, "BR_htt_THU", "lnN", ch.SystMap()(1.017))
			self.cb.cp().signals().AddSyst(self.cb, "BR_htt_PU_mq", "lnN", ch.SystMap()(1.0099))
			self.cb.cp().signals().AddSyst(self.cb, "BR_htt_PU_alphas", "lnN", ch.SystMap()(1.0062))

			# Uncertainty on BR of HWW @ 125 GeV
			self.cb.cp().process(["hww_gg125", "hww_qq125"]).AddSyst(self.cb, "BR_hww_THU", "lnN", ch.SystMap()(1.0099))
			self.cb.cp().process(["hww_gg125", "hww_qq125"]).AddSyst(self.cb, "BR_hww_PU_mq", "lnN", ch.SystMap()(1.0099))
			self.cb.cp().process(["hww_gg125", "hww_qq125"]).AddSyst(self.cb, "BR_hww_PU_alphas", "lnN", ch.SystMap()(1.0066))

			self.cb.cp().process(["ggH", "ggHsm", "ggHps", "ggHmm", "hww_gg125"]).AddSyst(self.cb, "QCDScale_ggH", "lnN", ch.SystMap()(1.039))
			self.cb.cp().process(["qqH", "qqHsm", "qqHps", "qqHmm", "hww_qq125"]).AddSyst(self.cb, "QCDScale_qqH", "lnN", ch.SystMap()(1.004))
			self.cb.cp().process(["WH"]).AddSyst(self.cb, "QCDScale_VH", "lnN", ch.SystMap()(1.007))
			self.cb.cp().process(["ZH"]).AddSyst(self.cb, "QCDScale_VH", "lnN", ch.SystMap()(1.038))

			self.cb.cp().process(["ggH", "ggHsm", "ggHps", "ggHmm", "hww_gg125"]).AddSyst(self.cb, "pdf_Higgs_gg", "lnN", ch.SystMap()(1.032))
			self.cb.cp().process(["qqH", "qqHsm", "qqHps", "qqHmm", "hww_qq125"]).AddSyst(self.cb, "pdf_Higgs_qq", "lnN", ch.SystMap()(1.021))
			self.cb.cp().process(["WH"]).AddSyst(self.cb, "pdf_Higgs_VH", "lnN", ch.SystMap()(1.019))
			self.cb.cp().process(["ZH"]).AddSyst(self.cb, "pdf_Higgs_VH", "lnN", ch.SystMap()(1.016))

			# ======================================================================
			# ttbar rate parameters
			if ttbarFit:
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["tt_ZeroJet2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TT"]).bin(["em_ZeroJet2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["TTT", "TTJJ"]).bin(["mt_Boosted2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["et_Boosted2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["tt_Boosted2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TT"]).bin(["em_Boosted2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["TTT", "TTJJ"]).bin(["mt_Vbf2D", "mt_Vbf3D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["et_Vbf2D", "et_Vbf3D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["tt_Vbf2D", "tt_Vbf3D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TT"]).bin(["em_Vbf2D", "em_Vbf3D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["TT"]).bin(["ttbar_TTbarCR"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().GetParameter("rate_ttbar").set_range(0.8, 1.2)

			# ======================================================================
			# mm rate parameters
			if mmFit:
				self.cb.cp().process(["ZTT"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["tt_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["em_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZLL"]).bin(["mm_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["ZTT"]).bin(["mt_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["et_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["tt_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["em_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZLL"]).bin(["mm_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["ZTT"]).bin(["mt_Vbf2D", "mt_Vbf3D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["et_Vbf2D", "et_Vbf3D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["tt_Vbf2D", "tt_Vbf3D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["em_Vbf2D", "em_Vbf3D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZLL"]).bin(["mm_Vbf2D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().GetParameter("rate_mm_ZTT_0jet").set_range(0.9, 1.1)
				self.cb.cp().GetParameter("rate_mm_ZTT_boosted").set_range(0.9, 1.1)
				self.cb.cp().GetParameter("rate_mm_ZTT_vbf").set_range(0.9, 1.1)

			# ======================================================================
			# control region rate parameters
			self.cb.cp().process(["W"]).bin(["mt_ZeroJet2D", "mt_ZeroJet2D_WJCR"]).AddSyst(self.cb, "rate_W_cr_0jet_mt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["W"]).bin(["mt_Boosted2D", "mt_Boosted2D_WJCR", "mt_Vbf2D", "mt_Vbf3D"]).AddSyst(self.cb, "rate_W_cr_boosted_mt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["W"]).bin(["et_ZeroJet2D", "et_ZeroJet2D_WJCR"]).AddSyst(self.cb, "rate_W_cr_0jet_et", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["W"]).bin(["et_Boosted2D", "et_Boosted2D_WJCR", "et_Vbf2D", "et_Vbf3D"]).AddSyst(self.cb, "rate_W_cr_boosted_et", "rateParam", ch.SystMap()(1.0))

			self.cb.cp().process(["QCD"]).bin(["mt_ZeroJet2D", "mt_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_0jet_mt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["mt_Boosted2D", "mt_Boosted2D_QCDCR", "mt_Vbf2D", "mt_Vbf3D"]).AddSyst(self.cb, "rate_QCD_cr_boosted_mt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["et_ZeroJet2D", "et_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_0jet_et", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["et_Boosted2D", "et_Boosted2D_QCDCR", "et_Vbf2D", "et_Vbf3D"]).AddSyst(self.cb, "rate_QCD_cr_boosted_et", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["tt_ZeroJet2D", "tt_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_0jet_tt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["tt_Boosted2D", "tt_Boosted2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_boosted_tt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["tt_Vbf2D", "tt_Vbf3D", "tt_Vbf3D_CP", "tt_Vbf3D_CP_jdeta", "tt_Vbf2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_vbf_tt", "rateParam", ch.SystMap()(1.0))

			self.cb.cp().GetParameter("rate_W_cr_0jet_mt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_W_cr_boosted_mt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_W_cr_0jet_et").set_range(0, 5)
			self.cb.cp().GetParameter("rate_W_cr_boosted_et").set_range(0, 5)

			self.cb.cp().GetParameter("rate_QCD_cr_0jet_mt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_boosted_mt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_0jet_et").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_boosted_et").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_0jet_tt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_boosted_tt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_vbf_tt").set_range(0, 5)

			# ======================================================================

			if log.isEnabledFor(logging.DEBUG):
				self.cb.PrintAll()
コード例 #6
0
###########################################

cb = ch.CombineHarvester()
cats = [
    (1, "%s_%s" % (analysis, channel))
    ]
masses = ["*"]
if not no_data :
    cb.AddObservations(["*"], ["%sl" % analysis], ["13TeV"], ["*"], cats)
cb.AddProcesses(    ['*'], [''], ['13TeV'], [''], bkg_proc_from_data + bkg_procs_from_MC, cats, False)
cb.AddProcesses(    ['*'], [''], ['13TeV'], [''], higgs_procs_plain, cats, True)

#######################################
print ("Adding lumi syt uncorrelated/year")
# check if we keep the lumis/era correlated or not
cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_%s" % str(era), "lnN", ch.SystMap()(lumiSyst[era]))
if (analysis != "ttH"):
    cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_2016_2017_2018", "lnN", ch.SystMap()(lumi_2016_2017_2018[era]))
    if era in [2017, 2018] :
        cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_2017_2018",  "lnN", ch.SystMap()(lumi_2017_2018[era]))
    #if era in [2017, 2016] :
    #    cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_2016_2017", "lnN", ch.SystMap()(lumi_2016_2017[era]))
else:
    cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_XY", "lnN", ch.SystMap()(lumi_2016_2017_2018[era]))
    if era in [2017, 2018] :
        cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_LS",  "lnN", ch.SystMap()(lumi_2017_2018[era]))
        cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_BCC", "lnN", ch.SystMap()(lumi_13TeV_BCC[era]))
    if era in [2017, 2016] :
        cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_BBD", "lnN", ch.SystMap()(lumi_2016_2017[era]))
        cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_DB",  "lnN", ch.SystMap()(lumi_13TeV_DB[era]))
        cb.cp().process(bkg_procs_from_MC + higgs_procs_plain).AddSyst(cb, "CMS_lumi_13TeV_GS",  "lnN", ch.SystMap()(lumi_13TeV_GS[era]))
コード例 #7
0
ファイル: chcardMaker.py プロジェクト: riga/KLUBAnalysis
def  writeCard(input,theLambda,select,region=-1) :
	print "writing cards"
	variables =[]
	if opt.isResonant : variables.append('HHKin_mass_raw')
	else : variables.append('MT2')

	#out_dir = opt.outDir
	theOutputDir = "{0}{1}{2}".format(theLambda,select,variables[0])
	dname = "_"+opt.channel+opt.outDir
	out_dir = "cards{1}/{0}/".format(theOutputDir,dname)
	print out_dir
	#in_dir = "/grid_mnt/vol__vol_U__u/llr/cms/ortona/diHiggs/CMSSW_7_4_7/src/KLUBAnalysis/combiner/cards_MuTauprova/HHSM2b0jMcutBDTMT2/";
	cmb1 = ch.CombineHarvester()
	cmb1.SetFlag('workspaces-use-clone', True)

	cmd = "mkdir -p {0}".format(out_dir)
	print cmd
	regionName = ["","regB","regC","regD"]
	regionSuffix = ["SR","SStight","OSinviso","SSinviso"]
	status, output = commands.getstatusoutput(cmd)   
	#outFile = opt.outDir+"/chCard{0}{2}_{1}_{3}.txt".format(theLambda,opt.channel,regionName[region+1],select)
	thechannel = "1"
	if opt.channel == "MuTau" : thechannel="2"
	elif opt.channel == "TauTau" : thechannel = "3"

	if "0b0j" in select : theCat = "0"
	if "2b0j" in select : theCat = "2"
	elif "1b1j" in select : theCat = "1"
	elif "boosted" in select : theCat = "3"

	outFile = "hh_{0}_C{1}_L{2}_13TeV.txt".format(thechannel,theCat,theLambda)
	file = open( "temp.txt", "wb")


	#read config
	categories = []
	#for icat in range(len(input.selections)) :
	#	categories.append((icat, input.selections[icat]))
	categories.append((0,select))
	backgrounds=[]
	MCbackgrounds=[]
	processes=[]
	processes.append(lambdaName)
	inRoot = TFile.Open(opt.filename)
	for bkg in input.background:
		#Add protection against empty processes => If I remove this I could build all bins at once instead of looping on the selections
		templateName = "{0}_{1}_SR_{2}".format(bkg,select,variables[0])
		print templateName
		template = inRoot.Get(templateName)
		if template.Integral()>0.000001 :
			backgrounds.append(bkg)
			processes.append(bkg)
			if bkg is not "QCD" :
				MCbackgrounds.append(bkg)

	#print backgrounds
	allQCD = False
	allQCDs = [0,0,0,0]
	for regionsuff in range(len(regionSuffix)) :
		for ichan in range(len(backgrounds)):
			if "QCD" in backgrounds[ichan] :
				fname = "data_obs"
				if regionSuffix[regionsuff] == "SR" :
					fname="QCD"
				templateName = "{0}_{1}_{3}_{2}".format(fname,select,variables[0],regionSuffix[regionsuff])
				template = inRoot.Get(templateName)
				#allQCDs.append(template.Integral())
				allQCDs[regionsuff]= allQCDs[regionsuff]+template.Integral()
				iQCD = ichan
			elif regionSuffix[regionsuff] is not "SR" :
				templateName = "{0}_{1}_{3}_{2}".format(backgrounds[ichan],select,variables[0],regionSuffix[regionsuff])
				template = inRoot.Get(templateName)
				allQCDs[regionsuff] = allQCDs[regionsuff] - template.Integral()

	if allQCDs[0]>0 and allQCDs[1]>0 and allQCDs[2]>0 and allQCDs[3]>0 : allQCD = True
	for i in range(4) : print allQCDs[i]
	#add processes to CH
	#masses->125 
	#analyses->Res/non-Res(HHKin_fit,MT2)
	#eras->13TeV 
	#channels->mutau/tautau/etau 
	#bin->bjet categories
	#print signals, signals[0]
	cmb1.AddObservations([theLambda.replace(lambdaName,"")], variables, ['13TeV'], [opt.channel], categories)
	cmb1.AddProcesses([theLambda.replace(lambdaName,"")], variables, ['13TeV'], [opt.channel], backgrounds, categories, False)
	cmb1.AddProcesses([theLambda.replace(lambdaName,"")], variables, ['13TeV'], [opt.channel], [lambdaName], categories, True) #signals[0]

	if region < 0 :

		#Systematics (I need to add by hand the shape ones)
		#potrei sostituire theLambda con "signal"
		#syst = systReader("../config/systematics.cfg",[theLambda],backgrounds,file)
		syst = systReader("../config/systematics.cfg",[lambdaName],backgrounds,file)
		syst.writeOutput(False)
		syst.verbose(True)
		if(opt.channel == "TauTau" ): 
			syst.addSystFile("../config/systematics_tautau.cfg")
		elif(opt.channel == "MuTau" ): 
			syst.addSystFile("../config/systematics_mutau.cfg")
			#if(opt.isResonant):
			#	syst.addSystFile("../config/systematics_resonant.cfg")
			#else : syst.addSystFile("../config/systematics_nonresonant.cfg")
		elif(opt.channel == "ETau" ): 
			syst.addSystFile("../config/systematics_etau.cfg")
			#if(opt.isResonant):
			#	syst.addSystFile("../config/systematics_resonant.cfg")
			#else : syst.addSystFile("../config/systematics_nonresonant.cfg")
		if opt.theory : syst.addSystFile("../config/syst_th.cfg")
		syst.writeSystematics()

		for isy in range(len(syst.SystNames)) :
			if "CMS_scale_t" in syst.SystNames[isy] or "CMS_scale_j" in syst.SystNames[isy]: continue
			for iproc in range(len(syst.SystProcesses[isy])) :
				if "/" in syst.SystValues[isy][iproc] :
					f = syst.SystValues[isy][iproc].split("/")
					systVal = (float(f[0]),float(f[1]))
				else :
					systVal = float(syst.SystValues[isy][iproc])
				#print isy, iproc, systVal
				print "adding Syst",systVal,syst.SystNames[isy],syst.SystTypes[isy],"to",syst.SystProcesses[isy][iproc]
				cmb1.cp().process([syst.SystProcesses[isy][iproc]]).AddSyst(cmb1, syst.SystNames[isy],syst.SystTypes[isy],ch.SystMap('channel','bin_id')([opt.channel],[0],systVal))
		if opt.shapeUnc > 0:
			jesproc = MCbackgrounds
			jesproc.append(lambdaName)
			if "1b1j" in select and opt.channel == "TauTau" : jesproc.remove("DY0b")
			cmb1.cp().process(jesproc).AddSyst(cmb1, "CMS_scale_j_13TeV","shape",ch.SystMap('channel','bin_id')([opt.channel],[0],1.000))
			cmb1.cp().process(jesproc).AddSyst(cmb1, "CMS_scale_t_13TeV","shape",ch.SystMap('channel','bin_id')([opt.channel],[0],1.000))
			cmb1.cp().process(["TT"]).AddSyst(cmb1, "top","shape",ch.SystMap('channel','bin_id')([opt.channel],[0],1.000))

	    #	$BIN        --> proc.bin()
	    #	$PROCESS    --> proc.process()
	    #	$MASS       --> proc.mass()
	    #	$SYSTEMATIC --> syst.name()
#		cmb1.cp().ExtractShapes(
#			opt.filename,
#			"$PROCESS_$BIN_{1}_{0}".format(variables[0],regionSuffix[region+1]),
#			"$PROCESS_$BIN_{1}_{0}_$SYSTEMATIC".format(variables[0],regionSuffix[region+1]))
		cmb1.cp().backgrounds().ExtractShapes(
			opt.filename,
			"$PROCESS_$BIN_{1}_{0}".format(variables[0],regionSuffix[region+1]),
			"$PROCESS_$BIN_{1}_{0}_$SYSTEMATIC".format(variables[0],regionSuffix[region+1]))
		cmb1.cp().signals().ExtractShapes(
			opt.filename,
			"$PROCESS$MASS_$BIN_{1}_{0}".format(variables[0],regionSuffix[region+1]),
			"$PROCESS$MASS_$BIN_{1}_{0}_$SYSTEMATIC".format(variables[0],regionSuffix[region+1]))

		bbb = ch.BinByBinFactory()
		bbb.SetAddThreshold(0.1).SetMergeThreshold(0.5).SetFixNorm(True)
		bbbQCD = ch.BinByBinFactory()
		bbbQCD.SetAddThreshold(0.0).SetMergeThreshold(0.5).SetFixNorm(True)
		if opt.binbybin : 
			bbb.MergeBinErrors(cmb1.cp().process(MCbackgrounds))
			bbbQCD.MergeBinErrors(cmb1.cp().process(["QCD"]))
			bbbQCD.AddBinByBin(cmb1.cp().process(["QCD"]), cmb1)
			bbb.AddBinByBin(cmb1.cp().process(MCbackgrounds), cmb1)
		#cmb1.cp().PrintProcs().PrintSysts()

		#outroot = TFile.Open(opt.outDir+"/chCard{0}{2}_{1}_{3}.input.root".format(theLambda,opt.channel,regionName[region+1],select),"RECREATE")
		#outtxt = "hh_{0}_C{1}_L{2}_13TeV.txt".format(theChannel,theCat,theHHLambda)
		outroot = TFile.Open(out_dir+"hh_{0}_C{1}_L{2}_13TeV.input.root".format(thechannel,theCat,theLambda),"RECREATE")
		cmb1.WriteDatacard(out_dir+outFile,out_dir+"hh_{0}_C{1}_L{2}_13TeV.input.root".format(thechannel,theCat,theLambda))
		if allQCD :
			file = open( out_dir+outFile, "a")	
			file.write("alpha rateParam {0} QCD (@0*@1/@2) QCD_regB,QCD_regC,QCD_regD".format(select))
	elif allQCD :
		#print thechannel,theCat,theLambda #,regionName2[region+1]
		#outFile = "hh_{0}_C{1}_L{2}_13TeV.txt".format(thechannel,theCat,theLambda)
		#print region, allQCD
		#print regionName2[region+1]
		#print outFile
		#print "hh_"+thechannel#+"_C"+theCat+"_L"+theLambda+"_13TeV_"+regionName[region+1]+".txt"
		#print "hh_"+thechannel+"_C"+theCat#+"_L"+theLambda+"_13TeV_"+regionName[region+1]+".txt"
		#print "hh_"+thechannel+"_C"+theCat+"_L"+theLambda#+"_13TeV_"+regionName[region+1]+".txt"
		#print "hh_"+thechannel+"_C"+theCat+"_L"+theLambda+"_13TeV_"#+regionName[region+1]+".txt"
		#print outFile
		outFile = "hh_{0}_C{1}_L{2}_13TeV_{3}.txt".format(thechannel,theCat,theLambda,regionName[region+1])
		file = open( out_dir+outFile, "wb")

		file.write("imax 1\n")
		file.write("jmax {0}\n".format(len(backgrounds)-1))
		file.write("kmax *\n")

		file.write("------------\n")
		file.write("shapes * * FAKE\n".format(opt.channel,regionName[region+1]))
		file.write("------------\n")

		templateName = "data_obs_{1}_{3}_{2}".format(bkg,select,variables[0],regionSuffix[region+1])
		template = inRoot.Get(templateName)        
		file.write("bin {0} \n".format(select))
		obs = template.GetEntries()
		file.write("observation {0} \n".format(obs))

		file.write("------------\n")

		file.write("bin ")        
		for chan in backgrounds:
			file.write("{0} ".format(select))
		file.write("\n")      

		file.write("process ")
		for chan in backgrounds:
			file.write("{0} ".format(chan))
		#file.write("QCD ")
		file.write("\n")

		file.write("process ")
		for chan in range(len(backgrounds)): #+1 for the QCD
			file.write("{0} ".format(chan+1))
		file.write("\n")

		file.write("rate ")
		rates = []
		iQCD = -1
		totRate = 0
		for ichan in range(len(backgrounds)):
			if "QCD" in backgrounds[ichan] :
				rates.append(-1)
				iQCD = ichan
			else :
				templateName = "{0}_{1}_{3}_{2}".format(backgrounds[ichan],select,variables[0],regionSuffix[region+1])
				template = inRoot.Get(templateName)
				#print templateName
				brate = template.Integral()
				rates.append(brate)
				totRate = totRate + brate
		if iQCD >= 0 : rates[iQCD] = TMath.Max(0.0000001,obs-totRate)
		for ichan in range(len(backgrounds)):
			file.write("{0:.4f} ".format(rates[ichan]))
		file.write("\n")
		file.write("------------\n")
		file.write("QCD_{0} rateParam  {1} QCD 1 \n".format(regionName[region+1],select))
コード例 #8
0
ファイル: Example3.py プロジェクト: senka/HTT_20162017
import CombineHarvester.CombineTools.ch as ch

cb = ch.CombineHarvester()
cb.SetVerbosity(3)

cats = [(0, 'A'), (1, 'B'), (2, 'C'), (3, 'D')]

obs_rates = {'A': 10, 'B': 50, 'C': 100, 'D': 500}

cb.AddObservations(['*'], [''], ['13TeV'], [''], cats)
cb.AddProcesses(['*'], [''], ['13TeV'], [''], ['bkg'], cats, False)

cb.ForEachObs(lambda x: x.set_rate(obs_rates[x.bin()]))
cb.ForEachProc(lambda x: x.set_rate(1))

cb.cp().bin(['D']).AddSyst(cb, 'DummySys', 'lnN', ch.SystMap()(1.0001))

cb.cp().bin(['B', 'C', 'D']).AddSyst(
    cb, 'scale_$BIN', 'rateParam',
    ch.SystMap('bin')(['B'], float(obs_rates['B']))(['C'], float(
        obs_rates['C']))(['D'], float(obs_rates['D'])))

cb.cp().bin(['A']).AddSyst(
    cb, 'scale_$BIN', 'rateParam',
    ch.SystMap()(
        ('(@0*@1/@2)', ','.join(['scale_' + x for x in ['B', 'C', 'D']]))))

cb.PrintAll()
cb.WriteDatacard('example3.txt')
コード例 #9
0
ファイル: setupDatacards.py プロジェクト: ajgilbert/Acorn
cb_no_fakes = cb.cp().process([fakes_name, 'data_fakes_lep_sub'], False)

##### Lumi
# https://twiki.cern.ch/twiki/bin/view/CMS/TWikiLUM#SummaryTable
# Uncorrelated 2016,2.2,0.0,0.0
# Uncorrelated 2017,0.0,2.0,0.0
# Uncorrelated 2018,0.0,0.0,1.5
# X-Y factorization,0.9,0.8,2.0
# Length scale 17-18,0.0,0.3,0.2
# Beam-beam deflection 15-17,0.4,0.4,0.0
# Dynamic beta 15-17,0.5,0.5,0.0
# Beam current calibration 17-18,0.0,0.3,0.2
# Ghosts and satellites 15-17,0.4,0.1,0.0
cb_no_fakes.cp().AddSyst(
    cb, 'CMS_lumi_$ERA', 'lnN',
    ch.SystMap('era')(['2016'], 1.022)(['2017'], 1.020)(['2018'], 1.015))

cb_no_fakes.cp().AddSyst(
    cb, 'CMS_lumi_xy_fact', 'lnN',
    ch.SystMap('era')(['2016'], 1.009)(['2017'], 1.008)(['2018'], 1.020))

cb_no_fakes.cp().AddSyst(cb, 'CMS_lumi_length_scale', 'lnN',
                         ch.SystMap('era')(['2017'], 1.003)(['2018'], 1.002))

cb_no_fakes.cp().AddSyst(cb, 'CMS_lumi_deflection', 'lnN',
                         ch.SystMap('era')(['2016'], 1.004)(['2017'], 1.004))

cb_no_fakes.cp().AddSyst(cb, 'CMS_lumi_dynamic_beta', 'lnN',
                         ch.SystMap('era')(['2016'], 1.005)(['2017'], 1.005))

cb_no_fakes.cp().AddSyst(cb, 'CMS_lumi_beam_current', 'lnN',
コード例 #10
0
	def extract_shapes(self, root_filename_template,
	                   bkg_histogram_name_template, sig_histogram_name_template,
	                   bkg_syst_histogram_name_template, sig_syst_histogram_name_template,
	                   update_systematics=False):
		for analysis in self.cb.analysis_set():
			for era in self.cb.cp().analysis([analysis]).era_set():
				for channel in self.cb.cp().analysis([analysis]).era([era]).channel_set():
					for category in self.cb.cp().analysis([analysis]).era([era]).channel([channel]).bin_set():
						root_filename = root_filename_template.format(
								ANALYSIS=analysis,
								CHANNEL=channel,
								BIN=category,
								ERA=era
						)

						cb_backgrounds = self.cb.cp().analysis([analysis]).era([era]).channel([channel]).bin([category]).backgrounds()
						cb_backgrounds.ExtractShapes(
								root_filename,
								bkg_histogram_name_template.replace("{", "").replace("}", ""),
								bkg_syst_histogram_name_template.replace("{", "").replace("}", "")
						)

						cb_signals = self.cb.cp().analysis([analysis]).era([era]).channel([channel]).bin([category]).signals()
						cb_signals.ExtractShapes(
								root_filename,
								sig_histogram_name_template.replace("{", "").replace("}", ""),
								sig_syst_histogram_name_template.replace("{", "").replace("}", "")
						)

						# update/add systematics related to the estimation of backgrounds/signals
						# these uncertainties are stored in the input root files
						if update_systematics:
							with tfilecontextmanager.TFileContextManager(root_filename, "READ") as root_file:
								root_object_paths = [path for key, path in roottools.RootTools.walk_root_directory(root_file)]

								processes_histogram_names = []
								for process in cb_backgrounds.process_set():
									bkg_histogram_name = bkg_histogram_name_template.replace("$", "").format(
											ANALYSIS=analysis,
											CHANNEL=channel,
											BIN=category,
											ERA=era,
											PROCESS=process
									)
									yield_unc_rel = Datacards.get_yield_unc_rel(bkg_histogram_name, root_file, root_object_paths)
									if (not yield_unc_rel is None) and (yield_unc_rel != 0.0):
										cb_backgrounds.cp().process([process]).AddSyst(
												self.cb,
												"CMS_$ANALYSIS_$PROCESS_estimation_$ERA",
												"lnN",
												ch.SystMap("process")([process], 1.0+yield_unc_rel)
										)

								for process in cb_signals.process_set():
									for mass in cb_signals.mass_set():
										if mass != "*":
											sig_histogram_name = sig_histogram_name_template.replace("$", "").format(
													ANALYSIS=analysis,
													CHANNEL=channel,
													BIN=category,
													ERA=era,
													PROCESS=process,
													MASS=mass
											)
											yield_unc_rel = Datacards.get_yield_unc_rel(sig_histogram_name, root_file, root_object_paths)
											if (not yield_unc_rel is None) and (yield_unc_rel != 0.0):
												cb_backgrounds.cp().process([process]).mass([mass]).AddSyst(
														self.cb,
														"CMS_$ANALYSIS_$PROCESS$MASS_estimation_$ERA",
														"lnN",
														ch.SystMap("process", "mass")([process], [mass], 1.0+yield_unc_rel)
												)

		if log.isEnabledFor(logging.DEBUG):
			self.cb.PrintAll()
コード例 #11
0
    def __init__(self,
                 channel_list,
                 signal_list,
                 category_list,
                 control_region_dic,
                 cb=None,
                 lnN_syst_enable=False,
                 shape_syst_enable=False,
                 rate_param_enable=False):
        super(LFVDatacards, self).__init__(cb)

        if cb is None:

            ###Define all background processes for each channel

            backgrounds = {
                "em": [
                    "ZTT", "ZLL", "EWKZ", "TT", "VV", "hww_gg125", "hww_qq125",
                    "W", "QCD"
                ],
                "et":
                ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"],
                "mt":
                ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"]
            }

            ##Generate instance of systematic libary, in which the relevant information about the systematics are safed

            systematics_list = SystLib.SystematicLibary()

            ###Fill Combine Harvester object with relevant information

            for channel in channel_list:

                ###Add channels as process in Combine Harvester
                for category in category_list + control_region_dic.keys():
                    self.add_processes(channel=channel,
                                       categories=[channel + "_" + category],
                                       bkg_processes=backgrounds[channel]
                                       if not "CR" in category else
                                       [control_region_dic[category][0]],
                                       sig_processes=[
                                           self.configs.sample2process(signal)
                                           for signal in signal_list
                                       ] if not "CR" in category else [],
                                       analysis=["LFV"],
                                       era=["13TeV"],
                                       mass=["125"])

                ###Add lnN/shape uncertanty for each channel, process and category

                if lnN_syst_enable:
                    for (systematic, process,
                         category) in systematics_list.get_LFV_systs(
                             channel, lnN=lnN_syst_enable):
                        if category == "":
                            self.cb.cp().channel([channel
                                                  ]).process(process).AddSyst(
                                                      self.cb, *systematic)
                        else:
                            self.cb.cp().channel([
                                channel
                            ]).process(process).bin(category).AddSyst(
                                self.cb, *systematic)

                if shape_syst_enable:
                    for (systematic, process,
                         category) in systematics_list.get_LFV_systs(
                             channel, shape=shape_syst_enable):
                        if category == "":
                            self.cb.cp().channel([channel
                                                  ]).process(process).AddSyst(
                                                      self.cb, *systematic)
                        else:
                            self.cb.cp().channel([
                                channel
                            ]).process(process).bin(category).AddSyst(
                                self.cb, *systematic)

                ##Add rate parameter

                if rate_param_enable:
                    for control_region, process in control_region_dic.iteritems(
                    ):
                        self.cb.cp().process([process[0]]).bin([
                            channel + "_" + cat
                            for cat in category_list + [control_region]
                        ]).AddSyst(self.cb,
                                   "rate_" + channel + "_" + process[0],
                                   "rateParam",
                                   ch.SystMap()(1.0))
コード例 #12
0
ファイル: cbtt.py プロジェクト: jd550179/bachelorarbeit
cb.AddObservations(["*"], ["htt"], ["13TeV"], ["tt"], [(0, "dphi")])

bkg_procs = ["ZTT", "ZLL", "WJ", "TTJ", "VV", "QCD", "qqH", "WH", "ZH"]

cb.AddProcesses(["*"], ["htt"], ["13TeV"], ["tt"], bkg_procs, [(0, "dphi")],
                False)

signal_procs = ["ggH125_000"]

cb.AddProcesses(["125"], ["htt"], ["13TeV"], ["tt"], signal_procs,
                [(0, "dphi")], True)

cb.cp().process(["ZTT", "ZLL", "WJ", "TTJ", "VV", "qqH", "WH",
                 "ZH"]).AddSyst(cb, "lumi_$ERA", "lnN",
                                ch.SystMap("era")(["13TeV"], 1.027))
cb.cp().signals().AddSyst(cb, "lumi_$ERA", "lnN",
                          ch.SystMap("era")(["13TeV"], 1.027))

cb.cp().backgrounds().ExtractShapes(auxshapes + "/dphitt_2016.root",
                                    "$BIN/$PROCESS",
                                    "$BIN/$PROCESS$MASS_$SYSTEMATIC")

cb.cp().signals().ExtractShapes(auxshapes + "/dphitt_2016.root",
                                "$BIN/$PROCESS",
                                "$BIN/$PROCESS$MASS_$SYSTEMATIC")

g = ROOT.TFile("htt_tt.input.root", "recreate")
g.Close()

cb.WriteDatacard("cardtt.txt", "htt_tt.input.root")
コード例 #13
0
    cb.AddProcesses(['*'], ana, era, [chn], bkg_procs[chn], bins[chn],
                    False)  ### DEF LINES
    cb.AddProcesses(['*'], ana, era, [chn], sig_procs, bins[chn],
                    True)  ### DEF LINES

##########################################################################
# Define systematic uncertainties
##########################################################################

#signal = cb.cp().signals().process_set()

#################### Yield systematics ############################

cb.cp().AddSyst(  ## Correl. across $CHANNEL and $BIN
    cb, 'EWK_unc', 'lnN',
    ch.SystMap('channel', 'process')(channels, ['EWK'], 1.5))

cb.cp().AddSyst(  ## Correl. across $CHANNEL and $BIN
    cb, 'TT_unc', 'lnN',
    ch.SystMap('channel', 'process')(channels, ['TT'], 1.5))

cb.cp().AddSyst(  ## Correl. across $CHANNEL and $BIN
    cb, 'TTW_unc', 'lnN',
    ch.SystMap('channel', 'process')(channels, ['TTW'], 1.2))

cb.cp().AddSyst(  ## Correl. across $CHANNEL and $BIN
    cb, 'TTZ_unc', 'lnN',
    ch.SystMap('channel', 'process')(channels, ['TTZ'], 1.2))

cb.cp().AddSyst(  ## Correl. across $CHANNEL and $BIN
    cb, 'signal_unc', 'lnN',
コード例 #14
0
    cb.AddObservations(['*'], prefix, era, [chn], categories[chn])

    cb.AddProcesses(['*'], prefix, era, [chn], bkg_procs, categories[chn],
                    False)
    cb.AddProcesses(['90'], prefix, era, [chn], sig_procs, categories[chn],
                    True)

print '>> Adding systematic uncertainties...'

#cb.cp().bin_id([1]).process(procs['sig'] + ['ZJ', 'ZL', 'TTJ', 'VV', 'STT', 'STJ', 'TTT', 'ZTT']).AddSyst(

cb.cp().process(sig_procs +
                ['bc_others', 'bc_jpsi_tau_N3p', 'bc_jpsi_dst']).AddSyst(
                    cb, 'CMS_lumi', 'lnN',
                    ch.SystMap()(1.025))

cb.cp().process(sig_procs +
                ['bc_others', 'bc_jpsi_tau_N3p', 'bc_jpsi_dst']).AddSyst(
                    cb, 'CMS_taureco', 'lnN',
                    ch.SystMap()(1.05))

cb.cp().process(sig_procs +
                ['bc_others', 'bc_jpsi_tau_N3p', 'bc_jpsi_dst']).AddSyst(
                    cb, 'CMS_xgbseff', 'lnN',
                    ch.SystMap()(1.05))

# This is from Stefano's number: https://sleontsi.web.cern.ch/sleontsi/Bc+/Yuta/

cb.cp().process(['dd_bkg']).AddSyst(cb, 'CMS_bkg', 'lnN',
                                    ch.SystMap()((0.952, 1.149)))
コード例 #15
0
	processes = [
		"sig",
		"bkg",
	]
	mass = "*"
	
	cb = ch.CombineHarvester()
	
	for category, bin_id in categories.iteritems():
		cb.AddObservations(analysis=[analysis], era=[era], channel=[channel], bin=[(bin_id, category)], mass=[mass])
		cb.AddProcesses(analysis=[analysis], era=[era], channel=[channel], bin=[(bin_id, category)], mass=[mass], procs=["bkg"], signal=False)
		cb.AddProcesses(analysis=[analysis], era=[era], channel=[channel], bin=[(bin_id, category)], mass=[mass], procs=["sig"], signal=True)
	
	for category in categories.keys():
		for process in processes:
			cb.cp().bin([category]).process([process]).AddSyst(cb, "uncorrelated_"+category+"_proc_"+process, "lnN", ch.SystMap()(1.2))
		
		cb.cp().bin([category]).AddSyst(cb, "correlated_"+category, "lnN", ch.SystMap()(1.2))
	
	for process in processes:
		cb.cp().process([process]).AddSyst(cb, "correlated_proc_"+process, "lnN", ch.SystMap()(1.2))
	
	cb.cp().AddSyst(cb, "correlated", "lnN", ch.SystMap()(1.2))
	
	input_file = os.path.expandvars("$CMSSW_BASE/src/Artus/Example/data/combine/sig_bkg_2categories_noshapes.root")
	cb.ExtractShapes(input_file, "$BIN/$PROCESS", "$BIN/$PROCESS_$SYSTEMATIC")
	
	if log.isEnabledFor(logging.DEBUG):
		cb.PrintAll()
	
	cb_categories = cb.cp().bin(["cat_sig", "cat_bkg"])
コード例 #16
0
        cb = ch.CombineHarvester()
        #cb.SetFlag('workspaces-use-clone', True)
        mc_backgrounds = ['ZTT','ZJ','W','VV','ST','TTT','TTL','TTJ']
        data_driven_backgrounds = ['QCD']
        backgrounds = mc_backgrounds + data_driven_backgrounds
        signals = ['ZL']

        categories = {
            'mutau' : [( 1, 'Pass' ),( 2, 'Fail' )],
        }

        cb.AddObservations(['*'], ['MuTauFR'], ['2016'], ['mutau'],              categories['mutau']) # adding observed data
        cb.AddProcesses(   ['*'], ['MuTauFR'], ['2016'], ['mutau'], backgrounds, categories['mutau'], False) # adding backgrounds
        cb.AddProcesses(   ['*'], ['MuTauFR'], ['2016'], ['mutau'], signals,     categories['mutau'], True) # adding signals

        cb.cp().process(mc_backgrounds).AddSyst(cb,'lumi_2016', 'lnN', ch.SystMap()(1.026))
        cb.cp().process(mc_backgrounds).AddSyst(cb,'muon_eff', 'lnN', ch.SystMap()(1.02))
        cb.cp().process(['ZTT', 'TTT']).AddSyst(cb,'tau_eff', 'lnN', ch.SystMap()(1.05))
        cb.cp().process(['TTT','TTL','TTJ','ST']).AddSyst(cb, 'xsec_top', 'lnN', ch.SystMap()(1.10))
        cb.cp().process(['VV']).AddSyst(cb, 'xsec_vv', 'lnN', ch.SystMap()(1.15))
        cb.cp().process(['ZL','ZTT','ZJ']).AddSyst(cb, 'xsec_z', 'lnN', ch.SystMap()(1.03))
        cb.cp().process(['W']).AddSyst(cb, 'w_estimation', 'lnN', ch.SystMap()(1.20))
        cb.cp().process(['ZJ','TTJ']).AddSyst(cb, 'jet_to_tauFR', 'lnN', ch.SystMap()(1.30))
        cb.cp().process(['QCD']).AddSyst(cb, 'ss_to_os_extrap', 'lnN', ch.SystMap()(1.2))
        cb.cp().process(['ZL']).AddSyst(cb, 'vsjetSF', 'rateParam', ch.SystMap()(1.0))
        cb.cp().process(['ZTT', 'TTT']).AddSyst(cb, 'TES', 'shape', ch.SystMap()(1.0))
        cb.cp().process(['ZL', 'TTL']).AddSyst(cb, 'FES', 'shape', ch.SystMap()(1.0))

        filepath = os.path.join(os.environ['CMSSW_BASE'],'src/TauFW/Fitter/MuTauFR/input', "MuTauFR_m_vis_eta%s_mt-2016.inputs.root")%(ieta)
        processName = '%s$BIN/$PROCESS'%(iwp)
        systematicName = '%s$BIN/$PROCESS_$SYSTEMATIC'%(iwp)
コード例 #17
0
                hist_ = file.Get('sb/' + iproc)
                subtract_total += hist_.GetBinContent(i)

            init = data_sb.GetBinContent(i) - subtract_total
            print 'init norm. = ', chn, ', bin=', i, ', sb data = ', data_sb.GetBinContent(
                i), ', sb sig. = ', subtract_total, ', init =>', init
            extraStr += 'yield_bg_bin{0} rateParam * bg_bin{0} '.format(
                i) + str(init) + ' [-10,5000]\n'

extraStr += 'ratio_sb_sr rateParam sr bg_* ' + str(init_sf) + ' [0.25,0.3]\n'
#extraStr += 'ratio_sb_sr rateParam sr bg_* ' + str(init_sf) + '\n'

print '>> Adding systematic uncertainties...'

cb.cp().process(sig_procs + bkg_procs).AddSyst(cb, 'CMS_lumi', 'lnN',
                                               ch.SystMap()(1.025))

cb.cp().process(['bc_jpsi_dst'
                 ]).AddSyst(cb, 'br_jpsi_hc_over_mu', 'lnN',
                            ch.SystMap()(1.38))  #taken from leptonic channel

for hammer in range(0, 9):
    cb.cp().AddSyst(
        cb, 'hammer_ebe_e' + str(hammer), 'shape',
        ch.SystMap('channel',
                   'process')(channels, ['bc_jpsi_tau_3p', 'bc_jpsi_tau_N3p'],
                              1.0))

cb.cp().AddSyst(
    cb, 'puweight', 'shape',
    ch.SystMap('channel', 'process')(channels, sig_procs + bkg_procs, 1.0))
コード例 #18
0
    'CMS_PileUpPtBB_j',
    'CMS_PileUpPtEC1_j',
    # 'CMS_PileUpPtEC2_j', # not even produced because zero
    # 'CMS_PileUpPtHF_j', # zero?
    'CMS_JER_j',
]

theory_shape_systs = [
    (tt_bkg + sig_processes, 'CMS_top_Weight'),
    (tt_bkg + sig_processes, 'CMS_LHEscale_Weight'),
    (tt_bkg + sig_processes, 'CMS_LHEPDF_Weight'),
]

theory_rate_systs = {
    # FIXME 50% uncertainty on ttcc?
    'ttcc_norm': ('lnN', ch.SystMap('process')(['ttcc'], 1.5)),
    'pdf_gg': ('lnN', ch.SystMap('process')(['ttV'], 1.03)),
    'pdf_gg_ttH': ('lnN', ch.SystMap('process')(['ttH'], 1.036)),
    'pdf_qg': ('lnN', ch.SystMap('process')(['stop'], 1.03)),
    'pdf_qqbar':
    ('lnN', ch.SystMap('process')(['VJ'], 1.04)(['VV'], 1.02)(['ttV'], 1.02)),
    'QCD_scale_ttH': ('lnN', ch.SystMap('process')(['ttH'], (0.908, 1.058))),
    'QCD_scale_t': ('lnN', ch.SystMap('process')(['stop'], (0.98, 1.03))),
    'QCD_scale_V': ('lnN', ch.SystMap('process')(['VJ'], 1.01)),
    'QCD_scale_VV': ('lnN', ch.SystMap('process')(['VV'], 1.02)),
}

# Will be frozen for all fits!
# Impact estimated by repeating fit while shifting nuisance up and down
externalised_nuisances = [
    'CMS_top_Weight',
コード例 #19
0
import CombineHarvester.CombineTools.ch as ch

cb = ch.CombineHarvester()
cb.AddObservations(["120"], ["ana"], ["era"], ["chan"], [(0, "cat")])
cb.AddProcesses(["120"], ["ana"], ["era"], ["chan"], ["sig"], [(0, "cat")],
                True)
cb.AddProcesses(["120"], ["ana"], ["era"], ["chan"], ["bkg"], [(0, "cat")],
                False)

cb.cp().process(["bkg"]).AddSyst(cb, "sys", "shape", ch.SystMap()(1.0))
cb.cp().ExtractShapes("shapes.root", "$PROCESS", "$PROCESS_$SYSTEMATIC")
"""
bbb = ch.BinByBinFactory()
bbb.SetVerbosity(1)
bbb.SetAddThreshold(0.0)
bbb.SetMergeThreshold(0.0)
bbb.SetFixNorm(True)
#bbb.MergeBinErrors(cb.cp())
bbb.AddBinByBin(cb.cp(), cb)
cb.SetGroup("bbb", [".*_bin_\\d+"])
cb.SetGroup("syst_plus_bbb", [".*"])
cb.SetGroup("syst", ["sys"])
"""

cb.PrintAll()

writer = ch.CardWriter("datacard.txt", "shapes_ch.root")
writer.SetVerbosity(1)
writer.CreateDirectories(False)
writer.WriteCards("", cb)
コード例 #20
0
    era = ['13TeV']
    cb.AddObservations(['*'], ana, era, [chn], bins[chn])
    cb.AddProcesses(['*'], ana, era, [chn], bkg_procs[chn], bins[chn], False)
    cb.AddProcesses(['*'], ana, era, [chn], sig_procs, bins[chn], True)

##########################################################################
# Define systematic uncertainties
##########################################################################
# define some useful shortcuts
real_m = ['ZTT', 'ZLL', 'ZL', 'ZJ', 'TT', 'VV']  # procs with a real muon
real_e = ['ZTT', 'ZLL', 'ZL', 'ZJ', 'TT', 'VV']  # procs with a real electron

cb.cp().AddSyst(
    cb, 'CMS_eff_m', 'lnN',
    ch.SystMap('channel', 'process')(['mt'], real_m,
                                     1.03)(['em'], ['ZTT', 'TT', 'W', 'VV'],
                                           1.03)(['mm'], ['ZTT', 'VV', 'ZLL'],
                                                 1.06)(['mm'], ['W'], 1.03))

cb.cp().AddSyst(
    cb, 'CMS_eff_e', 'lnN',
    ch.SystMap('channel', 'process')(['et'], real_e,
                                     1.04)(['em'], ['ZTT', 'TT', 'W', 'VV'],
                                           1.04))

# Only create the eff_t lnN if we want this to be constrained,
# otherwise set a rateParam.
# Split tau ID efficiency uncertainty into part ("CMS_eff_t") that is correlated between channels
# and part ("CMS_eff_t_et", "CMS_eff_t_mt", "CMS_eff_t_tt") that is uncorrelated
if args.constrain_tau_eff:
    print '>> Info: Tau efficiency will be constrained'
    cb.cp().AddSyst(
コード例 #21
0
    'sim': ['WZ', 'ZZ', 'ttW', 'ttZ', 'ttH'],
    'bkg': ['WZ', 'ZZ', 'ttW', 'ttZ', 'ttH', 'reducible']
}

cats = [(0, 'emt'), (1, 'mmt')]

masses = ['125']

cb.AddObservations(['*'], ['htt'], ["8TeV"], ['th'], cats)
cb.AddProcesses(['*'], ['htt'], ["8TeV"], ['th'], procs['bkg'], cats, False)
cb.AddProcesses(masses, ['htt'], ["8TeV"], ['th'], procs['sig'], cats, True)

print '>> Adding systematic uncertainties...'

cb.cp().process(procs['sig'] + procs['sim']).AddSyst(cb, 'lumi_$ERA', 'lnN',
                                                     ch.SystMap()(1.026))

cb.cp().process(procs['sig']).AddSyst(
    cb, 'CMS_th_sig_trigger_$BIN_$ERA', 'lnN',
    ch.SystMap('bin')(['emt'], 1.05)(['mmt'], 1.06))

cb.cp().process(procs['sig'] + procs['sim']).AddSyst(
    cb, 'CMS_th_eff_e_$ERA', 'lnN',
    ch.SystMap('bin')(['emt'], 1.051))

cb.cp().process(procs['sig'] + procs['sim']).AddSyst(
    cb, 'CMS_th_eff_m_$ERA', 'lnN',
    ch.SystMap('bin')(['emt'], 1.051)(['mmt'], 1.102))

cb.cp().process(procs['sig'] + procs['sim']).AddSyst(cb, 'CMS_th_eff_t_$ERA',
                                                     'lnN',
コード例 #22
0
def prepareShapesAndCards(options):

    cb = ch.CombineHarvester()

    if options.fit_mode == 'shape_CR1':
        cats = [
            (1, 'SR'),
            (2, 'CR1')
        ]
        print('-- QCD estimation: fit bin-by-bin by assuming shape in CR1 and SR is the same --')

    elif options.fit_mode == 'abcd':
        cats = [
            (1, 'SR'),
            (2, 'CR1'),
            (3, 'VR'),
            (4, 'CR2'),
        ]
        print('-- QCD etimation: bin-by-bin ABCD using the four regions --')

    # object to handle the factorisation of uncertainties among ttbar components
    factTheory = defs.FactorisedTheory(options.fact_theory)
    
    # factorise shape uncertainties for ttbar components
    theory_shape_systs = []
    for procs, syst in defs.theory_shape_systs:
        for newProcs,newSyst in factTheory.getGrouping(procs, syst):
            theory_shape_systs.append((newProcs, newSyst))

    if options.randomise:
        print("-- Will randomise MC predictions according to MC stat uncertainties!")
    
    # Process shapes
    processed_shapes = os.path.join(options.output, 'processed_shapes.root')
    QCD_VR_ratios = utils.extractShapes(options.input, processed_shapes, defs.tt_bkg + defs.other_bkg, defs.sig_processes, options.data, fact_theory=factTheory, equal_bins=options.equal_bins, sub_folder=options.sub_folder, randomise=options.randomise, rebinSB=options.rebinsb)
    Nbins = len(QCD_VR_ratios)

    cb.AddObservations(['*'], ['ttbb'], ['13TeV_2016'], ['FH'], cats)
    
    cb.AddProcesses(['*'], ['ttbb'], ['13TeV_2016'], ['FH'], defs.sig_processes, cats, True)

    cb.AddProcesses(['*'], ['ttbb'], ['13TeV_2016'], ['FH'], defs.tt_bkg + defs.other_bkg, cats, False)

    ### QCD estimate: add all "delta" templates
    QCD_processes = [ 'QCD_bin_{}'.format(i+1) for i in range(Nbins) ]
    cb.AddProcesses(['*'], ['ttbb'], ['13TeV_2016'], ['FH'], QCD_processes, cats, False)


    ### Systematics
    added_theory_systs = []
    added_exp_systs = []

    # Modeling systematics, not on QCD! ###
    cbWithoutQCD = cb.cp().process_rgx(['QCD.*'], False)
    
    # Theory rate uncertainties from the JSON file
    if options.rate_systs is not None:
        for json_file in options.rate_systs:
            added_theory_systs += addRateSystematics(cb, json_file, options.sub_folder, factTheory)
    
    # Experimental rate uncertainties from the JSON file
    if options.exp_rate is not None:
        for json_file in options.exp_rate:
            added_exp_systs += addRateSystematics(cb, json_file, options.sub_folder)

    # Luminosity
    cbWithoutQCD.AddSyst(cb, 'lumi_$ERA', 'lnN', ch.SystMap('era')(['13TeV_2016'], defs.getLumiUncertainty('13TeV_2016')))
    added_exp_systs.append('lumi_13TeV_2016')

    # Experimental systematics, common for all processes and categories
    for s in defs.exp_systs:
        # If we have added it already as a rate systematics, skip it!
        if s not in added_exp_systs:
            added_exp_systs.append(s)
            cbWithoutQCD.AddSyst(cb, s, 'shape', ch.SystMap()(1.))

    # Theory shape systematics
    for syst in theory_shape_systs:
        if syst[1] not in added_theory_systs:
            added_theory_systs.append(syst[1])
            cbWithoutQCD.cp().process(syst[0]).AddSyst(cb, syst[1], 'shape', ch.SystMap()(1.))
    
    # Theory rate systematics (not taken from JSON)
    for name,syst in defs.theory_rate_systs.items():
        if not name in added_theory_systs:
            added_theory_systs.append(name)
            cbWithoutQCD.AddSyst(cb, name, syst[0], syst[1])

        
    ### QCD systematics: add a lnN for each bin using the ratio QCD_subtr/QCD_est in the VR
    if options.QCD_systs:
        print('-- Will apply bin-by-bin uncertainties on QCD estimate from ratio in VR --')
        if options.fit_mode == 'shape_CR1':
            for i in range(1, Nbins+1):
                # lnN = 1 + abs(1 - QCD_VR_ratios[i-1])
                ratio = QCD_VR_ratios[i-1]
                lnN = ratio if ratio > 1 else 1./ratio
                cb.cp().bin(['SR']).process(['QCD_bin_{}'.format(i)]).AddSyst(cb, 'QCD_shape_bin_{}'.format(i), 'lnN', ch.SystMap()(lnN))
        elif options.fit_mode == 'abcd':
            # using max
            # QCD_VR_ratios = [1.1047956681135658, 1.104982852935791, 1.0103355569221637, 1.0365746040205628, 1.027778957040471, 1.1635257239763037, 1.0604289770126343, 1.0326651334762573, 1.0882024148481384, 1.0879310369491577, 1.2372238755691953, 1.1039656400680542, 1.1208300590515137, 1.1252394914627075, 1.0652162084238805, 1.1746360299507677, 1.1441897907967598, 1.032749056816101, 1.1105864995541361, 1.264707088470459, 1.1289979219436646, 1.1032386479572462, 1.3740112781524658, 1.0779788494110107, 1.0679041983173836, 1.1521316766738892, 1.0189466861549783, 1.1371627554677426, 1.180934637513623, 1.0807719230651855, 1.1220710277557373, 1.2163840919860773, 1.1803903579711914, 1.1331188470149183, 1.2841500043869019, 1.124382576013972, 1.2853591442108154, 1.1161022064238948, 1.0491153764429137, 1.3020191192626953, 1.6365387568006153, 1.3135310411453247, 1.183979775003691, 1.3237843031833378, 1.105936050415039, 1.4582525497144114, 1.2740960121154785, 1.1744883060455322, 1.2689180716203021, 1.5666807889938354, 1.1884409189224243, 1.6787212785213594, 1.1295689911887752, 1.2143068313598633, 1.144478440284729]
            # using geometric average
            QCD_VR_ratios = [1.0556093647141687, 1.0658984862062695, 1.0057472468756388, 1.0208612636340562, 1.0185833946498413, 1.1211169739938442, 1.0353973123690785, 1.0258664065695766, 1.0586147959018684, 1.0522305760086619, 1.1354690006073973, 1.072695547895069, 1.0799492240063984, 1.0621373200388462, 1.0593700756267987, 1.1529412209016232, 1.122536304991689, 1.0187320772559685, 1.0972767308832914, 1.175709681780302, 1.0832093989858067, 1.0823283151259013, 1.1831016555993352, 1.054608634579664, 1.0599488955753065, 1.0752925245754967, 1.017269399510584, 1.122209514629158, 1.1702168450787551, 1.0695165830450506, 1.0857979999559528, 1.2041393773004465, 1.1151294041413826, 1.1230274391829085, 1.2502545040629076, 1.1070056845911258, 1.139110776895264, 1.082765772887927, 1.0487710649869804, 1.2332536614187524, 1.4655095128617284, 1.19038044691305, 1.1104215756611893, 1.1838495100927606, 1.0880046566588846, 1.4004062409319984, 1.248629899444753, 1.1411489734003788, 1.1805956668619682, 1.4378115712379096, 1.129952938278906, 1.3437817991926544, 1.0912141233598036, 1.1453139866153634, 1.1135893789689448]
            for i in range(1, Nbins+1):
                lnN = 1.05
                # lnN = QCD_VR_ratios[i-1]
                cb.cp().bin(['SR']).process(['QCD_bin_{}'.format(i)]).AddSyst(cb, 'QCD_shape_bin_{}'.format(i), 'lnN', ch.SystMap()(lnN))
            # cb.cp().process(['ttlf']).AddSyst(cb, 'ttlf_norm', 'lnN', ch.SystMap()(1.2))


    extraStrForQCD = ''
    # To define nuisance group with all QCD parameters
    paramListQCD = []
    
    if options.fit_mode == 'shape_CR1':
        ### QCD estimate: fit shape from CR1, normalisation floating
        extraStrForQCD += 'scale_ratio_QCD_CR1_SR extArg 1. [0.,2.]\n'
        paramListQCD.append('scale_ratio_QCD_CR1_SR')
        
        for i in range(1, Nbins+1):
            extraStrForQCD += 'yield_QCD_SR_bin_{0} rateParam SR QCD_bin_{0} 1. [0.,2.]\n'.format(i)
            paramListQCD.append('yield_QCD_SR_bin_{}'.format(i))
    
        for i in range(1, Nbins+1):
            extraStrForQCD += 'yield_QCD_CR1_bin_{0} rateParam CR1 QCD_bin_{0} (@0*@1) scale_ratio_QCD_CR1_SR,yield_QCD_SR_bin_{0}\n'.format(i)
        
        if options.QCD_systs:
            for i in range(1, Nbins+1):
                paramListQCD.append('QCD_shape_bin_{}'.format(i))
    
    elif options.fit_mode == 'abcd':
        ### QCD estimate: add the rate params for each bin in the CR1, CR2 and VR
        ### The yield in the SR is then expressed as CR1*VR/CR2
        for i in range(1, Nbins+1):
            extraStrForQCD += 'yield_QCD_CR1_bin_{0} rateParam CR1 QCD_bin_{0} 1. [0.,5.]\n'.format(i)
            extraStrForQCD += 'yield_QCD_CR2_bin_{0} rateParam CR2 QCD_bin_{0} 1. [0.,5.]\n'.format(i)
            extraStrForQCD += 'yield_QCD_VR_bin_{0} rateParam VR QCD_bin_{0} 1. [0.,5.]\n'.format(i)
        
            extraStrForQCD += 'yield_QCD_SR_bin_{0} rateParam SR QCD_bin_{0} (@0*@1/@2) yield_QCD_VR_bin_{0},yield_QCD_CR1_bin_{0},yield_QCD_CR2_bin_{0}\n'.format(i)
            
            paramListQCD.append('yield_QCD_CR1_bin_{}'.format(i))
            paramListQCD.append('yield_QCD_CR2_bin_{}'.format(i))
            paramListQCD.append('yield_QCD_VR_bin_{}'.format(i))
    
    cb.AddDatacardLineAtEnd(extraStrForQCD)

    # Define systematic groups
    syst_groups = {
            "theory": added_theory_systs,
            "exp": added_exp_systs,
            "QCD": paramListQCD,
            "extern": defs.externalised_nuisances,
        }

    def getNuisanceGroupString(groups):
        m_str = ""
        for g in groups:
            m_str += g + ' group = '
            for sys in groups[g]:
                m_str += sys + ' '
            m_str += '\n'
        return m_str

    cb.AddDatacardLineAtEnd(getNuisanceGroupString(syst_groups))

    cb.cp().ExtractShapes(processed_shapes, '$BIN/$PROCESS', '$BIN/$PROCESS_$SYSTEMATIC')

    if options.bbb:
        print('-- Will add bin-by-bin uncertainties for MC statistics --')
        # MC statistics - has to be done after the shapes have been extracted!
        # bbb_bkg = ch.BinByBinFactory().SetVerbosity(5)
        # bbb_bkg.SetAddThreshold(0.02).SetMergeThreshold(0.5).SetFixNorm(False)
        # bbb_bkg.MergeBinErrors(cbWithoutQCD.cp().backgrounds())
        # bbb_bkg.AddBinByBin(cbWithoutQCD.cp().backgrounds(), cb)

        # bbb_sig = ch.BinByBinFactory().SetVerbosity(5).SetFixNorm(False)
        # bbb_sig.MergeBinErrors(cbWithoutQCD.cp().signals())
        # bbb_sig.AddBinByBin(cbWithoutQCD.cp().signals(), cb)
        
        # bbb = ch.BinByBinFactory().SetVerbosity(5)
        # bbb.SetAddThreshold(0.).SetMergeThreshold(1.).SetFixNorm(False).SetPoissonErrors(True)
        # bbb.MergeBinErrors(cb.cp())
        # bbb.AddBinByBin(cb.cp(), cb)
        
        # bbb_sig = ch.BinByBinFactory().SetVerbosity(5)
        # bbb_sig.SetAddThreshold(0.).SetMergeThreshold(1.).SetFixNorm(False)
        # bbb_sig.MergeBinErrors(cb.cp().signals())
        # bbb_sig.AddBinByBin(cb.cp().signals(), cb)
        # bbb_bkg = ch.BinByBinFactory().SetVerbosity(5)
        # bbb_bkg.SetAddThreshold(0.).SetMergeThreshold(1.).SetFixNorm(False)
        # bbb_bkg.MergeBinErrors(cb.cp().backgrounds())
        # bbb_bkg.AddBinByBin(cb.cp().backgrounds(), cb)

        # Use combine internal BBB (default: BB lite, merging everything for sig & bkg separately?)
        cb.AddDatacardLineAtEnd("* autoMCStats 5000 0 1\n")
        # cb.AddDatacardLineAtEnd("* autoMCStats 10000000 0 1\n")
    
    output_dir = options.output

    if not os.path.exists(output_dir):
        os.makedirs(output_dir)

    datacard = os.path.join(output_dir, 'datacard.dat')
    output_shapes = os.path.join(output_dir, 'shapes.root')
        
    cb.WriteDatacard(datacard, output_shapes)

    initWorkSpace = """
#!/bin/bash

if [[ ! -f workspace.root ]]; then
    text2workspace.py datacard.dat -o workspace.root
fi

RMIN=0.
RMAX=5.0
NPOINTS=50
export FIT_OPT=( --freezeNuisanceGroups=extern --cminDefaultMinimizerStrategy 0 --X-rtd MINIMIZER_MaxCalls=999999999 --X-rtd MINIMIZER_analytic --robustFit 1 --cminDefaultMinimizerPrecision 1E-12 )
"""
    if options.data:
        print("-- WILL USE REAL DATA IN SR")
        initWorkSpace += 'export TOY=""\n'
    else:
        print("-- Will use Asimov toy")
        initWorkSpace += 'export TOY="-t -1"\n'

    def createScript(content, filename):
        script_path = os.path.join(output_dir, filename)
        with open(script_path, 'w') as f:
            f.write(initWorkSpace)
            f.write(content)
        # make script executable
        st = os.stat(script_path)
        os.chmod(script_path, st.st_mode | stat.S_IEXEC)

    # Script: simple fit, fit diagnostics, postfit plots, frequentist toys, goodness of fit
    script = """
combine -M MultiDimFit -d workspace.root --rMin $RMIN --rMax $RMAX --expectSignal=1 ${TOY} --saveWorkspace --algo singles --setCrossingTolerance 1E-7 "${FIT_OPT[@]}" 2>&1 | tee fit.log
#combine -M FitDiagnostics -d workspace.root --rMin $RMIN --rMax $RMAX ${TOY} --expectSignal=1 --skipBOnlyFit --saveShapes --saveNormalizations --saveWithUncertainties --plots "${FIT_OPT[@]}" 2>&1 | tee fitDiag.log
#combine -M FitDiagnostics -d workspace.root --rMin $RMIN --rMax $RMAX ${TOY} --expectSignal=1 --skipBOnlyFit --robustHesse 1 "${FIT_OPT[@]}" 2>&1 | tee fitDiag.log
#../plotCovariance.py

# frequentist toys
#combine -M MultiDimFit -d workspace.root --rMin $RMIN --rMax $RMAX --expectSignal $1 -t 1000 -n _freq_$1 --toysFrequentist "${FIT_OPT[@]}" -s -1 > freq_$1.log
#combine -M MultiDimFit -d workspace.root --rMin $RMIN --rMax $RMAX --expectSignal $1 -t 1000 -n _freqNoSyst_$1 --toysNoSystematics "${FIT_OPT[@]}" -s -1 > freqNoSyst_$1.log

# Goodness of fit
#combine -M GoodnessOfFit workspace.root --algo=saturated "${FIT_OPT[@]}" 
#parallel --gnu -j 5 -n0 combine -M GoodnessOfFit workspace.root --algo=saturated "${FIT_OPT[@]}" -t 100 -s -1 --toysFreq ::: {1..10}
#hadd higgsCombineTest.GoodnessOfFit.mH120.toys.root higgsCombineTest.GoodnessOfFit.mH120.*.root

# Postfit plots
#PostFitShapesFromWorkspace -d datacard.dat -w workspace.root -o postfit_shapes.root -m 120 -f fitDiagnostics.root:fit_s --postfit --sampling --print 2>&1 | tee postFitRates.log
"""
    createScript(script, 'do_fit.sh')


    # Script: plots of NLL vs. r for different uncertainties
    script = """
RMIN=0.5
RMAX=3.
combine -M MultiDimFit --algo grid --points $NPOINTS --rMin $RMIN --rMax $RMAX ${TOY} --expectSignal=1 -n _nominal workspace.root "${FIT_OPT[@]}"
# stat-only: get best-fit parameters and dataset from saved workspace (so that it also works for post-fit)
combine -M MultiDimFit --algo grid --points $NPOINTS --rMin $RMIN --rMax $RMAX -n _stat -S 0 --snapshotName "MultiDimFit" -d higgsCombineTest.MultiDimFit.mH120.root "${FIT_OPT[@]}"

plot1DScan.py higgsCombine_nominal.MultiDimFit.mH120.root --others 'higgsCombine_stat.MultiDimFit.mH120.root:Freeze all:2' --breakdown syst,stat
    """
    createScript(script, 'do_DeltaNLL_plot.sh')


    # Script: impacts signal injected
    script = """
folder=impacts
mkdir ${folder}
pushd ${folder}

combineTool.py -M Impacts -d ../workspace.root ${TOY} -m 120 --rMin $RMIN --rMax $RMAX --expectSignal=1 --doInitialFit "${FIT_OPT[@]}"
combineTool.py -M Impacts -d ../workspace.root ${TOY} -m 120 --rMin $RMIN --rMax $RMAX --expectSignal=1 --doFits --parallel 6 "${FIT_OPT[@]}" --setParameterRanges CMS_qg_Weight=-2,2 --cminPreScan
combineTool.py -M Impacts -d ../workspace.root -m 120 -o impacts.json
plotImpacts.py -i impacts.json -o impacts
plotImpacts.py -i impacts.json -o impacts_qcd --groups QCD
plotImpacts.py -i impacts.json -o impacts_no_qcd --groups '!QCD' '!extern'

popd
    """
    createScript(script, 'do_impacts.sh')


    # Script: plots of NLL vs. nuisance parameters
    script = """
function scan_param() {{
    combine -M MultiDimFit --algo grid --points 20 -n _$1 --snapshotName "MultiDimFit" -d ../higgsCombineTest.MultiDimFit.mH120.root --setParameterRanges r=0,3:$1={scan} -P $1 "${{FIT_OPT[@]}}" --floatOtherPOIs 1
    plot1DScan.py higgsCombine_$1.MultiDimFit.mH120.root --output scan_$1 --POI $1
 
    combine -M MultiDimFit --algo grid --points 20 -n _freeze_$1 --snapshotName "MultiDimFit" -d ../higgsCombineTest.MultiDimFit.mH120.root --setParameterRanges r=0,3:$1={scan} -P $1 "${{FIT_OPT[@]}}" -S 0 --floatOtherPOIs 1
    plot1DScan.py higgsCombine_freeze_$1.MultiDimFit.mH120.root --output scan_freeze_$1 --POI $1
    
    combine -M MultiDimFit --algo grid --points 20 -n _freezeQCD_$1 --snapshotName "MultiDimFit" -d ../higgsCombineTest.MultiDimFit.mH120.root --setParameterRanges r=0,3:$1={scan} -P $1 --freezeNuisanceGroups extern,QCD --floatOtherPOIs 1
    plot1DScan.py higgsCombine_freezeQCD_$1.MultiDimFit.mH120.root --output scan_freezeQCD_$1 --POI $1
}}
export -f scan_param # needed for parallel

mkdir scans
pushd scans
SHELL=/bin/bash parallel --gnu -j 6 scan_param ::: {params}
popd
"""
    createScript(script.format(scan="-2,2", params=" ".join(syst_groups['exp'])), 'do_exp_scans.sh')
    createScript(script.format(scan="-2,2", params=" ".join(syst_groups['theory'])), 'do_theory_scans.sh')
    
    script = """
function scan_param() {{
    combine -M MultiDimFit --algo grid --points 20 -n _$1 --snapshotName "MultiDimFit" -d ../higgsCombineTest.MultiDimFit.mH120.root --setParameterRanges r=0,3 -P $1 --autoRange 3 "${{FIT_OPT[@]}}" --floatOtherPOIs 1
    plot1DScan.py higgsCombine_$1.MultiDimFit.mH120.root --output scan_$1 --POI $1
    
    combine -M MultiDimFit --algo grid --points 20 -n _freeze_$1 --snapshotName "MultiDimFit" -d ../higgsCombineTest.MultiDimFit.mH120.root --setParameterRanges r=0,3 -P $1 --autoRange 3 "${{FIT_OPT[@]}}" -S 0 --floatOtherPOIs 1
    plot1DScan.py higgsCombine_freeze_$1.MultiDimFit.mH120.root --output scan_freeze_$1 --POI $1
}}
export -f scan_param # needed for parallel

mkdir scans
pushd scans
SHELL=/bin/bash parallel --gnu -j 6 scan_param ::: {params}
popd
"""
    createScript(script.format(params=" ".join(syst_groups['QCD'])), 'do_QCD_scans.sh')
コード例 #23
0
ファイル: preparettH.py プロジェクト: senka/HTT_20162017
           ('param_mB', '.*hbb', 1.014), ('param_mC', '.*hcc', 1.062),
           ('HiggsDecayWidthTHU_hqq', '.*h(ww|zz|gg|tt|zg|mm|gluglu)', 0.988),
           ('HiggsDecayWidthTHU_hqq', '.*h(bb|cc)', 1.008),
           ('HiggsDecayWidthTHU_hvv', '.*h(ww|zz)', 1.004),
           ('HiggsDecayWidthTHU_hll', '.*h(tt|mm)', 1.019),
           ('HiggsDecayWidthTHU_hgg', '.*hgg', 1.010),
           ('HiggsDecayWidthTHU_hzg', '.*hzg', 1.051),
           ('HiggsDecayWidthTHU_hgluglu', '.*hgluglu', 1.028)]

if add_BRs:
    cb.syst_name(['CMS_hgg_BR'],
                 False)  # drop existing ones added by the analysts
    cb.SetVerbosity(3)
    for entry in br_list:
        cb.cp().signals().process([entry[1]]).AddSyst(cb, entry[0], 'lnN',
                                                      ch.SystMap()(entry[2]))
    cb.SetVerbosity(0)

sig_procs_in_bins = defaultdict(set)

print '>> Signal processes: '
pprint.pprint(cb.cp().signals().process_set(), indent=4)

for p in cb.cp().signals().process_set():
    for b in cb.cp().process(
        [p]).SetFromProcs(lambda x: (x.channel(), x.bin())):
        sig_procs_in_bins[p].add(b)

print '>> Signal processes in bins: '
pprint.pprint(dict(sig_procs_in_bins), indent=4)
コード例 #24
0
        backgrounds = mc_backgrounds + data_driven_backgrounds
        signals = ['ZL']

        categories = {
            'mutau': [(1, 'Pass'), (2, 'Fail')],
        }

        cb.AddObservations(['*'], ['MuTauFR'], ['2018'], ['mutau'],
                           categories['mutau'])  # adding observed data
        cb.AddProcesses(['*'], ['MuTauFR'], ['2018'], ['mutau'], backgrounds,
                        categories['mutau'], False)  # adding backgrounds
        cb.AddProcesses(['*'], ['MuTauFR'], ['2018'], ['mutau'], signals,
                        categories['mutau'], True)  # adding signals

        cb.cp().process(mc_backgrounds).AddSyst(cb, 'lumi_2018', 'lnN',
                                                ch.SystMap()(1.026))
        cb.cp().process(mc_backgrounds).AddSyst(cb, 'muon_eff', 'lnN',
                                                ch.SystMap()(1.02))

        cb.cp().process(['TTT', 'TTL', 'TTJ',
                         'ST']).AddSyst(cb, 'xsec_top', 'lnN',
                                        ch.SystMap()(1.10))
        cb.cp().process(['VV']).AddSyst(cb, 'xsec_vv', 'lnN',
                                        ch.SystMap()(1.15))
        cb.cp().process(['ZL', 'ZTT', 'ZJ']).AddSyst(cb, 'xsec_z', 'lnN',
                                                     ch.SystMap()(1.03))
        cb.cp().process(['W']).AddSyst(cb, 'w_estimation', 'lnN',
                                       ch.SystMap()(1.20))
        cb.cp().process(['ZJ', 'TTJ']).AddSyst(cb, 'jet_to_tauFR', 'lnN',
                                               ch.SystMap()(1.30))
        cb.cp().process(['QCD']).AddSyst(cb, 'ss_to_os_extrap', 'lnN',
コード例 #25
0
def prepareShapes(backgrounds, signals, discriminant, discriminantName):
    # Backgrounds is a list of string of the considered backgrounds corresponding to entries in processes_mapping
    # Signals is a list of string of the considered signals corresponding to entries in processes_mapping
    # discriminant is the corresponding entry in the dictionary discriminants

    import CombineHarvester.CombineTools.ch as ch
    root_path = options.root_path

    file, systematics = prepareFile(processes_mapping, discriminants,
                                    root_path, discriminantName)
    if options.dataYear != '2016':
        call([
            'python', 'symmetrize.py', options.output, file, options.dataYear
        ],
             shell=False)

    for signal in signals:
        cb = ch.CombineHarvester()
        cb.AddObservations(['*'], [''], ['_%s' % options.dataYear], [''],
                           discriminant)
        cb.AddProcesses(['*'], [''], ['_%s' % options.dataYear], [''],
                        [signal], discriminant, True)
        #cb.AddProcesses(['*'], [''], ['_%s'%options.dataYear], [''], backgrounds, discriminant, False)
        if options.dataYear == '2016':
            cb.AddProcesses(['*'], [''], ['_%s' % options.dataYear], [''],
                            backgrounds, discriminant, False)
        else:
            if not 'b2j3' in discriminantName:
                try:
                    backgrounds.remove('qcd')
                except:
                    pass
            else:
                if not 'qcd' in backgrounds: backgrounds.append('qcd')
            if 'all' in discriminantName:
                if signal == 'Hut':
                    discriminant.remove((1, 'DNN_Hut_b2j3'))
                    cb.AddProcesses(['*'], [''], ['_%s' % options.dataYear],
                                    [''], backgrounds + ['qcd'],
                                    [(1, 'DNN_Hut_b2j3')], False)
                else:
                    discriminant.remove((1, 'DNN_Hct_b2j3'))
                    cb.AddProcesses(['*'], [''], ['_%s' % options.dataYear],
                                    [''], backgrounds + ['qcd'],
                                    [(1, 'DNN_Hct_b2j3')], False)
                cb.AddProcesses(['*'], [''], ['_%s' % options.dataYear], [''],
                                backgrounds, discriminant, False)
                if signal == 'Hut': discriminant.append((1, 'DNN_Hut_b2j3'))
                else: discriminant.append((1, 'DNN_Hct_b2j3'))
            else:
                cb.AddProcesses(['*'], [''], ['_%s' % options.dataYear], [''],
                                backgrounds, discriminant, False)

        # Systematics
        if not options.nosys:
            for systematic in systematics:
                systematic_only_for_SMtt = False
                systematic_only_for_Sig = False

                for systSMtt in options.sysForSMtt:
                    if CMSNamingConvention(systSMtt) == systematic:
                        systematic_only_for_SMtt = True
                for systSig in options.sysForSig:
                    if CMSNamingConvention(systSig) == systematic:
                        systematic_only_for_Sig = True

                if not systematic_only_for_SMtt and not systematic_only_for_Sig:
                    cb.cp().AddSyst(cb, systematic, 'shape',
                                    ch.SystMap()(1.00))
                elif systematic_only_for_SMtt and not systematic_only_for_Sig:
                    cb.cp().AddSyst(cb, systematic, 'shape',
                                    ch.SystMap('process')(smTTlist, 1.00))
                    #if 'hdamp' in systematic:
                    #    for i in xrange(len(discriminant)):
                    #        if 'b2j3' in discriminant[i][1]:
                    #            cb.cp().AddSyst(cb, systematic, 'shape', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttlf'], 1.00))
                    #            cb.cp().AddSyst(cb, systematic, 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb','ttcc'], 1.05))
                    #        elif 'b2j4' in discriminant[i][1]:
                    #            cb.cp().AddSyst(cb, systematic, 'shape', ch.SystMap('bin', 'process')([discriminant[i][1]], smTTlist, 1.00))
                    #        elif 'b3j3' in discriminant[i][1]:
                    #            cb.cp().AddSyst(cb, systematic, 'shape', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttlf'], 1.00))
                    #            cb.cp().AddSyst(cb, systematic, 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb','ttcc'], 1.05))
                    #        elif 'b3j4' in discriminant[i][1]:
                    #            cb.cp().AddSyst(cb, systematic, 'shape', ch.SystMap('bin', 'process')([discriminant[i][1]], smTTlist, 1.00))
                    #        elif 'b4j4' in discriminant[i][1]:
                    #            cb.cp().AddSyst(cb, systematic, 'shape', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb'], 1.00))
                    #            cb.cp().AddSyst(cb, systematic, 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttcc','ttlf'], 1.05))
                    #else: cb.cp().AddSyst(cb, systematic, 'shape', ch.SystMap('process')(smTTlist, 1.00))
                elif not systematic_only_for_SMtt and systematic_only_for_Sig:
                    cb.cp().AddSyst(cb, systematic, 'shape',
                                    ch.SystMap('process')([signal], 1.00))
                else:
                    cb.cp().AddSyst(
                        cb, systematic, 'shape',
                        ch.SystMap('process')(smTTlist + [signal], 1.00))

            #Lumi corr. https://twiki.cern.ch/twiki/bin/view/CMS/TWikiLUM#LumiComb
            #cb.cp().AddSyst(cb, 'CMS_lumi', 'lnN', ch.SystMap()(options.luminosityError))
            if options.dataYear == '2016':
                cb.cp().AddSyst(cb, 'CMS_lumi_uncorr_2016', 'lnN',
                                ch.SystMap()(1.01))
                cb.cp().AddSyst(cb, 'CMS_lumi_corr_161718', 'lnN',
                                ch.SystMap()(1.006))
                #reproducing 2016
                #cb.cp().AddSyst(cb, 'CMS_lumi_uncorr_2016', 'lnN', ch.SystMap()(1.027))
            elif options.dataYear == '2017':
                cb.cp().AddSyst(cb, 'CMS_lumi_uncorr_2017', 'lnN',
                                ch.SystMap()(1.02))
                cb.cp().AddSyst(cb, 'CMS_lumi_corr_161718', 'lnN',
                                ch.SystMap()(1.009))
                cb.cp().AddSyst(cb, 'CMS_lumi_corr_1718', 'lnN',
                                ch.SystMap()(1.006))
            elif options.dataYear == '2018':
                cb.cp().AddSyst(cb, 'CMS_lumi_uncorr_2018', 'lnN',
                                ch.SystMap()(1.015))
                cb.cp().AddSyst(cb, 'CMS_lumi_corr_161718', 'lnN',
                                ch.SystMap()(1.02))
                cb.cp().AddSyst(cb, 'CMS_lumi_corr_1718', 'lnN',
                                ch.SystMap()(1.002))

            cb.cp().AddSyst(
                cb, 'tt_xsec', 'lnN',
                ch.SystMap('process')(['ttbb', 'ttcc', 'ttlf'], 1.055))
            cb.cp().AddSyst(cb, 'Other_xsec', 'lnN',
                            ch.SystMap('process')(['other'], 1.1))
            #cb.cp().AddSyst(cb, 'hdamp', 'lnN', ch.SystMap('process')(smTTlist, 1.05))
            #cb.cp().AddSyst(cb, 'TuneCP5', 'lnN', ch.SystMap('process')(smTTlist, 1.03))

            for i in xrange(len(discriminant)):
                if 'b2j3' in discriminant[i][1]:
                    cb.cp().AddSyst(cb, '$PROCESS_norm', 'lnN',
                                    ch.SystMap('process')(['qcd'], 1.5))
                #reproducing 2016 ### comment out Other_xsec above!
                #if 'b2j3' in discriminant[i][1]: cb.cp().AddSyst(cb, 'Other_xsec_b2j3', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['other'], 1.1))
                #if 'b2j4' in discriminant[i][1]: cb.cp().AddSyst(cb, 'Other_xsec_b2j4', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['other'], 1.1))
                #if 'b3j3' in discriminant[i][1]: cb.cp().AddSyst(cb, 'Other_xsec_b3j3', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['other'], 1.1))
                #if 'b3j4' in discriminant[i][1]: cb.cp().AddSyst(cb, 'Other_xsec_b3j4', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['other'], 1.1))
                #if 'b4j4' in discriminant[i][1]: cb.cp().AddSyst(cb, 'Other_xsec_b4j4', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['other'], 1.1))

            if options.dataYear == '2016':
                #reproducing 2016
                #cb.cp().AddSyst(cb, 'hdamp_2016', 'lnN', ch.SystMap('process')(['ttbb', 'ttcc', 'ttlf'], 1.05))
                #cb.cp().AddSyst(cb, 'scale_2016', 'lnN', ch.SystMap('process')(['ttbb', 'ttcc', 'ttlf'], 1.15))
                #for i in xrange(len(discriminant)):
                #    if 'j3' in discriminant[i][1]:
                #        cb.cp().AddSyst(cb, '$PROCESS_norm_j3', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb'], 1.5))
                #        cb.cp().AddSyst(cb, '$PROCESS_norm_j3', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttcc'], 1.5))
                #        cb.cp().AddSyst(cb, 'jec_2016', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb', 'ttcc', 'ttlf', 'other', signal], 1.01))
                #    else:
                #        cb.cp().AddSyst(cb, '$PROCESS_norm_j4', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb'], 1.5))
                #        cb.cp().AddSyst(cb, '$PROCESS_norm_j4', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttcc'], 1.5))
                #        cb.cp().AddSyst(cb, 'jec_2016', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb', 'ttcc', 'ttlf', 'other', signal], 1.05))#1.05 for j4
                for i in xrange(len(discriminant)):
                    if 'b2' in discriminant[i][1]:
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b2_2016', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttbb'], 1.3))
                        #cb.cp().AddSyst(cb, '$PROCESS_norm_b2_2016', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttcc'], 1.5))
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b2', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttcc'], 1.5))
                    elif 'b3' in discriminant[i][1]:
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b3_2016', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttbb'], 1.3))
                        #cb.cp().AddSyst(cb, '$PROCESS_norm_b3_2016', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttcc'], 1.5))
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b3', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttcc'], 1.5))
                    elif 'b4' in discriminant[i][1]:
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b4_2016', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttbb'], 1.3))
                        #cb.cp().AddSyst(cb, '$PROCESS_norm_b4_2016', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttcc'], 1.5))
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b4', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttcc'], 1.5))
            else:
                for i in xrange(len(discriminant)):
                    if 'b2' in discriminant[i][1]:
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b2', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttbb'], 1.2))
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b2', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttcc'], 1.5))
                    elif 'b3' in discriminant[i][1]:
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b3', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttbb'], 1.22))
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b3', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttcc'], 1.5))
                    elif 'b4' in discriminant[i][1]:
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b4', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttbb'], 1.2))
                        cb.cp().AddSyst(
                            cb, '$PROCESS_norm_b4', 'lnN',
                            ch.SystMap('bin', 'process')([discriminant[i][1]],
                                                         ['ttcc'], 1.5))

                #if 'j3' in discriminant[i][1]:
                #    #cb.cp().AddSyst(cb, '$PROCESS_norm_j3', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb'], 1.5))
                #    cb.cp().AddSyst(cb, '$PROCESS_norm_j3', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb'], 1.3))
                #    cb.cp().AddSyst(cb, '$PROCESS_norm_j3', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttcc'], 1.5))
                #else:
                #    #cb.cp().AddSyst(cb, '$PROCESS_norm_j4', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb'], 1.5))
                #    cb.cp().AddSyst(cb, '$PROCESS_norm_j4', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttbb'], 1.3))
                #    cb.cp().AddSyst(cb, '$PROCESS_norm_j4', 'lnN', ch.SystMap('bin', 'process')([discriminant[i][1]], ['ttcc'], 1.5))

        # Import shapes from ROOT file
        cb.cp().backgrounds().ExtractShapes(file, '$BIN/$PROCESS',
                                            '$BIN/$PROCESS__$SYSTEMATIC')
        cb.cp().signals().ExtractShapes(file, '$BIN/$PROCESS',
                                        '$BIN/$PROCESS__$SYSTEMATIC')

        #reproducing 2016 - comment out
        if options.dataYear == '2016':
            rebin = ch.AutoRebin().SetBinThreshold(100).SetBinUncertFraction(
                0.1)
            rebin.Rebin(cb.cp(), cb)

        #elif options.dataYear == '2017':
        #    #rebin_b2j3 = ch.AutoRebin().SetBinThreshold(5400)#.SetBinUncertFraction(0.1)
        #    #rebin_b2j3.Rebin(cb.cp().bin(["DNN_Hut_b2j3", "DNN_Hct_b2j3"]), cb)

        #AutoMCStat
        cb.SetAutoMCStats(cb, 0.1)
        #reproducing 2016
        #print "Treating bbb"
        #bbb = ch.BinByBinFactory()
        #bbb.SetAddThreshold(0.0001)
        #bbb.AddBinByBin(cb.cp().backgrounds(), cb)
        #bbb.AddBinByBin(cb.cp().signals(), cb)

        output_prefix = 'FCNC_%s_Discriminant_%s' % (signal, discriminantName)

        output_dir = os.path.join(options.output, '%s' % (signal))
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        fake_mass = '125'

        # Write card
        datacard = os.path.join(output_dir, output_prefix + '.dat')
        cb.cp().mass([fake_mass, "*"]).WriteDatacard(
            os.path.join(output_dir, output_prefix + '.dat'),
            os.path.join(output_dir, output_prefix + '_shapes.root'))

        # Write small script to compute the limit
        workspace_file = os.path.basename(
            os.path.join(output_dir,
                         output_prefix + '_combine_workspace.root'))
        script = """#! /bin/bash

text2workspace.py {datacard} -m {fake_mass} -o {workspace_root}

# Run limit

echo combine -M AsymptoticLimits -n {name} {workspace_root} -S {systematics} #--run blind #-v +2
#combine -M AsymptoticLimits -n {name} {workspace_root} -S {systematics} #--run expected #-v +2
combine -M AsymptoticLimits -n {name} {workspace_root} -S {systematics} #--run blind #-v +2
#combine -H AsymptoticLimits -M HybridNew -n {name} {workspace_root} -S {systematics} --LHCmode LHC-limits --expectedFromGrid 0.5 #for ecpected, use 0.84 and 0.16
""".format(workspace_root=workspace_file,
           datacard=os.path.basename(datacard),
           name=output_prefix,
           fake_mass=fake_mass,
           systematics=(0 if options.nosys else 1))
        script_file = os.path.join(output_dir,
                                   output_prefix + '_run_limits.sh')
        with open(script_file, 'w') as f:
            f.write(script)

        st = os.stat(script_file)
        os.chmod(script_file, st.st_mode | stat.S_IEXEC)

        # Write small script for datacard checks
        script = """#! /bin/bash

# Run checks
echo combine -M FitDiagnostics -t -1 --expectSignal 0 {datacard} -n fitDiagnostics_{name}_bkgOnly -m 125 --robustHesse 1 --robustFit=1 --rMin -20 --rMax 20 #--plots
echo python ../../../../HiggsAnalysis/CombinedLimit/test/diffNuisances.py -a fitDiagnostics_{name}_bkgOnly.root -g fitDiagnostics_{name}_bkgOnly_plots.root
combine -M FitDiagnostics -t -1 --expectSignal 0 {datacard} -n _{name}_bkgOnly -m 125 --robustHesse 1 --robustFit=1 --rMin -20 --rMax 20 #--plots
python ../../../../HiggsAnalysis/CombinedLimit/test/diffNuisances.py -a fitDiagnostics_{name}_bkgOnly.root -g fitDiagnostics_{name}_bkgOnly_plots.root --skipFitS > fitDiagnostics_{name}_bkgOnly.log
python ../../printPulls.py fitDiagnostics_{name}_bkgOnly_plots.root
combine -M FitDiagnostics -t -1 --expectSignal 1 {datacard} -n _{name}_bkgPlusSig -m 125 --robustHesse 1 --robustFit=1 --rMin -20 --rMax 20 #--plots
python ../../../../HiggsAnalysis/CombinedLimit/test/diffNuisances.py -a fitDiagnostics_{name}_bkgPlusSig.root -g fitDiagnostics_{name}_bkgPlusSig_plots.root --skipFitB > fitDiagnostics_{name}_bkgPlusSig.log
python ../../printPulls.py fitDiagnostics_{name}_bkgPlusSig_plots.root

#print NLL for check
combineTool.py -M FastScan -w {name}_combine_workspace.root:w -o {name}_nll
""".format(workspace_root=workspace_file,
           datacard=os.path.basename(datacard),
           name=output_prefix,
           fake_mass=fake_mass,
           systematics=(0 if options.nosys else 1))
        script_file = os.path.join(output_dir,
                                   output_prefix + '_run_closureChecks.sh')
        with open(script_file, 'w') as f:
            f.write(script)

        st = os.stat(script_file)
        os.chmod(script_file, st.st_mode | stat.S_IEXEC)

        # Write small script for impacts
        script = """#! /bin/bash

# Run impacts
combineTool.py -M Impacts -d {name}_combine_workspace.root -m 125 --doInitialFit --robustFit=1 --robustHesse 1 --rMin -20 --rMax 20 -t -1
combineTool.py -M Impacts -d {name}_combine_workspace.root -m 125 --robustFit=1 --robustHesse 1 --doFits --rMin -20 --rMax 20 -t -1 --parallel 32
combineTool.py -M Impacts -d {name}_combine_workspace.root -m 125 -o {name}_expected_impacts.json --rMin -20 --rMax 20 -t -1
plotImpacts.py -i {name}_expected_impacts.json -o {name}_expected_impacts --per-page 50

combineTool.py -M Impacts -d {name}_combine_workspace.root -m 125 --doInitialFit --robustFit=1 --robustHesse 1 --rMin -20 --rMax 20
combineTool.py -M Impacts -d {name}_combine_workspace.root -m 125 --robustFit=1 --doFits --robustHesse 1 --rMin -20 --rMax 20 --parallel 32
combineTool.py -M Impacts -d {name}_combine_workspace.root -m 125 -o {name}_impacts.json --rMin -20 --rMax 20
plotImpacts.py -i {name}_impacts.json -o {name}_impacts --per-page 50
""".format(workspace_root=workspace_file,
           datacard=os.path.basename(datacard),
           name=output_prefix,
           fake_mass=fake_mass,
           systematics=(0 if options.nosys else 1))
        script_file = os.path.join(output_dir,
                                   output_prefix + '_run_impacts.sh')
        with open(script_file, 'w') as f:
            f.write(script)

        st = os.stat(script_file)
        os.chmod(script_file, st.st_mode | stat.S_IEXEC)

        # Write small script for postfit shapes
        script = """#! /bin/bash

# Run postfit
echo combine -M FitDiagnostics {datacard} -n _{name}_postfit --saveNormalizations --saveShapes --saveWithUncertainties --preFitValue 0 --rMin -20 --rMax 20 --robustHesse 1 --robustFit=1 -v 1
combine -M FitDiagnostics {datacard} -n _{name}_postfit --saveNormalizations --saveShapes --saveWithUncertainties --preFitValue 0 --rMin -20 --rMax 20 --robustHesse 1 --robustFit=1 -v 1 #--plots
PostFitShapesFromWorkspace -w {name}_combine_workspace.root -d {datacard} -o postfit_shapes_{name}.root -f fitDiagnostics_{name}_postfit.root:fit_b --postfit --sampling
python ../../convertPostfitShapesForPlotIt.py -i postfit_shapes_{name}.root
$CMSSW_BASE/src/UserCode/HEPToolsFCNC/plotIt/plotIt -o postfit_shapes_{name}_forPlotIt ../../postfit_plotIt_config_{coupling}_{year}.yml -y
$CMSSW_BASE/src/UserCode/HEPToolsFCNC/plotIt/plotIt -o postfit_shapes_{name}_forPlotIt ../../postfit_plotIt_config_{coupling}_{year}_qcd.yml -y
""".format(workspace_root=workspace_file,
           datacard=os.path.basename(datacard),
           name=output_prefix,
           fake_mass=fake_mass,
           systematics=(0 if options.nosys else 1),
           coupling=("Hut" if "Hut" in output_prefix else "Hct"),
           year=options.dataYear)
        script_file = os.path.join(output_dir,
                                   output_prefix + '_run_postfit.sh')
        with open(script_file, 'w') as f:
            f.write(script)

        st = os.stat(script_file)
        os.chmod(script_file, st.st_mode | stat.S_IEXEC)
コード例 #26
0
ファイル: setupDatacards.py プロジェクト: senka/HTT_AC_81X
    cb.AddObservations(['*'], ana, era, [chn], bins[chn])
    cb.AddProcesses(['*'], ana, era, [chn], bkg_procs[chn], bins[chn], False)
    cb.AddProcesses(['*'], ana, era, [chn], sig_procs, bins[chn], True)

#####################################################################################
# Define systematic uncertainties
#####################################################################################
# define some useful shortcuts
real_m = ['ZTT', 'ZLL', 'ZL', 'ZJ', 'TT', 'VV']  # procs with a real muon
real_e = ['ZTT', 'ZLL', 'ZL', 'ZJ', 'TT', 'VV']  # procs with a real electron

constrain_eff_t = False

cb.cp().AddSyst(
    cb, 'CMS_eff_m', 'lnN',
    ch.SystMap('channel', 'process')(['mt'], real_m,
                                     1.03)(['em'], real_m + ['W'], 1.03))

cb.cp().AddSyst(
    cb, 'CMS_eff_e', 'lnN',
    ch.SystMap('channel', 'process')(['et'], real_e,
                                     1.03)(['em'], real_e + ['W'], 1.03))

# Only create the eff_t lnN if we want this to be constrained,
# otherwise set a rateParam.
# Split tau ID efficiency uncertainty into part ("CMS_eff_t") that is correlated between channels
# and part ("CMS_eff_t_et", "CMS_eff_t_mt", "CMS_eff_t_tt") that is uncorrelated
if constrain_eff_t:
    cb.cp().AddSyst(
        cb, 'CMS_eff_t', 'lnN',
        ch.SystMap('channel', 'process')(['et', 'mt'], ['ZTT', 'TT', 'VV'],
                                         1.05)(['tt'], ['ZTT', 'TT', 'VV'],
コード例 #27
0
    def __init__(self,
                 higgs_masses=["125"],
                 useRateParam=False,
                 year="",
                 cb=None):
        super(SMHttDatacards, self).__init__(cb)

        if cb is None:
            signal_processes = ["ggH", "qqH", "WH", "ZH"]

            # ======================================================================
            # MT channel
            self.add_processes(
                channel="mt",
                categories=Categories.CategoriesDict().getCategories(["mt"
                                                                      ])["mt"],
                bkg_processes=[
                    "ZTT", "ZL", "ZJ", "TTT", "TTJJ", "VV", "W", "QCD"
                ],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=higgs_masses)

            # efficiencies
            # (hopefully) temporary fix
            if year == "2016":
                self.cb.cp().channel(["mt"]).process([
                    "ZTT", "ZLL", "ZL", "ZJ", "TTTT", "TTJJ", "VV"
                ]).AddSyst(self.cb, *self.muon_efficiency2016_syst_args)
                self.cb.cp().channel(["mt"]).signals().AddSyst(
                    self.cb, *self.muon_efficiency2016_syst_args)
                self.cb.cp().channel(["mt"]).process([
                    "ZTT", "TTT", "TTJJ", "VV"
                ]).AddSyst(self.cb, *self.tau_efficiency2016_syst_args)
                self.cb.cp().channel(["mt"]).signals().AddSyst(
                    self.cb, *self.tau_efficiency2016_syst_args)
            else:
                self.cb.cp().channel(["mt"]).process(
                    ["ZTT", "ZLL", "ZL", "ZJ", "TTTT", "TTJJ",
                     "VV"]).AddSyst(self.cb, *self.muon_efficiency_syst_args)
                self.cb.cp().channel(["mt"]).signals().AddSyst(
                    self.cb, *self.muon_efficiency_syst_args)
                self.cb.cp().channel(["mt"]).process(
                    ["ZTT", "TTT",
                     "VV"]).AddSyst(self.cb, *self.tau_efficiency_syst_args)
                self.cb.cp().channel(["mt"]).signals().AddSyst(
                    self.cb, *self.tau_efficiency_syst_args)

            # Tau ES
            self.cb.cp().channel(["mt"]).process(["ZTT", "TTJJ"]).AddSyst(
                self.cb, *self.tau_es_syst_args)
            self.cb.cp().channel(["mt"
                                  ]).signals().AddSyst(self.cb,
                                                       *self.tau_es_syst_args)

            # fake-rate
            if year == "2016":
                self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                    self.cb, *self.muFakeTau2016_syst_args)
            else:
                self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                    self.cb, *self.muFakeTau_syst_args)

            if useRateParam:
                for category in Categories.CategoriesDict().getCategories(
                    ["mt"], False)["mt"]:
                    self.cb.cp().channel(["mt"]).bin([
                        "mt_" + category
                    ]).process(["ZTT"]).AddSyst(self.cb,
                                                "n_zll_" + category + "_norm",
                                                "rateParam",
                                                ch.SystMap()(1.0))

            # B-Tag
            #self.cb.cp().channel(["mt"]).process(["ZTT", "ZL", "ZJ", "TT", "VV", "W", "QCD"]).AddSyst(self.cb, *self.btag_efficiency_syst_args)
            #self.cb.cp().channel(["mt"]).signals().AddSyst(self.cb, *self.btag_efficiency_syst_args)

            #self.cb.cp().channel(["mt"]).process(["ZTT", "ZL", "ZJ", "TT", "VV", "W", "QCD"]).AddSyst(self.cb, *self.btag_mistag_syst_args)
            #self.cb.cp().channel(["mt"]).signals().AddSyst(self.cb, *self.btag_mistag_syst_args)

            # ======================================================================
            # ET channel
            self.add_processes(
                channel="et",
                categories=Categories.CategoriesDict().getCategories(["et"
                                                                      ])["et"],
                bkg_processes=[
                    "ZTT", "ZL", "ZJ", "TTT", "TTJJ", "VV", "W", "QCD"
                ],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=higgs_masses)

            # efficiencies
            # (hopefully) temporary fix
            if year == "2016":
                self.cb.cp().channel(["et"]).process([
                    "ZTT", "ZLL", "ZL", "ZJ", "TTT", "TTJJ", "VV"
                ]).AddSyst(self.cb, *self.electron_efficiency2016_syst_args)
                self.cb.cp().channel(["et"]).signals().AddSyst(
                    self.cb, *self.electron_efficiency2016_syst_args)
                self.cb.cp().channel(["et"]).process(
                    ["ZTT", "TTT",
                     "VV"]).AddSyst(self.cb,
                                    *self.tau_efficiency2016_syst_args)
                self.cb.cp().channel(["et"]).signals().AddSyst(
                    self.cb, *self.tau_efficiency2016_syst_args)
            else:
                self.cb.cp().channel(["et"]).process([
                    "ZTT", "ZLL", "ZL", "ZJ", "TTT", "TTJJ", "VV"
                ]).AddSyst(self.cb, *self.electron_efficiency_syst_args)
                self.cb.cp().channel(["et"]).signals().AddSyst(
                    self.cb, *self.electron_efficiency_syst_args)
                self.cb.cp().channel(["et"]).process(
                    ["ZTT", "TTT",
                     "VV"]).AddSyst(self.cb, *self.tau_efficiency_syst_args)
                self.cb.cp().channel(["et"]).signals().AddSyst(
                    self.cb, *self.tau_efficiency_syst_args)

            # Tau ES
            self.cb.cp().channel(["et"]).process(["ZTT"]).AddSyst(
                self.cb, *self.tau_es_syst_args)
            self.cb.cp().channel(["et"
                                  ]).signals().AddSyst(self.cb,
                                                       *self.tau_es_syst_args)

            # fake-rate
            if year == "2016":
                self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                    self.cb, *self.eFakeTau2016_syst_args)
            else:
                self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                    self.cb, *self.eFakeTau_tight_syst_args)

            if useRateParam:
                for category in Categories.CategoriesDict().getCategories(
                    ["et"], False)["et"]:
                    self.cb.cp().channel(["et"]).bin([
                        "et_" + category
                    ]).process(["ZTT"]).AddSyst(self.cb,
                                                "n_zll_" + category + "_norm",
                                                "rateParam",
                                                ch.SystMap()(1.0))

            # B-Tag
            #self.cb.cp().channel(["et"]).process(["ZTT", "ZL", "ZJ", "TT", "VV", "W", "QCD"]).AddSyst(self.cb, *self.btag_efficiency_syst_args)
            #self.cb.cp().channel(["et"]).signals().AddSyst(self.cb, *self.btag_efficiency_syst_args)

            #self.cb.cp().channel(["et"]).process(["ZTT", "ZL", "ZJ", "TT", "VV", "W", "QCD"]).AddSyst(self.cb, *self.btag_mistag_syst_args)
            #self.cb.cp().channel(["et"]).signals().AddSyst(self.cb, *self.btag_mistag_syst_args)

            # ======================================================================
            # EM channel
            self.add_processes(
                channel="em",
                categories=Categories.CategoriesDict().getCategories(["em"
                                                                      ])["em"],
                bkg_processes=["ZTT", "ZLL", "TT", "VV", "W", "QCD"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=higgs_masses)

            # efficiencies
            # (hopefully) temporary fix
            if year == "2016":
                self.cb.cp().channel(["em"]).process([
                    "ZTT", "ZLL", "ZL", "ZJ", "TT", "VV", "W"
                ]).AddSyst(self.cb, *self.electron_efficiency2016_syst_args)
                self.cb.cp().channel(["em"]).signals().AddSyst(
                    self.cb, *self.electron_efficiency2016_syst_args)

                self.cb.cp().channel(["em"]).process([
                    "ZTT", "ZLL", "ZL", "ZJ", "TT", "VV", "W"
                ]).AddSyst(self.cb, *self.muon_efficiency2016_syst_args)
                self.cb.cp().channel(["em"]).signals().AddSyst(
                    self.cb, *self.muon_efficiency2016_syst_args)
            else:
                self.cb.cp().channel(["em"]).process([
                    "ZTT", "ZLL", "ZL", "ZJ", "TT", "VV", "W"
                ]).AddSyst(self.cb, *self.electron_efficiency_syst_args)
                self.cb.cp().channel(["em"]).signals().AddSyst(
                    self.cb, *self.electron_efficiency_syst_args)

                self.cb.cp().channel(["em"]).process(
                    ["ZTT", "ZLL", "ZL", "ZJ", "TT", "VV",
                     "W"]).AddSyst(self.cb, *self.muon_efficiency_syst_args)
                self.cb.cp().channel(["em"]).signals().AddSyst(
                    self.cb, *self.muon_efficiency_syst_args)

            # B-Tag
            #self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "TT", "VV", "W", "QCD"]).AddSyst(self.cb, *self.btag_efficiency_syst_args)
            #self.cb.cp().channel(["em"]).signals().AddSyst(self.cb, *self.btag_efficiency_syst_args)

            #self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "TT", "VV", "W", "QCD"]).AddSyst(self.cb, *self.btag_mistag_syst_args)
            #self.cb.cp().channel(["em"]).signals().AddSyst(self.cb, *self.btag_mistag_syst_args)

            if useRateParam:
                for category in Categories.CategoriesDict().getCategories(
                    ["em"], False)["em"]:
                    self.cb.cp().channel(["em"]).bin([
                        "em_" + category
                    ]).process(["ZTT"]).AddSyst(self.cb,
                                                "n_zll_" + category + "_norm",
                                                "rateParam",
                                                ch.SystMap()(1.0))

            # ======================================================================
            # TT channel
            self.add_processes(
                channel="tt",
                categories=Categories.CategoriesDict().getCategories(["tt"
                                                                      ])["tt"],
                bkg_processes=[
                    "ZTT", "ZL", "ZJ", "TTT", "TTJJ", "VV", "W", "QCD"
                ],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=higgs_masses)

            # efficiencies
            # (hopefully) temporary fix
            if year == "2016":
                self.cb.cp().channel(["tt"]).process(
                    ["ZTT", "TTT",
                     "VV"]).AddSyst(self.cb,
                                    *self.tau_efficiency2016_syst_args)
                self.cb.cp().channel(["tt"]).signals().AddSyst(
                    self.cb, *self.tau_efficiency2016_syst_args)
            else:
                self.cb.cp().channel(["tt"]).process(
                    ["ZTT", "TTT",
                     "VV"]).AddSyst(self.cb, *self.tau_efficiency_syst_args)
                self.cb.cp().channel(["tt"]).signals().AddSyst(
                    self.cb, *self.tau_efficiency_syst_args)

            # Tau ES
            self.cb.cp().channel(["tt"]).process(["ZTT"]).AddSyst(
                self.cb, *self.tau_es_syst_args)
            self.cb.cp().channel(["tt"
                                  ]).signals().AddSyst(self.cb,
                                                       *self.tau_es_syst_args)

            # fake-rate
            #self.cb.cp().channel(["tt"]).process(["ZL", "ZJ"]).AddSyst(self.cb, *self.zllFakeTau_syst_args)
            #self.cb.cp().channel(["tt"]).process(["ZL"]).AddSyst(self.cb, *self.eFakeTau_vloose_syst_args)

            if useRateParam:
                for category in Categories.CategoriesDict().getCategories(
                    ["tt"], False)["tt"]:
                    self.cb.cp().channel(["tt"]).bin([
                        "tt_" + category
                    ]).process(["ZTT"]).AddSyst(self.cb,
                                                "n_zll_" + category + "_norm",
                                                "rateParam",
                                                ch.SystMap()(1.0))

            # ======================================================================
            # MM channel
            self.add_processes(
                channel="mm",
                categories=Categories.CategoriesDict().getCategories(["mm"
                                                                      ])["mm"],
                bkg_processes=["ZTT", "ZLL", "TT", "VV", "W", "QCD"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=higgs_masses)

            # efficiencies
            # (hopefully) temporary fix
            if year == "2016":
                self.cb.cp().channel(["mm"]).process([
                    "ZTT", "ZLL", "ZL", "ZJ", "TTTT", "TTJJ", "VV", "W"
                ]).AddSyst(self.cb, *self.muon_efficiency2016_syst_args)
                self.cb.cp().channel(["mm"]).signals().AddSyst(
                    self.cb, *self.muon_efficiency2016_syst_args)
            else:
                self.cb.cp().channel(["mm"]).process(
                    ["ZTT", "ZLL", "ZL", "ZJ", "TTTT", "TTJJ", "VV",
                     "W"]).AddSyst(self.cb, *self.muon_efficiency_syst_args)
                self.cb.cp().channel(["mm"]).signals().AddSyst(
                    self.cb, *self.muon_efficiency_syst_args)

            if useRateParam:
                for category in Categories.CategoriesDict().getCategories(
                    ["mm"], False)["mm"]:
                    self.cb.cp().channel(["mm"]).bin([
                        "mm_" + category
                    ]).process(["ZLL"]).AddSyst(self.cb,
                                                "n_zll_" + category + "_norm",
                                                "rateParam",
                                                ch.SystMap()(1.0))

            # ======================================================================
            # All channels

            # lumi
            # (hopefully) temporary fix
            if year == "2016":
                self.cb.cp().signals().AddSyst(self.cb,
                                               *self.lumi2016_syst_args)
                self.cb.cp().process(
                    ["ZTT", "ZLL", "ZL", "ZJ", "TTT", "TTJJ",
                     "VV"]).AddSyst(self.cb, *self.lumi2016_syst_args)
                self.cb.cp().process(["W"]).channel([
                    "em", "tt", "mm"
                ]).AddSyst(self.cb, *self.lumi2016_syst_args
                           )  # automatically in other channels determined
            else:
                self.cb.cp().signals().AddSyst(self.cb, *self.lumi_syst_args)
                self.cb.cp().process(["ZTT", "ZLL", "ZL", "ZJ", "TT",
                                      "VV"]).AddSyst(self.cb,
                                                     *self.lumi_syst_args)
                self.cb.cp().process(["W"]).channel([
                    "em", "tt", "mm"
                ]).AddSyst(self.cb, *self.lumi_syst_args
                           )  # automatically in other channels determined

            # jets
            self.cb.cp().process(
                ["ZTT", "ZL", "ZJ", "TT", "TTT", "TTJJ", "VV", "W",
                 "QCD"]).AddSyst(self.cb, *self.jec_syst_args)
            self.cb.cp().signals().AddSyst(self.cb, *self.jec_syst_args)
            # fakes
            if year == "2016":
                self.cb.cp().channel(["et", "mt",
                                      "tt"]).process(["ZJ", "TTJJ"]).AddSyst(
                                          self.cb, *self.jetFakeTau_syst_args)
            else:
                self.cb.cp().channel(["et", "mt", "tt"]).process(
                    ["ZJ", "W", "TTJJ"]).AddSyst(self.cb,
                                                 *self.jetFakeTau_syst_args)
            # MET
            self.cb.cp().AddSyst(self.cb, *self.met_scale_syst_args)

            # cross section
            self.cb.cp().process(["ZTT", "ZL", "ZJ", "ZLL"
                                  ]).AddSyst(self.cb,
                                             *self.ztt_cross_section_syst_args)
            self.cb.cp().process(["TTT", "TTJJ"]).channel(
                ["mt", "et",
                 "tt"]).AddSyst(self.cb, *self.ttj_cross_section_syst_args
                                )  # automatically in other channels determined
            if year == "2016":
                self.cb.cp().process(["VV"]).AddSyst(
                    self.cb, *self.vv_cross_section2016_syst_args)
            else:
                self.cb.cp().process(["VV"]).AddSyst(
                    self.cb, *self.vv_cross_section_syst_args)
            self.cb.cp().process(["W"]).channel(["em", "tt", "mm"]).AddSyst(
                self.cb, *self.wj_cross_section_syst_args
            )  # automatically in other channels determined

            # tau efficiency
            # (hopefully) temporary fix
            if year == "2016":
                self.cb.cp().channel(["mt", "et", "tt"]).process([
                    "ZTT", "TTT", "VV"
                ]).AddSyst(self.cb, *self.tau_efficiency2016_corr_syst_args)
                self.cb.cp().channel(["mt", "et", "tt"]).signals().AddSyst(
                    self.cb, *self.tau_efficiency2016_corr_syst_args)
            else:
                self.cb.cp().channel(["mt", "et", "tt"]).process([
                    "ZTT", "TTT", "VV"
                ]).AddSyst(self.cb, *self.tau_efficiency_corr_syst_args)
                self.cb.cp().channel(["mt", "et", "tt"]).signals().AddSyst(
                    self.cb, *self.tau_efficiency_corr_syst_args)
            # signal
            self.cb.cp().signals().AddSyst(self.cb,
                                           *self.htt_qcd_scale_syst_args)
            self.cb.cp().signals().AddSyst(self.cb,
                                           *self.htt_pdf_scale_syst_args)
            self.cb.cp().signals().AddSyst(self.cb, *self.htt_ueps_syst_args)

            # transform B-Tagging shape to lnN
            #self.cb.cp().syst_name(['CMS_eff_b_13TeV']).ForEachSyst(lambda x: x.set_type("lnN"))
            #self.cb.cp().syst_name(['CMS_mistag_b_13TeV']).ForEachSyst(lambda x: x.set_type("lnN"))

            if log.isEnabledFor(logging.DEBUG):
                self.cb.PrintAll()
コード例 #28
0
    def __init__(self,
                 cp_mixing_angles_over_pi_half=[],
                 higgs_masses=["125"],
                 year="2016",
                 add_data=True,
                 cb=None):
        super(CPStudiesDatacards, self).__init__(cb)

        if cb is None:
            signal_processes = ["ggH", "qqH", "VH", "WH"]

            #background_processes_tt = ["ZTT", "ZLL", "QCD"]
            background_processes_mt = [
                "ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"
            ]
            background_processes_et = [
                "ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"
            ]
            #background_processes_tt = ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VVT", "VVJ", "W", "QCD"]
            background_processes_tt = ["ZTT", "ZLL", "TTJJ", "QCD"]
            background_processes_em = [
                "ZTT", "ZLL", "EWKZ", "TT", "VV", "hww_gg125", "hww_qq125",
                "W", "QCD"
            ]
            background_processes_mm = ["ZLL", "TT", "VV", "W"]
            all_mc_bkgs = [
                "ZTT", "ZL", "ZJ", "ZLL", "TT", "TTT", "TTJJ", "VV", "VVT",
                "VVJ", "W", "hww_gg125", "hww_qq125"
            ]
            all_mc_bkgs_no_W = [
                "ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "TTJJ", "VV",
                "VVT", "VVJ", "hww_gg125", "hww_qq125"
            ]
            all_mc_bkgs_no_TTJ = [
                "ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "VV", "VVT",
                "VVJ", "W", "hww_gg125", "hww_qq125"
            ]

            ##Generate instance of systematic libary, in which the relevant information about the systematics are safed

            systematics_list = SystLib.SystematicLibary()

            jecUncertNames = [
                "AbsoluteFlavMap", "AbsoluteMPFBias", "AbsoluteScale",
                "AbsoluteStat", "FlavorQCD", "Fragmentation", "PileUpDataMC",
                "PileUpPtBB", "PileUpPtEC1", "PileUpPtEC2", "PileUpPtHF",
                "PileUpPtRef", "RelativeBal", "RelativeFSR", "RelativeJEREC1",
                "RelativeJEREC2", "RelativeJERHF", "RelativePtBB",
                "RelativePtEC1", "RelativePtEC2", "RelativePtHF",
                "RelativeStatEC", "RelativeStatFSR", "RelativeStatHF",
                "SinglePionECAL", "SinglePionHCAL", "TimePtEta"
            ]

            # ======================================================================
            # MT channel
            self.add_processes(
                channel="mt",
                #categories=["mt_"+category for category in ["0jet_low", "0jet_high", "1jet_low", "1jet_high", "2jet_vbf"]],
                categories=["mt_" + category for category in ["CP_mt"]],
                bkg_processes=["ZTT", "ZLL"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # efficiencies
            self.cb.cp().channel(["mt"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.muon_efficiency2016_syst_args)
            self.cb.cp().channel(["mt"]).signals().AddSyst(
                self.cb, *systematics_list.muon_efficiency2016_syst_args)

            self.cb.cp().channel(["mt"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_syst_args)
            self.cb.cp().channel(["mt"]).signals().AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_syst_args)
            self.cb.cp().channel(["mt"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_corr_syst_args)
            self.cb.cp().channel(["mt"]).signals().AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_corr_syst_args)

            # Tau ES
            self.cb.cp().channel(["mt"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)
            self.cb.cp().channel(["mt"]).signals().AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["mt"]).process(["ZLL"]).AddSyst(
                self.cb, *systematics_list.zllFakeTau_syst_args)

            # ======================================================================
            # ET channel
            self.add_processes(
                channel="et",
                #categories=["et_"+category for category in ["0jet_low", "0jet_high", "1jet_low", "1jet_high", "2jet_vbf"]],
                categories=["et_" + category for category in ["CP_et"]],
                bkg_processes=["ZTT", "ZLL"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # efficiencies
            self.cb.cp().channel(["et"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.electron_efficiency2016_syst_args)
            self.cb.cp().channel(["et"]).signals().AddSyst(
                self.cb, *systematics_list.electron_efficiency2016_syst_args)

            self.cb.cp().channel(["et"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_syst_args)
            self.cb.cp().channel(["et"]).signals().AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_syst_args)

            # Tau ES
            self.cb.cp().channel(["et"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)
            self.cb.cp().channel(["et"]).signals().AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["et"]).process(["ZLL"]).AddSyst(
                self.cb, *systematics_list.zllFakeTau_syst_args)

            # ======================================================================
            # EM channel
            self.add_processes(
                channel="em",
                #categories=["em_"+category for category in ["0jet_low", "0jet_high", "1jet_low", "1jet_high", "2jet_vbf"]],
                categories=["em_" + category for category in ["CP_em"]],
                bkg_processes=["ZTT", "ZLL"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # efficiencies
            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.electron_efficiency2016_syst_args)
            self.cb.cp().channel(["em"]).signals().AddSyst(
                self.cb, *systematics_list.electron_efficiency2016_syst_args)

            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.muon_efficiency2016_syst_args)
            self.cb.cp().channel(["em"]).signals().AddSyst(
                self.cb, *systematics_list.muon_efficiency2016_syst_args)

            # ======================================================================
            # TT channel
            self.add_processes(
                channel="tt",
                categories=["tt_" + category for category in ["CP_tt"]],
                bkg_processes=["ZTT", "ZLL"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # TT channel for rho analysis
            # TODO: There are 3 different processes here. -> Merge to one.
            self.add_processes(channel="tt",
                               categories=[
                                   "tt_" + category
                                   for category in ["CP_rho_merged"]
                               ],
                               bkg_processes=background_processes_tt,
                               sig_processes=signal_processes,
                               analysis=["htt"],
                               era=["13TeV"],
                               mass=cp_mixing_angles_over_pi_half,
                               add_data=add_data)

            self.add_processes(channel="tt",
                               categories=[
                                   "tt_" + category
                                   for category in ["CP_rho_yLhigh"]
                               ],
                               bkg_processes=background_processes_tt,
                               sig_processes=signal_processes,
                               analysis=["htt"],
                               era=["13TeV"],
                               mass=cp_mixing_angles_over_pi_half,
                               add_data=add_data)

            self.add_processes(
                channel="tt",
                categories=["tt_" + category for category in ["CP_rho_yLlow"]],
                bkg_processes=background_processes_tt,
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # efficiencies
            if year == "2016":
                self.cb.cp().channel(
                    ["tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                        self.cb,
                        *systematics_list.trigger_efficiency2016_syst_args)
                self.cb.cp().channel(
                    ["tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                        self.cb,
                        *systematics_list.tau_efficiency2016_tt_syst_args)
            else:
                self.cb.cp().channel([
                    "tt"
                ]).process(signal_processes + ["ZTT", "TTT", "VVT"]).AddSyst(
                    self.cb, *systematics_list.tau_efficiency_syst_args)

            # # efficiencies
            # self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_syst_args)
            # #self.cb.cp().channel(["tt"]).signals().AddSyst(self.cb, *systematics_list.tau_efficiency2016_syst_args)
            #
            # # Tau ES
            # self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_es_syst_args)
            # #self.cb.cp().channel(["tt"]).signals().AddSyst(self.cb, *systematics_list.tau_es_syst_args)
            #
            # # fake-rate
            # self.cb.cp().channel(["tt"]).process(["ZLL"]).AddSyst(self.cb, *systematics_list.zllFakeTau_syst_args)

            # ======================================================================
            # All channels

            # ======================================================================
            # lumi
            if year == "2016":
                self.cb.cp().process(
                    signal_processes +
                    ["VV", "VVT", "VVJ", "hww_gg125", "hww_qq125"]).AddSyst(
                        self.cb, *systematics_list.lumi2016_syst_args)

                self.cb.cp().process(["TT", "TTT", "TTJJ"]).AddSyst(
                    self.cb, *systematics_list.lumi2016_syst_args)
                self.cb.cp().process(["W"]).channel([
                    "em", "tt", "mm", "ttbar"
                ]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
            else:
                self.cb.cp().process(signal_processes +
                                     all_mc_bkgs_no_W).AddSyst(
                                         self.cb,
                                         *systematics_list.lumi_syst_args)
                self.cb.cp().process(["W"]).channel(
                    ["em", "tt",
                     "mm"]).AddSyst(self.cb, *systematics_list.lumi_syst_args)

            # ======================================================================
            # cross section

            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin([
                "em_ZeroJet2D"
            ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_em_13TeV", "lnN",
                       ch.SystMap()(1.07))
            self.cb.cp().channel(["tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["tt_ZeroJet2D", "tt_ZeroJet2D_QCDCR"
                    ]).AddSyst(self.cb,
                               "CMS_htt_zmm_norm_extrap_0jet_tt_13TeV", "lnN",
                               ch.SystMap()(1.07))
            self.cb.cp().channel(["mt", "et"]).process(
                ["ZTT", "ZL", "ZJ", "EWKZ"]).bin([
                    "mt_ZeroJet2D", "mt_ZeroJet2D_WJCR", "mt_ZeroJet2D_QCDCR",
                    "et_ZeroJet2D", "et_ZeroJet2D_WJCR", "et_ZeroJet2D_QCDCR"
                ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_lt_13TeV",
                           "lnN",
                           ch.SystMap()(1.07))

            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin([
                "em_Boosted2D"
            ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_em_13TeV",
                       "lnN",
                       ch.SystMap()(1.07))
            self.cb.cp().channel(["tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["tt_Boosted2D", "tt_Boosted2D_QCDCR"
                    ]).AddSyst(self.cb,
                               "CMS_htt_zmm_norm_extrap_boosted_tt_13TeV",
                               "lnN",
                               ch.SystMap()(1.07))
            self.cb.cp().channel(["mt", "et"]).process(
                ["ZTT", "ZL", "ZJ", "EWKZ"]).bin([
                    "mt_Boosted2D", "mt_Boosted2D_WJCR", "mt_Boosted2D_QCDCR",
                    "et_Boosted2D", "et_Boosted2D_WJCR", "et_Boosted2D_QCDCR"
                ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_lt_13TeV",
                           "lnN",
                           ch.SystMap()(1.07))

            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin([
                "em_Vbf2D"
            ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_em_13TeV", "lnN",
                       ch.SystMap()(1.15))
            self.cb.cp().channel(["tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["tt_Vbf2D", "tt_Vbf2D_QCDCR"
                    ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_tt_13TeV",
                               "lnN",
                               ch.SystMap()(1.15))
            self.cb.cp().channel(["mt", "et"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["mt_vbf2D", "et_vbf2D"
                    ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_lt_13TeV",
                               "lnN",
                               ch.SystMap()(1.10))

            self.cb.cp().channel(["mt", "et", "tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin([channel + "_Vbf2D" for channel in ["mt", "et", "tt"]
                    ]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV",
                               "shape",
                               ch.SystMap()(1.0))
            self.cb.cp().channel(["tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["tt_Vbf2D_QCDCR"]).AddSyst(self.cb,
                                               "CMS_htt_zmumuShape_VBF_13TeV",
                                               "shape",
                                               ch.SystMap()(1.0))
            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).bin(
                ["em_Vbf2D"]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV",
                                      "shape",
                                      ch.SystMap()(1.0))

            self.cb.cp().process(["TT", "TTT", "TTJJ"]).channel([
                "mt", "et", "em", "tt"
            ]).AddSyst(self.cb, *systematics_list.ttj_cross_section_syst_args)
            if year == "2016":
                self.cb.cp().process(["VV", "VVT", "VVJ"]).AddSyst(
                    self.cb, *systematics_list.vv_cross_section2016_syst_args)
            else:
                self.cb.cp().process(["VV", "VVT", "VVJ"]).AddSyst(
                    self.cb, *systematics_list.vv_cross_section_syst_args)
            self.cb.cp().process(["W"]).channel(["em"]).AddSyst(
                self.cb, "CMS_htt_jetFakeLep_13TeV", "lnN",
                ch.SystMap()(1.20))
            self.cb.cp().process(["W"]).channel(["tt", "mm"]).AddSyst(
                self.cb, *systematics_list.wj_cross_section_syst_args)

            # ======================================================================
            # tau id efficiency
            if year == "2016":
                self.cb.cp().channel(
                    ["mt",
                     "et"]).process(signal_processes + all_mc_bkgs).AddSyst(
                         self.cb,
                         *systematics_list.tau_efficiency2016_corr_syst_args)
                self.cb.cp().channel(
                    ["tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                        self.cb,
                        *systematics_list.tau_efficiency2016_tt_corr_syst_args)
            else:
                self.cb.cp().channel([
                    "mt", "et", "tt"
                ]).process(signal_processes + ["ZTT", "TTT", "VVT"]).AddSyst(
                    self.cb, *systematics_list.tau_efficiency_corr_syst_args)

            # ======================================================================
            # energy scales

            # tau ES
            self.cb.cp().channel(
                ["mt", "et",
                 "tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                     self.cb, "CMS_scale_t_1prong_13TeV", "shape",
                     ch.SystMap()(1.0))
            self.cb.cp().channel(
                ["mt", "et",
                 "tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                     self.cb, "CMS_scale_t_1prong1pizero_13TeV", "shape",
                     ch.SystMap()(1.0))
            self.cb.cp().channel(
                ["mt", "et",
                 "tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                     self.cb, "CMS_scale_t_3prong_13TeV", "shape",
                     ch.SystMap()(1.0))

            # jet ES
            # TODO: use mix of lnN/shape systematics as done in official analysis?

            for jecUncert in jecUncertNames:
                self.cb.cp().process(
                    signal_processes + all_mc_bkgs + ["QCD"]).bin([
                        channel + "_" + category
                        for channel in ["et", "mt", "tt", "em"]
                        for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                    ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                               "shape",
                               ch.SystMap()(1.0))
                self.cb.cp().channel(
                    ["mt"]).process(signal_processes + all_mc_bkgs).bin([
                        "mt_ZeroJet2D_WJCR", "mt_Boosted2D_WJCR",
                        "mt_ZeroJet2D_QCDCR", "mt_Boosted2D_QCDCR"
                    ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                               "shape",
                               ch.SystMap()(1.0))
                self.cb.cp().channel(
                    ["et"]).process(signal_processes + all_mc_bkgs).bin([
                        "et_ZeroJet2D_WJCR", "et_Boosted2D_WJCR",
                        "et_Boosted2D_QCDCR"
                    ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                               "shape",
                               ch.SystMap()(1.0))
                self.cb.cp().channel([
                    "et"
                ]).process(signal_processes + all_mc_bkgs_no_TTJ).bin([
                    "et_ZeroJet2D_QCDCR"
                ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                           "shape",
                           ch.SystMap()(1.0))
                self.cb.cp().channel(
                    ["tt"]).process(signal_processes + all_mc_bkgs).bin([
                        "tt_ZeroJet2D_QCDCR", "tt_Boosted2D_QCDCR",
                        "tt_Vbf2D_QCDCR"
                    ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                               "shape",
                               ch.SystMap()(1.0))

            # jet->tau fake ES
            if year == "2016":
                self.cb.cp().channel(["et", "mt", "tt"]).process([
                    "ZJ", "TTJJ", "VVJ"
                ]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape",
                           ch.SystMap()(1.0))
                self.cb.cp().channel(["et", "mt", "tt"]).process(["W"]).bin([
                    channel + "_" + category for channel in ["et", "mt", "tt"]
                    for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                ]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape",
                           ch.SystMap()(1.0))
                self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([
                    channel + "_" + category for channel in ["et", "mt"]
                    for category in ["ZeroJet2D_QCDCR", "Boosted2D_QCDCR"]
                ]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape",
                           ch.SystMap()(1.0))
            else:
                self.cb.cp().channel(["et", "mt", "tt"]).process([
                    "ZJ", "W", "TTJJ", "VVJ"
                ]).AddSyst(self.cb, *systematics_list.jetFakeTau_syst_args)

            # MET ES
            self.cb.cp().channel(
                ["et", "mt", "tt",
                 "em"]).process(signal_processes + all_mc_bkgs).bin([
                     channel + "_" + category
                     for channel in ["et", "mt", "tt", "em"]
                     for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                 ]).AddSyst(self.cb, "CMS_scale_met_clustered_13TeV", "shape",
                            ch.SystMap()(1.0))
            self.cb.cp().channel(
                ["et", "mt", "tt",
                 "em"]).process(signal_processes + all_mc_bkgs).bin([
                     channel + "_" + category
                     for channel in ["et", "mt", "tt", "em"]
                     for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                 ]).AddSyst(self.cb, "CMS_scale_met_unclustered_13TeV",
                            "shape",
                            ch.SystMap()(1.0))
            self.cb.cp().channel(["et", "mt"]).process(all_mc_bkgs).bin([
                channel + "_" + category for channel in ["et", "mt"]
                for category in [
                    "ZeroJet2D_WJCR", "ZeroJet2D_QCDCR", "Boosted2D_WJCR",
                    "Boosted2D_QCDCR"
                ]
            ]).AddSyst(self.cb, "CMS_scale_met_clustered_13TeV", "shape",
                       ch.SystMap()(1.0))
            self.cb.cp().channel(["et", "mt"]).process(all_mc_bkgs).bin([
                channel + "_" + category for channel in ["et", "mt"]
                for category in [
                    "ZeroJet2D_WJCR", "ZeroJet2D_QCDCR", "Boosted2D_WJCR",
                    "Boosted2D_QCDCR"
                ]
            ]).AddSyst(self.cb, "CMS_scale_met_unclustered_13TeV", "shape",
                       ch.SystMap()(1.0))

            # ======================================================================
            # W+jets and QCD estimation uncertainties

            # QCD normalization
            self.cb.cp().channel(["em"]).process(["QCD"]).bin(
                ["em_ZeroJet2D"]).AddSyst(self.cb, "CMS_htt_QCD_0jet_em_13TeV",
                                          "lnN",
                                          ch.SystMap()(1.10))
            self.cb.cp().channel(["em"]).process(["QCD"]).bin([
                "em_Boosted2D"
            ]).AddSyst(self.cb, "CMS_htt_QCD_boosted_em_13TeV", "lnN",
                       ch.SystMap()(1.10))
            self.cb.cp().channel(["em"]).process(["QCD"]).bin(
                ["em_Vbf2D"]).AddSyst(self.cb, "CMS_htt_QCD_VBF_em_13TeV",
                                      "lnN",
                                      ch.SystMap()(1.20))

            self.cb.cp().channel(["tt"]).process(["QCD"]).bin(
                ["tt_ZeroJet2D"]).AddSyst(self.cb, "CMS_htt_QCD_0jet_tt_13TeV",
                                          "lnN",
                                          ch.SystMap()(1.027))
            self.cb.cp().channel(["tt"]).process(["QCD"]).bin([
                "tt_Boosted2D"
            ]).AddSyst(self.cb, "CMS_htt_QCD_boosted_tt_13TeV", "lnN",
                       ch.SystMap()(1.027))
            self.cb.cp().channel(["tt"]).process(["QCD"]).bin(
                ["tt_Vbf2D"]).AddSyst(self.cb, "CMS_htt_QCD_VBF_tt_13TeV",
                                      "lnN",
                                      ch.SystMap()(1.15))

            self.cb.cp().channel(["mt"]).process(["QCD"]).bin([
                "mt_" + category
                for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
            ]).AddSyst(self.cb, "QCD_Extrap_Iso_nonIso_mt_13TeV", "lnN",
                       ch.SystMap()(1.20))
            self.cb.cp().channel(["et"]).process(["QCD"]).bin([
                "et_" + category
                for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
            ]).AddSyst(self.cb, "QCD_Extrap_Iso_nonIso_et_13TeV", "lnN",
                       ch.SystMap()(1.20))

            self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([
                channel + "_ZeroJet2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WSFUncert_$CHANNEL_0jet_13TeV", "shape",
                       ch.SystMap()(1.0))
            self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([
                channel + "_Boosted2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WSFUncert_$CHANNEL_boosted_13TeV", "shape",
                       ch.SystMap()(1.0))
            self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([
                channel + "_Vbf2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WSFUncert_$CHANNEL_vbf_13TeV", "shape",
                       ch.SystMap()(1.0))

            # W+jets high->low mt extrapolation uncertainty
            self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([
                channel + "_ZeroJet2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WHighMTtoLowMT_0jet_13TeV", "lnN",
                       ch.SystMap()(1.10))
            self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([
                channel + "_Boosted2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WHighMTtoLowMT_boosted_13TeV", "lnN",
                       ch.SystMap()(1.05))
            self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([
                channel + "_Vbf2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WHighMTtoLowMT_vbf_13TeV", "lnN",
                       ch.SystMap()(1.10))

            # ======================================================================
            # pt reweighting uncertainties

            # ttbar shape
            self.cb.cp().channel(["et", "mt", "em",
                                  "tt"]).process(["TTT", "TTJJ"]).AddSyst(
                                      self.cb, *systematics_list.ttj_syst_args)
            self.cb.cp().channel(["em"]).process(["TT"]).AddSyst(
                self.cb, *systematics_list.ttj_syst_args)

            # dy shape
            self.cb.cp().channel(["et", "mt",
                                  "tt"]).process(["ZTT", "ZL", "ZJ"]).AddSyst(
                                      self.cb,
                                      *systematics_list.dy_shape_syst_args)
            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.dy_shape_syst_args)

            # ======================================================================
            # Theory uncertainties
            self.cb.cp().channel(["mt", "et", "tt", "em"]).process(
                ["ggH"]).bin([
                    channel + "_" + category
                    for channel in ["et", "mt", "em", "tt"]
                    for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                ]).AddSyst(self.cb, "CMS_scale_gg_13TeV", "shape",
                           ch.SystMap()(1.0))
            self.cb.cp().process(["qqH"]).AddSyst(
                self.cb, *systematics_list.htt_qcd_scale_qqh_syst_args)
            self.cb.cp().process(["ggH", "qqH"]).AddSyst(
                self.cb, *systematics_list.htt_pdf_scale_smhtt_syst_args)
            self.cb.cp().process(["ggH", "qqH"]).AddSyst(
                self.cb, *systematics_list.htt_ueps_smhtt_syst_args)

            # Uncertainty on BR of HTT @ 125 GeV
            self.cb.cp().signals().AddSyst(self.cb, "BR_htt_THU", "lnN",
                                           ch.SystMap()(1.017))
            self.cb.cp().signals().AddSyst(self.cb, "BR_htt_PU_mq", "lnN",
                                           ch.SystMap()(1.0099))
            self.cb.cp().signals().AddSyst(self.cb, "BR_htt_PU_alphas", "lnN",
                                           ch.SystMap()(1.0062))

            # Uncertainty on BR of HWW @ 125 GeV
            self.cb.cp().process(["hww_gg125", "hww_qq125"
                                  ]).AddSyst(self.cb, "BR_hww_THU", "lnN",
                                             ch.SystMap()(1.0099))
            self.cb.cp().process(["hww_gg125", "hww_qq125"
                                  ]).AddSyst(self.cb, "BR_hww_PU_mq", "lnN",
                                             ch.SystMap()(1.0099))
            self.cb.cp().process(["hww_gg125", "hww_qq125"
                                  ]).AddSyst(self.cb, "BR_hww_PU_alphas",
                                             "lnN",
                                             ch.SystMap()(1.0066))

            self.cb.cp().process(["ggH", "hww_gg125"
                                  ]).AddSyst(self.cb, "QCDScale_ggH", "lnN",
                                             ch.SystMap()(1.039))
            self.cb.cp().process(["qqH", "hww_qq125"
                                  ]).AddSyst(self.cb, "QCDScale_qqH", "lnN",
                                             ch.SystMap()(1.004))
            self.cb.cp().process(["WH"]).AddSyst(self.cb, "QCDScale_VH", "lnN",
                                                 ch.SystMap()(1.007))
            self.cb.cp().process(["ZH"]).AddSyst(self.cb, "QCDScale_VH", "lnN",
                                                 ch.SystMap()(1.038))

            self.cb.cp().process(["ggH", "hww_gg125"
                                  ]).AddSyst(self.cb, "pdf_Higgs_gg", "lnN",
                                             ch.SystMap()(1.032))
            self.cb.cp().process(["qqH", "hww_qq125"
                                  ]).AddSyst(self.cb, "pdf_Higgs_qq", "lnN",
                                             ch.SystMap()(1.021))
            self.cb.cp().process(["WH"]).AddSyst(self.cb, "pdf_Higgs_VH",
                                                 "lnN",
                                                 ch.SystMap()(1.019))
            self.cb.cp().process(["ZH"]).AddSyst(self.cb, "pdf_Higgs_VH",
                                                 "lnN",
                                                 ch.SystMap()(1.016))

            # ======================================================================
            # control region rate parameters
            self.cb.cp().process(["W"
                                  ]).bin(["mt_ZeroJet2D", "mt_ZeroJet2D_WJCR"
                                          ]).AddSyst(self.cb,
                                                     "rate_W_cr_0jet_mt",
                                                     "rateParam",
                                                     ch.SystMap()(1.0))
            self.cb.cp().process(["W"]).bin([
                "mt_Boosted2D", "mt_Boosted2D_WJCR", "mt_Vbf2D"
            ]).AddSyst(self.cb, "rate_W_cr_boosted_mt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["W"
                                  ]).bin(["et_ZeroJet2D", "et_ZeroJet2D_WJCR"
                                          ]).AddSyst(self.cb,
                                                     "rate_W_cr_0jet_et",
                                                     "rateParam",
                                                     ch.SystMap()(1.0))
            self.cb.cp().process(["W"]).bin([
                "et_Boosted2D", "et_Boosted2D_WJCR", "et_Vbf2D"
            ]).AddSyst(self.cb, "rate_W_cr_boosted_et", "rateParam",
                       ch.SystMap()(1.0))

            self.cb.cp().process(["QCD"]).bin([
                "mt_ZeroJet2D", "mt_ZeroJet2D_QCDCR"
            ]).AddSyst(self.cb, "rate_QCD_cr_0jet_mt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "mt_Boosted2D", "mt_Boosted2D_QCDCR", "mt_Vbf2D"
            ]).AddSyst(self.cb, "rate_QCD_cr_boosted_mt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "et_ZeroJet2D", "et_ZeroJet2D_QCDCR"
            ]).AddSyst(self.cb, "rate_QCD_cr_0jet_et", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "et_Boosted2D", "et_Boosted2D_QCDCR", "et_Vbf2D"
            ]).AddSyst(self.cb, "rate_QCD_cr_boosted_et", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "tt_ZeroJet2D", "tt_ZeroJet2D_QCDCR"
            ]).AddSyst(self.cb, "rate_QCD_cr_0jet_tt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "tt_Boosted2D", "tt_Boosted2D_QCDCR"
            ]).AddSyst(self.cb, "rate_QCD_cr_boosted_tt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"
                                  ]).bin(["tt_Vbf2D", "tt_Vbf2D_QCDCR"
                                          ]).AddSyst(self.cb,
                                                     "rate_QCD_cr_vbf_tt",
                                                     "rateParam",
                                                     ch.SystMap()(1.0))

            #self.cb.cp().GetParameter("rate_W_cr_0jet_mt").set_range(0, 5)
            #self.cb.cp().GetParameter("rate_W_cr_boosted_mt").set_range(0, 5)
            #self.cb.cp().GetParameter("rate_W_cr_0jet_et").set_range(0, 5)
            #self.cb.cp().GetParameter("rate_W_cr_boosted_et").set_range(0, 5)

            # self.cb.cp().GetParameter("rate_QCD_cr_0jet_mt").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_boosted_mt").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_0jet_et").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_boosted_et").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_0jet_tt").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_boosted_tt").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_vbf_tt").set_range(0, 5)

            # ======================================================================

            if log.isEnabledFor(logging.DEBUG):
                self.cb.PrintAll()
コード例 #29
0
def main():
    options = options_()
    for cutkey in options.cut:
        print 'cutkey : ', cutkey
        ### get M_A and M_H ###
        mH = float(options.mH_list[cutkey])
        mA = float(options.mA_list[cutkey])
        print mH, mA
        """Main function"""
        # start the timer
        tstart = datetime.now()
        print 'starting...'
        # get the options
        #options = get_options()

        intL = options.lumi  # in pb-1
        #tag = 'v1.2.0+7415-19-g7bbca78_ZAAnalysis_1a69757'
        #path = '/nfs/scratch/fynu/amertens/cmssw/CMSSW_7_4_15/src/cp3_llbb/CommonTools/histFactory/16_01_28_syst/build'
        tag = 'v1.1.0+7415-83-g2a9f912_ZAAnalysis_2ff9261'
        #tag = 'v1.1.0+7415-57-g4bff5ea_ZAAnalysis_b1377a8'
        path = options.path
        CHANNEL = options.CHANNEL
        ERA = options.ERA
        MASS = str(mH) + "_" + str(mA)
        ANALYSIS = options.ANALYSIS
        DEBUG = 0

        c = ch.CombineHarvester()
        cats = [(0, "mmbbSR" + cutkey), (1, "mll_mmbbBR" + cutkey),
                (2, "eebbSR" + cutkey), (3, "mll_eebbBR" + cutkey)]

        bins = {}
        bins['signalregion_mm'] = "mmbbSR" + cutkey
        bins['mll_bkgregion_mm'] = "mll_mmbbBR" + cutkey
        bins['signalregion_ee'] = "eebbSR" + cutkey
        bins['mll_bkgregion_ee'] = "mll_eebbBR" + cutkey

        processes = {}
        p = Process('data_obs')
        #DoubleMuon_Run2015D_v1.1.0+7415-57-g4bff5ea_ZAAnalysis_b1377a8_histos.root
        p.prepare_process(path, 'data_obs', 'DoubleMuon_DoubleEG_Run2015D',
                          tag)
        processes['data_obs'] = p
        if DEBUG: print p
        # define signal
        # define backgrounds
        # zz
        p = Process('zz')
        p.prepare_process(
            path, 'zz',
            'ZZTo2L2Q_13TeV_amcatnloFXFX_madspin_pythia8_MiniAODv2', tag)
        processes['zz'] = p
        if DEBUG: print p

        # ttbar
        p = Process('ttbar')
        p.prepare_process(path, 'ttbar', 'TTTo2L2Nu_13TeV-powheg_MiniAODv2',
                          tag)
        processes['ttbar'] = p
        p = Process('ttbar')
        if DEBUG: print p
        '''
    # drell-yan
    p = Process('dy1')
    p.prepare_process(path, 'dy1', 'DYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-amcatnloFXFX_MiniAODv2', tag)
    processes['dy1'] = p
    if DEBUG: print p
    '''
        p = Process('dy2')
        p.prepare_process(
            path, 'dy2',
            'DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX_MiniAODv2', tag)
        processes['dy2'] = p
        if DEBUG: print p

        c.AddObservations([MASS], [ANALYSIS], [ERA], [CHANNEL], cats)
        c.AddProcesses([MASS], [ANALYSIS], [ERA], [CHANNEL], ['ZA'], cats,
                       True)
        c.AddProcesses([MASS], [ANALYSIS], [ERA], [CHANNEL],
                       ['ttbar', 'dy2', 'zz'], cats, False)
        c.cp().process(['ttbar', 'dy2', 'ZA']).AddSyst(
            c, "lumi", "lnN",
            ch.SystMap('channel', 'era', 'bin_id')([CHANNEL], [ERA],
                                                   [0, 1, 2, 3], 1.046))

        c.cp().process(['ttbar', 'dy2', 'ZA']).AddSyst(
            c, "trig", "lnN",
            ch.SystMap('channel', 'era', 'bin_id')([CHANNEL], [ERA],
                                                   [0, 1, 2, 3], 1.04))

        c.cp().process(['ttbar', 'dy2']).AddSyst(c, "btag", "shape",
                                                 ch.SystMap()(1.0))

        c.cp().process(['ttbar', 'dy2']).AddSyst(c, "jec", "shape",
                                                 ch.SystMap()(1.0))

        c.cp().process(['ttbar', 'dy2']).AddSyst(c, "jer", "shape",
                                                 ch.SystMap()(1.0))

        c.cp().process(['ttbar', 'dy2']).AddSyst(c, "pu", "shape",
                                                 ch.SystMap()(1.0))

        c.cp().process(['ttbar']).AddSyst(c, "TTpdf", "shape",
                                          ch.SystMap()(1.0))

        c.cp().process(['dy2']).AddSyst(c, "DYpdf", "shape", ch.SystMap()(1.0))

        c.cp().process(['dy2']).AddSyst(
            c, "DYnorm", "lnN",
            ch.SystMap('channel', 'era', 'bin_id')([CHANNEL], [ERA], [0, 1],
                                                   1.1))

        c.cp().process(['ttbar']).AddSyst(
            c, "TTnorm", "lnN",
            ch.SystMap('channel', 'era', 'bin_id')([CHANNEL], [ERA], [0], 1.1))

        nChannels = len(bins)
        nBackgrounds = len(
            [processes[x] for x in processes if processes[x].type > 0])
        nNuisances = 1

        systematics = {
            '': '',
            '_btagUp': '__btagup',
            '_btagDown': '__btagdown',
            '_jecUp': '__jecup',
            '_jecDown': '__jecdown',
            '_jerUp': '__jerup',
            '_jerDown': '__jerdown',
            '_puUp': '__puup',
            '_puDown': '__pudown',
            '_TTpdfUp': '__pdfup',
            '_TTpdfDown': '__pdfdown',
            '_DYpdfUp': '__pdfup',
            '_DYpdfDown': '__pdfdown'
        }
        outputRoot = "shapes.root"
        f = TFile(outputRoot, "recreate")
        f.Close()
        for b in bins:
            print b, bins[b]
            for p in processes:
                if p == 'data_obs':
                    file_in = TFile(processes[p].file, "READ")
                    print " Getting ", bins[b], " in file ", processes[p].file
                    h = file_in.Get(bins[b])
                    h.SetDirectory(0)
                    file_in.Close()
                    f = TFile(outputRoot, "update")
                    h.SetName("hist_" + bins[b] + "_" + p)
                    h.Write()
                    f.Write()
                    f.Close()

                else:
                    for s1, s2 in systematics.iteritems():
                        file_in = TFile(processes[p].file, "READ")
                        print " Getting ", bins[
                            b] + s2, " in file ", processes[p].file
                        h = file_in.Get(bins[b] + s2)
                        h.SetDirectory(0)
                        file_in.Close()
                        f = TFile(outputRoot, "update")
                        h.SetName("hist_" + bins[b] + "_" + p + s1)
                        h.Sumw2()
                        #h.Scale(processes[p].xsection * intL / processes[p].sumW)
                        h.Scale(intL)
                        h.Write()
                        f.Write()
                        f.Close()

        # Fill signal histograms FIXME: read efficiencies from eff.root

        eff_file = TFile("eff.root", "READ")
        effee_hist = eff_file.Get("effee")
        eff_ee = effee_hist.Interpolate(mA, mH)
        effmm_hist = eff_file.Get("effmm")
        eff_mm = effmm_hist.Interpolate(mA, mH)

        print "lumi : ", options.lumifb
        print "eff at ", mA, mH, ":", eff_ee, eff_mm
        print "ZA yields: ", options.lumifb * eff_mm, options.lumifb * eff_ee

        f = TFile(outputRoot, "update")
        h1 = TH1F("hist_" + bins['signalregion_mm'] + "_ZA",
                  "hist_" + bins['signalregion_mm'] + "_ZA", 1, 0, 1)
        h1.Fill(0.5, options.lumifb * eff_mm)
        h1.Write()

        h2 = TH1F("hist_" + bins['mll_bkgregion_mm'] + "_ZA",
                  "hist_" + bins['mll_bkgregion_mm'] + "_ZA", 60, 60, 120)
        h2.Write()

        h3 = TH1F("hist_" + bins['signalregion_ee'] + "_ZA",
                  "hist_" + bins['signalregion_ee'] + "_ZA", 1, 0, 1)
        h3.Fill(0.5, options.lumifb * eff_ee)
        h3.Write()

        h4 = TH1F("hist_" + bins['mll_bkgregion_ee'] + "_ZA",
                  "hist_" + bins['mll_bkgregion_ee'] + "_ZA", 60, 60, 120)
        h4.Write()

        f.Write()
        f.Close()

        c.cp().backgrounds().ExtractShapes(outputRoot, "hist_$BIN_$PROCESS",
                                           "hist_$BIN_$PROCESS_$SYSTEMATIC")
        c.cp().signals().ExtractShapes(outputRoot, "hist_$BIN_$PROCESS",
                                       "hist_$BIN_$PROCESS_$SYSTEMATIC")
        writer = ch.CardWriter(
            '$TAG/$MASS/$ANALYSIS_$CHANNEL_$ERA.dat',
            '$TAG/common/$ANALYSIS_$CHANNEL_$MASS.input_$ERA.root')
        writer.WriteCards('CARDS/', c)
コード例 #30
0
	def __init__(self):
		
	##----------------------------------------------------------lnN uncertanties----------------------------------------------------------##

		##-------------------------------Luminosity-------------------------------##
		
		self.lumi_syst_args = [
			"lumi_$ERA",
			"lnN",
			ch.SystMap("era")
				(["7TeV", "8TeV"], 1.026)
				(       ["13TeV"], 1.027) # CMS-PAS-LUM-15-001
		]
		self.lumi2016_syst_args = [
			"lumi_$ERA",
			"lnN",
			ch.SystMap("era")
				(       ["13TeV"], 1.025)

		]
		##-------------------------------Cross section-------------------------------##
		
		self.ztt_cross_section_syst_args = [
			"CMS_$ANALYSIS_zttNorm_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(["7TeV", "8TeV"], ["ZTT", "ZLL", "ZL", "ZJ"], 1.03)
				(       ["13TeV"], ["ZTT", "ZLL", "ZL", "ZJ"], 1.04)
		]
		self.zll_cross_section_syst_args = [
			"CMS_$ANALYSIS_zjXsec_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(       ["13TeV"], ["ZLL", "ZL", "ZJ"], 1.04) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.ttj_cross_section_syst_args = [
			"CMS_$ANALYSIS_ttjXsec_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				( ["7TeV"], ["TTJ"], 1.08)
				( ["8TeV"], ["TTJ"], 1.1)
				(["13TeV"], ["TTJ", "TT", "TTT", "TTJJ"], 1.06) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581HttNuisanceParamUpdate_2016Apr13.pdf
		]

		self.singlet_cross_section_syst_args = [
			"CMS_$ANALYSIS_singletXsec_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(["13TeV"], ["VV"], 1.04) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.vv_cross_section_syst_args = [
			"CMS_$ANALYSIS_vvXsec_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(["7TeV", "8TeV"], ["VV"], 1.15)
				(       ["13TeV"], ["VV", "VVT", "VVJ"], 1.10) # https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.vv_cross_section2016_syst_args = [
			"CMS_$ANALYSIS_vvXsec_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(       ["13TeV"], ["VV", "VVT", "VVJ"], 1.05) # https://indico.cern.ch/event/566822/contributions/2377598/attachments/1374111/2085739/systematics.pdf
		]
		self.wj_cross_section_syst_args = [
			"CMS_$ANALYSIS_wjXsec_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(       ["13TeV"], ["WJ", "W"], 1.04) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]

		##-------------------------------Efficiencies-------------------------------##
		
		self.trigger_efficiency2016_syst_args = [ # https://github.com/cms-analysis/CombineHarvester/blob/SM2016-dev/HTTSM2016/src/HttSystematics_SMRun2.cc#L76-L88
			"CMS_eff_trigger_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("era", "channel")
				(["13TeV"], ["mt", "et"], 1.02)
				(["13TeV"], ["tt"], 1.10)
		]
		self.trigger_efficiency2016_em_syst_args = [ # https://github.com/cms-analysis/CombineHarvester/blob/SM2016-dev/HTTSM2016/src/HttSystematics_SMRun2.cc#L82-L84
			"CMS_eff_trigger_em_$ERA",
			"lnN",
			ch.SystMap("era", "channel")
				(["13TeV"], ["em", "ttbar"], 1.02)
		]
		self.electron_efficiency_syst_args = [
			"CMS_eff_e",
			"lnN",
			ch.SystMap("era")
				(["7TeV", "8TeV"], 1.02)
				(       ["13TeV"], 1.04) # https://github.com/cms-analysis/CombineHarvester/blob/HIG15007/HIG15007/scripts/setupDatacards.py#L107-L110
		]
		self.electron_efficiency2016_syst_args = [
			"CMS_eff_e",
			"lnN",
			ch.SystMap("era")
				(       ["13TeV"], 1.02) # https://indico.cern.ch/event/566822/contributions/2377598/attachments/1374111/2085739/systematics.pdf
		]
		self.muon_efficiency_syst_args = [
			"CMS_eff_m",
			"lnN",
			ch.SystMap("era")
				(["7TeV", "8TeV"], 1.02)
				(       ["13TeV"], 1.03) # https://github.com/cms-analysis/CombineHarvester/blob/HIG15007/HIG15007/scripts/setupDatacards.py#L101-L105
		]
		self.muon_efficiency2016_syst_args = [
			"CMS_eff_m",
			"lnN",
			ch.SystMap("era")
				(       ["13TeV"], 1.02) # https://indico.cern.ch/event/566822/contributions/2377598/attachments/1374111/2085739/systematics.pdf
		]
		self.tau_efficiency_corr_syst_args = [
			"CMS_eff_t_$ERA",
			"lnN",
			ch.SystMap("era", "channel")
				(["7TeV", "8TeV"], ["mt", "et"], 1.08)
				(["7TeV", "8TeV"], ["tt"],       1.19)
				(       ["13TeV"], ["mt", "et", "tt"], 1.05) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.tau_efficiency_syst_args = [
			"CMS_eff_t_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("era", "channel")
				(["7TeV", "8TeV"], ["mt", "et"], 1.08)
				(["7TeV", "8TeV"], ["tt"],       1.19)
				(       ["13TeV"], ["mt", "et", "tt"], 1.03) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.tau_efficiency2016_corr_syst_args = [
			"CMS_eff_t_$ERA",
			"lnN",
			ch.SystMap("era", "channel")
				(       ["13TeV"], ["mt", "et"], 1.045) # https://github.com/cms-analysis/CombineHarvester/blob/SM2016-dev/HTTSM2016/src/HttSystematics_SMRun2.cc#L103-L128
		]
		self.tau_efficiency2016_tt_corr_syst_args = [
			"CMS_eff_t_$ERA",
			"lnN",
			ch.SystMap("era", "channel", "process")
				(       ["13TeV"], ["tt"], ["ZTT", "EWKZ", "VVT", "TTT", "ggH", "qqH", "WH", "ZH"], 1.09) # https://github.com/cms-analysis/CombineHarvester/blob/SM2016-dev/HTTSM2016/src/HttSystematics_SMRun2.cc#L103-L128
				(       ["13TeV"], ["tt"], ["ZJ", "VVJ", "TTJJ", "W"], 1.06) # https://github.com/cms-analysis/CombineHarvester/blob/SM2016-dev/HTTSM2016/src/HttSystematics_SMRun2.cc#L103-L128
		]
		self.tau_efficiency2016_syst_args = [
			"CMS_eff_t_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("era", "channel")
				(       ["13TeV"], ["mt", "et"], 1.02) # https://github.com/cms-analysis/CombineHarvester/blob/SM2016-dev/HTTSM2016/src/HttSystematics_SMRun2.cc#L103-L128
		]
		self.tau_efficiency2016_tt_syst_args = [
			"CMS_eff_t_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("era", "channel", "process")
				(       ["13TeV"], ["tt"], ["ZTT", "EWKZ", "VVT", "TTT", "ggH", "qqH", "WH", "ZH"], 1.04) # https://github.com/cms-analysis/CombineHarvester/blob/SM2016-dev/HTTSM2016/src/HttSystematics_SMRun2.cc#L103-L128
				(       ["13TeV"], ["tt"], ["ZJ", "VVJ", "TTJJ", "W"], 1.02) # https://github.com/cms-analysis/CombineHarvester/blob/SM2016-dev/HTTSM2016/src/HttSystematics_SMRun2.cc#L103-L128
		]
		self.btag_efficiency2016_syst_args = [ # https://github.com/cms-analysis/CombineHarvester/blob/SM2016-dev/HTTSM2016/src/HttSystematics_SMRun2.cc#L151-L154
			"CMS_htt_eff_b_$ERA",
			"lnN",
			ch.SystMap("era", "channel", "bin", "process")
				(["13TeV"], ["em"], ["TTJ", "TTJJ", "TTT", "TT"], ["em_ZeroJet2D"], 1.035)
				(["13TeV"], ["em"], ["TTJ", "TTJJ", "TTT", "TT"], ["em_Boosted2D", "em_Vbf2D"], 1.05)
				(["13TeV"], ["em"], ["VVJ", "VVT", "VV"], ["em_Boosted2D", "em_Vbf2D"], 1.015)
		]
		
		##-------------------------------Normalization-------------------------------##

		self.zee_norm_syst_args = [
			"CMS_$ANALYSIS_zeeNorm_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(       ["13TeV"], ["ZLL", "ZL"], 1.03) # Source?
		]
		self.htt_zmm_norm_extrap_0jet = [
			"CMS_htt_zmm_norm_extrap_0jet_$CHANNEL_$ERA", 
			"lnN", 
			ch.SystMap("channel", "era", "process")
				(["em"], ["13TeV"], ["ZTT", "ZLL", "EWKZ"], 1.07)
				(["et"], ["13TeV"], ["ZTT", "ZL", "ZJ", "EWKZ"], 1.07)
				(["mt"], ["13TeV"], ["ZTT", "ZL", "ZJ", "EWKZ"], 1.07)
		]
		self.htt_zmm_norm_extrap_boosted = [
			"CMS_htt_zmm_norm_extrap_boosted_$CHANNEL_$ERA", 
			"lnN", 
			ch.SystMap("channel", "era", "process")
				(["em"], ["13TeV"], ["ZTT", "ZLL", "EWKZ"], 1.07)
				(["et"], ["13TeV"], ["ZTT", "ZL", "ZJ", "EWKZ"], 1.07)
				(["mt"], ["13TeV"], ["ZTT", "ZL", "ZJ", "EWKZ"], 1.07)
		]
		self.htt_wnorm_syst_args = [
			"CMS_htt_WNorm_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(       ["13TeV"], ["W"], 1.10) # Source?
		]
		self.htt_ttnorm_syst_args = [
			"CMS_httTTNorm_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(       ["13TeV"], ["TTT", "TTJ"], 1.10) # Source?
		]				
		self.htt_vvnorm_syst_args = [
			"CMS_htt_VVNorm_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(       ["13TeV"], ["VVT", "VVJ"], 1.10) # Source?
		]
		##-------------------------------Scale-------------------------------##

		self.met_scale_syst_args = [
			"CMS_$ANALYSIS_scale_met_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(["13TeV"], ["ggH", "qqH", "WH", "ZH", "VH"], 0.98) # copied from 8TeV
				(["13TeV"], ["ZTT", "ZLL", "ZL", "ZJ", "TTJ", "TTJJ", "TTT", "TT", "VV", "WJ", "W"], 1.03) # copied from 8TeV
		]
		self.boson_scale_met_syst_args = [
			"CMS_$ANALYSIS_boson_scale_met",
			"lnN",
			ch.SystMap("channel")
				(["mt"], 1.02)
		]
		self.ewk_top_scale_met_syst_args = [
			"CMS_$ANALYSIS_ewkTop_scale_met",
			"lnN",
			ch.SystMap("channel")
				(["mt"], 1.03)
		]
		self.htt_qcd_scale_syst_args = [	# https://twiki.cern.ch/twiki/bin/view/LHCPhysics/CERNYellowReportPageAt1314TeV2014#s_13_0_TeV
			"QCD_scale_$PROCESS",
			"lnN",
			ch.SystMap("era", "process")
				(["13TeV"], ["ggH"], 1.079)
				(["13TeV"], ["qqH"], 1.007)
				(["13TeV"], ["VH"], 1.015)
				(["13TeV"], ["WH"], 1.015)
				(["13TeV"], ["ZH"], 1.038)
		]
		self.htt_pdf_scale_syst_args = [
			"PDF_scale_$PROCESS",
			"lnN",
			ch.SystMap("era", "process")
				(["13TeV"], ["ggH"], 1.071)
				(["13TeV"], ["qqH"], 1.032)
				(["13TeV"], ["VH"], 1.022)
				(["13TeV"], ["WH"], 1.022)
				(["13TeV"], ["ZH"], 1.022)
		]
		self.htt_qcd_scale_qqh_syst_args = [ # for 13 TeV ggH gets shape uncertainty
			"CMS_qqH_QCDUnc",
			"lnN",
			ch.SystMap("channel", "bin", "process")
				(["em"], ["em_ZeroJet2D"], ["qqH"], 0.997)
				(["em"], ["em_Boosted2D"], ["qqH"], 1.004)
				(["em"], ["em_Vbf2D"], ["qqH"], 1.005)
				
				(["et"], ["et_ZeroJet2D"], ["qqH"], 1.003)
				(["et"], ["et_Boosted2D"], ["qqH"], 1.004)
				(["et"], ["et_Vbf2D"], ["qqH"], 1.005)
				
				(["mt"], ["mt_ZeroJet2D"], ["qqH"], 0.998)
				(["mt"], ["mt_Boosted2D"], ["qqH"], 1.002)
				(["mt"], ["mt_Vbf2D"], ["qqH"], 1.002)
				
				(["tt"], ["tt_ZeroJet2D"], ["qqH"], 0.997)
				(["tt"], ["tt_Boosted2D"], ["qqH"], 1.003)
				(["tt"], ["tt_Vbf2D"], ["qqH"], 1.003)
		]
		self.htt_pdf_scale_smhtt_syst_args = [
			"CMS_$PROCESS_PDF",
			"lnN",
			ch.SystMap("channel", "bin", "process")
				(["em"], ["em_ZeroJet2D"], ["ggH"], 1.007)
				(["em"], ["em_Boosted2D"], ["ggH"], 1.007)
				(["em"], ["em_Vbf2D"], ["ggH"], 1.007)
				(["em"], ["em_ZeroJet2D"], ["qqH"], 1.011)
				(["em"], ["em_Boosted2D"], ["qqH"], 1.005)
				(["em"], ["em_Vbf2D"], ["qqH"], 1.005)
				
				(["et"], ["et_ZeroJet2D"], ["ggH"], 1.007)
				(["et"], ["et_Boosted2D"], ["ggH"], 1.007)
				(["et"], ["et_Vbf2D"], ["ggH"], 1.007)
				(["et"], ["et_ZeroJet2D"], ["qqH"], 1.005)
				(["et"], ["et_Boosted2D"], ["qqH"], 1.002)
				(["et"], ["et_Vbf2D"], ["qqH"], 1.005)
				
				(["mt"], ["mt_ZeroJet2D"], ["ggH"], 1.007)
				(["mt"], ["mt_Boosted2D"], ["ggH"], 1.007)
				(["mt"], ["mt_Vbf2D"], ["ggH"], 1.007)
				(["mt"], ["mt_ZeroJet2D"], ["qqH"], 1.005)
				(["mt"], ["mt_Boosted2D"], ["qqH"], 1.002)
				(["mt"], ["mt_Vbf2D"], ["qqH"], 1.005)
				
				(["tt"], ["tt_ZeroJet2D"], ["ggH"], 1.009)
				(["tt"], ["tt_Boosted2D"], ["ggH"], 1.009)
				(["tt"], ["tt_Vbf2D"], ["ggH"], 1.009)
				(["tt"], ["tt_ZeroJet2D"], ["qqH"], 1.008)
				(["tt"], ["tt_Boosted2D"], ["qqH"], 1.003)
				(["tt"], ["tt_Vbf2D"], ["qqH"], 1.005)
		]
		self.ztt_qcd_scale_syst_args = [
			"CMS_$ANALYSIS_QCDscale_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(["13TeV"], ["ZTT"], 1.005) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.ztt_qcd_scale_tt_syst_args = [
			"CMS_$ANALYSIS_QCDscale_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("era", "process", "channel")
				(["13TeV"], ["ZTT"], ["tt"], 1.06)
		]
		self.ztt_pdf_scale_syst_args = [
			"CMS_$ANALYSIS_pdf_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(["13TeV"], ["ZTT"], 1.015) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]

		##-------------------------------Resolution-------------------------------##

		self.boson_resolution_met_syst_args = [
			"CMS_$ANALYSIS_boson_reso_met",
			"lnN",
			ch.SystMap("channel")
				(["mt"], 1.02)
		]
		self.ewk_top_resolution_met_syst_args = [
			"CMS_$ANALYSIS_ewkTop_reso_met",
			"lnN",
			ch.SystMap("channel")
				(["mt"], 1.01)
		]
		
		##-------------------------------Fake rate-------------------------------##
		
		self.zllFakeTau_syst_args = [
			"CMS_$ANALYSIS_eFakeTau_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("era", "process", "channel")
				(["7TeV", "8TeV"], ["ZLL"], ["mt", "et"], 1.30)
				(       ["13TeV"], ["ZLL", "ZL", "ZJ"], ["mt", "tt"], 1.15) #CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
				(       ["13TeV"], ["ZLL", "ZL", "ZJ"], ["et"], 1.30) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.eFakeTau_vloose_syst_args = [
			"CMS_$ANALYSIS_rate_eFakeTau_vloose_$ERA",
			"lnN",
			ch.SystMap("era", "process", "channel")
				(       ["13TeV"], ["ZLL", "ZL"], ["mt", "tt"], 1.10) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.eFakeTau_tight_syst_args = [
			"CMS_$ANALYSIS_rate_eFakeTau_tight_$ERA",
			"lnN",
			ch.SystMap("era", "process", "channel")
				(       ["13TeV"], ["ZLL", "ZL"], ["et"], 1.30) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.muFakeTau_tight_syst_args = [
			"CMS_$ANALYSIS_rate_muFakeTau_tight_$ERA",
			"lnN",
			ch.SystMap("era", "process", "channel")
				(       ["13TeV"], ["ZLL", "ZL"], ["mt"], 1.30) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]		
		self.eFakeTau2016_syst_args = [
			"CMS_$ANALYSIS_eFakeTau_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(       ["13TeV"], ["ZLL", "ZL"], 1.12) # https://indico.cern.ch/event/566822/contributions/2377598/attachments/1374111/2085739/systematics.pdf
		]
		self.muFakeTau_syst_args = [
			"CMS_$ANALYSIS_mFakeTau_$ERA",
			"lnN",
			ch.SystMap("era", "process",)
				(       ["13TeV"], ["ZLL", "ZL"], 2.00) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.muFakeTau2016_syst_args = [
			"CMS_$ANALYSIS_mFakeTau_$ERA",
			"lnN",
			ch.SystMap("era", "process",)
				(       ["13TeV"], ["ZLL", "ZL"], 1.25) # https://indico.cern.ch/event/566822/contributions/2377598/attachments/1374111/2085739/systematics.pdf
		]
		self.zjFakeTau_syst_args = [
			"CMS_$ANALYSIS_zjFakeTau_$ERA",
			"lnN",
			ch.SystMap("era", "process",)
				(       ["13TeV"], ["ZLL", "ZL"], 1.30) # From Yuta's polarisation analysis
		]
		self.jetFakeTau_syst_args = [
			"CMS_$ANALYSIS_jetFakeTau_$ERA",
			"lnN",
			ch.SystMap("era", "process",)
				(       ["13TeV"], ["ZJ", "TTJJ", "VVJ"], 1.20)
		]		

		##-------------------------------QCD-------------------------------##
		
		self.ttj_extrapol_syst_args = [
			"CMS_$ANALYSIS_ttjExtrapol_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(["13TeV"], ["TTJ", "TT"], 1.10) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.wj_extrapol_syst_args = [
			"CMS_$ANALYSIS_wjExtrapol_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(       ["13TeV"], ["WJ", "W"], 1.2) # CV https://indico.cern.ch/event/515350/contributions/1194776/attachments/1257261/1856581/HttNuisanceParamUpdate_2016Apr13.pdf
		]
		self.qcd_syst_args = [
			"CMS_$ANALYSIS_qcdSyst_$BIN_$ERA",
			"lnN",
			ch.SystMap("era", "process", "bin")
				(["13TeV"], ["QCD"], ["mt_inclusive", "et_inclusive"], 1.06) # copied from 8TeV

				(["13TeV"], ["QCD"], ["mt_0jet_high"], 1.1) # copied from 8TeV
				(["13TeV"], ["QCD"], ["mt_0jet_low"], 1.1) # copied from 8TeV
				(["13TeV"], ["QCD"], ["mt_1jet_high"], 1.1) # copied from 8TeV
				(["13TeV"], ["QCD"], ["mt_1jet_low"], 1.1) # copied from 8TeV
				(["13TeV"], ["QCD"], ["mt_2jet_vbf"], 1.3) # copied from 8TeV

				(["13TeV"], ["QCD"], ["et_0jet_high"], 1.06) # copied from 8TeV
				(["13TeV"], ["QCD"], ["et_0jet_low"], 1.06) # copied from 8TeV
				(["13TeV"], ["QCD"], ["et_1jet_high"], 1.1) # copied from 8TeV
				(["13TeV"], ["QCD"], ["et_1jet_low"], 1.1) # copied from 8TeV
				(["13TeV"], ["QCD"], ["et_2jet_vbf"], 1.3) # copied from 8TeV

				(["13TeV"], ["QCD"], ["tt_inclusive"], 1.35) # copied from 8TeV
		]
		self.qcd_syst_inclusive_args = [
			"CMS_$ANALYSIS_qcdSyst_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(["13TeV"], ["QCD"], 1.10)
		]
		self.htt_QCD_0jet_syst_args = [
			"CMS_htt_QCD_0jet_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("channel", "era", "process")
				(["em"], ["13TeV"], ["QCD"], 1.10)
		]
		self.htt_QCD_boosted_syst_args = [
			"CMS_htt_QCD_boosted_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("channel", "era", "process")
				(["em"], ["13TeV"], ["QCD"], 1.20)
		]	
		self.QCD_Extrap_Iso_nonIso_syst_args = [
			"CMS_QCD_Extrap_Iso_nonIso_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("channel", "era", "process")
				(["mt"], ["13TeV"], ["QCD"], 1.20)
				(["et"], ["13TeV"], ["QCD"], 1.20)
		]
		self.WHighMTtoLowMT_0jet_syst_args = [
			"CMS_WHighMTtoLowMT_0jet_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("channel", "era", "process")
				(["mt"], ["13TeV"], ["W"], 1.10)
				(["et"], ["13TeV"], ["W"], 1.10)
		]
		self.WHighMTtoLowMT_boosted_syst_args = [
			"CMS_WHighMTtoLowMT_boosted_$CHANNEL_$ERA",
			"lnN",
			ch.SystMap("channel", "era", "process")
				(["mt"], ["13TeV"], ["W"], 1.05)
				(["et"], ["13TeV"], ["W"], 1.05)
		]

		##-------------------------------Theoretical uncertanty-------------------------------##

		self.lfv_BR_syst_args = [
			"CMS_lfv_BR_$PROCESS_$ERA",
			"lnN",
			ch.SystMap("era", "process")
				(["13TeV"], ["zem"], 1.00)
				(["13TeV"], ["zet"], 1.00)
				(["13TeV"], ["zmt"], 1.00)
				
		]
		
		# Uncertainties on the jet bin acceptance for the Higgs boson signal - Stewart-Tackamnn method (ST)
		# https://cds.cern.ch/record/2227475/files/CERN-2017-002-M.pdf Section: I.4.2.b
		
		ggH_signal_processes = ["ggH", "gghjhusm", "gghjhumm", "gghjhups"]
		
		self.CMS_ggH_STXSVBF2j_syst_args = [
			"CMS_ggH_STXSVBF2j",
			"lnN",
			ch.SystMap("bin", "process")
				(["em_ZeroJet2D"], ggH_signal_processes, 1.000)
				(["em_Boosted2D"], ggH_signal_processes, 1.000)
				(["em_dijet_boosted"], ggH_signal_processes, 1.2)
				(["em_dijet_lowM"], ggH_signal_processes, 1.2)
				(["em_dijet_highM"], ggH_signal_processes, 1.2)
				(["em_dijet_lowMjj"], ggH_signal_processes, 1.2)

				(["et_ZeroJet2D"], ["ggH"], 1.000)
				(["et_Boosted2D"], ["ggH"], 1.000)
				(["et_dijet_boosted"], ggH_signal_processes, 1.2)
				(["et_dijet_lowM"], ggH_signal_processes, 1.2)
				(["et_dijet_highM"], ggH_signal_processes, 1.2)
				(["et_dijet_lowMjj"], ggH_signal_processes, 1.2)
				
				(["mt_ZeroJet2D"], ["ggH"], 1.000)
				(["mt_Boosted2D"], ["ggH"], 1.000)
				(["mt_dijet_boosted"], ggH_signal_processes, 1.2)
				(["mt_dijet_lowM"], ggH_signal_processes, 1.2)
				(["mt_dijet_highM"], ggH_signal_processes, 1.2)
				(["mt_dijet_lowMjj"], ggH_signal_processes, 1.2)
				
				(["tt_ZeroJet2D"], ["ggH"], 1.000)
				(["tt_Boosted2D"], ["ggH"], 1.000)
				(["tt_dijet_boosted"], ggH_signal_processes, 1.2)
				(["tt_dijet_lowM"], ggH_signal_processes, 1.2)
				(["tt_dijet_highM"], ggH_signal_processes, 1.2)
				(["tt_dijet_lowMjj"], ggH_signal_processes, 1.2) 								
		]	
		self.CMS_ggH_STXSmig12_syst_args = [
			"CMS_ggH_STXSmig12",
			"lnN",
			ch.SystMap("bin", "process")
				(["em_ZeroJet2D"], ["ggH"], 1.000)
				(["em_Boosted2D"], ["ggH"], 0.932)
				(["em_dijet_boosted"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["em_dijet_lowM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["em_dijet_highM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["em_dijet_lowMjj"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)

				(["et_ZeroJet2D"], ["ggH"], 1.000)
				(["et_Boosted2D"], ["ggH"], 0.932)
				(["et_dijet_boosted"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["et_dijet_lowM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["et_dijet_highM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["et_dijet_lowMjj"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				
				(["mt_ZeroJet2D"], ["ggH"], 1.000)
				(["mt_Boosted2D"], ["ggH"], 0.932)
				(["mt_dijet_boosted"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["mt_dijet_lowM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["mt_dijet_highM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["mt_dijet_lowMjj"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				
				(["tt_ZeroJet2D"], ["ggH"], 1.000)
				(["tt_Boosted2D"], ["ggH"], 0.932)
				(["tt_dijet_boosted"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["tt_dijet_lowM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["tt_dijet_highM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161)
				(["tt_dijet_lowMjj"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.161) 								
		]				
		self.CMS_ggH_STXSmig01_syst_args = [
			"CMS_ggH_STXSmig01",
			"lnN",
			ch.SystMap("bin", "process")
				(["em_ZeroJet2D"], ["ggH"], 0.959)
				(["em_Boosted2D"], ["ggH"], 1.079)
				(["em_dijet_boosted"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["em_dijet_lowM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["em_dijet_highM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["em_dijet_lowMjj"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)

				(["et_ZeroJet2D"], ["ggH"], 0.959)
				(["et_Boosted2D"], ["ggH"], 1.079)
				(["et_dijet_boosted"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["et_dijet_lowM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["et_dijet_highM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["et_dijet_lowMjj"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				
				(["mt_ZeroJet2D"], ["ggH"], 0.959)
				(["mt_Boosted2D"], ["ggH"], 1.079)
				(["mt_dijet_boosted"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["mt_dijet_lowM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["mt_dijet_highM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["mt_dijet_lowMjj"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				
				(["tt_ZeroJet2D"], ["ggH"], 0.959)
				(["tt_Boosted2D"], ["ggH"], 1.079)
				(["tt_dijet_boosted"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["tt_dijet_lowM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["tt_dijet_highM"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079)
				(["tt_dijet_lowMjj"], ["ggH", "gghjhusm", "gghjhumm", "gghjhups"], 1.079) 								
		]			
		##-------------------------------Uncategorized-------------------------------##
		
	
		self.htt_ueps_smhtt_syst_args = [
			"CMS_$PROCESS_UEPS",
			"lnN",
			ch.SystMap("channel", "bin", "process")
				(["em"], ["em_ZeroJet2D"], ["ggH"], 1.015)
				(["em"], ["em_Boosted2D"], ["ggH"], 0.945)
				(["em"], ["em_Vbf2D"], ["ggH"], 1.03)
				(["em"], ["em_ZeroJet2D"], ["qqH"], 1.015)
				(["em"], ["em_Boosted2D"], ["qqH"], 0.945)
				(["em"], ["em_Vbf2D"], ["qqH"], 1.03)
				
				(["et"], ["et_ZeroJet2D"], ["ggH"], 1.015)
				(["et"], ["et_Boosted2D"], ["ggH"], 0.945)
				(["et"], ["et_Vbf2D"], ["ggH"], 1.03)
				(["et"], ["et_ZeroJet2D"], ["qqH"], 1.015)
				(["et"], ["et_Boosted2D"], ["qqH"], 0.945)
				(["et"], ["et_Vbf2D"], ["qqH"], 1.03)
				
				(["mt"], ["mt_ZeroJet2D"], ["ggH"], 1.015)
				(["mt"], ["mt_Boosted2D"], ["ggH"], 0.945)
				(["mt"], ["mt_Vbf2D"], ["ggH"], 1.03)
				(["mt"], ["mt_ZeroJet2D"], ["qqH"], 1.015)
				(["mt"], ["mt_Boosted2D"], ["qqH"], 0.945)
				(["mt"], ["mt_Vbf2D"], ["qqH"], 1.03)
				
				(["tt"], ["tt_ZeroJet2D"], ["ggH"], 1.015)
				(["tt"], ["tt_Boosted2D"], ["ggH"], 0.945)
				(["tt"], ["tt_Vbf2D"], ["ggH"], 1.03)
				(["tt"], ["tt_ZeroJet2D"], ["qqH"], 1.015)
				(["tt"], ["tt_Boosted2D"], ["qqH"], 0.945)
				(["tt"], ["tt_Vbf2D"], ["qqH"], 1.03)
		]
		self.htt_ueps_syst_args = [# CMS AN-13-262 (v8, table 3)
			"UEPS",
			"lnN",
			ch.SystMap("era", "process", "bin")
				(["13TeV"], ["ggH"], ["mt_0jet_high"], 1.060) # copied from 8TeV
				(["13TeV"], ["ggH"], ["mt_0jet_low"], 1.073) # copied from 8TeV
				(["13TeV"], ["ggH"], ["mt_1jet_high"], 0.996) # copied from 8TeV
				(["13TeV"], ["ggH"], ["mt_1jet_low"], 1.007) # copied from 8TeV
				(["13TeV"], ["ggH"], ["mt_2jet_vbf"], 0.988) # copied from 8TeV

				(["13TeV"], ["ggH"], ["et_0jet_high"], 1.060) # copied from 8TeV
				(["13TeV"], ["ggH"], ["et_0jet_low"], 1.073) # copied from 8TeV
				(["13TeV"], ["ggH"], ["et_1jet_high"], 0.996) # copied from 8TeV
				(["13TeV"], ["ggH"], ["et_1jet_low"], 1.007) # copied from 8TeV
				(["13TeV"], ["ggH"], ["et_2jet_vbf"], 0.988) # copied from 8TeV

				(["13TeV"], ["ggH"], ["em_0jet_high"], 1.063) # copied from 8TeV
				(["13TeV"], ["ggH"], ["em_0jet_low"], 1.089) # copied from 8TeV
				(["13TeV"], ["ggH"], ["em_1jet_high"], 1.004) # copied from 8TeV
				(["13TeV"], ["ggH"], ["em_1jet_low"], 1.000) # copied from 8TeV
				(["13TeV"], ["ggH"], ["em_2jet_vbf"], 0.988) # copied from 8TeV

				(["13TeV"], ["ggH"], ["tt_inclusive"], 1.025) # copied from 8TeV

				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["mt_0jet_high"], 1.028) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["mt_0jet_low"], 1.018) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["mt_1jet_high"], 0.954) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["mt_1jet_low"], 0.946) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["mt_2jet_vbf"], 0.893) # copied from 8TeV

				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["et_0jet_high"], 1.028) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["et_0jet_low"], 1.018) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["et_1jet_high"], 0.954) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["et_1jet_low"], 0.946) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["et_2jet_vbf"], 0.893) # copied from 8TeV

				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["em_0jet_high"], 1.042) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["em_0jet_low"], 1.035) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["em_1jet_high"], 0.978) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["em_1jet_low"], 0.984) # copied from 8TeV
				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["em_2jet_vbf"], 0.893) # copied from 8TeV

				(["13TeV"], ["qqH", "WH", "ZH", "VH"], ["tt_inclusive"], 1.025) # copied from 8TeV
		]

	##----------------------------------------------------------Shape uncertanties----------------------------------------------------------##
		
		##-------------------------------Fake Taus-------------------------------##		

		self.htt_jetToTauFake_syst_args = [
			"CMS_htt_jetToTauFake_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["et"], ["13TeV"], ["ZJ", "TTJJ", "VVJ", "W"], 1.0)
				(["mt"], ["13TeV"], ["ZJ", "TTJJ", "VVJ", "W"], 1.0)
				(["tt"], ["13TeV"], ["ZJ", "TTJJ", "VVJ", "W"], 1.0)
		]
		self.mFakeTau_1prong_syst_args = [
			"CMS_mFakeTau_1prong_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["mt"], ["13TeV"], ["ZL"], 1.0)
		]
		self.mFakeTau_1prong1pizero_syst_args = [
			"CMS_mFakeTau_1prong1pizero_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["mt"], ["13TeV"], ["ZL"], 1.0)
		]
		self.eFakeTau_1prong_syst_args = [
			"CMS_eFakeTau_1prong_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["et"], ["13TeV"], ["ZL"], 1.0)
		]
		self.eFakeTau_1prong1pizero_syst_args = [
			"CMS_eFakeTau_1prong1pizero_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["et"], ["13TeV"], ["ZL"], 1.0)
		]
		self.jetFakeTau_qcd_syst_args = [
			"CMS_$ANALYSIS_jetFakeTau_qcd_Shape_$ERA",
			"shape",
			ch.SystMap("era")
			(["13TeV"], 1.0)
		]
		self.jetFakeTau_w_syst_args = [
			"CMS_$ANALYSIS_jetFakeTau_w_Shape_$ERA",
			"shape",
			ch.SystMap("era")
			(["13TeV"], 1.0)
		]
		self.jetFakeTau_tt_corr_syst_args = [
			"CMS_$ANALYSIS_jetFakeTau_tt_corr_Shape_$ERA",
			"shape",
			ch.SystMap("era")
			(["13TeV"], 1.0)
		]
		self.jetFakeTau_tt_stat_syst_args = [
			"CMS_$ANALYSIS_jetFakeTau_tt_stat_Shape_$ERA",
			"shape",
			ch.SystMap("era")
			(["13TeV"], 1.0)
		]
		self.jetFakeTau_frac_qcd_syst_args = [
			"CMS_$ANALYSIS_jetFakeTau_frac_qcd_Shape_$ERA",
			"shape",
			ch.SystMap("era")
			(["13TeV"], 1.0)
		]
		self.jetFakeTau_frac_tt_syst_args = [
			"CMS_$ANALYSIS_jetFakeTau_frac_tt_Shape_$ERA",
			"shape",
			ch.SystMap("era")
			(["13TeV"], 1.0)
		]
		self.jetFakeTau_frac_w_syst_args = [
			"CMS_$ANALYSIS_jetFakeTau_frac_w_Shape_$ERA",
			"shape",
			ch.SystMap("era")
			(["13TeV"], 1.0)
		]
		self.jetFakeTau_frac_dy_syst_args = [
			"CMS_$ANALYSIS_jetFakeTau_frac_dy_Shape_$ERA",
			"shape",
			ch.SystMap("era")
			(["13TeV"], 1.0)
		]
		
		##-------------------------------Energy scale-------------------------------##		
		
		self.tau_es_syst_args = [
			"CMS_scale_t_$CHANNEL_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["mt"], 1.0)
				(["13TeV"], ["et"], 1.0)
				(["13TeV"], ["tt"], 1.0)
		]
		self.tau_es_corr_syst_args = [
			"CMS_scale_t_$ERA",
			"shape",
			ch.SystMap("era")
				(["13TeV"], 1.0)
		]
		self.ele_es_syst_args = [
			"CMS_scale_e_$CHANNEL_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["em"], 1.0)
				(["13TeV"], ["et"], 1.0)
		]
		self.mu_es_syst_args = [
			"CMS_scale_m_$CHANNEL_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["em"], 1.0)
				(["13TeV"], ["mt"], 1.0)
		]
		self.probetau_es_syst_args = [
			"CMS_scale_probetau_$CHANNEL_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["et"], 1.0)
		]
		self.probeele_es_syst_args = [
			"CMS_scale_probeele_$CHANNEL_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["et"], 1.0)
		]
		self.tagele_es_syst_args = [
			"CMS_scale_tagele_$CHANNEL_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["et"], 1.0)
		]
		self.muFakeTau_es_syst_args = [
			"CMS_$ANALYSIS_scale_mFakeTau_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["mt"], 1.0)
		]
		self.eleFakeTau_es_syst_args = [
			"CMS_$ANALYSIS_scale_eFakeTau_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["et"], 1.0)
		]
		self.jec_syst_args = [
			"CMS_scale_j_$ERA",
			"shape",
			ch.SystMap("era")
				(["13TeV"], 1.0)
		]

		##-------------------------------Shape-------------------------------##
		
		self.dy_shape_syst_args = [
			"CMS_htt_dyShape_$ERA",
			"shape",
			ch.SystMap("era")
				(["13TeV"], 1.0)
		]
		self.zl_shape_1prong_syst_args = [
			"CMS_ZLShape_$CHANNEL_1prong_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["et"], ["13TeV"], ["ZL"], 1.0)
				(["mt"], ["13TeV"], ["ZL"], 1.0)
		]
		self.zl_shape_1prong1pizero_syst_args = [
			"CMS_ZLShape_$CHANNEL_1prong1pizero_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["et"], ["13TeV"], ["ZL"], 1.0)
				(["mt"], ["13TeV"], ["ZL"], 1.0)
		]


		##--------------------------Decay mode reweighting------------------##

		self.tauDMReco_1prong_syst_args = [
			"CMS_tauDMReco_1prong_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["mt"], ["13TeV"], ["ZTT"], 1.0)
				(["et"], ["13TeV"], ["ZTT"], 1.0)
		]

		self.tauDMReco_1prong1pizero_syst_args = [
			"CMS_tauDMReco_1prong1pizero_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["mt"], ["13TeV"], ["ZTT"], 1.0)
				(["et"], ["13TeV"], ["ZTT"], 1.0)
		]
		self.tauDMReco_3prong_syst_args = [
			"CMS_tauDMReco_3prong_$ERA",
			"shape",
			ch.SystMap("channel", "era", "process")
				(["mt"], ["13TeV"], ["ZTT"], 1.0)
				(["et"], ["13TeV"], ["ZTT"], 1.0)
		]
		##-------------------------------Scale-------------------------------##

		self.scale_t_1prong_syst_args = [
			"CMS_scale_t_1prong_$ERA",
			"shape",
			ch.SystMap("channel", "era")
				(["et"], ["13TeV"], 1.0)
				(["mt"], ["13TeV"], 1.0)
				(["tt"], ["13TeV"], 1.0)
		]
		self.scale_t_3prong_syst_args = [
			"CMS_scale_t_3prong_$ERA",
			"shape",
			ch.SystMap("channel", "era")
				(["et"], ["13TeV"], 1.0)
				(["mt"], ["13TeV"], 1.0)
				(["tt"], ["13TeV"], 1.0)
		]
		self.scale_t_1prong1pizero_syst_args = [
			"CMS_scale_t_1prong1pizero_$ERA",
			"shape",
			ch.SystMap("channel", "era")
				(["et"], ["13TeV"], 1.0)
				(["mt"], ["13TeV"], 1.0)
				(["tt"], ["13TeV"], 1.0)
		]

		##-------------------------------QCD-------------------------------##

		self.btag_mistag_syst_args = [
			"CMS_mistag_b_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["em","et","mt"], 1.0)
		]
		self.btag_efficiency_syst_args = [
			"CMS_eff_b_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["em","et","mt"], 1.0)
		]
		self.ttj_syst_args = [
			"CMS_htt_ttbarShape_$ERA",
			"shape",
			ch.SystMap("era")
				(["13TeV"], 1.0)
		]
		self.htt_jetFakeLep_syst_args = [
			"CMS_htt_jetFakeLep_$ERA",
			"lnN",
			ch.SystMap("channel", "era", "process")
				(["em"], ["13TeV"], ["W"], 1.20)
		]
		
		self.WSFUncert_0jet_syst_args = [
			"CMS_WSFUncert_$CHANNEL_0jet_$ERA",
			"shape",
			ch.SystMap("era", "channel", "process")
				(["13TeV"], ["et","mt"], ["QCD"], 1.0)
		]

		self.WSFUncert_boosted_syst_args = [
			"CMS_WSFUncert_$CHANNEL_boosted_$ERA",
			"shape",
			ch.SystMap("era", "channel", "process")
				(["13TeV"], ["et","mt"], ["QCD"], 1.0)
		]

		self.WSFUncert_Vbf_syst_args = [
			"CMS_WSFUncert_$CHANNEL_vbf_$ERA",
			"shape",
			ch.SystMap("era", "channel", "process")
				(["13TeV"], ["et","mt"], ["QCD"], 1.0)
		]

		##-------------------------------MET-------------------------------##
		
		self.met_resp_syst_args = [
			"CMS_scale_met_$CHANNEL_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["em"], 1.0)
				(["13TeV"], ["et"], 1.0)
				(["13TeV"], ["mt"], 1.0)
				(["13TeV"], ["tt"], 1.0)
		]
		self.scale_met_clustered_syst_args = [
			"CMS_scale_met_clustered_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["em"], 1.0)
				(["13TeV"], ["et"], 1.0)
				(["13TeV"], ["mt"], 1.0)
				(["13TeV"], ["tt"], 1.0)
		]
		self.scale_met_unclustered_syst_args = [
			"CMS_scale_met_unclustered_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["em"], 1.0)
				(["13TeV"], ["et"], 1.0)
				(["13TeV"], ["mt"], 1.0)
				(["13TeV"], ["tt"], 1.0)
		]	
				


		self.massres_syst_args = [
			"CMS_scale_massRes_$CHANNEL_$ERA",
			"shape",
			ch.SystMap("era", "channel")
				(["13TeV"], ["et"], 1.0)
		]