diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/reconstruction.py b/Hlt/Hlt1Conf/python/Hlt1Conf/reconstruction.py index 3ff4f9b477ae3e704b09db3d3d2d5d5f53056485..4773aa4129f2189c660a83620f4b4c35dcfe236f 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/reconstruction.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/reconstruction.py @@ -143,7 +143,7 @@ def make_keyed_velo_tracks(make_velo_tracks=make_velo_tracks): @configurable def make_pvs(make_velo_tracks=make_velo_tracks, needConvertedTracks = False): tracks = make_velo_tracks(convertToSelection = needConvertedTracks) - return PVFinding(InputTracks = tracks, name = "WURST").OutputVerticesName + return PVFinding(InputTracks = tracks, name = "PVFinding").OutputVerticesName @configurable def make_V1_pvs(make_keyed_velo_tracks=make_keyed_velo_tracks, make_pvs=make_pvs): diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/data_from_file.py b/Hlt/Hlt2Conf/python/Hlt2Conf/data_from_file.py index b3ba367893b6dee241012f40410b91ccddbe3b82..ef59ebcc4c7a68c98364dc329fbc69d01f880685 100644 --- a/Hlt/Hlt2Conf/python/Hlt2Conf/data_from_file.py +++ b/Hlt/Hlt2Conf/python/Hlt2Conf/data_from_file.py @@ -46,8 +46,11 @@ from Configurables import ( UnpackCaloHypo, UnpackProtoParticle, UnpackRecVertex, - UnpackTrackFunctional + UnpackTrackFunctional, + UnpackMCParticle, + UnpackMCVertex ) + from RawEventFormat import Raw_location_db from PyConf.core import Algorithm, force_location @@ -67,12 +70,18 @@ def packed_data_from_file(): 'PackedTracks': '/Event/pRec/Track/Best', 'PackedMuonTracks': '/Event/pRec/Track/Muon', 'PackedNeutralProtos': '/Event/pRec/ProtoP/Neutrals', - 'PackedChargedProtos': '/Event/pRec/ProtoP/Charged' + 'PackedChargedProtos': '/Event/pRec/ProtoP/Charged', + 'PackedMCParticles' : '/Event/pSim/MCParticles', + 'PackedMCVertices' : '/Event/pSim/MCVertices' } def unpacked_locations(): - return {k: v.replace('pRec', 'Rec') for k, v in packed_data_from_file().items()} + locations = {k: v.replace('pRec', 'Rec') for k, v in packed_data_from_file().items()} + # If the structure is not like this, pointers point to to the wrong place... + locations.update({'PackedMCParticles': "/Event/MC/Particles" }) + locations.update({'PackedMCVertices': "/Event/MC/Vertices" }) + return locations @configurable @@ -136,7 +145,9 @@ def unpackers(): ('Tracks', unpacker('PackedTracks', UnpackTrackFunctional, 'UnpackBestTracks')), ('MuonTracks', unpacker('PackedMuonTracks', UnpackTrackFunctional, 'UnpackMuonTracks')), ('NeutralProtos', unpacker('PackedNeutralProtos', UnpackProtoParticle, 'UnpackNeutralProtos')), - ('ChargedProtos', unpacker('PackedChargedProtos', UnpackProtoParticle, 'UnpackChargedProtos')) + ('ChargedProtos', unpacker('PackedChargedProtos', UnpackProtoParticle, 'UnpackChargedProtos')), + ('MCParticles', unpacker('PackedMCParticles', UnpackMCParticle, 'UnpackMCParticles')), + ('MCVertices', unpacker('PackedMCVertices', UnpackMCVertex, 'UnpackMCVertices')) ]) # Make sure we have consistent names, and that we're unpacking everything diff --git a/Hlt/RecoConf/CMakeLists.txt b/Hlt/RecoConf/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..969c7433c7a888c540fa65d7efdfca804f662098 --- /dev/null +++ b/Hlt/RecoConf/CMakeLists.txt @@ -0,0 +1,19 @@ +############################################################################### +# (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. # +############################################################################### +find_package(pytools) + +gaudi_install_python_modules() +gaudi_install_scripts() + +gaudi_add_test(pytests + COMMAND python -m pytest -v --doctest-modules + ${CMAKE_CURRENT_SOURCE_DIR}/python) +gaudi_add_test(QMTest QMTEST) diff --git a/Hlt/RecoConf/options/reco_example.py b/Hlt/RecoConf/options/reco_example.py new file mode 100644 index 0000000000000000000000000000000000000000..1ea31fb6fefef88d1798ec5ddd77ed3748a4ccc7 --- /dev/null +++ b/Hlt/RecoConf/options/reco_example.py @@ -0,0 +1,94 @@ +############################################################################### +# (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 PyConf.smart import ( + configurable, +) +from Hlt1Conf.lines import ( + require_all, + require_any, + TrackV1FilterWithPVs, + TrackCombinerWithPVs, +) + +from Hlt1Conf.reconstruction import ( + gec, + RawData, + FilterEmptyPVs, + FTDecoding, + make_forward_tracks, + make_param_forward_fitted_tracks, + make_pvs, + EmptyFilter +) + +from Hlt2Conf.data_from_file import ( + unpackers +) + +from RecoConf.mcchecking import ( + make_velo_full_clusters, + make_links_veloclusters_mcparticles, + make_links_lhcbids_mcparticles, + make_links_tracks_mcparticles, + make_efficiency_checks +) + + +from PyConf.core import ( + Algorithm, + EverythingHandler, +) + +def patch_hybrid_tool(): + """Remove Hybrid modules that require a DVAlgorithm. + + Some modules import functors that depend on the DVAlgorithm context being + available. The LoKi::Hybrid::Tool tool loads these modules by default, but + we don't want nor need them, so remove them from the default list. + """ + # List of modules we will delete from the default list + dv_modules = [ + "LoKiPhys.decorators", + "LoKiArrayFunctors.decorators" + ] + + from Configurables import LoKi__Hybrid__Tool + factory = LoKi__Hybrid__Tool("HybridFactory") + for m in dv_modules: + del factory.Modules[factory.Modules.index(m)] + # Add the Track functors as we'll need most of these + # It can be important to include this in the Modules, otherwise the functor + # context patching might not be applied in time (e.g. if a Track functor is + # imported and instantiated in the preamble) + factory.Modules.append('LoKiTrack.decorators') + + + +ftdec_v = 4 +with FTDecoding.bind(DecodingVersion = ftdec_v): + + gec = gec(FTDecodingVersion=ftdec_v) + + NoPVFilter = FilterEmptyPVs() + + env = EverythingHandler(threadPoolSize = 1, nEventSlots = 1, evtMax = 100, debug=True, HistoFile = "test.root") + env.registerLine('Reconstruction', algs = [gec, make_pvs(), make_forward_tracks(), + make_velo_full_clusters(), make_links_lhcbids_mcparticles(), + make_links_tracks_mcparticles(), + make_efficiency_checks()]) + env.setupInputFromTestFileDB('MiniBrunel_2018_MinBias_FTv4_DIGI') + env.configureAllTheFlows() + #env.plotDataFlow() + + patch_hybrid_tool() diff --git a/Hlt/RecoConf/python/RecoConf/__init.py__ b/Hlt/RecoConf/python/RecoConf/__init.py__ new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Hlt/RecoConf/python/RecoConf/__init__.py b/Hlt/RecoConf/python/RecoConf/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Hlt/RecoConf/python/RecoConf/mcchecking.py b/Hlt/RecoConf/python/RecoConf/mcchecking.py new file mode 100644 index 0000000000000000000000000000000000000000..68c36cc75d789bf7b2a8964a4e036d9b9d0a111e --- /dev/null +++ b/Hlt/RecoConf/python/RecoConf/mcchecking.py @@ -0,0 +1,94 @@ +############################################################################### +# (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.smart import ( + configurable +) + +from PyConf.core import ( + Algorithm, + force_location, + Tool +) + + +from PyConf.Algorithms import (VPClusFull, + VPFullCluster2MCParticleLinker, + PrLHCbID2MCParticle, + PrTrackAssociator, + PrTrackChecker) + +from Hlt1Conf.reconstruction import( + RawData, + make_UT_clusters, + make_ft_clusters, + make_forward_tracks, + fromV2TrackV1Track +) + +from Hlt2Conf.data_from_file import ( + unpackers, + make_data_from_file +) + +from RecoConf.mccuts import getMCCuts + +@configurable +def make_velo_full_clusters(): + return VPClusFull(RawEventLocation=RawData().RawEvent).ClusterLocation + + +@configurable +def make_links_veloclusters_mcparticles(): + return VPFullCluster2MCParticleLinker(ClusterLocation=make_velo_full_clusters(), + MCParticlesLocation=unpackers()["MCParticles"], + VPDigit2MCParticleLinksLocation=make_data_from_file("/Event/Link/Raw/VP/Digits")).OutputLocation + +@configurable +def make_links_lhcbids_mcparticles(): + return PrLHCbID2MCParticle(MCParticlesLocation = unpackers()["MCParticles"], + VPFullClustersLocation = make_velo_full_clusters(), + VPFullClustersLinkLocation = make_links_veloclusters_mcparticles(), + UTHitsLocation = make_UT_clusters(), + UTHitsLinkLocation = make_data_from_file('/Event/Link/Raw/UT/Clusters'), + FTLiteClustersLocation = make_FT_clusters(), + FTLiteClustersLinkLocation = make_data_from_file('/Event/Link/Raw/FT/LiteClusters')).TargetName + +@configurable +def make_converted_to_track_v1(InputTracks=make_forward_tracks): + return fromV2TrackV1Track(InputTracksName=InputTracks()).OutputTracksName + +@configurable +def make_links_tracks_mcparticles(InputTracks = make_converted_to_track_v1, + LinkerLocationID = make_links_lhcbids_mcparticles): + return PrTrackAssociator(SingleContainer=InputTracks(), + LinkerLocationID = LinkerLocationID(), + MCParticleLocation = unpackers()["MCParticles"]).OutputLocation + +@configurable +def make_efficiency_checks(InputTracks=make_converted_to_track_v1, + Links = make_links_tracks_mcparticles, + TrackType = "Forward"): + props = dict(Title=TrackType, + HitTypesToCheck=8, + WriteHistos=1, + MyCuts=getMCCuts(TrackType)) + from Configurables import LoKi__Hybrid__MCTool + myFactory = Tool(LoKi__Hybrid__MCTool, Modules = [ "LoKiMC.decorators" ]) + + return PrTrackChecker(Tracks = InputTracks(), + Links = Links(), + MCParticleInput = unpackers()["MCParticles"], + MCVerticesInput = unpackers()["MCVertices"], + LinkTableLocation = make_links_lhcbids_mcparticles(), + MCPropertyInput = make_data_from_file("/Event/MC/TrackInfo"), + LoKiFactory = myFactory, + **props) diff --git a/Hlt/RecoConf/python/RecoConf/mccuts.py b/Hlt/RecoConf/python/RecoConf/mccuts.py new file mode 100644 index 0000000000000000000000000000000000000000..76aea57e7b7d0cf0bfcc748874d637180e7e5da7 --- /dev/null +++ b/Hlt/RecoConf/python/RecoConf/mccuts.py @@ -0,0 +1,101 @@ +############################################################################### +# (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 GaudiKernel.SystemOfUnits import mm, GeV +MCCuts = { + "Velo" : { "01_velo" : "isVelo", + "02_long" : "isLong", + "03_long>5GeV" : "isLong & over5", + "04_long_strange" : "isLong & strange", + "05_long_strange>5GeV" : "isLong & strange & over5", + "06_long_fromB" : "isLong & fromB", + "07_long_fromB>5GeV" : "isLong & fromB & over5", + "08_long_electrons" : "isLong & isElectron", + "09_long_fromB_electrons" : "isLong & isElectron & fromB", + "10_long_fromB_electrons_P>5GeV" : "isLong & isElectron & over5 & fromB" }, + "Forward" : { "01_long" : "isLong", + "02_long>5GeV" : "isLong & over5", + "03_long_strange" : "isLong & strange", + "04_long_strange>5GeV" : "isLong & strange & over5", + "05_long_fromB" : "isLong & fromB", + "06_long_fromB>5GeV" : "isLong & fromB & over5", + "07_long_electrons" : "isLong & isElectron", + "08_long_fromB_electrons" : "isLong & isElectron & fromB", + "09_long_fromB_electrons_P>5GeV" : "isLong & isElectron & over5 & fromB" }, + "Up" : { "01_velo" : "isVelo", + "02_velo+UT" : "isVelo & isUT", + "03_velo+UT>5GeV" : "isVelo & isUT & over5", + "04_velo+notLong" : "isNotLong & isVelo ", + "05_velo+UT+notLong" : "isNotLong & isVelo & isUT", + "06_velo+UT+notLong>5GeV" : "isNotLong & isVelo & isUT & over5", + "07_long" : "isLong", + "08_long>5GeV" : "isLong & over5 ", + "09_long_fromB" : "isLong & fromB", + "10_long_fromB>5GeV" : "isLong & fromB & over5", + "11_long_electrons" : "isLong & isElectron", + "12_long_fromB_electrons" : "isLong & isElectron & fromB", + "13_long_fromB_electrons_P>5GeV" : "isLong & isElectron & over5 & fromB" }, + "T" : { "01_hasT" : "isSeed ", + "02_long" : "isLong", + "03_long>5GeV" : "isLong & over5", + "04_long_fromB" : "isLong & fromB", + "05_long_fromB>5GeV" : "isLong & fromB & over5", + "06_UT+T_strange" : "strange & isDown", + "07_UT+T_strange>5GeV" : "strange & isDown & over5", + "08_noVelo+UT+T_strange" : "strange & isDown & isNotVelo", + "09_noVelo+UT+T_strange>5GeV" : "strange & isDown & over5 & isNotVelo", + "10_UT+T_SfromDB" : "strange & isDown & ( fromB | fromD )", + "11_UT+T_SfromDB>5GeV" : "strange & isDown & over5 & ( fromB | fromD )", + "12_noVelo+UT+T_SfromDB>5GeV" : "strange & isDown & isNotVelo & over5 & ( fromB | fromD )" }, + "Down" : { "01_UT+T" : "isDown ", + "02_UT+T>5GeV" : "isDown & over5", + "03_UT+T_strange" : " strange & isDown", + "04_UT+T_strange>5GeV" : " strange & isDown & over5", + "05_noVelo+UT+T_strange" : " strange & isDown & isNotVelo", + "06_noVelo+UT+T_strange>5GeV" : " strange & isDown & over5 & isNotVelo", + "07_UT+T_fromB" : "isDown & fromB", + "08_UT+T_fromB>5GeV" : "isDown & fromB & over5", + "09_noVelo+UT+T_fromB" : "isDown & fromB & isNotVelo", + "10_noVelo+UT+T_fromB>5GeV" : "isDown & fromB & over5 & isNotVelo", + "11_UT+T_SfromDB" : " strange & isDown & ( fromB | fromD )", + "12_UT+T_SfromDB>5GeV" : " strange & isDown & over5 & ( fromB | fromD )", + "13_noVelo+UT+T_SfromDB" : " strange & isDown & isNotVelo & ( fromB | fromD )", + "14_noVelo+UT+T_SfromDB>5GeV" : " strange & isDown & isNotVelo & over5 & ( fromB | fromD ) " }, + "UTForward" : { "01_long" : "isLong", + "02_long>5GeV" : "isLong & over5" }, + "UTDown" : { "01_has seed" : "isSeed", + "02_has seed +noVelo, T+UT" : "isSeed & isNotVelo & isDown", + "03_down+strange" : "strange & isDown", + "04_down+strange+>5GeV" : "strange & isDown & over5", + "05_pi<-Ks<-B" : "fromKsFromB", + "06_pi<-Ks<-B+> 5 GeV" : "fromKsFromB & over5" }, +} +TriggerMCCuts = { + "Velo" : { "11_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger", + "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger & isUT" }, + "Forward" : { "10_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger", + "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger & isUT" }, + "Up" :{ "14_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger", + "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger & isUT" }, + "New" : { "long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger", + "UT_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger & isUT" }, + "UTForward" : { "03_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger", + "04_UT_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger & isUT" }, + "UTDown" : { "07_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger", + "08_UT_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger & isUT" }, + "UTNew" : { "long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger", + "UT_long_fromB_P>3GeV_Pt>0.5GeV" : "isLong & fromB & trigger & isUT" }, +} +def getMCCuts(key, triggerNumbers = False): + cuts = MCCuts[key] if key in MCCuts else {} + if triggerNumbers and key in TriggerMCCuts: + cuts.update(TriggerMCCuts[key]) + return cuts + diff --git a/Hlt/RecoConf/tests/qmtest/test_reco_example.qmt b/Hlt/RecoConf/tests/qmtest/test_reco_example.qmt new file mode 100644 index 0000000000000000000000000000000000000000..3d10ce5f8c0a6998c31869db8d9f8574edf5236d --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/test_reco_example.qmt @@ -0,0 +1,32 @@ + + + + +gaudirun.py + + $RECOCONFROOT/options/reco_example.py + --output=reco_example.opts.py + --all-opt + + +from Configurables import HiveDataBrokerSvc +HiveDataBrokerSvc().OutputLevel = 5 + +true + + +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}) + + + diff --git a/PyConf/python/PyConf/core.py b/PyConf/python/PyConf/core.py index 2382b3f5d96f12daa00435aceb908efe7e36c9a6..d113b8e48e3fc34fc52f469fd3e9259434507b84 100644 --- a/PyConf/python/PyConf/core.py +++ b/PyConf/python/PyConf/core.py @@ -127,7 +127,7 @@ class CompositeNode(object): class EverythingHandler(object): - def __init__(self, threadPoolSize=1, nEventSlots=0, evtMax=-1, debug=True): + def __init__(self, threadPoolSize=1, nEventSlots=0, evtMax=-1, debug=True, HistoFile = None): self._nodes = [] self._algs = [] self._tools = [] #public tools @@ -152,6 +152,9 @@ class EverythingHandler(object): _setupComponent('MessageSvc', Format='% F%35W%S %7W%R%T %0W%M') _setupComponent('HistogramPersistencySvc', OutputLevel=5) self._eventClockSvc = _setupComponent('EventClockSvc', InitialTime=1433509200000000000) + if HistoFile != None: + self._histogramPersistencySvc = _setupComponent('HistogramPersistencySvc', OutputFile=HistoFile) + self._appMgr.HistogramPersistency = "ROOT" if debug: self._scheduler.OutputLevel = DEBUG self._hiveDataBroker.OutputLevel = DEBUG