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 run(self): kicked = gen.fs_filter_active_sort_load( {"sample":"TTJetsSignal", "analyzer":"ttbarPhotonMergerSingleCall", "name":re.compile("\S*Kicked")} ) whizard = gen.fs_filter_active_sort_load( {"sample":"whiz2to5", "analyzer":"photonsSignalMEanalyzer"} ) zipped = itertools.izip(kicked, whizard) zipped = (gen.callback(z, lambda x: x.histo.SetBinContent(1,0.)) for z in zipped) # remove first bin zipped = (gen.apply_histo_linecolor(z) for z in zipped) zipped = (gen.apply_histo_linewidth(z) for z in zipped) zipped = list(list(z) for z in zipped) # load all to memory if not (zipped and zipped[0]): self.message("WARNING Histograms not found!! Quitting..") return zipped[0][0].legend = "removed (madgraph)" zipped[0][1].legend = "tt#gamma (whizard)" def save_canvas(wrps, postfix): canvas = gen.canvas( wrps, [rnd.BottomPlotRatio, rnd.LegendRight, com.SimpleTitleBox] ) canvas = gen.save( canvas, lambda c: self.plot_output_dir + c.name + postfix ) canvas = gen.switch_log_scale(canvas) canvas = gen.save( canvas, lambda c: self.plot_output_dir + c.name + postfix + "_log" ) gen.consume_n_count(canvas) # norm to integral / lumi and save save_canvas( (gen.gen_norm_to_lumi(z) for z in zipped), "_lumi" )
def get_input_histos(self): mcee = gen.gen_prod( # need to norm to lumi itertools.izip( gen.gen_norm_to_lumi( gen.filter( settings.post_proc_dict["CutflowHistos"], {"is_data": False} ) ), itertools.repeat( settings.data_lumi_sum_wrp() ) ) ) data = gen.filter( settings.post_proc_dict["CutflowHistos"], {"is_data": True} ) self.input_mc = sorted(mcee, key = legend_key_func) self.input_data = sorted(data, key = legend_key_func)
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