Commit d51b912f authored by Olli Lupton's avatar Olli Lupton Committed by Rosen Matev
Browse files

Add a 2-track line using new combiner/functors

Squashed commit of the following:

commit b48c5585af67285b22d3697a8afcd1a389f49418
Author: Rosen Matev <rosen.matev@cern.ch>
Date:   Tue Jul 30 16:58:24 2019 +0200

    Fix CMake warning

commit 956d3b37384ffa2ee846fc93701553e0c5322bba
Author: Rosen Matev <rosen.matev@cern.ch>
Date:   Tue Jul 30 16:58:12 2019 +0200

    Rename HltCache package

commit c1b7f7bb5ec91b44e35463d37e8f13d2c95b67c1
Author: Rosen Matev <rosen.matev@cern.ch>
Date:   Tue Jul 30 15:45:46 2019 +0200

    Show how to set path of root file dump

commit 15c7d716a514e43baf4a8e47ed292bfa732ad449
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Mon Jul 29 13:27:54 2019 +0200

    Implement @graven's suggections.

commit ad53a36864262abdd1b06e24b1407258d2048cb2
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Fri Jul 26 16:23:55 2019 +0200

    Add comments.

commit 337134c0492479083f140383f1d273439e1b5bfa
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Fri Jul 26 15:37:16 2019 +0200

    Remove LoKi-based lines.

commit 672961e6fc13b6c30b472b5828fb78aa9bec71fb
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Fri Jul 26 15:24:54 2019 +0200

    Tweak new two track cuts.

commit b20ac7fcaf65dae199bc05f5bc35269b62f88830
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Fri Jul 26 14:34:06 2019 +0200

    Implement the TrackMVA line using new functors.

commit f2302cd6fbc3230ac3e1b498f740fab47e9db1df
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Thu Jul 25 14:44:24 2019 +0200

    Dump some more things.

commit faf9acfd5dec087f7cc8e1627936addaa0668872
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Wed Jul 17 16:10:44 2019 +0200

    Decode ODIN so my dumper can save the run/event number.

commit 089939c768eef650794e48e151fab9f3bfcbaba5
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Tue Jul 16 11:44:45 2019 +0200

    Add some more branches.

commit 23055bd49097fe061b4b9c000f0a59e595b952b8
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Mon Jul 15 13:43:03 2019 +0200

    Add example options that dump 2-track combination info.

commit 017ce8fb01c6b97695d5963f5356b7d1d3162f5d
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Mon Jul 15 13:03:15 2019 +0200

    Follow naming changes and support the tupling version of CombineTracks.

commit fde1762b39f45c2ea1ec4cc60dd0db44634b6eaf
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Fri Jul 12 09:57:32 2019 +0200

    Use v2::Track in the new two track line.

commit 43a71c54fa5202aebc4c79ff535779c6b01a998f
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Tue Jul 9 15:47:19 2019 +0200

    Use a new-functor-based void filter.

commit 869a25c82056593a8cebbecce9cde89c4ababee4
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Tue Jul 9 15:46:54 2019 +0200

    Add a Moore functor cache.

commit d5e698044ff36111b6c95460548cdcc79d9480b1
Author: Olli Lupton <oliver.lupton@cern.ch>
Date:   Thu Jul 4 17:04:32 2019 +0200

    Implement another two track "MVA" using the new functors.
