HiggsAnalysis-KITHiggsToTauTau
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
makePlots_datacardsQCDfactors.py File Reference

Namespaces

 makePlots_datacardsQCDfactors
 

Functions

def makePlots_datacardsQCDfactors.addArguments
 
def makePlots_datacardsQCDfactors.matching_process
 
def makePlots_datacardsQCDfactors.remove_procs_and_systs_with_zero_yield
 

Variables

tuple makePlots_datacardsQCDfactors.log = logging.getLogger(__name__)
 
tuple makePlots_datacardsQCDfactors.parser
 
tuple makePlots_datacardsQCDfactors.args = parser.parse_args()
 
tuple makePlots_datacardsQCDfactors.clear_output_dir = raw_input("Do you really want to clear the output directory? [yes]")
 
tuple makePlots_datacardsQCDfactors.sample_settings = samples.Samples()
 
tuple makePlots_datacardsQCDfactors.systematics_factory = systematics.SystematicsFactory()
 
list makePlots_datacardsQCDfactors.www_output_dirs_postfit = []
 
list makePlots_datacardsQCDfactors.www_output_dirs_weightbin = []
 
list makePlots_datacardsQCDfactors.www_output_dirs_parabola = []
 
string makePlots_datacardsQCDfactors.tmp_input_root_filename_template = "input/${ANALYSIS}_${CHANNEL}_${BIN}_${SYSTEMATIC}_${ERA}.root"
 
string makePlots_datacardsQCDfactors.input_root_filename_template = "input/${ANALYSIS}_${CHANNEL}_${BIN}_${ERA}.root"
 
string makePlots_datacardsQCDfactors.bkg_histogram_name_template = "${BIN}/${PROCESS}"
 
string makePlots_datacardsQCDfactors.sig_histogram_name_template = "${BIN}/${PROCESS}${MASS}"
 
string makePlots_datacardsQCDfactors.bkg_syst_histogram_name_template = "${BIN}/${PROCESS}_${SYSTEMATIC}"
 
string makePlots_datacardsQCDfactors.sig_syst_histogram_name_template = "${BIN}/${PROCESS}${MASS}_${SYSTEMATIC}"
 
list makePlots_datacardsQCDfactors.datacard_filename_templates = ["datacards/${BIN}/${ANALYSIS}_${CHANNEL}_${BIN}_${ERA}.txt"]
 
string makePlots_datacardsQCDfactors.output_root_filename_template = "datacards/common/${ANALYSIS}.input_${ERA}.root"
 
 makePlots_datacardsQCDfactors.quantity = args.quantity
 
list makePlots_datacardsQCDfactors.categories = [channel+"_"+category for channel in args.channels for category in args.categories[0]]
 
dictionary makePlots_datacardsQCDfactors.mapping_category2binid = {}
 
tuple makePlots_datacardsQCDfactors.datacards = qcdfactorsdatacards.QcdFactorsDatacards(quantity, args.era, mapping_category2binid)
 
tuple makePlots_datacardsQCDfactors.channel = category.split("_")
 
 makePlots_datacardsQCDfactors.useRelaxedIsolation = False
 
tuple makePlots_datacardsQCDfactors.output_file
 
list makePlots_datacardsQCDfactors.input_plot_configs = []
 
list makePlots_datacardsQCDfactors.hadd_commands = []
 
tuple makePlots_datacardsQCDfactors.datacards_per_channel_category = qcdfactorsdatacards.QcdFactorsDatacards(cb=datacards.cb.cp().channel([channel]).bin([category]), mapping_category2binid=mapping_category2binid)
 
list makePlots_datacardsQCDfactors.tmp_output_files = []
 
tuple makePlots_datacardsQCDfactors.nominal = (shape_systematic == "nominal")
 
list makePlots_datacardsQCDfactors.list_of_samples = [datacards.configs.process2sample(process) for process in list_of_samples]
 
string makePlots_datacardsQCDfactors.systematic = "nominal"
 
string makePlots_datacardsQCDfactors.samples = "\", \""
 
 makePlots_datacardsQCDfactors.category = category,
 
dictionary makePlots_datacardsQCDfactors.merged_config = {}
 
tuple makePlots_datacardsQCDfactors.config_rest
 
 makePlots_datacardsQCDfactors.histogram_name_template = bkg_histogram_name_templateifnominalelsebkg_syst_histogram_name_template
 
tuple makePlots_datacardsQCDfactors.PROCESS = datacards.configs.sample2process(sample)
 
 makePlots_datacardsQCDfactors.BIN = category,
 
 makePlots_datacardsQCDfactors.SYSTEMATIC = systematic
 
