From 5bcf0afed2d0a91017e90bbe7e268961869e139f Mon Sep 17 00:00:00 2001 From: Alex Pearce Date: Thu, 8 Aug 2019 13:21:28 +0200 Subject: [PATCH 01/16] Add a test to run all HLT2 lines. --- Hlt/Hlt2Conf/options/hlt2_all_lines.py | 58 +++++++++++++++++++++----- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/Hlt/Hlt2Conf/options/hlt2_all_lines.py b/Hlt/Hlt2Conf/options/hlt2_all_lines.py index cf4d8ab8379..10a1742aa4c 100644 --- a/Hlt/Hlt2Conf/options/hlt2_all_lines.py +++ b/Hlt/Hlt2Conf/options/hlt2_all_lines.py @@ -15,19 +15,55 @@ Run like any other options file: ./Moore/run gaudirun.py hlt2_all_lines.py """ from __future__ import absolute_import, division, print_function -from Moore import options, run_moore -from RecoConf.reco_objects_from_file import stateProvider_with_simplified_geom -from Hlt2Conf.lines import all_lines -options.set_conds_from_testfiledb('Upgrade_MinBias_LDST') -options.set_input_from_testfiledb('Upgrade_MinBias_LDST') -options.input_raw_format = 4.3 -options.evt_max = 100 +from PyConf.environment import EverythingHandler, setupInput +from PyConf.Algorithms import FTRawBankDecoder -def make_lines(): - return [builder() for builder in all_lines.values()] +from Hlt2Conf.setup import setup +from Hlt2Conf.data_from_file import raw_event_from_file +from Hlt2Conf.lines import _hlt2_line_builders, hlt2_line_builders +from RecoConf.reco_objects_from_file import ( + make_raw_data_for_gec_from_file, upfront_reconstruction, + stateProvider_with_simplified_geom) +from RecoConf.hlt1_tracking import require_gec -public_tools = [stateProvider_with_simplified_geom()] -run_moore(options, make_lines, public_tools) +input_files = [ + # MinBias 30000000 + # sim+std://MC/Upgrade/Beam7000GeV-Upgrade-MagDown-Nu7.6-25ns-Pythia8/Sim09c-Up02/Reco-Up01/30000000/LDST + 'root://xrootd.echo.stfc.ac.uk/lhcb:prod/lhcb/MC/Upgrade/LDST/00069155/0000/00069155_00000878_2.ldst' +] + +setup() + +ftdec_v = 4 +# When running from Upgrade MC, must use the post-juggling locations of the raw +# event +raw_event_format = 4.3 + +env = EverythingHandler( + threadPoolSize=1, nEventSlots=1, evtMax=100, debug=False) +setupInput( + input_files, + dataType='Upgrade', + DDDBTag='dddb-20171126', + CONDDBTag='sim-20171127-vc-md100', + Simulation=True, + inputFileType='ROOT') + +# Use private internal state to get all registered lines +lines_to_run = _hlt2_line_builders.keys() + +with FTRawBankDecoder.bind(DecodingVersion=ftdec_v), \ + require_gec.bind(make_raw=make_raw_data_for_gec_from_file, + FTDecodingVersion=ftdec_v), \ + raw_event_from_file.bind(raw_event_format=raw_event_format): + + for name, builder in hlt2_line_builders(lines_to_run).items(): + env.registerLine(name, upfront_reconstruction() + builder()) + +env.register_public_tool(stateProvider_with_simplified_geom()) + +env.configure() +# env.plotDataFlow() -- GitLab From 3dcb916fa73e935d5ec9e015efbe0bcca18999c7 Mon Sep 17 00:00:00 2001 From: jcobbled Date: Fri, 9 Aug 2019 10:47:56 +0200 Subject: [PATCH 02/16] Added 4BodyMethod and KKPiPi Line --- Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py | 22 +- .../python/Hlt2Conf/lines/D02_KKPiPi.py | 206 ++++++++++++++++++ .../python/Hlt2Conf/lines/__init__.py | 2 + 3 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py index eed5bedfd92..07e81f80ec8 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py @@ -20,10 +20,15 @@ functional algorithms. from __future__ import absolute_import, division, print_function import string -from Configurables import CombineParticles, FilterDesktop +from Configurables import CombineParticles, FilterDesktop, DaVinci__N4BodyDecays as N4BodyDecays +<<<<<<< HEAD from RecoConf.hlt1_tracking import EmptyFilter from PyConf.components import make_algorithm +======= +from RecoConf.hlt1_tracking import EmptyFilter +from PyConf.components import make_algorithm, Algorithm +>>>>>>> Added 4BodyMethod and KKPiPi Line __all__ = [ 'EmptyFilter', @@ -112,6 +117,9 @@ combiners = { 4: make_dvalgorithm(CombineParticles, ninputs=4) } +FourBodyCombiner = { + 1: make_dvalgorithm(N4BodyDecays) +} def ParticleFilter(particles, **kwargs): """Return a filter algorithm that takes `particles` as inputs. @@ -156,9 +164,21 @@ def ParticleCombiner(particles, **kwargs): return combiner(**kwargs).Output +def N4BodyCombiner(particles, **kwargs): + #Return a combiner algorithm that takes `particles` as inputs. + #Additional keyword arguments are forwarded to CombineParticles. + def transform(Inputs,PrimaryVertices=None): + return _dvalgorithm_inputs(Inputs,PrimaryVertices) + combiner = make_algorithm(N4BodyDecays,input_transform=transform,output_transform=_dvalgorithm_outputs) + return combiner(Inputs=particles,**kwargs).Output + + + def ParticleCombinerWithPVs(particles, pvs, **kwargs): """Return a combiner algorithm that takes `particles` and `pvs` as inputs. Additional keyword arguments are forwarded to CombineParticles. """ return ParticleCombiner(particles=particles, PrimaryVertices=pvs, **kwargs) + + diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py new file mode 100644 index 00000000000..4161c3fed32 --- /dev/null +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py @@ -0,0 +1,206 @@ +############################################################################### +# (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration # +# # +# This software is distributed under the terms of the GNU General Public # +# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # +# # +# In applying this licence, CERN does not waive the privileges and immunities # +# granted to it by virtue of its status as an Intergovernmental Organization # +# or submit itself to any jurisdiction. # +############################################################################### +"""Definition of some D0 -> h- h+ h- h+ HLT2 lines. + +The logic is the same as in Run 1/2: create HLT2 lines by defining selections +which create physics objects. These selections may consume other selections, as +filters or combiners. + +The change comes in how selection components are defined. + +TODO(AP): More docs. +""" +from __future__ import absolute_import, division, print_function +import math + +from GaudiKernel.SystemOfUnits import GeV, MeV, mm, mrad + +from Hlt1Conf.reconstruction import FilterEmptyPVs + +from ..algorithms import require_all, ParticleCombinerWithPVs, ParticleFilterWithPVs,N4BodyCombiner +from ..framework import configurable +from ..reconstruction import gec, make_pvs +from ..standard_particles import make_has_rich_pions, make_has_rich_kaons +from . import hlt2_line_builder + +# Charged pion mass in MeV +_PION_M = 139.57061 # +/- 0.00024 + + +# TODO(AP): implement shared decorator +# @shared +@configurable +def make_selected_particles(make_particles=make_has_rich_pions, + make_pvs=make_pvs, + trchi2dof_max=4, + mipchi2_min=3.5, + pt_min=250 * MeV, + trg_ghost_prob_max=0.5, + #p_min=8 * GeV, + pid=None): + # TODO(AP): this would be a whole lot nicer with f-strings (Python >= 3.6) + # An alternative is to pass **locals() to format, but... ew + code = require_all( + 'PT > {pt_min}', + 'TRGHOSTPROB < {trg_ghost_prob_max}', + #'P > {p_min}', + # TODO(AP): Cut value is reasonable for Run 2, but removes basically + # everything in the upgrade sample + 'TRCHI2DOF < {trchi2dof_max}', + 'MIPCHI2DV(PRIMARY) > {mipchi2_min}').format( + pt_min=pt_min, + trg_ghost_prob_max=trg_ghost_prob_max, + trchi2dof_max=trchi2dof_max, + mipchi2_min=mipchi2_min) + if pid is not None: + code += ' & ({})'.format(pid) + return ParticleFilterWithPVs(make_particles(), make_pvs(), Code=code) + +#implement selection criteria for soft pions +def make_soft_pions(make_particles=make_has_rich_pions, + make_pvs=make_pvs,trchi2dof_max=3): + + + code = require_all( + 'TRCHI2DOF < {trchi2dof_max}').format(trchi2dof_max=trchi2dof_max) + return ParticleFilterWithPVs(make_particles(), make_pvs(), Code=code) + +# TODO(AP): bound doesn't exist yet +# make_charm_pions = bound(make_selected_particles, make_has_rich_pions, pid='PIDK < 3') +# make_charm_kaons = bound(make_selected_particles, make_has_rich_pions, pid='PIDK > 3') + + +@configurable +def make_charm_pions(pid='PIDK > 0'): + return make_selected_particles(make_particles=make_has_rich_pions, pid=pid) + + +@configurable +def make_charm_kaons(pid='PIDK < 0'): + return make_selected_particles(make_particles=make_has_rich_kaons, pid=pid) + + +@configurable +def make_dzeros(particles=None, + descriptors=None, + make_pvs=make_pvs, + am_min=1730 * MeV, + am_max=2000 * MeV, + amaxchild_pt_min=1500 * MeV, + ap_min=20000 * MeV, + achi2doca_max=10.0, + vchi2pdof_max=10, + bpvvdchi2_min=25, + bpvdira_min=0.99995): + # TODO(AP): TypeError: Cannot decorate a function with positional arguments + # We want this function to be configurable, but there aren't aren't + # 'sensible' defaults for these args + assert particles is not None, 'particles must be specified' + assert descriptors is not None, 'descriptors must be specified' + + combination_code = require_all("in_range({am_min}, AM, {am_max})", + "(APT1 + APT2 + APT3 + APT4) > {amaxchild_pt_min}", + "AP > {ap_min}").format( + am_min=am_min, + am_max=am_max, + amaxchild_pt_min=amaxchild_pt_min, + ap_min=ap_min) + + combination123_code = require_all("AM < {am_min}", + "ACHI2DOCA(1,3) < {achi2doca_max}", + "ACHI2DOCA(2,3) < {achi2doca_max}").format( + am_min=2000 - _PION_M, + achi2doca_max=achi2doca_max) + + combination12_code = require_all("AM < {am_min}", + "ACHI2DOCA(1,2) < {achi2doca_max}").format( + am_min=2000 - _PION_M, + achi2doca_max=achi2doca_max) + #cos_bpvdira_min = math.cos(bpvdira_min) + vertex_code = require_all("CHI2VXNDOF < {vchi2pdof_max}", "BPVVALID()", + "BPVVDCHI2() > {bpvvdchi2_min}", + "BPVDIRA() > {cos_bpvdira_min}").format( + vchi2pdof_max=vchi2pdof_max, + bpvvdchi2_min=bpvvdchi2_min, + cos_bpvdira_min=bpvdira_min) + + #return N4BodyCombiner(particles=particles,PrimaryVertices=make_pvs(),DecayDescriptors=descriptors,CombinationCut=combination_code,MotherCut=vertex_code,Combination123Cut=combination123_code,Combination12Cut=combination12_code) + + return ParticleCombinerWithPVs( + particles=particles, + pvs=make_pvs(), + DecayDescriptors=descriptors, + CombinationCut=combination_code, + MotherCut=vertex_code) + + +@configurable +def make_dstars(dzeros=None, + soft_pions=None, + descriptors=None, + make_pvs=make_pvs, + max_comb_deltaM=190.0, + max_vtx_deltaM=170.0, + max_vtx_chi2_pdof=15.0): + assert dzeros is not None, 'dzeros must be specified' + assert soft_pions is not None, 'soft_pions must be specified' + assert descriptors is not None, 'descriptors must be specified' + + combination_code = require_all( + "(AM - AM1) < {max_comb_deltaM}").format( + max_comb_deltaM=max_comb_deltaM + ) + + vertex_code = require_all( + "(M - M1) < {max_vtx_deltaM}","VFASPF(VCHI2/VDOF) < {max_vtx_chi2_pdof}").format( + max_vtx_deltaM=max_vtx_deltaM, + max_vtx_chi2_pdof=max_vtx_chi2_pdof) + + return ParticleCombinerWithPVs( + particles=[dzeros, soft_pions], + pvs=make_pvs(), + DecayDescriptors=descriptors, + CombinationCut=combination_code, + MotherCut=vertex_code) + + +def charm_prefilters(): + return [gec(), FilterEmptyPVs(make_pvs=make_pvs)] + + +""" +@hlt2_line_builder('Hlt2CharmHadD02KmKpPimPipLine') +def dzero2pipipipi_line(): + pions = make_charm_pions() + dzeros = make_dzeros(particles=pions, descriptors=['D0 -> K- K+ pi- pi+']) + return charm_prefilters() + [dzeros] +""" + +@hlt2_line_builder('Hlt2CharmHadDstp2D0Pip_D02KmKpPimPipLine') +def dstar2dzeropi_dzero2Kpipipi_line(): + kaons = make_charm_kaons() + pions = make_charm_pions() + dzeros = make_dzeros( + particles=[kaons, pions], descriptors=['[D0 -> K- K+ pi- pi+]cc']) + soft_pions = make_has_rich_pions() + dstars = make_dstars( + dzeros=dzeros, + soft_pions=soft_pions, + descriptors=['[D*(2010)+ -> D0 pi+]cc']) + return charm_prefilters() + [dstars] + +""" +@hlt2_line_builder('Hlt2CharmHadD02KmKpLine') +def dzero2kk_line(): + kaons = make_charm_kaons() + dzeros = make_dzeros(particles=kaons, descriptors=['D0 -> K- K+']) + return charm_prefilters() + [dzeros] +""" diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/__init__.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/__init__.py index 487c0818e8f..8ce7939c0a9 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/__init__.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/__init__.py @@ -18,6 +18,7 @@ from Moore.config import add_line_to_registry from . import ( Bs2JpsiPhi, D02HH, + D02_KKPiPi, ) __all__ = [ @@ -43,6 +44,7 @@ def _get_all_lines(modules): modules = [ Bs2JpsiPhi, D02HH, + D02_KKPiPi, ] all_lines = _get_all_lines(modules) -- GitLab From 0d36451eb6796e4759e3f2ac076968cd75911b9c Mon Sep 17 00:00:00 2001 From: jcobbled Date: Fri, 9 Aug 2019 11:47:58 +0200 Subject: [PATCH 03/16] Commit before rebasing after adding conf.py --- PyConf/python/PyConf/components.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PyConf/python/PyConf/components.py b/PyConf/python/PyConf/components.py index 17980535885..8a72a3e09e6 100644 --- a/PyConf/python/PyConf/components.py +++ b/PyConf/python/PyConf/components.py @@ -547,8 +547,10 @@ class Algorithm(object): output_dict = _gather_locations(self.outputs) if self._input_transform: + print(input_dict) + print(self._input_transform) input_dict = self._input_transform(**input_dict) - + if self._output_transform: output_dict = self._output_transform(**output_dict) -- GitLab From ba335ead964c77cd71b7bd9a7bd46540f5a58fa7 Mon Sep 17 00:00:00 2001 From: Patrick Spradlin Date: Mon, 12 Aug 2019 13:06:03 +0200 Subject: [PATCH 04/16] Update algorithms.py and D02_KKPiPi.py to be compatible with head after rebase --- Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py | 5 ----- Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py | 12 +++++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py index 07e81f80ec8..467e0ef9d94 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py @@ -22,13 +22,8 @@ import string from Configurables import CombineParticles, FilterDesktop, DaVinci__N4BodyDecays as N4BodyDecays -<<<<<<< HEAD -from RecoConf.hlt1_tracking import EmptyFilter -from PyConf.components import make_algorithm -======= from RecoConf.hlt1_tracking import EmptyFilter from PyConf.components import make_algorithm, Algorithm ->>>>>>> Added 4BodyMethod and KKPiPi Line __all__ = [ 'EmptyFilter', diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py index 4161c3fed32..ed194af6afa 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py @@ -23,12 +23,14 @@ import math from GaudiKernel.SystemOfUnits import GeV, MeV, mm, mrad -from Hlt1Conf.reconstruction import FilterEmptyPVs - from ..algorithms import require_all, ParticleCombinerWithPVs, ParticleFilterWithPVs,N4BodyCombiner from ..framework import configurable -from ..reconstruction import gec, make_pvs -from ..standard_particles import make_has_rich_pions, make_has_rich_kaons +from RecoConf.hlt1_tracking import require_pvs, require_gec +from RecoConf.reco_objects_from_file import make_pvs +from ..standard_particles import (make_has_rich_long_pions + as make_has_rich_pions, + make_has_rich_long_kaons + as make_has_rich_kaons) from . import hlt2_line_builder # Charged pion mass in MeV @@ -173,7 +175,7 @@ def make_dstars(dzeros=None, def charm_prefilters(): - return [gec(), FilterEmptyPVs(make_pvs=make_pvs)] + return [require_gec(), require_pvs(make_pvs())] """ -- GitLab From 6695e66fd835ca1d39c957d289f9c4dea1db01e2 Mon Sep 17 00:00:00 2001 From: Patrick Spradlin Date: Tue, 13 Aug 2019 16:52:07 +0200 Subject: [PATCH 05/16] Changd N4BodyCombiner wrapper to replicate ParticleCombiner wrapper. Also added an options file that only runs the Hlt2CharmHadDstp2D0Pip_D02KmKpPimPipLine --- Hlt/Hlt2Conf/options/testrun_4bodies.py | 74 +++++++++++++++++++ Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py | 51 ++++++++++--- .../python/Hlt2Conf/lines/D02_KKPiPi.py | 16 ++-- 3 files changed, 124 insertions(+), 17 deletions(-) create mode 100644 Hlt/Hlt2Conf/options/testrun_4bodies.py diff --git a/Hlt/Hlt2Conf/options/testrun_4bodies.py b/Hlt/Hlt2Conf/options/testrun_4bodies.py new file mode 100644 index 00000000000..c4abd16a169 --- /dev/null +++ b/Hlt/Hlt2Conf/options/testrun_4bodies.py @@ -0,0 +1,74 @@ +############################################################################### +# (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration # +# # +# This software is distributed under the terms of the GNU General Public # +# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # +# # +# In applying this licence, CERN does not waive the privileges and immunities # +# granted to it by virtue of its status as an Intergovernmental Organization # +# or submit itself to any jurisdiction. # +############################################################################### +"""Options for running HLT2 lines. + +Run like any other options file: + + ./Moore/run gaudirun.py hlt2_example.py +""" +from __future__ import absolute_import, division, print_function + +from PyConf.environment import EverythingHandler + +from PyConf.Algorithms import FTRawBankDecoder + +from Hlt2Conf.setup import setup +from Hlt2Conf.data_from_file import raw_event_from_file +from Hlt2Conf.lines import hlt2_line_builders + +from RecoConf.reco_objects_from_file import ( + make_raw_data_for_gec_from_file, upfront_reconstruction, + stateProvider_with_simplified_geom) +from RecoConf.hlt1_tracking import require_gec + +input_files = [ + # MinBias 30000000 + #sim+std://MC/Upgrade/Beam7000GeV-Upgrade-MagDown-Nu7.6-25ns-Pythia8/Sim09c-Up02/Reco-Up01/30000000/LDST + #'root://xrootd.echo.stfc.ac.uk/lhcb:prod/lhcb/MC/Upgrade/LDST/00069155/0000/00069155_00000878_2.ldst' + # D*-tagged D0 to KK, 27163002 + # sim+std://MC/Upgrade/Beam7000GeV-Upgrade-MagDown-Nu7.6-25ns-Pythia8/Sim09c-Up02/Reco-Up01/27163002/LDST + #'root://lhcbxrootd-kit.gridka.de//pnfs/gridka.de/lhcb/MC/Upgrade/LDST/00070317/0000/00070317_00000012_2.ldst' + ##KKpipi sample + 'root://ccxrootdlhcb.in2p3.fr//pnfs/in2p3.fr/data/lhcb/MC/Upgrade/MCFILTER.LDST/00047762/0000/00047762_00000001_1.mcfilter.ldst' +] + +setup() + +ftdec_v = 4 +# When running from Upgrade MC, must use the post-juggling locations of the raw +# event +raw_event_format = 4.3 + +env = EverythingHandler( + threadPoolSize=1, nEventSlots=1, evtMax=100, debug=False) +env.setupInput( + input_files, + dataType='Upgrade', + DDDBTag='dddb-20171126', + CONDDBTag='sim-20171127-vc-md100', + Simulation=True, + inputFileType='ROOT') +lines_to_run = [ + 'Hlt2CharmHadDstp2D0Pip_D02KmKpPimPipLine' +] + +with FTRawBankDecoder.bind(DecodingVersion=ftdec_v), \ + require_gec.bind(make_raw = make_raw_data_for_gec_from_file, + FTDecodingVersion=ftdec_v), \ + raw_event_from_file.bind(raw_event_format=raw_event_format): + + for name, builder in hlt2_line_builders(lines_to_run).items(): + env.registerLine(name, upfront_reconstruction() + builder()) + +env.register_public_tool(stateProvider_with_simplified_geom()) + +env.configure() +# env.plotDataFlow() diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py index 467e0ef9d94..6766a4880fc 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py @@ -20,7 +20,8 @@ functional algorithms. from __future__ import absolute_import, division, print_function import string -from Configurables import CombineParticles, FilterDesktop, DaVinci__N4BodyDecays as N4BodyDecays +from Configurables import (CombineParticles, FilterDesktop, + DaVinci__N4BodyDecays as N4BodyDecays) from RecoConf.hlt1_tracking import EmptyFilter from PyConf.components import make_algorithm, Algorithm @@ -112,10 +113,15 @@ combiners = { 4: make_dvalgorithm(CombineParticles, ninputs=4) } -FourBodyCombiner = { - 1: make_dvalgorithm(N4BodyDecays) + +fourbodycombiners = { + 1: make_dvalgorithm(N4BodyDecays), + 2: make_dvalgorithm(N4BodyDecays, ninputs=2), + 3: make_dvalgorithm(N4BodyDecays, ninputs=3), + 4: make_dvalgorithm(N4BodyDecays, ninputs=4) } + def ParticleFilter(particles, **kwargs): """Return a filter algorithm that takes `particles` as inputs. @@ -160,13 +166,31 @@ def ParticleCombiner(particles, **kwargs): def N4BodyCombiner(particles, **kwargs): - #Return a combiner algorithm that takes `particles` as inputs. - #Additional keyword arguments are forwarded to CombineParticles. - def transform(Inputs,PrimaryVertices=None): - return _dvalgorithm_inputs(Inputs,PrimaryVertices) - combiner = make_algorithm(N4BodyDecays,input_transform=transform,output_transform=_dvalgorithm_outputs) - return combiner(Inputs=particles,**kwargs).Output + """Return a N4BodyDecays combiner algorithm that takes particles as inputs. + + Additional keyword arguments are forwarded to N4BodyDecays. + """ + ## TODO: eliminate duplication of code with ParticleCombiner + particles = particles if isinstance(particles, list) else [particles] + ninputs = len(particles) + + # Need to dispatch to the right combiner, based on the number of inputs + assert len( + combiners) >= ninputs, 'Do not have a combiner for {} inputs'.format( + ninputs) + combiner = fourbodycombiners[ninputs] + + # Map each input container to an input property name + inputs = { + 'Particles' + letter: p + for p, letter in zip(particles, string.ascii_uppercase) + } + # We need to merge dicts, we make sure we don't have overlapping keys (the + # caller really shouldn't specify ParticleX keys anyway) + assert set(inputs).intersection(kwargs) == set() + kwargs = dict(list(inputs.items()) + list(kwargs.items())) + return combiner(**kwargs).Output def ParticleCombinerWithPVs(particles, pvs, **kwargs): @@ -177,3 +201,12 @@ def ParticleCombinerWithPVs(particles, pvs, **kwargs): return ParticleCombiner(particles=particles, PrimaryVertices=pvs, **kwargs) +def N4BodyCombinerWithPVs(particles, pvs, **kwargs): + """Return a combiner algorithm that takes `particles` and `pvs` as inputs. + + Additional keyword arguments are forwarded to CombineParticles. + """ + ## TODO: eliminate duplication of code with ParticleCombinerWithPVs + return N4BodyCombiner(particles=particles, PrimaryVertices=pvs, **kwargs) + + diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py index ed194af6afa..4e016a0cef0 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py @@ -23,7 +23,7 @@ import math from GaudiKernel.SystemOfUnits import GeV, MeV, mm, mrad -from ..algorithms import require_all, ParticleCombinerWithPVs, ParticleFilterWithPVs,N4BodyCombiner +from ..algorithms import require_all, ParticleCombinerWithPVs, ParticleFilterWithPVs,N4BodyCombinerWithPVs from ..framework import configurable from RecoConf.hlt1_tracking import require_pvs, require_gec from RecoConf.reco_objects_from_file import make_pvs @@ -134,14 +134,14 @@ def make_dzeros(particles=None, bpvvdchi2_min=bpvvdchi2_min, cos_bpvdira_min=bpvdira_min) - #return N4BodyCombiner(particles=particles,PrimaryVertices=make_pvs(),DecayDescriptors=descriptors,CombinationCut=combination_code,MotherCut=vertex_code,Combination123Cut=combination123_code,Combination12Cut=combination12_code) + return N4BodyCombinerWithPVs(particles=particles,pvs=make_pvs(),DecayDescriptors=descriptors,CombinationCut=combination_code,MotherCut=vertex_code,Combination123Cut=combination123_code,Combination12Cut=combination12_code) - return ParticleCombinerWithPVs( - particles=particles, - pvs=make_pvs(), - DecayDescriptors=descriptors, - CombinationCut=combination_code, - MotherCut=vertex_code) + #return ParticleCombinerWithPVs( + # particles=particles, + # pvs=make_pvs(), + # DecayDescriptors=descriptors, + # CombinationCut=combination_code, + # MotherCut=vertex_code) @configurable -- GitLab From 561823466f334d5447e257553439ff49a5c0cc8f Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 13 Aug 2019 14:53:14 +0000 Subject: [PATCH 06/16] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/5152047 --- Hlt/Hlt2Conf/options/testrun_4bodies.py | 4 +- Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py | 3 - .../python/Hlt2Conf/lines/D02_KKPiPi.py | 92 ++++++++++--------- PyConf/python/PyConf/components.py | 2 +- 4 files changed, 52 insertions(+), 49 deletions(-) diff --git a/Hlt/Hlt2Conf/options/testrun_4bodies.py b/Hlt/Hlt2Conf/options/testrun_4bodies.py index c4abd16a169..7103289a0b1 100644 --- a/Hlt/Hlt2Conf/options/testrun_4bodies.py +++ b/Hlt/Hlt2Conf/options/testrun_4bodies.py @@ -56,9 +56,7 @@ env.setupInput( CONDDBTag='sim-20171127-vc-md100', Simulation=True, inputFileType='ROOT') -lines_to_run = [ - 'Hlt2CharmHadDstp2D0Pip_D02KmKpPimPipLine' -] +lines_to_run = ['Hlt2CharmHadDstp2D0Pip_D02KmKpPimPipLine'] with FTRawBankDecoder.bind(DecodingVersion=ftdec_v), \ require_gec.bind(make_raw = make_raw_data_for_gec_from_file, diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py index 6766a4880fc..5090ef420cf 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py @@ -113,7 +113,6 @@ combiners = { 4: make_dvalgorithm(CombineParticles, ninputs=4) } - fourbodycombiners = { 1: make_dvalgorithm(N4BodyDecays), 2: make_dvalgorithm(N4BodyDecays, ninputs=2), @@ -208,5 +207,3 @@ def N4BodyCombinerWithPVs(particles, pvs, **kwargs): """ ## TODO: eliminate duplication of code with ParticleCombinerWithPVs return N4BodyCombiner(particles=particles, PrimaryVertices=pvs, **kwargs) - - diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py index 4e016a0cef0..6f8bc800e27 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py @@ -23,13 +23,12 @@ import math from GaudiKernel.SystemOfUnits import GeV, MeV, mm, mrad -from ..algorithms import require_all, ParticleCombinerWithPVs, ParticleFilterWithPVs,N4BodyCombinerWithPVs +from ..algorithms import require_all, ParticleCombinerWithPVs, ParticleFilterWithPVs, N4BodyCombinerWithPVs from ..framework import configurable from RecoConf.hlt1_tracking import require_pvs, require_gec from RecoConf.reco_objects_from_file import make_pvs -from ..standard_particles import (make_has_rich_long_pions - as make_has_rich_pions, - make_has_rich_long_kaons +from ..standard_particles import (make_has_rich_long_pions as + make_has_rich_pions, make_has_rich_long_kaons as make_has_rich_kaons) from . import hlt2_line_builder @@ -40,14 +39,15 @@ _PION_M = 139.57061 # +/- 0.00024 # TODO(AP): implement shared decorator # @shared @configurable -def make_selected_particles(make_particles=make_has_rich_pions, - make_pvs=make_pvs, - trchi2dof_max=4, - mipchi2_min=3.5, - pt_min=250 * MeV, - trg_ghost_prob_max=0.5, - #p_min=8 * GeV, - pid=None): +def make_selected_particles( + make_particles=make_has_rich_pions, + make_pvs=make_pvs, + trchi2dof_max=4, + mipchi2_min=3.5, + pt_min=250 * MeV, + trg_ghost_prob_max=0.5, + #p_min=8 * GeV, + pid=None): # TODO(AP): this would be a whole lot nicer with f-strings (Python >= 3.6) # An alternative is to pass **locals() to format, but... ew code = require_all( @@ -66,15 +66,17 @@ def make_selected_particles(make_particles=make_has_rich_pions, code += ' & ({})'.format(pid) return ParticleFilterWithPVs(make_particles(), make_pvs(), Code=code) + #implement selection criteria for soft pions def make_soft_pions(make_particles=make_has_rich_pions, - make_pvs=make_pvs,trchi2dof_max=3): - + make_pvs=make_pvs, + trchi2dof_max=3): - code = require_all( - 'TRCHI2DOF < {trchi2dof_max}').format(trchi2dof_max=trchi2dof_max) + code = require_all('TRCHI2DOF < {trchi2dof_max}').format( + trchi2dof_max=trchi2dof_max) return ParticleFilterWithPVs(make_particles(), make_pvs(), Code=code) + # TODO(AP): bound doesn't exist yet # make_charm_pions = bound(make_selected_particles, make_has_rich_pions, pid='PIDK < 3') # make_charm_kaons = bound(make_selected_particles, make_has_rich_pions, pid='PIDK > 3') @@ -108,24 +110,23 @@ def make_dzeros(particles=None, assert particles is not None, 'particles must be specified' assert descriptors is not None, 'descriptors must be specified' - combination_code = require_all("in_range({am_min}, AM, {am_max})", - "(APT1 + APT2 + APT3 + APT4) > {amaxchild_pt_min}", - "AP > {ap_min}").format( - am_min=am_min, - am_max=am_max, - amaxchild_pt_min=amaxchild_pt_min, - ap_min=ap_min) - - combination123_code = require_all("AM < {am_min}", - "ACHI2DOCA(1,3) < {achi2doca_max}", - "ACHI2DOCA(2,3) < {achi2doca_max}").format( - am_min=2000 - _PION_M, - achi2doca_max=achi2doca_max) - - combination12_code = require_all("AM < {am_min}", - "ACHI2DOCA(1,2) < {achi2doca_max}").format( - am_min=2000 - _PION_M, - achi2doca_max=achi2doca_max) + combination_code = require_all( + "in_range({am_min}, AM, {am_max})", + "(APT1 + APT2 + APT3 + APT4) > {amaxchild_pt_min}", + "AP > {ap_min}").format( + am_min=am_min, + am_max=am_max, + amaxchild_pt_min=amaxchild_pt_min, + ap_min=ap_min) + + combination123_code = require_all( + "AM < {am_min}", "ACHI2DOCA(1,3) < {achi2doca_max}", + "ACHI2DOCA(2,3) < {achi2doca_max}").format( + am_min=2000 - _PION_M, achi2doca_max=achi2doca_max) + + combination12_code = require_all( + "AM < {am_min}", "ACHI2DOCA(1,2) < {achi2doca_max}").format( + am_min=2000 - _PION_M, achi2doca_max=achi2doca_max) #cos_bpvdira_min = math.cos(bpvdira_min) vertex_code = require_all("CHI2VXNDOF < {vchi2pdof_max}", "BPVVALID()", "BPVVDCHI2() > {bpvvdchi2_min}", @@ -134,7 +135,14 @@ def make_dzeros(particles=None, bpvvdchi2_min=bpvvdchi2_min, cos_bpvdira_min=bpvdira_min) - return N4BodyCombinerWithPVs(particles=particles,pvs=make_pvs(),DecayDescriptors=descriptors,CombinationCut=combination_code,MotherCut=vertex_code,Combination123Cut=combination123_code,Combination12Cut=combination12_code) + return N4BodyCombinerWithPVs( + particles=particles, + pvs=make_pvs(), + DecayDescriptors=descriptors, + CombinationCut=combination_code, + MotherCut=vertex_code, + Combination123Cut=combination123_code, + Combination12Cut=combination12_code) #return ParticleCombinerWithPVs( # particles=particles, @@ -156,15 +164,13 @@ def make_dstars(dzeros=None, assert soft_pions is not None, 'soft_pions must be specified' assert descriptors is not None, 'descriptors must be specified' - combination_code = require_all( - "(AM - AM1) < {max_comb_deltaM}").format( - max_comb_deltaM=max_comb_deltaM - ) + combination_code = require_all("(AM - AM1) < {max_comb_deltaM}").format( + max_comb_deltaM=max_comb_deltaM) vertex_code = require_all( - "(M - M1) < {max_vtx_deltaM}","VFASPF(VCHI2/VDOF) < {max_vtx_chi2_pdof}").format( - max_vtx_deltaM=max_vtx_deltaM, - max_vtx_chi2_pdof=max_vtx_chi2_pdof) + "(M - M1) < {max_vtx_deltaM}", + "VFASPF(VCHI2/VDOF) < {max_vtx_chi2_pdof}").format( + max_vtx_deltaM=max_vtx_deltaM, max_vtx_chi2_pdof=max_vtx_chi2_pdof) return ParticleCombinerWithPVs( particles=[dzeros, soft_pions], @@ -186,6 +192,7 @@ def dzero2pipipipi_line(): return charm_prefilters() + [dzeros] """ + @hlt2_line_builder('Hlt2CharmHadDstp2D0Pip_D02KmKpPimPipLine') def dstar2dzeropi_dzero2Kpipipi_line(): kaons = make_charm_kaons() @@ -199,6 +206,7 @@ def dstar2dzeropi_dzero2Kpipipi_line(): descriptors=['[D*(2010)+ -> D0 pi+]cc']) return charm_prefilters() + [dstars] + """ @hlt2_line_builder('Hlt2CharmHadD02KmKpLine') def dzero2kk_line(): diff --git a/PyConf/python/PyConf/components.py b/PyConf/python/PyConf/components.py index 8a72a3e09e6..ba4825bdd84 100644 --- a/PyConf/python/PyConf/components.py +++ b/PyConf/python/PyConf/components.py @@ -550,7 +550,7 @@ class Algorithm(object): print(input_dict) print(self._input_transform) input_dict = self._input_transform(**input_dict) - + if self._output_transform: output_dict = self._output_transform(**output_dict) -- GitLab From eb76a16e701cbfe9cfbcee84df2dff36018ab419 Mon Sep 17 00:00:00 2001 From: Patrick Spradlin Date: Thu, 15 Aug 2019 15:37:33 +0100 Subject: [PATCH 07/16] Reset branch change to PyConf/components.py --- PyConf/python/PyConf/components.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/PyConf/python/PyConf/components.py b/PyConf/python/PyConf/components.py index ba4825bdd84..17980535885 100644 --- a/PyConf/python/PyConf/components.py +++ b/PyConf/python/PyConf/components.py @@ -547,8 +547,6 @@ class Algorithm(object): output_dict = _gather_locations(self.outputs) if self._input_transform: - print(input_dict) - print(self._input_transform) input_dict = self._input_transform(**input_dict) if self._output_transform: -- GitLab From cd5ae7126dc2eedc0b93e451ad6475b39224d019 Mon Sep 17 00:00:00 2001 From: jcobbled Date: Fri, 9 Aug 2019 11:47:58 +0200 Subject: [PATCH 08/16] Commit before rebasing after adding conf.py --- PyConf/python/PyConf/components.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PyConf/python/PyConf/components.py b/PyConf/python/PyConf/components.py index 17980535885..8a72a3e09e6 100644 --- a/PyConf/python/PyConf/components.py +++ b/PyConf/python/PyConf/components.py @@ -547,8 +547,10 @@ class Algorithm(object): output_dict = _gather_locations(self.outputs) if self._input_transform: + print(input_dict) + print(self._input_transform) input_dict = self._input_transform(**input_dict) - + if self._output_transform: output_dict = self._output_transform(**output_dict) -- GitLab From 1a167234335bece15a47080416c2af9495a972d9 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 13 Aug 2019 14:53:14 +0000 Subject: [PATCH 09/16] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/5152047 --- PyConf/python/PyConf/components.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyConf/python/PyConf/components.py b/PyConf/python/PyConf/components.py index 8a72a3e09e6..ba4825bdd84 100644 --- a/PyConf/python/PyConf/components.py +++ b/PyConf/python/PyConf/components.py @@ -550,7 +550,7 @@ class Algorithm(object): print(input_dict) print(self._input_transform) input_dict = self._input_transform(**input_dict) - + if self._output_transform: output_dict = self._output_transform(**output_dict) -- GitLab From 21a46214de2231ae987311e610889faf046d1356 Mon Sep 17 00:00:00 2001 From: Patrick Spradlin Date: Thu, 15 Aug 2019 15:37:33 +0100 Subject: [PATCH 10/16] Reset branch change to PyConf/components.py --- PyConf/python/PyConf/components.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/PyConf/python/PyConf/components.py b/PyConf/python/PyConf/components.py index ba4825bdd84..17980535885 100644 --- a/PyConf/python/PyConf/components.py +++ b/PyConf/python/PyConf/components.py @@ -547,8 +547,6 @@ class Algorithm(object): output_dict = _gather_locations(self.outputs) if self._input_transform: - print(input_dict) - print(self._input_transform) input_dict = self._input_transform(**input_dict) if self._output_transform: -- GitLab From 4dcf6b1e82f088402ab18a3fd8e3c3afcbf09448 Mon Sep 17 00:00:00 2001 From: Patrick Spradlin Date: Wed, 28 Aug 2019 18:45:20 +0200 Subject: [PATCH 11/16] Incorporated NnBodyDecays wrapper implementation from MR 217. Added 3-body wrapper. --- Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py | 61 ++++++++++++---------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py index 5090ef420cf..f18553a5238 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py @@ -21,18 +21,17 @@ from __future__ import absolute_import, division, print_function import string from Configurables import (CombineParticles, FilterDesktop, + DaVinci__N3BodyDecays as N3BodyDecays, DaVinci__N4BodyDecays as N4BodyDecays) from RecoConf.hlt1_tracking import EmptyFilter from PyConf.components import make_algorithm, Algorithm __all__ = [ - 'EmptyFilter', - 'ParticleFilter', - 'ParticleCombiner', - 'ParticleFilterWithPVs', - 'ParticleCombinerWithPVs', - 'require_all', + 'EmptyFilter', 'ParticleFilter', 'ParticleCombiner' + 'ParticleFilterWithPVs', 'ParticleCombinerWithPVs', 'require_all', + 'N3BodyCombiner', 'N3BodyCombinerWithPVs' + 'N4BodyCombiner', 'N4BodyCombinerWithPVs', ] @@ -113,6 +112,13 @@ combiners = { 4: make_dvalgorithm(CombineParticles, ninputs=4) } +threebodycombiners = { + 1: make_dvalgorithm(N3BodyDecays), + 2: make_dvalgorithm(N3BodyDecays, ninputs=2), + 3: make_dvalgorithm(N3BodyDecays, ninputs=3), + 4: make_dvalgorithm(N3BodyDecays, ninputs=4) +} + fourbodycombiners = { 1: make_dvalgorithm(N4BodyDecays), 2: make_dvalgorithm(N4BodyDecays, ninputs=2), @@ -137,7 +143,7 @@ def ParticleFilterWithPVs(particles, pvs, **kwargs): return ParticleFilter(particles=particles, PrimaryVertices=pvs, **kwargs) -def ParticleCombiner(particles, **kwargs): +def ParticleCombiner(particles, my_combiners=combiners, **kwargs): """Return a combiner algorithm that takes `particles` as inputs. Additional keyword arguments are forwarded to CombineParticles. @@ -147,9 +153,9 @@ def ParticleCombiner(particles, **kwargs): # Need to dispatch to the right combiner, based on the number of inputs assert len( - combiners) >= ninputs, 'Do not have a combiner for {} inputs'.format( + my_combiners) >= ninputs, 'Do not have a combiner for {} inputs'.format( ninputs) - combiner = combiners[ninputs] + combiner = my_combiners[ninputs] # Map each input container to an input property name inputs = { @@ -164,40 +170,37 @@ def ParticleCombiner(particles, **kwargs): return combiner(**kwargs).Output +def N3BodyCombiner(particles, **kwargs): + """Return a N3BodyDecays combiner algorithm that takes particles as inputs. + + Additional keyword arguments are forwarded to N3BodyDecays. + """ + return ParticleCombiner(particles, my_combiners=threebodycombiners, **kwargs) + + def N4BodyCombiner(particles, **kwargs): """Return a N4BodyDecays combiner algorithm that takes particles as inputs. Additional keyword arguments are forwarded to N4BodyDecays. """ - ## TODO: eliminate duplication of code with ParticleCombiner - particles = particles if isinstance(particles, list) else [particles] - ninputs = len(particles) + return ParticleCombiner(particles, my_combiners=fourbodycombiners, **kwargs) - # Need to dispatch to the right combiner, based on the number of inputs - assert len( - combiners) >= ninputs, 'Do not have a combiner for {} inputs'.format( - ninputs) - combiner = fourbodycombiners[ninputs] - # Map each input container to an input property name - inputs = { - 'Particles' + letter: p - for p, letter in zip(particles, string.ascii_uppercase) - } - # We need to merge dicts, we make sure we don't have overlapping keys (the - # caller really shouldn't specify ParticleX keys anyway) - assert set(inputs).intersection(kwargs) == set() - kwargs = dict(list(inputs.items()) + list(kwargs.items())) +def ParticleCombinerWithPVs(particles, pvs, **kwargs): + """Return a combiner algorithm that takes `particles` and `pvs` as inputs. - return combiner(**kwargs).Output + Additional keyword arguments are forwarded to CombineParticles. + """ + return ParticleCombiner(particles=particles, PrimaryVertices=pvs, **kwargs) -def ParticleCombinerWithPVs(particles, pvs, **kwargs): +def N3BodyCombinerWithPVs(particles, pvs, **kwargs): """Return a combiner algorithm that takes `particles` and `pvs` as inputs. Additional keyword arguments are forwarded to CombineParticles. """ - return ParticleCombiner(particles=particles, PrimaryVertices=pvs, **kwargs) + ## TODO: eliminate duplication of code with ParticleCombinerWithPVs + return N3BodyCombiner(particles=particles, PrimaryVertices=pvs, **kwargs) def N4BodyCombinerWithPVs(particles, pvs, **kwargs): -- GitLab From 382738a473b0d2c18ff02fa2f1e8410ea07d5847 Mon Sep 17 00:00:00 2001 From: Patrick Spradlin Date: Tue, 3 Sep 2019 19:40:43 +0200 Subject: [PATCH 12/16] Several changes to conclude the initial WIP of the lines. - Renamed D02_KKPiPi.py to D02HHHH.py - Added lines for other 4-body modes . D*(2010)+ -> D0(-> pi- pi- pi+ pi+) pi+ . D*(2010)+ -> D0(-> K- pi- pi+ pi+) pi+ . D*(2010)+ -> D0(-> K- K- K+ pi+) pi+ . D*(2010)+ -> D0(-> K+ pi- pi- pi+) pi+ . D*(2010)+ -> D0(-> K- K+ K+ pi-) pi+ - Added lines for untagged D0s - Made line names conform to https://gitlab.cern.ch/lhcb/Moore/issues/60 - Removed duplicate combinatorics, https://gitlab.cern.ch/lhcb/Moore/issues/64 - Removed makers as defaults, https://gitlab.cern.ch/lhcb/Moore/issues/53 --- Hlt/Hlt2Conf/options/testrun_4bodies.py | 12 +- Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py | 362 ++++++++++++++++++ .../python/Hlt2Conf/lines/D02_KKPiPi.py | 216 ----------- .../python/Hlt2Conf/lines/__init__.py | 4 +- 4 files changed, 375 insertions(+), 219 deletions(-) create mode 100644 Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py delete mode 100644 Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py diff --git a/Hlt/Hlt2Conf/options/testrun_4bodies.py b/Hlt/Hlt2Conf/options/testrun_4bodies.py index 7103289a0b1..10cdd9525e0 100644 --- a/Hlt/Hlt2Conf/options/testrun_4bodies.py +++ b/Hlt/Hlt2Conf/options/testrun_4bodies.py @@ -56,7 +56,17 @@ env.setupInput( CONDDBTag='sim-20171127-vc-md100', Simulation=True, inputFileType='ROOT') -lines_to_run = ['Hlt2CharmHadDstp2D0Pip_D02KmKpPimPipLine'] +lines_to_run = ['Hlt2CharmD0ToPimPimPipPipLine', + 'Hlt2CharmD0ToKmPimPipPipLine', + 'Hlt2CharmD0ToKmKpPimPipLine', + 'Hlt2CharmD0ToKmKmKpPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToPimPimPipPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKmPimPipPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKmKpPimPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKmKmKpPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKpPimPimPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKmKpKpPimLine' +] with FTRawBankDecoder.bind(DecodingVersion=ftdec_v), \ require_gec.bind(make_raw = make_raw_data_for_gec_from_file, diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py new file mode 100644 index 00000000000..6115370cf39 --- /dev/null +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py @@ -0,0 +1,362 @@ +############################################################################### +# (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration # +# # +# This software is distributed under the terms of the GNU General Public # +# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # +# # +# In applying this licence, CERN does not waive the privileges and immunities # +# granted to it by virtue of its status as an Intergovernmental Organization # +# or submit itself to any jurisdiction. # +############################################################################### +"""Definition of some D0 -> h- h+ h- h+ HLT2 lines. + +The logic is the same as in Run 1/2: create HLT2 lines by defining selections +which create physics objects. These selections may consume other selections, as +filters or combiners. + +The change comes in how selection components are defined. + +TODO(AP): More docs. +""" +from __future__ import absolute_import, division, print_function +import math + +from GaudiKernel.SystemOfUnits import GeV, MeV, mm, mrad + +from ..algorithms import require_all, ParticleCombinerWithPVs, ParticleFilterWithPVs, N4BodyCombinerWithPVs +from ..framework import configurable +from RecoConf.hlt1_tracking import require_pvs, require_gec +from RecoConf.reco_objects_from_file import make_pvs +from ..standard_particles import (make_has_rich_long_pions as + make_has_rich_pions, make_has_rich_long_kaons + as make_has_rich_kaons) +from . import hlt2_line_builder + +# Charged pion mass in MeV +_PION_M = 139.57061 * MeV # +/- 0.00024 + + +# TODO(AP): implement shared decorator +# @shared +@configurable +def make_selected_particles( + make_particles=None, + make_pvs=None, + trchi2dof_max=4, + mipchi2_min=3.5, + pt_min=250 * MeV, + trg_ghost_prob_max=0.5, + pid=None): + # TODO(AP): this would be a whole lot nicer with f-strings (Python >= 3.6) + # An alternative is to pass **locals() to format, but... ew + assert make_particles is not None, 'particles must be specified' + assert make_pvs is not None, 'PVs must be specified' + code = require_all( + 'PT > {pt_min}', + 'TRGHOSTPROB < {trg_ghost_prob_max}', + # TODO(AP): Cut value is reasonable for Run 2, but removes basically + # everything in the upgrade sample + 'TRCHI2DOF < {trchi2dof_max}', + 'MIPCHI2DV(PRIMARY) > {mipchi2_min}').format( + pt_min=pt_min, + trg_ghost_prob_max=trg_ghost_prob_max, + trchi2dof_max=trchi2dof_max, + mipchi2_min=mipchi2_min) + if pid is not None: + code += ' & ({})'.format(pid) + return ParticleFilterWithPVs(make_particles(), make_pvs(), Code=code) + + +@configurable +def make_charm_pions(pid='PIDK > 0'): + return make_selected_particles(make_particles=make_has_rich_pions, + make_pvs=make_pvs, pid=pid) + + +@configurable +def make_charm_kaons(pid='PIDK < 0'): + return make_selected_particles(make_particles=make_has_rich_kaons, + make_pvs=make_pvs, pid=pid) + + +@configurable +def make_dzeros(particles=None, + descriptors=None, + make_pvs=None, + am_min=1730 * MeV, + am_max=2000 * MeV, + asumpt_min=1800 * MeV, + ap_min=25000 * MeV, + achi2doca_max=10.0, + vchi2pdof_max=12, + bpvvdchi2_min=25, + acos_bpvdira_max=20 * mrad): + # TODO(AP): TypeError: Cannot decorate a function with positional arguments + # We want this function to be configurable, but there aren't aren't + # 'sensible' defaults for these args + assert particles is not None, 'particles must be specified' + assert descriptors is not None, 'descriptors must be specified' + assert make_pvs is not None, 'PVs must be specified' + + combination_code = require_all( + "in_range({am_min}, AM, {am_max})", + "(APT1 + APT2 + APT3 + APT4) > {asumpt_min}", + "AP > {ap_min}", + "ACHI2DOCA(1,4) < {achi2doca_max}", + "ACHI2DOCA(2,4) < {achi2doca_max}", + "ACHI2DOCA(3,4) < {achi2doca_max}").format( + am_min=am_min, + am_max=am_max, + asumpt_min=asumpt_min, + ap_min=ap_min, + achi2doca_max=achi2doca_max) + + ## TODO: Consider generalizing the hard-coded assumption in + ## sub-combination AM that the remaining particles will be pions. + ## If used for semileptonic reconstruction, will need to be changed. + combination123_code = require_all( + "AM < {am_max}", "ACHI2DOCA(1,3) < {achi2doca_max}", + "ACHI2DOCA(2,3) < {achi2doca_max}").format( + am_max=am_max - _PION_M, achi2doca_max=achi2doca_max) + + combination12_code = require_all( + "AM < {am_max}", "ACHI2DOCA(1,2) < {achi2doca_max}").format( + am_max=am_max - 2 * _PION_M, achi2doca_max=achi2doca_max) + bpvdira_min = math.cos(acos_bpvdira_max) + vertex_code = require_all("CHI2VXNDOF < {vchi2pdof_max}", "BPVVALID()", + "BPVVDCHI2() > {bpvvdchi2_min}", + "BPVDIRA() > {bpvdira_min}").format( + vchi2pdof_max=vchi2pdof_max, + bpvvdchi2_min=bpvvdchi2_min, + bpvdira_min=bpvdira_min) + + return N4BodyCombinerWithPVs( + particles=particles, + pvs=make_pvs(), + DecayDescriptors=descriptors, + CombinationCut=combination_code, + MotherCut=vertex_code, + Combination123Cut=combination123_code, + Combination12Cut=combination12_code) + + +@configurable +def make_dstars(dzeros=None, + soft_pions=None, + descriptors=None, + make_pvs=None, + max_comb_deltaM=190.0 * MeV, + max_vtx_deltaM=170.0 * MeV, + max_vtx_chi2_pdof=15.0): + assert dzeros is not None, 'dzeros must be specified' + assert soft_pions is not None, 'soft_pions must be specified' + assert descriptors is not None, 'descriptors must be specified' + assert make_pvs is not None, 'PVs must be specified' + + ## TODO: consider rewriting the delta M cuts as cuts on Q so there is + ## no assumed order of the decay products in the decay descriptor. + combination_code = require_all("(AM - AM1) < {max_comb_deltaM}").format( + max_comb_deltaM=max_comb_deltaM) + + vertex_code = require_all( + "(M - M1) < {max_vtx_deltaM}", + "VFASPF(VCHI2/VDOF) < {max_vtx_chi2_pdof}").format( + max_vtx_deltaM=max_vtx_deltaM, max_vtx_chi2_pdof=max_vtx_chi2_pdof) + + return ParticleCombinerWithPVs( + particles=[dzeros, soft_pions], + pvs=make_pvs(), + DecayDescriptors=descriptors, + CombinationCut=combination_code, + MotherCut=vertex_code) + + +def charm_prefilters(): + return [require_gec(), require_pvs(make_pvs())] + + +@configurable +def make_dzero2kpipipi_fordstar(): + pions = make_charm_pions() + kaons = make_charm_kaons() + return make_dzeros(particles=[pions, kaons], + descriptors=['[D0 -> K- pi- pi+ pi+]cc'], + make_pvs=make_pvs) + + +@configurable +def make_dzero2kkkpi_fordstar(): + kaons = make_charm_kaons() + pions = make_charm_pions() + return make_dzeros(particles=[pions, kaons], + descriptors=['[D0 -> K- K- K+ pi+]cc'], + make_pvs=make_pvs) + + +@hlt2_line_builder('Hlt2CharmD0ToPimPimPipPipLine') +def dzero2pipipipi_line(): + """Line for D0 -> pi- pi- pi+ pi+ + + In principle, can use D0 candidates with selection criteria different from + those in the D* line. + """ + pions = make_charm_pions() + dzeros = make_dzeros(particles=[pions], + descriptors=['D0 -> pi- pi- pi+ pi+'], make_pvs=make_pvs) + return charm_prefilters() + [dzeros] + + +@hlt2_line_builder('Hlt2CharmD0ToKmPimPipPipLine') +def dzero2kpipipi_line(): + """Line for D0 -> K- pi- pi+ pi+ + C.C. + + In principle, can use D0 candidates with selection criteria different from + those in the D* lines. + """ + pions = make_charm_pions() + kaons = make_charm_kaons() + dzeros = make_dzeros(particles=[pions, kaons], + descriptors=['[D0 -> K- pi- pi+ pi+]cc'], make_pvs=make_pvs) + return charm_prefilters() + [dzeros] + + +@hlt2_line_builder('Hlt2CharmD0ToKmKpPimPipLine') +def dzero2kkpipi_line(): + """Line for D0 -> K- K+ pi- pi+ + + In principle, can use D0 candidates with selection criteria different from + those in the D* line. + """ + pions = make_charm_pions() + kaons = make_charm_kaons() + dzeros = make_dzeros(particles=[pions, kaons], + descriptors=['D0 -> K- K+ pi- pi+'], make_pvs=make_pvs) + return charm_prefilters() + [dzeros] + + +@hlt2_line_builder('Hlt2CharmD0ToKmKmKpPipLine') +def dzero2kkkpi_line(): + """Line for D0 -> K- K- K+ pi+ + C.C. + + In principle, can use D0 candidates with selection criteria different from + those in the D* lines. + """ + pions = make_charm_pions() + kaons = make_charm_kaons() + dzeros = make_dzeros(particles=[pions, kaons], + descriptors=['[D0 -> K- K- K+ pi+]cc'], make_pvs=make_pvs) + return charm_prefilters() + [dzeros] + + +@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToPimPimPipPipLine') +def dstar2dzeropi_dzero2pipipipi_line(): + """Line for D*+ -> D0(-> pi- pi- pi+ pi+) pi+ + C.C. + + In order to avoid duplication of combinatorics of the charge-symmetric + final state of the D0, only combinations labelled D0 are made. This + leads to the second 'unphysical' decay descriptor for the D*-. + See https://gitlab.cern.ch/lhcb/Moore/issues/64. + """ + pions = make_charm_pions() + dzeros = make_dzeros(particles=[pions], + descriptors=['D0 -> pi- pi- pi+ pi+'], make_pvs=make_pvs) + soft_pions = make_has_rich_pions() + dstars = make_dstars( + dzeros=dzeros, + soft_pions=soft_pions, + descriptors=['D*(2010)+ -> D0 pi+', 'D*(2010)- -> D0 pi-'], + make_pvs=make_pvs) + return charm_prefilters() + [dstars] + + +@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKmPimPipPipLine') +def dstar2dzeropi_dzero2kpipipiRS_line(): + """Line for D*+ -> D0(-> K- pi- pi+ pi+) pi+ + C.C. + """ + dzeros = make_dzero2kpipipi_fordstar() + soft_pions = make_has_rich_pions() + dstars = make_dstars( + dzeros=dzeros, + soft_pions=soft_pions, + descriptors=['[D*(2010)+ -> D0 pi+]cc'], + make_pvs=make_pvs) + return charm_prefilters() + [dstars] + + +@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKmKpPimPipLine') +def dstar2dzeropi_dzero2kkpipi_line(): + """Line for D*+ -> D0(-> K- K+ pi- pi+) pi+ + C.C. + + In order to avoid duplication of combinatorics of the charge-symmetric + final state of the D0, only combinations labelled D0 are made. This + leads to the second 'unphysical' decay descriptor for the D*-. + See https://gitlab.cern.ch/lhcb/Moore/issues/64. + """ + ## TODO: Update D* descriptors if the problem of duplication is solved. + kaons = make_charm_kaons() + pions = make_charm_pions() + dzeros = make_dzeros(particles=[pions, kaons], + descriptors=['D0 -> K- K+ pi- pi+'], make_pvs=make_pvs) + soft_pions = make_has_rich_pions() + dstars = make_dstars( + dzeros=dzeros, + soft_pions=soft_pions, + descriptors=['D*(2010)+ -> D0 pi+', 'D*(2010)- -> D0 pi-'], + make_pvs=make_pvs) + return charm_prefilters() + [dstars] + + +@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKmKmKpPipLine') +def dstar2dzeropi_dzero2kkkpiRS_line(): + """Line for D*+ -> D0(-> K- K- K+ pi+) pi+ + C.C. + """ + dzeros = make_dzero2kkkpi_fordstar() + soft_pions = make_has_rich_pions() + dstars = make_dstars( + dzeros=dzeros, + soft_pions=soft_pions, + descriptors=['[D*(2010)+ -> D0 pi+]cc'], + make_pvs=make_pvs) + return charm_prefilters() + [dstars] + + +@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKpPimPimPipLine') +def dstar2dzeropi_dzero2kpipipiWS_line(): + """Line for D*+ -> D0(-> K+ pi- pi- pi+) pi+ + C.C. + + In order to reuse the D0 combinatorics from + dstar2dzeropi_dzero2KpipipiRS_line, the D* decay descriptors are written + unphysically to treat the combinations that are labelled D0 as if they were + D~0. + """ + ## TODO: Update D* descriptors if the problem of duplication is solved. + dzeros = make_dzero2kpipipi_fordstar() + soft_pions = make_has_rich_pions() + dstars = make_dstars( + dzeros=dzeros, + soft_pions=soft_pions, + descriptors=['[D*(2010)- -> D0 pi-]cc'], + make_pvs=make_pvs) + return charm_prefilters() + [dstars] + + +@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKmKpKpPimLine') +def dstar2dzeropi_dzero2kkkpiWS_line(): + """Line for D*+ -> D0(-> K- K+ K+ pi-) pi+ + C.C. + + In order to reuse the D0 combinatorics from + dstar2dzeropi_dzero2KKKpiRS_line, the D* decay descriptors are written + unphysically to treat the combinations that are labelled D0 as if they were + D~0. + """ + ## TODO: Update D* descriptors if the problem of duplication is solved. + dzeros = make_dzero2kkkpi_fordstar() + soft_pions = make_has_rich_pions() + dstars = make_dstars( + dzeros=dzeros, + soft_pions=soft_pions, + descriptors=['[D*(2010)- -> D0 pi-]cc'], + make_pvs=make_pvs) + return charm_prefilters() + [dstars] + + diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py deleted file mode 100644 index 6f8bc800e27..00000000000 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02_KKPiPi.py +++ /dev/null @@ -1,216 +0,0 @@ -############################################################################### -# (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -"""Definition of some D0 -> h- h+ h- h+ HLT2 lines. - -The logic is the same as in Run 1/2: create HLT2 lines by defining selections -which create physics objects. These selections may consume other selections, as -filters or combiners. - -The change comes in how selection components are defined. - -TODO(AP): More docs. -""" -from __future__ import absolute_import, division, print_function -import math - -from GaudiKernel.SystemOfUnits import GeV, MeV, mm, mrad - -from ..algorithms import require_all, ParticleCombinerWithPVs, ParticleFilterWithPVs, N4BodyCombinerWithPVs -from ..framework import configurable -from RecoConf.hlt1_tracking import require_pvs, require_gec -from RecoConf.reco_objects_from_file import make_pvs -from ..standard_particles import (make_has_rich_long_pions as - make_has_rich_pions, make_has_rich_long_kaons - as make_has_rich_kaons) -from . import hlt2_line_builder - -# Charged pion mass in MeV -_PION_M = 139.57061 # +/- 0.00024 - - -# TODO(AP): implement shared decorator -# @shared -@configurable -def make_selected_particles( - make_particles=make_has_rich_pions, - make_pvs=make_pvs, - trchi2dof_max=4, - mipchi2_min=3.5, - pt_min=250 * MeV, - trg_ghost_prob_max=0.5, - #p_min=8 * GeV, - pid=None): - # TODO(AP): this would be a whole lot nicer with f-strings (Python >= 3.6) - # An alternative is to pass **locals() to format, but... ew - code = require_all( - 'PT > {pt_min}', - 'TRGHOSTPROB < {trg_ghost_prob_max}', - #'P > {p_min}', - # TODO(AP): Cut value is reasonable for Run 2, but removes basically - # everything in the upgrade sample - 'TRCHI2DOF < {trchi2dof_max}', - 'MIPCHI2DV(PRIMARY) > {mipchi2_min}').format( - pt_min=pt_min, - trg_ghost_prob_max=trg_ghost_prob_max, - trchi2dof_max=trchi2dof_max, - mipchi2_min=mipchi2_min) - if pid is not None: - code += ' & ({})'.format(pid) - return ParticleFilterWithPVs(make_particles(), make_pvs(), Code=code) - - -#implement selection criteria for soft pions -def make_soft_pions(make_particles=make_has_rich_pions, - make_pvs=make_pvs, - trchi2dof_max=3): - - code = require_all('TRCHI2DOF < {trchi2dof_max}').format( - trchi2dof_max=trchi2dof_max) - return ParticleFilterWithPVs(make_particles(), make_pvs(), Code=code) - - -# TODO(AP): bound doesn't exist yet -# make_charm_pions = bound(make_selected_particles, make_has_rich_pions, pid='PIDK < 3') -# make_charm_kaons = bound(make_selected_particles, make_has_rich_pions, pid='PIDK > 3') - - -@configurable -def make_charm_pions(pid='PIDK > 0'): - return make_selected_particles(make_particles=make_has_rich_pions, pid=pid) - - -@configurable -def make_charm_kaons(pid='PIDK < 0'): - return make_selected_particles(make_particles=make_has_rich_kaons, pid=pid) - - -@configurable -def make_dzeros(particles=None, - descriptors=None, - make_pvs=make_pvs, - am_min=1730 * MeV, - am_max=2000 * MeV, - amaxchild_pt_min=1500 * MeV, - ap_min=20000 * MeV, - achi2doca_max=10.0, - vchi2pdof_max=10, - bpvvdchi2_min=25, - bpvdira_min=0.99995): - # TODO(AP): TypeError: Cannot decorate a function with positional arguments - # We want this function to be configurable, but there aren't aren't - # 'sensible' defaults for these args - assert particles is not None, 'particles must be specified' - assert descriptors is not None, 'descriptors must be specified' - - combination_code = require_all( - "in_range({am_min}, AM, {am_max})", - "(APT1 + APT2 + APT3 + APT4) > {amaxchild_pt_min}", - "AP > {ap_min}").format( - am_min=am_min, - am_max=am_max, - amaxchild_pt_min=amaxchild_pt_min, - ap_min=ap_min) - - combination123_code = require_all( - "AM < {am_min}", "ACHI2DOCA(1,3) < {achi2doca_max}", - "ACHI2DOCA(2,3) < {achi2doca_max}").format( - am_min=2000 - _PION_M, achi2doca_max=achi2doca_max) - - combination12_code = require_all( - "AM < {am_min}", "ACHI2DOCA(1,2) < {achi2doca_max}").format( - am_min=2000 - _PION_M, achi2doca_max=achi2doca_max) - #cos_bpvdira_min = math.cos(bpvdira_min) - vertex_code = require_all("CHI2VXNDOF < {vchi2pdof_max}", "BPVVALID()", - "BPVVDCHI2() > {bpvvdchi2_min}", - "BPVDIRA() > {cos_bpvdira_min}").format( - vchi2pdof_max=vchi2pdof_max, - bpvvdchi2_min=bpvvdchi2_min, - cos_bpvdira_min=bpvdira_min) - - return N4BodyCombinerWithPVs( - particles=particles, - pvs=make_pvs(), - DecayDescriptors=descriptors, - CombinationCut=combination_code, - MotherCut=vertex_code, - Combination123Cut=combination123_code, - Combination12Cut=combination12_code) - - #return ParticleCombinerWithPVs( - # particles=particles, - # pvs=make_pvs(), - # DecayDescriptors=descriptors, - # CombinationCut=combination_code, - # MotherCut=vertex_code) - - -@configurable -def make_dstars(dzeros=None, - soft_pions=None, - descriptors=None, - make_pvs=make_pvs, - max_comb_deltaM=190.0, - max_vtx_deltaM=170.0, - max_vtx_chi2_pdof=15.0): - assert dzeros is not None, 'dzeros must be specified' - assert soft_pions is not None, 'soft_pions must be specified' - assert descriptors is not None, 'descriptors must be specified' - - combination_code = require_all("(AM - AM1) < {max_comb_deltaM}").format( - max_comb_deltaM=max_comb_deltaM) - - vertex_code = require_all( - "(M - M1) < {max_vtx_deltaM}", - "VFASPF(VCHI2/VDOF) < {max_vtx_chi2_pdof}").format( - max_vtx_deltaM=max_vtx_deltaM, max_vtx_chi2_pdof=max_vtx_chi2_pdof) - - return ParticleCombinerWithPVs( - particles=[dzeros, soft_pions], - pvs=make_pvs(), - DecayDescriptors=descriptors, - CombinationCut=combination_code, - MotherCut=vertex_code) - - -def charm_prefilters(): - return [require_gec(), require_pvs(make_pvs())] - - -""" -@hlt2_line_builder('Hlt2CharmHadD02KmKpPimPipLine') -def dzero2pipipipi_line(): - pions = make_charm_pions() - dzeros = make_dzeros(particles=pions, descriptors=['D0 -> K- K+ pi- pi+']) - return charm_prefilters() + [dzeros] -""" - - -@hlt2_line_builder('Hlt2CharmHadDstp2D0Pip_D02KmKpPimPipLine') -def dstar2dzeropi_dzero2Kpipipi_line(): - kaons = make_charm_kaons() - pions = make_charm_pions() - dzeros = make_dzeros( - particles=[kaons, pions], descriptors=['[D0 -> K- K+ pi- pi+]cc']) - soft_pions = make_has_rich_pions() - dstars = make_dstars( - dzeros=dzeros, - soft_pions=soft_pions, - descriptors=['[D*(2010)+ -> D0 pi+]cc']) - return charm_prefilters() + [dstars] - - -""" -@hlt2_line_builder('Hlt2CharmHadD02KmKpLine') -def dzero2kk_line(): - kaons = make_charm_kaons() - dzeros = make_dzeros(particles=kaons, descriptors=['D0 -> K- K+']) - return charm_prefilters() + [dzeros] -""" diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/__init__.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/__init__.py index 8ce7939c0a9..a37a39196bc 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/__init__.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/__init__.py @@ -18,7 +18,7 @@ from Moore.config import add_line_to_registry from . import ( Bs2JpsiPhi, D02HH, - D02_KKPiPi, + D02HHHH, ) __all__ = [ @@ -44,7 +44,7 @@ def _get_all_lines(modules): modules = [ Bs2JpsiPhi, D02HH, - D02_KKPiPi, + D02HHHH, ] all_lines = _get_all_lines(modules) -- GitLab From a50db2ee4df0d2347ebd7d2a88aeaae1dff87a14 Mon Sep 17 00:00:00 2001 From: Patrick Spradlin Date: Tue, 3 Sep 2019 20:53:25 +0200 Subject: [PATCH 13/16] Updated testrun_4bodies.py to be runnable on current master --- Hlt/Hlt2Conf/options/testrun_4bodies.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Hlt/Hlt2Conf/options/testrun_4bodies.py b/Hlt/Hlt2Conf/options/testrun_4bodies.py index 10cdd9525e0..7246e2da648 100644 --- a/Hlt/Hlt2Conf/options/testrun_4bodies.py +++ b/Hlt/Hlt2Conf/options/testrun_4bodies.py @@ -16,7 +16,7 @@ Run like any other options file: """ from __future__ import absolute_import, division, print_function -from PyConf.environment import EverythingHandler +from PyConf.environment import EverythingHandler, setupInput from PyConf.Algorithms import FTRawBankDecoder @@ -31,11 +31,11 @@ from RecoConf.hlt1_tracking import require_gec input_files = [ # MinBias 30000000 - #sim+std://MC/Upgrade/Beam7000GeV-Upgrade-MagDown-Nu7.6-25ns-Pythia8/Sim09c-Up02/Reco-Up01/30000000/LDST - #'root://xrootd.echo.stfc.ac.uk/lhcb:prod/lhcb/MC/Upgrade/LDST/00069155/0000/00069155_00000878_2.ldst' + # sim+std://MC/Upgrade/Beam7000GeV-Upgrade-MagDown-Nu7.6-25ns-Pythia8/Sim09c-Up02/Reco-Up01/30000000/LDST + # 'root://xrootd.echo.stfc.ac.uk/lhcb:prod/lhcb/MC/Upgrade/LDST/00069155/0000/00069155_00000878_2.ldst' # D*-tagged D0 to KK, 27163002 # sim+std://MC/Upgrade/Beam7000GeV-Upgrade-MagDown-Nu7.6-25ns-Pythia8/Sim09c-Up02/Reco-Up01/27163002/LDST - #'root://lhcbxrootd-kit.gridka.de//pnfs/gridka.de/lhcb/MC/Upgrade/LDST/00070317/0000/00070317_00000012_2.ldst' + # 'root://lhcbxrootd-kit.gridka.de//pnfs/gridka.de/lhcb/MC/Upgrade/LDST/00070317/0000/00070317_00000012_2.ldst' ##KKpipi sample 'root://ccxrootdlhcb.in2p3.fr//pnfs/in2p3.fr/data/lhcb/MC/Upgrade/MCFILTER.LDST/00047762/0000/00047762_00000001_1.mcfilter.ldst' ] @@ -49,7 +49,7 @@ raw_event_format = 4.3 env = EverythingHandler( threadPoolSize=1, nEventSlots=1, evtMax=100, debug=False) -env.setupInput( +setupInput( input_files, dataType='Upgrade', DDDBTag='dddb-20171126', @@ -79,4 +79,3 @@ with FTRawBankDecoder.bind(DecodingVersion=ftdec_v), \ env.register_public_tool(stateProvider_with_simplified_geom()) env.configure() -# env.plotDataFlow() -- GitLab From 53e1db5443593fb5a3755f2fe080e60a43796deb Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 3 Sep 2019 18:54:14 +0000 Subject: [PATCH 14/16] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/5358405 --- Hlt/Hlt2Conf/options/testrun_4bodies.py | 19 ++--- Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py | 26 ++++-- Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py | 83 ++++++++++--------- 3 files changed, 72 insertions(+), 56 deletions(-) diff --git a/Hlt/Hlt2Conf/options/testrun_4bodies.py b/Hlt/Hlt2Conf/options/testrun_4bodies.py index 7246e2da648..e7f422a5efa 100644 --- a/Hlt/Hlt2Conf/options/testrun_4bodies.py +++ b/Hlt/Hlt2Conf/options/testrun_4bodies.py @@ -56,16 +56,15 @@ setupInput( CONDDBTag='sim-20171127-vc-md100', Simulation=True, inputFileType='ROOT') -lines_to_run = ['Hlt2CharmD0ToPimPimPipPipLine', - 'Hlt2CharmD0ToKmPimPipPipLine', - 'Hlt2CharmD0ToKmKpPimPipLine', - 'Hlt2CharmD0ToKmKmKpPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToPimPimPipPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKmPimPipPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKmKpPimPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKmKmKpPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKpPimPimPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKmKpKpPimLine' +lines_to_run = [ + 'Hlt2CharmD0ToPimPimPipPipLine', 'Hlt2CharmD0ToKmPimPipPipLine', + 'Hlt2CharmD0ToKmKpPimPipLine', 'Hlt2CharmD0ToKmKmKpPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToPimPimPipPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKmPimPipPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKmKpPimPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKmKmKpPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKpPimPimPipLine', + 'Hlt2CharmDstpToD0Pip_D0ToKmKpKpPimLine' ] with FTRawBankDecoder.bind(DecodingVersion=ftdec_v), \ diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py index f18553a5238..b347f1a03c5 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py @@ -28,10 +28,16 @@ from RecoConf.hlt1_tracking import EmptyFilter from PyConf.components import make_algorithm, Algorithm __all__ = [ - 'EmptyFilter', 'ParticleFilter', 'ParticleCombiner' - 'ParticleFilterWithPVs', 'ParticleCombinerWithPVs', 'require_all', - 'N3BodyCombiner', 'N3BodyCombinerWithPVs' - 'N4BodyCombiner', 'N4BodyCombinerWithPVs', + 'EmptyFilter', + 'ParticleFilter', + 'ParticleCombiner' + 'ParticleFilterWithPVs', + 'ParticleCombinerWithPVs', + 'require_all', + 'N3BodyCombiner', + 'N3BodyCombinerWithPVs' + 'N4BodyCombiner', + 'N4BodyCombinerWithPVs', ] @@ -152,9 +158,9 @@ def ParticleCombiner(particles, my_combiners=combiners, **kwargs): ninputs = len(particles) # Need to dispatch to the right combiner, based on the number of inputs - assert len( - my_combiners) >= ninputs, 'Do not have a combiner for {} inputs'.format( - ninputs) + assert len(my_combiners + ) >= ninputs, 'Do not have a combiner for {} inputs'.format( + ninputs) combiner = my_combiners[ninputs] # Map each input container to an input property name @@ -175,7 +181,8 @@ def N3BodyCombiner(particles, **kwargs): Additional keyword arguments are forwarded to N3BodyDecays. """ - return ParticleCombiner(particles, my_combiners=threebodycombiners, **kwargs) + return ParticleCombiner( + particles, my_combiners=threebodycombiners, **kwargs) def N4BodyCombiner(particles, **kwargs): @@ -183,7 +190,8 @@ def N4BodyCombiner(particles, **kwargs): Additional keyword arguments are forwarded to N4BodyDecays. """ - return ParticleCombiner(particles, my_combiners=fourbodycombiners, **kwargs) + return ParticleCombiner( + particles, my_combiners=fourbodycombiners, **kwargs) def ParticleCombinerWithPVs(particles, pvs, **kwargs): diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py index 6115370cf39..92fd7e7d45e 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py @@ -39,14 +39,13 @@ _PION_M = 139.57061 * MeV # +/- 0.00024 # TODO(AP): implement shared decorator # @shared @configurable -def make_selected_particles( - make_particles=None, - make_pvs=None, - trchi2dof_max=4, - mipchi2_min=3.5, - pt_min=250 * MeV, - trg_ghost_prob_max=0.5, - pid=None): +def make_selected_particles(make_particles=None, + make_pvs=None, + trchi2dof_max=4, + mipchi2_min=3.5, + pt_min=250 * MeV, + trg_ghost_prob_max=0.5, + pid=None): # TODO(AP): this would be a whole lot nicer with f-strings (Python >= 3.6) # An alternative is to pass **locals() to format, but... ew assert make_particles is not None, 'particles must be specified' @@ -69,14 +68,14 @@ def make_selected_particles( @configurable def make_charm_pions(pid='PIDK > 0'): - return make_selected_particles(make_particles=make_has_rich_pions, - make_pvs=make_pvs, pid=pid) + return make_selected_particles( + make_particles=make_has_rich_pions, make_pvs=make_pvs, pid=pid) @configurable def make_charm_kaons(pid='PIDK < 0'): - return make_selected_particles(make_particles=make_has_rich_kaons, - make_pvs=make_pvs, pid=pid) + return make_selected_particles( + make_particles=make_has_rich_kaons, make_pvs=make_pvs, pid=pid) @configurable @@ -100,10 +99,8 @@ def make_dzeros(particles=None, combination_code = require_all( "in_range({am_min}, AM, {am_max})", - "(APT1 + APT2 + APT3 + APT4) > {asumpt_min}", - "AP > {ap_min}", - "ACHI2DOCA(1,4) < {achi2doca_max}", - "ACHI2DOCA(2,4) < {achi2doca_max}", + "(APT1 + APT2 + APT3 + APT4) > {asumpt_min}", "AP > {ap_min}", + "ACHI2DOCA(1,4) < {achi2doca_max}", "ACHI2DOCA(2,4) < {achi2doca_max}", "ACHI2DOCA(3,4) < {achi2doca_max}").format( am_min=am_min, am_max=am_max, @@ -111,7 +108,7 @@ def make_dzeros(particles=None, ap_min=ap_min, achi2doca_max=achi2doca_max) - ## TODO: Consider generalizing the hard-coded assumption in + ## TODO: Consider generalizing the hard-coded assumption in ## sub-combination AM that the remaining particles will be pions. ## If used for semileptonic reconstruction, will need to be changed. combination123_code = require_all( @@ -179,18 +176,20 @@ def charm_prefilters(): def make_dzero2kpipipi_fordstar(): pions = make_charm_pions() kaons = make_charm_kaons() - return make_dzeros(particles=[pions, kaons], - descriptors=['[D0 -> K- pi- pi+ pi+]cc'], - make_pvs=make_pvs) + return make_dzeros( + particles=[pions, kaons], + descriptors=['[D0 -> K- pi- pi+ pi+]cc'], + make_pvs=make_pvs) @configurable def make_dzero2kkkpi_fordstar(): kaons = make_charm_kaons() pions = make_charm_pions() - return make_dzeros(particles=[pions, kaons], - descriptors=['[D0 -> K- K- K+ pi+]cc'], - make_pvs=make_pvs) + return make_dzeros( + particles=[pions, kaons], + descriptors=['[D0 -> K- K- K+ pi+]cc'], + make_pvs=make_pvs) @hlt2_line_builder('Hlt2CharmD0ToPimPimPipPipLine') @@ -201,8 +200,10 @@ def dzero2pipipipi_line(): those in the D* line. """ pions = make_charm_pions() - dzeros = make_dzeros(particles=[pions], - descriptors=['D0 -> pi- pi- pi+ pi+'], make_pvs=make_pvs) + dzeros = make_dzeros( + particles=[pions], + descriptors=['D0 -> pi- pi- pi+ pi+'], + make_pvs=make_pvs) return charm_prefilters() + [dzeros] @@ -215,8 +216,10 @@ def dzero2kpipipi_line(): """ pions = make_charm_pions() kaons = make_charm_kaons() - dzeros = make_dzeros(particles=[pions, kaons], - descriptors=['[D0 -> K- pi- pi+ pi+]cc'], make_pvs=make_pvs) + dzeros = make_dzeros( + particles=[pions, kaons], + descriptors=['[D0 -> K- pi- pi+ pi+]cc'], + make_pvs=make_pvs) return charm_prefilters() + [dzeros] @@ -229,8 +232,10 @@ def dzero2kkpipi_line(): """ pions = make_charm_pions() kaons = make_charm_kaons() - dzeros = make_dzeros(particles=[pions, kaons], - descriptors=['D0 -> K- K+ pi- pi+'], make_pvs=make_pvs) + dzeros = make_dzeros( + particles=[pions, kaons], + descriptors=['D0 -> K- K+ pi- pi+'], + make_pvs=make_pvs) return charm_prefilters() + [dzeros] @@ -243,8 +248,10 @@ def dzero2kkkpi_line(): """ pions = make_charm_pions() kaons = make_charm_kaons() - dzeros = make_dzeros(particles=[pions, kaons], - descriptors=['[D0 -> K- K- K+ pi+]cc'], make_pvs=make_pvs) + dzeros = make_dzeros( + particles=[pions, kaons], + descriptors=['[D0 -> K- K- K+ pi+]cc'], + make_pvs=make_pvs) return charm_prefilters() + [dzeros] @@ -258,8 +265,10 @@ def dstar2dzeropi_dzero2pipipipi_line(): See https://gitlab.cern.ch/lhcb/Moore/issues/64. """ pions = make_charm_pions() - dzeros = make_dzeros(particles=[pions], - descriptors=['D0 -> pi- pi- pi+ pi+'], make_pvs=make_pvs) + dzeros = make_dzeros( + particles=[pions], + descriptors=['D0 -> pi- pi- pi+ pi+'], + make_pvs=make_pvs) soft_pions = make_has_rich_pions() dstars = make_dstars( dzeros=dzeros, @@ -295,8 +304,10 @@ def dstar2dzeropi_dzero2kkpipi_line(): ## TODO: Update D* descriptors if the problem of duplication is solved. kaons = make_charm_kaons() pions = make_charm_pions() - dzeros = make_dzeros(particles=[pions, kaons], - descriptors=['D0 -> K- K+ pi- pi+'], make_pvs=make_pvs) + dzeros = make_dzeros( + particles=[pions, kaons], + descriptors=['D0 -> K- K+ pi- pi+'], + make_pvs=make_pvs) soft_pions = make_has_rich_pions() dstars = make_dstars( dzeros=dzeros, @@ -358,5 +369,3 @@ def dstar2dzeropi_dzero2kkkpiWS_line(): descriptors=['[D*(2010)- -> D0 pi-]cc'], make_pvs=make_pvs) return charm_prefilters() + [dstars] - - -- GitLab From bfe3b38f13483c3981c703d5e6377c361ab72676 Mon Sep 17 00:00:00 2001 From: Patrick Spradlin Date: Wed, 2 Oct 2019 23:44:15 +0200 Subject: [PATCH 15/16] Cleanup after a complicated rebase. --- Hlt/Hlt2Conf/options/hlt2_all_lines.py | 58 +++++--------------------- 1 file changed, 11 insertions(+), 47 deletions(-) diff --git a/Hlt/Hlt2Conf/options/hlt2_all_lines.py b/Hlt/Hlt2Conf/options/hlt2_all_lines.py index 10a1742aa4c..cf4d8ab8379 100644 --- a/Hlt/Hlt2Conf/options/hlt2_all_lines.py +++ b/Hlt/Hlt2Conf/options/hlt2_all_lines.py @@ -15,55 +15,19 @@ Run like any other options file: ./Moore/run gaudirun.py hlt2_all_lines.py """ from __future__ import absolute_import, division, print_function +from Moore import options, run_moore +from RecoConf.reco_objects_from_file import stateProvider_with_simplified_geom +from Hlt2Conf.lines import all_lines -from PyConf.environment import EverythingHandler, setupInput +options.set_conds_from_testfiledb('Upgrade_MinBias_LDST') +options.set_input_from_testfiledb('Upgrade_MinBias_LDST') +options.input_raw_format = 4.3 +options.evt_max = 100 -from PyConf.Algorithms import FTRawBankDecoder -from Hlt2Conf.setup import setup -from Hlt2Conf.data_from_file import raw_event_from_file -from Hlt2Conf.lines import _hlt2_line_builders, hlt2_line_builders +def make_lines(): + return [builder() for builder in all_lines.values()] -from RecoConf.reco_objects_from_file import ( - make_raw_data_for_gec_from_file, upfront_reconstruction, - stateProvider_with_simplified_geom) -from RecoConf.hlt1_tracking import require_gec -input_files = [ - # MinBias 30000000 - # sim+std://MC/Upgrade/Beam7000GeV-Upgrade-MagDown-Nu7.6-25ns-Pythia8/Sim09c-Up02/Reco-Up01/30000000/LDST - 'root://xrootd.echo.stfc.ac.uk/lhcb:prod/lhcb/MC/Upgrade/LDST/00069155/0000/00069155_00000878_2.ldst' -] - -setup() - -ftdec_v = 4 -# When running from Upgrade MC, must use the post-juggling locations of the raw -# event -raw_event_format = 4.3 - -env = EverythingHandler( - threadPoolSize=1, nEventSlots=1, evtMax=100, debug=False) -setupInput( - input_files, - dataType='Upgrade', - DDDBTag='dddb-20171126', - CONDDBTag='sim-20171127-vc-md100', - Simulation=True, - inputFileType='ROOT') - -# Use private internal state to get all registered lines -lines_to_run = _hlt2_line_builders.keys() - -with FTRawBankDecoder.bind(DecodingVersion=ftdec_v), \ - require_gec.bind(make_raw=make_raw_data_for_gec_from_file, - FTDecodingVersion=ftdec_v), \ - raw_event_from_file.bind(raw_event_format=raw_event_format): - - for name, builder in hlt2_line_builders(lines_to_run).items(): - env.registerLine(name, upfront_reconstruction() + builder()) - -env.register_public_tool(stateProvider_with_simplified_geom()) - -env.configure() -# env.plotDataFlow() +public_tools = [stateProvider_with_simplified_geom()] +run_moore(options, make_lines, public_tools) -- GitLab From bc2a57b9013147580b205b8f6645fed769dc114b Mon Sep 17 00:00:00 2001 From: Patrick Spradlin Date: Thu, 3 Oct 2019 00:47:39 +0200 Subject: [PATCH 16/16] Update with the new line configuration method --- Hlt/Hlt2Conf/options/testrun_4bodies.py | 65 ++---- Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py | 2 +- Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py | 193 +++++++++++------- 3 files changed, 138 insertions(+), 122 deletions(-) diff --git a/Hlt/Hlt2Conf/options/testrun_4bodies.py b/Hlt/Hlt2Conf/options/testrun_4bodies.py index e7f422a5efa..8e229d7624b 100644 --- a/Hlt/Hlt2Conf/options/testrun_4bodies.py +++ b/Hlt/Hlt2Conf/options/testrun_4bodies.py @@ -14,67 +14,36 @@ Run like any other options file: ./Moore/run gaudirun.py hlt2_example.py """ -from __future__ import absolute_import, division, print_function +from Moore import options, run_moore -from PyConf.environment import EverythingHandler, setupInput - -from PyConf.Algorithms import FTRawBankDecoder - -from Hlt2Conf.setup import setup -from Hlt2Conf.data_from_file import raw_event_from_file -from Hlt2Conf.lines import hlt2_line_builders - -from RecoConf.reco_objects_from_file import ( - make_raw_data_for_gec_from_file, upfront_reconstruction, - stateProvider_with_simplified_geom) -from RecoConf.hlt1_tracking import require_gec +from Hlt2Conf.lines.D02HHHH import all_lines +from RecoConf.reco_objects_from_file import stateProvider_with_simplified_geom +# TODO stateProvider_with_simplified_geom must go away from option files input_files = [ # MinBias 30000000 # sim+std://MC/Upgrade/Beam7000GeV-Upgrade-MagDown-Nu7.6-25ns-Pythia8/Sim09c-Up02/Reco-Up01/30000000/LDST # 'root://xrootd.echo.stfc.ac.uk/lhcb:prod/lhcb/MC/Upgrade/LDST/00069155/0000/00069155_00000878_2.ldst' - # D*-tagged D0 to KK, 27163002 - # sim+std://MC/Upgrade/Beam7000GeV-Upgrade-MagDown-Nu7.6-25ns-Pythia8/Sim09c-Up02/Reco-Up01/27163002/LDST - # 'root://lhcbxrootd-kit.gridka.de//pnfs/gridka.de/lhcb/MC/Upgrade/LDST/00070317/0000/00070317_00000012_2.ldst' - ##KKpipi sample + # D*-tagged D0 to KKpipi 'root://ccxrootdlhcb.in2p3.fr//pnfs/in2p3.fr/data/lhcb/MC/Upgrade/MCFILTER.LDST/00047762/0000/00047762_00000001_1.mcfilter.ldst' ] -setup() - -ftdec_v = 4 +options.input_files = input_files +options.input_type = 'ROOT' +options.input_raw_format = 4.3 # When running from Upgrade MC, must use the post-juggling locations of the raw # event -raw_event_format = 4.3 -env = EverythingHandler( - threadPoolSize=1, nEventSlots=1, evtMax=100, debug=False) -setupInput( - input_files, - dataType='Upgrade', - DDDBTag='dddb-20171126', - CONDDBTag='sim-20171127-vc-md100', - Simulation=True, - inputFileType='ROOT') -lines_to_run = [ - 'Hlt2CharmD0ToPimPimPipPipLine', 'Hlt2CharmD0ToKmPimPipPipLine', - 'Hlt2CharmD0ToKmKpPimPipLine', 'Hlt2CharmD0ToKmKmKpPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToPimPimPipPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKmPimPipPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKmKpPimPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKmKmKpPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKpPimPimPipLine', - 'Hlt2CharmDstpToD0Pip_D0ToKmKpKpPimLine' -] +options.evt_max = 100 +options.simulation = True +options.data_type = 'Upgrade' +options.dddb_tag = 'dddb-20171126' +options.conddb_tag = 'sim-20171127-vc-md100' -with FTRawBankDecoder.bind(DecodingVersion=ftdec_v), \ - require_gec.bind(make_raw = make_raw_data_for_gec_from_file, - FTDecodingVersion=ftdec_v), \ - raw_event_from_file.bind(raw_event_format=raw_event_format): - for name, builder in hlt2_line_builders(lines_to_run).items(): - env.registerLine(name, upfront_reconstruction() + builder()) +def make_lines(): + return [builder() for builder in all_lines.values()] -env.register_public_tool(stateProvider_with_simplified_geom()) -env.configure() +public_tools = [stateProvider_with_simplified_geom()] +run_moore(options, make_lines, public_tools) diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py index b347f1a03c5..a6c7bb69e56 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/algorithms.py @@ -25,7 +25,7 @@ from Configurables import (CombineParticles, FilterDesktop, DaVinci__N4BodyDecays as N4BodyDecays) from RecoConf.hlt1_tracking import EmptyFilter -from PyConf.components import make_algorithm, Algorithm +from PyConf.components import make_algorithm __all__ = [ 'EmptyFilter', diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py index 92fd7e7d45e..8e13d13f5f6 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/D02HHHH.py @@ -21,26 +21,29 @@ TODO(AP): More docs. from __future__ import absolute_import, division, print_function import math +from Moore.config import HltLine, register_line_builder + from GaudiKernel.SystemOfUnits import GeV, MeV, mm, mrad -from ..algorithms import require_all, ParticleCombinerWithPVs, ParticleFilterWithPVs, N4BodyCombinerWithPVs -from ..framework import configurable from RecoConf.hlt1_tracking import require_pvs, require_gec -from RecoConf.reco_objects_from_file import make_pvs +from RecoConf.reco_objects_from_file import (make_pvs, upfront_reconstruction) + +from ..algorithms import (require_all, ParticleCombinerWithPVs, + ParticleFilterWithPVs, N4BodyCombinerWithPVs) +from ..framework import configurable from ..standard_particles import (make_has_rich_long_pions as make_has_rich_pions, make_has_rich_long_kaons as make_has_rich_kaons) -from . import hlt2_line_builder # Charged pion mass in MeV _PION_M = 139.57061 * MeV # +/- 0.00024 +all_lines = {} + -# TODO(AP): implement shared decorator -# @shared @configurable -def make_selected_particles(make_particles=None, - make_pvs=None, +def make_selected_particles(make_particles, + make_pvs, trchi2dof_max=4, mipchi2_min=3.5, pt_min=250 * MeV, @@ -48,8 +51,6 @@ def make_selected_particles(make_particles=None, pid=None): # TODO(AP): this would be a whole lot nicer with f-strings (Python >= 3.6) # An alternative is to pass **locals() to format, but... ew - assert make_particles is not None, 'particles must be specified' - assert make_pvs is not None, 'PVs must be specified' code = require_all( 'PT > {pt_min}', 'TRGHOSTPROB < {trg_ghost_prob_max}', @@ -79,9 +80,9 @@ def make_charm_kaons(pid='PIDK < 0'): @configurable -def make_dzeros(particles=None, - descriptors=None, - make_pvs=None, +def make_dzeros(particles, + descriptors, + pvs, am_min=1730 * MeV, am_max=2000 * MeV, asumpt_min=1800 * MeV, @@ -90,12 +91,6 @@ def make_dzeros(particles=None, vchi2pdof_max=12, bpvvdchi2_min=25, acos_bpvdira_max=20 * mrad): - # TODO(AP): TypeError: Cannot decorate a function with positional arguments - # We want this function to be configurable, but there aren't aren't - # 'sensible' defaults for these args - assert particles is not None, 'particles must be specified' - assert descriptors is not None, 'descriptors must be specified' - assert make_pvs is not None, 'PVs must be specified' combination_code = require_all( "in_range({am_min}, AM, {am_max})", @@ -129,7 +124,7 @@ def make_dzeros(particles=None, return N4BodyCombinerWithPVs( particles=particles, - pvs=make_pvs(), + pvs=pvs, DecayDescriptors=descriptors, CombinationCut=combination_code, MotherCut=vertex_code, @@ -138,17 +133,13 @@ def make_dzeros(particles=None, @configurable -def make_dstars(dzeros=None, - soft_pions=None, - descriptors=None, - make_pvs=None, +def make_dstars(dzeros, + soft_pions, + descriptors, + pvs, max_comb_deltaM=190.0 * MeV, max_vtx_deltaM=170.0 * MeV, max_vtx_chi2_pdof=15.0): - assert dzeros is not None, 'dzeros must be specified' - assert soft_pions is not None, 'soft_pions must be specified' - assert descriptors is not None, 'descriptors must be specified' - assert make_pvs is not None, 'PVs must be specified' ## TODO: consider rewriting the delta M cuts as cuts on Q so there is ## no assumed order of the decay products in the decay descriptor. @@ -162,7 +153,7 @@ def make_dstars(dzeros=None, return ParticleCombinerWithPVs( particles=[dzeros, soft_pions], - pvs=make_pvs(), + pvs=pvs, DecayDescriptors=descriptors, CombinationCut=combination_code, MotherCut=vertex_code) @@ -179,7 +170,7 @@ def make_dzero2kpipipi_fordstar(): return make_dzeros( particles=[pions, kaons], descriptors=['[D0 -> K- pi- pi+ pi+]cc'], - make_pvs=make_pvs) + pvs=make_pvs()) @configurable @@ -189,11 +180,12 @@ def make_dzero2kkkpi_fordstar(): return make_dzeros( particles=[pions, kaons], descriptors=['[D0 -> K- K- K+ pi+]cc'], - make_pvs=make_pvs) + pvs=make_pvs()) -@hlt2_line_builder('Hlt2CharmD0ToPimPimPipPipLine') -def dzero2pipipipi_line(): +@register_line_builder(all_lines) +@configurable +def dzero2pipipipi_line(name='Hlt2CharmD0ToPimPimPipPipLine', prescale=0.1): """Line for D0 -> pi- pi- pi+ pi+ In principle, can use D0 candidates with selection criteria different from @@ -203,12 +195,17 @@ def dzero2pipipipi_line(): dzeros = make_dzeros( particles=[pions], descriptors=['D0 -> pi- pi- pi+ pi+'], - make_pvs=make_pvs) - return charm_prefilters() + [dzeros] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dzeros], + prescale=prescale, + ) -@hlt2_line_builder('Hlt2CharmD0ToKmPimPipPipLine') -def dzero2kpipipi_line(): +@register_line_builder(all_lines) +@configurable +def dzero2kpipipi_line(name='Hlt2CharmD0ToKmPimPipPipLine', prescale=0.1): """Line for D0 -> K- pi- pi+ pi+ + C.C. In principle, can use D0 candidates with selection criteria different from @@ -219,12 +216,17 @@ def dzero2kpipipi_line(): dzeros = make_dzeros( particles=[pions, kaons], descriptors=['[D0 -> K- pi- pi+ pi+]cc'], - make_pvs=make_pvs) - return charm_prefilters() + [dzeros] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dzeros], + prescale=prescale, + ) -@hlt2_line_builder('Hlt2CharmD0ToKmKpPimPipLine') -def dzero2kkpipi_line(): +@register_line_builder(all_lines) +@configurable +def dzero2kkpipi_line(name='Hlt2CharmD0ToKmKpPimPipLine', prescale=0.1): """Line for D0 -> K- K+ pi- pi+ In principle, can use D0 candidates with selection criteria different from @@ -235,12 +237,17 @@ def dzero2kkpipi_line(): dzeros = make_dzeros( particles=[pions, kaons], descriptors=['D0 -> K- K+ pi- pi+'], - make_pvs=make_pvs) - return charm_prefilters() + [dzeros] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dzeros], + prescale=prescale, + ) -@hlt2_line_builder('Hlt2CharmD0ToKmKmKpPipLine') -def dzero2kkkpi_line(): +@register_line_builder(all_lines) +@configurable +def dzero2kkkpi_line(name='Hlt2CharmD0ToKmKmKpPipLine', prescale=0.1): """Line for D0 -> K- K- K+ pi+ + C.C. In principle, can use D0 candidates with selection criteria different from @@ -251,12 +258,18 @@ def dzero2kkkpi_line(): dzeros = make_dzeros( particles=[pions, kaons], descriptors=['[D0 -> K- K- K+ pi+]cc'], - make_pvs=make_pvs) - return charm_prefilters() + [dzeros] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dzeros], + prescale=prescale, + ) -@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToPimPimPipPipLine') -def dstar2dzeropi_dzero2pipipipi_line(): +@register_line_builder(all_lines) +@configurable +def dstar2dzeropi_dzero2pipipipi_line( + name='Hlt2CharmDstpToD0Pip_D0ToPimPimPipPipLine', prescale=1): """Line for D*+ -> D0(-> pi- pi- pi+ pi+) pi+ + C.C. In order to avoid duplication of combinatorics of the charge-symmetric @@ -268,18 +281,24 @@ def dstar2dzeropi_dzero2pipipipi_line(): dzeros = make_dzeros( particles=[pions], descriptors=['D0 -> pi- pi- pi+ pi+'], - make_pvs=make_pvs) + pvs=make_pvs()) soft_pions = make_has_rich_pions() dstars = make_dstars( dzeros=dzeros, soft_pions=soft_pions, descriptors=['D*(2010)+ -> D0 pi+', 'D*(2010)- -> D0 pi-'], - make_pvs=make_pvs) - return charm_prefilters() + [dstars] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dstars], + prescale=prescale, + ) -@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKmPimPipPipLine') -def dstar2dzeropi_dzero2kpipipiRS_line(): +@register_line_builder(all_lines) +@configurable +def dstar2dzeropi_dzero2kpipipiRS_line( + name='Hlt2CharmDstpToD0Pip_D0ToKmPimPipPipLine', prescale=1): """Line for D*+ -> D0(-> K- pi- pi+ pi+) pi+ + C.C. """ dzeros = make_dzero2kpipipi_fordstar() @@ -288,12 +307,18 @@ def dstar2dzeropi_dzero2kpipipiRS_line(): dzeros=dzeros, soft_pions=soft_pions, descriptors=['[D*(2010)+ -> D0 pi+]cc'], - make_pvs=make_pvs) - return charm_prefilters() + [dstars] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dstars], + prescale=prescale, + ) -@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKmKpPimPipLine') -def dstar2dzeropi_dzero2kkpipi_line(): +@register_line_builder(all_lines) +@configurable +def dstar2dzeropi_dzero2kkpipi_line( + name='Hlt2CharmDstpToD0Pip_D0ToKmKpPimPipLine', prescale=1): """Line for D*+ -> D0(-> K- K+ pi- pi+) pi+ + C.C. In order to avoid duplication of combinatorics of the charge-symmetric @@ -307,18 +332,24 @@ def dstar2dzeropi_dzero2kkpipi_line(): dzeros = make_dzeros( particles=[pions, kaons], descriptors=['D0 -> K- K+ pi- pi+'], - make_pvs=make_pvs) + pvs=make_pvs()) soft_pions = make_has_rich_pions() dstars = make_dstars( dzeros=dzeros, soft_pions=soft_pions, descriptors=['D*(2010)+ -> D0 pi+', 'D*(2010)- -> D0 pi-'], - make_pvs=make_pvs) - return charm_prefilters() + [dstars] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dstars], + prescale=prescale, + ) -@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKmKmKpPipLine') -def dstar2dzeropi_dzero2kkkpiRS_line(): +@register_line_builder(all_lines) +@configurable +def dstar2dzeropi_dzero2kkkpiRS_line( + name='Hlt2CharmDstpToD0Pip_D0ToKmKmKpPipLine', prescale=1): """Line for D*+ -> D0(-> K- K- K+ pi+) pi+ + C.C. """ dzeros = make_dzero2kkkpi_fordstar() @@ -327,12 +358,18 @@ def dstar2dzeropi_dzero2kkkpiRS_line(): dzeros=dzeros, soft_pions=soft_pions, descriptors=['[D*(2010)+ -> D0 pi+]cc'], - make_pvs=make_pvs) - return charm_prefilters() + [dstars] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dstars], + prescale=prescale, + ) -@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKpPimPimPipLine') -def dstar2dzeropi_dzero2kpipipiWS_line(): +@register_line_builder(all_lines) +@configurable +def dstar2dzeropi_dzero2kpipipiWS_line( + name='Hlt2CharmDstpToD0Pip_D0ToKpPimPimPipLine', prescale=1): """Line for D*+ -> D0(-> K+ pi- pi- pi+) pi+ + C.C. In order to reuse the D0 combinatorics from @@ -347,12 +384,18 @@ def dstar2dzeropi_dzero2kpipipiWS_line(): dzeros=dzeros, soft_pions=soft_pions, descriptors=['[D*(2010)- -> D0 pi-]cc'], - make_pvs=make_pvs) - return charm_prefilters() + [dstars] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dstars], + prescale=prescale, + ) -@hlt2_line_builder('Hlt2CharmDstpToD0Pip_D0ToKmKpKpPimLine') -def dstar2dzeropi_dzero2kkkpiWS_line(): +@register_line_builder(all_lines) +@configurable +def dstar2dzeropi_dzero2kkkpiWS_line( + name='Hlt2CharmDstpToD0Pip_D0ToKmKpKpPimLine', prescale=1): """Line for D*+ -> D0(-> K- K+ K+ pi-) pi+ + C.C. In order to reuse the D0 combinatorics from @@ -367,5 +410,9 @@ def dstar2dzeropi_dzero2kkkpiWS_line(): dzeros=dzeros, soft_pions=soft_pions, descriptors=['[D*(2010)- -> D0 pi-]cc'], - make_pvs=make_pvs) - return charm_prefilters() + [dstars] + pvs=make_pvs()) + return HltLine( + name=name, + algs=upfront_reconstruction() + charm_prefilters() + [dstars], + prescale=prescale, + ) -- GitLab