Example #1
0
 def store_to_pool(self, stream_stack_n_data):
     """
     Keep stacks and data histograms in histopool, for later use.
     The stream has to be splitted in a stack and a data stream and to be
     rejoined in the end.
     """
     stream_stack_n_data        = itertools.chain(stream_stack_n_data)   # resolve grouping
     stream_data, stream_stacks = gen.split_data_mc(stream_stack_n_data) # split (stacks are mc)
     stream_stacks              = gen.pool_store_items(stream_stacks)    # store
     stream_data                = gen.pool_store_items(stream_data)      # store
     stream_stack_n_data        = itertools.izip(stream_stacks, stream_data) # join stream again
     return stream_stack_n_data
    def set_up_stacking(self):
        self.result.fitter = self.fitter.__class__.__name__
        mc_tmplts = self.fetch_mc_templates()
        self.n_templates = len(mc_tmplts)
        settings.post_proc_dict[self.name+"_mc_tmplts"] = mc_tmplts[:]

        # do fit procedure
        self.fitted = gen.op.sum(self.fitted)
        self.x_min, self.x_max = find_x_range(self.fitted.histo)
        self.fitter.build_fit_function(
            self.fitted, mc_tmplts, self.x_min, self.x_max
        )
        self.fitter.do_the_fit()

        self.fitter.scale_templates_to_fit(mc_tmplts)
        self.fitter.make_fit_result(self.result, mc_tmplts)

        fit_textbox = self.make_fit_textbox()
        textboxes = {mc_tmplts[0].name: fit_textbox}
        self.canvas_decorators.append(
            rnd.TextBoxDecorator(None, True, textbox_dict=textboxes)
        )

        tmplt_stacks = [gen.op.stack(mc_tmplts)]
        stream_stack = [(tmplt_stacks[0], self.fitted)]
        self.stream_stack = gen.pool_store_items(stream_stack)

        del self.fitter
Example #3
0
 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)
Example #4
0
    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):
     stream_stack = gen.fs_mc_stack(self.filter_dict)
     self.stream_stack = gen.pool_store_items(stream_stack)