def set_up_stacking(self): mc_tmplts = self.__dict__["input_func"]() mc_tmplts = gen.gen_norm_to_integral(mc_tmplts) mc_tmplts = cosmetica1(mc_tmplts) mc_tmplts = rebin_chhadiso(mc_tmplts) mc_tmplts = gen.apply_histo_linecolor(mc_tmplts, [409, 625, 618, 596, 430]) mc_tmplts = gen.group(mc_tmplts, key_func=lambda w: w.sample) self.stream_stack = mc_tmplts
def set_up_stacking(self): wrps = gen.pool_content() wrps = gen.filter( wrps, {"analyzer": re.compile("CutFlow")} ) wrps = gen.group(wrps) stream_stack = gen.mc_stack_n_data_sum( wrps, use_all_data_lumi=True ) def assign_name(wrp): wrp.name = "CombinedCutflow" self.stream_stack = gen.pool_store_items(stream_stack, assign_name)
def set_up_stacking(self): mc_tmplts = gen.fs_filter_sort_load({ "sample" : self.sample_name, "analyzer" : ("TemplateChHadIsofake", "PlotSBID") }) sb_wrp = get_merged_sbbkg_histo(self.sample_name) mc_tmplts = [sb_wrp] + list(mc_tmplts) mc_tmplts = gen.gen_norm_to_integral(mc_tmplts) mc_tmplts = cosmetica1(mc_tmplts) mc_tmplts = rebin_chhadiso(mc_tmplts) mc_tmplts = gen.apply_histo_linecolor(mc_tmplts, [625, 618, 596]) mc_tmplts = apply_overlay_draw_mode(mc_tmplts) mc_tmplts = gen.group(mc_tmplts, key_func=lambda w: w.sample) self.stream_stack = mc_tmplts
def set_up_stacking(self): key_func = lambda w: w.analyzer[:-4] mc_tmplts = itertools.chain(*list( gen.get_from_post_proc_dict(k) for k in settings.post_proc_dict.keys() if ("TemplateStacks" in k ) )) mc_tmplts = histo_wrapperize(mc_tmplts) mc_tmplts = gen.gen_norm_to_lumi(mc_tmplts) mc_tmplts = cosmetica1(mc_tmplts) mc_tmplts = sorted(mc_tmplts, key=key_func) mc_tmplts = gen.group(mc_tmplts, key_func=key_func) self.stream_stack = mc_tmplts
def test_gen_group(self): from_fs = gen.fs_content() filtered = gen.filter(from_fs, {"name": "histo"}) sorted = gen.sort(filtered) grouped = gen.group(sorted) group_list = [] for group in grouped: group_list.append(list(group)) # length: 3 samples: 3 histos per group self.assertEqual(len(group_list), 26) for g in group_list: self.assertEqual(len(g), 3) self.assertEqual(g[0].analyzer, g[1].analyzer) self.assertEqual(g[0].analyzer, g[2].analyzer)
def run(self): wrps = gen.fs_content() wrps = gen.filter( wrps, {"analyzer": re.compile("CutFlow*")} ) wrps = gen.filter_active_samples(wrps) wrps = sorted(wrps, key = sample_key_func) wrps = gen.load(wrps) grps = gen.group(wrps, sample_key_func) wrps = (self.combine_cutflow_histo(g) for g in grps) wrps = gen.pool_store_items(wrps) wrps = list(wrps) self.result = wrps count = len(wrps) self.message("INFO: "+self.name+" stored "+str(count)+" histos in pool.")
def set_up_stacking(self): key_func = lambda w: w.post_proc_key mc_tmplts = itertools.chain(*list( gen.get_from_post_proc_dict(k) for k in settings.post_proc_dict.keys() if ("_mc_tmplts" in k ) )) mc_tmplts = self.norm_func(mc_tmplts) mc_tmplts = cosmetica1(mc_tmplts) def histo_namer(wrp): wrp.analyzer = wrp.post_proc_key[:-10] return wrp mc_tmplts = (histo_namer(w) for w in mc_tmplts) mc_tmplts = sorted(mc_tmplts, key=key_func) mc_tmplts = gen.group(mc_tmplts, key_func=key_func) self.stream_stack = mc_tmplts
def set_up_stacking(self): mc_tmplts = gen.fs_filter_sort_load({ "sample" : ("whiz2to5", "TTGamRD1"), "analyzer" : "TemplateChHadIsoreal", }) mc_tmplts = gen.gen_norm_to_integral(mc_tmplts) mc_tmplts = cosmetica1(mc_tmplts) def leg(wrps): for w in wrps: w.legend = w.sample w.draw_option = "E1" w.histo.SetMarkerStyle(24) yield w mc_tmplts = leg(mc_tmplts) mc_tmplts = rebin_chhadiso(mc_tmplts) mc_tmplts = gen.apply_histo_linecolor(mc_tmplts, [409, 625, 618, 596, 430]) mc_tmplts = gen.group(mc_tmplts, key_func=lambda w: w.analyzer) self.stream_stack = mc_tmplts
def set_up_stacking(self): mc_tmplts = rebin_chhadiso( gen.fs_filter_active_sort_load({ "analyzer" : all_analyzers, }) ) mc_tmplts = gen.gen_norm_to_lumi(mc_tmplts) mc_tmplts = gen.group(mc_tmplts) def stack_with_purity_info(grps): for grp in grps: sub_tot_list = [0., 0.] grp = list(com.count_ttgamma_photons(grp,sub_tot_list)) grp = gen.mc_stack((grp,)) grp = grp.next() grp.sub_tot_list = sub_tot_list yield grp mc_tmplts = list(stack_with_purity_info(mc_tmplts)) mc_tmplts_plot = list( gen.filter(mc_tmplts, {"analyzer": analyzers_mc}) ) self.result = mc_tmplts_plot self.stream_stack = mc_tmplts_plot
def set_up_stacking(self): def sum_up_two(wrps): while True: try: h = gen.op.sum((next(wrps), next(wrps))) except StopIteration: return yield h mc_tmplts = list(sum_up_two(gen.fs_filter_sort_load({ "sample" : self.sample_name, "analyzer" : re.compile("PlotLooseIDSliceSihihSB"), }))) mc_tmplts = itertools.chain(gen.fs_filter_sort_load({ "sample" : self.sample_name, "analyzer" : "TemplateChHadIsofake", }), mc_tmplts ) mc_tmplts = gen.gen_norm_to_integral(mc_tmplts) mc_tmplts = cosmetica1(mc_tmplts) mc_tmplts = rebin_chhadiso(mc_tmplts) mc_tmplts = gen.apply_histo_linecolor(mc_tmplts, [409, 625, 618, 596, 430]) mc_tmplts = gen.group(mc_tmplts, key_func=lambda w: w.sample) self.stream_stack = mc_tmplts