B2OC: try to cleanup line registration
A prototype here.
The basic idea is to avoid repeated copy/paste work when registering lines into hlt2/spruce_b2oc.py
.
The new hlt2_b2oc.py
file consists 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.
To be discussed whether adopt this structure or not.
Problem
Registering lines with generic builders like
for decay in default_lines:
@register_line_builder(hlt2_lines)
def make_default_hlt2_line(name='Hlt2B2OC_%s_Line'%decay, prescale=1):
line_alg = line_makers['make_%s'%decay](process=PROCESS)
return HltLine(
name=name,
prescale=prescale,
algs=prefilters.b2oc_prefilters() + [line_alg])
with same function name will bring trouble, the log looks like
...
LAZY_AND: moore #=286028 Sum=26 Eff=|(0.009090019 +- 0.00178262)%|
LAZY_AND: Hlt2B2OC_BcToD0K_D0ToHHHH_Line #=286028 Sum=26 Eff=|(0.009090019 +- 0.00178262)%|
LAZY_AND: Hlt2B2OC_BcToD0K_D0ToHH_Line #=286028 Sum=26 Eff=|(0.009090019 +- 0.00178262)%|
LAZY_AND: Hlt2B2OC_BcToD0K_D0ToKsDDHH_Line #=286028 Sum=26 Eff=|(0.009090019 +- 0.00178262)%|
LAZY_AND: Hlt2B2OC_BcToD0K_D0ToKsLLHH_Line #=286028 Sum=26 Eff=|(0.009090019 +- 0.00178262)%|
LAZY_AND: Hlt2B2OC_BcToD0Pi_D0ToHHHH_Line #=286028 Sum=26 Eff=|(0.009090019 +- 0.00178262)%|
...
All lines will be overridden by one line and produce same output. Don't know if it's possible to declare different function in the for loop.