def write_to_root_files(parsed_hists, parsed_log_hists, output_filename): start = time.time() f = TFile(output_filename[0], "RECREATE") for var in parsed_hists.keys(): index = 0 for mod_hist in parsed_hists[var]: hist = copy.deepcopy(mod_hist.hist()) hist.SetName("{}#{}".format(var, index)) hist.Write() index += 1 f.Close() f = TFile(output_filename[1], "RECREATE") for var in parsed_log_hists.keys(): index = 0 for mod_hist in parsed_log_hists[var]: hist = copy.deepcopy(mod_hist.hist()) hist.SetName("{}#{}".format(var, index)) hist.Write() index += 1 f.Close() end = time.time()
def save_hists_to_root_file(root_filename, hists_to_save): f = TFile(root_filename, "RECREATE") main_tree = Tree(name="main_tree") for var in hists_to_save: a = hists_to_save[var][0].hist() print a a = pickle.dump(a, open("plot.p", "wb"))
def root_file_to_hist(input_filename, hist_templates): hists = copy.deepcopy(hist_templates) root_file = TFile(input_filename, "read") for var in hists.keys(): mod_hist = hists[var] hist = root_file.Get(var) mod_hist.replace_hist(hist) return hists
def parse_to_root_file(input_filename, output_filename, hist_templates): print "Parsing {} to {}".format(input_filename, output_filename) parsed_hists, parsed_log_hists = parse_file( input_filename, copy.deepcopy(hist_templates[0]), copy.deepcopy(hist_templates[1])) f = TFile(output_filename[0], "RECREATE") for var in parsed_hists.keys(): index = 0 for mod_hist in parsed_hists[var]: hist = copy.deepcopy(mod_hist.hist()) hist.SetName("{}#{}".format(var, index)) hist.Write() index += 1 f.Close() f = TFile(output_filename[1], "RECREATE") for var in parsed_log_hists.keys(): index = 0 for mod_hist in parsed_log_hists[var]: hist = copy.deepcopy(mod_hist.hist()) hist.SetName("{}#{}".format(var, index)) hist.Write() index += 1 f.Close()
def parse_to_root_file(input_filename, output_filename, hist_templates): print "Parsing {} to {}".format(input_filename, output_filename) parsed_hists = parse_file(input_filename, copy.deepcopy(hist_templates)) f = TFile(output_filename, "RECREATE") for var in parsed_hists.keys(): mod_hist = parsed_hists[var] hist = copy.deepcopy(mod_hist.hist()) hist.SetName("{}".format(var)) hist.Write() f.Close()
def write_to_root_file(output_filename, parsed_hists): f = TFile(output_filename, "RECREATE") for var in parsed_hists.keys(): index = 0 for mod_hist in parsed_hists[var]: hist = copy.deepcopy(mod_hist.hist()) hist.SetName("{}#{}".format(var, index)) hist.Write() index += 1 f.Close()
def root_file_to_hist(input_filename, hist_templates): hists = copy.deepcopy(hist_templates) root_file = TFile(input_filename, "read") for var in hists.keys(): index = 0 for mod_hist in hists[var]: hist_name = "{}#{}".format(var, index) # Get hist from ROOT file. hist = root_file.Get(hist_name) mod_hist.replace_hist(hist) index += 1 return hists
def root_file_to_hist(input_filename, hist_templates, is_this_data): hists = copy.deepcopy(hist_templates) root_file = TFile(input_filename, "read") for var in hists.keys(): index = 0 # if var in ['hardest_pT', 'uncor_hardest_pT', 'hardest_eta']: # if var not in ['uncor_hardest_pT']: if is_this_data: for mod_hist in hists[var]: hist_name = "{}#{}".format(var, index) # Get hist from ROOT file. hist = root_file.Get(hist_name) mod_hist.replace_hist(hist) index += 1 else: if var != 'uncor_hardest_pT': for mod_hist in hists[var]: hist_name = "{}#{}".format(var, index) # Get hist from ROOT file. hist = root_file.Get(hist_name) mod_hist.replace_hist(hist) index += 1 return hists