tuple makePlots_datacardsQCDfactors.systematics_settings = systematics_factory.get(shape_systematic)
 
tuple makePlots_datacardsQCDfactors.config_ztt
 
tuple makePlots_datacardsQCDfactors.MASS = str(shift)
 
tuple makePlots_datacardsQCDfactors.tmp_output_file
 
 makePlots_datacardsQCDfactors.DST = output_file,
 
string makePlots_datacardsQCDfactors.SRC = " "
 
tuple makePlots_datacardsQCDfactors.output_files = list(set([os.path.join(config["output_dir"], config["filename"]+".root") for config in input_plot_configs[:args.n_plots[0]]]))
 
 makePlots_datacardsQCDfactors.update_systematics = True
 
tuple makePlots_datacardsQCDfactors.processes = datacards.cb.cp()
 
float makePlots_datacardsQCDfactors.add_threshold = 0.1
 
dictionary makePlots_datacardsQCDfactors.datacards_cbs = {}
 
tuple makePlots_datacardsQCDfactors.datacards_workspaces = datacards.text2workspace(datacards_cbs, n_processes=args.n_processes)
 
 makePlots_datacardsQCDfactors.VERBOSITY = args.combine_verbosity,
 
 makePlots_datacardsQCDfactors.STABLE = datacards.stable_options
 
tuple makePlots_datacardsQCDfactors.BINNING = int((args.shift_ranges[1]-args.shift_ranges[0])/args.shift_binning)
 
tuple makePlots_datacardsQCDfactors.RANGE = str(args.shift_ranges[0])
 
tuple makePlots_datacardsQCDfactors.datacards_postfit_shapes = datacards.postfit_shapes_fromworkspace(datacards_cbs, datacards_workspaces, True, args.n_processes, "--sampling" + (" --print" if args.n_processes <= 1 else ""))
 
list makePlots_datacardsQCDfactors.postfit_plot_configs = []
 
list makePlots_datacardsQCDfactors.bkg_plotting_order = ["ZTT", "ZL", "ZJ", "TTT","TTJJ", "VVT", "VVJ", "W", "QCD"]
 
tuple makePlots_datacardsQCDfactors.postfit_shapes = datacards_postfit_shapes.get("fit_s", {})
 
tuple makePlots_datacardsQCDfactors.decayMode = category.split("_")
 
tuple makePlots_datacardsQCDfactors.weightBin = int(category.split("_")[-1].split(weight_type+"bin")[-1])
 
list makePlots_datacardsQCDfactors.bkg_process = datacards_cbs[datacard]
 
list makePlots_datacardsQCDfactors.sig_process = datacards_cbs[datacard]
 
dictionary makePlots_datacardsQCDfactors.config = {}
 
tuple makePlots_datacardsQCDfactors.processes_to_plot = list(processes)
 
list makePlots_datacardsQCDfactors.parabola_plot_configs = []
 
list makePlots_datacardsQCDfactors.weightbin_plot_configs = []
 
tuple makePlots_datacardsQCDfactors.filename_mlfit = os.path.join(os.path.dirname(datacard), "mlfit.root")
 
tuple makePlots_datacardsQCDfactors.file_mlfit = ROOT.TFile(filename_mlfit)
 
tuple makePlots_datacardsQCDfactors.tree_mlfit = file_mlfit.Get("tree_fit_sb")
 
tuple makePlots_datacardsQCDfactors.filename_multidimfit = os.path.join(os.path.dirname(datacard), "higgsCombineTest.MultiDimFit.mH0.root")
 
tuple makePlots_datacardsQCDfactors.file_multidimfit = ROOT.TFile(filename_multidimfit)
 
tuple makePlots_datacardsQCDfactors.tree_multidimfit = file_multidimfit.Get("limit")
 
list makePlots_datacardsQCDfactors.mes_list = []
 
list makePlots_datacardsQCDfactors.deltaNLL_list = []
 
list makePlots_datacardsQCDfactors.deltaNLLshifted_list = []
 
list makePlots_datacardsQCDfactors.min_nll = deltaNLL_list[0]
 
list makePlots_datacardsQCDfactors.min_shift = mes_list[0]
 
list makePlots_datacardsQCDfactors.mes_list_nll_belowX = []
 
list makePlots_datacardsQCDfactors.nll_belowX = []
 
int makePlots_datacardsQCDfactors.nllMax = 10
 
 makePlots_datacardsQCDfactors.found2sigmaLow = True
 
tuple makePlots_datacardsQCDfactors.err2sigmaLow = abs((mes_list[index-1]+mes_list[index])/2.0 - min_shift)
 
 makePlots_datacardsQCDfactors.found1sigmaLow = True
 
