Commit bad2f141 authored by Olli Lupton's avatar Olli Lupton
Browse files

Replicate ZombieMoore TwoTrackMVA and remove converters.

parent 56e3ae37
......@@ -15,8 +15,9 @@ from PyConf import configurable
from RecoConf.hlt1_tracking import (require_gec, require_pvs, make_pvs,
make_odin, make_hlt1_tracks,
make_velokalman_fitted_tracks)
from ..algorithms import CombineTracks, PrFilterV2Tracks
from PyConf.Algorithms import FTRawBankDecoder
from ..algorithms import (CombineTracks, PrFilterV2Tracks,
FilterPrFittedForwardTracks)
from PyConf.Algorithms import (FTRawBankDecoder, MakeIterableTracks)
def make_tracks_mva_tracks():
......@@ -47,33 +48,59 @@ def one_track_mva_line(
hard_sel = (PT > max_pt) & MINIPCHI2CUT(IPChi2Cut=min_ipchi2, Vertices=pvs)
bulk_sel = in_range(min_pt, PT, max_pt) & (
log(MINIPCHI2(pvs)) >
(param1 / ((PT / GeV - param2)**2) +
(param1 / ((PT / GeV - param2) * (PT / GeV - param2)) +
(param3 / max_pt) * (max_pt - PT) + math.log(min_ipchi2)))
full_sel = pre_sel & (hard_sel | bulk_sel)
track_filter = PrFilterV2Tracks(
full_sel, Input=make_input_tracks()['v2Sel'])
track_filter = FilterPrFittedForwardTracks(
full_sel, Input=make_input_tracks()['Pr'])
return track_mva_prefilters() + [track_filter]
@configurable
def two_track_mva_line(make_input_tracks=make_tracks_mva_tracks,
make_pvs=make_pvs):
# Compared to TwoTrackMVALoose in ZombieMoore this is missing:
# in_range( 2, BPVETA, 5 )
# BPVCORRM > 1. * GeV
# (ignoring a very loose upper cut on BPVCORRM)
# and, of course, the actual MVA....
from Functors import P, PT, CHI2DOF, DOCACHI2, BPVDIRA, MINIPCHI2CUT
from GaudiKernel.SystemOfUnits import MeV
# This corresponds to TwoTrackMVALoose in ZombieMoore
from Functors.math import in_range
from Functors import (P, PT, CHI2DOF, DOCACHI2, BPVDIRA, MINIPCHI2CUT, MVA,
COMB, SUM, BPVIPCHI2, BPVFDCHI2, BPVETA, BPVCORRM)
from GaudiKernel.SystemOfUnits import MeV, GeV
pvs = make_pvs().location
ChildCut = ((PT > 800. * MeV) & (P > 5. * GeV) &
(CHI2DOF < 2.5) & MINIPCHI2CUT(IPChi2Cut=4., Vertices=pvs))
pr_children = FilterPrFittedForwardTracks(
ChildCut, Input=make_input_tracks()['Pr']).Output
children = MakeIterableTracks(Input=pr_children).Output
CombinationCut = (PT > 2. * GeV) & (DOCACHI2 < 10.)
VertexCut = (CHI2DOF < 10.) & (BPVDIRA(pvs) > 0)
children = PrFilterV2Tracks(
ChildCut, Input=make_input_tracks()['v2Sel']).Output
def apply_to_combination(functor):
"""Helper for applying 'Combination' cuts to a composite."""
return COMB(
Functor=functor,
ChildContainers=[children.location],
ChildContainerTypes=[
('LHCb::Pr::Iterable::Fitted::Forward::Tracks',
'Event/PrIterableTracks.h')
])
# TODO there seems to be some magic that substitutes the value of
# $PARAMFILESROOT before it gets to the C++. This is probably not what
# we want -- better to resolve it at runtime than bake a value into
# the functor cache, for example
VertexCut = ((CHI2DOF < 10.) & (BPVDIRA(pvs) > 0) & (
BPVCORRM(Mass=139.57018 * MeV, Vertices=pvs) > 1. * GeV
) & in_range(2., BPVETA(pvs), 5.) & (MVA(
MVAType='MatrixNet',
Config={'MatrixnetFile': "${PARAMFILESROOT}/data/Hlt1TwoTrackMVA.mx"},
Inputs={
'chi2': CHI2DOF,
'fdchi2': BPVFDCHI2(pvs),
'sumpt': apply_to_combination(SUM(PT)),
'nlt16': apply_to_combination(SUM(BPVIPCHI2(pvs) < 16.)),
}) > 0.96))
combination_filter = CombineTracks(
NBodies=2,
PrTracks=True,
VertexCut=VertexCut,
InputTracks=children,
CombinationCut=CombinationCut)
......@@ -94,8 +121,8 @@ def debug_two_track_mva_line(make_input_tracks=make_tracks_mva_tracks,
from Functors import (ALL, ETA, P, PT, CHI2DOF, SUM, DOCA, DOCACHI2,
BPVDIRA, BPVIPCHI2, MINIP, PHI, RUNNUMBER,
EVENTNUMBER, EVENTTYPE, BPVIPCHI2STATE)
from GaudiKernel.SystemOfUnits import MeV, GeV, mm, mrad
EVENTNUMBER, EVENTTYPE, BPVIPCHI2STATE, COMB)
from GaudiKernel.SystemOfUnits import MeV
pv_loc, odin_loc = make_pvs().location, make_odin().location
if VoidDump is None:
VoidDump = {
......@@ -105,6 +132,8 @@ def debug_two_track_mva_line(make_input_tracks=make_tracks_mva_tracks,
}
if ChildCut is None:
ChildCut = (PT > 250. * MeV)
children = PrFilterV2Tracks(
ChildCut, Input=make_input_tracks()['v2Sel']).Output
if ChildDump is None:
ChildDump = {
'P': P,
......@@ -119,13 +148,26 @@ def debug_two_track_mva_line(make_input_tracks=make_tracks_mva_tracks,
VertexCut = (CHI2DOF < 1e3)
if VertexDump is None:
VertexDump = {
'PT': PT,
'ETA': ETA,
'PHI': PHI,
'CHI2DOF': CHI2DOF,
'DIRA': BPVDIRA(pv_loc),
'IPCHI2': BPVIPCHI2(pv_loc),
'IPCHI2_STATE': BPVIPCHI2STATE(pv_loc),
'PT':
PT,
'ETA':
ETA,
'PHI':
PHI,
'CHI2DOF':
CHI2DOF,
'DIRA':
BPVDIRA(pv_loc),
'IPCHI2':
BPVIPCHI2(pv_loc),
'IPCHI2_STATE':
BPVIPCHI2STATE(pv_loc),
'SUMPT':
COMB(
Functor=SUM(PT),
ChildContainers=[children.location],
ChildContainerTypes=[('Pr::Selection<LHCb::Event::v2::Track>',
'PrKernel/PrSelection.h')]),
}
if CombinationCut is None:
CombinationCut = ALL
......@@ -136,8 +178,6 @@ def debug_two_track_mva_line(make_input_tracks=make_tracks_mva_tracks,
'SUMPT': SUM(PT),
'DOCACHI2': DOCACHI2,
}
children = PrFilterV2Tracks(
ChildCut, Input=make_input_tracks()['v2Sel']).Output
combiner = CombineTracks(
NBodies=2,
VertexCut=VertexCut,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment