def syst_weights(graph): _syst_weights = [] for lepton, w in weights_lepton.items(): weights_var_by_one = variateOneWeight([x[1] for x in (weights_syst+w)]) # The unvariated weight is taken as the list of the 0th elements of the # weight tuples weights_var_by_one.append( ("nominal", [x[1][0] for x in (weights_syst+w)]) ) wtot = [] for wn, s in weights_var_by_one: j = mul(s) #Multiply together the list of weights wtot.append((wn, j)) for name, j in wtot: filter_funcs=[ #Apply the weights separately for the lepton channels lambda _x,_lepton=lepton: is_chan(_x, _lepton), #Apply only in MC is_mc ] #Apply systematic weights only in case of nominal samples if name != "nominal": filter_funcs += [ #Check if the parent was a nominal sample lambda _x: "/nominal/" in _x[0].name ] syst = WeightNode( j, graph, "weight__" + name + "__" + lepton, [], [], filter_funcs=filter_funcs ) logger.debug("Appending weight %s" % syst.name) _syst_weights.append(syst) #Always produce the unweighted plot unw = WeightNode( Weights.no_weight, graph, "weight__unweighted", [], [] ) _syst_weights.append(unw) return _syst_weights
("bdt_discr", Cuts.mva_vars['ele'], [nbins, -1, 1]), ("bdt_discr_zoom_loose", Cuts.mva_vars['ele'], [nbins, Cuts.mva_wps['bdt']['ele']['loose'], 1]), ("lep_iso", 'el_iso', [nbins, 0, 0.5]), ("lep_pt", 'el_pt', [nbins, 0, 200]), ("mtw", "mt_el", [nbins, 0, 300]), ("mtw_50_150", "mt_el", [nbins, 50, 150]), ] #MC-only variables hdescs['mc'] = [ ("true_cos_theta", "true_cos_theta", [nbins, -1, 1]), ] #define a LUT for type <-> filtering function final_plot_lambdas = { 'mu': lambda x: is_chan(x, 'mu'), 'ele': lambda x: is_chan(x, 'ele'), 'mc': lambda x: is_mc(x) } def hdesc(name, func, binning): hdesc = { "name": name, "var": func, "binning": binning } return hdesc def create_plots(graph, plot_nodes, filter_funcs=[]): from weights import reweight, syst_weights from tree import HistNode