tuple makePlots_datacardsQCDfactors.err1sigmaLow = abs((mes_list[index-1]+mes_list[index])/2.0 - min_shift)
 
 makePlots_datacardsQCDfactors.found1sigmaHi = True
 
tuple makePlots_datacardsQCDfactors.err1sigmaHi = abs((mes_list[index]+mes_list[index+1])/2.0 - min_shift)
 
 makePlots_datacardsQCDfactors.found2sigmaHi = True
 
tuple makePlots_datacardsQCDfactors.err2sigmaHi = abs((mes_list[index]+mes_list[index+1])/2.0 - min_shift)
 
list makePlots_datacardsQCDfactors.xvaluesF = []
 
string makePlots_datacardsQCDfactors.xvalues = ""
 
string makePlots_datacardsQCDfactors.yvalues = ""
 
list makePlots_datacardsQCDfactors.xvaluesF_belowX = []
 
tuple makePlots_datacardsQCDfactors.RooFitGraph_Parabola
 
tuple makePlots_datacardsQCDfactors.fitf = ROOT.TF1("f1","pol2",min(xvaluesF_belowX),max(xvaluesF_belowX))
 
tuple makePlots_datacardsQCDfactors.minimumScanFit = fitf.GetMinimumX(min(xvaluesF_belowX),max(xvaluesF_belowX))
 
tuple makePlots_datacardsQCDfactors.minimumScanFitY = fitf.GetMinimum(min(xvaluesF_belowX),max(xvaluesF_belowX))
 
tuple makePlots_datacardsQCDfactors.sigmaScanFit = abs(fitf.GetX(minimumScanFitY+1)-minimumScanFit)
 
tuple makePlots_datacardsQCDfactors.graphfilename = os.path.join(os.path.dirname(datacard), "parabola_" + category + ("_tightenedMassWindow" if args.tighten_mass_window else "")+".root")
 
tuple makePlots_datacardsQCDfactors.graphfile = ROOT.TFile(graphfilename, "RECREATE")
 
list makePlots_datacardsQCDfactors.weight_bins_loop = weight_binsifargs.no_inclusiveelseweight_bins[1:]
 
list makePlots_datacardsQCDfactors.weight_ranges_loop = weight_rangesifargs.no_inclusiveelseweight_ranges[1:]
 
string makePlots_datacardsQCDfactors.xval = "0.7395 2.2185"
 
string makePlots_datacardsQCDfactors.xerrsval = "0.7395 0.7395"
 
list makePlots_datacardsQCDfactors.xbinsF = [0.7395, 2.2185]
 
list makePlots_datacardsQCDfactors.xerrsF = [0.7395, 0.7395]
 
tuple makePlots_datacardsQCDfactors.RooFitGraph_Linear
 
tuple makePlots_datacardsQCDfactors.fit_polZero = ROOT.TF1("f2","pol0",min(xbinsF),max(xbinsF))
 
tuple makePlots_datacardsQCDfactors.fit_polOne = ROOT.TF1("f3","pol1",min(xbinsF),max(xbinsF))
 
tuple makePlots_datacardsQCDfactors.polZero_filename = os.path.join(args.output_dir, "datacards/result_fit_" + ("eta" if args.eta_binning else "pt") + "_pol0_" + decayMode + "_" + quantity + ".root")
 
tuple makePlots_datacardsQCDfactors.polZero_file = ROOT.TFile(polZero_filename, "RECREATE")
 
tuple makePlots_datacardsQCDfactors.polOne_filename = os.path.join(args.output_dir, "datacards/result_fit_" + ("eta" if args.eta_binning else "pt") + "_pol1_" + decayMode + "_" + quantity + ".root")
 
tuple makePlots_datacardsQCDfactors.polOne_file = ROOT.TFile(polOne_filename, "RECREATE")
 
string makePlots_datacardsQCDfactors.row_format = "{:^22}"
 
string makePlots_datacardsQCDfactors.polZero_string1 = "%1.2f"
 
string makePlots_datacardsQCDfactors.polZero_string2 = "%1.2f"
 
string makePlots_datacardsQCDfactors.polOne_string1 = "%1.2f"
 
string makePlots_datacardsQCDfactors.polOne_string2 = "%1.2f"
 
tuple makePlots_datacardsQCDfactors.subpath = os.path.normpath(output_dir)
 
list makePlots_datacardsQCDfactors.output_filenames = []
 
tuple makePlots_datacardsQCDfactors.www = args.wwwif(subpath == "tauEsStudies_datacards")
 
 makePlots_datacardsQCDfactors.output_dir = output_dir,
 
 makePlots_datacardsQCDfactors.export_json = False,