parent 235add5f
......@@ -8,7 +8,8 @@
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
CMAKE_MINIMUM_REQUIRED(VERSION 3.14)
project(Moore LANGUAGES CXX)
#---------------------------------------------------------------
# Load macros and functions for Gaudi-based projects
......
###############################################################################
# (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. #
###############################################################################
from __future__ import absolute_import, division, print_function
from PyConf import configurable
from Hlt1Conf.lines import (
CombineTracks,
PrFilterV2Tracks,
)
from Hlt1Conf.reconstruction import (
gec, make_odin, FilterEmptyPVs, make_pvs, EmptyFilter,
make_param_forward_fitted_tracks_v2_selection)
from PyConf.Algorithms import FTRawBankDecoder
from PyConf.environment import EverythingHandler
def new_two_track_MVA(
make_odin=make_odin,
make_input_tracks=make_param_forward_fitted_tracks_v2_selection,
make_pvs=make_pvs,
VertexCut=None,
ChildCut=None,
CombinationCut=None,
VoidDump=None,
ChildDump=None,
CombinationDump=None,
VertexDump=None):
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
pv_loc, odin_loc = make_pvs().location, make_odin().location
if VoidDump is None:
VoidDump = {
'runNumber': RUNNUMBER(odin_loc),
'eventType': EVENTTYPE(odin_loc),
'eventNumber': EVENTNUMBER(odin_loc),
}
if ChildCut is None:
ChildCut = (PT > 250. * MeV)
if ChildDump is None:
ChildDump = {
'P': P,
'PT': PT,
'ETA': ETA,
'PHI': PHI,
'IP': MINIP(pv_loc),
'IPCHI2': BPVIPCHI2(pv_loc),
'CHI2DOF': CHI2DOF,
}
if VertexCut is None:
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),
}
if CombinationCut is None:
CombinationCut = ALL
if CombinationDump is None:
CombinationDump = {
'PT': PT,
'DOCA': DOCA,
'SUMPT': SUM(PT),
'DOCACHI2': DOCACHI2,
}
children = PrFilterV2Tracks(
Functor=ChildCut, Input=make_input_tracks()).Output
return CombineTracks(
NBodies=2,
VertexCut=VertexCut,
InputTracks=children,
CombinationCut=CombinationCut,
VoidDump=VoidDump,
ChildDump=ChildDump,
CombinationDump=CombinationDump,
VertexDump=VertexDump,
DumpFileName='PrCombineTracks.root').OutputVerticesStorage
ftdec_v = 4
with FTRawBankDecoder.bind(DecodingVersion=ftdec_v):
gec = gec(FTDecodingVersion=ftdec_v)
NoPVFilter = FilterEmptyPVs()
new_two_track = new_two_track_MVA()
env = EverythingHandler(threadPoolSize=1, nEventSlots=1, evtMax=5000)
env.registerLine(
'two_track', algs=[gec, NoPVFilter,
make_odin(), new_two_track])
env.setupInputFromTestFileDB('MiniBrunel_2018_MinBias_FTv4_DIGI')
env.configure()
###############################################################################
# (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. #
###############################################################################
from __future__ import absolute_import, division, print_function
import math
from GaudiKernel.SystemOfUnits import GeV
from PyConf import configurable
from Hlt1Conf.lines import (CombineTracks, PrFilterV2Tracks)
from RecoConf.hlt1_tracking import (require_gec, require_pvs, make_pvs,
make_hlt1_tracks,
make_velokalman_fitted_tracks)
from PyConf.Algorithms import FTRawBankDecoder
from PyConf.environment import EverythingHandler
def make_tracks_for_mva_lines():
return make_velokalman_fitted_tracks(make_hlt1_tracks())
@configurable
def one_track_MVA(
make_input_tracks=make_tracks_for_mva_lines,
make_pvs=make_pvs,
# TrackMVALoose cuts from ZombieMoore
max_chi2dof=2.5,
min_pt=2.0 * GeV,
max_pt=26 * GeV,
min_ipchi2=7.4,
param1=1.0,
param2=2.0,
param3=1.248):
pvs = make_pvs().location
from Functors import PT, CHI2DOF, MINIPCHI2, MINIPCHI2CUT
from Functors.math import in_range, log
pre_sel = (CHI2DOF < max_chi2dof)
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) +
(param3 / max_pt) * (max_pt - PT) + math.log(min_ipchi2)))
full_sel = pre_sel & (hard_sel | bulk_sel)
return PrFilterV2Tracks(
full_sel, Input=make_input_tracks()['v2Sel']).Output
def two_track_MVA(make_input_tracks=make_tracks_for_mva_lines,
make_pvs=make_pvs,
VertexCut=None,
ChildCut=None,
CombinationCut=None):
# 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
pvs = make_pvs().location
if ChildCut is None:
ChildCut = (PT > 800. * MeV) & (P > 5. * GeV) & (
CHI2DOF < 2.5) & MINIPCHI2CUT(
IPChi2Cut=4., Vertices=pvs)
if CombinationCut is None:
CombinationCut = (PT > 2. * GeV) & (DOCACHI2 < 10.)
if VertexCut is None:
VertexCut = (CHI2DOF < 10.) & (BPVDIRA(pvs) > 0)
children = PrFilterV2Tracks(
ChildCut, Input=make_input_tracks()['v2Sel']).Output
return CombineTracks(
NBodies=2,
VertexCut=VertexCut,
InputTracks=children,
CombinationCut=CombinationCut).OutputVerticesStorage
ftdec_v = 4
with FTRawBankDecoder.bind(DecodingVersion=ftdec_v):
gec = require_gec(FTDecodingVersion=ftdec_v)
NoPVFilter = require_pvs(make_pvs())
one_track = one_track_MVA()
two_track = two_track_MVA()
env = EverythingHandler(
threadPoolSize=1, nEventSlots=1, evtMax=1000, debug=True)
env.registerLine('one_track_mva', algs=[gec, NoPVFilter, one_track])
env.registerLine('two_track_mva', algs=[gec, NoPVFilter, two_track])
env.setupInputFromTestFileDB('MiniBrunel_2018_MinBias_FTv4_DIGI')
env.configure()
# env.plotDataFlow()
......@@ -12,7 +12,10 @@ from __future__ import absolute_import, division, print_function
from PyConf import configurable
from Configurables import (
PrFilter__Track_v1,
PrFilter__Track_v2,
TrackCombiner,
CombineTracks__2Body__Track_v2,
CombineTracks__2Body__Track_v2__Dumper,
)
from PyConf.components import Algorithm
......@@ -69,3 +72,48 @@ def TrackCombinerWithPVs(Preamble=[], **kwargs):
}
return Algorithm(TrackCombiner, input_transform=transform_inputs, **kwargs)
@configurable
def PrFilterV2Tracks(functor, **kwargs):
return Algorithm(
PrFilter__Track_v2,
Code=functor.code(),
Headers=functor.headers(),
Factory='FunctorFactory',
**kwargs)
@configurable
def CombineTracks(NBodies=2,
CombinationCut=None,
VertexCut=None,
VoidDump=None,
ChildDump=None,
CombinationDump=None,
VertexDump=None,
**kwargs):
assert NBodies == 2
def parse(input_dict):
if input_dict is None: return {}
return {k: [v.code()] + v.headers() for k, v in input_dict.items()}
VoidDump_dict = parse(VoidDump)
ChildDump_dict = parse(ChildDump)
CombinationDump_dict = parse(CombinationDump)
VertexDump_dict = parse(VertexDump)
enable_dumper = len(ChildDump_dict) or len(CombinationDump_dict) or len(
VertexDump_dict)
return Algorithm(
CombineTracks__2Body__Track_v2__Dumper
if enable_dumper else CombineTracks__2Body__Track_v2,
VertexCut_Code=VertexCut.code(),
VertexCut_Headers=VertexCut.headers(),
CombinationCut_Code=CombinationCut.code(),
CombinationCut_Headers=CombinationCut.headers(),
VoidDump_Functors=VoidDump_dict,
ChildDump_Functors=ChildDump_dict,
CombinationDump_Functors=CombinationDump_dict,
VertexDump_Functors=VertexDump_dict,
**kwargs)
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<!--
(c) Copyright 2000-2018 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.
-->
<!--
Make sure HLT1 configures and runs without errors on raw data
-->
<extension class="GaudiTest.GaudiExeTest" kind="test">
<argument name="program"><text>gaudirun.py</text></argument>
<argument name="args"><set>
<text>$HLT1CONFROOT/options/hlt1_example.py</text>
<text>--output=hlt1_example.opts.py</text>
<text>--all-opt</text>
</set></argument>
<argument name="options"><text>
from Configurables import HiveDataBrokerSvc
HiveDataBrokerSvc().OutputLevel = 5
</text></argument>
<argument name="use_temp_dir"><enumeral>true</enumeral></argument>
<argument name="validator"><text>
countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0})
# test that at least one event fires
import re
m = re.search('NONLAZY_OR: hlt_decision .*Sum=(\d+)', stdout)
if m:
result['hlt_decision_sum'] = result.Quote(m.group(1))
if int(m.group(1)) &lt; 1:
causes.append('no positive decisions found')
else:
causes.append('hlt_decision counter not found')
</text></argument>
</extension>
......@@ -19,7 +19,7 @@ from Configurables import (
Gaudi__Hive__FetchDataFromFile,
PrGECFilter,
PrStoreUTHit,
LoKi__VoidFilter,
VoidFilter,
PrVeloUT,
ParameterizedKalmanFit,
)
......@@ -27,6 +27,7 @@ from Configurables import (
# all trivial (not changing default) and fully datahandly imports can be done from here
from PyConf.Algorithms import (
MakeSelection__Track_v1 as TrackV1Selection,
MakeSelection__Track_v2 as TrackV2Selection,
LHCb__Converters__Track__v1__fromV2TrackV1TrackVector as
FromV2TrackV1TrackVector,
LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track,
......@@ -41,6 +42,7 @@ from PyConf.Algorithms import (
TrackBeamLineVertexFinderSoA,
SciFiTrackForwardingStoreHit,
VeloKalman,
createODIN,
)
from GaudiKernel.SystemOfUnits import mm, MeV
......@@ -63,18 +65,24 @@ VeloUTTracking = make_algorithm(PrVeloUT, defaults=dict(minPT=300 * MeV))
def __emptyfilter_input_transform(InputLocation):
return {"Code": "SIZE('{}')>0".format(InputLocation)}
from Functors import SIZE
fun = SIZE(InputLocation) > 0
return {"Code": fun.code(), "Headers": fun.headers()}
EmptyFilter = make_algorithm(
LoKi__VoidFilter, input_transform=__emptyfilter_input_transform)
VoidFilter, input_transform=__emptyfilter_input_transform)
def make_raw_data():
return RawData().RawEvent
# maker functions
@configurable
def make_odin(make_raw_data=make_raw_data):
return createODIN(RawEvent=make_raw_data).ODIN
@configurable
def require_gec(make_raw=make_raw_data, FTDecodingVersion=None, **kwargs):
# TODO use FTDecodingVersion=smart.REQUIRED above
......@@ -224,11 +232,13 @@ def make_velokalman_fitted_tracks(tracks, make_hits=make_velo_hits):
fitted_tracks_v1_sel = TrackV1Selection(
Input=FromV2TrackV1TrackVector(
InputTracksName=fitted_tracks_v2).OutputTracksName)
fitted_tracks_v2_sel = TrackV2Selection(Input=fitted_tracks_v2).Output
return {
"Pr": fitted_tracks,
"v2": fitted_tracks_v2,
"v1": fitted_tracks_v1,
"v1Sel": fitted_tracks_v1_sel
"v1Sel": fitted_tracks_v1_sel,
"v2Sel": fitted_tracks_v2_sel,
}
......
###############################################################################
# (c) Copyright 2000-2018 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. #
###############################################################################
gaudi_subdir(MooreCache)
gaudi_depends_on_subdirs(Hlt/Hlt1Conf
Phys/FunctorCore)
# Suppress compilation warnings from external packages
find_package(Boost)
find_package(ROOT)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS})
# Import the cache creation module
include(LoKiFunctorsCache)
# Allow build in satellite (lb-dev) projects
if(TARGET MooreConfUserDB)
set(conf_deps DEPENDS MooreConfUserDB)
endif()
# Additional factories for Upgrade
loki_functors_cache(Moore_FunctorCache
${Moore_SOURCE_DIR}/Hlt/Hlt1Conf/options/hlt1_example.py
options/DisableLoKiCacheFunctors.py
FACTORIES FunctorFactory
LINK_LIBRARIES FunctorCoreLib
${conf_deps}
SPLIT 1)
###############################################################################
# (c) Copyright 2000-2018 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. #
###############################################################################
from Configurables import ApplicationMgr
ApplicationMgr().Environment['LOKI_DISABLE_CACHE'] = '1'
ApplicationMgr().Environment['LOKI_DISABLE_CLING'] = '1'
......@@ -246,6 +246,7 @@ class EverythingHandler(object):
configuration.update(tool.configuration())
# FIXME we make the configurables accessible to be able to hack the ugly things
odin_loc = '/Event/DAQ/DummyODIN'
self.configurable_algs, self.configurable_tools = configuration.apply()
self.configurable_algs += [
setup_component(
......@@ -253,8 +254,10 @@ class EverythingHandler(object):
"DummyEventTime",
Start=self._eventClockSvc.InitialTime / 1E9,
Step=0,
ODIN=odin_loc,
IOVLockDep=False),
setup_component(reserveIOV, "reserveIOV", IOVLockDep=False)
setup_component(
reserveIOV, "reserveIOV", IOVLockDep=False, ODIN=odin_loc)
]
self._hiveDataBroker.DataProducers = self.configurable_algs
self._scheduler.CompositeCFNodes = [
......
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