def write_datacard(): lostlep_sf = get_lostlep_sf() # Get the lost lepton scale factors hists = get_yield_hists( "SR", True, lostlep_sf ) # Get the main yields with lost lepton scale factors applied systs = get_systs() # Get all systematic histograms # putting together the background histograms bgs = [hists[x] for x in config["bkg_order"]] # Write to the datacard # d = dw.DataCardWriter(sig=hists["www"], bgs=bgs, data=None, datacard_filename="datacard.txt", systs=systs, no_stat_procs=["lostlep"]) d = dw.DataCardWriter(sig=hists["www"], bgs=bgs, data=hists["data"], datacard_filename="datacard.txt", systs=systs, no_stat_procs=["lostlep"]) # Create output directory os.system("mkdir -p {}".format(config["output_dir"])) # Region names reg_names = ["b{}".format(index) for index in xrange(1, 10)] # Write the datacards for each regions for i, reg_name in enumerate(reg_names): d.set_bin(i + 1) # TH1 bin indices start with 1 d.set_region_name(reg_name) d.write("{}/datacard_{}.txt".format(config["output_dir"], reg_name)) print "Wrote datacards to {}".format(config["output_dir"])
def write_datacard_w_control_regions(): # # Signal region # hists = get_yield_hists( "SR", True) # Get the main yields without lost lepton scale factors applied systs = get_systs(apply_lostlep_sf=False, include_lostlep=True) # Get all systematic histograms # putting together the background histograms bgs = [hists[x] for x in config["bkg_order"]] # Write to the datacard d = dw.DataCardWriter(sig=hists["www"], bgs=bgs, data=hists["data"], datacard_filename="datacard.txt", systs=systs) # Region names reg_names = ["s{}".format(index) for index in xrange(1, 10)] # Write the datacards for each regions for i, reg_name in enumerate(reg_names): d.set_bin(i + 1) # TH1 bin indices start with 1 d.set_region_name(reg_name) d.write("{}/datacard_{}.txt".format(config["output_dir"], reg_name)) # # Lost Lep Control region # hists = get_yield_hists( "WZCR", True ) # Get the main yields without lost lepton scale factors applied in control region systs = get_systs("WZCR", apply_lostlep_sf=False, include_lostlep=True) # Get all systematic histograms # putting together the background histograms bgs = [hists[x] for x in config["bkg_order"]] # Write to the datacard d = dw.DataCardWriter(sig=hists["www"], bgs=bgs, data=hists["data"], datacard_filename="datacard.txt", systs=systs) # Region names reg_names = ["c{}".format(index) for index in xrange(1, 10)] # Write the datacards for each regions for i, reg_name in enumerate(reg_names): d.set_bin(i + 1) # TH1 bin indices start with 1 d.set_region_name(reg_name) d.write("{}/datacard_{}.txt".format(config["output_dir"], reg_name)) print "Wrote datacards to {}".format(config["output_dir"])
"0SFOS", "1SFOS", "2SFOS", ], hsuffix="__yield")) print hists bkg_hists = hists[:-1] sig_hists = [hists[-1]] bkg_hists[0].SetTitle("photon") bkg_hists[1].SetTitle("qflip") bkg_hists[2].SetTitle("ddfakes") bkg_hists[3].SetTitle("lostlep") bkg_hists[4].SetTitle("prompt") sig_hists[0].SetTitle("signal") # Now create data card writer # bkg2 does not need stat error as it is taken care of by CR stats d = dw.DataCardWriter(sig=sig_hists[0], bgs=bkg_hists, data=None, systs=systs, no_stat_procs=["ddfakes", "lostlep"]) for i in xrange(1, sig_hists[0].GetNbinsX() + 1): d.set_bin(i) d.set_region_name("bin{}".format(i)) d.write("datacards_simple/www_{}.txt".format(i))