Skip to content
Snippets Groups Projects
Commit cd28467a authored by Gitlab CI's avatar Gitlab CI Committed by Jamie Gooding
Browse files

Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/MooreAnalysis/-/jobs/34590011
parent 2440f099
No related branches found
No related tags found
1 merge request!132Move HltEffChecker scripts onto RDataFrame
Pipeline #6592675 passed
......@@ -117,7 +117,12 @@ def get_parser():
help=
'For plots where more than 1 denom is shown, specify the denom cut to apply on the shape histogram shown in the background of the plot. For plots with 1 denom only, that denom is used'
)
parser.add_argument('--group-denoms', action='store_true', help="For plotting all denoms on a single plot for each line/group. Individual plots will be created per denom if this flag is not passed.")
parser.add_argument(
'--group-denoms',
action='store_true',
help=
"For plotting all denoms on a single plot for each line/group. Individual plots will be created per denom if this flag is not passed."
)
parser.add_argument(
'--nbins', type=int, default=20, help="Number of efficiency bins.")
parser.add_argument(
......@@ -401,9 +406,11 @@ def main():
denom_ptrs = {key: rdf.Filter(cut).Count() for key, cut in denoms.items()}
line_numer_ptrs = {
key: [
rdf.Filter(' && '.join(filter(None, [cut, dec]))).Count() for dec in decisions
] for key, cut in denoms.items()
} # Dictionary of lists of RResultPtr to numerator values for line efficiencies
rdf.Filter(' && '.join(filter(None, [cut, dec]))).Count()
for dec in decisions
]
for key, cut in denoms.items()
} # Dictionary of lists of RResultPtr to numerator values for line efficiencies
ptrs_lists = list(denom_ptrs.values()) + [
item for ptr_list in line_numer_ptrs.values() for item in ptr_list
......@@ -411,9 +418,11 @@ def main():
if args.effs_groups:
group_numer_ptrs = {
key: [
rdf.Filter(f"({cut}) && ({' || '.join(filter(None, group))})").Count() for group in groups.values()
] for cut in denoms.values()
} # Dictionary of lists of RResultPtr to numerator values for group efficiencies
rdf.Filter(f"({cut}) && ({' || '.join(filter(None, group))})").
Count() for group in groups.values()
]
for cut in denoms.values()
} # Dictionary of lists of RResultPtr to numerator values for group efficiencies
ptrs_lists += [
item for ptr_list in group_numer_ptrs.values() for item in ptr_list
]
......@@ -440,7 +449,8 @@ def main():
)
print('-' * 84)
for line_name, line_numer_ptr in zip(decisions, line_numer_ptrs[denom]):
for line_name, line_numer_ptr in zip(decisions,
line_numer_ptrs[denom]):
eff = line_numer_ptr.GetValue() / denom_evts
integrated_efficiencies[denom][line_name] = eff
eff_bin_err = ROOT.TMath.Sqrt(eff * (1.0 - eff) / denom_evts)
......@@ -451,13 +461,14 @@ def main():
if args.effs_groups:
for group_name, group_numer_ptr in zip(groups.keys(),
group_numer_ptrs[denom]):
group_numer_ptrs[denom]):
print('-' * 84)
incl_group_eff = group_numer_ptr.GetValue() / denom_evts
integrated_efficiencies[denom][group_name] = incl_group_eff
incl_group_eff_err = ROOT.TMath.Sqrt(
incl_group_eff * (1.0 - incl_group_eff) / denom_evts)
integrated_efficiencies_err[denom][group_name] = incl_group_eff_err
integrated_efficiencies_err[denom][
group_name] = incl_group_eff_err
print('Efficiencies grouped by common physics: ')
for group_name, decs_in_group in groups.items():
......@@ -633,8 +644,8 @@ def main():
draw_var, shape_hist_denom, xmin, xmax)
ROOT.RDF.RunGraphs(
list(pass_hists_ptrs.values()) + list(total_hists_ptrs.values())
+ list(distr_ptrs.values()) + list(plot_evts_ptrs.values())
list(pass_hists_ptrs.values()) + list(total_hists_ptrs.values()) +
list(distr_ptrs.values()) + list(plot_evts_ptrs.values())
) # Run event loop to fill all numerator/denominator histograms
for var in plot_vars:
......
......@@ -203,9 +203,8 @@ def calculate_intersect(rdf, linesets, depth_limit=8, exclusive=False):
if i in combination or exclusive:
dec_string += f"({get_OR_dec(list_of_lines)}) && "
intersect_dict[counter] = {
"combination" : combination,
"ptr": rdf.Filter(
dec_string.rsplit(" && ", 1)[0]).Count()
"combination": combination,
"ptr": rdf.Filter(dec_string.rsplit(" && ", 1)[0]).Count()
}
counter += 1
comb_depth += 1
......@@ -214,7 +213,10 @@ def calculate_intersect(rdf, linesets, depth_limit=8, exclusive=False):
intersects = []
for item in intersect_dict.values():
intersect = {key: i in item["combination"] for i, key in enumerate(linesets.keys())}
intersect = {
key: i in item["combination"]
for i, key in enumerate(linesets.keys())
}
intersect["count"] = item["ptr"].GetValue()
intersects.append(intersect)
df = pd.DataFrame.from_dict(intersects)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment