def init_tree_and_hists(run_info, bins=400): filename = file_fmt.format(dir=data_dir, file_id=run_info["file_id"]) tree = get_tree_from_file("Trigger", filename) for attr, val in run_info.items(): setattr(tree, attr, val) assign_leaves(tree, channels) tree.hists = make_ch_hists(tree, channels, l_bound, u_bound, bins) return tree
def generate_data_histograms(run_id): # Open the input file & init the tree print "Starting run", run_id in_file_name = in_data_file_fmt.format(run_id=run_id) tree = get_tree_from_file("Trigger", in_file_name) assign_leaves(tree, [c[0] for c in channels]) # use comprehension to make a list of just the channels # Create the file to write to out_file_name = out_data_file_fmt.format(run_id=run_id) out_file = TFile(out_file_name, "RECREATE") # Make the histograms & fill them hists = {ch[0]:make_hist(ch[0], **hist_settings) for ch in channels} fill_data_hists (tree, hists) save_file(out_file)