B2OC: New line registration layout
The basic idea is to avoid repeated copy/paste work when registering lines into hlt2/spruce_b2oc.py
.
The new hlt2/spruce_b2oc.py
files consist of four parts:
- import
line_alg
makers from separate files likeb_to_dh.py
, and store them in a python dictionary. - book the lines with name of their decays in lists/dicts, separated into different purpose including
- default lines, which is Turbo-like and no further configuration is needed.
- prescaled lines, which is applied by a non-default (not 1) prescale value.
- flavor tagging lines, which need some extra output for flavor tagging. (TBD)
- isolation lines, which need some extra output for isolation variables. (TBD)
- mva filtered lines, which a TMVA-based filter is applied.
- register the lines with looping the lists by generic functions.
- a few lines for special purpose can be registered in "old-school" at the very end of file.
The option files options/hlt2_b2oc.py
is now splitted into two
-
hlt2_b2oc_all_lines.py
runs on all Hlt2 lines in B2OC, which are registered inHlt2Conf.lines.b_to_open_charm.hlt2_b2oc
. -
hlt2_b2oc_example.py
shows how this new layout can be configured outsideb_to_open_charm
module. This is also why inHlt2Conf.lines.b_to_open_charm.hlt2_b2oc
the registration process is declared as a function.
Closes #353 (closed).
Tasks
-
Simplify hlt2_b2oc.py
-
Simplify spruce_b2oc.py
-
Add example option hlt2_b2oc_example.py
-
Hlt2/Sprucing separation of remaining modules, O(10) lines left
Detailed explanation of new layout
In the new hlt2_b2oc.py
, line makers are imported in different modules (like b_to_dh
) as before,
and they are appended to a line_makers
dictionary, which stores the makers with their names as keys.
The function update_makers
is defined in Hlt2Conf.lines.b_to_open_charm.utils
and makes use of python inspect
module.
Then a series of functions are declared, in which the list of names is looped and lines are registered:
# default lines
def make_default_hlt2_lines(line_dict=hlt2_lines, line_makers=line_makers, default_lines=None):
if not default_lines: return
for decay in default_lines:
@register_line_builder(line_dict)
def make_hlt2_line(name='Hlt2B2OC_%s_Line'%decay, maker_name='make_%s'%decay, prescale=1):
line_alg = line_makers[maker_name](process=PROCESS)
return HltLine(
name=name,
prescale=prescale,
algs=prefilters.b2oc_prefilters() + [line_alg])
The looping process is implemented inside a function so that it can also be called outside this module. These function will be called later in the same file to book lines.
After the line builders, line names are stored as strings in some lists and dictionaries below. Currently lines in B2OC are categorized into five types:
- default lines: no additional requirements and
prescale=1
, saved in a list - prescaled_lines: no additional requirements and a non-default prescale value, saved in a dictionary with their prescale as values
- flavor_tagging_lines: some extra tracks are saved,
prescale=1
, not decided yet but there was a prototype in B2OC before. Assuming all lines requiring flavor tagging need the same extra info, so the names are saved in a list. - isolation_lines: some extra info is needed, not decided yet so now it's the same as default one. Assuming all lines requiring isolation need the same extra info, so the names are saved in a list.
- mva_filtered_lines: a TMVA post-filter needs to be applied to line algorithm,
prescale=1
. The MVA algorithm needed by each line is defined in their makers, so the only input is MVA cut value. They are saved in a dictionary with MVA cut as values.
Then a check_overlap
function is called to make sure every line is registered only once in those lists/dicts.
In the end those lines will be booked with functions for each type, and a few lines can also be registered in the old way at the end of file.
hlt2_b2oc
module
Import the function outside Now in test files, the lines can also be booked easier than before. As shown in hlt2_b2oc_example.py
:
# Book lines with generic functions
all_lines = {}
from Hlt2Conf.lines.b_to_open_charm.hlt2_b2oc import make_default_hlt2_lines
default_lines = [
'BdToDsmK_DsmToHHH',
]
make_default_hlt2_lines(line_dict=all_lines, default_lines=default_lines)
Just adding lines in the list and it will be booked in the all_lines
dictionary.
The makers of lines need to be defined in corresponding modules and imported in Hlt2Conf.lines.b_to_open_charm.hlt2_b2oc
.