From 0397448e50a2f02dbbacaf5c862f6d549ae3ef1c Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Wed, 18 Dec 2019 17:42:39 +0100 Subject: [PATCH 001/171] add track and IP resolution checker --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 331c1a5f65e..95ad31ce628 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -250,3 +250,35 @@ def make_track_filter(InputTracks, code): filtered_tracks = TrackListRefiner( inputLocation=InputTracks["v1"], Selector=selector).outputLocation return filtered_tracks + +def monitor_track_resolution(InputTracks): + from PyConf.Algorithms import TrackResChecker + links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() + links_to_tracks = make_links_tracks_mcparticles(InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + res_checker = TrackResChecker( + TracksInContainer= InputTracks["v1"], + MCParticleInContainer= mc_unpackers()["MCParticles"], + MCPropertyInput = make_data_with_FetchDataFromFile( "/Event/MC/TrackInfo" ), + LinkerInTable = links_to_tracks + ) + return res_checker + + +def monitor_IPresolution(InputTracks): + from PyConf.Algorithms import TrackIPResolutionCheckerNTMCHits, TrackIPResolutionCheckerNT + from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex + from PyConf.Algorithms import DataPacking__Unpack_LHCb__MCVPHitPacker_ + unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_(InputName=make_data_with_FetchDataFromFile( "/Event/pSim/VP/Hits" )) + vertexConverter = FromVectorLHCbRecVertex(InputVerticesName=pvs, InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName + links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() + links_to_tracks = make_links_tracks_mcparticles(InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + IPres_checker= TrackIPResolutionCheckerNTMCHits( + TrackContainer= InputTracks, + MCParticleInput= mc_unpackers()["MCParticles"], + MCHeaderLocation= make_data_with_FetchDataFromFile("/Event/MC/Header"), + LinkerLocation= links_to_tracks, + PVContainer= vertexConverter, + MCHitsLocation= unpacked_velo_mchits, + NTupleLUN = "FILE1") + return IPres_checker + -- GitLab From e33eb3468292cd412ec91287d38f1f748b2e1cdc Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 18 Dec 2019 16:43:35 +0000 Subject: [PATCH 002/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6602383 --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 41 ++++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 95ad31ce628..f7b5e71ecc8 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -251,16 +251,18 @@ def make_track_filter(InputTracks, code): inputLocation=InputTracks["v1"], Selector=selector).outputLocation return filtered_tracks + def monitor_track_resolution(InputTracks): from PyConf.Algorithms import TrackResChecker links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() - links_to_tracks = make_links_tracks_mcparticles(InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + links_to_tracks = make_links_tracks_mcparticles( + InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) res_checker = TrackResChecker( - TracksInContainer= InputTracks["v1"], - MCParticleInContainer= mc_unpackers()["MCParticles"], - MCPropertyInput = make_data_with_FetchDataFromFile( "/Event/MC/TrackInfo" ), - LinkerInTable = links_to_tracks - ) + TracksInContainer=InputTracks["v1"], + MCParticleInContainer=mc_unpackers()["MCParticles"], + MCPropertyInput=make_data_with_FetchDataFromFile( + "/Event/MC/TrackInfo"), + LinkerInTable=links_to_tracks) return res_checker @@ -268,17 +270,20 @@ def monitor_IPresolution(InputTracks): from PyConf.Algorithms import TrackIPResolutionCheckerNTMCHits, TrackIPResolutionCheckerNT from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex from PyConf.Algorithms import DataPacking__Unpack_LHCb__MCVPHitPacker_ - unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_(InputName=make_data_with_FetchDataFromFile( "/Event/pSim/VP/Hits" )) - vertexConverter = FromVectorLHCbRecVertex(InputVerticesName=pvs, InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName + unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_( + InputName=make_data_with_FetchDataFromFile("/Event/pSim/VP/Hits")) + vertexConverter = FromVectorLHCbRecVertex( + InputVerticesName=pvs, + InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() - links_to_tracks = make_links_tracks_mcparticles(InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) - IPres_checker= TrackIPResolutionCheckerNTMCHits( - TrackContainer= InputTracks, - MCParticleInput= mc_unpackers()["MCParticles"], - MCHeaderLocation= make_data_with_FetchDataFromFile("/Event/MC/Header"), - LinkerLocation= links_to_tracks, - PVContainer= vertexConverter, - MCHitsLocation= unpacked_velo_mchits, - NTupleLUN = "FILE1") + links_to_tracks = make_links_tracks_mcparticles( + InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + IPres_checker = TrackIPResolutionCheckerNTMCHits( + TrackContainer=InputTracks, + MCParticleInput=mc_unpackers()["MCParticles"], + MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), + LinkerLocation=links_to_tracks, + PVContainer=vertexConverter, + MCHitsLocation=unpacked_velo_mchits, + NTupleLUN="FILE1") return IPres_checker - -- GitLab From ccf0d346580ec94efd002de37f5a539b5b52eb3e Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 19 Dec 2019 09:47:47 +0100 Subject: [PATCH 003/171] modify the format --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index f7b5e71ecc8..ba8df603add 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -13,6 +13,7 @@ from __future__ import absolute_import, division, print_function In this file, algorithms needed to run the MC reconstruction checking (PrTrackChecker) are defined. ''' from PyConf.tonic import (configurable) +from PyConf.dataflow import DataHandle from PyConf.components import Tool from PyConf.application import default_raw_event @@ -24,9 +25,15 @@ from PyConf.Algorithms import ( PrTrackAssociator, PrTrackChecker, PrUTHitChecker, + TrackListRefiner, + TrackResChecker, + TrackIPResolutionCheckerNT, + DataPacking__Unpack_LHCb__MCVPHitPacker_ ) +from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool +from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector from RecoConf.hlt1_tracking import ( make_PrStoreUTHit_hits, @@ -44,7 +51,6 @@ def get_item(x, key): TODO: This helper function can be replaces once Moore!63 has been addressed. """ - from PyConf.dataflow import DataHandle if isinstance(x, DataHandle): return x return x[key] @@ -244,8 +250,6 @@ def get_best_tracks_checkers( def make_track_filter(InputTracks, code): - from PyConf.Algorithms import TrackListRefiner - from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector selector = LoKiTrackSelector(Code=code, StatPrint=True) filtered_tracks = TrackListRefiner( inputLocation=InputTracks["v1"], Selector=selector).outputLocation @@ -253,7 +257,6 @@ def make_track_filter(InputTracks, code): def monitor_track_resolution(InputTracks): - from PyConf.Algorithms import TrackResChecker links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) @@ -267,9 +270,6 @@ def monitor_track_resolution(InputTracks): def monitor_IPresolution(InputTracks): - from PyConf.Algorithms import TrackIPResolutionCheckerNTMCHits, TrackIPResolutionCheckerNT - from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex - from PyConf.Algorithms import DataPacking__Unpack_LHCb__MCVPHitPacker_ unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_( InputName=make_data_with_FetchDataFromFile("/Event/pSim/VP/Hits")) vertexConverter = FromVectorLHCbRecVertex( @@ -278,12 +278,11 @@ def monitor_IPresolution(InputTracks): links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) - IPres_checker = TrackIPResolutionCheckerNTMCHits( + IPres_checker = TrackIPResolutionCheckerNT( TrackContainer=InputTracks, MCParticleInput=mc_unpackers()["MCParticles"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), LinkerLocation=links_to_tracks, PVContainer=vertexConverter, - MCHitsLocation=unpacked_velo_mchits, NTupleLUN="FILE1") return IPres_checker -- GitLab From 31d3a53088992bfaea17273ecff9fd9059de06cd Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 19 Dec 2019 08:48:29 +0000 Subject: [PATCH 004/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6607609 --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index ba8df603add..02d97155812 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -20,16 +20,9 @@ from PyConf.application import default_raw_event from PyConf.application import make_data_with_FetchDataFromFile from PyConf.Algorithms import ( - VPFullCluster2MCParticleLinker, - PrLHCbID2MCParticle, - PrTrackAssociator, - PrTrackChecker, - PrUTHitChecker, - TrackListRefiner, - TrackResChecker, - TrackIPResolutionCheckerNT, - DataPacking__Unpack_LHCb__MCVPHitPacker_ -) + VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, PrTrackAssociator, + PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, + TrackIPResolutionCheckerNT, DataPacking__Unpack_LHCb__MCVPHitPacker_) from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool -- GitLab From e7a84ce3ae608a9edc370d9aa1a76b6507533035 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 19 Dec 2019 19:32:42 +0100 Subject: [PATCH 005/171] remove unused lines --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 02d97155812..423fe9c3c03 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -263,8 +263,6 @@ def monitor_track_resolution(InputTracks): def monitor_IPresolution(InputTracks): - unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_( - InputName=make_data_with_FetchDataFromFile("/Event/pSim/VP/Hits")) vertexConverter = FromVectorLHCbRecVertex( InputVerticesName=pvs, InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName -- GitLab From aaaea07d66d89852bb69b7873c7dd5ce5d722d61 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 20 Dec 2019 15:58:30 +0100 Subject: [PATCH 006/171] add options and qmt test for track and IP resolution --- .../options/hlt1_reco_IPresolution.py | 30 ++++++++++++++++++ .../options/hlt1_reco_trackresolution.py | 31 +++++++++++++++++++ Hlt/RecoConf/python/RecoConf/mc_checking.py | 12 +++---- .../tests/qmtest/hlt1_reco_IPresolution.qmt | 31 +++++++++++++++++++ .../qmtest/hlt1_reco_trackresolution.qmt | 31 +++++++++++++++++++ 5 files changed, 129 insertions(+), 6 deletions(-) create mode 100644 Hlt/RecoConf/options/hlt1_reco_IPresolution.py create mode 100644 Hlt/RecoConf/options/hlt1_reco_trackresolution.py create mode 100644 Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt create mode 100644 Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py new file mode 100644 index 00000000000..cb8c615e608 --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -0,0 +1,30 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks +from RecoConf.mc_checking import monitor_IPresolution +from Configurables import ApplicationMgr +from Configurables import NTupleSvc + + +def hlt1_reco_IPresolution(): + hlt1_tracks = make_hlt1_tracks() + fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) + pr_checker = monitor_IPresolution(fitted_tracks["v1"], hlt1_tracks["Velo"]["v1"]) + + return Reconstruction('IPresolution', [pr_checker], [require_gec()]) + +run_reconstruction(options, hlt1_reco_IPresolution) + +NTupleSvc().Output += ["FILE1 DATAFILE='Hlt1ForwardTracking_IPresolution.root' TYPE='ROOT' OPT='NEW'"] +ApplicationMgr().ExtSvc += [NTupleSvc()] +ApplicationMgr().HistogramPersistency="ROOT" diff --git a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py new file mode 100644 index 00000000000..c0f1006915b --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py @@ -0,0 +1,31 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks +from RecoConf.mc_checking import monitor_track_resolution + + +def hlt1_reco_trackresolution(): + track_type = "Forward" + tracks = make_hlt1_tracks()[track_type] + pr_checker = monitor_track_resolution( tracks) + + #return CompositeNode( + # name='hlt1_trackRes', + # children=pr_checker, + # combineLogic=NodeLogic.NONLAZY_OR, + # forceOrder=False) + return Reconstruction('track_resolution', [pr_checker], [require_gec()]) + + +options.histo_file = "Hlt1ForwardTrackingResolution.root" +run_reconstruction(options, hlt1_reco_trackresolution) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 423fe9c3c03..1d3d9cc7ec5 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -32,6 +32,7 @@ from RecoConf.hlt1_tracking import ( make_PrStoreUTHit_hits, make_FTRawBankDecoder_clusters, make_velo_full_clusters, + make_pvs ) from Hlt2Conf.data_from_file import mc_unpackers @@ -256,19 +257,18 @@ def monitor_track_resolution(InputTracks): res_checker = TrackResChecker( TracksInContainer=InputTracks["v1"], MCParticleInContainer=mc_unpackers()["MCParticles"], - MCPropertyInput=make_data_with_FetchDataFromFile( - "/Event/MC/TrackInfo"), LinkerInTable=links_to_tracks) return res_checker -def monitor_IPresolution(InputTracks): +def monitor_IPresolution(InputTracks, VeloTracks): + vertexConverter = FromVectorLHCbRecVertex( - InputVerticesName=pvs, - InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName + InputVerticesName=make_pvs(), + InputTracksName=VeloTracks).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( - InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + InputTracks, LinksToLHCbIDs=links_to_lhcbids) IPres_checker = TrackIPResolutionCheckerNT( TrackContainer=InputTracks, MCParticleInput=mc_unpackers()["MCParticles"], diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt new file mode 100644 index 00000000000..e34dcba158c --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt @@ -0,0 +1,31 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $RECOCONFROOT/options/hlt1_reco_IPresolution.py + --output=hlt1_reco_IPresolution.opts.py + --all-opt + +true + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt new file mode 100644 index 00000000000..38c0cdc0b83 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt @@ -0,0 +1,31 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $RECOCONFROOT/options/hlt1_reco_trackresolution.py + --output=hlt1_reco_trackresolution.opts.py + --all-opt + +true + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + -- GitLab From 13b8c9003c6d881699130f5acb01ac6251576434 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 20 Dec 2019 14:59:09 +0000 Subject: [PATCH 007/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6623848 --- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 10 +++++++--- Hlt/RecoConf/options/hlt1_reco_trackresolution.py | 4 ++-- Hlt/RecoConf/python/RecoConf/mc_checking.py | 9 +++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index cb8c615e608..2d3221e8b59 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -19,12 +19,16 @@ from Configurables import NTupleSvc def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) - pr_checker = monitor_IPresolution(fitted_tracks["v1"], hlt1_tracks["Velo"]["v1"]) + pr_checker = monitor_IPresolution(fitted_tracks["v1"], + hlt1_tracks["Velo"]["v1"]) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) + run_reconstruction(options, hlt1_reco_IPresolution) -NTupleSvc().Output += ["FILE1 DATAFILE='Hlt1ForwardTracking_IPresolution.root' TYPE='ROOT' OPT='NEW'"] +NTupleSvc().Output += [ + "FILE1 DATAFILE='Hlt1ForwardTracking_IPresolution.root' TYPE='ROOT' OPT='NEW'" +] ApplicationMgr().ExtSvc += [NTupleSvc()] -ApplicationMgr().HistogramPersistency="ROOT" +ApplicationMgr().HistogramPersistency = "ROOT" diff --git a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py index c0f1006915b..b540ab11836 100644 --- a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py @@ -11,13 +11,13 @@ from Moore import options, run_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks -from RecoConf.mc_checking import monitor_track_resolution +from RecoConf.mc_checking import monitor_track_resolution def hlt1_reco_trackresolution(): track_type = "Forward" tracks = make_hlt1_tracks()[track_type] - pr_checker = monitor_track_resolution( tracks) + pr_checker = monitor_track_resolution(tracks) #return CompositeNode( # name='hlt1_trackRes', diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 1d3d9cc7ec5..8877675a883 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -28,12 +28,9 @@ from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRec from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector -from RecoConf.hlt1_tracking import ( - make_PrStoreUTHit_hits, - make_FTRawBankDecoder_clusters, - make_velo_full_clusters, - make_pvs -) +from RecoConf.hlt1_tracking import (make_PrStoreUTHit_hits, + make_FTRawBankDecoder_clusters, + make_velo_full_clusters, make_pvs) from Hlt2Conf.data_from_file import mc_unpackers -- GitLab From de033e18763fb721ea1f86f5c4fa36d4244f7dfc Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 8 Jan 2020 12:30:18 +0000 Subject: [PATCH 008/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6706285 --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 40c8b9e68bf..3631ceefcf0 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -20,12 +20,12 @@ from PyConf.application import default_raw_event from PyConf.application import make_data_with_FetchDataFromFile from PyConf.Algorithms import ( - VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, PrTrackAssociator, PrLHCbID2MCParticleVPUTFTMU, - PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, - TrackIPResolutionCheckerNT, DataPacking__Unpack_LHCb__MCVPHitPacker_) + VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, PrTrackAssociator, + PrLHCbID2MCParticleVPUTFTMU, PrTrackChecker, PrUTHitChecker, + TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, + DataPacking__Unpack_LHCb__MCVPHitPacker_) from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex - from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector -- GitLab From d0be92220802f1312595814895521dffc36fc77d Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 9 Jan 2020 17:46:24 +0100 Subject: [PATCH 009/171] add script for reading IPresolution tuples --- Hlt/RecoConf/scripts/LHCbStyle.py | 104 +++++++++++++ Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 146 ++++++++++++++++++ 2 files changed, 250 insertions(+) create mode 100644 Hlt/RecoConf/scripts/LHCbStyle.py create mode 100644 Hlt/RecoConf/scripts/PrCheckerIPresolution.py diff --git a/Hlt/RecoConf/scripts/LHCbStyle.py b/Hlt/RecoConf/scripts/LHCbStyle.py new file mode 100644 index 00000000000..e57b3fe3876 --- /dev/null +++ b/Hlt/RecoConf/scripts/LHCbStyle.py @@ -0,0 +1,104 @@ +from ROOT import gStyle +from ROOT import gROOT +from ROOT import TStyle + +def setLHCbStyle() : + global lhcbStyle + + lhcbFont = 132 + lhcbTSize = 0.06 + lhcbWidth = 2 + + lhcbStyle= TStyle("lhcbStyle","LHCb plots style"); + lhcbStyle.SetFillColor(1) + lhcbStyle.SetFillStyle(1001) # solid + lhcbStyle.SetFrameFillColor(0) + lhcbStyle.SetFrameBorderMode(0) + lhcbStyle.SetPadBorderMode(0) + lhcbStyle.SetPadColor(0) + lhcbStyle.SetCanvasBorderMode(0) + lhcbStyle.SetCanvasColor(0) + lhcbStyle.SetStatColor(0) + lhcbStyle.SetLegendBorderSize(0) + lhcbStyle.SetLegendFont(132) + + # use large fonts + lhcbStyle.SetTextFont(lhcbFont) + lhcbStyle.SetTitleFont(lhcbFont) + lhcbStyle.SetTextSize(lhcbTSize) + lhcbStyle.SetLabelFont(lhcbFont,"x") + lhcbStyle.SetLabelFont(lhcbFont,"y") + lhcbStyle.SetLabelFont(lhcbFont,"z") + lhcbStyle.SetLabelSize(lhcbTSize,"x") + lhcbStyle.SetLabelSize(lhcbTSize,"y") + lhcbStyle.SetLabelSize(lhcbTSize,"z") + lhcbStyle.SetTitleFont(lhcbFont) + lhcbStyle.SetTitleFont(lhcbFont,"x") + lhcbStyle.SetTitleFont(lhcbFont,"y") + lhcbStyle.SetTitleFont(lhcbFont,"z") + lhcbStyle.SetTitleSize(1.2*lhcbTSize,"x") + lhcbStyle.SetTitleSize(1.2*lhcbTSize,"y") + lhcbStyle.SetTitleSize(1.2*lhcbTSize,"z") + + # set the paper & margin sizes + lhcbStyle.SetPaperSize(20,26) + lhcbStyle.SetPadTopMargin(0.05) + lhcbStyle.SetPadRightMargin(0.05) # increase for colz plots + lhcbStyle.SetPadBottomMargin(0.16) + lhcbStyle.SetPadLeftMargin(0.14) + + # use medium bold lines and thick markers + lhcbStyle.SetLineWidth(lhcbWidth); + lhcbStyle.SetFrameLineWidth(lhcbWidth); + lhcbStyle.SetHistLineWidth(lhcbWidth); + lhcbStyle.SetFuncWidth(lhcbWidth); + lhcbStyle.SetGridWidth(lhcbWidth); + lhcbStyle.SetLineStyleString(2,"[12 12]"); # postscript dashes + lhcbStyle.SetMarkerStyle(20); + lhcbStyle.SetMarkerSize(1.0); + + # label offsets + lhcbStyle.SetLabelOffset(0.010,"X"); + lhcbStyle.SetLabelOffset(0.010,"Y"); + + # by default, do not display histogram decorations: + lhcbStyle.SetOptStat(0) + #lhcbStyle.SetOptStat("emr") # show only nent -e , mean - m , rms -r + # full opts at http:#root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat + lhcbStyle.SetStatFormat("6.3g") # specified as c printf options + lhcbStyle.SetOptTitle(0) + lhcbStyle.SetOptFit(0) + #lhcbStyle.SetOptFit(1011) # order is probability, Chi2, errors, parameters + #titles + lhcbStyle.SetTitleOffset(0.85,"X") + lhcbStyle.SetTitleOffset(0.85,"Y") + lhcbStyle.SetTitleOffset(1.2,"Z") + lhcbStyle.SetTitleFillColor(0) + lhcbStyle.SetTitleStyle(0) + lhcbStyle.SetTitleBorderSize(0) + lhcbStyle.SetTitleFont(lhcbFont,"title") + lhcbStyle.SetTitleX(0.0) + lhcbStyle.SetTitleY(1.0) + lhcbStyle.SetTitleW(1.0) + lhcbStyle.SetTitleH(0.05) + + # look of the statistics box: + lhcbStyle.SetStatBorderSize(0) + lhcbStyle.SetStatFont(lhcbFont) + lhcbStyle.SetStatFontSize(0.05) + lhcbStyle.SetStatX(0.9) + lhcbStyle.SetStatY(0.9) + lhcbStyle.SetStatW(0.25) + lhcbStyle.SetStatH(0.15) + + # put tick marks on top and RHS of plots + lhcbStyle.SetPadTickX(1) + lhcbStyle.SetPadTickY(1) + + # histogram divisions: only 5 in x to avoid label overlaps + lhcbStyle.SetNdivisions(505,"x") + lhcbStyle.SetNdivisions(510,"y") + + gROOT.SetStyle("lhcbStyle") + return + diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py new file mode 100644 index 00000000000..1e035c09c9a --- /dev/null +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -0,0 +1,146 @@ +#!/usr/bin/python + +# Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution +# as well as a check of the IP error distribution and efficiencies in different chi2 cut. +# +# The resolution is fitted by a Gaussian function +# +# author: Peilian Li(peilian.li@cern.ch) +# date: 01/2020 +# + +import os,sys +import argparse +import ROOT +from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 +from ROOT import gROOT, gStyle, TStyle, TPaveText, TString +from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors + +from collections import defaultdict +from LHCbStyle import setLHCbStyle +setLHCbStyle() +#from collectRunResults import send_notification_mattermost + + +def argument_parser(): + parser = argparse.ArgumentParser(description="path of the tuple file location") + parser.add_argument('--directory', type=str, default=os.getcwd(), help='location of input tuple files') + parser.add_argument('--name', type=str, default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') + return parser + +def PrCheckerIPresolution(directory, name): + + f = TFile.Open(os.path.join(directory,name+'.root'), 'read') + outputfile = TFile( "IPResolution_plots.root", "recreate" ) + + tuples = f.Get("TrackIPResolutionCheckerNT/tracks"); + outputfile.cd() + + # typeofprefix==0 for track from PV and matched with MC + cutAcc= "trueeta<5 && trueeta>2 && typeofprefix==0" + print ("Velo track from PV in acceptance: " + cutAcc) + resIPx=TH2F("resIPx", "IPx:1/pt", 20, 0, 3, 100, -300, 300) + resIPy=TH2F("resIPy", "IPy:1/pt", 20, 0, 3, 100, -300, 300) + resIPx.SetMarkerStyle(1) + resIPy.SetMarkerStyle(1) + varx="recIPx*1000:1.0/truept" + vary="recIPy*1000:1.0/truept" + print ("IPx var: " +varx) + print ("IPy var: " +vary) + tuples.Draw(varx+">>resIPx", cutAcc) + tuples.Draw(vary+">>resIPy", cutAcc) + resIPx.FitSlicesY() + resIPy.FitSlicesY() + hresx_2 = outputfile.Get("resIPx_2") + hresy_2 = outputfile.Get("resIPy_2") + + canvas1 = TCanvas("resIPx_pT", "resIPx v.s. 1/pT") + hresx_2.Draw("E1 p1") + hresx_2.GetYaxis().SetTitle("#sigma_{IPx} [#mum]") + hresx_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") + hresx_2.SetTitle("#sigma(IP_{x}):1/p_{T}") + + polx = TF1("polx","pol1", 0, 3) + polx.SetLineColor(kRed) + print("Fit to Resolution of IPx v.s. 1/pT:") + hresx_2.Fit("polx", "R") + Par0x=format(polx.GetParameter(0), '.2f') + Par1x=format(polx.GetParameter(1), '.2f') + + pt = TPaveText(0.22,0.65,0.48,0.9,"BRNDC") + pt.SetTextSize(0.055) + pt.SetBorderSize(1) + pt.SetFillColor(10) + pt.SetLineWidth(0) + Funcx=Par0x+"+"+Par1x+"/p_{T}" + text=pt.AddText(Funcx) + pt.Draw() + canvas1.SetRightMargin(0.05) + canvas1.Write() + + canvas2 = TCanvas("resIPy_pT", "resIPy v.s. 1/pT") + hresy_2.Draw("E1 p1") + hresy_2.GetYaxis().SetTitle("#sigma_{IPy} [#mum]") + hresy_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") + hresy_2.SetTitle("#sigma(IP_{y}):1/p_{T}") + poly = TF1("poly","pol1", 0, 3) + poly.SetLineColor(kRed) + hresy_2.Fit("poly", "R") + Par0y=format(poly.GetParameter(0), '.2f') + Par1y=format(poly.GetParameter(1), '.2f') + + pt = TPaveText(0.22,0.65,0.48,0.9,"BRNDC") + pt.SetTextSize(0.055) + pt.SetBorderSize(1) + pt.SetFillColor(10) + pt.SetLineWidth(0) + Funcy=Par0y+"+"+Par1y+"/p_{T}" + texty=pt.AddText(Funcy) + pt.Draw() + canvas2.SetRightMargin(0.05) + canvas2.Write() + + resIPx_1=outputfile.Get("resIPx_1") + resIPx_2=outputfile.Get("resIPx_2") + resIPy_1=outputfile.Get("resIPy_1") + resIPy_2=outputfile.Get("resIPy_2") + for i in range(1, 20): + print("in 1/pT region: (" + format(resIPx_1.GetBinLowEdge(i), '.2f') + ", "+format(resIPx_1.GetBinLowEdge(i)+resIPx_1.GetBinWidth(i), '.2f')+") [c/GeV]" +" -***- "+ + "resIPx for mean : " + format(resIPx_1.GetBinContent(i), '.2f') + "[\mum] width : "+ format(resIPx_2.GetBinContent(i), '.2f') +"[\mum] -***- "+ + "resIPy for mean : " + format(resIPy_1.GetBinContent(i), '.2f') + "[\mum] width : "+ format(resIPy_2.GetBinContent(i), '.2f')+"[\mum]" ) + + #### rec IP chi2 distribution + recIPChi2=TH1F("recIPChi2", "recIPChi2", 100, 0, 200 ) + var="recIPChi2" + tuples.Draw(var+">>recIPChi2", cutAcc) + canvas=TCanvas("IPChi2", "IPChi2") + canvas.SetLogy() + recIPChi2.Draw() + recIPChi2.SetXTitle("#chi^{2}_{IP}") + recIPChi2.SetYTitle("N_{tracks}") + canvas.SetRightMargin(0.05) + canvas.Write() + + ### print efficiency of different IPchi2 cut + Numerator=TH1F("Numerator", "Numerator", 100, 0, 200 ) + Denominator=TH1F("Denominator", "Denominator", 100, 0, 200 ) + tuples.Draw(var+">>Denominator", cutAcc, "same") + for cut in [100, 25, 16, 9, 4]: + cutChi2=" && recIPChi2<"+format(cut) + cutNum=cutAcc + cutChi2 + tuples.Draw(var+">>Numerator", cutNum) + if Numerator.GetEntries() == 0 or Denominator.GetEntries() == 0 : + continue + Eff=Numerator.GetEntries()/(Denominator.GetEntries()+0.0) + print ("Efficiency of IPchi2<"+format(cut)+" : " + format(Eff,'.2%')) + + + outputfile.Write() + outputfile.Close() + f.Close() + +if __name__ == '__main__': + parser = argument_parser() + args = parser.parse_args() + PrCheckerIPresolution(**vars(args)) -- GitLab From c89e7471484d9a90111b6461f8cff9e1eef46f68 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 9 Jan 2020 16:47:05 +0000 Subject: [PATCH 010/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6722884 --- Hlt/RecoConf/scripts/LHCbStyle.py | 95 +++---- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 250 ++++++++++-------- 2 files changed, 182 insertions(+), 163 deletions(-) diff --git a/Hlt/RecoConf/scripts/LHCbStyle.py b/Hlt/RecoConf/scripts/LHCbStyle.py index e57b3fe3876..11d029b04b4 100644 --- a/Hlt/RecoConf/scripts/LHCbStyle.py +++ b/Hlt/RecoConf/scripts/LHCbStyle.py @@ -2,16 +2,17 @@ from ROOT import gStyle from ROOT import gROOT from ROOT import TStyle -def setLHCbStyle() : + +def setLHCbStyle(): global lhcbStyle - lhcbFont = 132 - lhcbTSize = 0.06 - lhcbWidth = 2 - - lhcbStyle= TStyle("lhcbStyle","LHCb plots style"); + lhcbFont = 132 + lhcbTSize = 0.06 + lhcbWidth = 2 + + lhcbStyle = TStyle("lhcbStyle", "LHCb plots style") lhcbStyle.SetFillColor(1) - lhcbStyle.SetFillStyle(1001) # solid + lhcbStyle.SetFillStyle(1001) # solid lhcbStyle.SetFrameFillColor(0) lhcbStyle.SetFrameBorderMode(0) lhcbStyle.SetPadBorderMode(0) @@ -26,62 +27,63 @@ def setLHCbStyle() : lhcbStyle.SetTextFont(lhcbFont) lhcbStyle.SetTitleFont(lhcbFont) lhcbStyle.SetTextSize(lhcbTSize) - lhcbStyle.SetLabelFont(lhcbFont,"x") - lhcbStyle.SetLabelFont(lhcbFont,"y") - lhcbStyle.SetLabelFont(lhcbFont,"z") - lhcbStyle.SetLabelSize(lhcbTSize,"x") - lhcbStyle.SetLabelSize(lhcbTSize,"y") - lhcbStyle.SetLabelSize(lhcbTSize,"z") + lhcbStyle.SetLabelFont(lhcbFont, "x") + lhcbStyle.SetLabelFont(lhcbFont, "y") + lhcbStyle.SetLabelFont(lhcbFont, "z") + lhcbStyle.SetLabelSize(lhcbTSize, "x") + lhcbStyle.SetLabelSize(lhcbTSize, "y") + lhcbStyle.SetLabelSize(lhcbTSize, "z") lhcbStyle.SetTitleFont(lhcbFont) - lhcbStyle.SetTitleFont(lhcbFont,"x") - lhcbStyle.SetTitleFont(lhcbFont,"y") - lhcbStyle.SetTitleFont(lhcbFont,"z") - lhcbStyle.SetTitleSize(1.2*lhcbTSize,"x") - lhcbStyle.SetTitleSize(1.2*lhcbTSize,"y") - lhcbStyle.SetTitleSize(1.2*lhcbTSize,"z") + lhcbStyle.SetTitleFont(lhcbFont, "x") + lhcbStyle.SetTitleFont(lhcbFont, "y") + lhcbStyle.SetTitleFont(lhcbFont, "z") + lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "x") + lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "y") + lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "z") # set the paper & margin sizes - lhcbStyle.SetPaperSize(20,26) + lhcbStyle.SetPaperSize(20, 26) lhcbStyle.SetPadTopMargin(0.05) - lhcbStyle.SetPadRightMargin(0.05) # increase for colz plots + lhcbStyle.SetPadRightMargin(0.05) # increase for colz plots lhcbStyle.SetPadBottomMargin(0.16) lhcbStyle.SetPadLeftMargin(0.14) # use medium bold lines and thick markers - lhcbStyle.SetLineWidth(lhcbWidth); - lhcbStyle.SetFrameLineWidth(lhcbWidth); - lhcbStyle.SetHistLineWidth(lhcbWidth); - lhcbStyle.SetFuncWidth(lhcbWidth); - lhcbStyle.SetGridWidth(lhcbWidth); - lhcbStyle.SetLineStyleString(2,"[12 12]"); # postscript dashes - lhcbStyle.SetMarkerStyle(20); - lhcbStyle.SetMarkerSize(1.0); - + lhcbStyle.SetLineWidth(lhcbWidth) + lhcbStyle.SetFrameLineWidth(lhcbWidth) + lhcbStyle.SetHistLineWidth(lhcbWidth) + lhcbStyle.SetFuncWidth(lhcbWidth) + lhcbStyle.SetGridWidth(lhcbWidth) + lhcbStyle.SetLineStyleString(2, "[12 12]") + # postscript dashes + lhcbStyle.SetMarkerStyle(20) + lhcbStyle.SetMarkerSize(1.0) + # label offsets - lhcbStyle.SetLabelOffset(0.010,"X"); - lhcbStyle.SetLabelOffset(0.010,"Y"); - + lhcbStyle.SetLabelOffset(0.010, "X") + lhcbStyle.SetLabelOffset(0.010, "Y") + # by default, do not display histogram decorations: - lhcbStyle.SetOptStat(0) + lhcbStyle.SetOptStat(0) #lhcbStyle.SetOptStat("emr") # show only nent -e , mean - m , rms -r # full opts at http:#root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat - lhcbStyle.SetStatFormat("6.3g") # specified as c printf options + lhcbStyle.SetStatFormat("6.3g") # specified as c printf options lhcbStyle.SetOptTitle(0) lhcbStyle.SetOptFit(0) #lhcbStyle.SetOptFit(1011) # order is probability, Chi2, errors, parameters #titles - lhcbStyle.SetTitleOffset(0.85,"X") - lhcbStyle.SetTitleOffset(0.85,"Y") - lhcbStyle.SetTitleOffset(1.2,"Z") + lhcbStyle.SetTitleOffset(0.85, "X") + lhcbStyle.SetTitleOffset(0.85, "Y") + lhcbStyle.SetTitleOffset(1.2, "Z") lhcbStyle.SetTitleFillColor(0) lhcbStyle.SetTitleStyle(0) lhcbStyle.SetTitleBorderSize(0) - lhcbStyle.SetTitleFont(lhcbFont,"title") + lhcbStyle.SetTitleFont(lhcbFont, "title") lhcbStyle.SetTitleX(0.0) - lhcbStyle.SetTitleY(1.0) + lhcbStyle.SetTitleY(1.0) lhcbStyle.SetTitleW(1.0) lhcbStyle.SetTitleH(0.05) - + # look of the statistics box: lhcbStyle.SetStatBorderSize(0) lhcbStyle.SetStatFont(lhcbFont) @@ -90,15 +92,14 @@ def setLHCbStyle() : lhcbStyle.SetStatY(0.9) lhcbStyle.SetStatW(0.25) lhcbStyle.SetStatH(0.15) - + # put tick marks on top and RHS of plots lhcbStyle.SetPadTickX(1) lhcbStyle.SetPadTickY(1) - + # histogram divisions: only 5 in x to avoid label overlaps - lhcbStyle.SetNdivisions(505,"x") - lhcbStyle.SetNdivisions(510,"y") - + lhcbStyle.SetNdivisions(505, "x") + lhcbStyle.SetNdivisions(510, "y") + gROOT.SetStyle("lhcbStyle") return - diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 1e035c09c9a..7a904d5cf2c 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -1,144 +1,162 @@ #!/usr/bin/python -# Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution +# Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution # as well as a check of the IP error distribution and efficiencies in different chi2 cut. # -# The resolution is fitted by a Gaussian function +# The resolution is fitted by a Gaussian function # # author: Peilian Li(peilian.li@cern.ch) # date: 01/2020 # -import os,sys +import os, sys import argparse import ROOT from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject -from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 -from ROOT import gROOT, gStyle, TStyle, TPaveText, TString +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 +from ROOT import gROOT, gStyle, TStyle, TPaveText, TString from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors from collections import defaultdict from LHCbStyle import setLHCbStyle setLHCbStyle() + #from collectRunResults import send_notification_mattermost def argument_parser(): - parser = argparse.ArgumentParser(description="path of the tuple file location") - parser.add_argument('--directory', type=str, default=os.getcwd(), help='location of input tuple files') - parser.add_argument('--name', type=str, default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') + parser = argparse.ArgumentParser( + description="path of the tuple file location") + parser.add_argument( + '--directory', + type=str, + default=os.getcwd(), + help='location of input tuple files') + parser.add_argument( + '--name', + type=str, + default='Hlt1ForwardTracking_IPresolution', + help='name of input tuple files') return parser + def PrCheckerIPresolution(directory, name): - f = TFile.Open(os.path.join(directory,name+'.root'), 'read') - outputfile = TFile( "IPResolution_plots.root", "recreate" ) - - tuples = f.Get("TrackIPResolutionCheckerNT/tracks"); - outputfile.cd() - - # typeofprefix==0 for track from PV and matched with MC - cutAcc= "trueeta<5 && trueeta>2 && typeofprefix==0" - print ("Velo track from PV in acceptance: " + cutAcc) - resIPx=TH2F("resIPx", "IPx:1/pt", 20, 0, 3, 100, -300, 300) - resIPy=TH2F("resIPy", "IPy:1/pt", 20, 0, 3, 100, -300, 300) - resIPx.SetMarkerStyle(1) - resIPy.SetMarkerStyle(1) - varx="recIPx*1000:1.0/truept" - vary="recIPy*1000:1.0/truept" - print ("IPx var: " +varx) - print ("IPy var: " +vary) - tuples.Draw(varx+">>resIPx", cutAcc) - tuples.Draw(vary+">>resIPy", cutAcc) - resIPx.FitSlicesY() - resIPy.FitSlicesY() - hresx_2 = outputfile.Get("resIPx_2") - hresy_2 = outputfile.Get("resIPy_2") - - canvas1 = TCanvas("resIPx_pT", "resIPx v.s. 1/pT") - hresx_2.Draw("E1 p1") - hresx_2.GetYaxis().SetTitle("#sigma_{IPx} [#mum]") - hresx_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") - hresx_2.SetTitle("#sigma(IP_{x}):1/p_{T}") - - polx = TF1("polx","pol1", 0, 3) - polx.SetLineColor(kRed) - print("Fit to Resolution of IPx v.s. 1/pT:") - hresx_2.Fit("polx", "R") - Par0x=format(polx.GetParameter(0), '.2f') - Par1x=format(polx.GetParameter(1), '.2f') - - pt = TPaveText(0.22,0.65,0.48,0.9,"BRNDC") - pt.SetTextSize(0.055) - pt.SetBorderSize(1) - pt.SetFillColor(10) - pt.SetLineWidth(0) - Funcx=Par0x+"+"+Par1x+"/p_{T}" - text=pt.AddText(Funcx) - pt.Draw() - canvas1.SetRightMargin(0.05) - canvas1.Write() - - canvas2 = TCanvas("resIPy_pT", "resIPy v.s. 1/pT") - hresy_2.Draw("E1 p1") - hresy_2.GetYaxis().SetTitle("#sigma_{IPy} [#mum]") - hresy_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") - hresy_2.SetTitle("#sigma(IP_{y}):1/p_{T}") - poly = TF1("poly","pol1", 0, 3) - poly.SetLineColor(kRed) - hresy_2.Fit("poly", "R") - Par0y=format(poly.GetParameter(0), '.2f') - Par1y=format(poly.GetParameter(1), '.2f') - - pt = TPaveText(0.22,0.65,0.48,0.9,"BRNDC") - pt.SetTextSize(0.055) - pt.SetBorderSize(1) - pt.SetFillColor(10) - pt.SetLineWidth(0) - Funcy=Par0y+"+"+Par1y+"/p_{T}" - texty=pt.AddText(Funcy) - pt.Draw() - canvas2.SetRightMargin(0.05) - canvas2.Write() - - resIPx_1=outputfile.Get("resIPx_1") - resIPx_2=outputfile.Get("resIPx_2") - resIPy_1=outputfile.Get("resIPy_1") - resIPy_2=outputfile.Get("resIPy_2") - for i in range(1, 20): - print("in 1/pT region: (" + format(resIPx_1.GetBinLowEdge(i), '.2f') + ", "+format(resIPx_1.GetBinLowEdge(i)+resIPx_1.GetBinWidth(i), '.2f')+") [c/GeV]" +" -***- "+ - "resIPx for mean : " + format(resIPx_1.GetBinContent(i), '.2f') + "[\mum] width : "+ format(resIPx_2.GetBinContent(i), '.2f') +"[\mum] -***- "+ - "resIPy for mean : " + format(resIPy_1.GetBinContent(i), '.2f') + "[\mum] width : "+ format(resIPy_2.GetBinContent(i), '.2f')+"[\mum]" ) - - #### rec IP chi2 distribution - recIPChi2=TH1F("recIPChi2", "recIPChi2", 100, 0, 200 ) - var="recIPChi2" - tuples.Draw(var+">>recIPChi2", cutAcc) - canvas=TCanvas("IPChi2", "IPChi2") - canvas.SetLogy() - recIPChi2.Draw() - recIPChi2.SetXTitle("#chi^{2}_{IP}") - recIPChi2.SetYTitle("N_{tracks}") - canvas.SetRightMargin(0.05) - canvas.Write() - - ### print efficiency of different IPchi2 cut - Numerator=TH1F("Numerator", "Numerator", 100, 0, 200 ) - Denominator=TH1F("Denominator", "Denominator", 100, 0, 200 ) - tuples.Draw(var+">>Denominator", cutAcc, "same") - for cut in [100, 25, 16, 9, 4]: - cutChi2=" && recIPChi2<"+format(cut) - cutNum=cutAcc + cutChi2 - tuples.Draw(var+">>Numerator", cutNum) - if Numerator.GetEntries() == 0 or Denominator.GetEntries() == 0 : - continue - Eff=Numerator.GetEntries()/(Denominator.GetEntries()+0.0) - print ("Efficiency of IPchi2<"+format(cut)+" : " + format(Eff,'.2%')) - - - outputfile.Write() - outputfile.Close() - f.Close() + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') + outputfile = TFile("IPResolution_plots.root", "recreate") + + tuples = f.Get("TrackIPResolutionCheckerNT/tracks") + outputfile.cd() + + # typeofprefix==0 for track from PV and matched with MC + cutAcc = "trueeta<5 && trueeta>2 && typeofprefix==0" + print("Velo track from PV in acceptance: " + cutAcc) + resIPx = TH2F("resIPx", "IPx:1/pt", 20, 0, 3, 100, -300, 300) + resIPy = TH2F("resIPy", "IPy:1/pt", 20, 0, 3, 100, -300, 300) + resIPx.SetMarkerStyle(1) + resIPy.SetMarkerStyle(1) + varx = "recIPx*1000:1.0/truept" + vary = "recIPy*1000:1.0/truept" + print("IPx var: " + varx) + print("IPy var: " + vary) + tuples.Draw(varx + ">>resIPx", cutAcc) + tuples.Draw(vary + ">>resIPy", cutAcc) + resIPx.FitSlicesY() + resIPy.FitSlicesY() + hresx_2 = outputfile.Get("resIPx_2") + hresy_2 = outputfile.Get("resIPy_2") + + canvas1 = TCanvas("resIPx_pT", "resIPx v.s. 1/pT") + hresx_2.Draw("E1 p1") + hresx_2.GetYaxis().SetTitle("#sigma_{IPx} [#mum]") + hresx_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") + hresx_2.SetTitle("#sigma(IP_{x}):1/p_{T}") + + polx = TF1("polx", "pol1", 0, 3) + polx.SetLineColor(kRed) + print("Fit to Resolution of IPx v.s. 1/pT:") + hresx_2.Fit("polx", "R") + Par0x = format(polx.GetParameter(0), '.2f') + Par1x = format(polx.GetParameter(1), '.2f') + + pt = TPaveText(0.22, 0.65, 0.48, 0.9, "BRNDC") + pt.SetTextSize(0.055) + pt.SetBorderSize(1) + pt.SetFillColor(10) + pt.SetLineWidth(0) + Funcx = Par0x + "+" + Par1x + "/p_{T}" + text = pt.AddText(Funcx) + pt.Draw() + canvas1.SetRightMargin(0.05) + canvas1.Write() + + canvas2 = TCanvas("resIPy_pT", "resIPy v.s. 1/pT") + hresy_2.Draw("E1 p1") + hresy_2.GetYaxis().SetTitle("#sigma_{IPy} [#mum]") + hresy_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") + hresy_2.SetTitle("#sigma(IP_{y}):1/p_{T}") + poly = TF1("poly", "pol1", 0, 3) + poly.SetLineColor(kRed) + hresy_2.Fit("poly", "R") + Par0y = format(poly.GetParameter(0), '.2f') + Par1y = format(poly.GetParameter(1), '.2f') + + pt = TPaveText(0.22, 0.65, 0.48, 0.9, "BRNDC") + pt.SetTextSize(0.055) + pt.SetBorderSize(1) + pt.SetFillColor(10) + pt.SetLineWidth(0) + Funcy = Par0y + "+" + Par1y + "/p_{T}" + texty = pt.AddText(Funcy) + pt.Draw() + canvas2.SetRightMargin(0.05) + canvas2.Write() + + resIPx_1 = outputfile.Get("resIPx_1") + resIPx_2 = outputfile.Get("resIPx_2") + resIPy_1 = outputfile.Get("resIPy_1") + resIPy_2 = outputfile.Get("resIPy_2") + for i in range(1, 20): + print("in 1/pT region: (" + format(resIPx_1.GetBinLowEdge(i), '.2f') + + ", " + format( + resIPx_1.GetBinLowEdge(i) + resIPx_1.GetBinWidth(i), '.2f') + + ") [c/GeV]" + " -***- " + "resIPx for mean : " + + format(resIPx_1.GetBinContent(i), '.2f') + "[\mum] width : " + + format(resIPx_2.GetBinContent(i), '.2f') + "[\mum] -***- " + + "resIPy for mean : " + format(resIPy_1.GetBinContent(i), '.2f') + + "[\mum] width : " + format(resIPy_2.GetBinContent(i), '.2f') + + "[\mum]") + + #### rec IP chi2 distribution + recIPChi2 = TH1F("recIPChi2", "recIPChi2", 100, 0, 200) + var = "recIPChi2" + tuples.Draw(var + ">>recIPChi2", cutAcc) + canvas = TCanvas("IPChi2", "IPChi2") + canvas.SetLogy() + recIPChi2.Draw() + recIPChi2.SetXTitle("#chi^{2}_{IP}") + recIPChi2.SetYTitle("N_{tracks}") + canvas.SetRightMargin(0.05) + canvas.Write() + + ### print efficiency of different IPchi2 cut + Numerator = TH1F("Numerator", "Numerator", 100, 0, 200) + Denominator = TH1F("Denominator", "Denominator", 100, 0, 200) + tuples.Draw(var + ">>Denominator", cutAcc, "same") + for cut in [100, 25, 16, 9, 4]: + cutChi2 = " && recIPChi2<" + format(cut) + cutNum = cutAcc + cutChi2 + tuples.Draw(var + ">>Numerator", cutNum) + if Numerator.GetEntries() == 0 or Denominator.GetEntries() == 0: + continue + Eff = Numerator.GetEntries() / (Denominator.GetEntries() + 0.0) + print("Efficiency of IPchi2<" + format(cut) + " : " + + format(Eff, '.2%')) + + outputfile.Write() + outputfile.Close() + f.Close() + if __name__ == '__main__': parser = argument_parser() -- GitLab From b8628c1a3ce3a44263a911d776909f4731caf766 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 9 Jan 2020 18:01:23 +0100 Subject: [PATCH 011/171] add script for reading the IPresolution tuples --- Hlt/RecoConf/scripts/LHCbStyle.py | 11 +++++++ Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 29 ++++++++++++------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Hlt/RecoConf/scripts/LHCbStyle.py b/Hlt/RecoConf/scripts/LHCbStyle.py index 11d029b04b4..88799a336e2 100644 --- a/Hlt/RecoConf/scripts/LHCbStyle.py +++ b/Hlt/RecoConf/scripts/LHCbStyle.py @@ -1,3 +1,14 @@ +############################################################################### +# (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 ROOT import gStyle from ROOT import gROOT from ROOT import TStyle diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 7a904d5cf2c..70941eae941 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -1,13 +1,22 @@ -#!/usr/bin/python - -# Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution -# as well as a check of the IP error distribution and efficiencies in different chi2 cut. -# -# The resolution is fitted by a Gaussian function -# -# author: Peilian Li(peilian.li@cern.ch) -# date: 01/2020 -# +############################################################################### +# (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. # +############################################################################### +''' + Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution + as well as a check of the IP error distribution and efficiencies in different chi2 cut. + + The resolution is fitted by a Gaussian function + + author: Peilian Li(peilian.li@cern.ch) + date: 01/2020 +''' import os, sys import argparse -- GitLab From ea6bd22592ed5110323c81d2da18b0dbe0a5307c Mon Sep 17 00:00:00 2001 From: Peilian Li Date: Thu, 9 Jan 2020 17:09:12 +0000 Subject: [PATCH 012/171] Apply suggestion to Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt --- Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt index e34dcba158c..74c2cfa3668 100644 --- a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt +++ b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt @@ -10,7 +10,7 @@ or submit itself to any jurisdiction. --> gaudirun.py -- GitLab From 8c494cfd0c9b17cb2d8995b8c509f6fb54fd3ada Mon Sep 17 00:00:00 2001 From: Peilian Li Date: Thu, 9 Jan 2020 17:30:49 +0000 Subject: [PATCH 013/171] Apply suggestion to Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt --- Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt index 38c0cdc0b83..0a10d19ac0d 100644 --- a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt +++ b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt @@ -10,7 +10,7 @@ or submit itself to any jurisdiction. --> gaudirun.py -- GitLab From 2798a894566306f4f2eadb7e83115f4bb2452400 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 10 Jan 2020 17:35:44 +0100 Subject: [PATCH 014/171] add scripts to plot the tracking and IP resolution --- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 19 ++- .../scripts/PrCheckerTrackResolution.py | 143 ++++++++++++++++++ Hlt/RecoConf/scripts/{ => utils}/LHCbStyle.py | 0 Hlt/RecoConf/scripts/utils/Legend.py | 117 ++++++++++++++ .../tests/qmtest/hlt1_reco_IPresolution.qmt | 31 ---- .../qmtest/hlt1_reco_trackresolution.qmt | 31 ---- 6 files changed, 272 insertions(+), 69 deletions(-) create mode 100644 Hlt/RecoConf/scripts/PrCheckerTrackResolution.py rename Hlt/RecoConf/scripts/{ => utils}/LHCbStyle.py (100%) create mode 100644 Hlt/RecoConf/scripts/utils/Legend.py delete mode 100644 Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt delete mode 100644 Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 70941eae941..e110da81343 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -24,18 +24,15 @@ import ROOT from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 from ROOT import gROOT, gStyle, TStyle, TPaveText, TString -from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors +from ROOT import ROOT, vector, TGraphAsymmErrors from collections import defaultdict -from LHCbStyle import setLHCbStyle -setLHCbStyle() #from collectRunResults import send_notification_mattermost - def argument_parser(): parser = argparse.ArgumentParser( - description="path of the tuple file location") + description="location of the tuple file") parser.add_argument( '--directory', type=str, @@ -46,18 +43,26 @@ def argument_parser(): type=str, default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') + parser.add_argument( + '--plotstyle', + default='', + help='location of LHCb plot style file') return parser -def PrCheckerIPresolution(directory, name): +def PrCheckerIPresolution(directory, name, plotstyle): + sys.path.append(os.path.abspath(plotstyle)) + from LHCbStyle import setLHCbStyle + setLHCbStyle() + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') outputfile = TFile("IPResolution_plots.root", "recreate") tuples = f.Get("TrackIPResolutionCheckerNT/tracks") outputfile.cd() - # typeofprefix==0 for track from PV and matched with MC + ### typeofprefix==0 for track from PV and matched with MC cutAcc = "trueeta<5 && trueeta>2 && typeofprefix==0" print("Velo track from PV in acceptance: " + cutAcc) resIPx = TH2F("resIPx", "IPx:1/pt", 20, 0, 3, 100, -300, 300) diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py new file mode 100644 index 00000000000..793da862153 --- /dev/null +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -0,0 +1,143 @@ +############################################################################### +# (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. # +############################################################################### +''' + Script for the plots of tracking resolution v.s. p and eta + The resolution is fitted by a Gaussian function + + author: Peilian Li(peilian.li@cern.ch) + date: 01/2020 +''' + +import os, sys +import argparse +import ROOT +from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1, TH2, TF1 +from ROOT import gROOT, gStyle, TStyle, TPaveText, TString +from ROOT import ROOT, vector, TGraphAsymmErrors + +from collections import defaultdict + +#from collectRunResults import send_notification_mattermost + + +def argument_parser(): + parser = argparse.ArgumentParser( + description="location of the histogram file") + parser.add_argument( + '--directory', + type=str, + default=os.getcwd(), + help='location of input tuple files') + parser.add_argument( + '--name', + type=str, + default='Hlt1ForwardTrackingResolution', + help='name of input tuple files') + parser.add_argument( + '--plotstyle', + default='', + help='location of LHCb plot style file') + return parser + + +def PrCheckerTrackResolution(directory, name, plotstyle): + + sys.path.append(os.path.abspath(plotstyle)) + from LHCbStyle import setLHCbStyle + from Legend import place_legend + setLHCbStyle() + + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') + outputfile = TFile("TrackResolution_plots.root", "recreate") + outputfile.cd() + + hres_p= f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") + hres_eta= f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") + + hres_p.Write() + hres_eta.Write() + hres_p.FitSlicesY() + hres_eta.FitSlicesY() + + hres_p_2 = outputfile.Get("dpoverp_vs_p_2") + hres_eta_2 = outputfile.Get("dpoverp_vs_eta_2") + + canvas1 = TCanvas("res_p", "res v.s. p") + canvas1.cd() + for i in range(1, hres_p_2.GetNbinsX()): + hres_p_2.SetBinContent(i, hres_p_2.GetBinContent(i)*100) + + hres_p_2.Draw("E1 p1") + hres_p_2.SetTitle("dp/p:p") + hres_p_2.GetYaxis().SetTitle("dp/p [%]") + hres_p_2.GetXaxis().SetTitle("p [GeV/c]") + hres_p_2.GetYaxis().SetRangeUser(0, 1.2) + hmom = hres_p.ProjectionX() + hmom.SetTitle("p histo.") + hmom.Scale(0.3/hres_p.GetMaximum()) + hmom.Draw("hist same") + hmom.SetFillStyle(3004) + hmom.SetLineColor(kBlue-10) + hmom.SetFillColor(kBlue) + hmom.SetLineWidth(2) + + canvas1.PlaceLegend() + canvas1.SetRightMargin(0.05) + canvas1.Write() + + canvas2 = TCanvas("res_eta", "res v.s. eta") + canvas2.cd() + for i in range(1, hres_eta_2.GetNbinsX()): + hres_eta_2.SetBinContent(i, hres_eta_2.GetBinContent(i)*100) + + hres_eta_2.Draw("E1 p1") + hres_eta_2.SetTitle("dp/p:#eta") + hres_eta_2.GetYaxis().SetTitle("dp/p [%]") + hres_eta_2.GetXaxis().SetTitle("#eta") + hres_eta_2.GetYaxis().SetRangeUser(0, 1.2) + heta = hres_eta.ProjectionX() + heta.SetTitle("#eta histo.") + heta.Scale(0.1/hres_eta.GetMaximum()) + heta.Draw("hist same") + heta.SetFillStyle(3004) + heta.SetLineColor(kBlue-10) + heta.SetFillColor(kBlue) + heta.SetLineWidth(2) + + canvas2.PlaceLegend() + canvas2.SetRightMargin(0.05) + canvas2.Write() + + for i in range(1, hres_p_2.GetNbinsX()): + print("Track resolution (dp/p) in p region: (" + format(hres_p_2.GetBinLowEdge(i), '.2f') + + ", " + format( + hres_p_2.GetBinLowEdge(i) +hres_p_2.GetBinWidth(i), '.2f') + + ") [GeV/c]" + " --- " + + format(hres_p_2.GetBinContent(i), '.2f')+"%" ) + + print("-----------------------------------") + for i in range(1, hres_eta_2.GetNbinsX()): + print("Track resolution (dp/p) in eta region: (" + format(hres_eta_2.GetBinLowEdge(i), '.2f') + + ", " + format( + hres_eta_2.GetBinLowEdge(i) +hres_eta_2.GetBinWidth(i), '.2f') + + ")" + " --- " + + format(hres_eta_2.GetBinContent(i), '.2f')+"%" ) + + outputfile.Write() + outputfile.Close() + f.Close() + + +if __name__ == '__main__': + parser = argument_parser() + args = parser.parse_args() + PrCheckerTrackResolution(**vars(args)) diff --git a/Hlt/RecoConf/scripts/LHCbStyle.py b/Hlt/RecoConf/scripts/utils/LHCbStyle.py similarity index 100% rename from Hlt/RecoConf/scripts/LHCbStyle.py rename to Hlt/RecoConf/scripts/utils/LHCbStyle.py diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py new file mode 100644 index 00000000000..68ce9aaddf3 --- /dev/null +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -0,0 +1,117 @@ +import ROOT +import itertools +from ROOT import gStyle + +# Some convenience function to easily iterate over the parts of the collections + + +# Needed if importing this script from another script in case TMultiGraphs are used +#ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) + + +# Start a bit right of the Yaxis and above the Xaxis to not overlap with the ticks +start, stop = 0.18, 0.89 +x_width, y_width = 0.3, 0.2 +PLACES = [(start, stop - y_width, start + x_width, stop), # top left opt + (start, start, start + x_width, start + y_width), # bottom left opt + (stop - x_width, stop - y_width, stop, stop), # top right opt + (stop - x_width, start, stop, start + y_width), # bottom right opt + (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right + (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2)] # left + + +def transform_to_user(canvas, x1, y1, x2, y2): + """ + Transforms from Pad coordinates to User coordinates. + + This can probably be replaced by using the built-in conversion commands. + """ + xstart = canvas.GetX1() + xlength = canvas.GetX2() - xstart + xlow = xlength * x1 + xstart + xhigh = xlength * x2 + xstart + if canvas.GetLogx(): + xlow = 10**xlow + xhigh = 10**xhigh + + ystart = canvas.GetY1() + ylength = canvas.GetY2() - ystart + ylow = ylength * y1 + ystart + yhigh = ylength * y2 + ystart + if canvas.GetLogy(): + ylow = 10**ylow + yhigh = 10**yhigh + + return xlow, ylow, xhigh, yhigh + + +def overlap_h(hist, x1, y1, x2, y2): + xlow = hist.FindFixBin(x1) + xhigh = hist.FindFixBin(x2) + for i in range(xlow, xhigh + 1): + val = hist.GetBinContent(i) + # Values + if y1 <= val <= y2: + return True + # Errors + if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow(i) < y2: + # print "Overlap with histo", hist.GetName(), "at bin", i + return True + return False + + +def overlap_rect(rect1, rect2): + """Do the two rectangles overlap?""" + if rect1[0] > rect2[2] or rect1[2] < rect2[0]: + return False + if rect1[1] > rect2[3] or rect1[3] < rect2[1]: + return False + return True + +def overlap_g(graph, x1, y1, x2, y2): + x_values = list(graph.GetX()) + y_values = list(graph.GetY()) + x_err = list(graph.GetEX()) or [0] * len(x_values) + y_err = list(graph.GetEY()) or [0] * len(y_values) + + for x, ex, y, ey in zip(x_values, x_err, y_values, y_err): + # Could maybe be less conservative + if overlap_rect((x1, y1, x2, y2), (x - ex, y - ey, x + ex, y + ey)): + # print "Overlap with graph", graph.GetName(), "at point", (x, y) + return True + return False + +def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option="LPF"): + gStyle.SetFillStyle(0) + gStyle.SetTextSize(0.06) + # If position is specified, use that + if all(x is not None for x in (x1, x2, y1, y2)): + return canvas.BuildLegend(x1, y1, x2, y2, header, option) + + # Make sure all objects are correctly registered + canvas.Update() + + # Build a list of objects to check for overlaps + objects = [] + for x in canvas.GetListOfPrimitives(): + if isinstance(x, ROOT.TH1) or isinstance(x, ROOT.TGraph): + objects.append(x) + elif isinstance(x, ROOT.THStack) or isinstance(x, ROOT.TMultiGraph): + objects.extend(x) + + for place in PLACES: + place_user = canvas.PadtoU(*place) + # Make sure there are no overlaps + if any(obj.Overlap(*place_user) for obj in objects): + continue + return canvas.BuildLegend(place[0], place[1], place[2], place[3], header, option) + # As a fallback, use the default values, taken from TCanvas::BuildLegend + return canvas.BuildLegend(0.5, 0.67, 0.88, 0.88, header, option) + +# Monkey patch ROOT objects to make it all work +ROOT.THStack.__iter__ = lambda self: iter(self.GetHists()) +ROOT.TMultiGraph.__iter__ = lambda self: iter(self.GetListOfGraphs()) +ROOT.TH1.Overlap = overlap_h +ROOT.TGraph.Overlap = overlap_g +ROOT.TPad.PadtoU = transform_to_user +ROOT.TPad.PlaceLegend = place_legend diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt deleted file mode 100644 index 74c2cfa3668..00000000000 --- a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt +++ /dev/null @@ -1,31 +0,0 @@ - - - - -gaudirun.py - - $MOOREROOT/tests/options/default_input_and_conds_hlt1.py - $RECOCONFROOT/options/hlt1_reco_IPresolution.py - --output=hlt1_reco_IPresolution.opts.py - --all-opt - -true - - -from Moore.qmtest.exclusions import remove_known_warnings -countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, - stdout=remove_known_warnings(stdout)) - - - diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt deleted file mode 100644 index 0a10d19ac0d..00000000000 --- a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt +++ /dev/null @@ -1,31 +0,0 @@ - - - - -gaudirun.py - - $MOOREROOT/tests/options/default_input_and_conds_hlt1.py - $RECOCONFROOT/options/hlt1_reco_trackresolution.py - --output=hlt1_reco_trackresolution.opts.py - --all-opt - -true - - -from Moore.qmtest.exclusions import remove_known_warnings -countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, - stdout=remove_known_warnings(stdout)) - - - -- GitLab From 62316eeb0a747320519a6178e6b7d438ece58f55 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 10 Jan 2020 17:40:12 +0100 Subject: [PATCH 015/171] check copyright --- Hlt/RecoConf/scripts/utils/Legend.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index 68ce9aaddf3..4b7b9c4f6b2 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -1,10 +1,20 @@ +############################################################################### +# (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. # +############################################################################### + import ROOT import itertools from ROOT import gStyle # Some convenience function to easily iterate over the parts of the collections - # Needed if importing this script from another script in case TMultiGraphs are used #ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) -- GitLab From 1733cb0a6fb206c02addeeba14f39a2c0ddeda54 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 10 Jan 2020 16:40:51 +0000 Subject: [PATCH 016/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6736425 --- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 10 ++-- .../scripts/PrCheckerTrackResolution.py | 48 +++++++++---------- Hlt/RecoConf/scripts/utils/Legend.py | 32 +++++++++---- 3 files changed, 49 insertions(+), 41 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index e110da81343..cc3c1687c24 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -30,9 +30,9 @@ from collections import defaultdict #from collectRunResults import send_notification_mattermost + def argument_parser(): - parser = argparse.ArgumentParser( - description="location of the tuple file") + parser = argparse.ArgumentParser(description="location of the tuple file") parser.add_argument( '--directory', type=str, @@ -44,9 +44,7 @@ def argument_parser(): default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') parser.add_argument( - '--plotstyle', - default='', - help='location of LHCb plot style file') + '--plotstyle', default='', help='location of LHCb plot style file') return parser @@ -55,7 +53,7 @@ def PrCheckerIPresolution(directory, name, plotstyle): sys.path.append(os.path.abspath(plotstyle)) from LHCbStyle import setLHCbStyle setLHCbStyle() - + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') outputfile = TFile("IPResolution_plots.root", "recreate") diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index 793da862153..64dbf24a1f8 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -9,7 +9,7 @@ # or submit itself to any jurisdiction. # ############################################################################### ''' - Script for the plots of tracking resolution v.s. p and eta + Script for the plots of tracking resolution v.s. p and eta The resolution is fitted by a Gaussian function author: Peilian Li(peilian.li@cern.ch) @@ -43,9 +43,7 @@ def argument_parser(): default='Hlt1ForwardTrackingResolution', help='name of input tuple files') parser.add_argument( - '--plotstyle', - default='', - help='location of LHCb plot style file') + '--plotstyle', default='', help='location of LHCb plot style file') return parser @@ -55,13 +53,13 @@ def PrCheckerTrackResolution(directory, name, plotstyle): from LHCbStyle import setLHCbStyle from Legend import place_legend setLHCbStyle() - + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') outputfile = TFile("TrackResolution_plots.root", "recreate") outputfile.cd() - hres_p= f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") - hres_eta= f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") + hres_p = f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") + hres_eta = f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") hres_p.Write() hres_eta.Write() @@ -74,7 +72,7 @@ def PrCheckerTrackResolution(directory, name, plotstyle): canvas1 = TCanvas("res_p", "res v.s. p") canvas1.cd() for i in range(1, hres_p_2.GetNbinsX()): - hres_p_2.SetBinContent(i, hres_p_2.GetBinContent(i)*100) + hres_p_2.SetBinContent(i, hres_p_2.GetBinContent(i) * 100) hres_p_2.Draw("E1 p1") hres_p_2.SetTitle("dp/p:p") @@ -83,13 +81,13 @@ def PrCheckerTrackResolution(directory, name, plotstyle): hres_p_2.GetYaxis().SetRangeUser(0, 1.2) hmom = hres_p.ProjectionX() hmom.SetTitle("p histo.") - hmom.Scale(0.3/hres_p.GetMaximum()) + hmom.Scale(0.3 / hres_p.GetMaximum()) hmom.Draw("hist same") hmom.SetFillStyle(3004) - hmom.SetLineColor(kBlue-10) + hmom.SetLineColor(kBlue - 10) hmom.SetFillColor(kBlue) hmom.SetLineWidth(2) - + canvas1.PlaceLegend() canvas1.SetRightMargin(0.05) canvas1.Write() @@ -97,7 +95,7 @@ def PrCheckerTrackResolution(directory, name, plotstyle): canvas2 = TCanvas("res_eta", "res v.s. eta") canvas2.cd() for i in range(1, hres_eta_2.GetNbinsX()): - hres_eta_2.SetBinContent(i, hres_eta_2.GetBinContent(i)*100) + hres_eta_2.SetBinContent(i, hres_eta_2.GetBinContent(i) * 100) hres_eta_2.Draw("E1 p1") hres_eta_2.SetTitle("dp/p:#eta") @@ -106,10 +104,10 @@ def PrCheckerTrackResolution(directory, name, plotstyle): hres_eta_2.GetYaxis().SetRangeUser(0, 1.2) heta = hres_eta.ProjectionX() heta.SetTitle("#eta histo.") - heta.Scale(0.1/hres_eta.GetMaximum()) + heta.Scale(0.1 / hres_eta.GetMaximum()) heta.Draw("hist same") heta.SetFillStyle(3004) - heta.SetLineColor(kBlue-10) + heta.SetLineColor(kBlue - 10) heta.SetFillColor(kBlue) heta.SetLineWidth(2) @@ -118,19 +116,19 @@ def PrCheckerTrackResolution(directory, name, plotstyle): canvas2.Write() for i in range(1, hres_p_2.GetNbinsX()): - print("Track resolution (dp/p) in p region: (" + format(hres_p_2.GetBinLowEdge(i), '.2f') + - ", " + format( - hres_p_2.GetBinLowEdge(i) +hres_p_2.GetBinWidth(i), '.2f') + - ") [GeV/c]" + " --- " + - format(hres_p_2.GetBinContent(i), '.2f')+"%" ) + print("Track resolution (dp/p) in p region: (" + + format(hres_p_2.GetBinLowEdge(i), '.2f') + ", " + format( + hres_p_2.GetBinLowEdge(i) + hres_p_2.GetBinWidth(i), '.2f') + + ") [GeV/c]" + " --- " + + format(hres_p_2.GetBinContent(i), '.2f') + "%") print("-----------------------------------") - for i in range(1, hres_eta_2.GetNbinsX()): - print("Track resolution (dp/p) in eta region: (" + format(hres_eta_2.GetBinLowEdge(i), '.2f') + - ", " + format( - hres_eta_2.GetBinLowEdge(i) +hres_eta_2.GetBinWidth(i), '.2f') + - ")" + " --- " + - format(hres_eta_2.GetBinContent(i), '.2f')+"%" ) + for i in range(1, hres_eta_2.GetNbinsX()): + print("Track resolution (dp/p) in eta region: (" + + format(hres_eta_2.GetBinLowEdge(i), '.2f') + ", " + format( + hres_eta_2.GetBinLowEdge(i) + + hres_eta_2.GetBinWidth(i), '.2f') + ")" + " --- " + + format(hres_eta_2.GetBinContent(i), '.2f') + "%") outputfile.Write() outputfile.Close() diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index 4b7b9c4f6b2..771c38e290d 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -18,16 +18,17 @@ from ROOT import gStyle # Needed if importing this script from another script in case TMultiGraphs are used #ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) - # Start a bit right of the Yaxis and above the Xaxis to not overlap with the ticks start, stop = 0.18, 0.89 x_width, y_width = 0.3, 0.2 -PLACES = [(start, stop - y_width, start + x_width, stop), # top left opt - (start, start, start + x_width, start + y_width), # bottom left opt - (stop - x_width, stop - y_width, stop, stop), # top right opt - (stop - x_width, start, stop, start + y_width), # bottom right opt - (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right - (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2)] # left +PLACES = [ + (start, stop - y_width, start + x_width, stop), # top left opt + (start, start, start + x_width, start + y_width), # bottom left opt + (stop - x_width, stop - y_width, stop, stop), # top right opt + (stop - x_width, start, stop, start + y_width), # bottom right opt + (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right + (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2) +] # left def transform_to_user(canvas, x1, y1, x2, y2): @@ -64,7 +65,8 @@ def overlap_h(hist, x1, y1, x2, y2): if y1 <= val <= y2: return True # Errors - if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow(i) < y2: + if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow( + i) < y2: # print "Overlap with histo", hist.GetName(), "at bin", i return True return False @@ -78,6 +80,7 @@ def overlap_rect(rect1, rect2): return False return True + def overlap_g(graph, x1, y1, x2, y2): x_values = list(graph.GetX()) y_values = list(graph.GetY()) @@ -91,7 +94,14 @@ def overlap_g(graph, x1, y1, x2, y2): return True return False -def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option="LPF"): + +def place_legend(canvas, + x1=None, + y1=None, + x2=None, + y2=None, + header="", + option="LPF"): gStyle.SetFillStyle(0) gStyle.SetTextSize(0.06) # If position is specified, use that @@ -114,10 +124,12 @@ def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option=" # Make sure there are no overlaps if any(obj.Overlap(*place_user) for obj in objects): continue - return canvas.BuildLegend(place[0], place[1], place[2], place[3], header, option) + return canvas.BuildLegend(place[0], place[1], place[2], place[3], + header, option) # As a fallback, use the default values, taken from TCanvas::BuildLegend return canvas.BuildLegend(0.5, 0.67, 0.88, 0.88, header, option) + # Monkey patch ROOT objects to make it all work ROOT.THStack.__iter__ = lambda self: iter(self.GetHists()) ROOT.TMultiGraph.__iter__ = lambda self: iter(self.GetListOfGraphs()) -- GitLab From 35191570b36882d598545618a268c0147ebc7648 Mon Sep 17 00:00:00 2001 From: Tomasz Wojton Date: Wed, 15 Jan 2020 23:00:57 +0100 Subject: [PATCH 017/171] PVChecker functional changes --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 42 +++++++++++++++++++++ Hlt/RecoConf/python/RecoConf/standalone.py | 5 ++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 06a26e0c006..efaa45b0e7c 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -13,6 +13,7 @@ from __future__ import absolute_import, division, print_function In this file, algorithms needed to run the MC reconstruction checking (PrTrackChecker) are defined. ''' from PyConf.tonic import (configurable) +from PyConf.dataflow import DataHandle from PyConf.components import Tool from PyConf.application import default_raw_event @@ -25,8 +26,10 @@ from PyConf.Algorithms import ( PrTrackAssociator, PrTrackChecker, PrUTHitChecker, + PrimaryVertexChecker ) +from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool from RecoConf.hlt1_tracking import ( @@ -265,6 +268,45 @@ def get_best_tracks_checkers( return efficiency_checkers +@configurable +def get_pv_checkers( + pvs, + tracks, + match_by_distance = False, + produce_ntuple = False, + make_links_lhcbids_mcparticles=make_links_lhcbids_mcparticles_tracking_system +): + + assert isinstance( + pvs, + DataHandle), "Please provide a dictionary of track type and tracks" + + pv_checkers = [] + + vertexConverter = FromVectorLHCbRecVertex( + InputVerticesName=pvs, + InputTracksName=tracks["v1"]).OutputVerticesName + + +# if not match_by_distance: +# links_to_lhcbids = make_links_lhcbids_mcparticles() +# links_to_tracks = make_links_tracks_mcparticles( +# InputTracks=tracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + + pvchecker = PrimaryVertexChecker(produceNtuple = produce_ntuple, + matchByTracks = match_by_distance, + inputVerticesName = vertexConverter, + inputTracksName = tracks["v1"] + ) + + pv_checkers.append(vertexConverter) + pv_checkers.append(pvchecker) +# pv_checkers.append(vertexConverter) + + return pv_checkers + + + def make_track_filter(InputTracks, code): from PyConf.Algorithms import TrackListRefiner from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 6371d9878ec..c236dce45c7 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -20,7 +20,7 @@ from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks from .calorimeter_reconstruction import make_calo -from .mc_checking import get_track_checkers, get_best_tracks_checkers +from .mc_checking import get_track_checkers, get_best_tracks_checkers, get_pv_checkers from .reco_objects_from_file import reconstruction from PyConf.application import default_raw_event from .rich_reconstruction import make_rich_pids, make_rich_pixels, default_rich_reco_options @@ -62,6 +62,9 @@ def standalone_hlt1_reco(do_mc_checking=False): "Forward": hlt1_tracks["Forward"], } data += get_track_checkers(types_and_locations_for_checkers) + print hlt1_tracks["Velo"] + print pvs + data += get_pv_checkers(pvs, hlt1_tracks["Velo"]) return Reconstruction('hlt1_reco', data, reco_prefilters()) -- GitLab From b8d73550cfef0061694cf76a63e5101a8a7cf708 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 15 Jan 2020 22:02:07 +0000 Subject: [PATCH 018/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6789766 --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 54 +++++++++------------ 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index efaa45b0e7c..82b57b8cc78 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -20,14 +20,9 @@ from PyConf.application import default_raw_event from PyConf.application import make_data_with_FetchDataFromFile from PyConf.Algorithms import ( - VPFullCluster2MCParticleLinker, - PrLHCbID2MCParticle, - PrLHCbID2MCParticleVPUTFTMU, - PrTrackAssociator, - PrTrackChecker, - PrUTHitChecker, - PrimaryVertexChecker -) + VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, + PrLHCbID2MCParticleVPUTFTMU, PrTrackAssociator, PrTrackChecker, + PrUTHitChecker, PrimaryVertexChecker) from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool @@ -270,41 +265,38 @@ def get_best_tracks_checkers( @configurable def get_pv_checkers( - pvs, - tracks, - match_by_distance = False, - produce_ntuple = False, + pvs, + tracks, + match_by_distance=False, + produce_ntuple=False, make_links_lhcbids_mcparticles=make_links_lhcbids_mcparticles_tracking_system ): assert isinstance( pvs, DataHandle), "Please provide a dictionary of track type and tracks" - + pv_checkers = [] vertexConverter = FromVectorLHCbRecVertex( - InputVerticesName=pvs, - InputTracksName=tracks["v1"]).OutputVerticesName - - -# if not match_by_distance: -# links_to_lhcbids = make_links_lhcbids_mcparticles() -# links_to_tracks = make_links_tracks_mcparticles( -# InputTracks=tracks["v1"], LinksToLHCbIDs=links_to_lhcbids) - - pvchecker = PrimaryVertexChecker(produceNtuple = produce_ntuple, - matchByTracks = match_by_distance, - inputVerticesName = vertexConverter, - inputTracksName = tracks["v1"] - ) + InputVerticesName=pvs, InputTracksName=tracks["v1"]).OutputVerticesName - pv_checkers.append(vertexConverter) - pv_checkers.append(pvchecker) -# pv_checkers.append(vertexConverter) + # if not match_by_distance: + # links_to_lhcbids = make_links_lhcbids_mcparticles() + # links_to_tracks = make_links_tracks_mcparticles( + # InputTracks=tracks["v1"], LinksToLHCbIDs=links_to_lhcbids) - return pv_checkers + pvchecker = PrimaryVertexChecker( + produceNtuple=produce_ntuple, + matchByTracks=match_by_distance, + inputVerticesName=vertexConverter, + inputTracksName=tracks["v1"]) + + pv_checkers.append(vertexConverter) + pv_checkers.append(pvchecker) + # pv_checkers.append(vertexConverter) + return pv_checkers def make_track_filter(InputTracks, code): -- GitLab From 4592617a11f2a445057dbd94e270510fc7c8cd95 Mon Sep 17 00:00:00 2001 From: Tomasz Wojton Date: Thu, 16 Jan 2020 16:09:44 +0100 Subject: [PATCH 019/171] distance matching, RecoVertex_v2 --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 22 +++++++-------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 82b57b8cc78..be64fe5f9a0 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -267,7 +267,6 @@ def get_best_tracks_checkers( def get_pv_checkers( pvs, tracks, - match_by_distance=False, produce_ntuple=False, make_links_lhcbids_mcparticles=make_links_lhcbids_mcparticles_tracking_system ): @@ -278,24 +277,16 @@ def get_pv_checkers( pv_checkers = [] - vertexConverter = FromVectorLHCbRecVertex( - InputVerticesName=pvs, InputTracksName=tracks["v1"]).OutputVerticesName - - # if not match_by_distance: - # links_to_lhcbids = make_links_lhcbids_mcparticles() - # links_to_tracks = make_links_tracks_mcparticles( - # InputTracks=tracks["v1"], LinksToLHCbIDs=links_to_lhcbids) - pvchecker = PrimaryVertexChecker( produceNtuple=produce_ntuple, - matchByTracks=match_by_distance, - inputVerticesName=vertexConverter, - inputTracksName=tracks["v1"]) + inputVerticesName=pvs, + inputTracksName=tracks["v1"], + MCVertexInput=mc_unpackers()["MCVertices"], + # MCParticleInput=mc_unpackers()["MCParticles"], + # LinkerLocation=links_to_tracks, + MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header")) - pv_checkers.append(vertexConverter) pv_checkers.append(pvchecker) - # pv_checkers.append(vertexConverter) - return pv_checkers @@ -306,3 +297,4 @@ def make_track_filter(InputTracks, code): filtered_tracks = TrackListRefiner( inputLocation=InputTracks["v1"], Selector=selector).outputLocation return filtered_tracks + -- GitLab From f6f877d080e8c676fb50ccd8efb9ca324fd271f2 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Wed, 18 Dec 2019 17:42:39 +0100 Subject: [PATCH 020/171] add track and IP resolution checker --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 06a26e0c006..06ba967b5b5 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -272,3 +272,35 @@ def make_track_filter(InputTracks, code): filtered_tracks = TrackListRefiner( inputLocation=InputTracks["v1"], Selector=selector).outputLocation return filtered_tracks + +def monitor_track_resolution(InputTracks): + from PyConf.Algorithms import TrackResChecker + links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() + links_to_tracks = make_links_tracks_mcparticles(InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + res_checker = TrackResChecker( + TracksInContainer= InputTracks["v1"], + MCParticleInContainer= mc_unpackers()["MCParticles"], + MCPropertyInput = make_data_with_FetchDataFromFile( "/Event/MC/TrackInfo" ), + LinkerInTable = links_to_tracks + ) + return res_checker + + +def monitor_IPresolution(InputTracks): + from PyConf.Algorithms import TrackIPResolutionCheckerNTMCHits, TrackIPResolutionCheckerNT + from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex + from PyConf.Algorithms import DataPacking__Unpack_LHCb__MCVPHitPacker_ + unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_(InputName=make_data_with_FetchDataFromFile( "/Event/pSim/VP/Hits" )) + vertexConverter = FromVectorLHCbRecVertex(InputVerticesName=pvs, InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName + links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() + links_to_tracks = make_links_tracks_mcparticles(InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + IPres_checker= TrackIPResolutionCheckerNTMCHits( + TrackContainer= InputTracks, + MCParticleInput= mc_unpackers()["MCParticles"], + MCHeaderLocation= make_data_with_FetchDataFromFile("/Event/MC/Header"), + LinkerLocation= links_to_tracks, + PVContainer= vertexConverter, + MCHitsLocation= unpacked_velo_mchits, + NTupleLUN = "FILE1") + return IPres_checker + -- GitLab From 750dc250bddf8f178aef7b4b1c8dae0d40bbab69 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 18 Dec 2019 16:43:35 +0000 Subject: [PATCH 021/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6602383 --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 41 ++++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 06ba967b5b5..0117deca6a8 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -273,16 +273,18 @@ def make_track_filter(InputTracks, code): inputLocation=InputTracks["v1"], Selector=selector).outputLocation return filtered_tracks + def monitor_track_resolution(InputTracks): from PyConf.Algorithms import TrackResChecker links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() - links_to_tracks = make_links_tracks_mcparticles(InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + links_to_tracks = make_links_tracks_mcparticles( + InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) res_checker = TrackResChecker( - TracksInContainer= InputTracks["v1"], - MCParticleInContainer= mc_unpackers()["MCParticles"], - MCPropertyInput = make_data_with_FetchDataFromFile( "/Event/MC/TrackInfo" ), - LinkerInTable = links_to_tracks - ) + TracksInContainer=InputTracks["v1"], + MCParticleInContainer=mc_unpackers()["MCParticles"], + MCPropertyInput=make_data_with_FetchDataFromFile( + "/Event/MC/TrackInfo"), + LinkerInTable=links_to_tracks) return res_checker @@ -290,17 +292,20 @@ def monitor_IPresolution(InputTracks): from PyConf.Algorithms import TrackIPResolutionCheckerNTMCHits, TrackIPResolutionCheckerNT from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex from PyConf.Algorithms import DataPacking__Unpack_LHCb__MCVPHitPacker_ - unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_(InputName=make_data_with_FetchDataFromFile( "/Event/pSim/VP/Hits" )) - vertexConverter = FromVectorLHCbRecVertex(InputVerticesName=pvs, InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName + unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_( + InputName=make_data_with_FetchDataFromFile("/Event/pSim/VP/Hits")) + vertexConverter = FromVectorLHCbRecVertex( + InputVerticesName=pvs, + InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() - links_to_tracks = make_links_tracks_mcparticles(InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) - IPres_checker= TrackIPResolutionCheckerNTMCHits( - TrackContainer= InputTracks, - MCParticleInput= mc_unpackers()["MCParticles"], - MCHeaderLocation= make_data_with_FetchDataFromFile("/Event/MC/Header"), - LinkerLocation= links_to_tracks, - PVContainer= vertexConverter, - MCHitsLocation= unpacked_velo_mchits, - NTupleLUN = "FILE1") + links_to_tracks = make_links_tracks_mcparticles( + InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + IPres_checker = TrackIPResolutionCheckerNTMCHits( + TrackContainer=InputTracks, + MCParticleInput=mc_unpackers()["MCParticles"], + MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), + LinkerLocation=links_to_tracks, + PVContainer=vertexConverter, + MCHitsLocation=unpacked_velo_mchits, + NTupleLUN="FILE1") return IPres_checker - -- GitLab From 80a9a08429ada93707ce869049c3cec195d64141 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 19 Dec 2019 09:47:47 +0100 Subject: [PATCH 022/171] modify the format --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 0117deca6a8..3f31bfc2217 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -13,6 +13,7 @@ from __future__ import absolute_import, division, print_function In this file, algorithms needed to run the MC reconstruction checking (PrTrackChecker) are defined. ''' from PyConf.tonic import (configurable) +from PyConf.dataflow import DataHandle from PyConf.components import Tool from PyConf.application import default_raw_event @@ -25,9 +26,15 @@ from PyConf.Algorithms import ( PrTrackAssociator, PrTrackChecker, PrUTHitChecker, + TrackListRefiner, + TrackResChecker, + TrackIPResolutionCheckerNT, + DataPacking__Unpack_LHCb__MCVPHitPacker_ ) +from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool +from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector from RecoConf.hlt1_tracking import ( make_PrStoreUTHit_hits, @@ -47,7 +54,6 @@ def get_item(x, key): TODO: This helper function can be replaces once Moore!63 has been addressed. """ - from PyConf.dataflow import DataHandle if isinstance(x, DataHandle): return x return x[key] @@ -266,8 +272,6 @@ def get_best_tracks_checkers( def make_track_filter(InputTracks, code): - from PyConf.Algorithms import TrackListRefiner - from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector selector = LoKiTrackSelector(Code=code, StatPrint=True) filtered_tracks = TrackListRefiner( inputLocation=InputTracks["v1"], Selector=selector).outputLocation @@ -275,7 +279,6 @@ def make_track_filter(InputTracks, code): def monitor_track_resolution(InputTracks): - from PyConf.Algorithms import TrackResChecker links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) @@ -289,9 +292,6 @@ def monitor_track_resolution(InputTracks): def monitor_IPresolution(InputTracks): - from PyConf.Algorithms import TrackIPResolutionCheckerNTMCHits, TrackIPResolutionCheckerNT - from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex - from PyConf.Algorithms import DataPacking__Unpack_LHCb__MCVPHitPacker_ unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_( InputName=make_data_with_FetchDataFromFile("/Event/pSim/VP/Hits")) vertexConverter = FromVectorLHCbRecVertex( @@ -300,12 +300,11 @@ def monitor_IPresolution(InputTracks): links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) - IPres_checker = TrackIPResolutionCheckerNTMCHits( + IPres_checker = TrackIPResolutionCheckerNT( TrackContainer=InputTracks, MCParticleInput=mc_unpackers()["MCParticles"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), LinkerLocation=links_to_tracks, PVContainer=vertexConverter, - MCHitsLocation=unpacked_velo_mchits, NTupleLUN="FILE1") return IPres_checker -- GitLab From a05fdbe857fe476ed13c75c066ad8dab5f0f16c1 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 19 Dec 2019 19:32:42 +0100 Subject: [PATCH 023/171] remove unused lines --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 3f31bfc2217..425db41c6f7 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -292,8 +292,6 @@ def monitor_track_resolution(InputTracks): def monitor_IPresolution(InputTracks): - unpacked_velo_mchits = DataPacking__Unpack_LHCb__MCVPHitPacker_( - InputName=make_data_with_FetchDataFromFile("/Event/pSim/VP/Hits")) vertexConverter = FromVectorLHCbRecVertex( InputVerticesName=pvs, InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName -- GitLab From f91f4efcddb8e81c0e6f718277dbe92adb95039c Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 20 Dec 2019 15:58:30 +0100 Subject: [PATCH 024/171] add options and qmt test for track and IP resolution --- .../options/hlt1_reco_IPresolution.py | 30 ++++++++++++++++++ .../options/hlt1_reco_trackresolution.py | 31 +++++++++++++++++++ Hlt/RecoConf/python/RecoConf/mc_checking.py | 12 +++---- .../tests/qmtest/hlt1_reco_IPresolution.qmt | 31 +++++++++++++++++++ .../qmtest/hlt1_reco_trackresolution.qmt | 31 +++++++++++++++++++ 5 files changed, 129 insertions(+), 6 deletions(-) create mode 100644 Hlt/RecoConf/options/hlt1_reco_IPresolution.py create mode 100644 Hlt/RecoConf/options/hlt1_reco_trackresolution.py create mode 100644 Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt create mode 100644 Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py new file mode 100644 index 00000000000..cb8c615e608 --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -0,0 +1,30 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks +from RecoConf.mc_checking import monitor_IPresolution +from Configurables import ApplicationMgr +from Configurables import NTupleSvc + + +def hlt1_reco_IPresolution(): + hlt1_tracks = make_hlt1_tracks() + fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) + pr_checker = monitor_IPresolution(fitted_tracks["v1"], hlt1_tracks["Velo"]["v1"]) + + return Reconstruction('IPresolution', [pr_checker], [require_gec()]) + +run_reconstruction(options, hlt1_reco_IPresolution) + +NTupleSvc().Output += ["FILE1 DATAFILE='Hlt1ForwardTracking_IPresolution.root' TYPE='ROOT' OPT='NEW'"] +ApplicationMgr().ExtSvc += [NTupleSvc()] +ApplicationMgr().HistogramPersistency="ROOT" diff --git a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py new file mode 100644 index 00000000000..c0f1006915b --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py @@ -0,0 +1,31 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks +from RecoConf.mc_checking import monitor_track_resolution + + +def hlt1_reco_trackresolution(): + track_type = "Forward" + tracks = make_hlt1_tracks()[track_type] + pr_checker = monitor_track_resolution( tracks) + + #return CompositeNode( + # name='hlt1_trackRes', + # children=pr_checker, + # combineLogic=NodeLogic.NONLAZY_OR, + # forceOrder=False) + return Reconstruction('track_resolution', [pr_checker], [require_gec()]) + + +options.histo_file = "Hlt1ForwardTrackingResolution.root" +run_reconstruction(options, hlt1_reco_trackresolution) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 425db41c6f7..42a86e16633 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -40,6 +40,7 @@ from RecoConf.hlt1_tracking import ( make_PrStoreUTHit_hits, make_FTRawBankDecoder_clusters, make_velo_full_clusters, + make_pvs ) from Hlt2Conf.data_from_file import mc_unpackers @@ -285,19 +286,18 @@ def monitor_track_resolution(InputTracks): res_checker = TrackResChecker( TracksInContainer=InputTracks["v1"], MCParticleInContainer=mc_unpackers()["MCParticles"], - MCPropertyInput=make_data_with_FetchDataFromFile( - "/Event/MC/TrackInfo"), LinkerInTable=links_to_tracks) return res_checker -def monitor_IPresolution(InputTracks): +def monitor_IPresolution(InputTracks, VeloTracks): + vertexConverter = FromVectorLHCbRecVertex( - InputVerticesName=pvs, - InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName + InputVerticesName=make_pvs(), + InputTracksName=VeloTracks).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( - InputTracks["v1"], LinksToLHCbIDs=links_to_lhcbids) + InputTracks, LinksToLHCbIDs=links_to_lhcbids) IPres_checker = TrackIPResolutionCheckerNT( TrackContainer=InputTracks, MCParticleInput=mc_unpackers()["MCParticles"], diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt new file mode 100644 index 00000000000..e34dcba158c --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt @@ -0,0 +1,31 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $RECOCONFROOT/options/hlt1_reco_IPresolution.py + --output=hlt1_reco_IPresolution.opts.py + --all-opt + +true + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt new file mode 100644 index 00000000000..38c0cdc0b83 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt @@ -0,0 +1,31 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $RECOCONFROOT/options/hlt1_reco_trackresolution.py + --output=hlt1_reco_trackresolution.opts.py + --all-opt + +true + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + -- GitLab From 31c2264919188b4243d7f83362a24cdf10ca7663 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 20 Dec 2019 14:59:09 +0000 Subject: [PATCH 025/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6623848 --- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 10 +++++++--- Hlt/RecoConf/options/hlt1_reco_trackresolution.py | 4 ++-- Hlt/RecoConf/python/RecoConf/mc_checking.py | 9 +++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index cb8c615e608..2d3221e8b59 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -19,12 +19,16 @@ from Configurables import NTupleSvc def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) - pr_checker = monitor_IPresolution(fitted_tracks["v1"], hlt1_tracks["Velo"]["v1"]) + pr_checker = monitor_IPresolution(fitted_tracks["v1"], + hlt1_tracks["Velo"]["v1"]) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) + run_reconstruction(options, hlt1_reco_IPresolution) -NTupleSvc().Output += ["FILE1 DATAFILE='Hlt1ForwardTracking_IPresolution.root' TYPE='ROOT' OPT='NEW'"] +NTupleSvc().Output += [ + "FILE1 DATAFILE='Hlt1ForwardTracking_IPresolution.root' TYPE='ROOT' OPT='NEW'" +] ApplicationMgr().ExtSvc += [NTupleSvc()] -ApplicationMgr().HistogramPersistency="ROOT" +ApplicationMgr().HistogramPersistency = "ROOT" diff --git a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py index c0f1006915b..b540ab11836 100644 --- a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py @@ -11,13 +11,13 @@ from Moore import options, run_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks -from RecoConf.mc_checking import monitor_track_resolution +from RecoConf.mc_checking import monitor_track_resolution def hlt1_reco_trackresolution(): track_type = "Forward" tracks = make_hlt1_tracks()[track_type] - pr_checker = monitor_track_resolution( tracks) + pr_checker = monitor_track_resolution(tracks) #return CompositeNode( # name='hlt1_trackRes', diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 42a86e16633..04678f1eeb1 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -36,12 +36,9 @@ from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRec from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector -from RecoConf.hlt1_tracking import ( - make_PrStoreUTHit_hits, - make_FTRawBankDecoder_clusters, - make_velo_full_clusters, - make_pvs -) +from RecoConf.hlt1_tracking import (make_PrStoreUTHit_hits, + make_FTRawBankDecoder_clusters, + make_velo_full_clusters, make_pvs) from Hlt2Conf.data_from_file import mc_unpackers -- GitLab From faf438f63fb774de88abf6cabc8279d6036cd4d1 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 9 Jan 2020 17:46:24 +0100 Subject: [PATCH 026/171] add script for reading IPresolution tuples --- Hlt/RecoConf/scripts/LHCbStyle.py | 104 +++++++++++++ Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 146 ++++++++++++++++++ 2 files changed, 250 insertions(+) create mode 100644 Hlt/RecoConf/scripts/LHCbStyle.py create mode 100644 Hlt/RecoConf/scripts/PrCheckerIPresolution.py diff --git a/Hlt/RecoConf/scripts/LHCbStyle.py b/Hlt/RecoConf/scripts/LHCbStyle.py new file mode 100644 index 00000000000..e57b3fe3876 --- /dev/null +++ b/Hlt/RecoConf/scripts/LHCbStyle.py @@ -0,0 +1,104 @@ +from ROOT import gStyle +from ROOT import gROOT +from ROOT import TStyle + +def setLHCbStyle() : + global lhcbStyle + + lhcbFont = 132 + lhcbTSize = 0.06 + lhcbWidth = 2 + + lhcbStyle= TStyle("lhcbStyle","LHCb plots style"); + lhcbStyle.SetFillColor(1) + lhcbStyle.SetFillStyle(1001) # solid + lhcbStyle.SetFrameFillColor(0) + lhcbStyle.SetFrameBorderMode(0) + lhcbStyle.SetPadBorderMode(0) + lhcbStyle.SetPadColor(0) + lhcbStyle.SetCanvasBorderMode(0) + lhcbStyle.SetCanvasColor(0) + lhcbStyle.SetStatColor(0) + lhcbStyle.SetLegendBorderSize(0) + lhcbStyle.SetLegendFont(132) + + # use large fonts + lhcbStyle.SetTextFont(lhcbFont) + lhcbStyle.SetTitleFont(lhcbFont) + lhcbStyle.SetTextSize(lhcbTSize) + lhcbStyle.SetLabelFont(lhcbFont,"x") + lhcbStyle.SetLabelFont(lhcbFont,"y") + lhcbStyle.SetLabelFont(lhcbFont,"z") + lhcbStyle.SetLabelSize(lhcbTSize,"x") + lhcbStyle.SetLabelSize(lhcbTSize,"y") + lhcbStyle.SetLabelSize(lhcbTSize,"z") + lhcbStyle.SetTitleFont(lhcbFont) + lhcbStyle.SetTitleFont(lhcbFont,"x") + lhcbStyle.SetTitleFont(lhcbFont,"y") + lhcbStyle.SetTitleFont(lhcbFont,"z") + lhcbStyle.SetTitleSize(1.2*lhcbTSize,"x") + lhcbStyle.SetTitleSize(1.2*lhcbTSize,"y") + lhcbStyle.SetTitleSize(1.2*lhcbTSize,"z") + + # set the paper & margin sizes + lhcbStyle.SetPaperSize(20,26) + lhcbStyle.SetPadTopMargin(0.05) + lhcbStyle.SetPadRightMargin(0.05) # increase for colz plots + lhcbStyle.SetPadBottomMargin(0.16) + lhcbStyle.SetPadLeftMargin(0.14) + + # use medium bold lines and thick markers + lhcbStyle.SetLineWidth(lhcbWidth); + lhcbStyle.SetFrameLineWidth(lhcbWidth); + lhcbStyle.SetHistLineWidth(lhcbWidth); + lhcbStyle.SetFuncWidth(lhcbWidth); + lhcbStyle.SetGridWidth(lhcbWidth); + lhcbStyle.SetLineStyleString(2,"[12 12]"); # postscript dashes + lhcbStyle.SetMarkerStyle(20); + lhcbStyle.SetMarkerSize(1.0); + + # label offsets + lhcbStyle.SetLabelOffset(0.010,"X"); + lhcbStyle.SetLabelOffset(0.010,"Y"); + + # by default, do not display histogram decorations: + lhcbStyle.SetOptStat(0) + #lhcbStyle.SetOptStat("emr") # show only nent -e , mean - m , rms -r + # full opts at http:#root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat + lhcbStyle.SetStatFormat("6.3g") # specified as c printf options + lhcbStyle.SetOptTitle(0) + lhcbStyle.SetOptFit(0) + #lhcbStyle.SetOptFit(1011) # order is probability, Chi2, errors, parameters + #titles + lhcbStyle.SetTitleOffset(0.85,"X") + lhcbStyle.SetTitleOffset(0.85,"Y") + lhcbStyle.SetTitleOffset(1.2,"Z") + lhcbStyle.SetTitleFillColor(0) + lhcbStyle.SetTitleStyle(0) + lhcbStyle.SetTitleBorderSize(0) + lhcbStyle.SetTitleFont(lhcbFont,"title") + lhcbStyle.SetTitleX(0.0) + lhcbStyle.SetTitleY(1.0) + lhcbStyle.SetTitleW(1.0) + lhcbStyle.SetTitleH(0.05) + + # look of the statistics box: + lhcbStyle.SetStatBorderSize(0) + lhcbStyle.SetStatFont(lhcbFont) + lhcbStyle.SetStatFontSize(0.05) + lhcbStyle.SetStatX(0.9) + lhcbStyle.SetStatY(0.9) + lhcbStyle.SetStatW(0.25) + lhcbStyle.SetStatH(0.15) + + # put tick marks on top and RHS of plots + lhcbStyle.SetPadTickX(1) + lhcbStyle.SetPadTickY(1) + + # histogram divisions: only 5 in x to avoid label overlaps + lhcbStyle.SetNdivisions(505,"x") + lhcbStyle.SetNdivisions(510,"y") + + gROOT.SetStyle("lhcbStyle") + return + diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py new file mode 100644 index 00000000000..1e035c09c9a --- /dev/null +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -0,0 +1,146 @@ +#!/usr/bin/python + +# Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution +# as well as a check of the IP error distribution and efficiencies in different chi2 cut. +# +# The resolution is fitted by a Gaussian function +# +# author: Peilian Li(peilian.li@cern.ch) +# date: 01/2020 +# + +import os,sys +import argparse +import ROOT +from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 +from ROOT import gROOT, gStyle, TStyle, TPaveText, TString +from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors + +from collections import defaultdict +from LHCbStyle import setLHCbStyle +setLHCbStyle() +#from collectRunResults import send_notification_mattermost + + +def argument_parser(): + parser = argparse.ArgumentParser(description="path of the tuple file location") + parser.add_argument('--directory', type=str, default=os.getcwd(), help='location of input tuple files') + parser.add_argument('--name', type=str, default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') + return parser + +def PrCheckerIPresolution(directory, name): + + f = TFile.Open(os.path.join(directory,name+'.root'), 'read') + outputfile = TFile( "IPResolution_plots.root", "recreate" ) + + tuples = f.Get("TrackIPResolutionCheckerNT/tracks"); + outputfile.cd() + + # typeofprefix==0 for track from PV and matched with MC + cutAcc= "trueeta<5 && trueeta>2 && typeofprefix==0" + print ("Velo track from PV in acceptance: " + cutAcc) + resIPx=TH2F("resIPx", "IPx:1/pt", 20, 0, 3, 100, -300, 300) + resIPy=TH2F("resIPy", "IPy:1/pt", 20, 0, 3, 100, -300, 300) + resIPx.SetMarkerStyle(1) + resIPy.SetMarkerStyle(1) + varx="recIPx*1000:1.0/truept" + vary="recIPy*1000:1.0/truept" + print ("IPx var: " +varx) + print ("IPy var: " +vary) + tuples.Draw(varx+">>resIPx", cutAcc) + tuples.Draw(vary+">>resIPy", cutAcc) + resIPx.FitSlicesY() + resIPy.FitSlicesY() + hresx_2 = outputfile.Get("resIPx_2") + hresy_2 = outputfile.Get("resIPy_2") + + canvas1 = TCanvas("resIPx_pT", "resIPx v.s. 1/pT") + hresx_2.Draw("E1 p1") + hresx_2.GetYaxis().SetTitle("#sigma_{IPx} [#mum]") + hresx_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") + hresx_2.SetTitle("#sigma(IP_{x}):1/p_{T}") + + polx = TF1("polx","pol1", 0, 3) + polx.SetLineColor(kRed) + print("Fit to Resolution of IPx v.s. 1/pT:") + hresx_2.Fit("polx", "R") + Par0x=format(polx.GetParameter(0), '.2f') + Par1x=format(polx.GetParameter(1), '.2f') + + pt = TPaveText(0.22,0.65,0.48,0.9,"BRNDC") + pt.SetTextSize(0.055) + pt.SetBorderSize(1) + pt.SetFillColor(10) + pt.SetLineWidth(0) + Funcx=Par0x+"+"+Par1x+"/p_{T}" + text=pt.AddText(Funcx) + pt.Draw() + canvas1.SetRightMargin(0.05) + canvas1.Write() + + canvas2 = TCanvas("resIPy_pT", "resIPy v.s. 1/pT") + hresy_2.Draw("E1 p1") + hresy_2.GetYaxis().SetTitle("#sigma_{IPy} [#mum]") + hresy_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") + hresy_2.SetTitle("#sigma(IP_{y}):1/p_{T}") + poly = TF1("poly","pol1", 0, 3) + poly.SetLineColor(kRed) + hresy_2.Fit("poly", "R") + Par0y=format(poly.GetParameter(0), '.2f') + Par1y=format(poly.GetParameter(1), '.2f') + + pt = TPaveText(0.22,0.65,0.48,0.9,"BRNDC") + pt.SetTextSize(0.055) + pt.SetBorderSize(1) + pt.SetFillColor(10) + pt.SetLineWidth(0) + Funcy=Par0y+"+"+Par1y+"/p_{T}" + texty=pt.AddText(Funcy) + pt.Draw() + canvas2.SetRightMargin(0.05) + canvas2.Write() + + resIPx_1=outputfile.Get("resIPx_1") + resIPx_2=outputfile.Get("resIPx_2") + resIPy_1=outputfile.Get("resIPy_1") + resIPy_2=outputfile.Get("resIPy_2") + for i in range(1, 20): + print("in 1/pT region: (" + format(resIPx_1.GetBinLowEdge(i), '.2f') + ", "+format(resIPx_1.GetBinLowEdge(i)+resIPx_1.GetBinWidth(i), '.2f')+") [c/GeV]" +" -***- "+ + "resIPx for mean : " + format(resIPx_1.GetBinContent(i), '.2f') + "[\mum] width : "+ format(resIPx_2.GetBinContent(i), '.2f') +"[\mum] -***- "+ + "resIPy for mean : " + format(resIPy_1.GetBinContent(i), '.2f') + "[\mum] width : "+ format(resIPy_2.GetBinContent(i), '.2f')+"[\mum]" ) + + #### rec IP chi2 distribution + recIPChi2=TH1F("recIPChi2", "recIPChi2", 100, 0, 200 ) + var="recIPChi2" + tuples.Draw(var+">>recIPChi2", cutAcc) + canvas=TCanvas("IPChi2", "IPChi2") + canvas.SetLogy() + recIPChi2.Draw() + recIPChi2.SetXTitle("#chi^{2}_{IP}") + recIPChi2.SetYTitle("N_{tracks}") + canvas.SetRightMargin(0.05) + canvas.Write() + + ### print efficiency of different IPchi2 cut + Numerator=TH1F("Numerator", "Numerator", 100, 0, 200 ) + Denominator=TH1F("Denominator", "Denominator", 100, 0, 200 ) + tuples.Draw(var+">>Denominator", cutAcc, "same") + for cut in [100, 25, 16, 9, 4]: + cutChi2=" && recIPChi2<"+format(cut) + cutNum=cutAcc + cutChi2 + tuples.Draw(var+">>Numerator", cutNum) + if Numerator.GetEntries() == 0 or Denominator.GetEntries() == 0 : + continue + Eff=Numerator.GetEntries()/(Denominator.GetEntries()+0.0) + print ("Efficiency of IPchi2<"+format(cut)+" : " + format(Eff,'.2%')) + + + outputfile.Write() + outputfile.Close() + f.Close() + +if __name__ == '__main__': + parser = argument_parser() + args = parser.parse_args() + PrCheckerIPresolution(**vars(args)) -- GitLab From 3942ae507b9dc35eaac0baddf126511fb1007c54 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 9 Jan 2020 16:47:05 +0000 Subject: [PATCH 027/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6722884 --- Hlt/RecoConf/scripts/LHCbStyle.py | 95 +++---- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 250 ++++++++++-------- 2 files changed, 182 insertions(+), 163 deletions(-) diff --git a/Hlt/RecoConf/scripts/LHCbStyle.py b/Hlt/RecoConf/scripts/LHCbStyle.py index e57b3fe3876..11d029b04b4 100644 --- a/Hlt/RecoConf/scripts/LHCbStyle.py +++ b/Hlt/RecoConf/scripts/LHCbStyle.py @@ -2,16 +2,17 @@ from ROOT import gStyle from ROOT import gROOT from ROOT import TStyle -def setLHCbStyle() : + +def setLHCbStyle(): global lhcbStyle - lhcbFont = 132 - lhcbTSize = 0.06 - lhcbWidth = 2 - - lhcbStyle= TStyle("lhcbStyle","LHCb plots style"); + lhcbFont = 132 + lhcbTSize = 0.06 + lhcbWidth = 2 + + lhcbStyle = TStyle("lhcbStyle", "LHCb plots style") lhcbStyle.SetFillColor(1) - lhcbStyle.SetFillStyle(1001) # solid + lhcbStyle.SetFillStyle(1001) # solid lhcbStyle.SetFrameFillColor(0) lhcbStyle.SetFrameBorderMode(0) lhcbStyle.SetPadBorderMode(0) @@ -26,62 +27,63 @@ def setLHCbStyle() : lhcbStyle.SetTextFont(lhcbFont) lhcbStyle.SetTitleFont(lhcbFont) lhcbStyle.SetTextSize(lhcbTSize) - lhcbStyle.SetLabelFont(lhcbFont,"x") - lhcbStyle.SetLabelFont(lhcbFont,"y") - lhcbStyle.SetLabelFont(lhcbFont,"z") - lhcbStyle.SetLabelSize(lhcbTSize,"x") - lhcbStyle.SetLabelSize(lhcbTSize,"y") - lhcbStyle.SetLabelSize(lhcbTSize,"z") + lhcbStyle.SetLabelFont(lhcbFont, "x") + lhcbStyle.SetLabelFont(lhcbFont, "y") + lhcbStyle.SetLabelFont(lhcbFont, "z") + lhcbStyle.SetLabelSize(lhcbTSize, "x") + lhcbStyle.SetLabelSize(lhcbTSize, "y") + lhcbStyle.SetLabelSize(lhcbTSize, "z") lhcbStyle.SetTitleFont(lhcbFont) - lhcbStyle.SetTitleFont(lhcbFont,"x") - lhcbStyle.SetTitleFont(lhcbFont,"y") - lhcbStyle.SetTitleFont(lhcbFont,"z") - lhcbStyle.SetTitleSize(1.2*lhcbTSize,"x") - lhcbStyle.SetTitleSize(1.2*lhcbTSize,"y") - lhcbStyle.SetTitleSize(1.2*lhcbTSize,"z") + lhcbStyle.SetTitleFont(lhcbFont, "x") + lhcbStyle.SetTitleFont(lhcbFont, "y") + lhcbStyle.SetTitleFont(lhcbFont, "z") + lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "x") + lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "y") + lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "z") # set the paper & margin sizes - lhcbStyle.SetPaperSize(20,26) + lhcbStyle.SetPaperSize(20, 26) lhcbStyle.SetPadTopMargin(0.05) - lhcbStyle.SetPadRightMargin(0.05) # increase for colz plots + lhcbStyle.SetPadRightMargin(0.05) # increase for colz plots lhcbStyle.SetPadBottomMargin(0.16) lhcbStyle.SetPadLeftMargin(0.14) # use medium bold lines and thick markers - lhcbStyle.SetLineWidth(lhcbWidth); - lhcbStyle.SetFrameLineWidth(lhcbWidth); - lhcbStyle.SetHistLineWidth(lhcbWidth); - lhcbStyle.SetFuncWidth(lhcbWidth); - lhcbStyle.SetGridWidth(lhcbWidth); - lhcbStyle.SetLineStyleString(2,"[12 12]"); # postscript dashes - lhcbStyle.SetMarkerStyle(20); - lhcbStyle.SetMarkerSize(1.0); - + lhcbStyle.SetLineWidth(lhcbWidth) + lhcbStyle.SetFrameLineWidth(lhcbWidth) + lhcbStyle.SetHistLineWidth(lhcbWidth) + lhcbStyle.SetFuncWidth(lhcbWidth) + lhcbStyle.SetGridWidth(lhcbWidth) + lhcbStyle.SetLineStyleString(2, "[12 12]") + # postscript dashes + lhcbStyle.SetMarkerStyle(20) + lhcbStyle.SetMarkerSize(1.0) + # label offsets - lhcbStyle.SetLabelOffset(0.010,"X"); - lhcbStyle.SetLabelOffset(0.010,"Y"); - + lhcbStyle.SetLabelOffset(0.010, "X") + lhcbStyle.SetLabelOffset(0.010, "Y") + # by default, do not display histogram decorations: - lhcbStyle.SetOptStat(0) + lhcbStyle.SetOptStat(0) #lhcbStyle.SetOptStat("emr") # show only nent -e , mean - m , rms -r # full opts at http:#root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat - lhcbStyle.SetStatFormat("6.3g") # specified as c printf options + lhcbStyle.SetStatFormat("6.3g") # specified as c printf options lhcbStyle.SetOptTitle(0) lhcbStyle.SetOptFit(0) #lhcbStyle.SetOptFit(1011) # order is probability, Chi2, errors, parameters #titles - lhcbStyle.SetTitleOffset(0.85,"X") - lhcbStyle.SetTitleOffset(0.85,"Y") - lhcbStyle.SetTitleOffset(1.2,"Z") + lhcbStyle.SetTitleOffset(0.85, "X") + lhcbStyle.SetTitleOffset(0.85, "Y") + lhcbStyle.SetTitleOffset(1.2, "Z") lhcbStyle.SetTitleFillColor(0) lhcbStyle.SetTitleStyle(0) lhcbStyle.SetTitleBorderSize(0) - lhcbStyle.SetTitleFont(lhcbFont,"title") + lhcbStyle.SetTitleFont(lhcbFont, "title") lhcbStyle.SetTitleX(0.0) - lhcbStyle.SetTitleY(1.0) + lhcbStyle.SetTitleY(1.0) lhcbStyle.SetTitleW(1.0) lhcbStyle.SetTitleH(0.05) - + # look of the statistics box: lhcbStyle.SetStatBorderSize(0) lhcbStyle.SetStatFont(lhcbFont) @@ -90,15 +92,14 @@ def setLHCbStyle() : lhcbStyle.SetStatY(0.9) lhcbStyle.SetStatW(0.25) lhcbStyle.SetStatH(0.15) - + # put tick marks on top and RHS of plots lhcbStyle.SetPadTickX(1) lhcbStyle.SetPadTickY(1) - + # histogram divisions: only 5 in x to avoid label overlaps - lhcbStyle.SetNdivisions(505,"x") - lhcbStyle.SetNdivisions(510,"y") - + lhcbStyle.SetNdivisions(505, "x") + lhcbStyle.SetNdivisions(510, "y") + gROOT.SetStyle("lhcbStyle") return - diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 1e035c09c9a..7a904d5cf2c 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -1,144 +1,162 @@ #!/usr/bin/python -# Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution +# Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution # as well as a check of the IP error distribution and efficiencies in different chi2 cut. # -# The resolution is fitted by a Gaussian function +# The resolution is fitted by a Gaussian function # # author: Peilian Li(peilian.li@cern.ch) # date: 01/2020 # -import os,sys +import os, sys import argparse import ROOT from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject -from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 -from ROOT import gROOT, gStyle, TStyle, TPaveText, TString +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 +from ROOT import gROOT, gStyle, TStyle, TPaveText, TString from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors from collections import defaultdict from LHCbStyle import setLHCbStyle setLHCbStyle() + #from collectRunResults import send_notification_mattermost def argument_parser(): - parser = argparse.ArgumentParser(description="path of the tuple file location") - parser.add_argument('--directory', type=str, default=os.getcwd(), help='location of input tuple files') - parser.add_argument('--name', type=str, default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') + parser = argparse.ArgumentParser( + description="path of the tuple file location") + parser.add_argument( + '--directory', + type=str, + default=os.getcwd(), + help='location of input tuple files') + parser.add_argument( + '--name', + type=str, + default='Hlt1ForwardTracking_IPresolution', + help='name of input tuple files') return parser + def PrCheckerIPresolution(directory, name): - f = TFile.Open(os.path.join(directory,name+'.root'), 'read') - outputfile = TFile( "IPResolution_plots.root", "recreate" ) - - tuples = f.Get("TrackIPResolutionCheckerNT/tracks"); - outputfile.cd() - - # typeofprefix==0 for track from PV and matched with MC - cutAcc= "trueeta<5 && trueeta>2 && typeofprefix==0" - print ("Velo track from PV in acceptance: " + cutAcc) - resIPx=TH2F("resIPx", "IPx:1/pt", 20, 0, 3, 100, -300, 300) - resIPy=TH2F("resIPy", "IPy:1/pt", 20, 0, 3, 100, -300, 300) - resIPx.SetMarkerStyle(1) - resIPy.SetMarkerStyle(1) - varx="recIPx*1000:1.0/truept" - vary="recIPy*1000:1.0/truept" - print ("IPx var: " +varx) - print ("IPy var: " +vary) - tuples.Draw(varx+">>resIPx", cutAcc) - tuples.Draw(vary+">>resIPy", cutAcc) - resIPx.FitSlicesY() - resIPy.FitSlicesY() - hresx_2 = outputfile.Get("resIPx_2") - hresy_2 = outputfile.Get("resIPy_2") - - canvas1 = TCanvas("resIPx_pT", "resIPx v.s. 1/pT") - hresx_2.Draw("E1 p1") - hresx_2.GetYaxis().SetTitle("#sigma_{IPx} [#mum]") - hresx_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") - hresx_2.SetTitle("#sigma(IP_{x}):1/p_{T}") - - polx = TF1("polx","pol1", 0, 3) - polx.SetLineColor(kRed) - print("Fit to Resolution of IPx v.s. 1/pT:") - hresx_2.Fit("polx", "R") - Par0x=format(polx.GetParameter(0), '.2f') - Par1x=format(polx.GetParameter(1), '.2f') - - pt = TPaveText(0.22,0.65,0.48,0.9,"BRNDC") - pt.SetTextSize(0.055) - pt.SetBorderSize(1) - pt.SetFillColor(10) - pt.SetLineWidth(0) - Funcx=Par0x+"+"+Par1x+"/p_{T}" - text=pt.AddText(Funcx) - pt.Draw() - canvas1.SetRightMargin(0.05) - canvas1.Write() - - canvas2 = TCanvas("resIPy_pT", "resIPy v.s. 1/pT") - hresy_2.Draw("E1 p1") - hresy_2.GetYaxis().SetTitle("#sigma_{IPy} [#mum]") - hresy_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") - hresy_2.SetTitle("#sigma(IP_{y}):1/p_{T}") - poly = TF1("poly","pol1", 0, 3) - poly.SetLineColor(kRed) - hresy_2.Fit("poly", "R") - Par0y=format(poly.GetParameter(0), '.2f') - Par1y=format(poly.GetParameter(1), '.2f') - - pt = TPaveText(0.22,0.65,0.48,0.9,"BRNDC") - pt.SetTextSize(0.055) - pt.SetBorderSize(1) - pt.SetFillColor(10) - pt.SetLineWidth(0) - Funcy=Par0y+"+"+Par1y+"/p_{T}" - texty=pt.AddText(Funcy) - pt.Draw() - canvas2.SetRightMargin(0.05) - canvas2.Write() - - resIPx_1=outputfile.Get("resIPx_1") - resIPx_2=outputfile.Get("resIPx_2") - resIPy_1=outputfile.Get("resIPy_1") - resIPy_2=outputfile.Get("resIPy_2") - for i in range(1, 20): - print("in 1/pT region: (" + format(resIPx_1.GetBinLowEdge(i), '.2f') + ", "+format(resIPx_1.GetBinLowEdge(i)+resIPx_1.GetBinWidth(i), '.2f')+") [c/GeV]" +" -***- "+ - "resIPx for mean : " + format(resIPx_1.GetBinContent(i), '.2f') + "[\mum] width : "+ format(resIPx_2.GetBinContent(i), '.2f') +"[\mum] -***- "+ - "resIPy for mean : " + format(resIPy_1.GetBinContent(i), '.2f') + "[\mum] width : "+ format(resIPy_2.GetBinContent(i), '.2f')+"[\mum]" ) - - #### rec IP chi2 distribution - recIPChi2=TH1F("recIPChi2", "recIPChi2", 100, 0, 200 ) - var="recIPChi2" - tuples.Draw(var+">>recIPChi2", cutAcc) - canvas=TCanvas("IPChi2", "IPChi2") - canvas.SetLogy() - recIPChi2.Draw() - recIPChi2.SetXTitle("#chi^{2}_{IP}") - recIPChi2.SetYTitle("N_{tracks}") - canvas.SetRightMargin(0.05) - canvas.Write() - - ### print efficiency of different IPchi2 cut - Numerator=TH1F("Numerator", "Numerator", 100, 0, 200 ) - Denominator=TH1F("Denominator", "Denominator", 100, 0, 200 ) - tuples.Draw(var+">>Denominator", cutAcc, "same") - for cut in [100, 25, 16, 9, 4]: - cutChi2=" && recIPChi2<"+format(cut) - cutNum=cutAcc + cutChi2 - tuples.Draw(var+">>Numerator", cutNum) - if Numerator.GetEntries() == 0 or Denominator.GetEntries() == 0 : - continue - Eff=Numerator.GetEntries()/(Denominator.GetEntries()+0.0) - print ("Efficiency of IPchi2<"+format(cut)+" : " + format(Eff,'.2%')) - - - outputfile.Write() - outputfile.Close() - f.Close() + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') + outputfile = TFile("IPResolution_plots.root", "recreate") + + tuples = f.Get("TrackIPResolutionCheckerNT/tracks") + outputfile.cd() + + # typeofprefix==0 for track from PV and matched with MC + cutAcc = "trueeta<5 && trueeta>2 && typeofprefix==0" + print("Velo track from PV in acceptance: " + cutAcc) + resIPx = TH2F("resIPx", "IPx:1/pt", 20, 0, 3, 100, -300, 300) + resIPy = TH2F("resIPy", "IPy:1/pt", 20, 0, 3, 100, -300, 300) + resIPx.SetMarkerStyle(1) + resIPy.SetMarkerStyle(1) + varx = "recIPx*1000:1.0/truept" + vary = "recIPy*1000:1.0/truept" + print("IPx var: " + varx) + print("IPy var: " + vary) + tuples.Draw(varx + ">>resIPx", cutAcc) + tuples.Draw(vary + ">>resIPy", cutAcc) + resIPx.FitSlicesY() + resIPy.FitSlicesY() + hresx_2 = outputfile.Get("resIPx_2") + hresy_2 = outputfile.Get("resIPy_2") + + canvas1 = TCanvas("resIPx_pT", "resIPx v.s. 1/pT") + hresx_2.Draw("E1 p1") + hresx_2.GetYaxis().SetTitle("#sigma_{IPx} [#mum]") + hresx_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") + hresx_2.SetTitle("#sigma(IP_{x}):1/p_{T}") + + polx = TF1("polx", "pol1", 0, 3) + polx.SetLineColor(kRed) + print("Fit to Resolution of IPx v.s. 1/pT:") + hresx_2.Fit("polx", "R") + Par0x = format(polx.GetParameter(0), '.2f') + Par1x = format(polx.GetParameter(1), '.2f') + + pt = TPaveText(0.22, 0.65, 0.48, 0.9, "BRNDC") + pt.SetTextSize(0.055) + pt.SetBorderSize(1) + pt.SetFillColor(10) + pt.SetLineWidth(0) + Funcx = Par0x + "+" + Par1x + "/p_{T}" + text = pt.AddText(Funcx) + pt.Draw() + canvas1.SetRightMargin(0.05) + canvas1.Write() + + canvas2 = TCanvas("resIPy_pT", "resIPy v.s. 1/pT") + hresy_2.Draw("E1 p1") + hresy_2.GetYaxis().SetTitle("#sigma_{IPy} [#mum]") + hresy_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") + hresy_2.SetTitle("#sigma(IP_{y}):1/p_{T}") + poly = TF1("poly", "pol1", 0, 3) + poly.SetLineColor(kRed) + hresy_2.Fit("poly", "R") + Par0y = format(poly.GetParameter(0), '.2f') + Par1y = format(poly.GetParameter(1), '.2f') + + pt = TPaveText(0.22, 0.65, 0.48, 0.9, "BRNDC") + pt.SetTextSize(0.055) + pt.SetBorderSize(1) + pt.SetFillColor(10) + pt.SetLineWidth(0) + Funcy = Par0y + "+" + Par1y + "/p_{T}" + texty = pt.AddText(Funcy) + pt.Draw() + canvas2.SetRightMargin(0.05) + canvas2.Write() + + resIPx_1 = outputfile.Get("resIPx_1") + resIPx_2 = outputfile.Get("resIPx_2") + resIPy_1 = outputfile.Get("resIPy_1") + resIPy_2 = outputfile.Get("resIPy_2") + for i in range(1, 20): + print("in 1/pT region: (" + format(resIPx_1.GetBinLowEdge(i), '.2f') + + ", " + format( + resIPx_1.GetBinLowEdge(i) + resIPx_1.GetBinWidth(i), '.2f') + + ") [c/GeV]" + " -***- " + "resIPx for mean : " + + format(resIPx_1.GetBinContent(i), '.2f') + "[\mum] width : " + + format(resIPx_2.GetBinContent(i), '.2f') + "[\mum] -***- " + + "resIPy for mean : " + format(resIPy_1.GetBinContent(i), '.2f') + + "[\mum] width : " + format(resIPy_2.GetBinContent(i), '.2f') + + "[\mum]") + + #### rec IP chi2 distribution + recIPChi2 = TH1F("recIPChi2", "recIPChi2", 100, 0, 200) + var = "recIPChi2" + tuples.Draw(var + ">>recIPChi2", cutAcc) + canvas = TCanvas("IPChi2", "IPChi2") + canvas.SetLogy() + recIPChi2.Draw() + recIPChi2.SetXTitle("#chi^{2}_{IP}") + recIPChi2.SetYTitle("N_{tracks}") + canvas.SetRightMargin(0.05) + canvas.Write() + + ### print efficiency of different IPchi2 cut + Numerator = TH1F("Numerator", "Numerator", 100, 0, 200) + Denominator = TH1F("Denominator", "Denominator", 100, 0, 200) + tuples.Draw(var + ">>Denominator", cutAcc, "same") + for cut in [100, 25, 16, 9, 4]: + cutChi2 = " && recIPChi2<" + format(cut) + cutNum = cutAcc + cutChi2 + tuples.Draw(var + ">>Numerator", cutNum) + if Numerator.GetEntries() == 0 or Denominator.GetEntries() == 0: + continue + Eff = Numerator.GetEntries() / (Denominator.GetEntries() + 0.0) + print("Efficiency of IPchi2<" + format(cut) + " : " + + format(Eff, '.2%')) + + outputfile.Write() + outputfile.Close() + f.Close() + if __name__ == '__main__': parser = argument_parser() -- GitLab From 9dbb28551fa909eade1708fc08e15d245cc85f11 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 9 Jan 2020 18:01:23 +0100 Subject: [PATCH 028/171] add script for reading the IPresolution tuples --- Hlt/RecoConf/scripts/LHCbStyle.py | 11 +++++++ Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 29 ++++++++++++------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Hlt/RecoConf/scripts/LHCbStyle.py b/Hlt/RecoConf/scripts/LHCbStyle.py index 11d029b04b4..88799a336e2 100644 --- a/Hlt/RecoConf/scripts/LHCbStyle.py +++ b/Hlt/RecoConf/scripts/LHCbStyle.py @@ -1,3 +1,14 @@ +############################################################################### +# (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 ROOT import gStyle from ROOT import gROOT from ROOT import TStyle diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 7a904d5cf2c..70941eae941 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -1,13 +1,22 @@ -#!/usr/bin/python - -# Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution -# as well as a check of the IP error distribution and efficiencies in different chi2 cut. -# -# The resolution is fitted by a Gaussian function -# -# author: Peilian Li(peilian.li@cern.ch) -# date: 01/2020 -# +############################################################################### +# (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. # +############################################################################### +''' + Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution + as well as a check of the IP error distribution and efficiencies in different chi2 cut. + + The resolution is fitted by a Gaussian function + + author: Peilian Li(peilian.li@cern.ch) + date: 01/2020 +''' import os, sys import argparse -- GitLab From 6326a2c891bc6e38afbfa6fbedb0ce2baeb8c0d6 Mon Sep 17 00:00:00 2001 From: Peilian Li Date: Thu, 9 Jan 2020 17:09:12 +0000 Subject: [PATCH 029/171] Apply suggestion to Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt --- Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt index e34dcba158c..74c2cfa3668 100644 --- a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt +++ b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt @@ -10,7 +10,7 @@ or submit itself to any jurisdiction. --> gaudirun.py -- GitLab From db9c1ce4f02fe20fb6b3beb042a522a7e403e260 Mon Sep 17 00:00:00 2001 From: Peilian Li Date: Thu, 9 Jan 2020 17:30:49 +0000 Subject: [PATCH 030/171] Apply suggestion to Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt --- Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt index 38c0cdc0b83..0a10d19ac0d 100644 --- a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt +++ b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt @@ -10,7 +10,7 @@ or submit itself to any jurisdiction. --> gaudirun.py -- GitLab From 1059ea41108dd92c774d4d76ed0066cc719a9e75 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 10 Jan 2020 17:35:44 +0100 Subject: [PATCH 031/171] add scripts to plot the tracking and IP resolution --- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 19 ++- .../scripts/PrCheckerTrackResolution.py | 143 ++++++++++++++++++ Hlt/RecoConf/scripts/{ => utils}/LHCbStyle.py | 0 Hlt/RecoConf/scripts/utils/Legend.py | 117 ++++++++++++++ .../tests/qmtest/hlt1_reco_IPresolution.qmt | 31 ---- .../qmtest/hlt1_reco_trackresolution.qmt | 31 ---- 6 files changed, 272 insertions(+), 69 deletions(-) create mode 100644 Hlt/RecoConf/scripts/PrCheckerTrackResolution.py rename Hlt/RecoConf/scripts/{ => utils}/LHCbStyle.py (100%) create mode 100644 Hlt/RecoConf/scripts/utils/Legend.py delete mode 100644 Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt delete mode 100644 Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 70941eae941..e110da81343 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -24,18 +24,15 @@ import ROOT from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 from ROOT import gROOT, gStyle, TStyle, TPaveText, TString -from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors +from ROOT import ROOT, vector, TGraphAsymmErrors from collections import defaultdict -from LHCbStyle import setLHCbStyle -setLHCbStyle() #from collectRunResults import send_notification_mattermost - def argument_parser(): parser = argparse.ArgumentParser( - description="path of the tuple file location") + description="location of the tuple file") parser.add_argument( '--directory', type=str, @@ -46,18 +43,26 @@ def argument_parser(): type=str, default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') + parser.add_argument( + '--plotstyle', + default='', + help='location of LHCb plot style file') return parser -def PrCheckerIPresolution(directory, name): +def PrCheckerIPresolution(directory, name, plotstyle): + sys.path.append(os.path.abspath(plotstyle)) + from LHCbStyle import setLHCbStyle + setLHCbStyle() + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') outputfile = TFile("IPResolution_plots.root", "recreate") tuples = f.Get("TrackIPResolutionCheckerNT/tracks") outputfile.cd() - # typeofprefix==0 for track from PV and matched with MC + ### typeofprefix==0 for track from PV and matched with MC cutAcc = "trueeta<5 && trueeta>2 && typeofprefix==0" print("Velo track from PV in acceptance: " + cutAcc) resIPx = TH2F("resIPx", "IPx:1/pt", 20, 0, 3, 100, -300, 300) diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py new file mode 100644 index 00000000000..793da862153 --- /dev/null +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -0,0 +1,143 @@ +############################################################################### +# (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. # +############################################################################### +''' + Script for the plots of tracking resolution v.s. p and eta + The resolution is fitted by a Gaussian function + + author: Peilian Li(peilian.li@cern.ch) + date: 01/2020 +''' + +import os, sys +import argparse +import ROOT +from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1, TH2, TF1 +from ROOT import gROOT, gStyle, TStyle, TPaveText, TString +from ROOT import ROOT, vector, TGraphAsymmErrors + +from collections import defaultdict + +#from collectRunResults import send_notification_mattermost + + +def argument_parser(): + parser = argparse.ArgumentParser( + description="location of the histogram file") + parser.add_argument( + '--directory', + type=str, + default=os.getcwd(), + help='location of input tuple files') + parser.add_argument( + '--name', + type=str, + default='Hlt1ForwardTrackingResolution', + help='name of input tuple files') + parser.add_argument( + '--plotstyle', + default='', + help='location of LHCb plot style file') + return parser + + +def PrCheckerTrackResolution(directory, name, plotstyle): + + sys.path.append(os.path.abspath(plotstyle)) + from LHCbStyle import setLHCbStyle + from Legend import place_legend + setLHCbStyle() + + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') + outputfile = TFile("TrackResolution_plots.root", "recreate") + outputfile.cd() + + hres_p= f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") + hres_eta= f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") + + hres_p.Write() + hres_eta.Write() + hres_p.FitSlicesY() + hres_eta.FitSlicesY() + + hres_p_2 = outputfile.Get("dpoverp_vs_p_2") + hres_eta_2 = outputfile.Get("dpoverp_vs_eta_2") + + canvas1 = TCanvas("res_p", "res v.s. p") + canvas1.cd() + for i in range(1, hres_p_2.GetNbinsX()): + hres_p_2.SetBinContent(i, hres_p_2.GetBinContent(i)*100) + + hres_p_2.Draw("E1 p1") + hres_p_2.SetTitle("dp/p:p") + hres_p_2.GetYaxis().SetTitle("dp/p [%]") + hres_p_2.GetXaxis().SetTitle("p [GeV/c]") + hres_p_2.GetYaxis().SetRangeUser(0, 1.2) + hmom = hres_p.ProjectionX() + hmom.SetTitle("p histo.") + hmom.Scale(0.3/hres_p.GetMaximum()) + hmom.Draw("hist same") + hmom.SetFillStyle(3004) + hmom.SetLineColor(kBlue-10) + hmom.SetFillColor(kBlue) + hmom.SetLineWidth(2) + + canvas1.PlaceLegend() + canvas1.SetRightMargin(0.05) + canvas1.Write() + + canvas2 = TCanvas("res_eta", "res v.s. eta") + canvas2.cd() + for i in range(1, hres_eta_2.GetNbinsX()): + hres_eta_2.SetBinContent(i, hres_eta_2.GetBinContent(i)*100) + + hres_eta_2.Draw("E1 p1") + hres_eta_2.SetTitle("dp/p:#eta") + hres_eta_2.GetYaxis().SetTitle("dp/p [%]") + hres_eta_2.GetXaxis().SetTitle("#eta") + hres_eta_2.GetYaxis().SetRangeUser(0, 1.2) + heta = hres_eta.ProjectionX() + heta.SetTitle("#eta histo.") + heta.Scale(0.1/hres_eta.GetMaximum()) + heta.Draw("hist same") + heta.SetFillStyle(3004) + heta.SetLineColor(kBlue-10) + heta.SetFillColor(kBlue) + heta.SetLineWidth(2) + + canvas2.PlaceLegend() + canvas2.SetRightMargin(0.05) + canvas2.Write() + + for i in range(1, hres_p_2.GetNbinsX()): + print("Track resolution (dp/p) in p region: (" + format(hres_p_2.GetBinLowEdge(i), '.2f') + + ", " + format( + hres_p_2.GetBinLowEdge(i) +hres_p_2.GetBinWidth(i), '.2f') + + ") [GeV/c]" + " --- " + + format(hres_p_2.GetBinContent(i), '.2f')+"%" ) + + print("-----------------------------------") + for i in range(1, hres_eta_2.GetNbinsX()): + print("Track resolution (dp/p) in eta region: (" + format(hres_eta_2.GetBinLowEdge(i), '.2f') + + ", " + format( + hres_eta_2.GetBinLowEdge(i) +hres_eta_2.GetBinWidth(i), '.2f') + + ")" + " --- " + + format(hres_eta_2.GetBinContent(i), '.2f')+"%" ) + + outputfile.Write() + outputfile.Close() + f.Close() + + +if __name__ == '__main__': + parser = argument_parser() + args = parser.parse_args() + PrCheckerTrackResolution(**vars(args)) diff --git a/Hlt/RecoConf/scripts/LHCbStyle.py b/Hlt/RecoConf/scripts/utils/LHCbStyle.py similarity index 100% rename from Hlt/RecoConf/scripts/LHCbStyle.py rename to Hlt/RecoConf/scripts/utils/LHCbStyle.py diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py new file mode 100644 index 00000000000..68ce9aaddf3 --- /dev/null +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -0,0 +1,117 @@ +import ROOT +import itertools +from ROOT import gStyle + +# Some convenience function to easily iterate over the parts of the collections + + +# Needed if importing this script from another script in case TMultiGraphs are used +#ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) + + +# Start a bit right of the Yaxis and above the Xaxis to not overlap with the ticks +start, stop = 0.18, 0.89 +x_width, y_width = 0.3, 0.2 +PLACES = [(start, stop - y_width, start + x_width, stop), # top left opt + (start, start, start + x_width, start + y_width), # bottom left opt + (stop - x_width, stop - y_width, stop, stop), # top right opt + (stop - x_width, start, stop, start + y_width), # bottom right opt + (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right + (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2)] # left + + +def transform_to_user(canvas, x1, y1, x2, y2): + """ + Transforms from Pad coordinates to User coordinates. + + This can probably be replaced by using the built-in conversion commands. + """ + xstart = canvas.GetX1() + xlength = canvas.GetX2() - xstart + xlow = xlength * x1 + xstart + xhigh = xlength * x2 + xstart + if canvas.GetLogx(): + xlow = 10**xlow + xhigh = 10**xhigh + + ystart = canvas.GetY1() + ylength = canvas.GetY2() - ystart + ylow = ylength * y1 + ystart + yhigh = ylength * y2 + ystart + if canvas.GetLogy(): + ylow = 10**ylow + yhigh = 10**yhigh + + return xlow, ylow, xhigh, yhigh + + +def overlap_h(hist, x1, y1, x2, y2): + xlow = hist.FindFixBin(x1) + xhigh = hist.FindFixBin(x2) + for i in range(xlow, xhigh + 1): + val = hist.GetBinContent(i) + # Values + if y1 <= val <= y2: + return True + # Errors + if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow(i) < y2: + # print "Overlap with histo", hist.GetName(), "at bin", i + return True + return False + + +def overlap_rect(rect1, rect2): + """Do the two rectangles overlap?""" + if rect1[0] > rect2[2] or rect1[2] < rect2[0]: + return False + if rect1[1] > rect2[3] or rect1[3] < rect2[1]: + return False + return True + +def overlap_g(graph, x1, y1, x2, y2): + x_values = list(graph.GetX()) + y_values = list(graph.GetY()) + x_err = list(graph.GetEX()) or [0] * len(x_values) + y_err = list(graph.GetEY()) or [0] * len(y_values) + + for x, ex, y, ey in zip(x_values, x_err, y_values, y_err): + # Could maybe be less conservative + if overlap_rect((x1, y1, x2, y2), (x - ex, y - ey, x + ex, y + ey)): + # print "Overlap with graph", graph.GetName(), "at point", (x, y) + return True + return False + +def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option="LPF"): + gStyle.SetFillStyle(0) + gStyle.SetTextSize(0.06) + # If position is specified, use that + if all(x is not None for x in (x1, x2, y1, y2)): + return canvas.BuildLegend(x1, y1, x2, y2, header, option) + + # Make sure all objects are correctly registered + canvas.Update() + + # Build a list of objects to check for overlaps + objects = [] + for x in canvas.GetListOfPrimitives(): + if isinstance(x, ROOT.TH1) or isinstance(x, ROOT.TGraph): + objects.append(x) + elif isinstance(x, ROOT.THStack) or isinstance(x, ROOT.TMultiGraph): + objects.extend(x) + + for place in PLACES: + place_user = canvas.PadtoU(*place) + # Make sure there are no overlaps + if any(obj.Overlap(*place_user) for obj in objects): + continue + return canvas.BuildLegend(place[0], place[1], place[2], place[3], header, option) + # As a fallback, use the default values, taken from TCanvas::BuildLegend + return canvas.BuildLegend(0.5, 0.67, 0.88, 0.88, header, option) + +# Monkey patch ROOT objects to make it all work +ROOT.THStack.__iter__ = lambda self: iter(self.GetHists()) +ROOT.TMultiGraph.__iter__ = lambda self: iter(self.GetListOfGraphs()) +ROOT.TH1.Overlap = overlap_h +ROOT.TGraph.Overlap = overlap_g +ROOT.TPad.PadtoU = transform_to_user +ROOT.TPad.PlaceLegend = place_legend diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt deleted file mode 100644 index 74c2cfa3668..00000000000 --- a/Hlt/RecoConf/tests/qmtest/hlt1_reco_IPresolution.qmt +++ /dev/null @@ -1,31 +0,0 @@ - - - - -gaudirun.py - - $MOOREROOT/tests/options/default_input_and_conds_hlt1.py - $RECOCONFROOT/options/hlt1_reco_IPresolution.py - --output=hlt1_reco_IPresolution.opts.py - --all-opt - -true - - -from Moore.qmtest.exclusions import remove_known_warnings -countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, - stdout=remove_known_warnings(stdout)) - - - diff --git a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt deleted file mode 100644 index 0a10d19ac0d..00000000000 --- a/Hlt/RecoConf/tests/qmtest/hlt1_reco_trackresolution.qmt +++ /dev/null @@ -1,31 +0,0 @@ - - - - -gaudirun.py - - $MOOREROOT/tests/options/default_input_and_conds_hlt1.py - $RECOCONFROOT/options/hlt1_reco_trackresolution.py - --output=hlt1_reco_trackresolution.opts.py - --all-opt - -true - - -from Moore.qmtest.exclusions import remove_known_warnings -countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, - stdout=remove_known_warnings(stdout)) - - - -- GitLab From a1a5322b12788056590caa951bd4d55bea04a4bd Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 10 Jan 2020 17:40:12 +0100 Subject: [PATCH 032/171] check copyright --- Hlt/RecoConf/scripts/utils/Legend.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index 68ce9aaddf3..4b7b9c4f6b2 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -1,10 +1,20 @@ +############################################################################### +# (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. # +############################################################################### + import ROOT import itertools from ROOT import gStyle # Some convenience function to easily iterate over the parts of the collections - # Needed if importing this script from another script in case TMultiGraphs are used #ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) -- GitLab From bb2386bd72d92334c8de3a53690d59b9249dcff0 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 10 Jan 2020 16:40:51 +0000 Subject: [PATCH 033/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6736425 --- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 10 ++-- .../scripts/PrCheckerTrackResolution.py | 48 +++++++++---------- Hlt/RecoConf/scripts/utils/Legend.py | 32 +++++++++---- 3 files changed, 49 insertions(+), 41 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index e110da81343..cc3c1687c24 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -30,9 +30,9 @@ from collections import defaultdict #from collectRunResults import send_notification_mattermost + def argument_parser(): - parser = argparse.ArgumentParser( - description="location of the tuple file") + parser = argparse.ArgumentParser(description="location of the tuple file") parser.add_argument( '--directory', type=str, @@ -44,9 +44,7 @@ def argument_parser(): default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') parser.add_argument( - '--plotstyle', - default='', - help='location of LHCb plot style file') + '--plotstyle', default='', help='location of LHCb plot style file') return parser @@ -55,7 +53,7 @@ def PrCheckerIPresolution(directory, name, plotstyle): sys.path.append(os.path.abspath(plotstyle)) from LHCbStyle import setLHCbStyle setLHCbStyle() - + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') outputfile = TFile("IPResolution_plots.root", "recreate") diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index 793da862153..64dbf24a1f8 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -9,7 +9,7 @@ # or submit itself to any jurisdiction. # ############################################################################### ''' - Script for the plots of tracking resolution v.s. p and eta + Script for the plots of tracking resolution v.s. p and eta The resolution is fitted by a Gaussian function author: Peilian Li(peilian.li@cern.ch) @@ -43,9 +43,7 @@ def argument_parser(): default='Hlt1ForwardTrackingResolution', help='name of input tuple files') parser.add_argument( - '--plotstyle', - default='', - help='location of LHCb plot style file') + '--plotstyle', default='', help='location of LHCb plot style file') return parser @@ -55,13 +53,13 @@ def PrCheckerTrackResolution(directory, name, plotstyle): from LHCbStyle import setLHCbStyle from Legend import place_legend setLHCbStyle() - + f = TFile.Open(os.path.join(directory, name + '.root'), 'read') outputfile = TFile("TrackResolution_plots.root", "recreate") outputfile.cd() - hres_p= f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") - hres_eta= f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") + hres_p = f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") + hres_eta = f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") hres_p.Write() hres_eta.Write() @@ -74,7 +72,7 @@ def PrCheckerTrackResolution(directory, name, plotstyle): canvas1 = TCanvas("res_p", "res v.s. p") canvas1.cd() for i in range(1, hres_p_2.GetNbinsX()): - hres_p_2.SetBinContent(i, hres_p_2.GetBinContent(i)*100) + hres_p_2.SetBinContent(i, hres_p_2.GetBinContent(i) * 100) hres_p_2.Draw("E1 p1") hres_p_2.SetTitle("dp/p:p") @@ -83,13 +81,13 @@ def PrCheckerTrackResolution(directory, name, plotstyle): hres_p_2.GetYaxis().SetRangeUser(0, 1.2) hmom = hres_p.ProjectionX() hmom.SetTitle("p histo.") - hmom.Scale(0.3/hres_p.GetMaximum()) + hmom.Scale(0.3 / hres_p.GetMaximum()) hmom.Draw("hist same") hmom.SetFillStyle(3004) - hmom.SetLineColor(kBlue-10) + hmom.SetLineColor(kBlue - 10) hmom.SetFillColor(kBlue) hmom.SetLineWidth(2) - + canvas1.PlaceLegend() canvas1.SetRightMargin(0.05) canvas1.Write() @@ -97,7 +95,7 @@ def PrCheckerTrackResolution(directory, name, plotstyle): canvas2 = TCanvas("res_eta", "res v.s. eta") canvas2.cd() for i in range(1, hres_eta_2.GetNbinsX()): - hres_eta_2.SetBinContent(i, hres_eta_2.GetBinContent(i)*100) + hres_eta_2.SetBinContent(i, hres_eta_2.GetBinContent(i) * 100) hres_eta_2.Draw("E1 p1") hres_eta_2.SetTitle("dp/p:#eta") @@ -106,10 +104,10 @@ def PrCheckerTrackResolution(directory, name, plotstyle): hres_eta_2.GetYaxis().SetRangeUser(0, 1.2) heta = hres_eta.ProjectionX() heta.SetTitle("#eta histo.") - heta.Scale(0.1/hres_eta.GetMaximum()) + heta.Scale(0.1 / hres_eta.GetMaximum()) heta.Draw("hist same") heta.SetFillStyle(3004) - heta.SetLineColor(kBlue-10) + heta.SetLineColor(kBlue - 10) heta.SetFillColor(kBlue) heta.SetLineWidth(2) @@ -118,19 +116,19 @@ def PrCheckerTrackResolution(directory, name, plotstyle): canvas2.Write() for i in range(1, hres_p_2.GetNbinsX()): - print("Track resolution (dp/p) in p region: (" + format(hres_p_2.GetBinLowEdge(i), '.2f') + - ", " + format( - hres_p_2.GetBinLowEdge(i) +hres_p_2.GetBinWidth(i), '.2f') + - ") [GeV/c]" + " --- " + - format(hres_p_2.GetBinContent(i), '.2f')+"%" ) + print("Track resolution (dp/p) in p region: (" + + format(hres_p_2.GetBinLowEdge(i), '.2f') + ", " + format( + hres_p_2.GetBinLowEdge(i) + hres_p_2.GetBinWidth(i), '.2f') + + ") [GeV/c]" + " --- " + + format(hres_p_2.GetBinContent(i), '.2f') + "%") print("-----------------------------------") - for i in range(1, hres_eta_2.GetNbinsX()): - print("Track resolution (dp/p) in eta region: (" + format(hres_eta_2.GetBinLowEdge(i), '.2f') + - ", " + format( - hres_eta_2.GetBinLowEdge(i) +hres_eta_2.GetBinWidth(i), '.2f') + - ")" + " --- " + - format(hres_eta_2.GetBinContent(i), '.2f')+"%" ) + for i in range(1, hres_eta_2.GetNbinsX()): + print("Track resolution (dp/p) in eta region: (" + + format(hres_eta_2.GetBinLowEdge(i), '.2f') + ", " + format( + hres_eta_2.GetBinLowEdge(i) + + hres_eta_2.GetBinWidth(i), '.2f') + ")" + " --- " + + format(hres_eta_2.GetBinContent(i), '.2f') + "%") outputfile.Write() outputfile.Close() diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index 4b7b9c4f6b2..771c38e290d 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -18,16 +18,17 @@ from ROOT import gStyle # Needed if importing this script from another script in case TMultiGraphs are used #ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) - # Start a bit right of the Yaxis and above the Xaxis to not overlap with the ticks start, stop = 0.18, 0.89 x_width, y_width = 0.3, 0.2 -PLACES = [(start, stop - y_width, start + x_width, stop), # top left opt - (start, start, start + x_width, start + y_width), # bottom left opt - (stop - x_width, stop - y_width, stop, stop), # top right opt - (stop - x_width, start, stop, start + y_width), # bottom right opt - (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right - (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2)] # left +PLACES = [ + (start, stop - y_width, start + x_width, stop), # top left opt + (start, start, start + x_width, start + y_width), # bottom left opt + (stop - x_width, stop - y_width, stop, stop), # top right opt + (stop - x_width, start, stop, start + y_width), # bottom right opt + (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right + (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2) +] # left def transform_to_user(canvas, x1, y1, x2, y2): @@ -64,7 +65,8 @@ def overlap_h(hist, x1, y1, x2, y2): if y1 <= val <= y2: return True # Errors - if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow(i) < y2: + if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow( + i) < y2: # print "Overlap with histo", hist.GetName(), "at bin", i return True return False @@ -78,6 +80,7 @@ def overlap_rect(rect1, rect2): return False return True + def overlap_g(graph, x1, y1, x2, y2): x_values = list(graph.GetX()) y_values = list(graph.GetY()) @@ -91,7 +94,14 @@ def overlap_g(graph, x1, y1, x2, y2): return True return False -def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option="LPF"): + +def place_legend(canvas, + x1=None, + y1=None, + x2=None, + y2=None, + header="", + option="LPF"): gStyle.SetFillStyle(0) gStyle.SetTextSize(0.06) # If position is specified, use that @@ -114,10 +124,12 @@ def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option=" # Make sure there are no overlaps if any(obj.Overlap(*place_user) for obj in objects): continue - return canvas.BuildLegend(place[0], place[1], place[2], place[3], header, option) + return canvas.BuildLegend(place[0], place[1], place[2], place[3], + header, option) # As a fallback, use the default values, taken from TCanvas::BuildLegend return canvas.BuildLegend(0.5, 0.67, 0.88, 0.88, header, option) + # Monkey patch ROOT objects to make it all work ROOT.THStack.__iter__ = lambda self: iter(self.GetHists()) ROOT.TMultiGraph.__iter__ = lambda self: iter(self.GetListOfGraphs()) -- GitLab From 650d84d3e9afe03896535f0dbb4bec1e7247cb31 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 22 Jan 2020 15:16:13 +0100 Subject: [PATCH 034/171] start on calling Allen from Moore --- CMakeLists.txt | 2 +- Hlt/Moore/tests/options/default_conds_FTv6.py | 1 + ...reco_baseline_and_Allen_with_mcchecking.py | 36 +++++++++++++++++ Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 39 +++++++++++++++++++ Hlt/RecoConf/python/RecoConf/standalone.py | 30 ++++++++++++++ 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py create mode 100644 Hlt/RecoConf/python/RecoConf/hlt1_allen.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 44aac78d329..6fb575652fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ find_package(GaudiProject) # Declare project name and version gaudi_project(Moore v50r0 - USE Phys v30r6 + USE Allen v0r7 DATA AppConfig VERSION v3r* FieldMap VERSION v5r* PRConfig VERSION v1r* diff --git a/Hlt/Moore/tests/options/default_conds_FTv6.py b/Hlt/Moore/tests/options/default_conds_FTv6.py index f8a23c89b00..0d5089fcf18 100644 --- a/Hlt/Moore/tests/options/default_conds_FTv6.py +++ b/Hlt/Moore/tests/options/default_conds_FTv6.py @@ -10,3 +10,4 @@ ############################################################################### from Moore import options options.set_conds_from_testfiledb('upgrade_DC19_01_MinBiasMD') + diff --git a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py new file mode 100644 index 00000000000..b9d3998d074 --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py @@ -0,0 +1,36 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from RecoConf.standalone import standalone_hlt1_reco_and_allen +from Configurables import ApplicationMgr +from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable +from Configurables import DumpMuonGeometry, DumpVPGeometry +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks + +with standalone_hlt1_reco_and_allen.bind(do_mc_checking=True): + run_reconstruction(options, standalone_hlt1_reco_and_allen) + + +producers = [p(DumpToFile=False) for p in (DumpVPGeometry, + DumpUTGeometry, + DumpFTGeometry, + DumpMuonGeometry, + DumpMuonTable, + DumpMagneticField, + DumpBeamline, + DumpUTLookupTables)] + + +# Add the services that will produce the non-event-data +ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), +] + producers diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py new file mode 100644 index 00000000000..eb937cb4357 --- /dev/null +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -0,0 +1,39 @@ +############################################################################### +# (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 PyConf import configurable +from PyConf.components import ( + make_algorithm, + Algorithm, +) +from PyConf.application import default_raw_event, make_odin + +from Configurables import ( + VPClus, + createODIN, + DumpRawBanks, + RunAllen +) + +dump_raw_banks = make_algorithm( + DumpRawBanks, + defaults=dict(BankTypes=["VP", "UT", "FTCluster", "Muon"], DumpToFile=False)) + +@configurable +def make_dumped_raw_banks(make_raw=default_raw_event): + return dump_raw_banks(RawEventLocation=make_raw()).AllenRawInput + + +run_allen = makeAlgorithm( + RunAllen, + defaults=dict()) + +#def make_allen_host_buffers(): + diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 6371d9878ec..a35cc37bfbc 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -16,6 +16,8 @@ from .hlt1_tracking import ( make_PrForwardTracking_tracks, make_PatPV3DFuture_pvs, all_hlt1_forward_track_types, make_TrackEventFitter_fitted_tracks, make_hlt1_fitted_tracks) +from .hlt1_allen import ( + make_dumped_raw_banks) from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks @@ -52,7 +54,35 @@ def standalone_hlt1_reco(do_mc_checking=False): fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) muon_ids = make_muon_id(hlt1_tracks["Forward"]) tracks_with_muon_id = make_tracks_with_muon_id(fitted_tracks, muon_ids) + + data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] + + if do_mc_checking: + types_and_locations_for_checkers = { + "Velo": hlt1_tracks["Velo"], + "Upstream": hlt1_tracks["Upstream"], + "Forward": hlt1_tracks["Forward"], + } + data += get_track_checkers(types_and_locations_for_checkers) + return Reconstruction('hlt1_reco', data, reco_prefilters()) + +@configurable +def standalone_hlt1_reco_and_allen(do_mc_checking=False): + """ Run the Hlt1 reconstruction, i.e. tracking and muon id, MC checking optional both with the baseline and the Allen sequence + Args: + do_mc_checking (bool): Enable MC checking. + Returns: + Reconstruction: Data and control flow of Hlt1 reconstruction. + + """ + hlt1_tracks = make_hlt1_tracks() + pvs = make_pvs() + fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) + muon_ids = make_muon_id(hlt1_tracks["Forward"]) + tracks_with_muon_id = make_tracks_with_muon_id(fitted_tracks, muon_ids) + dumped_raw_banks = make_dumped_raw_banks() + data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] if do_mc_checking: -- GitLab From 04ed00699bc8401b23058d1011088e908a2e7a78 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 22 Jan 2020 16:02:50 +0100 Subject: [PATCH 035/171] call Allen --- .../tests/options/default_input_and_conds_hlt1.py | 2 +- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 14 ++++++++------ Hlt/RecoConf/python/RecoConf/standalone.py | 12 ++++++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 2bf391d876c..592a42d7fa4 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -12,6 +12,6 @@ import os from Moore import options options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') -options.evt_max = 1000 +options.evt_max = 10 execfile(os.path.expandvars('$MOOREROOT/tests/options/default_conds.py')) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index eb937cb4357..ad5dbf1e167 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -27,13 +27,15 @@ dump_raw_banks = make_algorithm( defaults=dict(BankTypes=["VP", "UT", "FTCluster", "Muon"], DumpToFile=False)) @configurable -def make_dumped_raw_banks(make_raw=default_raw_event): - return dump_raw_banks(RawEventLocation=make_raw()).AllenRawInput +def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin): + return dump_raw_banks(RawEventLocation=make_raw(), ODINLocation=odin_location()).AllenRawInput -run_allen = makeAlgorithm( +run_allen = make_algorithm( RunAllen, - defaults=dict()) + defaults=dict(DetectorConfigurationPath="../Allen/input/detector_configuration/down/", + AlgorithmConfigurationPath="../Allen/configuration/constants/")) + +def make_allen_output(odin_location=make_odin, dumped_raw_banks=make_dumped_raw_banks): + return run_allen(AllenRawInput=dumped_raw_banks(), ODINLocation=odin_location()).AllenOutput -#def make_allen_host_buffers(): - diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index a35cc37bfbc..a60fc77e385 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -17,7 +17,7 @@ from .hlt1_tracking import ( all_hlt1_forward_track_types, make_TrackEventFitter_fitted_tracks, make_hlt1_fitted_tracks) from .hlt1_allen import ( - make_dumped_raw_banks) + make_dumped_raw_banks, make_allen_output) from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks @@ -76,14 +76,18 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): Reconstruction: Data and control flow of Hlt1 reconstruction. """ + # baseline hlt1 hlt1_tracks = make_hlt1_tracks() pvs = make_pvs() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) muon_ids = make_muon_id(hlt1_tracks["Forward"]) tracks_with_muon_id = make_tracks_with_muon_id(fitted_tracks, muon_ids) - dumped_raw_banks = make_dumped_raw_banks() - - data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] + + # Allen hlt1 + #dumped_raw_banks = make_dumped_raw_banks() + allen_raw_output = make_allen_output() + + data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id, allen_raw_output] if do_mc_checking: types_and_locations_for_checkers = { -- GitLab From 4a01c09af88f26ef1a858a73f1b0ada27e40b97d Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 22 Jan 2020 16:42:07 +0100 Subject: [PATCH 036/171] call track converters and MC checking for Allen tracks --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 47 ++++++++++++++++++++++ Hlt/RecoConf/python/RecoConf/standalone.py | 13 +++--- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index ad5dbf1e167..576400bfcdf 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -22,6 +22,13 @@ from Configurables import ( RunAllen ) +from PyConf.Algorithms import ( + LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track, + AllenVeloToV2Tracks, + AllenUTToV2Tracks, + AllenForwardToV2Tracks +) + dump_raw_banks = make_algorithm( DumpRawBanks, defaults=dict(BankTypes=["VP", "UT", "FTCluster", "Muon"], DumpToFile=False)) @@ -39,3 +46,43 @@ run_allen = make_algorithm( def make_allen_output(odin_location=make_odin, dumped_raw_banks=make_dumped_raw_banks): return run_allen(AllenRawInput=dumped_raw_banks(), ODINLocation=odin_location()).AllenOutput +def make_allen_velo_tracks(): + allen_output = make_allen_output() + velo_tracks_v2 = AllenVeloToV2Tracks(AllenOutput=allen_output).OutputTracks + velo_tracks_v1 = FromV2TrackV1Track(InputTracksName=velo_tracks_v2).OutputTracksName + + return { + "v2" : velo_tracks_v2, + "v1" : velo_tracks_v1 + } + +def make_allen_veloUT_tracks(): + allen_output = make_allen_output() + veloUT_tracks_v2 = AllenUTToV2Tracks(AllenOutput=allen_output).OutputTracks + veloUT_tracks_v1 = FromV2TrackV1Track(InputTracksName=veloUT_tracks_v2).OutputTracksName + + return { + "v2" : veloUT_tracks_v2, + "v1" : veloUT_tracks_v1 + } + +def make_allen_forward_tracks(): + allen_output = make_allen_output() + forward_tracks_v2 = AllenForwardToV2Tracks(AllenOutput=allen_output).OutputTracks + forward_tracks_v1 = FromV2TrackV1Track(InputTracksName=forward_tracks_v2).OutputTracksName + + return { + "v2" : forward_tracks_v2, + "v1" : forward_tracks_v1 + } + +def make_allen_tracks(): + velo_tracks = make_allen_velo_tracks() + velo_ut_tracks = make_allen_veloUT_tracks() + forward_tracks = make_allen_forward_tracks() + + return { + "Velo" : velo_tracks, + "Upstream": velo_ut_tracks, + "Forward": forward_tracks, + } diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index a60fc77e385..f91d6d708d2 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -17,7 +17,7 @@ from .hlt1_tracking import ( all_hlt1_forward_track_types, make_TrackEventFitter_fitted_tracks, make_hlt1_fitted_tracks) from .hlt1_allen import ( - make_dumped_raw_banks, make_allen_output) + make_dumped_raw_banks, make_allen_output, make_allen_tracks) from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks @@ -84,16 +84,15 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): tracks_with_muon_id = make_tracks_with_muon_id(fitted_tracks, muon_ids) # Allen hlt1 - #dumped_raw_banks = make_dumped_raw_banks() - allen_raw_output = make_allen_output() + allen_tracks = make_allen_tracks() - data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id, allen_raw_output] + data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] if do_mc_checking: types_and_locations_for_checkers = { - "Velo": hlt1_tracks["Velo"], - "Upstream": hlt1_tracks["Upstream"], - "Forward": hlt1_tracks["Forward"], + "Velo": allen_tracks["Velo"], + "Upstream": allen_tracks["Upstream"], + "Forward": allen_tracks["Forward"], } data += get_track_checkers(types_and_locations_for_checkers) -- GitLab From 36d0afe32d9255530c796cc21e65376ae645ca45 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 22 Jan 2020 17:23:55 +0100 Subject: [PATCH 037/171] make Moore depend on Phys and Allen --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fb575652fd..352de7818fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ find_package(GaudiProject) # Declare project name and version gaudi_project(Moore v50r0 - USE Allen v0r7 + USE Phys v30r6 Allen v0r7 DATA AppConfig VERSION v3r* FieldMap VERSION v5r* PRConfig VERSION v1r* -- GitLab From 2daeb5bf7f0b26d5e9805946b430f66ba8e0511e Mon Sep 17 00:00:00 2001 From: bua Date: Thu, 23 Jan 2020 14:12:13 +0100 Subject: [PATCH 038/171] refactoring (MCTrackInfo added) --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index be64fe5f9a0..191d86aad88 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -273,7 +273,7 @@ def get_pv_checkers( assert isinstance( pvs, - DataHandle), "Please provide a dictionary of track type and tracks" + DataHandle), "Please provide reconstructed primary verticies" pv_checkers = [] @@ -282,9 +282,9 @@ def get_pv_checkers( inputVerticesName=pvs, inputTracksName=tracks["v1"], MCVertexInput=mc_unpackers()["MCVertices"], - # MCParticleInput=mc_unpackers()["MCParticles"], - # LinkerLocation=links_to_tracks, - MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header")) + MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), + MCPropertyInput=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo") + ) pv_checkers.append(pvchecker) return pv_checkers -- GitLab From cde921a55711c8c5a5d553b7d1bec6173559de24 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 23 Jan 2020 14:26:58 +0100 Subject: [PATCH 039/171] bsphiphi as input --- Hlt/Moore/tests/options/default_input_and_conds_hlt1.py | 6 ++++-- .../options/hlt1_reco_baseline_and_Allen_with_mcchecking.py | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 592a42d7fa4..92b7e926015 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -11,7 +11,9 @@ import os from Moore import options -options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') -options.evt_max = 10 +#options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') +options.set_input_from_testfiledb("Upgrade_BsPhiPhi_FTv4_DIGI") + +options.evt_max = 1000 execfile(os.path.expandvars('$MOOREROOT/tests/options/default_conds.py')) diff --git a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py index b9d3998d074..6d08af62e3e 100644 --- a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py +++ b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py @@ -19,7 +19,6 @@ from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenV with standalone_hlt1_reco_and_allen.bind(do_mc_checking=True): run_reconstruction(options, standalone_hlt1_reco_and_allen) - producers = [p(DumpToFile=False) for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, -- GitLab From 8c9474e37d3d3b2c815a0587d9f8d935fddc2c8a Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 23 Jan 2020 17:18:13 +0100 Subject: [PATCH 040/171] call PV converter and MC checking for Allen PVs --- Hlt/Moore/tests/options/default_input_and_conds_hlt1.py | 4 ++-- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 7 ++++++- Hlt/RecoConf/python/RecoConf/standalone.py | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 92b7e926015..8da7b5b7df0 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -11,8 +11,8 @@ import os from Moore import options -#options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') -options.set_input_from_testfiledb("Upgrade_BsPhiPhi_FTv4_DIGI") +options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') +#options.set_input_from_testfiledb("Upgrade_BsPhiPhi_FTv4_DIGI") options.evt_max = 1000 diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 576400bfcdf..c1503137e2b 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -26,7 +26,8 @@ from PyConf.Algorithms import ( LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track, AllenVeloToV2Tracks, AllenUTToV2Tracks, - AllenForwardToV2Tracks + AllenForwardToV2Tracks, + AllenPVsToRecVertexV2 ) dump_raw_banks = make_algorithm( @@ -86,3 +87,7 @@ def make_allen_tracks(): "Upstream": velo_ut_tracks, "Forward": forward_tracks, } + +def make_allen_pvs(): + allen_output = make_allen_output() + return AllenPVsToRecVertexV2(AllenOutput=allen_output).OutputPVs diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index fae7add43ef..693c4de04c1 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -17,7 +17,7 @@ from .hlt1_tracking import ( all_hlt1_forward_track_types, make_TrackEventFitter_fitted_tracks, make_hlt1_fitted_tracks) from .hlt1_allen import ( - make_dumped_raw_banks, make_allen_output, make_allen_tracks) + make_allen_tracks, make_allen_pvs) from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks @@ -88,6 +88,7 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): # Allen hlt1 allen_tracks = make_allen_tracks() + allen_pvs = make_allen_pvs() data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] @@ -98,6 +99,7 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): "Forward": allen_tracks["Forward"], } data += get_track_checkers(types_and_locations_for_checkers) + data += get_pv_checkers(allen_pvs, allen_tracks["Velo"]) return Reconstruction('hlt1_reco', data, reco_prefilters()) -- GitLab From ef1b8d709a53a0c199924b5cac046d1c1704402d Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 23 Jan 2020 17:58:52 +0100 Subject: [PATCH 041/171] write Allen DecReports to TES --- Hlt/Moore/tests/options/default_input_and_conds_hlt1.py | 2 +- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 7 ++++++- Hlt/RecoConf/python/RecoConf/standalone.py | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 8da7b5b7df0..796c9860834 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -14,6 +14,6 @@ from Moore import options options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') #options.set_input_from_testfiledb("Upgrade_BsPhiPhi_FTv4_DIGI") -options.evt_max = 1000 +options.evt_max = 10 execfile(os.path.expandvars('$MOOREROOT/tests/options/default_conds.py')) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index c1503137e2b..9640e2a765e 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -27,7 +27,8 @@ from PyConf.Algorithms import ( AllenVeloToV2Tracks, AllenUTToV2Tracks, AllenForwardToV2Tracks, - AllenPVsToRecVertexV2 + AllenPVsToRecVertexV2, + AllenDecReportsToTES ) dump_raw_banks = make_algorithm( @@ -91,3 +92,7 @@ def make_allen_tracks(): def make_allen_pvs(): allen_output = make_allen_output() return AllenPVsToRecVertexV2(AllenOutput=allen_output).OutputPVs + +def make_allen_dec_reports(): + allen_output = make_allen_output() + return AllenDecReportsToTES(AllenOutput=allen_output).OutputDecReports diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 693c4de04c1..962fbfbf574 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -17,7 +17,7 @@ from .hlt1_tracking import ( all_hlt1_forward_track_types, make_TrackEventFitter_fitted_tracks, make_hlt1_fitted_tracks) from .hlt1_allen import ( - make_allen_tracks, make_allen_pvs) + make_allen_tracks, make_allen_pvs, make_allen_dec_reports) from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks @@ -86,11 +86,14 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): muon_ids = make_muon_id(hlt1_tracks["Forward"]) tracks_with_muon_id = make_tracks_with_muon_id(fitted_tracks, muon_ids) + data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] + # Allen hlt1 allen_tracks = make_allen_tracks() allen_pvs = make_allen_pvs() + allen_dec_reports = make_allen_dec_reports() - data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] + data += [allen_dec_reports] if do_mc_checking: types_and_locations_for_checkers = { -- GitLab From 579344b78e9d172b96361228f0f7179aca6b3f3d Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 23 Jan 2020 16:59:45 +0000 Subject: [PATCH 042/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6894958 --- Hlt/Moore/tests/options/default_conds_FTv6.py | 1 - ...reco_baseline_and_Allen_with_mcchecking.py | 17 ++-- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 87 ++++++++++--------- Hlt/RecoConf/python/RecoConf/mc_checking.py | 8 +- Hlt/RecoConf/python/RecoConf/standalone.py | 11 +-- 5 files changed, 61 insertions(+), 63 deletions(-) diff --git a/Hlt/Moore/tests/options/default_conds_FTv6.py b/Hlt/Moore/tests/options/default_conds_FTv6.py index 0d5089fcf18..f8a23c89b00 100644 --- a/Hlt/Moore/tests/options/default_conds_FTv6.py +++ b/Hlt/Moore/tests/options/default_conds_FTv6.py @@ -10,4 +10,3 @@ ############################################################################### from Moore import options options.set_conds_from_testfiledb('upgrade_DC19_01_MinBiasMD') - diff --git a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py index 6d08af62e3e..3d3321275af 100644 --- a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py +++ b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py @@ -19,17 +19,14 @@ from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenV with standalone_hlt1_reco_and_allen.bind(do_mc_checking=True): run_reconstruction(options, standalone_hlt1_reco_and_allen) -producers = [p(DumpToFile=False) for p in (DumpVPGeometry, - DumpUTGeometry, - DumpFTGeometry, - DumpMuonGeometry, - DumpMuonTable, - DumpMagneticField, - DumpBeamline, - DumpUTLookupTables)] +producers = [ + p(DumpToFile=False) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) +] - -# Add the services that will produce the non-event-data +# Add the services that will produce the non-event-data ApplicationMgr().ExtSvc += [ AllenUpdater(OutputLevel=2), ] + producers diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 9640e2a765e..dc780f34c86 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -15,84 +15,85 @@ from PyConf.components import ( ) from PyConf.application import default_raw_event, make_odin -from Configurables import ( - VPClus, - createODIN, - DumpRawBanks, - RunAllen -) +from Configurables import (VPClus, createODIN, DumpRawBanks, RunAllen) -from PyConf.Algorithms import ( - LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track, - AllenVeloToV2Tracks, - AllenUTToV2Tracks, - AllenForwardToV2Tracks, - AllenPVsToRecVertexV2, - AllenDecReportsToTES -) +from PyConf.Algorithms import (LHCb__Converters__Track__v1__fromV2TrackV1Track + as FromV2TrackV1Track, AllenVeloToV2Tracks, + AllenUTToV2Tracks, AllenForwardToV2Tracks, + AllenPVsToRecVertexV2, AllenDecReportsToTES) dump_raw_banks = make_algorithm( DumpRawBanks, - defaults=dict(BankTypes=["VP", "UT", "FTCluster", "Muon"], DumpToFile=False)) - + defaults=dict( + BankTypes=["VP", "UT", "FTCluster", "Muon"], DumpToFile=False)) + + @configurable def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin): - return dump_raw_banks(RawEventLocation=make_raw(), ODINLocation=odin_location()).AllenRawInput + return dump_raw_banks( + RawEventLocation=make_raw(), + ODINLocation=odin_location()).AllenRawInput run_allen = make_algorithm( RunAllen, - defaults=dict(DetectorConfigurationPath="../Allen/input/detector_configuration/down/", - AlgorithmConfigurationPath="../Allen/configuration/constants/")) + defaults=dict( + DetectorConfigurationPath="../Allen/input/detector_configuration/down/", + AlgorithmConfigurationPath="../Allen/configuration/constants/")) + + +def make_allen_output(odin_location=make_odin, + dumped_raw_banks=make_dumped_raw_banks): + return run_allen( + AllenRawInput=dumped_raw_banks(), + ODINLocation=odin_location()).AllenOutput -def make_allen_output(odin_location=make_odin, dumped_raw_banks=make_dumped_raw_banks): - return run_allen(AllenRawInput=dumped_raw_banks(), ODINLocation=odin_location()).AllenOutput def make_allen_velo_tracks(): allen_output = make_allen_output() velo_tracks_v2 = AllenVeloToV2Tracks(AllenOutput=allen_output).OutputTracks - velo_tracks_v1 = FromV2TrackV1Track(InputTracksName=velo_tracks_v2).OutputTracksName - - return { - "v2" : velo_tracks_v2, - "v1" : velo_tracks_v1 - } + velo_tracks_v1 = FromV2TrackV1Track( + InputTracksName=velo_tracks_v2).OutputTracksName + + return {"v2": velo_tracks_v2, "v1": velo_tracks_v1} + def make_allen_veloUT_tracks(): allen_output = make_allen_output() veloUT_tracks_v2 = AllenUTToV2Tracks(AllenOutput=allen_output).OutputTracks - veloUT_tracks_v1 = FromV2TrackV1Track(InputTracksName=veloUT_tracks_v2).OutputTracksName - - return { - "v2" : veloUT_tracks_v2, - "v1" : veloUT_tracks_v1 - } + veloUT_tracks_v1 = FromV2TrackV1Track( + InputTracksName=veloUT_tracks_v2).OutputTracksName + + return {"v2": veloUT_tracks_v2, "v1": veloUT_tracks_v1} + def make_allen_forward_tracks(): allen_output = make_allen_output() - forward_tracks_v2 = AllenForwardToV2Tracks(AllenOutput=allen_output).OutputTracks - forward_tracks_v1 = FromV2TrackV1Track(InputTracksName=forward_tracks_v2).OutputTracksName - - return { - "v2" : forward_tracks_v2, - "v1" : forward_tracks_v1 - } + forward_tracks_v2 = AllenForwardToV2Tracks( + AllenOutput=allen_output).OutputTracks + forward_tracks_v1 = FromV2TrackV1Track( + InputTracksName=forward_tracks_v2).OutputTracksName + + return {"v2": forward_tracks_v2, "v1": forward_tracks_v1} + def make_allen_tracks(): velo_tracks = make_allen_velo_tracks() velo_ut_tracks = make_allen_veloUT_tracks() forward_tracks = make_allen_forward_tracks() - + return { - "Velo" : velo_tracks, + "Velo": velo_tracks, "Upstream": velo_ut_tracks, "Forward": forward_tracks, - } + } + def make_allen_pvs(): allen_output = make_allen_output() return AllenPVsToRecVertexV2(AllenOutput=allen_output).OutputPVs + def make_allen_dec_reports(): allen_output = make_allen_output() return AllenDecReportsToTES(AllenOutput=allen_output).OutputDecReports diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 6620ce57740..234538378e1 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -272,8 +272,7 @@ def get_pv_checkers( ): assert isinstance( - pvs, - DataHandle), "Please provide reconstructed primary verticies" + pvs, DataHandle), "Please provide reconstructed primary verticies" pv_checkers = [] @@ -283,8 +282,8 @@ def get_pv_checkers( inputTracksName=tracks["v1"], MCVertexInput=mc_unpackers()["MCVertices"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), - MCPropertyInput=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo") - ) + MCPropertyInput=make_data_with_FetchDataFromFile( + "/Event/MC/TrackInfo")) pv_checkers.append(pvchecker) return pv_checkers @@ -296,6 +295,7 @@ def make_track_filter(InputTracks, code): inputLocation=InputTracks["v1"], Selector=selector).outputLocation return filtered_tracks + def monitor_track_resolution(InputTracks): links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 962fbfbf574..4cb532713d5 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -16,8 +16,8 @@ from .hlt1_tracking import ( make_PrForwardTracking_tracks, make_PatPV3DFuture_pvs, all_hlt1_forward_track_types, make_TrackEventFitter_fitted_tracks, make_hlt1_fitted_tracks) -from .hlt1_allen import ( - make_allen_tracks, make_allen_pvs, make_allen_dec_reports) +from .hlt1_allen import (make_allen_tracks, make_allen_pvs, + make_allen_dec_reports) from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks @@ -54,7 +54,7 @@ def standalone_hlt1_reco(do_mc_checking=False): fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) muon_ids = make_muon_id(hlt1_tracks["Forward"]) tracks_with_muon_id = make_tracks_with_muon_id(fitted_tracks, muon_ids) - + data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] if do_mc_checking: @@ -70,6 +70,7 @@ def standalone_hlt1_reco(do_mc_checking=False): return Reconstruction('hlt1_reco', data, reco_prefilters()) + @configurable def standalone_hlt1_reco_and_allen(do_mc_checking=False): """ Run the Hlt1 reconstruction, i.e. tracking and muon id, MC checking optional both with the baseline and the Allen sequence @@ -87,12 +88,12 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): tracks_with_muon_id = make_tracks_with_muon_id(fitted_tracks, muon_ids) data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] - + # Allen hlt1 allen_tracks = make_allen_tracks() allen_pvs = make_allen_pvs() allen_dec_reports = make_allen_dec_reports() - + data += [allen_dec_reports] if do_mc_checking: -- GitLab From 59989a3564178acadb30b14c27bc46990986233b Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 24 Jan 2020 12:36:57 +0100 Subject: [PATCH 043/171] call IP resolution and track resolution checks for Allen --- .../options/default_input_and_conds_hlt1.py | 2 +- .../options/hlt1_reco_IPresolution.py | 4 +- .../options/hlt1_reco_allen_IPresolution.py | 51 +++++++++++++++++++ .../hlt1_reco_allen_trackresolution.py | 48 +++++++++++++++++ Hlt/RecoConf/python/RecoConf/mc_checking.py | 6 +-- 5 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py create mode 100644 Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 796c9860834..8da7b5b7df0 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -14,6 +14,6 @@ from Moore import options options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') #options.set_input_from_testfiledb("Upgrade_BsPhiPhi_FTv4_DIGI") -options.evt_max = 10 +options.evt_max = 1000 execfile(os.path.expandvars('$MOOREROOT/tests/options/default_conds.py')) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index 2d3221e8b59..6753709704d 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -10,7 +10,7 @@ ############################################################################### from Moore import options, run_reconstruction from Moore.config import Reconstruction -from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks, make_pvs from RecoConf.mc_checking import monitor_IPresolution from Configurables import ApplicationMgr from Configurables import NTupleSvc @@ -19,7 +19,9 @@ from Configurables import NTupleSvc def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) + pvs = make_pvs() pr_checker = monitor_IPresolution(fitted_tracks["v1"], + pvs, hlt1_tracks["Velo"]["v1"]) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py new file mode 100644 index 00000000000..7bae6f8c7ed --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py @@ -0,0 +1,51 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec, make_VeloKalman_fitted_tracks +from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs +from RecoConf.mc_checking import monitor_IPresolution +from Configurables import ApplicationMgr +from Configurables import NTupleSvc +from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable +from Configurables import DumpMuonGeometry, DumpVPGeometry +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import AllenUpdater + +def hlt1_reco_allen_IPresolution(): + allen_tracks = make_allen_tracks() + allen_pvs = make_allen_pvs() + pr_checker = monitor_IPresolution(allen_tracks["Forward"]["v1"], + allen_pvs, + allen_tracks["Velo"]["v1"]) + + return Reconstruction('IPresolution', [pr_checker], [require_gec()]) + + +run_reconstruction(options, hlt1_reco_allen_IPresolution) + +NTupleSvc().Output += [ + "FILE1 DATAFILE='Hlt1ForwardTracking_IPresolution_Allen.root' TYPE='ROOT' OPT='NEW'" +] +ApplicationMgr().ExtSvc += [NTupleSvc()] +ApplicationMgr().HistogramPersistency = "ROOT" + +producers = [ + p(DumpToFile=False) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) +] + +# Add the services that will produce the non-event-data +ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), +] + producers diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py new file mode 100644 index 00000000000..a7b342b4ad8 --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py @@ -0,0 +1,48 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec +from RecoConf.hlt1_allen import make_allen_tracks +from RecoConf.mc_checking import monitor_track_resolution +from Configurables import ApplicationMgr +from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable +from Configurables import DumpMuonGeometry, DumpVPGeometry +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import AllenUpdater + +def hlt1_reco_allen_trackresolution(): + track_type = "Forward" + tracks = make_allen_tracks()[track_type] + pr_checker = monitor_track_resolution(tracks) + + #return CompositeNode( + # name='hlt1_trackRes', + # children=pr_checker, + # combineLogic=NodeLogic.NONLAZY_OR, + # forceOrder=False) + return Reconstruction('track_resolution', [pr_checker], [require_gec()]) + + +options.histo_file = "Hlt1ForwardTrackingResolutionAllen.root" +run_reconstruction(options, hlt1_reco_allen_trackresolution) + +producers = [ + p(DumpToFile=False) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) +] + +# Add the services that will produce the non-event-data +ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), +] + producers diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 234538378e1..83c9724d4bb 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -32,7 +32,7 @@ from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector from RecoConf.hlt1_tracking import (make_PrStoreUTHit_hits, make_FTRawBankDecoder_clusters, - make_velo_full_clusters, make_pvs) + make_velo_full_clusters) from Hlt2Conf.data_from_file import mc_unpackers @@ -307,10 +307,10 @@ def monitor_track_resolution(InputTracks): return res_checker -def monitor_IPresolution(InputTracks, VeloTracks): +def monitor_IPresolution(InputTracks, InputVertices, VeloTracks): vertexConverter = FromVectorLHCbRecVertex( - InputVerticesName=make_pvs(), + InputVerticesName=InputVertices, InputTracksName=VeloTracks).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( -- GitLab From 8a2b04eae141966d93fa9a3e60ceee65800259b9 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 24 Jan 2020 17:32:07 +0100 Subject: [PATCH 044/171] save Allen histograms --- Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py index 7bae6f8c7ed..cfad3cd96ce 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py @@ -29,6 +29,7 @@ def hlt1_reco_allen_IPresolution(): return Reconstruction('IPresolution', [pr_checker], [require_gec()]) +options.histo_file = "AllenQuantities.root" run_reconstruction(options, hlt1_reco_allen_IPresolution) @@ -49,3 +50,5 @@ producers = [ ApplicationMgr().ExtSvc += [ AllenUpdater(OutputLevel=2), ] + producers + + -- GitLab From 067a8110c0c72fe44d79d36aaf6a5e521619b2d1 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Mon, 27 Jan 2020 12:21:51 +0100 Subject: [PATCH 045/171] add scripts for plotting tracking efficiency --- .../options/hlt1_reco_IPresolution.py | 2 +- Hlt/RecoConf/scripts/Legend.py | 117 ++++++++ .../scripts/PrCheckerEfficiency_HLT1.py | 268 ++++++++++++++++++ Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 5 +- .../scripts/PrCheckerTrackResolution.py | 5 +- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 139 +++++++++ Hlt/RecoConf/scripts/utils/Legend.py | 50 +--- 7 files changed, 545 insertions(+), 41 deletions(-) create mode 100644 Hlt/RecoConf/scripts/Legend.py create mode 100644 Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py create mode 100644 Hlt/RecoConf/scripts/utils/ConfigHistos.py diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index 2d3221e8b59..587b0b2c880 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -10,7 +10,7 @@ ############################################################################### from Moore import options, run_reconstruction from Moore.config import Reconstruction -from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks from RecoConf.mc_checking import monitor_IPresolution from Configurables import ApplicationMgr from Configurables import NTupleSvc diff --git a/Hlt/RecoConf/scripts/Legend.py b/Hlt/RecoConf/scripts/Legend.py new file mode 100644 index 00000000000..33e479a6fcc --- /dev/null +++ b/Hlt/RecoConf/scripts/Legend.py @@ -0,0 +1,117 @@ +import ROOT +import itertools +from ROOT import gStyle + +# Some convenience function to easily iterate over the parts of the collections + + +# Needed if importing this script from another script in case TMultiGraphs are used +#ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) + + +# Start a bit right of the Yaxis and above the Xaxis to not overlap with the ticks +start, stop = 0.18, 0.89 +x_width, y_width = 0.3, 0.2 +PLACES = [(start, stop - y_width, start + x_width, stop), # top left opt + (start, start, start + x_width, start + y_width), # bottom left opt + (stop - x_width, stop - y_width, stop, stop), # top right opt + (stop - x_width, start, stop, start + y_width), # bottom right opt + (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right + (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2)] # left + + +def transform_to_user(canvas, x1, y1, x2, y2): + """ + Transforms from Pad coordinates to User coordinates. + + This can probably be replaced by using the built-in conversion commands. + """ + xstart = canvas.GetX1() + xlength = canvas.GetX2() - xstart + xlow = xlength * x1 + xstart + xhigh = xlength * x2 + xstart + if canvas.GetLogx(): + xlow = 10**xlow + xhigh = 10**xhigh + + ystart = canvas.GetY1() + ylength = canvas.GetY2() - ystart + ylow = ylength * y1 + ystart + yhigh = ylength * y2 + ystart + if canvas.GetLogy(): + ylow = 10**ylow + yhigh = 10**yhigh + + return xlow, ylow, xhigh, yhigh + + +def overlap_h(hist, x1, y1, x2, y2): + xlow = hist.FindFixBin(x1) + xhigh = hist.FindFixBin(x2) + for i in range(xlow, xhigh + 1): + val = hist.GetBinContent(i) + # Values + if y1 <= val <= y2: + return True + # Errors + if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow(i) < y2: + # print "Overlap with histo", hist.GetName(), "at bin", i + return True + return False + + +def overlap_rect(rect1, rect2): + """Do the two rectangles overlap?""" + if rect1[0] > rect2[2] or rect1[2] < rect2[0]: + return False + if rect1[1] > rect2[3] or rect1[3] < rect2[1]: + return False + return True + +def overlap_g(graph, x1, y1, x2, y2): + x_values = list(graph.GetX()) + y_values = list(graph.GetY()) + x_err = list(graph.GetEX()) or [0] * len(x_values) + y_err = list(graph.GetEY()) or [0] * len(y_values) + + for x, ex, y, ey in zip(x_values, x_err, y_values, y_err): + # Could maybe be less conservative + if overlap_rect((x1, y1, x2, y2), (x - ex, y - ey, x + ex, y + ey)): + # print "Overlap with graph", graph.GetName(), "at point", (x, y) + return True + return False + +def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option="LPF"): + gStyle.SetFillStyle(0) + gStyle.SetTextSize(0.09) + # If position is specified, use that + if all(x is not None for x in (x1, x2, y1, y2)): + return canvas.BuildLegend(x1, y1, x2, y2, header, option) + + # Make sure all objects are correctly registered + canvas.Update() + + # Build a list of objects to check for overlaps + objects = [] + for x in canvas.GetListOfPrimitives(): + if isinstance(x, ROOT.TH1) or isinstance(x, ROOT.TGraph): + objects.append(x) + elif isinstance(x, ROOT.THStack) or isinstance(x, ROOT.TMultiGraph): + objects.extend(x) + + for place in PLACES: + place_user = canvas.PadtoU(*place) + # Make sure there are no overlaps + if any(obj.Overlap(*place_user) for obj in objects): + continue + return canvas.BuildLegend(place[0], place[1], place[2], place[3], header, option) + # As a fallback, use the default values, taken from TCanvas::BuildLegend + return canvas.BuildLegend(0.5, 0.67, 0.88, 0.88, header, option) + +# Monkey patch ROOT objects to make it all work +ROOT.THStack.__iter__ = lambda self: iter(self.GetHists()) +ROOT.TMultiGraph.__iter__ = lambda self: iter(self.GetListOfGraphs()) +ROOT.TH1.Overlap = overlap_h +ROOT.TGraph.Overlap = overlap_g +ROOT.TPad.PadtoU = transform_to_user +ROOT.TPad.PlaceLegend = place_legend diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py new file mode 100644 index 00000000000..ef67dfeaebb --- /dev/null +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -0,0 +1,268 @@ +#!/usr/bin/python + +# Script for accessing histograms of reconstructible and +# reconstructed tracks for different tracking categories +# created by PrChecker2 +# +# The efficency is calculated usig TGraphAsymmErrors +# and Bayesian error bars +# +# author: Dorothea vom Bruch (dorothea.vom.bruch@cern.ch) +# date: 10/2018 +# updated by Peilian Li +# + +import os,sys +import argparse +import ROOT +from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad +from ROOT import gROOT, gStyle, TStyle, TPaveText +from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors +#from BaseHandler import BaseHandler +#from collectRunResults import urlopen +import logging +import subprocess +#from collectRunResults import send_notification_mattermost + +def getEfficiencyHistoNames() : + return ["eta", "p", "pt", "phi", "nPV"] + +def getTrackers() : + return ["Velo", "Upstream", "Forward"] + +def getOriginFolders() : + basedict = { + "Velo" : {}, + "Upstream" : {}, + "Forward" : {} + } + + basedict["Velo"]["folder"] = "VeloTrackChecker/" + basedict["Upstream"]["folder"] = "UpstreamTrackChecker/" + basedict["Forward"]["folder"] = "ForwardTrackChecker/" + + return basedict + +def getGhostHistoNames() : + return ["eta", "nPV", "pt", "p"] + +def getMode() : + return ["Bd2Kstee", "Bs2PhiPhi", "Dp2KSPip", "Dst2D0pi", "Z2mumu", "Bd2Dstmumu"] + +def argument_parser(): + parser = argparse.ArgumentParser(description="location of the tuple file") + parser.add_argument( + '--directory', + type=str, + default=os.getcwd(), + help='location of input tuple files') + parser.add_argument( + '--mode', + type=str, + default='Bs2PhiPhi', + help='decay mode') + parser.add_argument( + '--method', + type=str, + default='baseline', + help='HLT1 reconstruction method') + parser.add_argument( + '--plotstyle', default='', help='location of LHCb utils plot style file') + return parser + + +def PrCheckerEfficiency(directory, mode, method, plotstyle): + sys.path.append(os.path.abspath(plotstyle)) + from utils.LHCbStyle import setLHCbStyle + from utils.ConfigHistos import (efficiencyHistoDict, + ghostHistoDict, + categoriesDict, + getCuts) + from utils.Legend import place_legend + setLHCbStyle() + + f = TFile(directory+"/MCMatching_"+method+"_"+mode+".root", "read") + outputfile=TFile(directory+"/efficiency_plots_"+method+"_"+mode+".root", "recreate") + + latex=TLatex() + latex.SetNDC() + latex.SetTextSize(0.045) + + efficiencyHistoDict = efficiencyHistoDict() + efficiencyHistos = getEfficiencyHistoNames() + ghostHistos = getGhostHistoNames() + ghostHistoDict = ghostHistoDict() + categories = categoriesDict() + cuts = getCuts() + trackers = getTrackers() + folders = getOriginFolders() + + for tracker in trackers : + outputfile.cd() + trackerDir = outputfile.mkdir(tracker) + trackerDir.cd() + + for cut in cuts[tracker]: + cutDir = trackerDir.mkdir(cut) + cutDir.cd() + folder = folders[tracker]["folder"] + print (folder) + histoBaseName = "Track/" + folder + tracker + "/" + cut + "_" + + # calculate efficiency + for histo in efficiencyHistos: + title = "efficiency vs. " + histo + ", " + categories[tracker][cut]["title"] + name = "efficiency vs. " + histo + canvas = TCanvas(name, title) + # get efficiency for not electrons category + histoName = histoBaseName + "" + efficiencyHistoDict[histo]["variable"] + print ("not electrons: " + histoName) + numeratorName = histoName + "_reconstructed" + numerator = f.Get(numeratorName) + denominatorName = histoName + "_reconstructible" + denominator = f.Get(denominatorName) + if numerator.GetEntries() == 0 or denominator.GetEntries() == 0 : + continue + + numerator.Sumw2() + denominator.Sumw2() + + g_efficiency_notElectrons = TGraphAsymmErrors() + g_efficiency_notElectrons.SetName("g_efficiency_notElectrons") + g_efficiency_notElectrons.Divide(numerator, denominator, "cl=0.683 b(1,1) mode") + g_efficiency_notElectrons.SetTitle("Eff. not electrons") + if (histoName.find('strange') != -1) : + g_efficiency_notElectrons.SetTitle("Eff. from stranges") + g_efficiency_notElectrons.Draw() + + h_numerator_notElectrons = denominator.Clone() + h_numerator_notElectrons.SetName("h_numerator_notElectrons") + h_numerator_notElectrons.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. not electrons") + if (histoName.find('strange') != -1) : + h_numerator_notElectrons.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. stranges") + + # get efficiency for electrons category + if categories[tracker][cut]["plotElectrons"] : + histoNameElec = "Track/" + folder + tracker + "/" + categories[tracker][cut]["Electrons"] + histoName = histoNameElec + "_" + efficiencyHistoDict[histo]["variable"] + print ("electrons: " + histoName) + numeratorName = histoName + "_reconstructed" + numerator = f.Get(numeratorName) + denominatorName = histoName + "_reconstructible" + denominator = f.Get(denominatorName) + if numerator.GetEntries() == 0 or denominator.GetEntries() == 0 : + continue + + numerator.Sumw2() + denominator.Sumw2() + + g_efficiency_electrons = TGraphAsymmErrors() + g_efficiency_electrons.SetName("g_efficiency_electrons") + g_efficiency_electrons.Divide(numerator, denominator, "cl=0.683 b(1,1) mode") + g_efficiency_electrons.SetTitle("Eff. electrons") + g_efficiency_electrons.SetMarkerColor(kAzure-3) + g_efficiency_electrons.SetMarkerStyle(24) + g_efficiency_electrons.SetLineColor(kAzure-3) + + h_numerator_electrons = denominator.Clone() + h_numerator_electrons.SetName("h_numerator_electrons") + h_numerator_electrons.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. electrons") + + #draw them both + mg = TMultiGraph() + mg.Add(g_efficiency_notElectrons) + if categories[tracker][cut]["plotElectrons"] : + mg.Add(g_efficiency_electrons) + + mg.Draw("ap") + xtitle = efficiencyHistoDict[histo]["xTitle"] + mg.GetXaxis().SetTitle(xtitle) + mg.GetYaxis().SetTitle("Efficiency") + mg.GetYaxis().SetRangeUser(0,1.05) + + mg.SetName("efficiency vs. " + histo) + mg.SetTitle(tracker+" " +cut) + + rightmax = 1.05*h_numerator_notElectrons.GetMaximum() + scale = gPad.GetUymax()/rightmax + h_numerator_notElectrons.Scale(scale) + h_numerator_notElectrons.SetFillStyle(3004) + h_numerator_notElectrons.SetFillColor(kBlue) + h_numerator_notElectrons.SetLineColor(kBlue-10) + h_numerator_notElectrons.SetLineWidth(2) + h_numerator_notElectrons.Draw("hist same") + if categories[tracker][cut]["plotElectrons"] : + scale = gPad.GetUymax()/(h_numerator_electrons.GetMaximum()*1.1) + h_numerator_electrons.Scale(scale) + h_numerator_electrons.SetFillStyle(3003) + h_numerator_electrons.SetFillColor(kGreen) + h_numerator_electrons.SetLineColor(kGreen-10) + h_numerator_electrons.SetLineWidth(2) + h_numerator_electrons.Draw("hist same") + axis = TGaxis(gPad.GetUxmax(), 0, gPad.GetUxmax(), 1.05, 0,rightmax,510,"+L") + if histo == "p": + axis = TGaxis(50000, 0, 50000, 1.05, 0,rightmax,510,"+L") + mg.GetXaxis().SetRangeUser(0,50000) + if histo == "pt": + axis = TGaxis(5000, 0, 5000, 1.05, 0,rightmax,510,"+L") + mg.GetXaxis().SetRangeUser(0,5000) + axis.SetTitle("Number of events") + axis.SetTextFont(132) + axis.SetLabelFont(132) + axis.SetTitleFont(132) + axis.SetLabelSize(0.06) + axis.SetTitleSize(0.07) + axis.SetNdivisions(505) + gPad.SetRightMargin(0.75) + + canvas.PlaceLegend() + + pt = TPaveText(0.32,0.65,0.68,0.8,"BRNDC"); + pt.SetTextSize(0.05); + pt.SetBorderSize(1); + pt.SetFillColor(10); + pt.SetLineWidth(0); + cutName=categories[tracker][cut]["title"] + text=pt.AddText(cutName); + pt.Draw() + canvas.SetRightMargin(0.05) + canvas.Write() + + # calculate ghost rate + if tracker == "Forward": + histoBaseName = "Track/" + folder + tracker + "/" + for histo in ghostHistos : + trackerDir.cd() + title = "ghost rate vs " + histo + canvas = TCanvas(title, title) + gPad.SetTicks() + numeratorName = histoBaseName + ghostHistoDict[histo]["variable"] + "_Ghosts" + denominatorName = histoBaseName + ghostHistoDict[histo]["variable"] + "_Total" + print ("ghost histo: " + histoBaseName + " " + numeratorName+" "+denominatorName) + numerator = f.Get(numeratorName) + denominator = f.Get(denominatorName) + numerator.Sumw2() + denominator.Sumw2() + + g_efficiency = TGraphAsymmErrors() + g_efficiency.SetName(title + " ref") + g_efficiency.Divide(numerator, denominator, "cl=0.683 b(1,1) mode") + + xtitle = ghostHistoDict[histo]["xTitle"] + g_efficiency.GetXaxis().SetTitle(xtitle) + g_efficiency.GetYaxis().SetTitle("ghost rate") + g_efficiency.Write() + g_efficiency.Draw("ap") + + canvas.Write() + + outputfile.Write() + outputfile.Close() + f.Close() + + +if __name__ == '__main__': + parser = argument_parser() + args = parser.parse_args() + PrCheckerEfficiency(**vars(args)) diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index cc3c1687c24..02b6564642c 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -8,6 +8,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +#!/usr/bin/env python ''' Script for accessing tuples of IP resolution checker to obtain the values of mean and width of IP resolution as well as a check of the IP error distribution and efficiencies in different chi2 cut. @@ -44,14 +45,14 @@ def argument_parser(): default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') parser.add_argument( - '--plotstyle', default='', help='location of LHCb plot style file') + '--plotstyle', default='', help='location of LHCb utils plot style file') return parser def PrCheckerIPresolution(directory, name, plotstyle): sys.path.append(os.path.abspath(plotstyle)) - from LHCbStyle import setLHCbStyle + from utils.LHCbStyle import setLHCbStyle setLHCbStyle() f = TFile.Open(os.path.join(directory, name + '.root'), 'read') diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index 64dbf24a1f8..b506a025a37 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -8,6 +8,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +#!/usr/bin/env python ''' Script for the plots of tracking resolution v.s. p and eta The resolution is fitted by a Gaussian function @@ -43,14 +44,14 @@ def argument_parser(): default='Hlt1ForwardTrackingResolution', help='name of input tuple files') parser.add_argument( - '--plotstyle', default='', help='location of LHCb plot style file') + '--plotstyle', default='', help='location of LHCb utils plot style file') return parser def PrCheckerTrackResolution(directory, name, plotstyle): sys.path.append(os.path.abspath(plotstyle)) - from LHCbStyle import setLHCbStyle + from utils.LHCbStyle import setLHCbStyle from Legend import place_legend setLHCbStyle() diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py new file mode 100644 index 00000000000..c51f030978a --- /dev/null +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -0,0 +1,139 @@ +from collections import defaultdict + +def efficiencyHistoDict() : + basedict = { + "eta" : {}, + "p" : {}, + "pt" : {}, + "phi" : {}, + "nPV" : {}, + "docaz" : {} + } + + basedict["eta"]["xTitle"] = "#eta" + basedict["eta"]["variable"] = "Eta" + + basedict["p"]["xTitle"] = "p [MeV]" + basedict["p"]["variable"] = "P" + + basedict["pt"]["xTitle"] = "p_{T} [MeV]" + basedict["pt"]["variable"] = "Pt" + + basedict["phi"]["xTitle"] = "#phi [rad]" + basedict["phi"]["variable"] = "Phi" + + basedict["nPV"]["xTitle"] = "# of PVs" + basedict["nPV"]["variable"] = "nPV" + + basedict["docaz"]["xTitle"] = "docaz (mm)" + basedict["docaz"]["variable"] = "docaz" + + return basedict + +def ghostHistoDict() : + basedict = { + "eta" : {}, + "nPV" : {}, + "pt" : {}, + "p" : {} + } + + basedict["eta"]["xTitle"] = "#eta" + basedict["eta"]["variable"] = "Eta" + + basedict["nPV"]["xTitle"] = "# of PVs" + basedict["nPV"]["variable"] = "nPV" + + basedict["pt"]["xTitle"] = "p_{T} [MeV]" + basedict["pt"]["variable"] = "Pt" + + basedict["p"]["xTitle"] = "p [MeV]" + basedict["p"]["variable"] = "P" + + return basedict + +def getCuts() : + basedict = { + "Velo" : {}, + "Upstream" : {}, + "Forward" : {} + } + + basedict["Velo"] = ["01_velo","02_long", "03_long_P>5GeV", "04_long_strange", "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV"] + basedict["Upstream"] = ["01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV"] + basedict["Forward"] = ["01_long", "02_long_P>5GeV", "03_long_strange", "04_long_strange_P>5GeV", "05_long_fromB_P", "06_long_fromB_P>5GeV", "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV"] + + return basedict + +def categoriesDict() : + basedict = defaultdict(lambda : defaultdict(dict)) + + basedict["Velo"]["01_velo"]["title"] = "Velo, 2 < eta < 5" + basedict["Velo"]["02_long"]["title"] = "Long, 2 < eta < 5" + basedict["Velo"]["03_long_P>5GeV"]["title"] = "Long, p>5GeV, 2 < eta < 5" + basedict["Velo"]["04_long_strange"]["title"] = "Long, from Strange, 2 < eta < 5" + basedict["Velo"]["05_long_strange_P>5GeV"]["title"] = "Long, from Strange, p>5GeV, 2 < eta < 5" + basedict["Velo"]["06_long_fromB"]["title"] = "Long from B, 25GeV"]["title"] = "Long from B, p>5GeV, 23GeV_Pt>0.5GeV"]["title"] = "Long from B, p>3GeV, pt>0.5GeV, electron" + basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "UT Long, from B, p>3GeV, pt>0.5GeV" + basedict["Velo"]["01_velo"]["plotElectrons"] = False + basedict["Velo"]["02_long"]["plotElectrons"] = True + basedict["Velo"]["03_long_P>5GeV"]["plotElectrons"] = False + basedict["Velo"]["04_long_strange"]["plotElectrons"] = False + basedict["Velo"]["05_long_strange_P>5GeV"]["plotElectrons"] = False + basedict["Velo"]["06_long_fromB"]["plotElectrons"] = True + basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True + basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + + basedict["Velo"]["02_long"]["Electrons"] = "08_long_electrons" + basedict["Velo"]["06_long_fromB"]["Electrons"] = "09_long_fromB_electrons" + basedict["Velo"]["07_long_fromB_P>5GeV"]["Electrons"] = "10_long_fromB_electrons_P>5GeV" + + basedict["Upstream"]["01_velo"]["title"] = "Velo, 2 < eta < 5" + basedict["Upstream"]["02_velo+UT"]["title"] = "VeloUT, 2 < eta < 5" + basedict["Upstream"]["03_velo+UT_P>5GeV"]["title"] = "VeloUT, p>5GeV, 2 < eta < 5" + basedict["Upstream"]["07_long"]["title"] = "Long, 2 < eta < 5" + basedict["Upstream"]["08_long_P>5GeV"]["title"] = "Long, p>5GeV, 2 < eta < 5" + basedict["Upstream"]["09_long_fromB"]["title"] = "Long from B, 2 < eta < 5" + basedict["Upstream"]["10_long_fromB_P>5GeV"]["title"] = "Long from B, p>5GeV, 2 < eta < 5" + basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "Long, from B, p>3GeV, pt>0.5GeV" + basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "Long, from B, p>3GeV, pt>0.5GeV" + + basedict["Upstream"]["01_velo"]["plotElectrons"] = False + basedict["Upstream"]["02_velo+UT"]["plotElectrons"] = False + basedict["Upstream"]["03_velo+UT_P>5GeV"]["plotElectrons"] = False + basedict["Upstream"]["07_long"]["plotElectrons"] = True + basedict["Upstream"]["08_long_P>5GeV"]["plotElectrons"] = False + basedict["Upstream"]["09_long_fromB"]["plotElectrons"] = True + basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True + basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Upstream"]["07_long"]["Electrons"] = "11_long_electrons" + basedict["Upstream"]["09_long_fromB"]["Electrons"] = "12_long_fromB_electrons" + basedict["Upstream"]["10_long_fromB_P>5GeV"]["Electrons"] = "13_long_fromB_electrons_P>5GeV" + + basedict["Forward"]["01_long"]["title"] = "Long, 2 < eta < 5" + basedict["Forward"]["02_long_P>5GeV"]["title"] = "Long, p>5GeV, 2 < eta < 5" + basedict["Forward"]["03_long_strange"]["title"] = "Long, from strange, 2 < eta < 5" + basedict["Forward"]["04_long_strange_P>5GeV"]["title"] = "Long, from strange, p>5GeV, 2 < eta < 5" + basedict["Forward"]["05_long_fromB"]["title"] = "Long from B, 2 < eta < 5" + basedict["Forward"]["06_long_fromB_P>5GeV"]["title"] = "Long from B, p>5GeV 2 < eta < 5" + basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "Long from B, p>3GeV, pt>0.5GeV, 2 < eta < 5" + basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "UT Long from B, p>3GeV, pt>0.5GeV, 2 < eta < 5" + + basedict["Forward"]["01_long"]["plotElectrons"] = True + basedict["Forward"]["02_long_P>5GeV"]["plotElectrons"] = False + basedict["Forward"]["03_long_strange"]["plotElectrons"] = False + basedict["Forward"]["04_long_strange_P>5GeV"]["plotElectrons"] = False + basedict["Forward"]["05_long_fromB"]["plotElectrons"] = True + basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True + basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] =False + basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + + basedict["Forward"]["01_long"]["Electrons"] = "07_long_electrons" + basedict["Forward"]["05_long_fromB"]["Electrons"] = "08_long_fromB_electrons" + basedict["Forward"]["06_long_fromB_P>5GeV"]["Electrons"] = "09_long_fromB_electrons_P>5GeV" + + return basedict diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index 771c38e290d..ccbce6dafa3 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -1,34 +1,23 @@ -############################################################################### -# (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. # -############################################################################### - import ROOT import itertools from ROOT import gStyle # Some convenience function to easily iterate over the parts of the collections + # Needed if importing this script from another script in case TMultiGraphs are used #ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) + # Start a bit right of the Yaxis and above the Xaxis to not overlap with the ticks -start, stop = 0.18, 0.89 -x_width, y_width = 0.3, 0.2 -PLACES = [ - (start, stop - y_width, start + x_width, stop), # top left opt - (start, start, start + x_width, start + y_width), # bottom left opt - (stop - x_width, stop - y_width, stop, stop), # top right opt - (stop - x_width, start, stop, start + y_width), # bottom right opt - (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right - (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2) -] # left +start, stop = 0.28, 0.52 +x_width, y_width = 0.4, 0.2 +PLACES = [(start, stop - y_width, start + x_width, stop), # top left opt + (start, start, start + x_width, start + y_width), # bottom left opt + (stop - x_width, stop - y_width, stop, stop), # top right opt + (stop - x_width, start, stop, start + y_width), # bottom right opt + (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right + (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2)] # left def transform_to_user(canvas, x1, y1, x2, y2): @@ -65,8 +54,7 @@ def overlap_h(hist, x1, y1, x2, y2): if y1 <= val <= y2: return True # Errors - if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow( - i) < y2: + if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow(i) < y2: # print "Overlap with histo", hist.GetName(), "at bin", i return True return False @@ -80,7 +68,6 @@ def overlap_rect(rect1, rect2): return False return True - def overlap_g(graph, x1, y1, x2, y2): x_values = list(graph.GetX()) y_values = list(graph.GetY()) @@ -94,14 +81,7 @@ def overlap_g(graph, x1, y1, x2, y2): return True return False - -def place_legend(canvas, - x1=None, - y1=None, - x2=None, - y2=None, - header="", - option="LPF"): +def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option="LPF"): gStyle.SetFillStyle(0) gStyle.SetTextSize(0.06) # If position is specified, use that @@ -124,11 +104,9 @@ def place_legend(canvas, # Make sure there are no overlaps if any(obj.Overlap(*place_user) for obj in objects): continue - return canvas.BuildLegend(place[0], place[1], place[2], place[3], - header, option) + return canvas.BuildLegend(place[0], place[1], place[2], place[3], header, option) # As a fallback, use the default values, taken from TCanvas::BuildLegend - return canvas.BuildLegend(0.5, 0.67, 0.88, 0.88, header, option) - + return canvas.BuildLegend(0.4, 0.37, 0.88, 0.68, header, option) # Monkey patch ROOT objects to make it all work ROOT.THStack.__iter__ = lambda self: iter(self.GetHists()) -- GitLab From af4d9e5067885f82bbdcbe172f3d27d603749c0f Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Mon, 27 Jan 2020 11:42:35 +0000 Subject: [PATCH 046/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6935922 --- .../options/hlt1_reco_IPresolution.py | 2 +- Hlt/RecoConf/python/RecoConf/mc_checking.py | 15 +- Hlt/RecoConf/scripts/Legend.py | 33 ++- .../scripts/PrCheckerEfficiency_HLT1.py | 212 +++++++++-------- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 4 +- .../scripts/PrCheckerTrackResolution.py | 4 +- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 219 ++++++++++-------- Hlt/RecoConf/scripts/utils/Legend.py | 24 +- 8 files changed, 294 insertions(+), 219 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index 587b0b2c880..2d3221e8b59 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -10,7 +10,7 @@ ############################################################################### from Moore import options, run_reconstruction from Moore.config import Reconstruction -from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks from RecoConf.mc_checking import monitor_IPresolution from Configurables import ApplicationMgr from Configurables import NTupleSvc diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 04678f1eeb1..7cd1ebfc2e0 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -20,17 +20,10 @@ from PyConf.application import default_raw_event from PyConf.application import make_data_with_FetchDataFromFile from PyConf.Algorithms import ( - VPFullCluster2MCParticleLinker, - PrLHCbID2MCParticle, - PrLHCbID2MCParticleVPUTFTMU, - PrTrackAssociator, - PrTrackChecker, - PrUTHitChecker, - TrackListRefiner, - TrackResChecker, - TrackIPResolutionCheckerNT, - DataPacking__Unpack_LHCb__MCVPHitPacker_ -) + VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, + PrLHCbID2MCParticleVPUTFTMU, PrTrackAssociator, PrTrackChecker, + PrUTHitChecker, TrackListRefiner, TrackResChecker, + TrackIPResolutionCheckerNT, DataPacking__Unpack_LHCb__MCVPHitPacker_) from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool diff --git a/Hlt/RecoConf/scripts/Legend.py b/Hlt/RecoConf/scripts/Legend.py index 33e479a6fcc..c40a9d8d8fa 100644 --- a/Hlt/RecoConf/scripts/Legend.py +++ b/Hlt/RecoConf/scripts/Legend.py @@ -4,20 +4,20 @@ from ROOT import gStyle # Some convenience function to easily iterate over the parts of the collections - # Needed if importing this script from another script in case TMultiGraphs are used #ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) - # Start a bit right of the Yaxis and above the Xaxis to not overlap with the ticks start, stop = 0.18, 0.89 x_width, y_width = 0.3, 0.2 -PLACES = [(start, stop - y_width, start + x_width, stop), # top left opt - (start, start, start + x_width, start + y_width), # bottom left opt - (stop - x_width, stop - y_width, stop, stop), # top right opt - (stop - x_width, start, stop, start + y_width), # bottom right opt - (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right - (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2)] # left +PLACES = [ + (start, stop - y_width, start + x_width, stop), # top left opt + (start, start, start + x_width, start + y_width), # bottom left opt + (stop - x_width, stop - y_width, stop, stop), # top right opt + (stop - x_width, start, stop, start + y_width), # bottom right opt + (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right + (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2) +] # left def transform_to_user(canvas, x1, y1, x2, y2): @@ -54,7 +54,8 @@ def overlap_h(hist, x1, y1, x2, y2): if y1 <= val <= y2: return True # Errors - if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow(i) < y2: + if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow( + i) < y2: # print "Overlap with histo", hist.GetName(), "at bin", i return True return False @@ -68,6 +69,7 @@ def overlap_rect(rect1, rect2): return False return True + def overlap_g(graph, x1, y1, x2, y2): x_values = list(graph.GetX()) y_values = list(graph.GetY()) @@ -81,7 +83,14 @@ def overlap_g(graph, x1, y1, x2, y2): return True return False -def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option="LPF"): + +def place_legend(canvas, + x1=None, + y1=None, + x2=None, + y2=None, + header="", + option="LPF"): gStyle.SetFillStyle(0) gStyle.SetTextSize(0.09) # If position is specified, use that @@ -104,10 +113,12 @@ def place_legend(canvas, x1=None, y1=None, x2=None, y2=None, header="", option=" # Make sure there are no overlaps if any(obj.Overlap(*place_user) for obj in objects): continue - return canvas.BuildLegend(place[0], place[1], place[2], place[3], header, option) + return canvas.BuildLegend(place[0], place[1], place[2], place[3], + header, option) # As a fallback, use the default values, taken from TCanvas::BuildLegend return canvas.BuildLegend(0.5, 0.67, 0.88, 0.88, header, option) + # Monkey patch ROOT objects to make it all work ROOT.THStack.__iter__ = lambda self: iter(self.GetHists()) ROOT.TMultiGraph.__iter__ = lambda self: iter(self.GetListOfGraphs()) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index ef67dfeaebb..3af620d7ae8 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -12,43 +12,48 @@ # updated by Peilian Li # -import os,sys +import os, sys import argparse import ROOT from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject -from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad from ROOT import gROOT, gStyle, TStyle, TPaveText from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors #from BaseHandler import BaseHandler #from collectRunResults import urlopen import logging import subprocess + #from collectRunResults import send_notification_mattermost -def getEfficiencyHistoNames() : + +def getEfficiencyHistoNames(): return ["eta", "p", "pt", "phi", "nPV"] -def getTrackers() : + +def getTrackers(): return ["Velo", "Upstream", "Forward"] -def getOriginFolders() : - basedict = { - "Velo" : {}, - "Upstream" : {}, - "Forward" : {} - } - basedict["Velo"]["folder"] = "VeloTrackChecker/" - basedict["Upstream"]["folder"] = "UpstreamTrackChecker/" - basedict["Forward"]["folder"] = "ForwardTrackChecker/" +def getOriginFolders(): + basedict = {"Velo": {}, "Upstream": {}, "Forward": {}} + + basedict["Velo"]["folder"] = "VeloTrackChecker/" + basedict["Upstream"]["folder"] = "UpstreamTrackChecker/" + basedict["Forward"]["folder"] = "ForwardTrackChecker/" + + return basedict - return basedict -def getGhostHistoNames() : +def getGhostHistoNames(): return ["eta", "nPV", "pt", "p"] -def getMode() : - return ["Bd2Kstee", "Bs2PhiPhi", "Dp2KSPip", "Dst2D0pi", "Z2mumu", "Bd2Dstmumu"] + +def getMode(): + return [ + "Bd2Kstee", "Bs2PhiPhi", "Dp2KSPip", "Dst2D0pi", "Z2mumu", "Bd2Dstmumu" + ] + def argument_parser(): parser = argparse.ArgumentParser(description="location of the tuple file") @@ -58,47 +63,47 @@ def argument_parser(): default=os.getcwd(), help='location of input tuple files') parser.add_argument( - '--mode', - type=str, - default='Bs2PhiPhi', - help='decay mode') + '--mode', type=str, default='Bs2PhiPhi', help='decay mode') parser.add_argument( '--method', type=str, default='baseline', help='HLT1 reconstruction method') parser.add_argument( - '--plotstyle', default='', help='location of LHCb utils plot style file') + '--plotstyle', + default='', + help='location of LHCb utils plot style file') return parser def PrCheckerEfficiency(directory, mode, method, plotstyle): sys.path.append(os.path.abspath(plotstyle)) from utils.LHCbStyle import setLHCbStyle - from utils.ConfigHistos import (efficiencyHistoDict, - ghostHistoDict, - categoriesDict, - getCuts) + from utils.ConfigHistos import (efficiencyHistoDict, ghostHistoDict, + categoriesDict, getCuts) from utils.Legend import place_legend setLHCbStyle() - f = TFile(directory+"/MCMatching_"+method+"_"+mode+".root", "read") - outputfile=TFile(directory+"/efficiency_plots_"+method+"_"+mode+".root", "recreate") + f = TFile(directory + "/MCMatching_" + method + "_" + mode + ".root", + "read") + outputfile = TFile( + directory + "/efficiency_plots_" + method + "_" + mode + ".root", + "recreate") - latex=TLatex() + latex = TLatex() latex.SetNDC() latex.SetTextSize(0.045) efficiencyHistoDict = efficiencyHistoDict() - efficiencyHistos = getEfficiencyHistoNames() - ghostHistos = getGhostHistoNames() - ghostHistoDict = ghostHistoDict() - categories = categoriesDict() - cuts = getCuts() - trackers = getTrackers() - folders = getOriginFolders() - - for tracker in trackers : + efficiencyHistos = getEfficiencyHistoNames() + ghostHistos = getGhostHistoNames() + ghostHistoDict = ghostHistoDict() + categories = categoriesDict() + cuts = getCuts() + trackers = getTrackers() + folders = getOriginFolders() + + for tracker in trackers: outputfile.cd() trackerDir = outputfile.mkdir(tracker) trackerDir.cd() @@ -107,22 +112,25 @@ def PrCheckerEfficiency(directory, mode, method, plotstyle): cutDir = trackerDir.mkdir(cut) cutDir.cd() folder = folders[tracker]["folder"] - print (folder) + print(folder) histoBaseName = "Track/" + folder + tracker + "/" + cut + "_" # calculate efficiency for histo in efficiencyHistos: - title = "efficiency vs. " + histo + ", " + categories[tracker][cut]["title"] + title = "efficiency vs. " + histo + ", " + categories[tracker][ + cut]["title"] name = "efficiency vs. " + histo canvas = TCanvas(name, title) # get efficiency for not electrons category - histoName = histoBaseName + "" + efficiencyHistoDict[histo]["variable"] - print ("not electrons: " + histoName) - numeratorName = histoName + "_reconstructed" - numerator = f.Get(numeratorName) + histoName = histoBaseName + "" + efficiencyHistoDict[histo][ + "variable"] + print("not electrons: " + histoName) + numeratorName = histoName + "_reconstructed" + numerator = f.Get(numeratorName) denominatorName = histoName + "_reconstructible" - denominator = f.Get(denominatorName) - if numerator.GetEntries() == 0 or denominator.GetEntries() == 0 : + denominator = f.Get(denominatorName) + if numerator.GetEntries() == 0 or denominator.GetEntries( + ) == 0: continue numerator.Sumw2() @@ -130,28 +138,36 @@ def PrCheckerEfficiency(directory, mode, method, plotstyle): g_efficiency_notElectrons = TGraphAsymmErrors() g_efficiency_notElectrons.SetName("g_efficiency_notElectrons") - g_efficiency_notElectrons.Divide(numerator, denominator, "cl=0.683 b(1,1) mode") + g_efficiency_notElectrons.Divide(numerator, denominator, + "cl=0.683 b(1,1) mode") g_efficiency_notElectrons.SetTitle("Eff. not electrons") - if (histoName.find('strange') != -1) : - g_efficiency_notElectrons.SetTitle("Eff. from stranges") + if (histoName.find('strange') != -1): + g_efficiency_notElectrons.SetTitle("Eff. from stranges") g_efficiency_notElectrons.Draw() h_numerator_notElectrons = denominator.Clone() h_numerator_notElectrons.SetName("h_numerator_notElectrons") - h_numerator_notElectrons.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. not electrons") - if (histoName.find('strange') != -1) : - h_numerator_notElectrons.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. stranges") + h_numerator_notElectrons.SetTitle( + efficiencyHistoDict[histo]["variable"] + + " histo. not electrons") + if (histoName.find('strange') != -1): + h_numerator_notElectrons.SetTitle( + efficiencyHistoDict[histo]["variable"] + + " histo. stranges") # get efficiency for electrons category - if categories[tracker][cut]["plotElectrons"] : - histoNameElec = "Track/" + folder + tracker + "/" + categories[tracker][cut]["Electrons"] - histoName = histoNameElec + "_" + efficiencyHistoDict[histo]["variable"] - print ("electrons: " + histoName) - numeratorName = histoName + "_reconstructed" - numerator = f.Get(numeratorName) + if categories[tracker][cut]["plotElectrons"]: + histoNameElec = "Track/" + folder + tracker + "/" + categories[ + tracker][cut]["Electrons"] + histoName = histoNameElec + "_" + efficiencyHistoDict[ + histo]["variable"] + print("electrons: " + histoName) + numeratorName = histoName + "_reconstructed" + numerator = f.Get(numeratorName) denominatorName = histoName + "_reconstructible" - denominator = f.Get(denominatorName) - if numerator.GetEntries() == 0 or denominator.GetEntries() == 0 : + denominator = f.Get(denominatorName) + if numerator.GetEntries() == 0 or denominator.GetEntries( + ) == 0: continue numerator.Sumw2() @@ -159,54 +175,60 @@ def PrCheckerEfficiency(directory, mode, method, plotstyle): g_efficiency_electrons = TGraphAsymmErrors() g_efficiency_electrons.SetName("g_efficiency_electrons") - g_efficiency_electrons.Divide(numerator, denominator, "cl=0.683 b(1,1) mode") + g_efficiency_electrons.Divide(numerator, denominator, + "cl=0.683 b(1,1) mode") g_efficiency_electrons.SetTitle("Eff. electrons") - g_efficiency_electrons.SetMarkerColor(kAzure-3) + g_efficiency_electrons.SetMarkerColor(kAzure - 3) g_efficiency_electrons.SetMarkerStyle(24) - g_efficiency_electrons.SetLineColor(kAzure-3) + g_efficiency_electrons.SetLineColor(kAzure - 3) h_numerator_electrons = denominator.Clone() h_numerator_electrons.SetName("h_numerator_electrons") - h_numerator_electrons.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. electrons") + h_numerator_electrons.SetTitle( + efficiencyHistoDict[histo]["variable"] + + " histo. electrons") #draw them both mg = TMultiGraph() mg.Add(g_efficiency_notElectrons) - if categories[tracker][cut]["plotElectrons"] : + if categories[tracker][cut]["plotElectrons"]: mg.Add(g_efficiency_electrons) mg.Draw("ap") xtitle = efficiencyHistoDict[histo]["xTitle"] mg.GetXaxis().SetTitle(xtitle) mg.GetYaxis().SetTitle("Efficiency") - mg.GetYaxis().SetRangeUser(0,1.05) + mg.GetYaxis().SetRangeUser(0, 1.05) mg.SetName("efficiency vs. " + histo) - mg.SetTitle(tracker+" " +cut) + mg.SetTitle(tracker + " " + cut) - rightmax = 1.05*h_numerator_notElectrons.GetMaximum() - scale = gPad.GetUymax()/rightmax + rightmax = 1.05 * h_numerator_notElectrons.GetMaximum() + scale = gPad.GetUymax() / rightmax h_numerator_notElectrons.Scale(scale) h_numerator_notElectrons.SetFillStyle(3004) h_numerator_notElectrons.SetFillColor(kBlue) - h_numerator_notElectrons.SetLineColor(kBlue-10) + h_numerator_notElectrons.SetLineColor(kBlue - 10) h_numerator_notElectrons.SetLineWidth(2) h_numerator_notElectrons.Draw("hist same") - if categories[tracker][cut]["plotElectrons"] : - scale = gPad.GetUymax()/(h_numerator_electrons.GetMaximum()*1.1) + if categories[tracker][cut]["plotElectrons"]: + scale = gPad.GetUymax() / ( + h_numerator_electrons.GetMaximum() * 1.1) h_numerator_electrons.Scale(scale) h_numerator_electrons.SetFillStyle(3003) h_numerator_electrons.SetFillColor(kGreen) - h_numerator_electrons.SetLineColor(kGreen-10) + h_numerator_electrons.SetLineColor(kGreen - 10) h_numerator_electrons.SetLineWidth(2) h_numerator_electrons.Draw("hist same") - axis = TGaxis(gPad.GetUxmax(), 0, gPad.GetUxmax(), 1.05, 0,rightmax,510,"+L") + axis = TGaxis(gPad.GetUxmax(), 0, gPad.GetUxmax(), 1.05, 0, + rightmax, 510, "+L") if histo == "p": - axis = TGaxis(50000, 0, 50000, 1.05, 0,rightmax,510,"+L") - mg.GetXaxis().SetRangeUser(0,50000) + axis = TGaxis(50000, 0, 50000, 1.05, 0, rightmax, 510, + "+L") + mg.GetXaxis().SetRangeUser(0, 50000) if histo == "pt": - axis = TGaxis(5000, 0, 5000, 1.05, 0,rightmax,510,"+L") - mg.GetXaxis().SetRangeUser(0,5000) + axis = TGaxis(5000, 0, 5000, 1.05, 0, rightmax, 510, "+L") + mg.GetXaxis().SetRangeUser(0, 5000) axis.SetTitle("Number of events") axis.SetTextFont(132) axis.SetLabelFont(132) @@ -215,16 +237,16 @@ def PrCheckerEfficiency(directory, mode, method, plotstyle): axis.SetTitleSize(0.07) axis.SetNdivisions(505) gPad.SetRightMargin(0.75) - + canvas.PlaceLegend() - pt = TPaveText(0.32,0.65,0.68,0.8,"BRNDC"); - pt.SetTextSize(0.05); - pt.SetBorderSize(1); - pt.SetFillColor(10); - pt.SetLineWidth(0); - cutName=categories[tracker][cut]["title"] - text=pt.AddText(cutName); + pt = TPaveText(0.32, 0.65, 0.68, 0.8, "BRNDC") + pt.SetTextSize(0.05) + pt.SetBorderSize(1) + pt.SetFillColor(10) + pt.SetLineWidth(0) + cutName = categories[tracker][cut]["title"] + text = pt.AddText(cutName) pt.Draw() canvas.SetRightMargin(0.05) canvas.Write() @@ -232,22 +254,26 @@ def PrCheckerEfficiency(directory, mode, method, plotstyle): # calculate ghost rate if tracker == "Forward": histoBaseName = "Track/" + folder + tracker + "/" - for histo in ghostHistos : + for histo in ghostHistos: trackerDir.cd() title = "ghost rate vs " + histo canvas = TCanvas(title, title) gPad.SetTicks() - numeratorName = histoBaseName + ghostHistoDict[histo]["variable"] + "_Ghosts" - denominatorName = histoBaseName + ghostHistoDict[histo]["variable"] + "_Total" - print ("ghost histo: " + histoBaseName + " " + numeratorName+" "+denominatorName) - numerator = f.Get(numeratorName) - denominator = f.Get(denominatorName) + numeratorName = histoBaseName + ghostHistoDict[histo][ + "variable"] + "_Ghosts" + denominatorName = histoBaseName + ghostHistoDict[histo][ + "variable"] + "_Total" + print("ghost histo: " + histoBaseName + " " + numeratorName + + " " + denominatorName) + numerator = f.Get(numeratorName) + denominator = f.Get(denominatorName) numerator.Sumw2() denominator.Sumw2() g_efficiency = TGraphAsymmErrors() g_efficiency.SetName(title + " ref") - g_efficiency.Divide(numerator, denominator, "cl=0.683 b(1,1) mode") + g_efficiency.Divide(numerator, denominator, + "cl=0.683 b(1,1) mode") xtitle = ghostHistoDict[histo]["xTitle"] g_efficiency.GetXaxis().SetTitle(xtitle) diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index aed4cb38093..b1a841dd491 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -44,7 +44,9 @@ def argument_parser(): default='Hlt1ForwardTracking_IPresolution', help='name of input tuple files') parser.add_argument( - '--plotstyle', default='', help='location of LHCb utils plot style file') + '--plotstyle', + default='', + help='location of LHCb utils plot style file') return parser diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index cbe370be2aa..d943412a9b7 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -43,7 +43,9 @@ def argument_parser(): default='Hlt1ForwardTrackingResolution', help='name of input tuple files') parser.add_argument( - '--plotstyle', default='', help='location of LHCb utils plot style file') + '--plotstyle', + default='', + help='location of LHCb utils plot style file') return parser diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index c51f030978a..496313b6080 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -1,15 +1,16 @@ from collections import defaultdict -def efficiencyHistoDict() : + +def efficiencyHistoDict(): basedict = { - "eta" : {}, - "p" : {}, - "pt" : {}, - "phi" : {}, - "nPV" : {}, - "docaz" : {} - } - + "eta": {}, + "p": {}, + "pt": {}, + "phi": {}, + "nPV": {}, + "docaz": {} + } + basedict["eta"]["xTitle"] = "#eta" basedict["eta"]["variable"] = "Eta" @@ -24,26 +25,22 @@ def efficiencyHistoDict() : basedict["nPV"]["xTitle"] = "# of PVs" basedict["nPV"]["variable"] = "nPV" - + basedict["docaz"]["xTitle"] = "docaz (mm)" basedict["docaz"]["variable"] = "docaz" - + return basedict -def ghostHistoDict() : - basedict = { - "eta" : {}, - "nPV" : {}, - "pt" : {}, - "p" : {} - } + +def ghostHistoDict(): + basedict = {"eta": {}, "nPV": {}, "pt": {}, "p": {}} basedict["eta"]["xTitle"] = "#eta" basedict["eta"]["variable"] = "Eta" basedict["nPV"]["xTitle"] = "# of PVs" basedict["nPV"]["variable"] = "nPV" - + basedict["pt"]["xTitle"] = "p_{T} [MeV]" basedict["pt"]["variable"] = "Pt" @@ -52,88 +49,124 @@ def ghostHistoDict() : return basedict -def getCuts() : - basedict = { - "Velo" : {}, - "Upstream" : {}, - "Forward" : {} - } - - basedict["Velo"] = ["01_velo","02_long", "03_long_P>5GeV", "04_long_strange", "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV"] - basedict["Upstream"] = ["01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV"] - basedict["Forward"] = ["01_long", "02_long_P>5GeV", "03_long_strange", "04_long_strange_P>5GeV", "05_long_fromB_P", "06_long_fromB_P>5GeV", "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV"] - - return basedict - -def categoriesDict() : - basedict = defaultdict(lambda : defaultdict(dict)) - - basedict["Velo"]["01_velo"]["title"] = "Velo, 2 < eta < 5" - basedict["Velo"]["02_long"]["title"] = "Long, 2 < eta < 5" - basedict["Velo"]["03_long_P>5GeV"]["title"] = "Long, p>5GeV, 2 < eta < 5" - basedict["Velo"]["04_long_strange"]["title"] = "Long, from Strange, 2 < eta < 5" - basedict["Velo"]["05_long_strange_P>5GeV"]["title"] = "Long, from Strange, p>5GeV, 2 < eta < 5" - basedict["Velo"]["06_long_fromB"]["title"] = "Long from B, 25GeV"]["title"] = "Long from B, p>5GeV, 23GeV_Pt>0.5GeV"]["title"] = "Long from B, p>3GeV, pt>0.5GeV, electron" - basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "UT Long, from B, p>3GeV, pt>0.5GeV" - basedict["Velo"]["01_velo"]["plotElectrons"] = False - basedict["Velo"]["02_long"]["plotElectrons"] = True - basedict["Velo"]["03_long_P>5GeV"]["plotElectrons"] = False - basedict["Velo"]["04_long_strange"]["plotElectrons"] = False - basedict["Velo"]["05_long_strange_P>5GeV"]["plotElectrons"] = False - basedict["Velo"]["06_long_fromB"]["plotElectrons"] = True - basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True + +def getCuts(): + basedict = {"Velo": {}, "Upstream": {}, "Forward": {}} + + basedict["Velo"] = [ + "01_velo", "02_long", "03_long_P>5GeV", "04_long_strange", + "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", + "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" + ] + basedict["Upstream"] = [ + "01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", + "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", + "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" + ] + basedict["Forward"] = [ + "01_long", "02_long_P>5GeV", "03_long_strange", + "04_long_strange_P>5GeV", "05_long_fromB_P", "06_long_fromB_P>5GeV", + "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" + ] + + return basedict + + +def categoriesDict(): + basedict = defaultdict(lambda: defaultdict(dict)) + + basedict["Velo"]["01_velo"]["title"] = "Velo, 2 < eta < 5" + basedict["Velo"]["02_long"]["title"] = "Long, 2 < eta < 5" + basedict["Velo"]["03_long_P>5GeV"]["title"] = "Long, p>5GeV, 2 < eta < 5" + basedict["Velo"]["04_long_strange"][ + "title"] = "Long, from Strange, 2 < eta < 5" + basedict["Velo"]["05_long_strange_P>5GeV"][ + "title"] = "Long, from Strange, p>5GeV, 2 < eta < 5" + basedict["Velo"]["06_long_fromB"]["title"] = "Long from B, 25GeV"][ + "title"] = "Long from B, p>5GeV, 23GeV_Pt>0.5GeV"][ + "title"] = "Long from B, p>3GeV, pt>0.5GeV, electron" + basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ + "title"] = "UT Long, from B, p>3GeV, pt>0.5GeV" + basedict["Velo"]["01_velo"]["plotElectrons"] = False + basedict["Velo"]["02_long"]["plotElectrons"] = True + basedict["Velo"]["03_long_P>5GeV"]["plotElectrons"] = False + basedict["Velo"]["04_long_strange"]["plotElectrons"] = False + basedict["Velo"]["05_long_strange_P>5GeV"]["plotElectrons"] = False + basedict["Velo"]["06_long_fromB"]["plotElectrons"] = True + basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False - basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False - basedict["Velo"]["02_long"]["Electrons"] = "08_long_electrons" - basedict["Velo"]["06_long_fromB"]["Electrons"] = "09_long_fromB_electrons" - basedict["Velo"]["07_long_fromB_P>5GeV"]["Electrons"] = "10_long_fromB_electrons_P>5GeV" + basedict["Velo"]["02_long"]["Electrons"] = "08_long_electrons" + basedict["Velo"]["06_long_fromB"]["Electrons"] = "09_long_fromB_electrons" + basedict["Velo"]["07_long_fromB_P>5GeV"][ + "Electrons"] = "10_long_fromB_electrons_P>5GeV" basedict["Upstream"]["01_velo"]["title"] = "Velo, 2 < eta < 5" basedict["Upstream"]["02_velo+UT"]["title"] = "VeloUT, 2 < eta < 5" - basedict["Upstream"]["03_velo+UT_P>5GeV"]["title"] = "VeloUT, p>5GeV, 2 < eta < 5" - basedict["Upstream"]["07_long"]["title"] = "Long, 2 < eta < 5" - basedict["Upstream"]["08_long_P>5GeV"]["title"] = "Long, p>5GeV, 2 < eta < 5" - basedict["Upstream"]["09_long_fromB"]["title"] = "Long from B, 2 < eta < 5" - basedict["Upstream"]["10_long_fromB_P>5GeV"]["title"] = "Long from B, p>5GeV, 2 < eta < 5" - basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "Long, from B, p>3GeV, pt>0.5GeV" - basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "Long, from B, p>3GeV, pt>0.5GeV" + basedict["Upstream"]["03_velo+UT_P>5GeV"][ + "title"] = "VeloUT, p>5GeV, 2 < eta < 5" + basedict["Upstream"]["07_long"]["title"] = "Long, 2 < eta < 5" + basedict["Upstream"]["08_long_P>5GeV"][ + "title"] = "Long, p>5GeV, 2 < eta < 5" + basedict["Upstream"]["09_long_fromB"]["title"] = "Long from B, 2 < eta < 5" + basedict["Upstream"]["10_long_fromB_P>5GeV"][ + "title"] = "Long from B, p>5GeV, 2 < eta < 5" + basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long, from B, p>3GeV, pt>0.5GeV" + basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long, from B, p>3GeV, pt>0.5GeV" basedict["Upstream"]["01_velo"]["plotElectrons"] = False basedict["Upstream"]["02_velo+UT"]["plotElectrons"] = False basedict["Upstream"]["03_velo+UT_P>5GeV"]["plotElectrons"] = False - basedict["Upstream"]["07_long"]["plotElectrons"] = True - basedict["Upstream"]["08_long_P>5GeV"]["plotElectrons"] = False - basedict["Upstream"]["09_long_fromB"]["plotElectrons"] = True - basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True - basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False - basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False - basedict["Upstream"]["07_long"]["Electrons"] = "11_long_electrons" - basedict["Upstream"]["09_long_fromB"]["Electrons"] = "12_long_fromB_electrons" - basedict["Upstream"]["10_long_fromB_P>5GeV"]["Electrons"] = "13_long_fromB_electrons_P>5GeV" - - basedict["Forward"]["01_long"]["title"] = "Long, 2 < eta < 5" - basedict["Forward"]["02_long_P>5GeV"]["title"] = "Long, p>5GeV, 2 < eta < 5" - basedict["Forward"]["03_long_strange"]["title"] = "Long, from strange, 2 < eta < 5" - basedict["Forward"]["04_long_strange_P>5GeV"]["title"] = "Long, from strange, p>5GeV, 2 < eta < 5" - basedict["Forward"]["05_long_fromB"]["title"] = "Long from B, 2 < eta < 5" - basedict["Forward"]["06_long_fromB_P>5GeV"]["title"] = "Long from B, p>5GeV 2 < eta < 5" - basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "Long from B, p>3GeV, pt>0.5GeV, 2 < eta < 5" - basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["title"] = "UT Long from B, p>3GeV, pt>0.5GeV, 2 < eta < 5" - - basedict["Forward"]["01_long"]["plotElectrons"] = True + basedict["Upstream"]["07_long"]["plotElectrons"] = True + basedict["Upstream"]["08_long_P>5GeV"]["plotElectrons"] = False + basedict["Upstream"]["09_long_fromB"]["plotElectrons"] = True + basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True + basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False + basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False + basedict["Upstream"]["07_long"]["Electrons"] = "11_long_electrons" + basedict["Upstream"]["09_long_fromB"][ + "Electrons"] = "12_long_fromB_electrons" + basedict["Upstream"]["10_long_fromB_P>5GeV"][ + "Electrons"] = "13_long_fromB_electrons_P>5GeV" + + basedict["Forward"]["01_long"]["title"] = "Long, 2 < eta < 5" + basedict["Forward"]["02_long_P>5GeV"][ + "title"] = "Long, p>5GeV, 2 < eta < 5" + basedict["Forward"]["03_long_strange"][ + "title"] = "Long, from strange, 2 < eta < 5" + basedict["Forward"]["04_long_strange_P>5GeV"][ + "title"] = "Long, from strange, p>5GeV, 2 < eta < 5" + basedict["Forward"]["05_long_fromB"]["title"] = "Long from B, 2 < eta < 5" + basedict["Forward"]["06_long_fromB_P>5GeV"][ + "title"] = "Long from B, p>5GeV 2 < eta < 5" + basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long from B, p>3GeV, pt>0.5GeV, 2 < eta < 5" + basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ + "title"] = "UT Long from B, p>3GeV, pt>0.5GeV, 2 < eta < 5" + + basedict["Forward"]["01_long"]["plotElectrons"] = True basedict["Forward"]["02_long_P>5GeV"]["plotElectrons"] = False - basedict["Forward"]["03_long_strange"]["plotElectrons"] = False - basedict["Forward"]["04_long_strange_P>5GeV"]["plotElectrons"] = False - basedict["Forward"]["05_long_fromB"]["plotElectrons"] = True - basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True - basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] =False - basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False - - basedict["Forward"]["01_long"]["Electrons"] = "07_long_electrons" - basedict["Forward"]["05_long_fromB"]["Electrons"] = "08_long_fromB_electrons" - basedict["Forward"]["06_long_fromB_P>5GeV"]["Electrons"] = "09_long_fromB_electrons_P>5GeV" - + basedict["Forward"]["03_long_strange"]["plotElectrons"] = False + basedict["Forward"]["04_long_strange_P>5GeV"]["plotElectrons"] = False + basedict["Forward"]["05_long_fromB"]["plotElectrons"] = True + basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True + basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False + basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False + + basedict["Forward"]["01_long"]["Electrons"] = "07_long_electrons" + basedict["Forward"]["05_long_fromB"][ + "Electrons"] = "08_long_fromB_electrons" + basedict["Forward"]["06_long_fromB_P>5GeV"][ + "Electrons"] = "09_long_fromB_electrons_P>5GeV" + return basedict diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index e241bbdc9f2..ac205a555f5 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -20,12 +20,15 @@ from ROOT import gStyle # Start a bit right of the Yaxis and above the Xaxis to not overlap with the ticks start, stop = 0.28, 0.52 x_width, y_width = 0.4, 0.2 -PLACES = [(start, stop - y_width, start + x_width, stop), # top left opt - (start, start, start + x_width, start + y_width), # bottom left opt - (stop - x_width, stop - y_width, stop, stop), # top right opt - (stop - x_width, start, stop, start + y_width), # bottom right opt - (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right - (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2)] # left +PLACES = [ + (start, stop - y_width, start + x_width, stop), # top left opt + (start, start, start + x_width, start + y_width), # bottom left opt + (stop - x_width, stop - y_width, stop, stop), # top right opt + (stop - x_width, start, stop, start + y_width), # bottom right opt + (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right + (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2) +] # left + # Needed if importing this script from another script in case TMultiGraphs are used #ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) @@ -64,7 +67,8 @@ def overlap_h(hist, x1, y1, x2, y2): if y1 <= val <= y2: return True # Errors - if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow(i) < y2: + if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow( + i) < y2: return True return False @@ -77,6 +81,7 @@ def overlap_rect(rect1, rect2): return False return True + def overlap_g(graph, x1, y1, x2, y2): x_values = list(graph.GetX()) y_values = list(graph.GetY()) @@ -90,6 +95,7 @@ def overlap_g(graph, x1, y1, x2, y2): return True return False + def place_legend(canvas, x1=None, y1=None, @@ -119,10 +125,12 @@ def place_legend(canvas, # Make sure there are no overlaps if any(obj.Overlap(*place_user) for obj in objects): continue - return canvas.BuildLegend(place[0], place[1], place[2], place[3], header, option) + return canvas.BuildLegend(place[0], place[1], place[2], place[3], + header, option) # As a fallback, use the default values, taken from TCanvas::BuildLegend return canvas.BuildLegend(0.4, 0.37, 0.88, 0.68, header, option) + # Monkey patch ROOT objects to make it all work ROOT.THStack.__iter__ = lambda self: iter(self.GetHists()) ROOT.TMultiGraph.__iter__ = lambda self: iter(self.GetListOfGraphs()) -- GitLab From 530107611e10fe599fe07a5a4dee380887f5746f Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Mon, 27 Jan 2020 12:53:16 +0100 Subject: [PATCH 047/171] fix copyrights --- Hlt/RecoConf/scripts/Legend.py | 128 ------------------ .../scripts/PrCheckerEfficiency_HLT1.py | 16 ++- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 11 ++ 3 files changed, 22 insertions(+), 133 deletions(-) delete mode 100644 Hlt/RecoConf/scripts/Legend.py diff --git a/Hlt/RecoConf/scripts/Legend.py b/Hlt/RecoConf/scripts/Legend.py deleted file mode 100644 index c40a9d8d8fa..00000000000 --- a/Hlt/RecoConf/scripts/Legend.py +++ /dev/null @@ -1,128 +0,0 @@ -import ROOT -import itertools -from ROOT import gStyle - -# Some convenience function to easily iterate over the parts of the collections - -# Needed if importing this script from another script in case TMultiGraphs are used -#ROOT.SetMemoryPolicy(ROOT.kMemoryStrict) - -# Start a bit right of the Yaxis and above the Xaxis to not overlap with the ticks -start, stop = 0.18, 0.89 -x_width, y_width = 0.3, 0.2 -PLACES = [ - (start, stop - y_width, start + x_width, stop), # top left opt - (start, start, start + x_width, start + y_width), # bottom left opt - (stop - x_width, stop - y_width, stop, stop), # top right opt - (stop - x_width, start, stop, start + y_width), # bottom right opt - (stop - x_width, 0.5 - y_width / 2, stop, 0.5 + y_width / 2), # right - (start, 0.5 - y_width / 2, start + x_width, 0.5 + y_width / 2) -] # left - - -def transform_to_user(canvas, x1, y1, x2, y2): - """ - Transforms from Pad coordinates to User coordinates. - - This can probably be replaced by using the built-in conversion commands. - """ - xstart = canvas.GetX1() - xlength = canvas.GetX2() - xstart - xlow = xlength * x1 + xstart - xhigh = xlength * x2 + xstart - if canvas.GetLogx(): - xlow = 10**xlow - xhigh = 10**xhigh - - ystart = canvas.GetY1() - ylength = canvas.GetY2() - ystart - ylow = ylength * y1 + ystart - yhigh = ylength * y2 + ystart - if canvas.GetLogy(): - ylow = 10**ylow - yhigh = 10**yhigh - - return xlow, ylow, xhigh, yhigh - - -def overlap_h(hist, x1, y1, x2, y2): - xlow = hist.FindFixBin(x1) - xhigh = hist.FindFixBin(x2) - for i in range(xlow, xhigh + 1): - val = hist.GetBinContent(i) - # Values - if y1 <= val <= y2: - return True - # Errors - if val + hist.GetBinErrorUp(i) > y1 and val - hist.GetBinErrorLow( - i) < y2: - # print "Overlap with histo", hist.GetName(), "at bin", i - return True - return False - - -def overlap_rect(rect1, rect2): - """Do the two rectangles overlap?""" - if rect1[0] > rect2[2] or rect1[2] < rect2[0]: - return False - if rect1[1] > rect2[3] or rect1[3] < rect2[1]: - return False - return True - - -def overlap_g(graph, x1, y1, x2, y2): - x_values = list(graph.GetX()) - y_values = list(graph.GetY()) - x_err = list(graph.GetEX()) or [0] * len(x_values) - y_err = list(graph.GetEY()) or [0] * len(y_values) - - for x, ex, y, ey in zip(x_values, x_err, y_values, y_err): - # Could maybe be less conservative - if overlap_rect((x1, y1, x2, y2), (x - ex, y - ey, x + ex, y + ey)): - # print "Overlap with graph", graph.GetName(), "at point", (x, y) - return True - return False - - -def place_legend(canvas, - x1=None, - y1=None, - x2=None, - y2=None, - header="", - option="LPF"): - gStyle.SetFillStyle(0) - gStyle.SetTextSize(0.09) - # If position is specified, use that - if all(x is not None for x in (x1, x2, y1, y2)): - return canvas.BuildLegend(x1, y1, x2, y2, header, option) - - # Make sure all objects are correctly registered - canvas.Update() - - # Build a list of objects to check for overlaps - objects = [] - for x in canvas.GetListOfPrimitives(): - if isinstance(x, ROOT.TH1) or isinstance(x, ROOT.TGraph): - objects.append(x) - elif isinstance(x, ROOT.THStack) or isinstance(x, ROOT.TMultiGraph): - objects.extend(x) - - for place in PLACES: - place_user = canvas.PadtoU(*place) - # Make sure there are no overlaps - if any(obj.Overlap(*place_user) for obj in objects): - continue - return canvas.BuildLegend(place[0], place[1], place[2], place[3], - header, option) - # As a fallback, use the default values, taken from TCanvas::BuildLegend - return canvas.BuildLegend(0.5, 0.67, 0.88, 0.88, header, option) - - -# Monkey patch ROOT objects to make it all work -ROOT.THStack.__iter__ = lambda self: iter(self.GetHists()) -ROOT.TMultiGraph.__iter__ = lambda self: iter(self.GetListOfGraphs()) -ROOT.TH1.Overlap = overlap_h -ROOT.TGraph.Overlap = overlap_g -ROOT.TPad.PadtoU = transform_to_user -ROOT.TPad.PlaceLegend = place_legend diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 3af620d7ae8..43f3c1f89f2 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -1,8 +1,18 @@ +############################################################################### +# (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. # +############################################################################### #!/usr/bin/python # Script for accessing histograms of reconstructible and # reconstructed tracks for different tracking categories -# created by PrChecker2 +# created by hlt1_reco_baseline_with_mcchecking # # The efficency is calculated usig TGraphAsymmErrors # and Bayesian error bars @@ -19,13 +29,9 @@ from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad from ROOT import gROOT, gStyle, TStyle, TPaveText from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors -#from BaseHandler import BaseHandler -#from collectRunResults import urlopen import logging import subprocess -#from collectRunResults import send_notification_mattermost - def getEfficiencyHistoNames(): return ["eta", "p", "pt", "phi", "nPV"] diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 496313b6080..3a8e4e71f94 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -1,3 +1,14 @@ +############################################################################### +# (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 collections import defaultdict -- GitLab From 7bbcef593f3733ead57e634efc9f14e0a9b6bc29 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Mon, 27 Jan 2020 13:41:55 +0100 Subject: [PATCH 048/171] qmtest for plotting --- .../hlt1_reco_IPresolution.qmt | 31 +++++++++++++++++ .../hlt1_reco_IPresolution_plots.qmt | 33 +++++++++++++++++++ .../hlt1_reco_trackresolution.qmt | 31 +++++++++++++++++ .../hlt1_reco_trackresolution_plots.qmt | 31 +++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution.qmt create mode 100644 Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt create mode 100644 Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution.qmt create mode 100644 Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution.qmt new file mode 100644 index 00000000000..74c2cfa3668 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution.qmt @@ -0,0 +1,31 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $RECOCONFROOT/options/hlt1_reco_IPresolution.py + --output=hlt1_reco_IPresolution.opts.py + --all-opt + +true + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt new file mode 100644 index 00000000000..ce4f78f3690 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt @@ -0,0 +1,33 @@ + + + + +python + + $RECOCONFROOT/scripts/PrCheckerIPresolution.py + --name=Hlt1ForwardTracking_IPresolution + --plotstyle=$RECOCONFROOT/scripts/ + --output=hlt1_reco_IPresolution_plot.opts.py + +true + + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + + diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution.qmt new file mode 100644 index 00000000000..0a10d19ac0d --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution.qmt @@ -0,0 +1,31 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $RECOCONFROOT/options/hlt1_reco_trackresolution.py + --output=hlt1_reco_trackresolution.opts.py + --all-opt + +true + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt new file mode 100644 index 00000000000..dd1d3b8976f --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt @@ -0,0 +1,31 @@ + + + + +python + + $RECOCONFROOT/scripts/PrCheckerTrackResolution.py + --plotstyle=$RECOCONFROOT/scripts/ + --output=hlt1_reco_trackresolution.opts.py + --all-opt + +true + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + -- GitLab From 6c89a979b67ee3576d884011971297947fe67ba5 Mon Sep 17 00:00:00 2001 From: Tomasz Wojton Date: Tue, 28 Jan 2020 10:39:47 +0100 Subject: [PATCH 049/171] removed prints (pvs, hlt1_tracks) --- Hlt/RecoConf/python/RecoConf/standalone.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index c236dce45c7..9a8bc483b53 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -62,8 +62,6 @@ def standalone_hlt1_reco(do_mc_checking=False): "Forward": hlt1_tracks["Forward"], } data += get_track_checkers(types_and_locations_for_checkers) - print hlt1_tracks["Velo"] - print pvs data += get_pv_checkers(pvs, hlt1_tracks["Velo"]) return Reconstruction('hlt1_reco', data, reco_prefilters()) -- GitLab From cdae793dad309b602acb7c162ddcc072a1ef7d47 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 28 Jan 2020 09:40:12 +0000 Subject: [PATCH 050/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/6950020 --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 191d86aad88..9af2be96f60 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -272,8 +272,7 @@ def get_pv_checkers( ): assert isinstance( - pvs, - DataHandle), "Please provide reconstructed primary verticies" + pvs, DataHandle), "Please provide reconstructed primary verticies" pv_checkers = [] @@ -283,8 +282,8 @@ def get_pv_checkers( inputTracksName=tracks["v1"], MCVertexInput=mc_unpackers()["MCVertices"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), - MCPropertyInput=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo") - ) + MCPropertyInput=make_data_with_FetchDataFromFile( + "/Event/MC/TrackInfo")) pv_checkers.append(pvchecker) return pv_checkers @@ -297,4 +296,3 @@ def make_track_filter(InputTracks, code): filtered_tracks = TrackListRefiner( inputLocation=InputTracks["v1"], Selector=selector).outputLocation return filtered_tracks - -- GitLab From 632f5af415f857365650ac968c84b88fc67786f3 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Tue, 28 Jan 2020 16:27:34 +0100 Subject: [PATCH 051/171] decode Allen DecReports --- .../tests/options/default_input_and_conds_hlt1.py | 2 +- ...lt1_reco_baseline_and_Allen_with_mcchecking.py | 2 +- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 7 +++++-- Hlt/RecoConf/python/RecoConf/standalone.py | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 8da7b5b7df0..796c9860834 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -14,6 +14,6 @@ from Moore import options options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') #options.set_input_from_testfiledb("Upgrade_BsPhiPhi_FTv4_DIGI") -options.evt_max = 1000 +options.evt_max = 10 execfile(os.path.expandvars('$MOOREROOT/tests/options/default_conds.py')) diff --git a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py index 3d3321275af..7a53a2052bd 100644 --- a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py +++ b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py @@ -9,7 +9,7 @@ # or submit itself to any jurisdiction. # ############################################################################### from Moore import options, run_reconstruction -from RecoConf.standalone import standalone_hlt1_reco_and_allen +from RecoConf.standalone import standalone_hlt1_reco_and_allen, standalone_hlt1_allen from Configurables import ApplicationMgr from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable from Configurables import DumpMuonGeometry, DumpVPGeometry diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index dc780f34c86..6e80cfaa75e 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -43,10 +43,12 @@ run_allen = make_algorithm( def make_allen_output(odin_location=make_odin, - dumped_raw_banks=make_dumped_raw_banks): + dumped_raw_banks=make_dumped_raw_banks, + filter_hlt1=False): return run_allen( AllenRawInput=dumped_raw_banks(), - ODINLocation=odin_location()).AllenOutput + ODINLocation=odin_location(), + filter_HLT1=filter_hlt1).AllenOutput def make_allen_velo_tracks(): @@ -97,3 +99,4 @@ def make_allen_pvs(): def make_allen_dec_reports(): allen_output = make_allen_output() return AllenDecReportsToTES(AllenOutput=allen_output).OutputDecReports + diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 4cb532713d5..1aa56fd3d43 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -31,6 +31,7 @@ from .rich_data_monitoring import (make_rich_pixel_monitors, default_rich_monitoring_options) from .rich_mc_checking import make_rich_checkers, default_rich_checking_options from PyConf.Algorithms import Rich__Future__Rec__TrackFilter as TrackFilter +from PyConf.Algorithms import HltDecReportsDecoder from GaudiKernel.SystemOfUnits import MeV, mm from Moore.config import Reconstruction @@ -71,6 +72,20 @@ def standalone_hlt1_reco(do_mc_checking=False): return Reconstruction('hlt1_reco', data, reco_prefilters()) +@configurable +def standalone_hlt1_allen(): + """ Run the Allen HLT1 sequence + Returns: + Reconstruction: Data and control flow of Hlt1 reconstruction. + + """ + # Allen hlt1 + allen_dec_reports_raw = make_allen_dec_reports() + allen_dec_reports = HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw).OutputHltDecReportsLocation + data = [allen_dec_reports] + + return Reconstruction('hlt1_allen', data, reco_prefilters()) + @configurable def standalone_hlt1_reco_and_allen(do_mc_checking=False): """ Run the Hlt1 reconstruction, i.e. tracking and muon id, MC checking optional both with the baseline and the Allen sequence -- GitLab From 5405680e62f9560ed5fdef1b0daf069d38e7163e Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Tue, 28 Jan 2020 17:42:04 +0100 Subject: [PATCH 052/171] output decoded decReports --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 6e80cfaa75e..94a41e3ad11 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -98,5 +98,7 @@ def make_allen_pvs(): def make_allen_dec_reports(): allen_output = make_allen_output() - return AllenDecReportsToTES(AllenOutput=allen_output).OutputDecReports + allen_dec_reports_raw = AllenDecReportsToTES(AllenOutput=allen_output).OutputDecReports + return HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw).OutputHltDecReportsLocation + -- GitLab From eaa41ce53983488a9c9e00e0b2d9efc82912527a Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Tue, 28 Jan 2020 19:00:48 +0100 Subject: [PATCH 053/171] add DecReportsDecoder --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 94a41e3ad11..a0e089205f1 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -21,6 +21,7 @@ from PyConf.Algorithms import (LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track, AllenVeloToV2Tracks, AllenUTToV2Tracks, AllenForwardToV2Tracks, AllenPVsToRecVertexV2, AllenDecReportsToTES) +from PyConf.Algorithms import HltDecReportsDecoder dump_raw_banks = make_algorithm( DumpRawBanks, -- GitLab From 14f5b22665e56990e774e694a8d8be22452d929f Mon Sep 17 00:00:00 2001 From: Tomasz Wojton Date: Tue, 4 Feb 2020 12:26:21 +0100 Subject: [PATCH 054/171] refactoring --- Hlt/RecoConf/options/hlt1_reco_pvchecker.py | 35 +++++++++++++++++++++ Hlt/RecoConf/python/RecoConf/mc_checking.py | 4 +++ 2 files changed, 39 insertions(+) create mode 100644 Hlt/RecoConf/options/hlt1_reco_pvchecker.py diff --git a/Hlt/RecoConf/options/hlt1_reco_pvchecker.py b/Hlt/RecoConf/options/hlt1_reco_pvchecker.py new file mode 100644 index 00000000000..2cff83329dd --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_pvchecker.py @@ -0,0 +1,35 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks, make_pvs +from RecoConf.mc_checking import get_pv_checkers, get_track_checkers +from Configurables import ApplicationMgr +from Configurables import NTupleSvc + + +def hlt1_reco_pvchecker(): + + hlt1_tracks = make_hlt1_tracks() + pvs = make_pvs() + + data = [pvs] + data += get_pv_checkers(pvs, hlt1_tracks["Velo"], produce_ntuple=True) + + return Reconstruction('PVperformance', data, [require_gec()]) + +run_reconstruction(options, hlt1_reco_pvchecker) + +NTupleSvc().Output += [ + "FILE1 DATAFILE='Hlt1_PVperformance.root' TYPE='ROOT' OPT='NEW'" +] +ApplicationMgr().ExtSvc += [NTupleSvc()] +ApplicationMgr().HistogramPersistency = "ROOT" diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 9af2be96f60..5bb2bfa5e09 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -274,6 +274,9 @@ def get_pv_checkers( assert isinstance( pvs, DataHandle), "Please provide reconstructed primary verticies" + links_to_lhcbids = make_links_lhcbids_mcparticles() + links_to_tracks = make_links_tracks_mcparticles( + InputTracks=tracks, LinksToLHCbIDs=links_to_lhcbids) pv_checkers = [] pvchecker = PrimaryVertexChecker( @@ -281,6 +284,7 @@ def get_pv_checkers( inputVerticesName=pvs, inputTracksName=tracks["v1"], MCVertexInput=mc_unpackers()["MCVertices"], + MCParticleInput = mc_unpackers()["MCParticles"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), MCPropertyInput=make_data_with_FetchDataFromFile( "/Event/MC/TrackInfo")) -- GitLab From faffe69110467f801e7167109d79f4b29b0cd5a9 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 4 Feb 2020 11:27:09 +0000 Subject: [PATCH 055/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7045996 --- Hlt/RecoConf/options/hlt1_reco_pvchecker.py | 1 + Hlt/RecoConf/python/RecoConf/mc_checking.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_pvchecker.py b/Hlt/RecoConf/options/hlt1_reco_pvchecker.py index 2cff83329dd..91175618897 100644 --- a/Hlt/RecoConf/options/hlt1_reco_pvchecker.py +++ b/Hlt/RecoConf/options/hlt1_reco_pvchecker.py @@ -26,6 +26,7 @@ def hlt1_reco_pvchecker(): return Reconstruction('PVperformance', data, [require_gec()]) + run_reconstruction(options, hlt1_reco_pvchecker) NTupleSvc().Output += [ diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 5bb2bfa5e09..377fce1a22c 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -276,7 +276,7 @@ def get_pv_checkers( links_to_lhcbids = make_links_lhcbids_mcparticles() links_to_tracks = make_links_tracks_mcparticles( - InputTracks=tracks, LinksToLHCbIDs=links_to_lhcbids) + InputTracks=tracks, LinksToLHCbIDs=links_to_lhcbids) pv_checkers = [] pvchecker = PrimaryVertexChecker( @@ -284,7 +284,7 @@ def get_pv_checkers( inputVerticesName=pvs, inputTracksName=tracks["v1"], MCVertexInput=mc_unpackers()["MCVertices"], - MCParticleInput = mc_unpackers()["MCParticles"], + MCParticleInput=mc_unpackers()["MCParticles"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), MCPropertyInput=make_data_with_FetchDataFromFile( "/Event/MC/TrackInfo")) -- GitLab From 6c8011a78726dcd431e86cdce41d31357fcf162a Mon Sep 17 00:00:00 2001 From: Ross Hunter Date: Thu, 6 Feb 2020 19:30:09 +0100 Subject: [PATCH 056/171] Put Allen into a node like moore_control_flow --- Hlt/RecoConf/python/RecoConf/standalone.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 1aa56fd3d43..82e4e066ed8 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -81,10 +81,23 @@ def standalone_hlt1_allen(): """ # Allen hlt1 allen_dec_reports_raw = make_allen_dec_reports() - allen_dec_reports = HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw).OutputHltDecReportsLocation + #allen_dec_reports = HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw).OutputHltDecReportsLocation + allen_dec_reports = HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw) data = [allen_dec_reports] - return Reconstruction('hlt1_allen', data, reco_prefilters()) + #dec = CompositeNode( + # 'hlt_decision', + # combineLogic=NodeLogic.NONLAZY_OR, + # children=[line.node for line in lines], + # forceOrder=False) + + return CompositeNode( + 'allen', + combineLogic=NodeLogic.LAZY_AND, + children=data + reco_prefilters(), + forceOrder=True) + #return Reconstruction('hlt1_allen', data, reco_prefilters()) + #return data @configurable def standalone_hlt1_reco_and_allen(do_mc_checking=False): -- GitLab From 6fd0a3060b8b43855524624ff331fee350a73d3e Mon Sep 17 00:00:00 2001 From: Peilian Li Date: Fri, 7 Feb 2020 16:05:09 +0100 Subject: [PATCH 057/171] fix a typo --- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 3a8e4e71f94..6020b49c340 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -76,7 +76,7 @@ def getCuts(): ] basedict["Forward"] = [ "01_long", "02_long_P>5GeV", "03_long_strange", - "04_long_strange_P>5GeV", "05_long_fromB_P", "06_long_fromB_P>5GeV", + "04_long_strange_P>5GeV", "05_long_fromB", "06_long_fromB_P>5GeV", "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] -- GitLab From 0f4b5d8cc65174c541aadef0e106549af95878bc Mon Sep 17 00:00:00 2001 From: Ross Hunter Date: Wed, 12 Feb 2020 18:01:10 +0100 Subject: [PATCH 058/171] make_algorithm -> Algorithm --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index a0e089205f1..75cdd63030c 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -10,7 +10,7 @@ ############################################################################### from PyConf import configurable from PyConf.components import ( - make_algorithm, + #Algorithm, Algorithm, ) from PyConf.application import default_raw_event, make_odin @@ -23,7 +23,7 @@ from PyConf.Algorithms import (LHCb__Converters__Track__v1__fromV2TrackV1Track AllenPVsToRecVertexV2, AllenDecReportsToTES) from PyConf.Algorithms import HltDecReportsDecoder -dump_raw_banks = make_algorithm( +dump_raw_banks = Algorithm( DumpRawBanks, defaults=dict( BankTypes=["VP", "UT", "FTCluster", "Muon"], DumpToFile=False)) @@ -36,7 +36,7 @@ def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin): ODINLocation=odin_location()).AllenRawInput -run_allen = make_algorithm( +run_allen = Algorithm( RunAllen, defaults=dict( DetectorConfigurationPath="../Allen/input/detector_configuration/down/", -- GitLab From 3a663f614fd271ea588f2a2f815ea1aee10bb168 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 13 Feb 2020 02:54:12 +0100 Subject: [PATCH 059/171] make Allen calling from Moore work after merge with Moore master and using branch allen_tdr in Allen --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 32 ++++++---------------- Hlt/RecoConf/python/RecoConf/standalone.py | 4 +-- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 75cdd63030c..5a695c31283 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -9,10 +9,7 @@ # or submit itself to any jurisdiction. # ############################################################################### from PyConf import configurable -from PyConf.components import ( - #Algorithm, - Algorithm, -) + from PyConf.application import default_raw_event, make_odin from Configurables import (VPClus, createODIN, DumpRawBanks, RunAllen) @@ -20,36 +17,25 @@ from Configurables import (VPClus, createODIN, DumpRawBanks, RunAllen) from PyConf.Algorithms import (LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track, AllenVeloToV2Tracks, AllenUTToV2Tracks, AllenForwardToV2Tracks, - AllenPVsToRecVertexV2, AllenDecReportsToTES) + AllenPVsToRecVertexV2, AllenDecReportsToTES, DumpRawBanks, RunAllen) from PyConf.Algorithms import HltDecReportsDecoder -dump_raw_banks = Algorithm( - DumpRawBanks, - defaults=dict( - BankTypes=["VP", "UT", "FTCluster", "Muon"], DumpToFile=False)) - - @configurable def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin): - return dump_raw_banks( + return DumpRawBanks( RawEventLocation=make_raw(), - ODINLocation=odin_location()).AllenRawInput - - -run_allen = Algorithm( - RunAllen, - defaults=dict( - DetectorConfigurationPath="../Allen/input/detector_configuration/down/", - AlgorithmConfigurationPath="../Allen/configuration/constants/")) - + ODINLocation=odin_location(), + BankTypes=["VP", "UT", "FTCluster", "Muon"], DumpToFile=False).AllenRawInput def make_allen_output(odin_location=make_odin, dumped_raw_banks=make_dumped_raw_banks, filter_hlt1=False): - return run_allen( + return RunAllen( AllenRawInput=dumped_raw_banks(), ODINLocation=odin_location(), - filter_HLT1=filter_hlt1).AllenOutput + filter_HLT1=filter_hlt1, + ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", + JSON="${ALLEN_PROJECT_ROOT}/configuration/constants/default.json").AllenOutput def make_allen_velo_tracks(): diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 75cd5df9759..933e011a296 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -120,9 +120,9 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): # Allen hlt1 allen_tracks = make_allen_tracks() allen_pvs = make_allen_pvs() - allen_dec_reports = make_allen_dec_reports() + #allen_dec_reports = make_allen_dec_reports() - data += [allen_dec_reports] + #data += [allen_dec_reports] if do_mc_checking: types_and_locations_for_checkers = { -- GitLab From 4bd2db354f3b865a6e612dbb4662d69ccfdd3ab5 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 13 Feb 2020 14:35:59 +0100 Subject: [PATCH 060/171] cleanup --- Hlt/RecoConf/python/RecoConf/standalone.py | 33 +--------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 933e011a296..ccfc04dc3f0 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -71,34 +71,6 @@ def standalone_hlt1_reco(do_mc_checking=False): return Reconstruction('hlt1_reco', data, reco_prefilters()) - -@configurable -def standalone_hlt1_allen(): - """ Run the Allen HLT1 sequence - Returns: - Reconstruction: Data and control flow of Hlt1 reconstruction. - - """ - # Allen hlt1 - allen_dec_reports_raw = make_allen_dec_reports() - #allen_dec_reports = HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw).OutputHltDecReportsLocation - allen_dec_reports = HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw) - data = [allen_dec_reports] - - #dec = CompositeNode( - # 'hlt_decision', - # combineLogic=NodeLogic.NONLAZY_OR, - # children=[line.node for line in lines], - # forceOrder=False) - - return CompositeNode( - 'allen', - combineLogic=NodeLogic.LAZY_AND, - children=data + reco_prefilters(), - forceOrder=True) - #return Reconstruction('hlt1_allen', data, reco_prefilters()) - #return data - @configurable def standalone_hlt1_reco_and_allen(do_mc_checking=False): """ Run the Hlt1 reconstruction, i.e. tracking and muon id, MC checking optional both with the baseline and the Allen sequence @@ -120,10 +92,7 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): # Allen hlt1 allen_tracks = make_allen_tracks() allen_pvs = make_allen_pvs() - #allen_dec_reports = make_allen_dec_reports() - - #data += [allen_dec_reports] - + if do_mc_checking: types_and_locations_for_checkers = { "Velo": allen_tracks["Velo"], -- GitLab From ce57a02b108c8d214379f30a5329a90ae8cfbfd4 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 13 Feb 2020 22:00:29 +0100 Subject: [PATCH 061/171] add MuonMatch category for muonID Efficiency check --- Hlt/RecoConf/python/RecoConf/standalone.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 85712977f38..d1ea229e07b 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -91,6 +91,7 @@ def standalone_hlt1_muonmatching_reco(do_mc_checking=False, "Velo": all_tracks["Velo"], "Upstream": all_tracks["Upstream"], "Forward": all_tracks["Forward"], + "MuonMatch": all_tracks["MuonMatch"], } data += get_track_checkers(types_and_locations_for_checkers) -- GitLab From d62c2a614cf8f6f8c5c4111a13bf2ea2faac8245 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 14 Feb 2020 14:50:26 +0100 Subject: [PATCH 062/171] dump default raw banks, so that ODIN is dumped as well --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 5a695c31283..e829efb0279 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -25,7 +25,7 @@ def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin): return DumpRawBanks( RawEventLocation=make_raw(), ODINLocation=odin_location(), - BankTypes=["VP", "UT", "FTCluster", "Muon"], DumpToFile=False).AllenRawInput + DumpToFile=False).AllenRawInput def make_allen_output(odin_location=make_odin, dumped_raw_banks=make_dumped_raw_banks, -- GitLab From 7deb1cc2ce66b98c31322f1e36da16a3943b4f79 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 14 Feb 2020 15:36:24 +0100 Subject: [PATCH 063/171] add option files for muonID efficiency check --- .../options/hlt1_reco_muonid_efficiency.py | 67 +++++++++++++++++++ Hlt/RecoConf/python/RecoConf/standalone.py | 1 - 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py diff --git a/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py new file mode 100644 index 00000000000..7a69b2e3b1a --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py @@ -0,0 +1,67 @@ +############################################################################### +# (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 Moore import options +from PyConf.application import configure_input, configure +from PyConf.control_flow import CompositeNode, NodeLogic +from RecoConf.hlt1_tracking import ( + require_gec, + make_VeloClusterTrackingSIMD_hits +) +from RecoConf.mc_checking import monitor_tracking_efficiency, make_links_tracks_mcparticles, make_links_lhcbids_mcparticles_tracking_system +from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask +from RecoConf.hlt1_muonid import make_fitted_tracks_with_muon_id + +from Hlt1Conf.algorithms import Filter + +from Functors import ISMUON + +from PyConf.Algorithms import ( + LHCb__Converters__Track__v1__fromV2TrackV1Track as + trackV1FromV2TrackV1Track, + LHCb__Converters__Track__v2__fromPrFittedForwardTrackWithMuonID as + trackV2FromPrFittedForwardTrackWithMuonID +) + + + +def hlt1_reco_muonid_efficiency(): + # get the fitted tracks with muon ID + tracks_with_muon_id = make_fitted_tracks_with_muon_id() + + # appliy selection to tracks to select only tracks which are isMuon + full_sel = ISMUON + track_filter = Filter(tracks_with_muon_id, full_sel)['PrFittedForwardWithMuonID'] + + # convert result to v1 (which is what the PrChecker needs) + velo_hits = make_VeloClusterTrackingSIMD_hits() + v2_tracks = trackV2FromPrFittedForwardTrackWithMuonID(FittedTracks=track_filter, VeloHits=velo_hits) + v1_tracks = trackV1FromV2TrackV1Track(InputTracksName=v2_tracks, ) + + # make links to lhcb id for mc matching + links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() + # make links between tracks and mcparticles for mc matching + links_to_tracks_muon_id = make_links_tracks_mcparticles(InputTracks={"v1":v1_tracks.OutputTracksName}, LinksToLHCbIDs=links_to_lhcbids) + + # build the PrChecker algorihm + pr_checker_for_muon_id = monitor_tracking_efficiency( + TrackType="MuonMatch", + InputTracks={"v1":v1_tracks.OutputTracksName}, + LinksToTracks=links_to_tracks_muon_id, + LinksToLHCbIDs=links_to_lhcbids, + MCCategories=get_mc_categories("MuonMatch"), + HitTypesToCheck=get_hit_type_mask("BestLong"), + ) + + return Reconstruction('muonideff', [pr_checker_for_muon_id], [require_gec()]) + +options.histo_file = "PrChecker_MuonID.root" +run_reconstruction(options, hlt1_reco_muonid_efficiency) + diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index d1ea229e07b..85712977f38 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -91,7 +91,6 @@ def standalone_hlt1_muonmatching_reco(do_mc_checking=False, "Velo": all_tracks["Velo"], "Upstream": all_tracks["Upstream"], "Forward": all_tracks["Forward"], - "MuonMatch": all_tracks["MuonMatch"], } data += get_track_checkers(types_and_locations_for_checkers) -- GitLab From fbf1554ad54acc49dd8a6813fd112ec16182a3b6 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 14 Feb 2020 16:55:27 +0100 Subject: [PATCH 064/171] add MC file loction --- Hlt/RecoConf/options/hlt1_reco_trackresolution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py index b540ab11836..bcc86a4185b 100644 --- a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py @@ -24,7 +24,7 @@ def hlt1_reco_trackresolution(): # children=pr_checker, # combineLogic=NodeLogic.NONLAZY_OR, # forceOrder=False) - return Reconstruction('track_resolution', [pr_checker], [require_gec()]) + return Reconstruction('track_resolution', [make_data_with_FetchDataFromFile( "/Event/MC/TrackInfo" ), pr_checker], [require_gec()]) options.histo_file = "Hlt1ForwardTrackingResolution.root" -- GitLab From a606338a2035d26dfe54ec31d2298ef6c2add717 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 14 Feb 2020 15:55:51 +0000 Subject: [PATCH 065/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7198604 --- Hlt/RecoConf/options/hlt1_reco_trackresolution.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py index bcc86a4185b..dc8301f0562 100644 --- a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py @@ -24,7 +24,10 @@ def hlt1_reco_trackresolution(): # children=pr_checker, # combineLogic=NodeLogic.NONLAZY_OR, # forceOrder=False) - return Reconstruction('track_resolution', [make_data_with_FetchDataFromFile( "/Event/MC/TrackInfo" ), pr_checker], [require_gec()]) + return Reconstruction( + 'track_resolution', + [make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), pr_checker], + [require_gec()]) options.histo_file = "Hlt1ForwardTrackingResolution.root" -- GitLab From 54fa58c863c3421619ce83abd4c23384db698595 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 14 Feb 2020 17:18:29 +0100 Subject: [PATCH 066/171] add missing algorithm --- Hlt/RecoConf/options/hlt1_reco_trackresolution.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py index dc8301f0562..a18e2d82c1d 100644 --- a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py @@ -12,6 +12,7 @@ from Moore import options, run_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks from RecoConf.mc_checking import monitor_track_resolution +from PyConf.application import make_data_with_FetchDataFromFile def hlt1_reco_trackresolution(): -- GitLab From 999911ef45349fea4cdff8efe34fec9448648939 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 14 Feb 2020 16:36:39 +0000 Subject: [PATCH 067/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7199656 --- .../options/hlt1_reco_muonid_efficiency.py | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py index 7a69b2e3b1a..9bb93bbf5c1 100644 --- a/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py +++ b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py @@ -11,10 +11,8 @@ from Moore import options from PyConf.application import configure_input, configure from PyConf.control_flow import CompositeNode, NodeLogic -from RecoConf.hlt1_tracking import ( - require_gec, - make_VeloClusterTrackingSIMD_hits -) +from RecoConf.hlt1_tracking import (require_gec, + make_VeloClusterTrackingSIMD_hits) from RecoConf.mc_checking import monitor_tracking_efficiency, make_links_tracks_mcparticles, make_links_lhcbids_mcparticles_tracking_system from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask from RecoConf.hlt1_muonid import make_fitted_tracks_with_muon_id @@ -27,41 +25,44 @@ from PyConf.Algorithms import ( LHCb__Converters__Track__v1__fromV2TrackV1Track as trackV1FromV2TrackV1Track, LHCb__Converters__Track__v2__fromPrFittedForwardTrackWithMuonID as - trackV2FromPrFittedForwardTrackWithMuonID -) - + trackV2FromPrFittedForwardTrackWithMuonID) def hlt1_reco_muonid_efficiency(): # get the fitted tracks with muon ID tracks_with_muon_id = make_fitted_tracks_with_muon_id() - + # appliy selection to tracks to select only tracks which are isMuon full_sel = ISMUON - track_filter = Filter(tracks_with_muon_id, full_sel)['PrFittedForwardWithMuonID'] - + track_filter = Filter(tracks_with_muon_id, + full_sel)['PrFittedForwardWithMuonID'] + # convert result to v1 (which is what the PrChecker needs) velo_hits = make_VeloClusterTrackingSIMD_hits() - v2_tracks = trackV2FromPrFittedForwardTrackWithMuonID(FittedTracks=track_filter, VeloHits=velo_hits) + v2_tracks = trackV2FromPrFittedForwardTrackWithMuonID( + FittedTracks=track_filter, VeloHits=velo_hits) v1_tracks = trackV1FromV2TrackV1Track(InputTracksName=v2_tracks, ) - + # make links to lhcb id for mc matching links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() # make links between tracks and mcparticles for mc matching - links_to_tracks_muon_id = make_links_tracks_mcparticles(InputTracks={"v1":v1_tracks.OutputTracksName}, LinksToLHCbIDs=links_to_lhcbids) - + links_to_tracks_muon_id = make_links_tracks_mcparticles( + InputTracks={"v1": v1_tracks.OutputTracksName}, + LinksToLHCbIDs=links_to_lhcbids) + # build the PrChecker algorihm pr_checker_for_muon_id = monitor_tracking_efficiency( TrackType="MuonMatch", - InputTracks={"v1":v1_tracks.OutputTracksName}, + InputTracks={"v1": v1_tracks.OutputTracksName}, LinksToTracks=links_to_tracks_muon_id, LinksToLHCbIDs=links_to_lhcbids, MCCategories=get_mc_categories("MuonMatch"), HitTypesToCheck=get_hit_type_mask("BestLong"), - ) + ) + + return Reconstruction('muonideff', [pr_checker_for_muon_id], + [require_gec()]) - return Reconstruction('muonideff', [pr_checker_for_muon_id], [require_gec()]) options.histo_file = "PrChecker_MuonID.root" run_reconstruction(options, hlt1_reco_muonid_efficiency) - -- GitLab From 5be41a490078a2bf64e3b84bb7d823dae248f242 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 14 Feb 2020 17:44:14 +0100 Subject: [PATCH 068/171] fix bug --- Hlt/RecoConf/scripts/PrCheckerTrackResolution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index d943412a9b7..02be30980a7 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -53,7 +53,7 @@ def PrCheckerTrackResolution(directory, name, plotstyle): sys.path.append(os.path.abspath(plotstyle)) from utils.LHCbStyle import setLHCbStyle - from Legend import place_legend + from utils.Legend import place_legend setLHCbStyle() f = TFile.Open(os.path.join(directory, name + '.root'), 'read') -- GitLab From c6772870a4fba466ab2447af611850900e822133 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 14 Feb 2020 17:47:22 +0100 Subject: [PATCH 069/171] add defaul path for utils --- Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py | 2 +- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 2 +- Hlt/RecoConf/scripts/PrCheckerTrackResolution.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 43f3c1f89f2..191e366f4a5 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -77,7 +77,7 @@ def argument_parser(): help='HLT1 reconstruction method') parser.add_argument( '--plotstyle', - default='', + default=os.getcwd(), help='location of LHCb utils plot style file') return parser diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index b1a841dd491..0e142a26731 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -45,7 +45,7 @@ def argument_parser(): help='name of input tuple files') parser.add_argument( '--plotstyle', - default='', + default=os.getcwd(), help='location of LHCb utils plot style file') return parser diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index 02be30980a7..bd8ad506675 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -44,7 +44,7 @@ def argument_parser(): help='name of input tuple files') parser.add_argument( '--plotstyle', - default='', + default=os.getcwd(), help='location of LHCb utils plot style file') return parser -- GitLab From 755d8aefc28405e4292ce12df0710966d557b528 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 14 Feb 2020 22:21:08 +0100 Subject: [PATCH 070/171] fix cleanup --- ...1_reco_baseline_and_Allen_with_mcchecking.py | 2 +- Hlt/RecoConf/python/RecoConf/standalone.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py index 7a53a2052bd..3d3321275af 100644 --- a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py +++ b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py @@ -9,7 +9,7 @@ # or submit itself to any jurisdiction. # ############################################################################### from Moore import options, run_reconstruction -from RecoConf.standalone import standalone_hlt1_reco_and_allen, standalone_hlt1_allen +from RecoConf.standalone import standalone_hlt1_reco_and_allen from Configurables import ApplicationMgr from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable from Configurables import DumpMuonGeometry, DumpVPGeometry diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index ccfc04dc3f0..576696fce39 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -104,6 +104,23 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): return Reconstruction('hlt1_reco', data, reco_prefilters()) +def standalone_hlt1_allen(): + """ Run the Allen HLT1 sequence + Returns: + Reconstruction: Data and control flow of Hlt1 reconstruction. + + """ + # Allen hlt1 + allen_dec_reports_raw = make_allen_dec_reports() + allen_dec_reports = HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw) + data = [allen_dec_reports] + + return CompositeNode( + 'allen', + combineLogic=NodeLogic.LAZY_AND, + children=data + reco_prefilters(), + forceOrder=True) + def standalone_hlt1_reco_velo_only(): """ Run the default Hlt1 Velo reconstruction -- GitLab From aff88189f828212d247b12006312da7835f03f66 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 14 Feb 2020 23:37:52 +0100 Subject: [PATCH 071/171] modify muonID checker --- .../options/hlt1_reco_muonid_efficiency.py | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py index 9bb93bbf5c1..014d270222e 100644 --- a/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py +++ b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py @@ -8,10 +8,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -from Moore import options +from Moore import options, run_reconstruction +from Moore.config import Reconstruction from PyConf.application import configure_input, configure from PyConf.control_flow import CompositeNode, NodeLogic from RecoConf.hlt1_tracking import (require_gec, + make_hlt1_tracks, make_VeloClusterTrackingSIMD_hits) from RecoConf.mc_checking import monitor_tracking_efficiency, make_links_tracks_mcparticles, make_links_lhcbids_mcparticles_tracking_system from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask @@ -34,8 +36,7 @@ def hlt1_reco_muonid_efficiency(): # appliy selection to tracks to select only tracks which are isMuon full_sel = ISMUON - track_filter = Filter(tracks_with_muon_id, - full_sel)['PrFittedForwardWithMuonID'] + track_filter = Filter(tracks_with_muon_id, full_sel)['PrFittedForwardWithMuonID'] # convert result to v1 (which is what the PrChecker needs) velo_hits = make_VeloClusterTrackingSIMD_hits() @@ -50,19 +51,33 @@ def hlt1_reco_muonid_efficiency(): InputTracks={"v1": v1_tracks.OutputTracksName}, LinksToLHCbIDs=links_to_lhcbids) - # build the PrChecker algorihm - pr_checker_for_muon_id = monitor_tracking_efficiency( + # build the PrChecker algorihm for muon_id track + pr_checker_for_muon_id= monitor_tracking_efficiency( TrackType="MuonMatch", InputTracks={"v1": v1_tracks.OutputTracksName}, + #InputTracks={"v1": v1_tracks.OutputTracksName}, LinksToTracks=links_to_tracks_muon_id, LinksToLHCbIDs=links_to_lhcbids, MCCategories=get_mc_categories("MuonMatch"), HitTypesToCheck=get_hit_type_mask("BestLong"), ) + + # build the PrChecker algorihm for forward track + forward_tracks = make_hlt1_tracks()['Forward'] + links_to_forward_tracks= make_links_tracks_mcparticles( + InputTracks=forward_tracks, + LinksToLHCbIDs=links_to_lhcbids) - return Reconstruction('muonideff', [pr_checker_for_muon_id], - [require_gec()]) + pr_checker_for_forward_track= monitor_tracking_efficiency( + TrackType="Forward", + InputTracks=forward_tracks, + LinksToTracks=links_to_forward_tracks, + LinksToLHCbIDs=links_to_lhcbids, + MCCategories=get_mc_categories("MuonMatch"), + HitTypesToCheck=get_hit_type_mask("BestLong"), + ) + return Reconstruction('muonideff', [pr_checker_for_forward_track, pr_checker_for_muon_id], [require_gec()]) options.histo_file = "PrChecker_MuonID.root" run_reconstruction(options, hlt1_reco_muonid_efficiency) -- GitLab From 006262103f0995dd3ebb599efeb261ccee54c300 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 14 Feb 2020 22:38:39 +0000 Subject: [PATCH 072/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7202571 --- .../options/hlt1_reco_muonid_efficiency.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py index 014d270222e..06423ffe9bb 100644 --- a/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py +++ b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py @@ -12,8 +12,7 @@ from Moore import options, run_reconstruction from Moore.config import Reconstruction from PyConf.application import configure_input, configure from PyConf.control_flow import CompositeNode, NodeLogic -from RecoConf.hlt1_tracking import (require_gec, - make_hlt1_tracks, +from RecoConf.hlt1_tracking import (require_gec, make_hlt1_tracks, make_VeloClusterTrackingSIMD_hits) from RecoConf.mc_checking import monitor_tracking_efficiency, make_links_tracks_mcparticles, make_links_lhcbids_mcparticles_tracking_system from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask @@ -36,7 +35,8 @@ def hlt1_reco_muonid_efficiency(): # appliy selection to tracks to select only tracks which are isMuon full_sel = ISMUON - track_filter = Filter(tracks_with_muon_id, full_sel)['PrFittedForwardWithMuonID'] + track_filter = Filter(tracks_with_muon_id, + full_sel)['PrFittedForwardWithMuonID'] # convert result to v1 (which is what the PrChecker needs) velo_hits = make_VeloClusterTrackingSIMD_hits() @@ -52,7 +52,7 @@ def hlt1_reco_muonid_efficiency(): LinksToLHCbIDs=links_to_lhcbids) # build the PrChecker algorihm for muon_id track - pr_checker_for_muon_id= monitor_tracking_efficiency( + pr_checker_for_muon_id = monitor_tracking_efficiency( TrackType="MuonMatch", InputTracks={"v1": v1_tracks.OutputTracksName}, #InputTracks={"v1": v1_tracks.OutputTracksName}, @@ -61,14 +61,13 @@ def hlt1_reco_muonid_efficiency(): MCCategories=get_mc_categories("MuonMatch"), HitTypesToCheck=get_hit_type_mask("BestLong"), ) - + # build the PrChecker algorihm for forward track forward_tracks = make_hlt1_tracks()['Forward'] - links_to_forward_tracks= make_links_tracks_mcparticles( - InputTracks=forward_tracks, - LinksToLHCbIDs=links_to_lhcbids) + links_to_forward_tracks = make_links_tracks_mcparticles( + InputTracks=forward_tracks, LinksToLHCbIDs=links_to_lhcbids) - pr_checker_for_forward_track= monitor_tracking_efficiency( + pr_checker_for_forward_track = monitor_tracking_efficiency( TrackType="Forward", InputTracks=forward_tracks, LinksToTracks=links_to_forward_tracks, @@ -77,7 +76,10 @@ def hlt1_reco_muonid_efficiency(): HitTypesToCheck=get_hit_type_mask("BestLong"), ) - return Reconstruction('muonideff', [pr_checker_for_forward_track, pr_checker_for_muon_id], [require_gec()]) + return Reconstruction( + 'muonideff', [pr_checker_for_forward_track, pr_checker_for_muon_id], + [require_gec()]) + options.histo_file = "PrChecker_MuonID.root" run_reconstruction(options, hlt1_reco_muonid_efficiency) -- GitLab From f998818653bfb62de543c2b9ab76ca2744b1c06a Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 19 Feb 2020 05:46:30 +0100 Subject: [PATCH 073/171] add RecoConf options script for muonid checking of Allen tracks --- .../hlt1_reco_allen_muonid_efficiency.py | 92 +++++++++++++++++++ Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 9 ++ 2 files changed, 101 insertions(+) create mode 100644 Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py b/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py new file mode 100644 index 00000000000..185ac820c9b --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py @@ -0,0 +1,92 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from PyConf.application import configure_input, configure +from PyConf.control_flow import CompositeNode, NodeLogic +from RecoConf.hlt1_tracking import (require_gec, make_hlt1_tracks, + make_VeloClusterTrackingSIMD_hits) +from RecoConf.mc_checking import monitor_tracking_efficiency, make_links_tracks_mcparticles, make_links_lhcbids_mcparticles_tracking_system +from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask +from RecoConf.hlt1_muonid import make_fitted_tracks_with_muon_id +from Configurables import ApplicationMgr +from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable +from Configurables import DumpMuonGeometry, DumpVPGeometry +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks +from RecoConf.hlt1_allen import (make_allen_forward_tracks, make_allen_forward_muon_tracks) + +from Hlt1Conf.algorithms import Filter + +from Functors import ISMUON + +from PyConf.Algorithms import ( + LHCb__Converters__Track__v1__fromV2TrackV1Track as + trackV1FromV2TrackV1Track, + LHCb__Converters__Track__v2__fromPrFittedForwardTrackWithMuonID as + trackV2FromPrFittedForwardTrackWithMuonID) + + +producers = [ + p(DumpToFile=False) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) +] + +# Add the services that will produce the non-event-data +ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), +] + producers + +def hlt1_reco_allen_muonid_efficiency(): + # get the fitted tracks with muon ID + forward_muon_tracks = make_allen_forward_muon_tracks() + + # make links to lhcb id for mc matching + links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() + # make links between tracks and mcparticles for mc matching + links_to_tracks_muon_id = make_links_tracks_mcparticles( + InputTracks=forward_muon_tracks, + LinksToLHCbIDs=links_to_lhcbids) + + # build the PrChecker algorihm for muon_id track + pr_checker_for_muon_id = monitor_tracking_efficiency( + TrackType="MuonMatch", + InputTracks=forward_muon_tracks, + #InputTracks={"v1": v1_tracks.OutputTracksName}, + LinksToTracks=links_to_tracks_muon_id, + LinksToLHCbIDs=links_to_lhcbids, + MCCategories=get_mc_categories("MuonMatch"), + HitTypesToCheck=get_hit_type_mask("BestLong"), + ) + + # build the PrChecker algorihm for forward track + forward_tracks = make_allen_forward_tracks() + links_to_forward_tracks = make_links_tracks_mcparticles( + InputTracks=forward_tracks, LinksToLHCbIDs=links_to_lhcbids) + + pr_checker_for_forward_track = monitor_tracking_efficiency( + TrackType="Forward", + InputTracks=forward_tracks, + LinksToTracks=links_to_forward_tracks, + LinksToLHCbIDs=links_to_lhcbids, + MCCategories=get_mc_categories("MuonMatch"), + HitTypesToCheck=get_hit_type_mask("BestLong"), + ) + + return Reconstruction( + 'muonideff', [pr_checker_for_forward_track, pr_checker_for_muon_id], + [require_gec()]) + + +options.histo_file = "PrChecker_MuonID.root" +run_reconstruction(options, hlt1_reco_allen_muonid_efficiency) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index e829efb0279..4cd1ecdb888 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -64,7 +64,16 @@ def make_allen_forward_tracks(): InputTracksName=forward_tracks_v2).OutputTracksName return {"v2": forward_tracks_v2, "v1": forward_tracks_v1} + +def make_allen_forward_muon_tracks(): + allen_output = make_allen_output() + forward_muon_tracks_v2 = AllenForwardToV2Tracks( + AllenOutput=allen_output).OutputMuonTracks + forward_muon_tracks_v1 = FromV2TrackV1Track( + InputTracksName=forward_muon_tracks_v2).OutputTracksName + return {"v2": forward_muon_tracks_v2, "v1": forward_muon_tracks_v1} + def make_allen_tracks(): velo_tracks = make_allen_velo_tracks() -- GitLab From 9408546ae373e56c04287760717020f522a72cb3 Mon Sep 17 00:00:00 2001 From: Roel Aaij Date: Wed, 19 Feb 2020 13:47:18 +0100 Subject: [PATCH 074/171] Decode only HLT1 DecReports. --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 4cd1ecdb888..53c4ff579e7 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -20,6 +20,7 @@ from PyConf.Algorithms import (LHCb__Converters__Track__v1__fromV2TrackV1Track AllenPVsToRecVertexV2, AllenDecReportsToTES, DumpRawBanks, RunAllen) from PyConf.Algorithms import HltDecReportsDecoder + @configurable def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin): return DumpRawBanks( @@ -27,6 +28,7 @@ def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin): ODINLocation=odin_location(), DumpToFile=False).AllenRawInput + def make_allen_output(odin_location=make_odin, dumped_raw_banks=make_dumped_raw_banks, filter_hlt1=False): @@ -64,7 +66,8 @@ def make_allen_forward_tracks(): InputTracksName=forward_tracks_v2).OutputTracksName return {"v2": forward_tracks_v2, "v1": forward_tracks_v1} - + + def make_allen_forward_muon_tracks(): allen_output = make_allen_output() forward_muon_tracks_v2 = AllenForwardToV2Tracks( @@ -73,7 +76,7 @@ def make_allen_forward_muon_tracks(): InputTracksName=forward_muon_tracks_v2).OutputTracksName return {"v2": forward_muon_tracks_v2, "v1": forward_muon_tracks_v1} - + def make_allen_tracks(): velo_tracks = make_allen_velo_tracks() @@ -94,7 +97,6 @@ def make_allen_pvs(): def make_allen_dec_reports(): allen_output = make_allen_output() - allen_dec_reports_raw = AllenDecReportsToTES(AllenOutput=allen_output).OutputDecReports - return HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw).OutputHltDecReportsLocation - - + allen_dec_reports_raw = AllenDecReportsToTES( + AllenOutput=allen_output).OutputDecReports + return HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw, SourceID=1).OutputHltDecReportsLocation -- GitLab From 1ff832b8c52552e0394f3f4200b0e46016bb2a62 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 19 Feb 2020 12:48:22 +0000 Subject: [PATCH 075/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7264657 --- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 3 +-- .../options/hlt1_reco_allen_IPresolution.py | 7 +++---- .../options/hlt1_reco_allen_muonid_efficiency.py | 8 ++++---- .../options/hlt1_reco_allen_trackresolution.py | 1 + Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 15 +++++++++------ Hlt/RecoConf/python/RecoConf/standalone.py | 7 +++++-- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index 6753709704d..d525b0c0399 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -20,8 +20,7 @@ def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) pvs = make_pvs() - pr_checker = monitor_IPresolution(fitted_tracks["v1"], - pvs, + pr_checker = monitor_IPresolution(fitted_tracks["v1"], pvs, hlt1_tracks["Velo"]["v1"]) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py index cfad3cd96ce..0398d3973a0 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py @@ -20,15 +20,16 @@ from Configurables import DumpMuonGeometry, DumpVPGeometry from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import AllenUpdater + def hlt1_reco_allen_IPresolution(): allen_tracks = make_allen_tracks() allen_pvs = make_allen_pvs() - pr_checker = monitor_IPresolution(allen_tracks["Forward"]["v1"], - allen_pvs, + pr_checker = monitor_IPresolution(allen_tracks["Forward"]["v1"], allen_pvs, allen_tracks["Velo"]["v1"]) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) + options.histo_file = "AllenQuantities.root" run_reconstruction(options, hlt1_reco_allen_IPresolution) @@ -50,5 +51,3 @@ producers = [ ApplicationMgr().ExtSvc += [ AllenUpdater(OutputLevel=2), ] + producers - - diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py b/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py index 185ac820c9b..4893320ef90 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py @@ -22,7 +22,8 @@ from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable from Configurables import DumpMuonGeometry, DumpVPGeometry from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks -from RecoConf.hlt1_allen import (make_allen_forward_tracks, make_allen_forward_muon_tracks) +from RecoConf.hlt1_allen import (make_allen_forward_tracks, + make_allen_forward_muon_tracks) from Hlt1Conf.algorithms import Filter @@ -34,7 +35,6 @@ from PyConf.Algorithms import ( LHCb__Converters__Track__v2__fromPrFittedForwardTrackWithMuonID as trackV2FromPrFittedForwardTrackWithMuonID) - producers = [ p(DumpToFile=False) for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, @@ -47,6 +47,7 @@ ApplicationMgr().ExtSvc += [ AllenUpdater(OutputLevel=2), ] + producers + def hlt1_reco_allen_muonid_efficiency(): # get the fitted tracks with muon ID forward_muon_tracks = make_allen_forward_muon_tracks() @@ -55,8 +56,7 @@ def hlt1_reco_allen_muonid_efficiency(): links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() # make links between tracks and mcparticles for mc matching links_to_tracks_muon_id = make_links_tracks_mcparticles( - InputTracks=forward_muon_tracks, - LinksToLHCbIDs=links_to_lhcbids) + InputTracks=forward_muon_tracks, LinksToLHCbIDs=links_to_lhcbids) # build the PrChecker algorihm for muon_id track pr_checker_for_muon_id = monitor_tracking_efficiency( diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py index a7b342b4ad8..7cf6d85fd1a 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py @@ -19,6 +19,7 @@ from Configurables import DumpMuonGeometry, DumpVPGeometry from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import AllenUpdater + def hlt1_reco_allen_trackresolution(): track_type = "Forward" tracks = make_allen_tracks()[track_type] diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 53c4ff579e7..391461b636c 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -14,10 +14,10 @@ from PyConf.application import default_raw_event, make_odin from Configurables import (VPClus, createODIN, DumpRawBanks, RunAllen) -from PyConf.Algorithms import (LHCb__Converters__Track__v1__fromV2TrackV1Track - as FromV2TrackV1Track, AllenVeloToV2Tracks, - AllenUTToV2Tracks, AllenForwardToV2Tracks, - AllenPVsToRecVertexV2, AllenDecReportsToTES, DumpRawBanks, RunAllen) +from PyConf.Algorithms import ( + LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track, + AllenVeloToV2Tracks, AllenUTToV2Tracks, AllenForwardToV2Tracks, + AllenPVsToRecVertexV2, AllenDecReportsToTES, DumpRawBanks, RunAllen) from PyConf.Algorithms import HltDecReportsDecoder @@ -37,7 +37,8 @@ def make_allen_output(odin_location=make_odin, ODINLocation=odin_location(), filter_HLT1=filter_hlt1, ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", - JSON="${ALLEN_PROJECT_ROOT}/configuration/constants/default.json").AllenOutput + JSON="${ALLEN_PROJECT_ROOT}/configuration/constants/default.json" + ).AllenOutput def make_allen_velo_tracks(): @@ -99,4 +100,6 @@ def make_allen_dec_reports(): allen_output = make_allen_output() allen_dec_reports_raw = AllenDecReportsToTES( AllenOutput=allen_output).OutputDecReports - return HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw, SourceID=1).OutputHltDecReportsLocation + return HltDecReportsDecoder( + RawEventLocations=allen_dec_reports_raw, + SourceID=1).OutputHltDecReportsLocation diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 576696fce39..c4f4b389d9f 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -71,6 +71,7 @@ def standalone_hlt1_reco(do_mc_checking=False): return Reconstruction('hlt1_reco', data, reco_prefilters()) + @configurable def standalone_hlt1_reco_and_allen(do_mc_checking=False): """ Run the Hlt1 reconstruction, i.e. tracking and muon id, MC checking optional both with the baseline and the Allen sequence @@ -92,7 +93,7 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): # Allen hlt1 allen_tracks = make_allen_tracks() allen_pvs = make_allen_pvs() - + if do_mc_checking: types_and_locations_for_checkers = { "Velo": allen_tracks["Velo"], @@ -104,6 +105,7 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): return Reconstruction('hlt1_reco', data, reco_prefilters()) + def standalone_hlt1_allen(): """ Run the Allen HLT1 sequence Returns: @@ -112,7 +114,8 @@ def standalone_hlt1_allen(): """ # Allen hlt1 allen_dec_reports_raw = make_allen_dec_reports() - allen_dec_reports = HltDecReportsDecoder(RawEventLocations=allen_dec_reports_raw) + allen_dec_reports = HltDecReportsDecoder( + RawEventLocations=allen_dec_reports_raw) data = [allen_dec_reports] return CompositeNode( -- GitLab From 0a1f63d4051ac9eeb61b82c08aca02b442c8d77a Mon Sep 17 00:00:00 2001 From: Florian Reiss Date: Fri, 21 Feb 2020 11:06:57 +0100 Subject: [PATCH 076/171] remove MooreCache --- .../options/default_input_and_conds_hlt1.py | 2 +- MooreCache/CMakeLists.txt | 56 ------------------- MooreCache/options/process_zero_events.py | 12 ---- .../options/silence_application_manager.py | 16 ------ 4 files changed, 1 insertion(+), 85 deletions(-) delete mode 100644 MooreCache/CMakeLists.txt delete mode 100644 MooreCache/options/process_zero_events.py delete mode 100644 MooreCache/options/silence_application_manager.py diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 796c9860834..8da7b5b7df0 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -14,6 +14,6 @@ from Moore import options options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') #options.set_input_from_testfiledb("Upgrade_BsPhiPhi_FTv4_DIGI") -options.evt_max = 10 +options.evt_max = 1000 execfile(os.path.expandvars('$MOOREROOT/tests/options/default_conds.py')) diff --git a/MooreCache/CMakeLists.txt b/MooreCache/CMakeLists.txt deleted file mode 100644 index 10a8126ede5..00000000000 --- a/MooreCache/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -############################################################################### -# (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() - -# Disable LoKi-specific hacks in LoKiFunctorsCachePostActionOpts.py -# Save the old value so we don't change the behaviour elsewhere. -set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS_TMP ${LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS}) -set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS "") - -loki_functors_cache(Moore_FunctorCache_Hlt1 - ${REC_ROOT_DIR}/Phys/FunctorCache/options/DisableLoKiCacheFunctors.py - ${Moore_SOURCE_DIR}/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py - ${Moore_SOURCE_DIR}/MooreCache/options/process_zero_events.py - ${Moore_SOURCE_DIR}/MooreCache/options/silence_application_manager.py - ${Moore_SOURCE_DIR}/Hlt/Hlt1Conf/options/hlt1_pp_default.py - FACTORIES FunctorFactory - LINK_LIBRARIES FunctorCoreLib - ${conf_deps} - SPLIT 15) - -loki_functors_cache(Moore_FunctorCache_Hlt2_generic_lines - ${REC_ROOT_DIR}/Phys/FunctorCache/options/DisableLoKiCacheFunctors.py - ${Moore_SOURCE_DIR}/MooreCache/options/process_zero_events.py - ${Moore_SOURCE_DIR}/MooreCache/options/silence_application_manager.py - ${Moore_SOURCE_DIR}/Hlt/Hlt2Conf/options/generic_example.py - FACTORIES FunctorFactory - LINK_LIBRARIES FunctorCoreLib DaVinciKernelLib LoKiArrayFunctorsLib LoKiPhysLib - ${conf_deps} - SPLIT 15) - -# Restore the old value -set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS ${LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS_TMP}) diff --git a/MooreCache/options/process_zero_events.py b/MooreCache/options/process_zero_events.py deleted file mode 100644 index d2f06be43f3..00000000000 --- a/MooreCache/options/process_zero_events.py +++ /dev/null @@ -1,12 +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. # -############################################################################### -from Moore import options -options.evt_max = 0 diff --git a/MooreCache/options/silence_application_manager.py b/MooreCache/options/silence_application_manager.py deleted file mode 100644 index a94aac4ef67..00000000000 --- a/MooreCache/options/silence_application_manager.py +++ /dev/null @@ -1,16 +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. # -############################################################################### -from Moore import options -from Gaudi.Configuration import ERROR -import logging - -options.output_level = ERROR -options.python_logging_level = logging.ERROR -- GitLab From a8892d857efaaac6a1cf219efbf11d878791cefc Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 21 Feb 2020 16:00:04 +0100 Subject: [PATCH 077/171] adapt the PV input format for IP checker --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 7cd1ebfc2e0..b21619092ed 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -282,9 +282,9 @@ def monitor_track_resolution(InputTracks): def monitor_IPresolution(InputTracks, VeloTracks): - vertexConverter = FromVectorLHCbRecVertex( - InputVerticesName=make_pvs(), - InputTracksName=VeloTracks).OutputVerticesName + #vertexConverter = FromVectorLHCbRecVertex( + # InputVerticesName=make_pvs(), + # InputTracksName=VeloTracks).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( InputTracks, LinksToLHCbIDs=links_to_lhcbids) @@ -293,6 +293,6 @@ def monitor_IPresolution(InputTracks, VeloTracks): MCParticleInput=mc_unpackers()["MCParticles"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), LinkerLocation=links_to_tracks, - PVContainer=vertexConverter, + PVContainer=make_pvs(), NTupleLUN="FILE1") return IPres_checker -- GitLab From 5031c13b04aaf2d0e03b7f0abd975f21e9aceba4 Mon Sep 17 00:00:00 2001 From: Florian Reiss Date: Fri, 21 Feb 2020 18:34:55 +0100 Subject: [PATCH 078/171] fix include --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 9af625d5ea2..f2a0d9921c8 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -33,7 +33,7 @@ from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector from RecoConf.hlt1_tracking import (make_PrStoreUTHit_hits, make_FTRawBankDecoder_clusters, - make_velo_full_clusters) + make_velo_full_clusters, make_pvs) from Hlt2Conf.data_from_file import mc_unpackers -- GitLab From 60c1c72fa624f655a62ff72df1219fc00ec5cdf6 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Mon, 24 Feb 2020 11:32:06 +0000 Subject: [PATCH 079/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7313554 --- Hlt/RecoConf/python/RecoConf/standalone.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 805b9959583..4ac07266b26 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -65,7 +65,7 @@ def standalone_hlt1_reco(do_mc_checking=False): "Forward": hlt1_tracks["Forward"], } data += get_track_checkers(types_and_locations_for_checkers) - + return Reconstruction('hlt1_reco', data, reco_prefilters()) -- GitLab From 6317f6fec87313a5e060ad10c0cf80f58157547d Mon Sep 17 00:00:00 2001 From: Peilian Li Date: Mon, 24 Feb 2020 16:38:54 +0100 Subject: [PATCH 080/171] add more cut catogeries --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 9 +-- .../python/RecoConf/mc_checking_categories.py | 20 +++++++ Hlt/RecoConf/python/RecoConf/standalone.py | 5 +- MooreCache/CMakeLists.txt | 56 ------------------- MooreCache/options/process_zero_events.py | 12 ---- .../options/silence_application_manager.py | 16 ------ 6 files changed, 26 insertions(+), 92 deletions(-) delete mode 100644 MooreCache/CMakeLists.txt delete mode 100644 MooreCache/options/process_zero_events.py delete mode 100644 MooreCache/options/silence_application_manager.py diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 58f1676d5de..818ae8b5771 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -25,9 +25,6 @@ from PyConf.Algorithms import ( TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, DataPacking__Unpack_LHCb__MCVPHitPacker_, PrimaryVertexChecker) -from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex - -from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector @@ -110,7 +107,7 @@ def monitor_tracking_efficiency( LinksToLHCbIDs, MCCategories, HitTypesToCheck, - WriteHistos=1, + WriteHistos=2, ): """ Setup tracking efficiency checker @@ -282,6 +279,7 @@ def get_pv_checkers( inputVerticesName=pvs, inputTracksName=tracks["v1"], MCVertexInput=mc_unpackers()["MCVertices"], + MCParticleInput=mc_unpackers()["MCParticles"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), MCPropertyInput=make_data_with_FetchDataFromFile( "/Event/MC/TrackInfo")) @@ -310,9 +308,6 @@ def monitor_track_resolution(InputTracks): def monitor_IPresolution(InputTracks, VeloTracks): - #vertexConverter = FromVectorLHCbRecVertex( - # InputVerticesName=make_pvs(), - # InputTracksName=VeloTracks).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( InputTracks, LinksToLHCbIDs=links_to_lhcbids) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py b/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py index 586b86c400e..5eb906ac444 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py @@ -20,12 +20,17 @@ categories = { "04_long_strange": "isLong & strange", "05_long_strange_P>5GeV": "isLong & strange & over5", "06_long_fromB": "isLong & fromB", + "06_long_fromD": "isLong & fromD", "07_long_fromB_P>5GeV": "isLong & fromB & over5", + "07_long_fromD_P>5GeV": "isLong & fromD & over5", "08_long_electrons": "isLong & isElectron", "09_long_fromB_electrons": "isLong & isElectron & fromB", "10_long_fromB_electrons_P>5GeV": "isLong & isElectron & over5 & fromB", "11_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger", + "11_long_fromB_electrons_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isElectron", + "11_long_strange_P>3GeV_Pt>0.5GeV": "isLong & strange& trigger", + "11_long_fromD_P>3GeV_Pt>0.5GeV": "isLong & fromD & trigger", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isUT", }, "VeloFull": { @@ -116,12 +121,17 @@ categories = { "03_long_strange": "isLong & strange", "04_long_strange_P>5GeV": "isLong & strange & over5", "05_long_fromB": "isLong & fromB", + "05_long_fromD": "isLong & fromD", "06_long_fromB_P>5GeV": "isLong & fromB & over5", + "06_long_fromD_P>5GeV": "isLong & fromD & over5", "07_long_electrons": "isLong & isElectron", "08_long_fromB_electrons": "isLong & isElectron & fromB", "09_long_fromB_electrons_P>5GeV": "isLong & isElectron & over5 & fromB", "10_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger", + "10_long_fromB_electrons_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isElectron", + "10_long_strange_P>3GeV_Pt>0.5GeV": "isLong & strange & trigger", + "10_long_fromD_P>3GeV_Pt>0.5GeV": "isLong & fromD & trigger", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isUT", }, "Upstream": { @@ -132,14 +142,21 @@ categories = { "05_velo+UT+notLong": "isNotLong & isVelo & isUT", "06_velo+UT+notLong_P>5GeV": "isNotLong & isVelo & isUT & over5", "07_long": "isLong", + "07_long_strange": "isLong & strange", "08_long_P>5GeV": "isLong & over5 ", + "08_long_strange_P>5GeV": "isLong & over5 & strange", "09_long_fromB": "isLong & fromB", + "09_long_fromD": "isLong & fromD", "10_long_fromB_P>5GeV": "isLong & fromB & over5", + "10_long_fromD_P>5GeV": "isLong & fromD & over5", "11_long_electrons": "isLong & isElectron", "12_long_fromB_electrons": "isLong & isElectron & fromB", "13_long_fromB_electrons_P>5GeV": "isLong & isElectron & over5 & fromB", "14_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger", + "14_long_fromB_electrons_P>3GeV_Pt>0.5GeV": "isLong & fromB & isElectron & trigger", + "14_long_strange_P>3GeV_Pt>0.5GeV": "isLong & strange& trigger", + "14_long_fromD_P>3GeV_Pt>0.5GeV": "isLong & fromD & trigger", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isUT", }, "UpstreamForMuons": { @@ -150,8 +167,11 @@ categories = { "MuonMatch": { "01_long": "isLong", "02_long_muon": "isLong & isMuon", + "02_long_muon_p>3GeV_pt>0.5GeV": "isLong & isMuon & (MCPT>500) & (MCP>3000)", "03_long_muon_from_strange": "isLong & strange & isMuon", + "03_long_muon_strange_p>3GeV_pt>0.5GeV": "isLong & isMuon & (MCPT>500) & (MCP>3000) & strange", "04_long_pion": "isLong & isPion", + "04_long_pion_p>3GeV_pt>0.5GeV": "isLong & isPion & (MCPT>500) & (MCP>3000)", }, "MuonID": { "01_long": "isLong", diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 4ac07266b26..e4896f9571b 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -65,6 +65,9 @@ def standalone_hlt1_reco(do_mc_checking=False): "Forward": hlt1_tracks["Forward"], } data += get_track_checkers(types_and_locations_for_checkers) + print hlt1_tracks["Velo"] + print pvs + #data += get_pv_checkers(pvs, hlt1_tracks["Velo"]) return Reconstruction('hlt1_reco', data, reco_prefilters()) @@ -98,7 +101,7 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): "Forward": allen_tracks["Forward"], } data += get_track_checkers(types_and_locations_for_checkers) - data += get_pv_checkers(allen_pvs, allen_tracks["Velo"]) + #data += get_pv_checkers(allen_pvs, allen_tracks["Velo"]) return Reconstruction('hlt1_reco', data, reco_prefilters()) diff --git a/MooreCache/CMakeLists.txt b/MooreCache/CMakeLists.txt deleted file mode 100644 index 10a8126ede5..00000000000 --- a/MooreCache/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -############################################################################### -# (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() - -# Disable LoKi-specific hacks in LoKiFunctorsCachePostActionOpts.py -# Save the old value so we don't change the behaviour elsewhere. -set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS_TMP ${LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS}) -set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS "") - -loki_functors_cache(Moore_FunctorCache_Hlt1 - ${REC_ROOT_DIR}/Phys/FunctorCache/options/DisableLoKiCacheFunctors.py - ${Moore_SOURCE_DIR}/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py - ${Moore_SOURCE_DIR}/MooreCache/options/process_zero_events.py - ${Moore_SOURCE_DIR}/MooreCache/options/silence_application_manager.py - ${Moore_SOURCE_DIR}/Hlt/Hlt1Conf/options/hlt1_pp_default.py - FACTORIES FunctorFactory - LINK_LIBRARIES FunctorCoreLib - ${conf_deps} - SPLIT 15) - -loki_functors_cache(Moore_FunctorCache_Hlt2_generic_lines - ${REC_ROOT_DIR}/Phys/FunctorCache/options/DisableLoKiCacheFunctors.py - ${Moore_SOURCE_DIR}/MooreCache/options/process_zero_events.py - ${Moore_SOURCE_DIR}/MooreCache/options/silence_application_manager.py - ${Moore_SOURCE_DIR}/Hlt/Hlt2Conf/options/generic_example.py - FACTORIES FunctorFactory - LINK_LIBRARIES FunctorCoreLib DaVinciKernelLib LoKiArrayFunctorsLib LoKiPhysLib - ${conf_deps} - SPLIT 15) - -# Restore the old value -set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS ${LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS_TMP}) diff --git a/MooreCache/options/process_zero_events.py b/MooreCache/options/process_zero_events.py deleted file mode 100644 index d2f06be43f3..00000000000 --- a/MooreCache/options/process_zero_events.py +++ /dev/null @@ -1,12 +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. # -############################################################################### -from Moore import options -options.evt_max = 0 diff --git a/MooreCache/options/silence_application_manager.py b/MooreCache/options/silence_application_manager.py deleted file mode 100644 index a94aac4ef67..00000000000 --- a/MooreCache/options/silence_application_manager.py +++ /dev/null @@ -1,16 +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. # -############################################################################### -from Moore import options -from Gaudi.Configuration import ERROR -import logging - -options.output_level = ERROR -options.python_logging_level = logging.ERROR -- GitLab From 36aaacd7656443a1cbaa78d3aabbef2032222141 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Mon, 24 Feb 2020 15:39:52 +0000 Subject: [PATCH 081/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7318169 --- .../python/RecoConf/mc_checking_categories.py | 177 ++++++++++++------ 1 file changed, 118 insertions(+), 59 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py b/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py index 5eb906ac444..b6d4aea5975 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py @@ -14,24 +14,40 @@ from collections import OrderedDict categories = { "Velo": { - "01_velo": "isVelo", - "02_long": "isLong", - "03_long_P>5GeV": "isLong & over5", - "04_long_strange": "isLong & strange", - "05_long_strange_P>5GeV": "isLong & strange & over5", - "06_long_fromB": "isLong & fromB", - "06_long_fromD": "isLong & fromD", - "07_long_fromB_P>5GeV": "isLong & fromB & over5", - "07_long_fromD_P>5GeV": "isLong & fromD & over5", - "08_long_electrons": "isLong & isElectron", - "09_long_fromB_electrons": "isLong & isElectron & fromB", + "01_velo": + "isVelo", + "02_long": + "isLong", + "03_long_P>5GeV": + "isLong & over5", + "04_long_strange": + "isLong & strange", + "05_long_strange_P>5GeV": + "isLong & strange & over5", + "06_long_fromB": + "isLong & fromB", + "06_long_fromD": + "isLong & fromD", + "07_long_fromB_P>5GeV": + "isLong & fromB & over5", + "07_long_fromD_P>5GeV": + "isLong & fromD & over5", + "08_long_electrons": + "isLong & isElectron", + "09_long_fromB_electrons": + "isLong & isElectron & fromB", "10_long_fromB_electrons_P>5GeV": "isLong & isElectron & over5 & fromB", - "11_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger", - "11_long_fromB_electrons_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isElectron", - "11_long_strange_P>3GeV_Pt>0.5GeV": "isLong & strange& trigger", - "11_long_fromD_P>3GeV_Pt>0.5GeV": "isLong & fromD & trigger", - "12_UT_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isUT", + "11_long_fromB_P>3GeV_Pt>0.5GeV": + "isLong & fromB & trigger", + "11_long_fromB_electrons_P>3GeV_Pt>0.5GeV": + "isLong & fromB & trigger & isElectron", + "11_long_strange_P>3GeV_Pt>0.5GeV": + "isLong & strange& trigger", + "11_long_fromD_P>3GeV_Pt>0.5GeV": + "isLong & fromD & trigger", + "12_UT_long_fromB_P>3GeV_Pt>0.5GeV": + "isLong & fromB & trigger & isUT", }, "VeloFull": { "01_notElectron_Velo": @@ -116,48 +132,84 @@ categories = { "isElectron & isLong & strange & (MCETA>2.0) & (MCETA<5.0) & (MCP>3000) & (MCPT>400)" }, "Forward": { - "01_long": "isLong", - "02_long_P>5GeV": "isLong & over5", - "03_long_strange": "isLong & strange", - "04_long_strange_P>5GeV": "isLong & strange & over5", - "05_long_fromB": "isLong & fromB", - "05_long_fromD": "isLong & fromD", - "06_long_fromB_P>5GeV": "isLong & fromB & over5", - "06_long_fromD_P>5GeV": "isLong & fromD & over5", - "07_long_electrons": "isLong & isElectron", - "08_long_fromB_electrons": "isLong & isElectron & fromB", + "01_long": + "isLong", + "02_long_P>5GeV": + "isLong & over5", + "03_long_strange": + "isLong & strange", + "04_long_strange_P>5GeV": + "isLong & strange & over5", + "05_long_fromB": + "isLong & fromB", + "05_long_fromD": + "isLong & fromD", + "06_long_fromB_P>5GeV": + "isLong & fromB & over5", + "06_long_fromD_P>5GeV": + "isLong & fromD & over5", + "07_long_electrons": + "isLong & isElectron", + "08_long_fromB_electrons": + "isLong & isElectron & fromB", "09_long_fromB_electrons_P>5GeV": "isLong & isElectron & over5 & fromB", - "10_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger", - "10_long_fromB_electrons_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isElectron", - "10_long_strange_P>3GeV_Pt>0.5GeV": "isLong & strange & trigger", - "10_long_fromD_P>3GeV_Pt>0.5GeV": "isLong & fromD & trigger", - "11_UT_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isUT", + "10_long_fromB_P>3GeV_Pt>0.5GeV": + "isLong & fromB & trigger", + "10_long_fromB_electrons_P>3GeV_Pt>0.5GeV": + "isLong & fromB & trigger & isElectron", + "10_long_strange_P>3GeV_Pt>0.5GeV": + "isLong & strange & trigger", + "10_long_fromD_P>3GeV_Pt>0.5GeV": + "isLong & fromD & trigger", + "11_UT_long_fromB_P>3GeV_Pt>0.5GeV": + "isLong & fromB & trigger & isUT", }, "Upstream": { - "01_velo": "isVelo", - "02_velo+UT": "isVelo & isUT", - "03_velo+UT_P>5GeV": "isVelo & isUT & over5", - "04_velo+notLong": "isNotLong & isVelo ", - "05_velo+UT+notLong": "isNotLong & isVelo & isUT", - "06_velo+UT+notLong_P>5GeV": "isNotLong & isVelo & isUT & over5", - "07_long": "isLong", - "07_long_strange": "isLong & strange", - "08_long_P>5GeV": "isLong & over5 ", - "08_long_strange_P>5GeV": "isLong & over5 & strange", - "09_long_fromB": "isLong & fromB", - "09_long_fromD": "isLong & fromD", - "10_long_fromB_P>5GeV": "isLong & fromB & over5", - "10_long_fromD_P>5GeV": "isLong & fromD & over5", - "11_long_electrons": "isLong & isElectron", - "12_long_fromB_electrons": "isLong & isElectron & fromB", + "01_velo": + "isVelo", + "02_velo+UT": + "isVelo & isUT", + "03_velo+UT_P>5GeV": + "isVelo & isUT & over5", + "04_velo+notLong": + "isNotLong & isVelo ", + "05_velo+UT+notLong": + "isNotLong & isVelo & isUT", + "06_velo+UT+notLong_P>5GeV": + "isNotLong & isVelo & isUT & over5", + "07_long": + "isLong", + "07_long_strange": + "isLong & strange", + "08_long_P>5GeV": + "isLong & over5 ", + "08_long_strange_P>5GeV": + "isLong & over5 & strange", + "09_long_fromB": + "isLong & fromB", + "09_long_fromD": + "isLong & fromD", + "10_long_fromB_P>5GeV": + "isLong & fromB & over5", + "10_long_fromD_P>5GeV": + "isLong & fromD & over5", + "11_long_electrons": + "isLong & isElectron", + "12_long_fromB_electrons": + "isLong & isElectron & fromB", "13_long_fromB_electrons_P>5GeV": "isLong & isElectron & over5 & fromB", - "14_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger", - "14_long_fromB_electrons_P>3GeV_Pt>0.5GeV": "isLong & fromB & isElectron & trigger", - "14_long_strange_P>3GeV_Pt>0.5GeV": "isLong & strange& trigger", - "14_long_fromD_P>3GeV_Pt>0.5GeV": "isLong & fromD & trigger", - "15_UT_long_fromB_P>3GeV_Pt>0.5GeV": "isLong & fromB & trigger & isUT", + "14_long_fromB_P>3GeV_Pt>0.5GeV": + "isLong & fromB & trigger", + "14_long_fromB_electrons_P>3GeV_Pt>0.5GeV": + "isLong & fromB & isElectron & trigger", + "14_long_strange_P>3GeV_Pt>0.5GeV": + "isLong & strange& trigger", + "14_long_fromD_P>3GeV_Pt>0.5GeV": + "isLong & fromD & trigger", + "15_UT_long_fromB_P>3GeV_Pt>0.5GeV": + "isLong & fromB & trigger & isUT", }, "UpstreamForMuons": { "01_long_muon": "isLong & isMuon", @@ -165,13 +217,20 @@ categories = { "03_long_pion": "isLong & isPion", }, "MuonMatch": { - "01_long": "isLong", - "02_long_muon": "isLong & isMuon", - "02_long_muon_p>3GeV_pt>0.5GeV": "isLong & isMuon & (MCPT>500) & (MCP>3000)", - "03_long_muon_from_strange": "isLong & strange & isMuon", - "03_long_muon_strange_p>3GeV_pt>0.5GeV": "isLong & isMuon & (MCPT>500) & (MCP>3000) & strange", - "04_long_pion": "isLong & isPion", - "04_long_pion_p>3GeV_pt>0.5GeV": "isLong & isPion & (MCPT>500) & (MCP>3000)", + "01_long": + "isLong", + "02_long_muon": + "isLong & isMuon", + "02_long_muon_p>3GeV_pt>0.5GeV": + "isLong & isMuon & (MCPT>500) & (MCP>3000)", + "03_long_muon_from_strange": + "isLong & strange & isMuon", + "03_long_muon_strange_p>3GeV_pt>0.5GeV": + "isLong & isMuon & (MCPT>500) & (MCP>3000) & strange", + "04_long_pion": + "isLong & isPion", + "04_long_pion_p>3GeV_pt>0.5GeV": + "isLong & isPion & (MCPT>500) & (MCP>3000)", }, "MuonID": { "01_long": "isLong", -- GitLab From a292597ab23ebecf7a81001361906cb53ba9e349 Mon Sep 17 00:00:00 2001 From: Peilian Li Date: Mon, 24 Feb 2020 16:54:50 +0100 Subject: [PATCH 082/171] to keep the same format as previous --- Hlt/RecoConf/python/RecoConf/mc_checking_categories.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py b/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py index b6d4aea5975..809366bad19 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking_categories.py @@ -221,15 +221,15 @@ categories = { "isLong", "02_long_muon": "isLong & isMuon", - "02_long_muon_p>3GeV_pt>0.5GeV": + "02_long_muon_P>3GeV_Pt>0.5GeV": "isLong & isMuon & (MCPT>500) & (MCP>3000)", "03_long_muon_from_strange": "isLong & strange & isMuon", - "03_long_muon_strange_p>3GeV_pt>0.5GeV": + "03_long_muon_strange_P>3GeV_Pt>0.5GeV": "isLong & isMuon & (MCPT>500) & (MCP>3000) & strange", "04_long_pion": "isLong & isPion", - "04_long_pion_p>3GeV_pt>0.5GeV": + "04_long_pion_P>3GeV_Pt>0.5GeV": "isLong & isPion & (MCPT>500) & (MCP>3000)", }, "MuonID": { -- GitLab From 08fa1f4a2600594fa5bba9248ed777a2ddf6acc1 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Mon, 24 Feb 2020 17:01:46 +0100 Subject: [PATCH 083/171] clean up old way of calling pv checker --- Hlt/RecoConf/python/RecoConf/standalone.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 4ac07266b26..5fd1c3ccf8f 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -98,7 +98,6 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): "Forward": allen_tracks["Forward"], } data += get_track_checkers(types_and_locations_for_checkers) - data += get_pv_checkers(allen_pvs, allen_tracks["Velo"]) return Reconstruction('hlt1_reco', data, reco_prefilters()) -- GitLab From 51ee905f16f66e467a7393145fc89404e227ba91 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Mon, 24 Feb 2020 17:46:17 +0100 Subject: [PATCH 084/171] add options script for Allen PV checking --- .../options/hlt1_reco_allen_pvchecker.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py new file mode 100644 index 00000000000..3f2244ffaab --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py @@ -0,0 +1,52 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec +from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs +from RecoConf.mc_checking import get_pv_checkers, get_track_checkers +from Configurables import ApplicationMgr +from Configurables import NTupleSvc +from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable +from Configurables import DumpMuonGeometry, DumpVPGeometry +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import AllenUpdater + +def hlt1_reco_pvchecker(): + + allen_tracks = make_allen_tracks() + allen_pvs = make_allen_pvs() + + data = [allen_pvs] + data += get_pv_checkers(allen_pvs, allen_tracks["Velo"], produce_ntuple=True) + + return Reconstruction('PVperformance', data, [require_gec()]) + + +run_reconstruction(options, hlt1_reco_pvchecker) + +NTupleSvc().Output += [ + "FILE1 DATAFILE='Hlt1_PVperformance.root' TYPE='ROOT' OPT='NEW'" +] +ApplicationMgr().ExtSvc += [NTupleSvc()] +ApplicationMgr().HistogramPersistency = "ROOT" + +producers = [ + p(DumpToFile=False) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) +] + +# Add the services that will produce the non-event-data +ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), +] + producers -- GitLab From e12c59caa83e54444ccffa9ba18914ab24f8f20c Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 25 Feb 2020 15:37:42 +0100 Subject: [PATCH 085/171] add muonid efficiency plotting scripts --- .../hlt1_reco_baseline_with_mcchecking.py | 2 + Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 195 ++++++++++++++++++ Hlt/RecoConf/scripts/utils/ConfigHistos.py | 107 +++++++--- 3 files changed, 275 insertions(+), 29 deletions(-) create mode 100644 Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py diff --git a/Hlt/RecoConf/options/hlt1_reco_baseline_with_mcchecking.py b/Hlt/RecoConf/options/hlt1_reco_baseline_with_mcchecking.py index 6a3072e8c6f..6e154957e5b 100644 --- a/Hlt/RecoConf/options/hlt1_reco_baseline_with_mcchecking.py +++ b/Hlt/RecoConf/options/hlt1_reco_baseline_with_mcchecking.py @@ -13,3 +13,5 @@ from RecoConf.standalone import standalone_hlt1_reco with standalone_hlt1_reco.bind(do_mc_checking=True): run_reconstruction(options, standalone_hlt1_reco) + +options.histo_file = "MCMatching_MiniBias.root" diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py new file mode 100644 index 00000000000..1a3213626bc --- /dev/null +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -0,0 +1,195 @@ +############################################################################### +# (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. # +############################################################################### +#!/usr/bin/python + +# Script for accessing histograms of reconstructible and +# reconstructed tracks for different tracking categories +# created by hlt1_reco_baseline_with_mcchecking.py and +# hlt1_reco_baseline_and_Allen_with_mcchecking.py +# +# The efficency is calculated usig TGraphAsymmErrors +# and Bayesian error bars +# +# author: Dorothea vom Bruch (dorothea.vom.bruch@cern.ch) +# date: 10/2018 +# updated by Peilian Li +# + +import os, sys +import argparse +import ROOT +from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TPad +from ROOT import gROOT, gStyle, TStyle, TPaveText, TH1F +from ROOT import ROOT, TH1D, TH1F, TGraphAsymmErrors +import logging +import subprocess + + +def getEfficiencyHistoNames(): + return ["eta", "p", "pt", "phi", "nPV"] + +def getOriginFolders(): + basedict = {"Forward": {}, "MuonMatch":{}} + basedict["Forward"]["folder"] = "ForwardTrackChecker/" + basedict["MuonMatch"]["folder"] = "MuonMatchTrackChecker/" + + return basedict + + +def getGhostHistoNames(): + return ["eta", "nPV", "pt", "p", "phi"] + + +def argument_parser(): + parser = argparse.ArgumentParser(description="location of the tuple file") + parser.add_argument( + '--directory', + type=str, + default=os.getcwd(), + help='location of input tuple files') + parser.add_argument( + '--mode', type=str, default='', help='name of decay mode') + parser.add_argument( + '--output', type=str, default='efficiency_plots_', help='name of output file') + parser.add_argument( + '--plotstyle', + default=os.getcwd(), + help='location of LHCb utils plot style file') + return parser + + +def PrCheckerEfficiency(directory, mode, output, plotstyle): + sys.path.append(os.path.abspath(plotstyle)) + from utils.LHCbStyle import setLHCbStyle + from utils.ConfigHistos import (efficiencyHistoDict, ghostHistoDict, + categoriesDict, getCuts) + from utils.Legend import place_legend + setLHCbStyle() + + f_CPU = TFile(directory + "/PrChecker_MuonID" + mode+ ".root", "read") + outputfile = TFile(directory + "/"+output + mode+ ".root", "recreate") + + latex = TLatex() + latex.SetNDC() + latex.SetTextSize(0.055) + + efficiencyHistoDict = efficiencyHistoDict() + efficiencyHistos = getEfficiencyHistoNames() + ghostHistos = getGhostHistoNames() + ghostHistoDict = ghostHistoDict() + categories = categoriesDict() + cuts = getCuts() + folders = getOriginFolders() + + tracker="MuonMatch" + outputfile.cd() + trackerDir = outputfile.mkdir(tracker) + trackerDir.cd() + + for cut in cuts[tracker]: + cutDir = trackerDir.mkdir(cut) + cutDir.cd() + folder = folders[tracker]["folder"] + print(folder) + histoBaseName = "Track/" + folder + tracker + "/" + cut + "_" + histoBaseName_den = "Track/" + "ForwardTrackChecker/Forward/" + cut + "_" + + # calculate efficiency + for histo in efficiencyHistos: + title = "efficiency vs. " + histo + ", " + categories[tracker][cut]["title"] + name = "efficiency_" + histo + canvas = TCanvas(name, title) + + # get efficiency for not electrons category + histoName = histoBaseName + "" + efficiencyHistoDict[histo]["variable"] + histoName_den = histoBaseName_den + "" + efficiencyHistoDict[histo]["variable"] + print("not electrons: " + histoName) + numeratorName = histoName + "_reconstructed" + numerator_CPU = TH1D() + numerator_CPU = f_CPU.Get(numeratorName) + denominatorName = histoName_den + "_reconstructed" + denominator_CPU = TH1D() + denominator_CPU = f_CPU.Get(denominatorName) + if numerator_CPU.GetEntries() == 0 or denominator_CPU.GetEntries() == 0: + continue + + numerator_CPU.Sumw2() + denominator_CPU.Sumw2() + + g_efficiency_CPU = TGraphAsymmErrors() + g_efficiency_CPU.SetName("g_efficiency_notElectrons") + g_efficiency_CPU.Divide(numerator_CPU, denominator_CPU, "cl=0.683 b(1,1) mode") + g_efficiency_CPU.SetTitle("Baseline") + if (histoName.find('strange') != -1): + g_efficiency_CPU.SetTitle("Baseline, from stranges") + g_efficiency_CPU.SetMarkerStyle(20) + + h_denominator_CPU = denominator_CPU.Clone() + h_denominator_CPU.SetName("h_denominator_notElectrons") + h_denominator_CPU.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. forward reconstructed") + if (histoName.find('strange') != -1): + h_denominator_CPU.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. strange, forward reconstructed") + + #draw them both if there is ref + mg = TMultiGraph() + mg.Add(g_efficiency_CPU) + mg.Draw("ap") + xtitle = efficiencyHistoDict[histo]["xTitle"] + mg.GetXaxis().SetTitle(xtitle) + mg.GetYaxis().SetTitle("Efficiency") + mg.GetYaxis().SetRangeUser(0, 1.05) + + mg.SetName("efficiency vs. " + histo) + mg.SetTitle(tracker + " " + cut) + + if histo == "p": + mg.GetXaxis().SetRangeUser(0, 50000) + if histo == "pt": + mg.GetXaxis().SetRangeUser(0, 5000) + if histo == "eta": + mg.GetXaxis().SetRangeUser(2, 5) + scale_cpu = 1.0 /h_denominator_CPU.GetMaximum() + h_denominator_CPU.Scale(scale_cpu) + h_denominator_CPU.SetFillStyle(3004) + h_denominator_CPU.SetFillColor(kBlue-10) + h_denominator_CPU.SetLineColor(kBlue - 10) + h_denominator_CPU.SetLineWidth(2) + h_denominator_CPU.Draw("hist same") + + canvas.PlaceLegend() + cutName = categories[tracker][cut]["title"] + latex.DrawLatex(0.35,0.3, cutName) + latex.DrawLatex(0.35,0.4, "LHCb simulation") + + canvas.SetRightMargin(0.05) + canvas.Write() + + #print the muonID efficiency in each p bin + if histo == "p": + for i in range(1, numerator_CPU.GetNbinsX()): + if denominator_CPU.GetBinContent(i) == 0: + continue + Eff = numerator_CPU.GetBinContent(i) / (denominator_CPU.GetBinContent(i) + 0.0) + print("Efficiency of muon ID in (" + + format(numerator_CPU.GetBinLowEdge(i), '.2f') + ", " + format( + numerator_CPU.GetBinLowEdge(i) + numerator_CPU.GetBinWidth(i), '.2f') + + ") [GeV/c] : " + format(Eff, '.2%')) + + outputfile.Write() + outputfile.Close() + f_CPU.Close() + + +if __name__ == '__main__': + parser = argument_parser() + args = parser.parse_args() + PrCheckerEfficiency(**vars(args)) diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 6020b49c340..7c3cfa3a6a8 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -62,22 +62,30 @@ def ghostHistoDict(): def getCuts(): - basedict = {"Velo": {}, "Upstream": {}, "Forward": {}} + basedict = {"Velo": {}, "Upstream": {}, "Forward": {}, "MuonMatch":{} } basedict["Velo"] = [ "01_velo", "02_long", "03_long_P>5GeV", "04_long_strange", "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", - "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV", + "11_long_fromD_P>3GeV_Pt>0.5GeV", "11_long_strange_P>3GeV_Pt>0.5GeV", "06_long_fromD" ] basedict["Upstream"] = [ "01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", - "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV", + "09_long_fromD", "14_long_fromD_P>3GeV_Pt>0.5GeV", "14_long_strange_P>3GeV_Pt>0.5GeV" ] basedict["Forward"] = [ "01_long", "02_long_P>5GeV", "03_long_strange", "04_long_strange_P>5GeV", "05_long_fromB", "06_long_fromB_P>5GeV", - "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV", + "05_long_fromD", "10_long_fromD_P>3GeV_Pt>0.5GeV", + "10_long_strange_P>3GeV_Pt>0.5GeV" + ] + basedict["MuonMatch"] = [ + "02_long_muon_P>3GeV_Pt>0.5GeV", "04_long_pion_P>3GeV_Pt>0.5GeV", "03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", + "01_long", "02_long_muon", "03_long_muon_from_strange", "04_long_pion" ] return basedict @@ -86,28 +94,44 @@ def getCuts(): def categoriesDict(): basedict = defaultdict(lambda: defaultdict(dict)) - basedict["Velo"]["01_velo"]["title"] = "Velo, 2 < eta < 5" - basedict["Velo"]["02_long"]["title"] = "Long, 2 < eta < 5" - basedict["Velo"]["03_long_P>5GeV"]["title"] = "Long, p>5GeV, 2 < eta < 5" + basedict["MuonMatch"]["01_long"]["title"] = "Long, forward track, 2 <#eta< 5" + basedict["MuonMatch"]["02_long_muon"]["title"] = "Long, #mu, forward track, 2 <#eta< 5" + basedict["MuonMatch"]["02_long_muon_P>3GeV_Pt>0.5GeV"]["title"] = "Long, #mu, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" + basedict["MuonMatch"]["03_long_from_strange"]["title"] = "Long, #mu from strange, forward track, 2 <#eta< 5" + basedict["MuonMatch"]["03_long_from_strange_P>3GeV_Pt>0.5GeV"]["title"] = "Long, #mu from strange, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" + basedict["MuonMatch"]["04_long_pion"]["title"] = "Long, #pi, forward track, 2 <#eta< 5" + basedict["MuonMatch"]["04_long_pion_P>3GeV_Pt>0.5GeV"]["title"] = "Long, #pi, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" + + basedict["Velo"]["01_velo"]["title"] = "Velo, 2 <#eta< 5" + basedict["Velo"]["02_long"]["title"] = "Long, 2 <#eta< 5" + basedict["Velo"]["03_long_P>5GeV"]["title"] = "Long, p>5GeV, 2<#eta< 5" basedict["Velo"]["04_long_strange"][ - "title"] = "Long, from Strange, 2 < eta < 5" + "title"] = "Long, from Strange, 2 <#eta < 5" basedict["Velo"]["05_long_strange_P>5GeV"][ - "title"] = "Long, from Strange, p>5GeV, 2 < eta < 5" - basedict["Velo"]["06_long_fromB"]["title"] = "Long from B, 25GeV"][ - "title"] = "Long from B, p>5GeV, 23GeV_Pt>0.5GeV"][ - "title"] = "Long from B, p>3GeV, pt>0.5GeV, electron" + "title"] = "Long from B, p>3GeV, pt>0.5GeV, 2<#eta<5" + basedict["Velo"]["11_long_fromD_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long from D, p>3GeV, pt>0.5GeV, 2<#eta<5" + basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long from strange, p>3GeV, pt>0.5GeV, 2<#eta<5" basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ - "title"] = "UT Long, from B, p>3GeV, pt>0.5GeV" + "title"] = "UT Long, from B, p>3GeV, pt>0.5GeV, 2<#eta<5" basedict["Velo"]["01_velo"]["plotElectrons"] = False basedict["Velo"]["02_long"]["plotElectrons"] = True basedict["Velo"]["03_long_P>5GeV"]["plotElectrons"] = False basedict["Velo"]["04_long_strange"]["plotElectrons"] = False basedict["Velo"]["05_long_strange_P>5GeV"]["plotElectrons"] = False basedict["Velo"]["06_long_fromB"]["plotElectrons"] = True + basedict["Velo"]["06_long_fromD"]["plotElectrons"] = False basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True - basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True + basedict["Velo"]["11_long_fromD_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False @@ -115,19 +139,25 @@ def categoriesDict(): basedict["Velo"]["06_long_fromB"]["Electrons"] = "09_long_fromB_electrons" basedict["Velo"]["07_long_fromB_P>5GeV"][ "Electrons"] = "10_long_fromB_electrons_P>5GeV" + basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["Electrons"] = "11_long_fromB_electrons_P>3GeV_Pt>0.5GeV" - basedict["Upstream"]["01_velo"]["title"] = "Velo, 2 < eta < 5" - basedict["Upstream"]["02_velo+UT"]["title"] = "VeloUT, 2 < eta < 5" + basedict["Upstream"]["01_velo"]["title"] = "Velo, 2 <#eta < 5" + basedict["Upstream"]["02_velo+UT"]["title"] = "VeloUT, 2 <#eta < 5" basedict["Upstream"]["03_velo+UT_P>5GeV"][ - "title"] = "VeloUT, p>5GeV, 2 < eta < 5" - basedict["Upstream"]["07_long"]["title"] = "Long, 2 < eta < 5" + "title"] = "VeloUT, p>5GeV, 2 <#eta < 5" + basedict["Upstream"]["07_long"]["title"] = "Long, 2 <#eta < 5" basedict["Upstream"]["08_long_P>5GeV"][ - "title"] = "Long, p>5GeV, 2 < eta < 5" - basedict["Upstream"]["09_long_fromB"]["title"] = "Long from B, 2 < eta < 5" + "title"] = "Long, p>5GeV, 2 <#eta < 5" + basedict["Upstream"]["09_long_fromB"]["title"] = "Long from B, 2 <#eta < 5" + basedict["Upstream"]["09_long_fromD"]["title"] = "Long from D, 2 <#eta < 5" basedict["Upstream"]["10_long_fromB_P>5GeV"][ - "title"] = "Long from B, p>5GeV, 2 < eta < 5" + "title"] = "Long from B, p>5GeV, 2 <#eta < 5" basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ "title"] = "Long, from B, p>3GeV, pt>0.5GeV" + basedict["Upstream"]["14_long_fromD_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long, from D, p>3GeV, pt>0.5GeV" + basedict["Upstream"]["14_long_strange_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long, from strange, p>3GeV, pt>0.5GeV" basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ "title"] = "Long, from B, p>3GeV, pt>0.5GeV" @@ -137,8 +167,13 @@ def categoriesDict(): basedict["Upstream"]["07_long"]["plotElectrons"] = True basedict["Upstream"]["08_long_P>5GeV"]["plotElectrons"] = False basedict["Upstream"]["09_long_fromB"]["plotElectrons"] = True + basedict["Upstream"]["09_long_fromD"]["plotElectrons"] = False basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = True + basedict["Upstream"]["14_long_fromD_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False + basedict["Upstream"]["14_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False @@ -147,29 +182,41 @@ def categoriesDict(): "Electrons"] = "12_long_fromB_electrons" basedict["Upstream"]["10_long_fromB_P>5GeV"][ "Electrons"] = "13_long_fromB_electrons_P>5GeV" + basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ + "Electrons"] = "14_long_fromB_electrons_P>3GeV_Pt>0.5GeV" - basedict["Forward"]["01_long"]["title"] = "Long, 2 < eta < 5" + basedict["Forward"]["01_long"]["title"] = "Long, 2 <#eta < 5" basedict["Forward"]["02_long_P>5GeV"][ - "title"] = "Long, p>5GeV, 2 < eta < 5" + "title"] = "Long, p>5GeV, 2 <#eta < 5" basedict["Forward"]["03_long_strange"][ - "title"] = "Long, from strange, 2 < eta < 5" + "title"] = "Long, from strange, 2 <#eta < 5" basedict["Forward"]["04_long_strange_P>5GeV"][ - "title"] = "Long, from strange, p>5GeV, 2 < eta < 5" - basedict["Forward"]["05_long_fromB"]["title"] = "Long from B, 2 < eta < 5" + "title"] = "Long, from strange, p>5GeV, 2 <#eta < 5" + basedict["Forward"]["05_long_fromB"]["title"] = "Long from B, 2 <#eta < 5" + basedict["Forward"]["05_long_fromD"]["title"] = "Long from D, 2 <#eta < 5" basedict["Forward"]["06_long_fromB_P>5GeV"][ - "title"] = "Long from B, p>5GeV 2 < eta < 5" + "title"] = "Long from B, p>5GeV 2 <#eta < 5" basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ - "title"] = "Long from B, p>3GeV, pt>0.5GeV, 2 < eta < 5" + "title"] = "Long from B, p>3GeV, pt>0.5GeV, 2 <#eta < 5" + basedict["Forward"]["10_long_fromD_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long from D, p>3GeV, pt>0.5GeV, 2 <#eta < 5" + basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long from strange, p>3GeV, pt>0.5GeV, 2 <#eta < 5" basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ - "title"] = "UT Long from B, p>3GeV, pt>0.5GeV, 2 < eta < 5" + "title"] = "UT Long from B, p>3GeV, pt>0.5GeV, 2 <#eta < 5" basedict["Forward"]["01_long"]["plotElectrons"] = True basedict["Forward"]["02_long_P>5GeV"]["plotElectrons"] = False basedict["Forward"]["03_long_strange"]["plotElectrons"] = False basedict["Forward"]["04_long_strange_P>5GeV"]["plotElectrons"] = False basedict["Forward"]["05_long_fromB"]["plotElectrons"] = True + basedict["Forward"]["05_long_fromD"]["plotElectrons"] = False basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = True + basedict["Forward"]["10_long_fromD_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False + basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False @@ -179,5 +226,7 @@ def categoriesDict(): "Electrons"] = "08_long_fromB_electrons" basedict["Forward"]["06_long_fromB_P>5GeV"][ "Electrons"] = "09_long_fromB_electrons_P>5GeV" + basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ + "Electrons"] = "10_long_fromB_electrons_P>3GeV_Pt>0.5GeV" return basedict -- GitLab From b05ed1f20ac51d9b5e04131924d4239dd575c085 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 25 Feb 2020 14:39:20 +0000 Subject: [PATCH 086/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7333030 --- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 63 +++++++++++++--------- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 42 +++++++++------ 2 files changed, 66 insertions(+), 39 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index 1a3213626bc..ea9b5ac1324 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -12,8 +12,8 @@ # Script for accessing histograms of reconstructible and # reconstructed tracks for different tracking categories -# created by hlt1_reco_baseline_with_mcchecking.py and -# hlt1_reco_baseline_and_Allen_with_mcchecking.py +# created by hlt1_reco_baseline_with_mcchecking.py and +# hlt1_reco_baseline_and_Allen_with_mcchecking.py # # The efficency is calculated usig TGraphAsymmErrors # and Bayesian error bars @@ -37,8 +37,9 @@ import subprocess def getEfficiencyHistoNames(): return ["eta", "p", "pt", "phi", "nPV"] + def getOriginFolders(): - basedict = {"Forward": {}, "MuonMatch":{}} + basedict = {"Forward": {}, "MuonMatch": {}} basedict["Forward"]["folder"] = "ForwardTrackChecker/" basedict["MuonMatch"]["folder"] = "MuonMatchTrackChecker/" @@ -59,7 +60,10 @@ def argument_parser(): parser.add_argument( '--mode', type=str, default='', help='name of decay mode') parser.add_argument( - '--output', type=str, default='efficiency_plots_', help='name of output file') + '--output', + type=str, + default='efficiency_plots_', + help='name of output file') parser.add_argument( '--plotstyle', default=os.getcwd(), @@ -75,8 +79,8 @@ def PrCheckerEfficiency(directory, mode, output, plotstyle): from utils.Legend import place_legend setLHCbStyle() - f_CPU = TFile(directory + "/PrChecker_MuonID" + mode+ ".root", "read") - outputfile = TFile(directory + "/"+output + mode+ ".root", "recreate") + f_CPU = TFile(directory + "/PrChecker_MuonID" + mode + ".root", "read") + outputfile = TFile(directory + "/" + output + mode + ".root", "recreate") latex = TLatex() latex.SetNDC() @@ -90,7 +94,7 @@ def PrCheckerEfficiency(directory, mode, output, plotstyle): cuts = getCuts() folders = getOriginFolders() - tracker="MuonMatch" + tracker = "MuonMatch" outputfile.cd() trackerDir = outputfile.mkdir(tracker) trackerDir.cd() @@ -105,13 +109,16 @@ def PrCheckerEfficiency(directory, mode, output, plotstyle): # calculate efficiency for histo in efficiencyHistos: - title = "efficiency vs. " + histo + ", " + categories[tracker][cut]["title"] + title = "efficiency vs. " + histo + ", " + categories[tracker][ + cut]["title"] name = "efficiency_" + histo canvas = TCanvas(name, title) # get efficiency for not electrons category - histoName = histoBaseName + "" + efficiencyHistoDict[histo]["variable"] - histoName_den = histoBaseName_den + "" + efficiencyHistoDict[histo]["variable"] + histoName = histoBaseName + "" + efficiencyHistoDict[histo][ + "variable"] + histoName_den = histoBaseName_den + "" + efficiencyHistoDict[ + histo]["variable"] print("not electrons: " + histoName) numeratorName = histoName + "_reconstructed" numerator_CPU = TH1D() @@ -119,7 +126,8 @@ def PrCheckerEfficiency(directory, mode, output, plotstyle): denominatorName = histoName_den + "_reconstructed" denominator_CPU = TH1D() denominator_CPU = f_CPU.Get(denominatorName) - if numerator_CPU.GetEntries() == 0 or denominator_CPU.GetEntries() == 0: + if numerator_CPU.GetEntries() == 0 or denominator_CPU.GetEntries( + ) == 0: continue numerator_CPU.Sumw2() @@ -127,7 +135,8 @@ def PrCheckerEfficiency(directory, mode, output, plotstyle): g_efficiency_CPU = TGraphAsymmErrors() g_efficiency_CPU.SetName("g_efficiency_notElectrons") - g_efficiency_CPU.Divide(numerator_CPU, denominator_CPU, "cl=0.683 b(1,1) mode") + g_efficiency_CPU.Divide(numerator_CPU, denominator_CPU, + "cl=0.683 b(1,1) mode") g_efficiency_CPU.SetTitle("Baseline") if (histoName.find('strange') != -1): g_efficiency_CPU.SetTitle("Baseline, from stranges") @@ -135,9 +144,12 @@ def PrCheckerEfficiency(directory, mode, output, plotstyle): h_denominator_CPU = denominator_CPU.Clone() h_denominator_CPU.SetName("h_denominator_notElectrons") - h_denominator_CPU.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. forward reconstructed") + h_denominator_CPU.SetTitle(efficiencyHistoDict[histo]["variable"] + + " histo. forward reconstructed") if (histoName.find('strange') != -1): - h_denominator_CPU.SetTitle(efficiencyHistoDict[histo]["variable"] +" histo. strange, forward reconstructed") + h_denominator_CPU.SetTitle( + efficiencyHistoDict[histo]["variable"] + + " histo. strange, forward reconstructed") #draw them both if there is ref mg = TMultiGraph() @@ -157,32 +169,35 @@ def PrCheckerEfficiency(directory, mode, output, plotstyle): mg.GetXaxis().SetRangeUser(0, 5000) if histo == "eta": mg.GetXaxis().SetRangeUser(2, 5) - scale_cpu = 1.0 /h_denominator_CPU.GetMaximum() + scale_cpu = 1.0 / h_denominator_CPU.GetMaximum() h_denominator_CPU.Scale(scale_cpu) h_denominator_CPU.SetFillStyle(3004) - h_denominator_CPU.SetFillColor(kBlue-10) + h_denominator_CPU.SetFillColor(kBlue - 10) h_denominator_CPU.SetLineColor(kBlue - 10) h_denominator_CPU.SetLineWidth(2) h_denominator_CPU.Draw("hist same") canvas.PlaceLegend() cutName = categories[tracker][cut]["title"] - latex.DrawLatex(0.35,0.3, cutName) - latex.DrawLatex(0.35,0.4, "LHCb simulation") + latex.DrawLatex(0.35, 0.3, cutName) + latex.DrawLatex(0.35, 0.4, "LHCb simulation") canvas.SetRightMargin(0.05) canvas.Write() - #print the muonID efficiency in each p bin + #print the muonID efficiency in each p bin if histo == "p": for i in range(1, numerator_CPU.GetNbinsX()): if denominator_CPU.GetBinContent(i) == 0: continue - Eff = numerator_CPU.GetBinContent(i) / (denominator_CPU.GetBinContent(i) + 0.0) - print("Efficiency of muon ID in (" + - format(numerator_CPU.GetBinLowEdge(i), '.2f') + ", " + format( - numerator_CPU.GetBinLowEdge(i) + numerator_CPU.GetBinWidth(i), '.2f') + - ") [GeV/c] : " + format(Eff, '.2%')) + Eff = numerator_CPU.GetBinContent(i) / ( + denominator_CPU.GetBinContent(i) + 0.0) + print("Efficiency of muon ID in (" + + format(numerator_CPU.GetBinLowEdge(i), '.2f') + + ", " + format( + numerator_CPU.GetBinLowEdge(i) + + numerator_CPU.GetBinWidth(i), '.2f') + + ") [GeV/c] : " + format(Eff, '.2%')) outputfile.Write() outputfile.Close() diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 7c3cfa3a6a8..a6d3c4c4efc 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -62,19 +62,21 @@ def ghostHistoDict(): def getCuts(): - basedict = {"Velo": {}, "Upstream": {}, "Forward": {}, "MuonMatch":{} } + basedict = {"Velo": {}, "Upstream": {}, "Forward": {}, "MuonMatch": {}} basedict["Velo"] = [ "01_velo", "02_long", "03_long_P>5GeV", "04_long_strange", "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV", - "11_long_fromD_P>3GeV_Pt>0.5GeV", "11_long_strange_P>3GeV_Pt>0.5GeV", "06_long_fromD" + "11_long_fromD_P>3GeV_Pt>0.5GeV", "11_long_strange_P>3GeV_Pt>0.5GeV", + "06_long_fromD" ] basedict["Upstream"] = [ "01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV", - "09_long_fromD", "14_long_fromD_P>3GeV_Pt>0.5GeV", "14_long_strange_P>3GeV_Pt>0.5GeV" + "09_long_fromD", "14_long_fromD_P>3GeV_Pt>0.5GeV", + "14_long_strange_P>3GeV_Pt>0.5GeV" ] basedict["Forward"] = [ "01_long", "02_long_P>5GeV", "03_long_strange", @@ -84,8 +86,9 @@ def getCuts(): "10_long_strange_P>3GeV_Pt>0.5GeV" ] basedict["MuonMatch"] = [ - "02_long_muon_P>3GeV_Pt>0.5GeV", "04_long_pion_P>3GeV_Pt>0.5GeV", "03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", - "01_long", "02_long_muon", "03_long_muon_from_strange", "04_long_pion" + "02_long_muon_P>3GeV_Pt>0.5GeV", "04_long_pion_P>3GeV_Pt>0.5GeV", + "03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", "01_long", + "02_long_muon", "03_long_muon_from_strange", "04_long_pion" ] return basedict @@ -94,13 +97,20 @@ def getCuts(): def categoriesDict(): basedict = defaultdict(lambda: defaultdict(dict)) - basedict["MuonMatch"]["01_long"]["title"] = "Long, forward track, 2 <#eta< 5" - basedict["MuonMatch"]["02_long_muon"]["title"] = "Long, #mu, forward track, 2 <#eta< 5" - basedict["MuonMatch"]["02_long_muon_P>3GeV_Pt>0.5GeV"]["title"] = "Long, #mu, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" - basedict["MuonMatch"]["03_long_from_strange"]["title"] = "Long, #mu from strange, forward track, 2 <#eta< 5" - basedict["MuonMatch"]["03_long_from_strange_P>3GeV_Pt>0.5GeV"]["title"] = "Long, #mu from strange, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" - basedict["MuonMatch"]["04_long_pion"]["title"] = "Long, #pi, forward track, 2 <#eta< 5" - basedict["MuonMatch"]["04_long_pion_P>3GeV_Pt>0.5GeV"]["title"] = "Long, #pi, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" + basedict["MuonMatch"]["01_long"][ + "title"] = "Long, forward track, 2 <#eta< 5" + basedict["MuonMatch"]["02_long_muon"][ + "title"] = "Long, #mu, forward track, 2 <#eta< 5" + basedict["MuonMatch"]["02_long_muon_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long, #mu, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" + basedict["MuonMatch"]["03_long_from_strange"][ + "title"] = "Long, #mu from strange, forward track, 2 <#eta< 5" + basedict["MuonMatch"]["03_long_from_strange_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long, #mu from strange, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" + basedict["MuonMatch"]["04_long_pion"][ + "title"] = "Long, #pi, forward track, 2 <#eta< 5" + basedict["MuonMatch"]["04_long_pion_P>3GeV_Pt>0.5GeV"][ + "title"] = "Long, #pi, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" basedict["Velo"]["01_velo"]["title"] = "Velo, 2 <#eta< 5" basedict["Velo"]["02_long"]["title"] = "Long, 2 <#eta< 5" @@ -129,9 +139,10 @@ def categoriesDict(): basedict["Velo"]["06_long_fromB"]["plotElectrons"] = True basedict["Velo"]["06_long_fromD"]["plotElectrons"] = False basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True - basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True + basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True basedict["Velo"]["11_long_fromD_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False - basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False @@ -139,7 +150,8 @@ def categoriesDict(): basedict["Velo"]["06_long_fromB"]["Electrons"] = "09_long_fromB_electrons" basedict["Velo"]["07_long_fromB_P>5GeV"][ "Electrons"] = "10_long_fromB_electrons_P>5GeV" - basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["Electrons"] = "11_long_fromB_electrons_P>3GeV_Pt>0.5GeV" + basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"][ + "Electrons"] = "11_long_fromB_electrons_P>3GeV_Pt>0.5GeV" basedict["Upstream"]["01_velo"]["title"] = "Velo, 2 <#eta < 5" basedict["Upstream"]["02_velo+UT"]["title"] = "VeloUT, 2 <#eta < 5" -- GitLab From 78a50d20eb542ebe8720d043242252c505cc4785 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 25 Feb 2020 16:48:37 +0100 Subject: [PATCH 087/171] add desciption in document about the HLT1 tracking performance check --- .../hlt1_reco_baseline_with_mcchecking.py | 2 +- .../options/hlt1_reco_muonid_efficiency.py | 2 +- Hlt/RecoConf/python/RecoConf/hlt1_tracking.py | 3 +- .../scripts/PrCheckerEfficiency_HLT1.py | 2 +- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 6 +- doc/index.rst | 1 + doc/tutorials/hlt1_tracking_performance.rst | 60 +++++++++++++++++++ 7 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 doc/tutorials/hlt1_tracking_performance.rst diff --git a/Hlt/RecoConf/options/hlt1_reco_baseline_with_mcchecking.py b/Hlt/RecoConf/options/hlt1_reco_baseline_with_mcchecking.py index 6e154957e5b..07e463e8243 100644 --- a/Hlt/RecoConf/options/hlt1_reco_baseline_with_mcchecking.py +++ b/Hlt/RecoConf/options/hlt1_reco_baseline_with_mcchecking.py @@ -14,4 +14,4 @@ from RecoConf.standalone import standalone_hlt1_reco with standalone_hlt1_reco.bind(do_mc_checking=True): run_reconstruction(options, standalone_hlt1_reco) -options.histo_file = "MCMatching_MiniBias.root" +options.histo_file = "MCMatching_baseline_MiniBias.root" diff --git a/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py index 06423ffe9bb..6d58dc723fc 100644 --- a/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py +++ b/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py @@ -81,5 +81,5 @@ def hlt1_reco_muonid_efficiency(): [require_gec()]) -options.histo_file = "PrChecker_MuonID.root" +options.histo_file = "PrChecker_MuonID_MiniBias.root" run_reconstruction(options, hlt1_reco_muonid_efficiency) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py index 38137d66d8a..aa891e48c17 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py @@ -374,7 +374,8 @@ def make_SciFiTrackForwarding_tracks( DataHandle: SciFiTrackForwarding's Output. """ return SciFiTrackForwarding( - HitsLocation=make_ft_hits(), InputTracks=input_tracks["Pr"]).Output + #HitsLocation=make_ft_hits(), InputTracks=input_tracks["Pr"]).Output + HitsLocation=make_ft_hits(), InputTracks=input_tracks["Pr"], SecondLoop=False).Output @configurable diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 191e366f4a5..a39ab47e3b4 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -69,7 +69,7 @@ def argument_parser(): default=os.getcwd(), help='location of input tuple files') parser.add_argument( - '--mode', type=str, default='Bs2PhiPhi', help='decay mode') + '--mode', type=str, default='MiniBias', help='decay mode') parser.add_argument( '--method', type=str, diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index ea9b5ac1324..2620ca98be1 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -58,11 +58,11 @@ def argument_parser(): default=os.getcwd(), help='location of input tuple files') parser.add_argument( - '--mode', type=str, default='', help='name of decay mode') + '--mode', type=str, default='MiniBias', help='name of decay mode') parser.add_argument( '--output', type=str, - default='efficiency_plots_', + default='muonIDeff_plots_', help='name of output file') parser.add_argument( '--plotstyle', @@ -79,7 +79,7 @@ def PrCheckerEfficiency(directory, mode, output, plotstyle): from utils.Legend import place_legend setLHCbStyle() - f_CPU = TFile(directory + "/PrChecker_MuonID" + mode + ".root", "read") + f_CPU = TFile(directory + "/PrChecker_MuonID_" + mode + ".root", "read") outputfile = TFile(directory + "/" + output + mode + ".root", "recreate") latex = TLatex() diff --git a/doc/index.rst b/doc/index.rst index d61e3f40ee1..7a52ec9fc42 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -42,6 +42,7 @@ flow in order to run a `Gaudi`_-based application. tutorials/developing tutorials/hlt2_line tutorials/documentation + tutorials/hlt1_tracking_performance .. toctree:: :caption: Moore diff --git a/doc/tutorials/hlt1_tracking_performance.rst b/doc/tutorials/hlt1_tracking_performance.rst new file mode 100644 index 00000000000..e354499f8b2 --- /dev/null +++ b/doc/tutorials/hlt1_tracking_performance.rst @@ -0,0 +1,60 @@ +HLT1 Tracking Performance Check +============= + +To check the tracking level performance of HLT1 reconstruction, you need to +run these options files in /Moore/Hlt/RecoConf/options with the description +in :doc:`Runing Moore`, like:: + ./Moore/run gaudirun.py some_options_file.py +Then, run these corresponding python scripts in /Moore/Hlt/Recoconf/scripts to +draw these plots. You can find more details below. + +Tracking Efficiency Check +------------------------- + +To check the tracking efficiency, firstly:: +./Moore/run gaudirun.py ./Moore/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py ./Moore/Hlt/RecoConf/options/hlt1_reco_baseline_with_mcchecking.py +Secondly:: + python ./Moore/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py --plotstyle ./Moore/Hlt/RecoConf/scripts + +Then you will have a root file ``efficiency_plots_baseline_MiniBias.root``, including all the tracking efficiency +distribution along with momentum, transverse momentum, eta, etc... +Note that the tracking efficiency is defined as the reconstructed divided by reconstructible tracks. The definition +of reconstructible particles could be found in the LHCb-Note-XXX (will release soon, it is the conventional definition used in LHCb). + + +IP Resolution Check +------------------- + +To check the IP resolution, the input tracks will be velo tracks. Run as follows:: +./Moore/run gaudirun.py ./Moore/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py ./Moore/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +:: + python ./Moore/Hlt/RecoConf/scripts/PrCheckerIPresolution.py --plotstyle ./Moore/Hlt/RecoConf/scripts + +You will see some output of IPx and IPy resolution in different ``1/pT`` and ``eta`` regions, you +will also have a root file ``IPResolution_plots.root``, saving the resolution distributions along with ``1/pT`` and ``eta``. + + +Tracking Resolution Check +------------------------- + +To check the tracking resolution, the input tracks will be forward tracks. Run in two steps:: +./Moore/run gaudirun.py ./Moore/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py ./Moore/Hlt/RecoConf/options/hlt1_reco_trackresolution.py +:: + python ./Moore/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py --plotstyle ./Moore/Hlt/RecoConf/scripts + +You will see the tracking resolution outputs in different momentum ``p`` and ``eta`` regions, you +will also have a root file ``TrackResolution_plots.root``, saving the resolution distributions along with ``p`` and ``eta``. + + +Muon ID Efficiency Check +------------------------- + +To check the muon ID efficiency, run as follows:: +./Moore/run gaudirun.py ./Moore/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py ./Moore/Hlt/RecoConf/options/hlt1_reco_muonid_efficiency.py +:: + python ./Moore/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py --plotstyle ./Moore/Hlt/RecoConf/scripts + +The resultant root file ``muonIDeff_plots_MiniBias.root`` will include the muonID efficiency distributions +along with momentum, transverse momentum, eta, etc.. +Note the muonID efficiency is defined on these reconstructed forward tracks. + -- GitLab From fac0a7205452fe2fafa72b6b5a92fcb8e132065b Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 25 Feb 2020 17:24:35 +0100 Subject: [PATCH 088/171] add notes --- doc/tutorials/hlt1_tracking_performance.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/tutorials/hlt1_tracking_performance.rst b/doc/tutorials/hlt1_tracking_performance.rst index e354499f8b2..b9c4948a43f 100644 --- a/doc/tutorials/hlt1_tracking_performance.rst +++ b/doc/tutorials/hlt1_tracking_performance.rst @@ -1,12 +1,12 @@ HLT1 Tracking Performance Check ============= - -To check the tracking level performance of HLT1 reconstruction, you need to -run these options files in /Moore/Hlt/RecoConf/options with the description +This part is delicated to introduce how to run the applications and plotting scripts for +the tracking level performance of HLT1 reconstruction. +Generally, you need to run these options files in /Moore/Hlt/RecoConf/options with the description in :doc:`Runing Moore`, like:: ./Moore/run gaudirun.py some_options_file.py Then, run these corresponding python scripts in /Moore/Hlt/Recoconf/scripts to -draw these plots. You can find more details below. +draw the plots. You can find more details below. Tracking Efficiency Check ------------------------- @@ -56,5 +56,9 @@ To check the muon ID efficiency, run as follows:: The resultant root file ``muonIDeff_plots_MiniBias.root`` will include the muonID efficiency distributions along with momentum, transverse momentum, eta, etc.. -Note the muonID efficiency is defined on these reconstructed forward tracks. +Note that the muonID efficiency is defined on these reconstructed forward tracks. + + +.. note:: + The input file used here is for SciFi decoding version 4, if you would like to run for SciFi decoding version 6, you can change the input file to ``default_input_and_conds_hlt1_FT6.py``. If you would like to run for other MC samples, you may change your input files refering to the ``TestFileDB.py`` in PRConfig repository. -- GitLab From b01acdb33a8684177118366dfd1daaf002921068 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Tue, 25 Feb 2020 17:42:48 +0100 Subject: [PATCH 089/171] update to changes in IP resolution script --- Hlt/Moore/tests/options/default_input_and_conds_hlt1.py | 4 ++-- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 4 ++-- Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 8da7b5b7df0..0c888f230b3 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -11,8 +11,8 @@ import os from Moore import options -options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') -#options.set_input_from_testfiledb("Upgrade_BsPhiPhi_FTv4_DIGI") +#options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') +options.set_input_from_testfiledb("Upgrade_BsPhiPhi_MD_FTv4_DIGI") options.evt_max = 1000 diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index d525b0c0399..e4cc280f04f 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -19,8 +19,8 @@ from Configurables import NTupleSvc def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) - pvs = make_pvs() - pr_checker = monitor_IPresolution(fitted_tracks["v1"], pvs, + #pvs = make_pvs() + pr_checker = monitor_IPresolution(fitted_tracks["v1"], hlt1_tracks["Velo"]["v1"]) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py index 0398d3973a0..54f9289a9a6 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py @@ -23,8 +23,8 @@ from Configurables import AllenUpdater def hlt1_reco_allen_IPresolution(): allen_tracks = make_allen_tracks() - allen_pvs = make_allen_pvs() - pr_checker = monitor_IPresolution(allen_tracks["Forward"]["v1"], allen_pvs, + #allen_pvs = make_allen_pvs() + pr_checker = monitor_IPresolution(allen_tracks["Forward"]["v1"], allen_tracks["Velo"]["v1"]) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) -- GitLab From 5f1e352892cff50b4d1c1dd25028bd79d329138b Mon Sep 17 00:00:00 2001 From: Agnieszka Dziurda Date: Wed, 26 Feb 2020 09:23:18 +0100 Subject: [PATCH 090/171] script for efficiency plots, small bugfix for decay categories --- .../scripts/PrimaryVertexCheckerEfficiency.py | 133 +++++++++++++ Hlt/RecoConf/scripts/utils/pvutils.py | 182 ++++++++++++++++++ 2 files changed, 315 insertions(+) create mode 100644 Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py create mode 100644 Hlt/RecoConf/scripts/utils/pvutils.py diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py new file mode 100644 index 00000000000..58913f387c0 --- /dev/null +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py @@ -0,0 +1,133 @@ +############################################################################### +# (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. # +############################################################################### +#!/usr/bin/python + +import os, sys +import argparse +import ROOT + +from ROOT import TFile, TTree +from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray +from ROOT import gROOT, TLegend + +parser = argparse.ArgumentParser() +parser.add_argument( '--file', + dest = 'fileName', + default = "", + nargs='+', + help = 'filename to plot') +parser.add_argument( '--label', + dest = 'label', + default = "", + nargs='+', + help = 'labels for files') +parser.add_argument( '--tree', + dest = 'treeName', + default = "", + nargs='+', + help = 'tree name to plot', + ) +parser.add_argument( '--smog', + dest = 'smog', + default = False, + action = 'store_true', + help = 'set true for SMOG' + ) +parser.add_argument( '--multi', + dest = 'multi', + default = False, + action = 'store_true', + help = 'add multiplicity plots' + ) +parser.add_argument( '--dist', + dest = 'dist', + default = False, + action = 'store_true', + help = 'plot distributions in the canvas' + ) +parser.add_argument( '--prefix', + dest = 'prefix', + default = "pv_eff", + help = 'prefix for the plot name', + ) + +def get_categories(multi,smog): + cut = {} + cut["all"] = {"cut":""} + cut["isolated"] = {"cut":"&&isol==1"} + if not smog: + cut["close"] = {"cut":"&&isol==0"} + if multi: + cut["1st"] = {"cut":"&&multimc==1"} + cut["2nd"] = {"cut":"&&multimc==2"} + cut["3rd"] = {"cut":"&&multimc==3"} + cut["4th"] = {"cut":"&&multimc==4"} + cut["5th"] = {"cut":"&&multimc==5"} + + return cut + +def get_colors(): + return [kRed, kBlue, kOrange, kMagenta+2, kGreen+3, kCyan+2] +def get_markers(): + return [21,20,22,23,24,25,26] +def get_labels(number_of_files): + label = [] + for i in range(0,number_of_files): + label.append("PV Checker {number}".format(number=str(i+1))) + return label + + +if __name__ == '__main__' : + args = parser.parse_args() + path = os.getcwd()+"/utils/" + sys.path.append(os.path.abspath(path)) + + gROOT.SetBatch() + + from pvutils import get_default_tree_name + from pvutils import get_files, get_trees, get_eff, plot_eff + from pvutils import set_legend + + markers = get_markers() + colors = get_colors() + + label = args.label + if args.label=="": + label = get_labels(len(args.fileName)) + + tr = {} + tf = {} + tf = get_files(tf, label, args.fileName) + tr = get_trees(tf, tr, label, args.treeName, True) + + eff_tr = {} + eff_z = {} + eff_r = {} + hist_tr = {} + hist_z = {} + hist_r = {} + + cat = get_categories(args.multi,args.smog) + eff_tr, hist_tr = get_eff(eff_tr,hist_tr,tr,"nrectrmc",colors,markers,args.smog,cat,label) + eff_z, hist_z = get_eff(eff_z, hist_z, tr, "zMC",colors,markers,args.smog,cat,label) + eff_r, hist_r = get_eff(eff_r, hist_r, tr, "rMC",colors,markers,args.smog,cat,label) + + if args.dist: + legend = TLegend(0.15, 0.82, 0.88, 0.98 ) + else: + legend = TLegend(0.15, 0.86, 0.88, 0.98 ) + legend = set_legend(legend, label, eff_tr, hist_tr, args.dist) + + plot_eff(eff_tr,hist_tr,args.prefix,"ntracks",cat,label, legend, args.dist) + plot_eff(eff_z, hist_z, args.prefix,"z", cat,label, legend, args.dist) + plot_eff(eff_r, hist_r, args.prefix,"r", cat,label, legend, args.dist) + + diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py new file mode 100644 index 00000000000..3ffa5e54b94 --- /dev/null +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -0,0 +1,182 @@ +############################################################################### +# (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 ROOT import TFile, TTree, TH1F, gDirectory, TGraphAsymmErrors +from ROOT import TCanvas +from ROOT import TGraphErrors, TLegend +from ROOT import gPad, kGray + +def get_default_tree_name(is_checker): + if is_checker: + return "PrimaryVertexChecker/101" + else: + return "VertexCompare/102" + +def get_files(tf, label, files): + i = 0 + for f in files: + tf[label[i]] = TFile(f) + i+=1 + return tf + +def get_trees(tf, tr, label, trees, is_checker): + i=0 + for lab in label: + if len(tf) == len(trees): + tr[lab] = tf[lab].Get(trees[i]) + else: + tr[lab] = tf[lab].Get(get_default_tree_name(is_checker)) + i+=1 + return tr + +def set_style(graph, color, marker, xaxis, yaxis, title): + graph.SetTitle(""); + graph.SetLineColor(color); + graph.SetMarkerColor(color); + graph.SetMarkerSize(1.3); + graph.SetMarkerStyle(marker); + if type(graph) == TH1F: + graph.SetFillColor(color); + graph.SetLineWidth(4) + graph.GetYaxis().SetTitleOffset(0.85); + graph.GetYaxis().SetTitleSize(0.06); + graph.GetYaxis().SetLabelSize(0.06); + graph.GetXaxis().SetTitleSize(0.06); + graph.GetXaxis().SetLabelSize(0.06); + graph.GetXaxis().SetTitleFont(132); + graph.GetXaxis().SetLabelFont(132); + graph.GetYaxis().SetTitleFont(132); + graph.GetYaxis().SetLabelFont(132); + + if title != "": + graph.SetTitle(title) + if xaxis != "": + graph.GetXaxis().SetTitle(xaxis) + if yaxis != "": + graph.GetYaxis().SetTitle(yaxis) + + +def get_range(dependence,smog): + if dependence == "zMC": + if smog: + return "(100,-500,200)" + else: + return "(50,-200,200)" + elif dependence == "rMC": + return "(50,0.0,0.2)" + else: + return "(66,4,70)" + +def get_x_axis(dependence): + if dependence=="zMC": + return "z [mm]" + elif dependence == "rMC": + return "radial distance [mm]" + else: + return "number of tracks in Primary Vertex" + + +def get_eff(eff, hist, trees, dependence, colors, markers, smog, categories, label): + + hist_range = get_range(dependence,smog) + + for cat in categories: + eff[cat] = {} + hist[cat] = {} + i = 0 + for lab in label: + var_den = '{dependence}>>hist{code}_{dep}_{cat}_{lab}{hist_range}'.format( + dependence=dependence,code="den",dep=dependence,cat=cat,lab=lab,hist_range=hist_range) + var_nom = '{dependence}>>hist{code}_{dep}_{cat}_{lab}{hist_range}'.format( + dependence=dependence,code="nom",dep=dependence,cat=cat,lab=lab,hist_range=hist_range) + + cut_den = 'nrectrmc>3 {cuts}'.format(cuts = categories[cat]["cut"]) + cut_nom = cut_den + ' && reco == 1' + + trees[lab].Draw(var_nom,cut_nom) + trees[lab].Draw(var_den,cut_den) + + h_nom = gDirectory.Get('hist{code}_{dep}_{cat}_{lab}'.format(code="nom",dep=dependence,cat=cat,lab=lab)) + h_den = gDirectory.Get('hist{code}_{dep}_{cat}_{lab}'.format(code="den",dep=dependence,cat=cat,lab=lab)) + + g_eff = TGraphAsymmErrors() + g_eff.Divide(h_nom,h_den,"cl=0.683 b(1,1) mode") + + set_style(h_nom, colors[i]-8, markers[i], get_x_axis(dependence),"Efficiency","") + set_style(h_den, kGray, markers[i], get_x_axis(dependence),"Efficiency","") + hist[cat][lab] = {} + hist[cat][lab]["nom"] = h_nom + hist[cat][lab]["den"] = h_den + + set_style(g_eff, colors[i], markers[i], get_x_axis(dependence),"Efficiency","") + eff[cat][lab] = g_eff + i+=1 + + return eff, hist + + +def set_legend(legend, label, gr, hist, dist): + legend.SetTextSize(0.04) + legend.SetTextFont(12) + legend.SetFillColor(4000) + legend.SetShadowColor(0) + legend.SetBorderSize(0) + legend.SetTextFont(132) + legend.SetNColumns(2) + #legend.SetHeader("LHCb Preliminary"); + for lab in label: + legend.AddEntry(gr["all"][lab],"Efficiency {lab}".format(lab=lab),"lep") + if dist: + legend.AddEntry(hist["all"][label[0]]["den"],"Distribution MC","f") + for lab in label: + legend.AddEntry(hist["all"][lab]["nom"],"Distribution {lab}".format(lab=lab),"f") + + return legend + +def plot_eff(eff, hist, prefix, dependence, categories, label, legend, dist): + + for cat in categories: + can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence,cat=cat), "cR", 1200, 800) + can.SetBottomMargin(0.15) + can.SetLeftMargin(0.12) + can.SetTopMargin(0.15) + if dist: + can.SetTopMargin(0.20) + can.SetRightMargin(0.05) + can.cd() + + eff[cat][label[0]].GetYaxis().SetRangeUser(0.0,1.1) + eff[cat][label[0]].Draw("AP") + + for lab in label: + eff[cat][lab].Draw("SAME P") + + if dist: + histmax_den = 1.1*hist[cat][label[0]]["den"].GetMaximum() + scale = gPad.GetUymax()/histmax_den + hist[cat][label[0]]["den"].Scale(scale*0.75) + hist[cat][label[0]]["den"].Draw("hist SAME") + + for lab in label: + histmax_nom = 1.1*hist[cat][lab]["nom"].GetMaximum() + scale = gPad.GetUymax()/histmax_nom + hist[cat][lab]["nom"].Scale(scale*0.75) + hist[cat][lab]["nom"].Draw("SAME") + + legend.Draw("SAME") + + + + saveName = '{prefix}_{dependence}_{cat}.pdf'.format(prefix=prefix,dependence=dependence,cat=cat) + can.SaveAs(saveName) + + + -- GitLab From 8610d321bf78ad7b1717279407ef6ea869fa468a Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 26 Feb 2020 08:26:40 +0000 Subject: [PATCH 091/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7342166 --- .../scripts/PrimaryVertexCheckerEfficiency.py | 160 ++++++++-------- Hlt/RecoConf/scripts/utils/pvutils.py | 177 ++++++++++-------- 2 files changed, 181 insertions(+), 156 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py index 58913f387c0..f05ccd397cb 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py @@ -12,122 +12,126 @@ import os, sys import argparse -import ROOT +import ROOT from ROOT import TFile, TTree from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray from ROOT import gROOT, TLegend parser = argparse.ArgumentParser() -parser.add_argument( '--file', - dest = 'fileName', - default = "", - nargs='+', - help = 'filename to plot') -parser.add_argument( '--label', - dest = 'label', - default = "", - nargs='+', - help = 'labels for files') -parser.add_argument( '--tree', - dest = 'treeName', - default = "", - nargs='+', - help = 'tree name to plot', - ) -parser.add_argument( '--smog', - dest = 'smog', - default = False, - action = 'store_true', - help = 'set true for SMOG' - ) -parser.add_argument( '--multi', - dest = 'multi', - default = False, - action = 'store_true', - help = 'add multiplicity plots' - ) -parser.add_argument( '--dist', - dest = 'dist', - default = False, - action = 'store_true', - help = 'plot distributions in the canvas' - ) -parser.add_argument( '--prefix', - dest = 'prefix', - default = "pv_eff", - help = 'prefix for the plot name', - ) - -def get_categories(multi,smog): +parser.add_argument( + '--file', dest='fileName', default="", nargs='+', help='filename to plot') +parser.add_argument( + '--label', dest='label', default="", nargs='+', help='labels for files') +parser.add_argument( + '--tree', + dest='treeName', + default="", + nargs='+', + help='tree name to plot', +) +parser.add_argument( + '--smog', + dest='smog', + default=False, + action='store_true', + help='set true for SMOG') +parser.add_argument( + '--multi', + dest='multi', + default=False, + action='store_true', + help='add multiplicity plots') +parser.add_argument( + '--dist', + dest='dist', + default=False, + action='store_true', + help='plot distributions in the canvas') +parser.add_argument( + '--prefix', + dest='prefix', + default="pv_eff", + help='prefix for the plot name', +) + + +def get_categories(multi, smog): cut = {} - cut["all"] = {"cut":""} - cut["isolated"] = {"cut":"&&isol==1"} + cut["all"] = {"cut": ""} + cut["isolated"] = {"cut": "&&isol==1"} if not smog: - cut["close"] = {"cut":"&&isol==0"} + cut["close"] = {"cut": "&&isol==0"} if multi: - cut["1st"] = {"cut":"&&multimc==1"} - cut["2nd"] = {"cut":"&&multimc==2"} - cut["3rd"] = {"cut":"&&multimc==3"} - cut["4th"] = {"cut":"&&multimc==4"} - cut["5th"] = {"cut":"&&multimc==5"} + cut["1st"] = {"cut": "&&multimc==1"} + cut["2nd"] = {"cut": "&&multimc==2"} + cut["3rd"] = {"cut": "&&multimc==3"} + cut["4th"] = {"cut": "&&multimc==4"} + cut["5th"] = {"cut": "&&multimc==5"} return cut + def get_colors(): - return [kRed, kBlue, kOrange, kMagenta+2, kGreen+3, kCyan+2] + return [kRed, kBlue, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] + + def get_markers(): - return [21,20,22,23,24,25,26] + return [21, 20, 22, 23, 24, 25, 26] + + def get_labels(number_of_files): label = [] - for i in range(0,number_of_files): - label.append("PV Checker {number}".format(number=str(i+1))) - return label + for i in range(0, number_of_files): + label.append("PV Checker {number}".format(number=str(i + 1))) + return label -if __name__ == '__main__' : +if __name__ == '__main__': args = parser.parse_args() - path = os.getcwd()+"/utils/" + path = os.getcwd() + "/utils/" sys.path.append(os.path.abspath(path)) - + gROOT.SetBatch() - from pvutils import get_default_tree_name - from pvutils import get_files, get_trees, get_eff, plot_eff + from pvutils import get_default_tree_name + from pvutils import get_files, get_trees, get_eff, plot_eff from pvutils import set_legend markers = get_markers() colors = get_colors() label = args.label - if args.label=="": + if args.label == "": label = get_labels(len(args.fileName)) - + tr = {} - tf = {} + tf = {} tf = get_files(tf, label, args.fileName) tr = get_trees(tf, tr, label, args.treeName, True) eff_tr = {} eff_z = {} - eff_r = {} - hist_tr = {} + eff_r = {} + hist_tr = {} hist_z = {} - hist_r = {} + hist_r = {} - cat = get_categories(args.multi,args.smog) - eff_tr, hist_tr = get_eff(eff_tr,hist_tr,tr,"nrectrmc",colors,markers,args.smog,cat,label) - eff_z, hist_z = get_eff(eff_z, hist_z, tr, "zMC",colors,markers,args.smog,cat,label) - eff_r, hist_r = get_eff(eff_r, hist_r, tr, "rMC",colors,markers,args.smog,cat,label) + cat = get_categories(args.multi, args.smog) + eff_tr, hist_tr = get_eff(eff_tr, hist_tr, tr, "nrectrmc", colors, markers, + args.smog, cat, label) + eff_z, hist_z = get_eff(eff_z, hist_z, tr, "zMC", colors, markers, + args.smog, cat, label) + eff_r, hist_r = get_eff(eff_r, hist_r, tr, "rMC", colors, markers, + args.smog, cat, label) if args.dist: - legend = TLegend(0.15, 0.82, 0.88, 0.98 ) + legend = TLegend(0.15, 0.82, 0.88, 0.98) else: - legend = TLegend(0.15, 0.86, 0.88, 0.98 ) - legend = set_legend(legend, label, eff_tr, hist_tr, args.dist) - - plot_eff(eff_tr,hist_tr,args.prefix,"ntracks",cat,label, legend, args.dist) - plot_eff(eff_z, hist_z, args.prefix,"z", cat,label, legend, args.dist) - plot_eff(eff_r, hist_r, args.prefix,"r", cat,label, legend, args.dist) - + legend = TLegend(0.15, 0.86, 0.88, 0.98) + legend = set_legend(legend, label, eff_tr, hist_tr, args.dist) + plot_eff(eff_tr, hist_tr, args.prefix, "ntracks", cat, label, legend, + args.dist) + plot_eff(eff_z, hist_z, args.prefix, "z", cat, label, legend, args.dist) + plot_eff(eff_r, hist_r, args.prefix, "r", cat, label, legend, args.dist) diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py index 3ffa5e54b94..b04330e898a 100644 --- a/Hlt/RecoConf/scripts/utils/pvutils.py +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -11,52 +11,56 @@ from ROOT import TFile, TTree, TH1F, gDirectory, TGraphAsymmErrors from ROOT import TCanvas -from ROOT import TGraphErrors, TLegend -from ROOT import gPad, kGray - +from ROOT import TGraphErrors, TLegend +from ROOT import gPad, kGray + + def get_default_tree_name(is_checker): if is_checker: return "PrimaryVertexChecker/101" else: return "VertexCompare/102" + def get_files(tf, label, files): - i = 0 + i = 0 for f in files: tf[label[i]] = TFile(f) - i+=1 + i += 1 return tf + def get_trees(tf, tr, label, trees, is_checker): - i=0 + i = 0 for lab in label: if len(tf) == len(trees): tr[lab] = tf[lab].Get(trees[i]) else: tr[lab] = tf[lab].Get(get_default_tree_name(is_checker)) - i+=1 - return tr + i += 1 + return tr + def set_style(graph, color, marker, xaxis, yaxis, title): - graph.SetTitle(""); - graph.SetLineColor(color); - graph.SetMarkerColor(color); - graph.SetMarkerSize(1.3); - graph.SetMarkerStyle(marker); + graph.SetTitle("") + graph.SetLineColor(color) + graph.SetMarkerColor(color) + graph.SetMarkerSize(1.3) + graph.SetMarkerStyle(marker) if type(graph) == TH1F: - graph.SetFillColor(color); + graph.SetFillColor(color) graph.SetLineWidth(4) - graph.GetYaxis().SetTitleOffset(0.85); - graph.GetYaxis().SetTitleSize(0.06); - graph.GetYaxis().SetLabelSize(0.06); - graph.GetXaxis().SetTitleSize(0.06); - graph.GetXaxis().SetLabelSize(0.06); - graph.GetXaxis().SetTitleFont(132); - graph.GetXaxis().SetLabelFont(132); - graph.GetYaxis().SetTitleFont(132); - graph.GetYaxis().SetLabelFont(132); - - if title != "": + graph.GetYaxis().SetTitleOffset(0.85) + graph.GetYaxis().SetTitleSize(0.06) + graph.GetYaxis().SetLabelSize(0.06) + graph.GetXaxis().SetTitleSize(0.06) + graph.GetXaxis().SetLabelSize(0.06) + graph.GetXaxis().SetTitleFont(132) + graph.GetXaxis().SetLabelFont(132) + graph.GetYaxis().SetTitleFont(132) + graph.GetYaxis().SetLabelFont(132) + + if title != "": graph.SetTitle(title) if xaxis != "": graph.GetXaxis().SetTitle(xaxis) @@ -64,63 +68,80 @@ def set_style(graph, color, marker, xaxis, yaxis, title): graph.GetYaxis().SetTitle(yaxis) -def get_range(dependence,smog): +def get_range(dependence, smog): if dependence == "zMC": if smog: return "(100,-500,200)" else: return "(50,-200,200)" elif dependence == "rMC": - return "(50,0.0,0.2)" + return "(50,0.0,0.2)" else: return "(66,4,70)" + def get_x_axis(dependence): - if dependence=="zMC": + if dependence == "zMC": return "z [mm]" elif dependence == "rMC": return "radial distance [mm]" else: - return "number of tracks in Primary Vertex" + return "number of tracks in Primary Vertex" -def get_eff(eff, hist, trees, dependence, colors, markers, smog, categories, label): +def get_eff(eff, hist, trees, dependence, colors, markers, smog, categories, + label): - hist_range = get_range(dependence,smog) + hist_range = get_range(dependence, smog) for cat in categories: eff[cat] = {} - hist[cat] = {} + hist[cat] = {} i = 0 for lab in label: var_den = '{dependence}>>hist{code}_{dep}_{cat}_{lab}{hist_range}'.format( - dependence=dependence,code="den",dep=dependence,cat=cat,lab=lab,hist_range=hist_range) + dependence=dependence, + code="den", + dep=dependence, + cat=cat, + lab=lab, + hist_range=hist_range) var_nom = '{dependence}>>hist{code}_{dep}_{cat}_{lab}{hist_range}'.format( - dependence=dependence,code="nom",dep=dependence,cat=cat,lab=lab,hist_range=hist_range) - - cut_den = 'nrectrmc>3 {cuts}'.format(cuts = categories[cat]["cut"]) + dependence=dependence, + code="nom", + dep=dependence, + cat=cat, + lab=lab, + hist_range=hist_range) + + cut_den = 'nrectrmc>3 {cuts}'.format(cuts=categories[cat]["cut"]) cut_nom = cut_den + ' && reco == 1' - - trees[lab].Draw(var_nom,cut_nom) - trees[lab].Draw(var_den,cut_den) - - h_nom = gDirectory.Get('hist{code}_{dep}_{cat}_{lab}'.format(code="nom",dep=dependence,cat=cat,lab=lab)) - h_den = gDirectory.Get('hist{code}_{dep}_{cat}_{lab}'.format(code="den",dep=dependence,cat=cat,lab=lab)) - + + trees[lab].Draw(var_nom, cut_nom) + trees[lab].Draw(var_den, cut_den) + + h_nom = gDirectory.Get('hist{code}_{dep}_{cat}_{lab}'.format( + code="nom", dep=dependence, cat=cat, lab=lab)) + h_den = gDirectory.Get('hist{code}_{dep}_{cat}_{lab}'.format( + code="den", dep=dependence, cat=cat, lab=lab)) + g_eff = TGraphAsymmErrors() - g_eff.Divide(h_nom,h_den,"cl=0.683 b(1,1) mode") - - set_style(h_nom, colors[i]-8, markers[i], get_x_axis(dependence),"Efficiency","") - set_style(h_den, kGray, markers[i], get_x_axis(dependence),"Efficiency","") + g_eff.Divide(h_nom, h_den, "cl=0.683 b(1,1) mode") + + set_style(h_nom, colors[i] - 8, markers[i], get_x_axis(dependence), + "Efficiency", "") + set_style(h_den, kGray, markers[i], get_x_axis(dependence), + "Efficiency", "") hist[cat][lab] = {} hist[cat][lab]["nom"] = h_nom hist[cat][lab]["den"] = h_den - set_style(g_eff, colors[i], markers[i], get_x_axis(dependence),"Efficiency","") + set_style(g_eff, colors[i], markers[i], get_x_axis(dependence), + "Efficiency", "") eff[cat][lab] = g_eff - i+=1 - - return eff, hist + i += 1 + + return eff, hist def set_legend(legend, label, gr, hist, dist): @@ -133,18 +154,22 @@ def set_legend(legend, label, gr, hist, dist): legend.SetNColumns(2) #legend.SetHeader("LHCb Preliminary"); for lab in label: - legend.AddEntry(gr["all"][lab],"Efficiency {lab}".format(lab=lab),"lep") + legend.AddEntry(gr["all"][lab], "Efficiency {lab}".format(lab=lab), + "lep") if dist: - legend.AddEntry(hist["all"][label[0]]["den"],"Distribution MC","f") + legend.AddEntry(hist["all"][label[0]]["den"], "Distribution MC", "f") for lab in label: - legend.AddEntry(hist["all"][lab]["nom"],"Distribution {lab}".format(lab=lab),"f") - + legend.AddEntry(hist["all"][lab]["nom"], + "Distribution {lab}".format(lab=lab), "f") + return legend + def plot_eff(eff, hist, prefix, dependence, categories, label, legend, dist): - - for cat in categories: - can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence,cat=cat), "cR", 1200, 800) + + for cat in categories: + can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence, cat=cat), + "cR", 1200, 800) can.SetBottomMargin(0.15) can.SetLeftMargin(0.12) can.SetTopMargin(0.15) @@ -152,31 +177,27 @@ def plot_eff(eff, hist, prefix, dependence, categories, label, legend, dist): can.SetTopMargin(0.20) can.SetRightMargin(0.05) can.cd() - - eff[cat][label[0]].GetYaxis().SetRangeUser(0.0,1.1) + + eff[cat][label[0]].GetYaxis().SetRangeUser(0.0, 1.1) eff[cat][label[0]].Draw("AP") - + for lab in label: eff[cat][lab].Draw("SAME P") if dist: - histmax_den = 1.1*hist[cat][label[0]]["den"].GetMaximum() - scale = gPad.GetUymax()/histmax_den - hist[cat][label[0]]["den"].Scale(scale*0.75) - hist[cat][label[0]]["den"].Draw("hist SAME") - - for lab in label: - histmax_nom = 1.1*hist[cat][lab]["nom"].GetMaximum() - scale = gPad.GetUymax()/histmax_nom - hist[cat][lab]["nom"].Scale(scale*0.75) + histmax_den = 1.1 * hist[cat][label[0]]["den"].GetMaximum() + scale = gPad.GetUymax() / histmax_den + hist[cat][label[0]]["den"].Scale(scale * 0.75) + hist[cat][label[0]]["den"].Draw("hist SAME") + + for lab in label: + histmax_nom = 1.1 * hist[cat][lab]["nom"].GetMaximum() + scale = gPad.GetUymax() / histmax_nom + hist[cat][lab]["nom"].Scale(scale * 0.75) hist[cat][lab]["nom"].Draw("SAME") - - legend.Draw("SAME") - - - - saveName = '{prefix}_{dependence}_{cat}.pdf'.format(prefix=prefix,dependence=dependence,cat=cat) - can.SaveAs(saveName) - + legend.Draw("SAME") + saveName = '{prefix}_{dependence}_{cat}.pdf'.format( + prefix=prefix, dependence=dependence, cat=cat) + can.SaveAs(saveName) -- GitLab From 928152f98935a5ae93ae421a855bd32d4c8aa78f Mon Sep 17 00:00:00 2001 From: Agnieszka Dziurda Date: Wed, 26 Feb 2020 10:30:00 +0100 Subject: [PATCH 092/171] adding description --- .../scripts/PrimaryVertexCheckerEfficiency.py | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py index f05ccd397cb..d4692b031e6 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py @@ -10,6 +10,23 @@ ############################################################################### #!/usr/bin/python + +# The script for plotting PV efficinecy as the function +# of various distributions: nTracks, z, r. +# As input the NTuple created by hlt1_reco_pvchecker.py +# is needed. +# +# The efficency is calculated usig TGraphAsymmErrors +# and Bayesian error bars +# +# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) +# date: 02/2020 +# +# Example of usage: +# ../../../run python PrimaryVertexCheckerEfficiency.py +# --file file1.root file2.root --label name1 name2 --dist +# + import os, sys import argparse import ROOT @@ -54,7 +71,12 @@ parser.add_argument( default="pv_eff", help='prefix for the plot name', ) - +parser.add_argument( + '--dir', + dest='directory', + default=os.getcwd(), + help='tree name to plot', +) def get_categories(multi, smog): cut = {} @@ -89,7 +111,7 @@ def get_labels(number_of_files): if __name__ == '__main__': args = parser.parse_args() - path = os.getcwd() + "/utils/" + path = args.directory + "/utils/" sys.path.append(os.path.abspath(path)) gROOT.SetBatch() -- GitLab From 86edaf81e20c8a72bb184b9fdaa53c77cfa5dc55 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 26 Feb 2020 09:31:21 +0000 Subject: [PATCH 093/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7343320 --- .../scripts/PrimaryVertexCheckerEfficiency.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py index d4692b031e6..56f166169fd 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py @@ -10,20 +10,19 @@ ############################################################################### #!/usr/bin/python - -# The script for plotting PV efficinecy as the function -# of various distributions: nTracks, z, r. +# The script for plotting PV efficinecy as the function +# of various distributions: nTracks, z, r. # As input the NTuple created by hlt1_reco_pvchecker.py -# is needed. +# is needed. # # The efficency is calculated usig TGraphAsymmErrors # and Bayesian error bars # # author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) # date: 02/2020 -# +# # Example of usage: -# ../../../run python PrimaryVertexCheckerEfficiency.py +# ../../../run python PrimaryVertexCheckerEfficiency.py # --file file1.root file2.root --label name1 name2 --dist # @@ -78,6 +77,7 @@ parser.add_argument( help='tree name to plot', ) + def get_categories(multi, smog): cut = {} cut["all"] = {"cut": ""} -- GitLab From 2f74472ba8c6d159b7bfa27a29e5cf56bad0ff58 Mon Sep 17 00:00:00 2001 From: Agnieszka Dziurda Date: Thu, 27 Feb 2020 09:50:32 +0100 Subject: [PATCH 094/171] very first scripts for plotting resol and pull, for now only global --- .../scripts/PrimaryVertexCheckerPull.py | 147 ++++++++++++++++++ .../scripts/PrimaryVertexCheckerResolution.py | 147 ++++++++++++++++++ Hlt/RecoConf/scripts/utils/pvutils.py | 133 +++++++++++++++- 3 files changed, 423 insertions(+), 4 deletions(-) create mode 100644 Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py create mode 100644 Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py new file mode 100644 index 00000000000..4c9e1f97df3 --- /dev/null +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py @@ -0,0 +1,147 @@ +############################################################################### +# (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. # +############################################################################### +#!/usr/bin/python + +# The script for plotting PV efficinecy as the function +# of various distributions: nTracks, z, r. +# As input the NTuple created by hlt1_reco_pvchecker.py +# is needed. +# +# The efficency is calculated usig TGraphAsymmErrors +# and Bayesian error bars +# +# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) +# date: 02/2020 +# +# Example of usage: +# ../../../run python PrimaryVertexCheckerPull.py +# --file file1.root file2.root --label name1 name2 +# + +import os, sys +import argparse +import ROOT + +from ROOT import TFile, TTree +from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow +from ROOT import gROOT, TLegend + +parser = argparse.ArgumentParser() +parser.add_argument( + '--file', dest='fileName', default="", nargs='+', help='filename to plot') +parser.add_argument( + '--label', dest='label', default="", nargs='+', help='labels for files') +parser.add_argument( + '--tree', + dest='treeName', + default="", + nargs='+', + help='tree name to plot', +) +parser.add_argument( + '--smog', + dest='smog', + default=False, + action='store_true', + help='set true for SMOG') +parser.add_argument( + '--multi', + dest='multi', + default=False, + action='store_true', + help='add multiplicity plots') +parser.add_argument( + '--dist', + dest='dist', + default=False, + action='store_true', + help='plot distributions in the canvas') +parser.add_argument( + '--prefix', + dest='prefix', + default="pv_pull", + help='prefix for the plot name', +) +parser.add_argument( + '--dir', + dest='directory', + default=os.getcwd(), + help='tree name to plot', +) + + +def get_categories(multi, smog): + cut = {} + cut["all"] = {"cut": ""} + cut["isolated"] = {"cut": "&&isol==1"} + if not smog: + cut["close"] = {"cut": "&&isol==0"} + if multi: + cut["1st"] = {"cut": "&&multimc==1"} + cut["2nd"] = {"cut": "&&multimc==2"} + cut["3rd"] = {"cut": "&&multimc==3"} + cut["4th"] = {"cut": "&&multimc==4"} + cut["5th"] = {"cut": "&&multimc==5"} + + return cut + + +def get_colors(): + return [kRed, kBlue, kOrange, kMagenta, kGreen, kCyan] + + +def get_markers(): + return [21, 20, 22, 23, 24, 25, 26] + + +def get_labels(number_of_files): + label = [] + for i in range(0, number_of_files): + label.append("PV Checker {number}".format(number=str(i + 1))) + return label + + +if __name__ == '__main__': + args = parser.parse_args() + path = args.directory + "/utils/" + sys.path.append(os.path.abspath(path)) + + gROOT.SetBatch() + + from pvutils import get_default_tree_name + from pvutils import get_files, get_trees + from pvutils import set_legend, get_global, plot_comparison + + markers = get_markers() + colors = get_colors() + cat = get_categories(args.multi, args.smog) + label = args.label + if args.label == "": + label = get_labels(len(args.fileName)) + + tr = {} + tf = {} + tf = get_files(tf, label, args.fileName) + tr = get_trees(tf, tr, label, args.treeName, True) + + hist_x = {} + hist_y = {} + hist_z = {} + norm = True #to-do + hist_x = get_global(hist_x, tr, "pullx", "#Delta x / #sigma_{x}", "Candidates Normalized", colors, markers, cat, label) + hist_y = get_global(hist_y, tr, "pully", "#Delta y / #sigma_{y}", "Candidates Normalized", colors, markers, cat, label) + hist_z = get_global(hist_z, tr, "pullz", "#Delta z / #sigma_{z}", "Candidates Normalized", colors, markers, cat, label) + + plot_comparison(hist_x, args.prefix, "pullx", cat, label, colors, norm) + plot_comparison(hist_y, args.prefix, "pully", cat, label, colors, norm) + plot_comparison(hist_z, args.prefix, "pullz", cat, label, colors, norm) + + diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py new file mode 100644 index 00000000000..9ee3f4b1be0 --- /dev/null +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py @@ -0,0 +1,147 @@ +############################################################################### +# (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. # +############################################################################### +#!/usr/bin/python + +# The script for plotting PV efficinecy as the function +# of various distributions: nTracks, z, r. +# As input the NTuple created by hlt1_reco_pvchecker.py +# is needed. +# +# The efficency is calculated usig TGraphAsymmErrors +# and Bayesian error bars +# +# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) +# date: 02/2020 +# +# Example of usage: +# ../../../run python PrimaryVertexCheckerResolution.py +# --file file1.root file2.root --label name1 name2 +# + +import os, sys +import argparse +import ROOT + +from ROOT import TFile, TTree +from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow +from ROOT import gROOT, TLegend + +parser = argparse.ArgumentParser() +parser.add_argument( + '--file', dest='fileName', default="", nargs='+', help='filename to plot') +parser.add_argument( + '--label', dest='label', default="", nargs='+', help='labels for files') +parser.add_argument( + '--tree', + dest='treeName', + default="", + nargs='+', + help='tree name to plot', +) +parser.add_argument( + '--smog', + dest='smog', + default=False, + action='store_true', + help='set true for SMOG') +parser.add_argument( + '--multi', + dest='multi', + default=False, + action='store_true', + help='add multiplicity plots') +parser.add_argument( + '--dist', + dest='dist', + default=False, + action='store_true', + help='plot distributions in the canvas') +parser.add_argument( + '--prefix', + dest='prefix', + default="pv_resol", + help='prefix for the plot name', +) +parser.add_argument( + '--dir', + dest='directory', + default=os.getcwd(), + help='tree name to plot', +) + + +def get_categories(multi, smog): + cut = {} + cut["all"] = {"cut": ""} + cut["isolated"] = {"cut": "&&isol==1"} + if not smog: + cut["close"] = {"cut": "&&isol==0"} + if multi: + cut["1st"] = {"cut": "&&multimc==1"} + cut["2nd"] = {"cut": "&&multimc==2"} + cut["3rd"] = {"cut": "&&multimc==3"} + cut["4th"] = {"cut": "&&multimc==4"} + cut["5th"] = {"cut": "&&multimc==5"} + + return cut + + +def get_colors(): + return [kRed, kBlue, kOrange, kMagenta, kGreen, kCyan] + + +def get_markers(): + return [21, 20, 22, 23, 24, 25, 26] + + +def get_labels(number_of_files): + label = [] + for i in range(0, number_of_files): + label.append("PV Checker {number}".format(number=str(i + 1))) + return label + + +if __name__ == '__main__': + args = parser.parse_args() + path = args.directory + "/utils/" + sys.path.append(os.path.abspath(path)) + + gROOT.SetBatch() + + from pvutils import get_default_tree_name + from pvutils import get_files, get_trees + from pvutils import set_legend, get_global, plot_comparison + + markers = get_markers() + colors = get_colors() + cat = get_categories(args.multi, args.smog) + label = args.label + if args.label == "": + label = get_labels(len(args.fileName)) + + tr = {} + tf = {} + tf = get_files(tf, label, args.fileName) + tr = get_trees(tf, tr, label, args.treeName, True) + + hist_x = {} + hist_y = {} + hist_z = {} + norm = True + hist_x = get_global(hist_x, tr, "dx", "#Delta x [mm]", "Candidates Normalized", colors, markers, cat, label) + hist_y = get_global(hist_y, tr, "dy", "#Delta y [mm]", "Candidates Normalized", colors, markers, cat, label) + hist_z = get_global(hist_z, tr, "dz", "#Delta z [mm]", "Candidates Normalized", colors, markers, cat, label) + + plot_comparison(hist_x, args.prefix, "dx", cat, label, colors, norm) + plot_comparison(hist_y, args.prefix, "dy", cat, label, colors, norm) + plot_comparison(hist_z, args.prefix, "dz", cat, label, colors, norm) + + diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py index b04330e898a..934a3d42f53 100644 --- a/Hlt/RecoConf/scripts/utils/pvutils.py +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -9,10 +9,17 @@ # or submit itself to any jurisdiction. # ############################################################################### +# The utils for processing output of the PrimaryVertexChecker output +# +# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) +# date: 02/2020 +# + + from ROOT import TFile, TTree, TH1F, gDirectory, TGraphAsymmErrors from ROOT import TCanvas from ROOT import TGraphErrors, TLegend -from ROOT import gPad, kGray +from ROOT import gPad, kGray, TLatex def get_default_tree_name(is_checker): @@ -47,10 +54,12 @@ def set_style(graph, color, marker, xaxis, yaxis, title): graph.SetMarkerColor(color) graph.SetMarkerSize(1.3) graph.SetMarkerStyle(marker) + graph.GetYaxis().SetTitleOffset(0.85) if type(graph) == TH1F: graph.SetFillColor(color) graph.SetLineWidth(4) - graph.GetYaxis().SetTitleOffset(0.85) + graph.SetStats(False) + graph.GetYaxis().SetTitleOffset(1.1) graph.GetYaxis().SetTitleSize(0.06) graph.GetYaxis().SetLabelSize(0.06) graph.GetXaxis().SetTitleSize(0.06) @@ -76,6 +85,12 @@ def get_range(dependence, smog): return "(50,-200,200)" elif dependence == "rMC": return "(50,0.0,0.2)" + elif (dependence == "dx" or dependence == "dy"): + return "(50,-0.10,0.10)" + elif dependence == "dz": + return "(50,-0.5,0.5)" + elif "err" in dependence or "pull" in dependence: + return "(50,-3.5,3.5)" else: return "(66,4,70)" @@ -114,7 +129,7 @@ def get_eff(eff, hist, trees, dependence, colors, markers, smog, categories, lab=lab, hist_range=hist_range) - cut_den = 'nrectrmc>3 {cuts}'.format(cuts=categories[cat]["cut"]) + cut_den = 'nrectrmc>=4 {cuts}'.format(cuts=categories[cat]["cut"]) cut_nom = cut_den + ' && reco == 1' trees[lab].Draw(var_nom, cut_nom) @@ -195,9 +210,119 @@ def plot_eff(eff, hist, prefix, dependence, categories, label, legend, dist): scale = gPad.GetUymax() / histmax_nom hist[cat][lab]["nom"].Scale(scale * 0.75) hist[cat][lab]["nom"].Draw("SAME") - + + eff[cat][lab].Draw("SAME P") + legend.Draw("SAME") saveName = '{prefix}_{dependence}_{cat}.pdf'.format( prefix=prefix, dependence=dependence, cat=cat) can.SaveAs(saveName) + +def transfer_dependence(dep): + if dep == "pullx": + return "dx/errx" + elif dep == "pully": + return "dy/erry" + elif dep == "pullz": + return "dz/errz" + else: + return dep + +def get_global(hist, trees, dependence, x_axis, y_axis, colors, markers, categories, + label): + + hist_range = get_range(dependence, False) + dep = transfer_dependence(dependence) + + for cat in categories: + hist[cat] = {} + i = 0 + for lab in label: + var = '{dependence}>>hist_{dep}_{cat}_{lab}{hist_range}'.format( + dependence=dep, + dep=dependence, + cat=cat, + lab=lab, + hist_range=hist_range) + + cut = 'nrectrmc>=4 && reco == 1 {cuts}'.format(cuts=categories[cat]["cut"]) + + trees[lab].Draw(var, cut) + h = gDirectory.Get('hist_{dep}_{cat}_{lab}'.format(dep=dependence, cat=cat, lab=lab)) + if i == 0: + col = colors[i]-10 + else: + col = colors[i] + set_style(h, col, markers[i], x_axis, y_axis, "") + + hist[cat][lab] = h + i += 1 + + return hist + +def get_text_cor(): + return {"x":[0.17, 0.65, 0.17, 0.65], "y":[0.92,0.92,0.75,0.75]} + +def set_text(text, color, x, y, lab, mean, mean_err, rms, rms_err, scale, units ): + s = 1.0 + if scale: + s = 1000.0 + + u = "" + if units: + u = "[#mu m]" + + text.SetNDC() + text.SetTextFont(132); + text.SetTextColor(color) + text.DrawLatex(x,y*1.0,lab) + + text.DrawLatex(x,y*0.95, "#mu = {0:0.2f} #pm {1:0.2f} {unit}".format( + mean*1000.0, mean_err*1000.0,unit=u)) + text.DrawLatex(x,y*0.90, "#sigma = {0:0.2f} #pm {1:0.2f} {unit}".format( + rms*s, rms_err*s,unit=u)) + return text + + +def plot_comparison(hist, prefix, dependence, categories, label, colors, norm): + + for cat in categories: + can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence, cat=cat), + "cR", 1200, 800) + can.SetBottomMargin(0.15) + can.SetLeftMargin(0.15) + can.SetTopMargin(0.20) + can.SetRightMargin(0.05) + + can.cd() + cor = get_text_cor() + + hist[cat][label[0]].GetYaxis().SetRangeUser(0.0, hist[cat][label[0]].GetMaximum()*1.1) + scale = True + units = True + if "pull" in dependence: + scale = False + units = False + if norm: + hist[cat][label[0]].DrawNormalized("hist") + hist_max = hist[cat][label[0]].GetMaximum() + i = 0 + for lab in label: + hist[cat][lab].DrawNormalized("SAME PE") + text = TLatex() + text = set_text(text,colors[i],cor["x"][i],cor["y"][i],lab, + hist[cat][lab].GetMean(), hist[cat][lab].GetMeanError(), + hist[cat][lab].GetRMS(), hist[cat][lab].GetRMSError(), + scale,units) + i+=1 + + else: + hist[cat][label[0]].Draw("hist") + for lab in label: + hist[cat][lab].Draw("SAME PE") + + can.Update() + saveName = '{prefix}_{dependence}_{cat}.pdf'.format( + prefix=prefix, dependence=dependence, cat=cat) + can.SaveAs(saveName) -- GitLab From ff00243c818fdaee4a431c578d53d9b71b0e50a2 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 27 Feb 2020 08:51:49 +0000 Subject: [PATCH 095/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7359521 --- .../scripts/PrimaryVertexCheckerPull.py | 23 ++--- .../scripts/PrimaryVertexCheckerResolution.py | 23 ++--- Hlt/RecoConf/scripts/utils/pvutils.py | 88 +++++++++++-------- 3 files changed, 73 insertions(+), 61 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py index 4c9e1f97df3..0e226d931be 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py @@ -132,16 +132,17 @@ if __name__ == '__main__': tf = get_files(tf, label, args.fileName) tr = get_trees(tf, tr, label, args.treeName, True) - hist_x = {} + hist_x = {} hist_y = {} hist_z = {} - norm = True #to-do - hist_x = get_global(hist_x, tr, "pullx", "#Delta x / #sigma_{x}", "Candidates Normalized", colors, markers, cat, label) - hist_y = get_global(hist_y, tr, "pully", "#Delta y / #sigma_{y}", "Candidates Normalized", colors, markers, cat, label) - hist_z = get_global(hist_z, tr, "pullz", "#Delta z / #sigma_{z}", "Candidates Normalized", colors, markers, cat, label) - - plot_comparison(hist_x, args.prefix, "pullx", cat, label, colors, norm) - plot_comparison(hist_y, args.prefix, "pully", cat, label, colors, norm) - plot_comparison(hist_z, args.prefix, "pullz", cat, label, colors, norm) - - + norm = True #to-do + hist_x = get_global(hist_x, tr, "pullx", "#Delta x / #sigma_{x}", + "Candidates Normalized", colors, markers, cat, label) + hist_y = get_global(hist_y, tr, "pully", "#Delta y / #sigma_{y}", + "Candidates Normalized", colors, markers, cat, label) + hist_z = get_global(hist_z, tr, "pullz", "#Delta z / #sigma_{z}", + "Candidates Normalized", colors, markers, cat, label) + + plot_comparison(hist_x, args.prefix, "pullx", cat, label, colors, norm) + plot_comparison(hist_y, args.prefix, "pully", cat, label, colors, norm) + plot_comparison(hist_z, args.prefix, "pullz", cat, label, colors, norm) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py index 9ee3f4b1be0..e89588da0e6 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py @@ -132,16 +132,17 @@ if __name__ == '__main__': tf = get_files(tf, label, args.fileName) tr = get_trees(tf, tr, label, args.treeName, True) - hist_x = {} + hist_x = {} hist_y = {} hist_z = {} - norm = True - hist_x = get_global(hist_x, tr, "dx", "#Delta x [mm]", "Candidates Normalized", colors, markers, cat, label) - hist_y = get_global(hist_y, tr, "dy", "#Delta y [mm]", "Candidates Normalized", colors, markers, cat, label) - hist_z = get_global(hist_z, tr, "dz", "#Delta z [mm]", "Candidates Normalized", colors, markers, cat, label) - - plot_comparison(hist_x, args.prefix, "dx", cat, label, colors, norm) - plot_comparison(hist_y, args.prefix, "dy", cat, label, colors, norm) - plot_comparison(hist_z, args.prefix, "dz", cat, label, colors, norm) - - + norm = True + hist_x = get_global(hist_x, tr, "dx", "#Delta x [mm]", + "Candidates Normalized", colors, markers, cat, label) + hist_y = get_global(hist_y, tr, "dy", "#Delta y [mm]", + "Candidates Normalized", colors, markers, cat, label) + hist_z = get_global(hist_z, tr, "dz", "#Delta z [mm]", + "Candidates Normalized", colors, markers, cat, label) + + plot_comparison(hist_x, args.prefix, "dx", cat, label, colors, norm) + plot_comparison(hist_y, args.prefix, "dy", cat, label, colors, norm) + plot_comparison(hist_z, args.prefix, "dz", cat, label, colors, norm) diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py index 934a3d42f53..124731fe94f 100644 --- a/Hlt/RecoConf/scripts/utils/pvutils.py +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -10,11 +10,10 @@ ############################################################################### # The utils for processing output of the PrimaryVertexChecker output -# +# # author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) -# date: 02/2020 -# - +# date: 02/2020 +# from ROOT import TFile, TTree, TH1F, gDirectory, TGraphAsymmErrors from ROOT import TCanvas @@ -210,30 +209,32 @@ def plot_eff(eff, hist, prefix, dependence, categories, label, legend, dist): scale = gPad.GetUymax() / histmax_nom hist[cat][lab]["nom"].Scale(scale * 0.75) hist[cat][lab]["nom"].Draw("SAME") - + eff[cat][lab].Draw("SAME P") - + legend.Draw("SAME") saveName = '{prefix}_{dependence}_{cat}.pdf'.format( prefix=prefix, dependence=dependence, cat=cat) can.SaveAs(saveName) + def transfer_dependence(dep): if dep == "pullx": return "dx/errx" elif dep == "pully": return "dy/erry" elif dep == "pullz": - return "dz/errz" - else: - return dep + return "dz/errz" + else: + return dep + + +def get_global(hist, trees, dependence, x_axis, y_axis, colors, markers, + categories, label): -def get_global(hist, trees, dependence, x_axis, y_axis, colors, markers, categories, - label): - hist_range = get_range(dependence, False) - dep = transfer_dependence(dependence) + dep = transfer_dependence(dependence) for cat in categories: hist[cat] = {} @@ -245,13 +246,15 @@ def get_global(hist, trees, dependence, x_axis, y_axis, colors, markers, categor cat=cat, lab=lab, hist_range=hist_range) - - cut = 'nrectrmc>=4 && reco == 1 {cuts}'.format(cuts=categories[cat]["cut"]) - + + cut = 'nrectrmc>=4 && reco == 1 {cuts}'.format( + cuts=categories[cat]["cut"]) + trees[lab].Draw(var, cut) - h = gDirectory.Get('hist_{dep}_{cat}_{lab}'.format(dep=dependence, cat=cat, lab=lab)) + h = gDirectory.Get('hist_{dep}_{cat}_{lab}'.format( + dep=dependence, cat=cat, lab=lab)) if i == 0: - col = colors[i]-10 + col = colors[i] - 10 else: col = colors[i] set_style(h, col, markers[i], x_axis, y_axis, "") @@ -261,32 +264,37 @@ def get_global(hist, trees, dependence, x_axis, y_axis, colors, markers, categor return hist + def get_text_cor(): - return {"x":[0.17, 0.65, 0.17, 0.65], "y":[0.92,0.92,0.75,0.75]} + return {"x": [0.17, 0.65, 0.17, 0.65], "y": [0.92, 0.92, 0.75, 0.75]} + -def set_text(text, color, x, y, lab, mean, mean_err, rms, rms_err, scale, units ): +def set_text(text, color, x, y, lab, mean, mean_err, rms, rms_err, scale, + units): s = 1.0 if scale: s = 1000.0 - u = "" + u = "" if units: u = "[#mu m]" text.SetNDC() - text.SetTextFont(132); + text.SetTextFont(132) text.SetTextColor(color) - text.DrawLatex(x,y*1.0,lab) + text.DrawLatex(x, y * 1.0, lab) - text.DrawLatex(x,y*0.95, "#mu = {0:0.2f} #pm {1:0.2f} {unit}".format( - mean*1000.0, mean_err*1000.0,unit=u)) - text.DrawLatex(x,y*0.90, "#sigma = {0:0.2f} #pm {1:0.2f} {unit}".format( - rms*s, rms_err*s,unit=u)) - return text + text.DrawLatex( + x, y * 0.95, "#mu = {0:0.2f} #pm {1:0.2f} {unit}".format( + mean * 1000.0, mean_err * 1000.0, unit=u)) + text.DrawLatex( + x, y * 0.90, "#sigma = {0:0.2f} #pm {1:0.2f} {unit}".format( + rms * s, rms_err * s, unit=u)) + return text def plot_comparison(hist, prefix, dependence, categories, label, colors, norm): - + for cat in categories: can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence, cat=cat), "cR", 1200, 800) @@ -296,14 +304,15 @@ def plot_comparison(hist, prefix, dependence, categories, label, colors, norm): can.SetRightMargin(0.05) can.cd() - cor = get_text_cor() + cor = get_text_cor() - hist[cat][label[0]].GetYaxis().SetRangeUser(0.0, hist[cat][label[0]].GetMaximum()*1.1) + hist[cat][label[0]].GetYaxis().SetRangeUser( + 0.0, hist[cat][label[0]].GetMaximum() * 1.1) scale = True units = True if "pull" in dependence: - scale = False - units = False + scale = False + units = False if norm: hist[cat][label[0]].DrawNormalized("hist") hist_max = hist[cat][label[0]].GetMaximum() @@ -311,18 +320,19 @@ def plot_comparison(hist, prefix, dependence, categories, label, colors, norm): for lab in label: hist[cat][lab].DrawNormalized("SAME PE") text = TLatex() - text = set_text(text,colors[i],cor["x"][i],cor["y"][i],lab, - hist[cat][lab].GetMean(), hist[cat][lab].GetMeanError(), - hist[cat][lab].GetRMS(), hist[cat][lab].GetRMSError(), - scale,units) - i+=1 + text = set_text(text, colors[i], cor["x"][i], cor["y"][i], lab, + hist[cat][lab].GetMean(), + hist[cat][lab].GetMeanError(), + hist[cat][lab].GetRMS(), + hist[cat][lab].GetRMSError(), scale, units) + i += 1 else: hist[cat][label[0]].Draw("hist") for lab in label: hist[cat][lab].Draw("SAME PE") - can.Update() + can.Update() saveName = '{prefix}_{dependence}_{cat}.pdf'.format( prefix=prefix, dependence=dependence, cat=cat) can.SaveAs(saveName) -- GitLab From 7fee7c08b22eeecfeceafcf52965ed4dcf778d59 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 27 Feb 2020 18:39:59 +0100 Subject: [PATCH 096/171] change to the new vertex convertor --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index b21619092ed..97c9d8e166c 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -24,7 +24,7 @@ from PyConf.Algorithms import ( PrLHCbID2MCParticleVPUTFTMU, PrTrackAssociator, PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, DataPacking__Unpack_LHCb__MCVPHitPacker_) -from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertex as FromVectorLHCbRecVertex +from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector @@ -282,9 +282,9 @@ def monitor_track_resolution(InputTracks): def monitor_IPresolution(InputTracks, VeloTracks): - #vertexConverter = FromVectorLHCbRecVertex( - # InputVerticesName=make_pvs(), - # InputTracksName=VeloTracks).OutputVerticesName + vertexConverter = FromVectorLHCbRecVertex( + InputVerticesName=make_pvs(), + InputTracksName=VeloTracks).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( InputTracks, LinksToLHCbIDs=links_to_lhcbids) @@ -293,6 +293,6 @@ def monitor_IPresolution(InputTracks, VeloTracks): MCParticleInput=mc_unpackers()["MCParticles"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), LinkerLocation=links_to_tracks, - PVContainer=make_pvs(), + PVContainer=vertexConverter, NTupleLUN="FILE1") return IPres_checker -- GitLab From 52269141fbb99ba9c64d98e6996e2b47c19e96fd Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 27 Feb 2020 17:40:41 +0000 Subject: [PATCH 097/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7370431 --- Hlt/RecoConf/python/RecoConf/hlt1_tracking.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py index aa891e48c17..096234f8d10 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py @@ -375,7 +375,9 @@ def make_SciFiTrackForwarding_tracks( """ return SciFiTrackForwarding( #HitsLocation=make_ft_hits(), InputTracks=input_tracks["Pr"]).Output - HitsLocation=make_ft_hits(), InputTracks=input_tracks["Pr"], SecondLoop=False).Output + HitsLocation=make_ft_hits(), + InputTracks=input_tracks["Pr"], + SecondLoop=False).Output @configurable -- GitLab From 50f1f3026b36c450930d363d2b2f96e33fd83ea7 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Thu, 27 Feb 2020 23:25:37 +0100 Subject: [PATCH 098/171] add muonID efficiency test --- .../scripts/PrCheckerEfficiency_HLT1.py | 14 ++++---- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 17 +++++---- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 14 ++++---- .../scripts/PrCheckerTrackResolution.py | 15 +++++--- .../hlt1_rec_trackingeff_plots.qmt | 35 +++++++++++++++++++ .../hlt1_reco_IPresolution_plots.qmt | 3 +- .../performance.qms/hlt1_reco_muonIDeff.qmt | 31 ++++++++++++++++ .../hlt1_reco_muonIDeff_plots.qmt | 35 +++++++++++++++++++ .../hlt1_reco_trackresolution_plots.qmt | 2 ++ 9 files changed, 140 insertions(+), 26 deletions(-) create mode 100644 Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_rec_trackingeff_plots.qmt create mode 100644 Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff.qmt create mode 100644 Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index a39ab47e3b4..d9b53a6b939 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -69,12 +69,12 @@ def argument_parser(): default=os.getcwd(), help='location of input tuple files') parser.add_argument( - '--mode', type=str, default='MiniBias', help='decay mode') + '--filename', type=str, default='MCMatching_MiniBias.root', help='input file') parser.add_argument( - '--method', + '--outputfile', type=str, - default='baseline', - help='HLT1 reconstruction method') + default='efficiency_plots.root', + help='output file') parser.add_argument( '--plotstyle', default=os.getcwd(), @@ -82,7 +82,7 @@ def argument_parser(): return parser -def PrCheckerEfficiency(directory, mode, method, plotstyle): +def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): sys.path.append(os.path.abspath(plotstyle)) from utils.LHCbStyle import setLHCbStyle from utils.ConfigHistos import (efficiencyHistoDict, ghostHistoDict, @@ -90,10 +90,10 @@ def PrCheckerEfficiency(directory, mode, method, plotstyle): from utils.Legend import place_legend setLHCbStyle() - f = TFile(directory + "/MCMatching_" + method + "_" + mode + ".root", + f = TFile(directory + "/" + filename, "read") outputfile = TFile( - directory + "/efficiency_plots_" + method + "_" + mode + ".root", + directory + "/" + outputfile, "recreate") latex = TLatex() diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 0e142a26731..81f60b13393 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -39,10 +39,15 @@ def argument_parser(): default=os.getcwd(), help='location of input tuple files') parser.add_argument( - '--name', + '--filename', type=str, - default='Hlt1ForwardTracking_IPresolution', - help='name of input tuple files') + default='Hlt1ForwardTracking_IPresolution.root', + help='input tuple files') + parser.add_argument( + '--outputfile', + type=str, + default='IPResolution_plots.root', + help='output files for plots') parser.add_argument( '--plotstyle', default=os.getcwd(), @@ -50,14 +55,14 @@ def argument_parser(): return parser -def PrCheckerIPresolution(directory, name, plotstyle): +def PrCheckerIPresolution(directory, filename, outputfile, plotstyle): sys.path.append(os.path.abspath(plotstyle)) from utils.LHCbStyle import setLHCbStyle setLHCbStyle() - f = TFile.Open(os.path.join(directory, name + '.root'), 'read') - outputfile = TFile("IPResolution_plots.root", "recreate") + f = TFile.Open(os.path.join(directory, filename), 'read') + outputfile = TFile(directory+"/"+outputfile, "recreate") tuples = f.Get("TrackIPResolutionCheckerNT/tracks") outputfile.cd() diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index 2620ca98be1..945d9dca7f0 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -58,12 +58,12 @@ def argument_parser(): default=os.getcwd(), help='location of input tuple files') parser.add_argument( - '--mode', type=str, default='MiniBias', help='name of decay mode') + '--filename', type=str, default='PrChecker_MuonID_MiniBias.root', help='input file') parser.add_argument( - '--output', + '--outputfile', type=str, - default='muonIDeff_plots_', - help='name of output file') + default='muonIDeff_plots.root', + help='output file') parser.add_argument( '--plotstyle', default=os.getcwd(), @@ -71,7 +71,7 @@ def argument_parser(): return parser -def PrCheckerEfficiency(directory, mode, output, plotstyle): +def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): sys.path.append(os.path.abspath(plotstyle)) from utils.LHCbStyle import setLHCbStyle from utils.ConfigHistos import (efficiencyHistoDict, ghostHistoDict, @@ -79,8 +79,8 @@ def PrCheckerEfficiency(directory, mode, output, plotstyle): from utils.Legend import place_legend setLHCbStyle() - f_CPU = TFile(directory + "/PrChecker_MuonID_" + mode + ".root", "read") - outputfile = TFile(directory + "/" + output + mode + ".root", "recreate") + f_CPU = TFile(directory + "/"+ filename, "read") + outputfile = TFile(directory + "/" + outputfile, "recreate") latex = TLatex() latex.SetNDC() diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index bd8ad506675..d6461913390 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -38,9 +38,14 @@ def argument_parser(): default=os.getcwd(), help='location of input tuple files') parser.add_argument( - '--name', + '--filename', type=str, - default='Hlt1ForwardTrackingResolution', + default='Hlt1ForwardTrackingResolution.root', + help='name of input tuple files') + parser.add_argument( + '--outputfile', + type=str, + default='TrackResolution_plots.root', help='name of input tuple files') parser.add_argument( '--plotstyle', @@ -49,15 +54,15 @@ def argument_parser(): return parser -def PrCheckerTrackResolution(directory, name, plotstyle): +def PrCheckerTrackResolution(directory, filename, outputfile, plotstyle): sys.path.append(os.path.abspath(plotstyle)) from utils.LHCbStyle import setLHCbStyle from utils.Legend import place_legend setLHCbStyle() - f = TFile.Open(os.path.join(directory, name + '.root'), 'read') - outputfile = TFile("TrackResolution_plots.root", "recreate") + f = TFile.Open(os.path.join(directory, filename), 'read') + outputfile = TFile(outputfile, "recreate") outputfile.cd() hres_p = f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_rec_trackingeff_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_rec_trackingeff_plots.qmt new file mode 100644 index 00000000000..731c0006648 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_rec_trackingeff_plots.qmt @@ -0,0 +1,35 @@ + + + + +python + + $RECOCONFROOT/scripts/PrCheckerEfficiency_HLT1.py + --filename=MCMatching_MiniBias.root + --outputfile=efficiency_plots.root + --plotstyle=$RECOCONFROOT/scripts/ + --output=hlt1_reco_trackeff_plot.opts.py + +true + + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + + diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt index ce4f78f3690..ec49d8a7ae3 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt @@ -16,7 +16,8 @@ Test script to determine IP resolution on simulation. python $RECOCONFROOT/scripts/PrCheckerIPresolution.py - --name=Hlt1ForwardTracking_IPresolution + --filename=Hlt1ForwardTracking_IPresolution.root + --outputfile=IPResolution_plots.root --plotstyle=$RECOCONFROOT/scripts/ --output=hlt1_reco_IPresolution_plot.opts.py diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff.qmt new file mode 100644 index 00000000000..def414f3724 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff.qmt @@ -0,0 +1,31 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $RECOCONFROOT/options/hlt1_reco_muonid_efficiency.py + --output=hlt1_reco_muonid_efficiency.opts.py + --all-opt + +true + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt new file mode 100644 index 00000000000..e8c326d40e1 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt @@ -0,0 +1,35 @@ + + + + +python + + $RECOCONFROOT/scripts/PrCheckerMuonIDEff.py + --filename=PrChecker_MuonID_MiniBias.root + --outputfile=muonIDeff_plots.root + --plotstyle=$RECOCONFROOT/scripts/ + --output=hlt1_reco_muonideff_plot.opts.py + +true + + + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + + + diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt index dd1d3b8976f..1bdb4418760 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt @@ -16,6 +16,8 @@ Test plot script to draw the track resolution in Hlt1 and test for changes. python $RECOCONFROOT/scripts/PrCheckerTrackResolution.py + --filename=Hlt1ForwardTrackingResolution.root + --outputfile=TrackResolution_plots.root --plotstyle=$RECOCONFROOT/scripts/ --output=hlt1_reco_trackresolution.opts.py --all-opt -- GitLab From 33412cf3406ca87181583648f8158d4227605633 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 27 Feb 2020 22:26:18 +0000 Subject: [PATCH 099/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7372463 --- Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py | 12 ++++++------ Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 2 +- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index d9b53a6b939..43a8c3afaa4 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -69,7 +69,10 @@ def argument_parser(): default=os.getcwd(), help='location of input tuple files') parser.add_argument( - '--filename', type=str, default='MCMatching_MiniBias.root', help='input file') + '--filename', + type=str, + default='MCMatching_MiniBias.root', + help='input file') parser.add_argument( '--outputfile', type=str, @@ -90,11 +93,8 @@ def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): from utils.Legend import place_legend setLHCbStyle() - f = TFile(directory + "/" + filename, - "read") - outputfile = TFile( - directory + "/" + outputfile, - "recreate") + f = TFile(directory + "/" + filename, "read") + outputfile = TFile(directory + "/" + outputfile, "recreate") latex = TLatex() latex.SetNDC() diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 81f60b13393..0568d9fb763 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -62,7 +62,7 @@ def PrCheckerIPresolution(directory, filename, outputfile, plotstyle): setLHCbStyle() f = TFile.Open(os.path.join(directory, filename), 'read') - outputfile = TFile(directory+"/"+outputfile, "recreate") + outputfile = TFile(directory + "/" + outputfile, "recreate") tuples = f.Get("TrackIPResolutionCheckerNT/tracks") outputfile.cd() diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index 945d9dca7f0..211819d69c8 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -58,7 +58,10 @@ def argument_parser(): default=os.getcwd(), help='location of input tuple files') parser.add_argument( - '--filename', type=str, default='PrChecker_MuonID_MiniBias.root', help='input file') + '--filename', + type=str, + default='PrChecker_MuonID_MiniBias.root', + help='input file') parser.add_argument( '--outputfile', type=str, @@ -79,7 +82,7 @@ def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): from utils.Legend import place_legend setLHCbStyle() - f_CPU = TFile(directory + "/"+ filename, "read") + f_CPU = TFile(directory + "/" + filename, "read") outputfile = TFile(directory + "/" + outputfile, "recreate") latex = TLatex() -- GitLab From e3c7ac3fd371ff288a4b1f3049dcc4b7026b7328 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 28 Feb 2020 11:20:20 +0100 Subject: [PATCH 100/171] modify the monitor_IPresolution --- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 9 ++++++--- Hlt/RecoConf/python/RecoConf/hlt1_tracking.py | 5 +---- Hlt/RecoConf/python/RecoConf/mc_checking.py | 10 +++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index 2d3221e8b59..772a8e709fd 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -10,7 +10,8 @@ ############################################################################### from Moore import options, run_reconstruction from Moore.config import Reconstruction -from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks, make_pvs +from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from RecoConf.mc_checking import monitor_IPresolution from Configurables import ApplicationMgr from Configurables import NTupleSvc @@ -19,8 +20,10 @@ from Configurables import NTupleSvc def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) - pr_checker = monitor_IPresolution(fitted_tracks["v1"], - hlt1_tracks["Velo"]["v1"]) + vertexConverter = FromVectorLHCbRecVertex( + InputVerticesName=make_pvs(), + InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName + pr_checker = monitor_IPresolution(fitted_tracks["v1"], vertexConverter) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py index 096234f8d10..38137d66d8a 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py @@ -374,10 +374,7 @@ def make_SciFiTrackForwarding_tracks( DataHandle: SciFiTrackForwarding's Output. """ return SciFiTrackForwarding( - #HitsLocation=make_ft_hits(), InputTracks=input_tracks["Pr"]).Output - HitsLocation=make_ft_hits(), - InputTracks=input_tracks["Pr"], - SecondLoop=False).Output + HitsLocation=make_ft_hits(), InputTracks=input_tracks["Pr"]).Output @configurable diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 97c9d8e166c..ec32806ef14 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -24,14 +24,13 @@ from PyConf.Algorithms import ( PrLHCbID2MCParticleVPUTFTMU, PrTrackAssociator, PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, DataPacking__Unpack_LHCb__MCVPHitPacker_) -from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector from RecoConf.hlt1_tracking import (make_PrStoreUTHit_hits, make_FTRawBankDecoder_clusters, - make_velo_full_clusters, make_pvs) + make_velo_full_clusters) from Hlt2Conf.data_from_file import mc_unpackers @@ -280,11 +279,8 @@ def monitor_track_resolution(InputTracks): return res_checker -def monitor_IPresolution(InputTracks, VeloTracks): +def monitor_IPresolution(InputTracks, InputPVs): - vertexConverter = FromVectorLHCbRecVertex( - InputVerticesName=make_pvs(), - InputTracksName=VeloTracks).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( InputTracks, LinksToLHCbIDs=links_to_lhcbids) @@ -293,6 +289,6 @@ def monitor_IPresolution(InputTracks, VeloTracks): MCParticleInput=mc_unpackers()["MCParticles"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), LinkerLocation=links_to_tracks, - PVContainer=vertexConverter, + PVContainer=InputPVs, NTupleLUN="FILE1") return IPres_checker -- GitLab From 31d362a754c0a1cbdb71493be37caeae9e8cefe9 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 28 Feb 2020 12:01:09 +0100 Subject: [PATCH 101/171] change the input in monitor_IPresolution --- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 7 ++----- Hlt/RecoConf/python/RecoConf/mc_checking.py | 8 ++++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index 772a8e709fd..19248df61cd 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -11,7 +11,6 @@ from Moore import options, run_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks, make_pvs -from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from RecoConf.mc_checking import monitor_IPresolution from Configurables import ApplicationMgr from Configurables import NTupleSvc @@ -20,10 +19,8 @@ from Configurables import NTupleSvc def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) - vertexConverter = FromVectorLHCbRecVertex( - InputVerticesName=make_pvs(), - InputTracksName=hlt1_tracks["Velo"]["v1"]).OutputVerticesName - pr_checker = monitor_IPresolution(fitted_tracks["v1"], vertexConverter) + inputPVs = make_pvs() + pr_checker = monitor_IPresolution(fitted_tracks["v1"], inputPVs, hlt1_tracks["Velo"]["v1"]) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index ec32806ef14..21866764a1f 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -24,6 +24,7 @@ from PyConf.Algorithms import ( PrLHCbID2MCParticleVPUTFTMU, PrTrackAssociator, PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, DataPacking__Unpack_LHCb__MCVPHitPacker_) +from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector @@ -279,8 +280,11 @@ def monitor_track_resolution(InputTracks): return res_checker -def monitor_IPresolution(InputTracks, InputPVs): +def monitor_IPresolution(InputTracks, InputPVs, VeloTracks): + vertexConverter = FromVectorLHCbRecVertex( + InputVerticesName=InputPVs, + InputTracksName=VeloTracks).OutputVerticesName links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( InputTracks, LinksToLHCbIDs=links_to_lhcbids) @@ -289,6 +293,6 @@ def monitor_IPresolution(InputTracks, InputPVs): MCParticleInput=mc_unpackers()["MCParticles"], MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), LinkerLocation=links_to_tracks, - PVContainer=InputPVs, + PVContainer=vertexConverter, NTupleLUN="FILE1") return IPres_checker -- GitLab From e46ebedab11113f8f9bc3477374a49fbd5a3ad97 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 28 Feb 2020 11:01:53 +0000 Subject: [PATCH 102/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7378111 --- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index 19248df61cd..2cc6d335657 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -20,7 +20,8 @@ def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) inputPVs = make_pvs() - pr_checker = monitor_IPresolution(fitted_tracks["v1"], inputPVs, hlt1_tracks["Velo"]["v1"]) + pr_checker = monitor_IPresolution(fitted_tracks["v1"], inputPVs, + hlt1_tracks["Velo"]["v1"]) return Reconstruction('IPresolution', [pr_checker], [require_gec()]) -- GitLab From 88c111239256591716c37907c5ad5acd5da6e3e5 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 28 Feb 2020 12:47:16 +0000 Subject: [PATCH 103/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7379715 --- Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py | 6 ++++-- Hlt/RecoConf/python/RecoConf/mc_checking.py | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py index 3f2244ffaab..ce1bc77ceea 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py @@ -20,13 +20,15 @@ from Configurables import DumpMuonGeometry, DumpVPGeometry from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import AllenUpdater + def hlt1_reco_pvchecker(): - + allen_tracks = make_allen_tracks() allen_pvs = make_allen_pvs() data = [allen_pvs] - data += get_pv_checkers(allen_pvs, allen_tracks["Velo"], produce_ntuple=True) + data += get_pv_checkers( + allen_pvs, allen_tracks["Velo"], produce_ntuple=True) return Reconstruction('PVperformance', data, [require_gec()]) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index b035b1b6618..01085d90487 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -298,7 +298,6 @@ def make_track_filter(InputTracks, code): return filtered_tracks - def monitor_track_resolution(InputTracks): links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_tracks = make_links_tracks_mcparticles( @@ -326,4 +325,3 @@ def monitor_IPresolution(InputTracks, InputPVs, VeloTracks): PVContainer=vertexConverter, NTupleLUN="FILE1") return IPres_checker - -- GitLab From 4c5513ebb3d423c9003c027c99271c314c273d30 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 3 Mar 2020 00:07:19 +0100 Subject: [PATCH 104/171] add possibility to plot multiply input files --- .../scripts/PrCheckerEfficiency_HLT1.py | 377 ++++++++++-------- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 301 ++++++++------ Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 223 ++++++----- .../scripts/PrCheckerTrackResolution.py | 189 +++++---- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 8 +- Hlt/RecoConf/scripts/utils/LHCbStyle.py | 26 +- 6 files changed, 670 insertions(+), 454 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 43a8c3afaa4..70efeca341a 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -26,7 +26,7 @@ import os, sys import argparse import ROOT from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject -from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad +from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kGray, kOrange, kMagenta, kCyan, kTRUE, kFALSE, gPad from ROOT import gROOT, gStyle, TStyle, TPaveText from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors import logging @@ -36,11 +36,9 @@ import subprocess def getEfficiencyHistoNames(): return ["eta", "p", "pt", "phi", "nPV"] - def getTrackers(): return ["Velo", "Upstream", "Forward"] - def getOriginFolders(): basedict = {"Velo": {}, "Upstream": {}, "Forward": {}} @@ -50,55 +48,119 @@ def getOriginFolders(): return basedict +def get_colors(): + return [kBlack, kAzure, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] + +def get_markers(): + return [20, 24, 21, 22, 23, 25 ] +def get_fillstyles(): + return [3004, 3003, 3325, 3144, 3244, 3444] def getGhostHistoNames(): return ["eta", "nPV", "pt", "p"] - -def getMode(): - return [ - "Bd2Kstee", "Bs2PhiPhi", "Dp2KSPip", "Dst2D0pi", "Z2mumu", "Bd2Dstmumu" - ] - - def argument_parser(): parser = argparse.ArgumentParser(description="location of the tuple file") - parser.add_argument( - '--directory', - type=str, - default=os.getcwd(), - help='location of input tuple files') parser.add_argument( '--filename', type=str, default='MCMatching_MiniBias.root', - help='input file') + nargs='+', + help='input files, including path') parser.add_argument( - '--outputfile', + '--outfile', type=str, default='efficiency_plots.root', help='output file') + parser.add_argument( + '--label', + nargs='+', + default="EffChecker", + help='label for files') parser.add_argument( '--plotstyle', default=os.getcwd(), help='location of LHCb utils plot style file') + parser.add_argument( + '--dist', + default=False, + action='store_true', + help='draw histogram of all files') + parser.add_argument( + '--plotelec', + default=False, + action='store_true', + help='draw eff of electron on the same canvas') + parser.add_argument( + '--savepdf', + default=False, + action='store_true', + help='save plots in pdf format') return parser - -def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): +def get_files(tf, filename, label): + for i, f in enumerate(filename): + tf[label[i]] = TFile(f, "read") + return tf + +def get_eff(eff, hist, tf, histoName, label, var): + eff = {} + hist = {} + for i, lab in enumerate(label): + numeratorName = histoName + "_reconstructed" + numerator = tf[lab].Get(numeratorName) + denominatorName = histoName + "_reconstructible" + denominator = tf[lab].Get(denominatorName) + if numerator.GetEntries() == 0 or denominator.GetEntries() == 0: + continue + numerator.Sumw2() + denominator.Sumw2() + + eff[lab] = TGraphAsymmErrors() + eff[lab].SetName(lab) + eff[lab].Divide(numerator, denominator, "cl=0.683 b(1,1) mode") + eff[lab].SetTitle(lab+"not elec.") + if (histoName.find('strange') != -1): + eff[lab].SetTitle(lab+" from stranges") + if (histoName.find('electron') != -1): + eff[lab].SetTitle(lab+" electron") + + hist[lab]= denominator.Clone() + hist[lab].SetName("h_numerator_notElectrons") + hist[lab].SetTitle(var +" histo. not elec.") + if (histoName.find('strange') != -1): + hist[lab].SetTitle(var +" histo. stranges") + if (histoName.find('electron') != -1): + hist[lab].SetTitle(var +" histo. electron") + + if var== "p": + eff[lab].GetXaxis().SetRangeUser(0, 50000) + hist[lab].GetXaxis().SetRangeUser(0, 50000) + if var== "pt": + eff[lab].GetXaxis().SetRangeUser(0, 5000) + hist[lab].GetXaxis().SetRangeUser(0, 5000) + + return eff, hist + +def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, savepdf): sys.path.append(os.path.abspath(plotstyle)) - from utils.LHCbStyle import setLHCbStyle + from utils.LHCbStyle import setLHCbStyle, set_style from utils.ConfigHistos import (efficiencyHistoDict, ghostHistoDict, categoriesDict, getCuts) from utils.Legend import place_legend setLHCbStyle() - f = TFile(directory + "/" + filename, "read") - outputfile = TFile(directory + "/" + outputfile, "recreate") + markers = get_markers() + colors = get_colors() + styles= get_fillstyles() + tf={} + + tf=get_files(tf, filename, label) + outputfile = TFile(outfile, "recreate") latex = TLatex() latex.SetNDC() - latex.SetTextSize(0.045) + latex.SetTextSize(0.05) efficiencyHistoDict = efficiencyHistoDict() efficiencyHistos = getEfficiencyHistoNames() @@ -123,140 +185,134 @@ def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): # calculate efficiency for histo in efficiencyHistos: - title = "efficiency vs. " + histo + ", " + categories[tracker][ + canvastitle = "efficiency_" + histo + ", " + categories[tracker][ cut]["title"] - name = "efficiency vs. " + histo - canvas = TCanvas(name, title) # get efficiency for not electrons category histoName = histoBaseName + "" + efficiencyHistoDict[histo][ "variable"] print("not electrons: " + histoName) - numeratorName = histoName + "_reconstructed" - numerator = f.Get(numeratorName) - denominatorName = histoName + "_reconstructible" - denominator = f.Get(denominatorName) - if numerator.GetEntries() == 0 or denominator.GetEntries( - ) == 0: - continue - - numerator.Sumw2() - denominator.Sumw2() - - g_efficiency_notElectrons = TGraphAsymmErrors() - g_efficiency_notElectrons.SetName("g_efficiency_notElectrons") - g_efficiency_notElectrons.Divide(numerator, denominator, - "cl=0.683 b(1,1) mode") - g_efficiency_notElectrons.SetTitle("Eff. not electrons") - if (histoName.find('strange') != -1): - g_efficiency_notElectrons.SetTitle("Eff. from stranges") - g_efficiency_notElectrons.Draw() - - h_numerator_notElectrons = denominator.Clone() - h_numerator_notElectrons.SetName("h_numerator_notElectrons") - h_numerator_notElectrons.SetTitle( - efficiencyHistoDict[histo]["variable"] + - " histo. not electrons") - if (histoName.find('strange') != -1): - h_numerator_notElectrons.SetTitle( - efficiencyHistoDict[histo]["variable"] + - " histo. stranges") - - # get efficiency for electrons category - if categories[tracker][cut]["plotElectrons"]: - histoNameElec = "Track/" + folder + tracker + "/" + categories[ - tracker][cut]["Electrons"] - histoName = histoNameElec + "_" + efficiencyHistoDict[ - histo]["variable"] - print("electrons: " + histoName) - numeratorName = histoName + "_reconstructed" - numerator = f.Get(numeratorName) - denominatorName = histoName + "_reconstructible" - denominator = f.Get(denominatorName) - if numerator.GetEntries() == 0 or denominator.GetEntries( - ) == 0: - continue - - numerator.Sumw2() - denominator.Sumw2() - - g_efficiency_electrons = TGraphAsymmErrors() - g_efficiency_electrons.SetName("g_efficiency_electrons") - g_efficiency_electrons.Divide(numerator, denominator, - "cl=0.683 b(1,1) mode") - g_efficiency_electrons.SetTitle("Eff. electrons") - g_efficiency_electrons.SetMarkerColor(kAzure - 3) - g_efficiency_electrons.SetMarkerStyle(24) - g_efficiency_electrons.SetLineColor(kAzure - 3) - - h_numerator_electrons = denominator.Clone() - h_numerator_electrons.SetName("h_numerator_electrons") - h_numerator_electrons.SetTitle( - efficiencyHistoDict[histo]["variable"] + - " histo. electrons") - - #draw them both + eff={} + hist_den={} + eff, hist_den = get_eff( eff, hist_den, tf, histoName, label, histo) + name = "efficiency_" + histo + canvas = TCanvas(name, canvastitle) mg = TMultiGraph() - mg.Add(g_efficiency_notElectrons) - if categories[tracker][cut]["plotElectrons"]: - mg.Add(g_efficiency_electrons) - - mg.Draw("ap") + for i, lab in enumerate(label): + mg.Add(eff[lab]) + set_style(eff[lab], colors[i], markers[i], styles[i]) + mg.Draw("AP") + mg.GetYaxis().SetRangeUser(0, 1.05) xtitle = efficiencyHistoDict[histo]["xTitle"] mg.GetXaxis().SetTitle(xtitle) mg.GetYaxis().SetTitle("Efficiency") - mg.GetYaxis().SetRangeUser(0, 1.05) - - mg.SetName("efficiency vs. " + histo) - mg.SetTitle(tracker + " " + cut) - - rightmax = 1.05 * h_numerator_notElectrons.GetMaximum() - scale = gPad.GetUymax() / rightmax - h_numerator_notElectrons.Scale(scale) - h_numerator_notElectrons.SetFillStyle(3004) - h_numerator_notElectrons.SetFillColor(kBlue) - h_numerator_notElectrons.SetLineColor(kBlue - 10) - h_numerator_notElectrons.SetLineWidth(2) - h_numerator_notElectrons.Draw("hist same") - if categories[tracker][cut]["plotElectrons"]: - scale = gPad.GetUymax() / ( - h_numerator_electrons.GetMaximum() * 1.1) - h_numerator_electrons.Scale(scale) - h_numerator_electrons.SetFillStyle(3003) - h_numerator_electrons.SetFillColor(kGreen) - h_numerator_electrons.SetLineColor(kGreen - 10) - h_numerator_electrons.SetLineWidth(2) - h_numerator_electrons.Draw("hist same") - axis = TGaxis(gPad.GetUxmax(), 0, gPad.GetUxmax(), 1.05, 0, - rightmax, 510, "+L") - if histo == "p": - axis = TGaxis(50000, 0, 50000, 1.05, 0, rightmax, 510, - "+L") - mg.GetXaxis().SetRangeUser(0, 50000) - if histo == "pt": - axis = TGaxis(5000, 0, 5000, 1.05, 0, rightmax, 510, "+L") - mg.GetXaxis().SetRangeUser(0, 5000) - axis.SetTitle("Number of events") - axis.SetTextFont(132) - axis.SetLabelFont(132) - axis.SetTitleFont(132) - axis.SetLabelSize(0.06) - axis.SetTitleSize(0.07) - axis.SetNdivisions(505) - gPad.SetRightMargin(0.75) + if dist: + for i, lab in enumerate(label): + rightmax = 1.05 * hist_den[lab].GetMaximum() + scale = gPad.GetUymax() / rightmax + hist_den[lab].Scale(scale) + if i==0: + set_style(hist_den[lab], kGray, markers[i], styles[i]) + else: + set_style(hist_den[lab], colors[i]-10, markers[i], styles[i]) + hist_den[lab].Draw("hist SAME") + else: + rightmax = 0.95 * hist_den[label[0]].GetMaximum() + scale = gPad.GetUymax() / rightmax + set_style(hist_den[label[0]], kBlue-10, markers[i], styles[i]) + hist_den[label[0]].Scale(scale) + hist_den[label[0]].Draw("hist SAME") canvas.PlaceLegend() - - pt = TPaveText(0.32, 0.65, 0.68, 0.8, "BRNDC") - pt.SetTextSize(0.05) - pt.SetBorderSize(1) - pt.SetFillColor(10) - pt.SetLineWidth(0) cutName = categories[tracker][cut]["title"] - text = pt.AddText(cutName) - pt.Draw() + latex.DrawLatex(0.7,0.85, "LHCb simultaion") + latex.DrawLatex(0.35,0.3, cutName) + canvasName=tracker+"_"+cut+"_"+histo+".pdf" + if savepdf: + canvas.SaveAs(canvasName) canvas.SetRightMargin(0.05) canvas.Write() + # get efficiency for electrons category + if categories[tracker][cut]["plotElectrons"]: + histoNameElec = "Track/" + folder + tracker + "/" + categories[ + tracker][cut]["Electrons"] + histoName = histoNameElec + "_" + efficiencyHistoDict[ + histo]["variable"] + print("electrons: " + histoName) + eff_elec={} + hist_elec={} + eff_elec, hist_elec=get_eff(eff_elec, hist_elec, tf, histoName, label, histo) + + #draw efficiency of electron + canvas_elec=TCanvas(name+"_elec", canvastitle+"_elec") + mg_elec = TMultiGraph() + for i, lab in enumerate(label): + mg_elec.Add(eff_elec[lab]) + set_style(eff_elec[lab], colors[i], markers[i], styles[i]) + set_style(hist_elec[lab], colors[i]-10, markers[i], styles[i]) + mg_elec.Draw("AP") + mg_elec.GetYaxis().SetRangeUser(0, 1.05) + mg_elec.GetXaxis().SetTitle(xtitle) + mg_elec.GetYaxis().SetTitle("Efficiency") + if dist: + for lab in label: + rightmax = 1.05 * hist_elec[lab].GetMaximum() + scale = gPad.GetUymax() / rightmax + hist_elec[lab].Scale(scale) + hist_elec[lab].Draw("hist SAME") + else: + rightmax = 1.05 * hist_elec[label[0]].GetMaximum() + scale = gPad.GetUymax() / rightmax + hist_elec[label[0]].Scale(scale) + hist_elec[label[0]].Draw("hist SAME") + set_style(hist_elec[label[0]], kBlue-10, markers[i], styles[i]) + + canvas_elec.PlaceLegend() + latex.DrawLatex(0.7,0.85, "LHCb simultaion") + latex.DrawLatex(0.35,0.3, cutName) + canvasName_elec=tracker+"_"+cut+"_"+histo+"_elec.pdf" + if savepdf: + canvas_elec.SaveAs(canvasName_elec) + canvas_elec.SetRightMargin(0.05) + canvas_elec.Write() + + #draw them both + if plotelec: + canvas_com=TCanvas(name+"_combine", title+"_combine") + i=0 + mg_comb = TMultiGraph() + for lab in label: + mg_comb.Add(eff[lab]) + mg_comb.Add(eff_elec[lab]) + set_style(eff[lab], colors[i], markers[i], styles[i]) + set_style(eff_elec[lab], colors[i+1], markers[i+1], styles[i]) + set_style(hist_den[lab], colors[i]-10, markers[i], styles[i]) + set_style(hist_elec[lab], colors[i+1]-10, markers[i+1], styles[i]) + rightmax = 1.05 * hist_den[lab].GetMaximum() + scale = gPad.GetUymax() / rightmax + hist_den[lab].Scale(scale) + rightmax_elec = 1.05 * hist_elec[lab].GetMaximum() + scale_elec = gPad.GetUymax() / rightmax_elec + hist_elec[lab].Scale(scale_elec) + i=i+2 + + mg_comb.Draw("ap") + mg_comb.GetYaxis().SetRangeUser(0, 1.05) + rightmax = 1.05 * hist_den[label[0]].GetMaximum() + mg_comb.GetXaxis().SetTitle(xtitle) + mg_comb.GetYaxis().SetTitle("Efficiency") + mg_comb.GetYaxis().SetRangeUser(0, 1.05) + mg_comb.SetTitle(tracker + " " + cut) + for lab in label: + hist_lab[lab].Draw("hist SAME") + hist_elec[lab].Draw("hist SAME") + + canvas_com.PlaceLegend() + latex.DrawLatex(0.7,0.85, "LHCb simultaion") + latex.DrawLatex(0.35,0.3, cutName) + canvas_com.SetRightMargin(0.05) + canvas_com.Write() + # calculate ghost rate if tracker == "Forward": histoBaseName = "Track/" + folder + tracker + "/" @@ -271,28 +327,33 @@ def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): "variable"] + "_Total" print("ghost histo: " + histoBaseName + " " + numeratorName + " " + denominatorName) - numerator = f.Get(numeratorName) - denominator = f.Get(denominatorName) - numerator.Sumw2() - denominator.Sumw2() - - g_efficiency = TGraphAsymmErrors() - g_efficiency.SetName(title + " ref") - g_efficiency.Divide(numerator, denominator, - "cl=0.683 b(1,1) mode") + ghost={} + mg = TMultiGraph() + for i, lab in enumerate(label): + numerator = tf[lab].Get(numeratorName) + denominator = tf[lab].Get(denominatorName) + numerator.Sumw2() + denominator.Sumw2() + + ghost[lab]= TGraphAsymmErrors() + ghost[lab].SetName(lab) + ghost[lab].Divide(numerator, denominator, + "cl=0.683 b(1,1) mode") + set_style(ghost[lab], colors[i], markers[i], styles[i]) + mg.Add(ghost[lab]) xtitle = ghostHistoDict[histo]["xTitle"] - g_efficiency.GetXaxis().SetTitle(xtitle) - g_efficiency.GetYaxis().SetTitle("ghost rate") - g_efficiency.Write() - g_efficiency.Draw("ap") - + mg.GetXaxis().SetTitle(xtitle) + mg.GetYaxis().SetTitle("ghost rate") + mg.Draw("ap") + canvas.PlaceLegend() + if savepdf: + canvas.SaveAs("ghost_rate_"+histo+".pdf") canvas.Write() outputfile.Write() outputfile.Close() - f.Close() - + if __name__ == '__main__': parser = argument_parser() diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 0568d9fb763..0ac5ccb055e 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -22,160 +22,227 @@ import os, sys import argparse import ROOT from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject -from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 -from ROOT import gROOT, gStyle, TStyle, TPaveText, TString +from ROOT import kDashed, kRed, kGreen, kBlue, kCyan, kMagenta, kBlack, kOrange, kAzure, kTRUE, kFALSE, gPad, TH1F, TH2F, TF1 +from ROOT import gDirectory, gROOT, gStyle, TStyle, TPaveText, TString from ROOT import ROOT, vector, TGraphAsymmErrors -from collections import defaultdict +def get_colors(): + return [kBlack, kBlue, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] -#from collectRunResults import send_notification_mattermost +def get_markers(): + return [20, 24, 21, 22, 23, 25 ] +def get_fillstyles(): + return [3004, 3003, 3325, 3144, 3244, 3444] +def get_files(tf, filename, label): + for i, f in enumerate(filename): + tf[label[i]] = TFile(f, "read") + return tf + +def get_trees(tr, tf, label): + for lab in label: + tr[lab]=tf[lab].Get("TrackIPResolutionCheckerNT/tracks") + return tr def argument_parser(): parser = argparse.ArgumentParser(description="location of the tuple file") - parser.add_argument( - '--directory', - type=str, - default=os.getcwd(), - help='location of input tuple files') parser.add_argument( '--filename', - type=str, - default='Hlt1ForwardTracking_IPresolution.root', - help='input tuple files') + nargs='+', + default=[], + help='input tuple files, including path') parser.add_argument( - '--outputfile', - type=str, - default='IPResolution_plots.root', - help='output files for plots') + '--label', + nargs='+', + default=["IPchecker"], + help='label of input files') + parser.add_argument( + '--outfile', + default='IPresolution_plots.root', + help='output file name ') + parser.add_argument( + '--savepdf', + default=False, + action='store_true', + help='save plots in pdf format') parser.add_argument( '--plotstyle', default=os.getcwd(), help='location of LHCb utils plot style file') return parser +def get_resolution(resx, resy, tr, label): -def PrCheckerIPresolution(directory, filename, outputfile, plotstyle): + resIPx={} + resIPy={} + resIPx_1={} + resIPy_1={} + markers = get_markers() + colors = get_colors() + styles = get_fillstyles() + cutAcc = "trueeta<5 && trueeta>2 && typeofprefix==0" + print("Velo track from PV in acceptance: " + cutAcc) + for i, lab in enumerate(label): + ### typeofprefix==0 for track from PV and matched with MC + resIPx[lab] = TH2F("resIPx_"+lab, "IPx:1/pt", 20, 0, 2, 100, -300, 300) + resIPy[lab] = TH2F("resIPy_"+lab, "IPy:1/pt", 20, 0, 2, 100, -300, 300) + resIPx[lab].SetMarkerStyle(1) + resIPy[lab].SetMarkerStyle(1) + varx = "recIPx*1000:1.0/truept" + vary = "recIPy*1000:1.0/truept" + print("IPx var: " + varx +" " + " IPy var: " + vary) + tr[lab].Draw(varx + ">>resIPx_"+lab, cutAcc) + tr[lab].Draw(vary + ">>resIPy_"+lab, cutAcc) + resIPx[lab].FitSlicesY() + resIPy[lab].FitSlicesY() + resx[lab] = gDirectory.Get("resIPx_"+lab+"_2") + resy[lab] = gDirectory.Get("resIPy_"+lab+"_2") + resIPx_1[lab]= gDirectory.Get("resIPx_"+lab+"_1") + resIPy_1[lab]= gDirectory.Get("resIPy_"+lab+"_1") + for i in range(1, 20): + print(lab+": in 1/pT region: (" + format(resIPx_1[lab].GetBinLowEdge(i), '.2f') + + ", " + format( + resIPx_1[lab].GetBinLowEdge(i) + resIPx_1[lab].GetBinWidth(i), '.2f') + + ") [c/GeV]" + " ---- " + "resIPx for mean : " + + format(resIPx_1[lab].GetBinContent(i), '.2f') + "[\mum] width : " + + format(resx[lab].GetBinContent(i), '.2f') + "[\mum] ---- " + + "resIPy for mean : " + format(resIPy_1[lab].GetBinContent(i), '.2f') + + "[\mum] width : " + format(resy[lab].GetBinContent(i), '.2f') + + "[\mum]") + + return resx, resy + +def PrCheckerIPresolution(filename, label, outfile, savepdf, plotstyle): sys.path.append(os.path.abspath(plotstyle)) - from utils.LHCbStyle import setLHCbStyle + from utils.LHCbStyle import setLHCbStyle, set_style setLHCbStyle() - - f = TFile.Open(os.path.join(directory, filename), 'read') - outputfile = TFile(directory + "/" + outputfile, "recreate") - - tuples = f.Get("TrackIPResolutionCheckerNT/tracks") + from utils.Legend import place_legend + latex = TLatex() + latex.SetNDC() + latex.SetTextSize(0.05) + + markers = get_markers() + colors = get_colors() + styles= get_fillstyles() + tf={} + tr={} + tf=get_files(tf, filename, label) + tr=get_trees(tr, tf, label) + + outputfile = TFile(outfile, "recreate") outputfile.cd() - ### typeofprefix==0 for track from PV and matched with MC - cutAcc = "trueeta<5 && trueeta>2 && typeofprefix==0" - print("Velo track from PV in acceptance: " + cutAcc) - resIPx = TH2F("resIPx", "IPx:1/pt", 20, 0, 3, 100, -300, 300) - resIPy = TH2F("resIPy", "IPy:1/pt", 20, 0, 3, 100, -300, 300) - resIPx.SetMarkerStyle(1) - resIPy.SetMarkerStyle(1) - varx = "recIPx*1000:1.0/truept" - vary = "recIPy*1000:1.0/truept" - print("IPx var: " + varx) - print("IPy var: " + vary) - tuples.Draw(varx + ">>resIPx", cutAcc) - tuples.Draw(vary + ">>resIPy", cutAcc) - resIPx.FitSlicesY() - resIPy.FitSlicesY() - hresx_2 = outputfile.Get("resIPx_2") - hresy_2 = outputfile.Get("resIPy_2") + gr_resx={} + gr_resy={} + gr_resx, gr_resy = get_resolution(gr_resx, gr_resy, tr, label) canvas1 = TCanvas("resIPx_pT", "resIPx v.s. 1/pT") - hresx_2.Draw("E1 p1") - hresx_2.GetYaxis().SetTitle("#sigma_{IPx} [#mum]") - hresx_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") - hresx_2.SetTitle("#sigma(IP_{x}):1/p_{T}") - - polx = TF1("polx", "pol1", 0, 3) - polx.SetLineColor(kRed) - print("Fit to Resolution of IPx v.s. 1/pT:") - hresx_2.Fit("polx", "R") - Par0x = format(polx.GetParameter(0), '.2f') - Par1x = format(polx.GetParameter(1), '.2f') - - pt = TPaveText(0.22, 0.65, 0.48, 0.9, "BRNDC") - pt.SetTextSize(0.055) - pt.SetBorderSize(1) - pt.SetFillColor(10) - pt.SetLineWidth(0) - Funcx = Par0x + "+" + Par1x + "/p_{T}" - text = pt.AddText(Funcx) - pt.Draw() + canvas2 = TCanvas("resIPy_pT", "resIPy v.s. 1/pT") + canvas = TCanvas("IPChi2", "IPChi2") + canvas.SetLogy() + + canvas1.cd() + latex.DrawLatex(0.7,0.85, "LHCb simultaion") + + polx={} + Par0x={} + Par1x={} + Funcx={} + gr_resx[label[0]].GetYaxis().SetTitle("#sigma_{IPx} [#mum]") + gr_resx[label[0]].GetXaxis().SetTitle("1/p_{T} [c/GeV]") + gr_resx[label[0]].SetTitle("#sigma(IP_{x}):1/p_{T}") + for idx, lab in enumerate(label): + set_style(gr_resx[lab], colors[idx], markers[idx], 0) + if idx==0: + gr_resx[lab].Draw("E1 p1") + else: + gr_resx[lab].Draw("E1 p1 same") + polx[lab] = TF1("polx_"+lab, "pol1", 0, 3) + polx[lab].SetLineColor(colors[idx]) + print(lab+": Fit to Resolution of IPx v.s. 1/pT:") + gr_resx[lab].Fit("polx_"+lab, "R") + Par0x[lab] = format(polx[lab].GetParameter(0), '.2f') + Par1x[lab] = format(polx[lab].GetParameter(1), '.2f') + Funcx[lab] = lab+": "+ Par0x[lab] + "+" + Par1x[lab] + "/p_{T}" + gr_resx[lab].SetTitle(Funcx[lab]) + #canvas1.PlaceLegend() + place_legend(canvas1, 0.5,0.2, 0.85, 0.45, header="LHCb simulation", option="lep") canvas1.SetRightMargin(0.05) canvas1.Write() - - canvas2 = TCanvas("resIPy_pT", "resIPy v.s. 1/pT") - hresy_2.Draw("E1 p1") - hresy_2.GetYaxis().SetTitle("#sigma_{IPy} [#mum]") - hresy_2.GetXaxis().SetTitle("1/p_{T} [c/GeV]") - hresy_2.SetTitle("#sigma(IP_{y}):1/p_{T}") - poly = TF1("poly", "pol1", 0, 3) - poly.SetLineColor(kRed) - hresy_2.Fit("poly", "R") - Par0y = format(poly.GetParameter(0), '.2f') - Par1y = format(poly.GetParameter(1), '.2f') - - pt = TPaveText(0.22, 0.65, 0.48, 0.9, "BRNDC") - pt.SetTextSize(0.055) - pt.SetBorderSize(1) - pt.SetFillColor(10) - pt.SetLineWidth(0) - Funcy = Par0y + "+" + Par1y + "/p_{T}" - texty = pt.AddText(Funcy) - pt.Draw() + if savepdf: + canvas1.SaveAs("resIPx_pt.pdf") + + canvas2.cd() + latex.DrawLatex(0.7,0.85, "LHCb simultaion") + poly={} + Par0y={} + Par1y={} + Funcy={} + gr_resy[label[0]].GetYaxis().SetTitle("#sigma_{IPy} [#mum]") + gr_resy[label[0]].GetXaxis().SetTitle("1/p_{T} [c/GeV]") + gr_resy[label[0]].SetTitle("#sigma(IP_{y}):1/p_{T}") + for idx, lab in enumerate(label): + set_style(gr_resy[lab], colors[idx], markers[idx], 0) + if idx==0: + gr_resy[lab].Draw("E1 p1") + else: + gr_resy[lab].Draw("E1 p1 same") + poly[lab] = TF1("poly_"+lab, "pol1", 0, 3) + poly[lab].SetLineColor(colors[idx]) + print(lab+": Fit to Resolution of IPy v.s. 1/pT:") + gr_resy[lab].Fit("poly_"+lab, "R") + Par0y[lab] = format(poly[lab].GetParameter(0), '.2f') + Par1y[lab] = format(poly[lab].GetParameter(1), '.2f') + Funcy[lab] = lab+": "+Par0y[lab] + "+" + Par1y[lab] + "/p_{T}" + gr_resy[lab].SetTitle(Funcy[lab]) + #canvas2.PlaceLegend() + place_legend(canvas2, 0.5,0.2, 0.85, 0.45, header="LHCb simulation", option="lep") canvas2.SetRightMargin(0.05) canvas2.Write() - - resIPx_1 = outputfile.Get("resIPx_1") - resIPx_2 = outputfile.Get("resIPx_2") - resIPy_1 = outputfile.Get("resIPy_1") - resIPy_2 = outputfile.Get("resIPy_2") - for i in range(1, 20): - print("in 1/pT region: (" + format(resIPx_1.GetBinLowEdge(i), '.2f') + - ", " + format( - resIPx_1.GetBinLowEdge(i) + resIPx_1.GetBinWidth(i), '.2f') + - ") [c/GeV]" + " -***- " + "resIPx for mean : " + - format(resIPx_1.GetBinContent(i), '.2f') + "[\mum] width : " + - format(resIPx_2.GetBinContent(i), '.2f') + "[\mum] -***- " + - "resIPy for mean : " + format(resIPy_1.GetBinContent(i), '.2f') + - "[\mum] width : " + format(resIPy_2.GetBinContent(i), '.2f') + - "[\mum]") + if savepdf: + canvas2.SaveAs("resIPy_pt.pdf") #### rec IP chi2 distribution - recIPChi2 = TH1F("recIPChi2", "recIPChi2", 100, 0, 200) + recIPChi2={} var = "recIPChi2" - tuples.Draw(var + ">>recIPChi2", cutAcc) - canvas = TCanvas("IPChi2", "IPChi2") - canvas.SetLogy() - recIPChi2.Draw() - recIPChi2.SetXTitle("#chi^{2}_{IP}") - recIPChi2.SetYTitle("N_{tracks}") + cutAcc = "trueeta<5 && trueeta>2 && typeofprefix==0" + for i, lab in enumerate(label): + recIPChi2[lab] = TH1F("recIPChi2_"+lab, lab, 100, 0, 200) + tr[lab].Draw(var + ">>recIPChi2_"+lab, cutAcc) + recIPChi2[lab].SetLineColor(colors[i]) + canvas.cd() + latex.DrawLatex(0.7,0.85, "LHCb simultaion") + recIPChi2[label[0]].Draw() + recIPChi2[label[0]].SetXTitle("#chi^{2}_{IP}") + recIPChi2[label[0]].SetYTitle("N_{tracks}") + for lab in label[1:]: + recIPChi2[lab].Draw("hist same") + + place_legend(canvas, 0.5, 0.5,0.8,0.7, "", "lep") canvas.SetRightMargin(0.05) canvas.Write() + if savepdf: + canvas.SaveAs("recIPchi2.pdf") + + for lab in label: + ### print efficiency of different IPchi2 cut + Numerator = TH1F("Numerator", "Numerator", 100, 0, 200) + Denominator = TH1F("Denominator", "Denominator", 100, 0, 200) + tr[lab].Draw(var + ">>Denominator", cutAcc) + for cut in [100, 25, 16, 9, 4]: + cutChi2 = " && recIPChi2<" + format(cut) + cutNum = cutAcc + cutChi2 + tr[lab].Draw(var + ">>Numerator", cutNum) + if Numerator.GetEntries() == 0 or Denominator.GetEntries() == 0: + continue + Eff = Numerator.GetEntries() / (Denominator.GetEntries() + 0.0) + print(lab+ ": Efficiency of IPchi2<" + format(cut) + " : " + + format(Eff, '.2%')) - ### print efficiency of different IPchi2 cut - Numerator = TH1F("Numerator", "Numerator", 100, 0, 200) - Denominator = TH1F("Denominator", "Denominator", 100, 0, 200) - tuples.Draw(var + ">>Denominator", cutAcc, "same") - for cut in [100, 25, 16, 9, 4]: - cutChi2 = " && recIPChi2<" + format(cut) - cutNum = cutAcc + cutChi2 - tuples.Draw(var + ">>Numerator", cutNum) - if Numerator.GetEntries() == 0 or Denominator.GetEntries() == 0: - continue - Eff = Numerator.GetEntries() / (Denominator.GetEntries() + 0.0) - print("Efficiency of IPchi2<" + format(cut) + " : " + - format(Eff, '.2%')) outputfile.Write() outputfile.Close() - f.Close() - if __name__ == '__main__': parser = argument_parser() diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index 211819d69c8..102ca195bd5 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -27,7 +27,7 @@ import os, sys import argparse import ROOT from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject -from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TPad +from ROOT import kDashed, kGray, kOrange, kMagenta, kRed, kGreen, kCyan, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TPad from ROOT import gROOT, gStyle, TStyle, TPaveText, TH1F from ROOT import ROOT, TH1D, TH1F, TGraphAsymmErrors import logging @@ -37,7 +37,6 @@ import subprocess def getEfficiencyHistoNames(): return ["eta", "p", "pt", "phi", "nPV"] - def getOriginFolders(): basedict = {"Forward": {}, "MuonMatch": {}} basedict["Forward"]["folder"] = "ForwardTrackChecker/" @@ -45,45 +44,124 @@ def getOriginFolders(): return basedict +def get_colors(): + return [kBlack, kAzure, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] -def getGhostHistoNames(): - return ["eta", "nPV", "pt", "p", "phi"] +def get_markers(): + return [20, 24, 21, 22, 23, 25 ] +def get_fillstyles(): + return [3004, 3003, 3325, 3144, 3244, 3444] def argument_parser(): parser = argparse.ArgumentParser(description="location of the tuple file") - parser.add_argument( - '--directory', - type=str, - default=os.getcwd(), - help='location of input tuple files') parser.add_argument( '--filename', type=str, - default='PrChecker_MuonID_MiniBias.root', - help='input file') + default='MCMatching_MiniBias.root', + nargs='+', + help='input files, including path') parser.add_argument( - '--outputfile', + '--outfile', type=str, - default='muonIDeff_plots.root', + default='MuonIDefficiency_plots.root', help='output file') + parser.add_argument( + '--label', + nargs='+', + default="EffChecker", + help='label for files') parser.add_argument( '--plotstyle', default=os.getcwd(), help='location of LHCb utils plot style file') + parser.add_argument( + '--savepdf', + default=False, + action='store_true', + help='save plots in pdf format') + parser.add_argument( + '--printval', + default=False, + action='store_true', + help='print out the muon ID efficiency in momentum bins ') return parser -def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): +def get_files(tf, filename, label): + for i, f in enumerate(filename): + tf[label[i]] = TFile(f, "read") + return tf + +def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): + eff = {} + hist = {} + for i, lab in enumerate(label): + numeratorName = histoName + "_reconstructed" + numerator = tf[lab].Get(numeratorName) + denominatorName = histoName_Den + "_reconstructed" + denominator = tf[lab].Get(denominatorName) + if numerator.GetEntries() == 0 or denominator.GetEntries() == 0: + continue + numerator.Sumw2() + denominator.Sumw2() + + eff[lab] = TGraphAsymmErrors() + eff[lab].SetName(lab) + eff[lab].Divide(numerator, denominator, "cl=0.683 b(1,1) mode") + eff[lab].SetTitle(lab+"not elec.") + if (histoName.find('strange') != -1): + eff[lab].SetTitle(lab+" from stranges") + if (histoName.find('electron') != -1): + eff[lab].SetTitle(lab+" electron") + + hist[lab]= denominator.Clone() + hist[lab].SetName("h_numerator_notElectrons") + hist[lab].SetTitle(var +" histo. not elec.") + if (histoName.find('strange') != -1): + hist[lab].SetTitle(var +" histo. stranges") + if (histoName.find('electron') != -1): + hist[lab].SetTitle(var +" histo. electron") + + if var== "p": + eff[lab].GetXaxis().SetRangeUser(0, 50000) + hist[lab].GetXaxis().SetRangeUser(0, 50000) + #print the muonID efficiency in each p bin + if var== "p" and printval: + for i in range(1, numerator.GetNbinsX()): + if denominator.GetBinContent(i) == 0: + continue + Eff = numerator.GetBinContent(i) / ( + denominator.GetBinContent(i) + 0.0) + print(lab+": Efficiency of muon ID in (" + + format(numerator.GetBinLowEdge(i), '.2f') + + ", " + format( + numerator.GetBinLowEdge(i) + + numerator.GetBinWidth(i), '.2f') + + ") [GeV/c] : " + format(Eff, '.2%')) + + + if var== "pt": + eff[lab].GetXaxis().SetRangeUser(0, 5000) + hist[lab].GetXaxis().SetRangeUser(0, 5000) + + return eff, hist + + +def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): sys.path.append(os.path.abspath(plotstyle)) - from utils.LHCbStyle import setLHCbStyle - from utils.ConfigHistos import (efficiencyHistoDict, ghostHistoDict, - categoriesDict, getCuts) + from utils.LHCbStyle import setLHCbStyle, set_style + from utils.ConfigHistos import (efficiencyHistoDict, categoriesDict, getCuts) from utils.Legend import place_legend setLHCbStyle() - f_CPU = TFile(directory + "/" + filename, "read") - outputfile = TFile(directory + "/" + outputfile, "recreate") + markers = get_markers() + colors = get_colors() + styles= get_fillstyles() + + tf={} + tf=get_files(tf, filename, label) + outputfile = TFile(outfile, "recreate") latex = TLatex() latex.SetNDC() @@ -91,8 +169,6 @@ def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): efficiencyHistoDict = efficiencyHistoDict() efficiencyHistos = getEfficiencyHistoNames() - ghostHistos = getGhostHistoNames() - ghostHistoDict = ghostHistoDict() categories = categoriesDict() cuts = getCuts() folders = getOriginFolders() @@ -112,102 +188,55 @@ def PrCheckerEfficiency(directory, filename, outputfile, plotstyle): # calculate efficiency for histo in efficiencyHistos: - title = "efficiency vs. " + histo + ", " + categories[tracker][ - cut]["title"] - name = "efficiency_" + histo - canvas = TCanvas(name, title) - + canvastitle = "efficiency vs. " + histo + ", " + categories[tracker][cut]["title"] + name = "efficiency_" + histo+"_"+cut # get efficiency for not electrons category histoName = histoBaseName + "" + efficiencyHistoDict[histo][ "variable"] histoName_den = histoBaseName_den + "" + efficiencyHistoDict[ histo]["variable"] print("not electrons: " + histoName) - numeratorName = histoName + "_reconstructed" - numerator_CPU = TH1D() - numerator_CPU = f_CPU.Get(numeratorName) - denominatorName = histoName_den + "_reconstructed" - denominator_CPU = TH1D() - denominator_CPU = f_CPU.Get(denominatorName) - if numerator_CPU.GetEntries() == 0 or denominator_CPU.GetEntries( - ) == 0: - continue - - numerator_CPU.Sumw2() - denominator_CPU.Sumw2() - - g_efficiency_CPU = TGraphAsymmErrors() - g_efficiency_CPU.SetName("g_efficiency_notElectrons") - g_efficiency_CPU.Divide(numerator_CPU, denominator_CPU, - "cl=0.683 b(1,1) mode") - g_efficiency_CPU.SetTitle("Baseline") - if (histoName.find('strange') != -1): - g_efficiency_CPU.SetTitle("Baseline, from stranges") - g_efficiency_CPU.SetMarkerStyle(20) - - h_denominator_CPU = denominator_CPU.Clone() - h_denominator_CPU.SetName("h_denominator_notElectrons") - h_denominator_CPU.SetTitle(efficiencyHistoDict[histo]["variable"] + - " histo. forward reconstructed") - if (histoName.find('strange') != -1): - h_denominator_CPU.SetTitle( - efficiencyHistoDict[histo]["variable"] + - " histo. strange, forward reconstructed") - - #draw them both if there is ref + eff={} + hist_den={} + eff, hist_den = get_eff( eff, hist_den, tf, histoName, histoName_den, label, histo, printval) + + canvas = TCanvas(name, canvastitle) mg = TMultiGraph() - mg.Add(g_efficiency_CPU) - mg.Draw("ap") + for i, lab in enumerate(label): + mg.Add(eff[lab]) + set_style(eff[lab], colors[i], markers[i], styles[i]) + mg.Draw("AP") + mg.GetYaxis().SetRangeUser(0, 1.05) xtitle = efficiencyHistoDict[histo]["xTitle"] mg.GetXaxis().SetTitle(xtitle) - mg.GetYaxis().SetTitle("Efficiency") - mg.GetYaxis().SetRangeUser(0, 1.05) - - mg.SetName("efficiency vs. " + histo) - mg.SetTitle(tracker + " " + cut) - - if histo == "p": - mg.GetXaxis().SetRangeUser(0, 50000) - if histo == "pt": - mg.GetXaxis().SetRangeUser(0, 5000) - if histo == "eta": - mg.GetXaxis().SetRangeUser(2, 5) - scale_cpu = 1.0 / h_denominator_CPU.GetMaximum() - h_denominator_CPU.Scale(scale_cpu) - h_denominator_CPU.SetFillStyle(3004) - h_denominator_CPU.SetFillColor(kBlue - 10) - h_denominator_CPU.SetLineColor(kBlue - 10) - h_denominator_CPU.SetLineWidth(2) - h_denominator_CPU.Draw("hist same") + mg.GetYaxis().SetTitle("Muon ID Efficiency") + for i, lab in enumerate(label): + rightmax = 1.05 * hist_den[lab].GetMaximum() + scale = gPad.GetUymax() / rightmax + hist_den[lab].Scale(scale) + if i==0: + set_style(hist_den[lab], kGray, markers[i], styles[i]) + else: + set_style(hist_den[lab], colors[i]-10, markers[i], styles[i]) + hist_den[lab].Draw("hist SAME") canvas.PlaceLegend() cutName = categories[tracker][cut]["title"] latex.DrawLatex(0.35, 0.3, cutName) - latex.DrawLatex(0.35, 0.4, "LHCb simulation") + latex.DrawLatex(0.7, 0.85, "LHCb simulation") canvas.SetRightMargin(0.05) canvas.Write() - - #print the muonID efficiency in each p bin - if histo == "p": - for i in range(1, numerator_CPU.GetNbinsX()): - if denominator_CPU.GetBinContent(i) == 0: - continue - Eff = numerator_CPU.GetBinContent(i) / ( - denominator_CPU.GetBinContent(i) + 0.0) - print("Efficiency of muon ID in (" + - format(numerator_CPU.GetBinLowEdge(i), '.2f') + - ", " + format( - numerator_CPU.GetBinLowEdge(i) + - numerator_CPU.GetBinWidth(i), '.2f') + - ") [GeV/c] : " + format(Eff, '.2%')) + canvasName="MuonIDEff_"+cut+"_"+histo+".pdf" + if savepdf: + canvas.SaveAs(canvasName) + canvas.SetRightMargin(0.05) + canvas.Write() outputfile.Write() outputfile.Close() - f_CPU.Close() - if __name__ == '__main__': parser = argument_parser() args = parser.parse_args() - PrCheckerEfficiency(**vars(args)) + PrCheckerMuonIDEff(**vars(args)) diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index d6461913390..816c725a77c 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -19,34 +19,49 @@ import os, sys import argparse import ROOT -from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject -from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1, TH2, TF1 -from ROOT import gROOT, gStyle, TStyle, TPaveText, TString +from ROOT import TMultiGraph, TMath, TAxis, TH2F, TH2, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject +from ROOT import kDashed, kOrange, kGray, kMagenta, kCyan, kRed, kGreen, kBlue, kBlack, kAzure, kTRUE, kFALSE, gPad, TH1, TH2, TF1 +from ROOT import gROOT, gDirectory, gStyle, TStyle, TPaveText, TString from ROOT import ROOT, vector, TGraphAsymmErrors from collections import defaultdict -#from collectRunResults import send_notification_mattermost +def get_colors(): + return [kBlack, kBlue, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] +def get_markers(): + return [20, 24, 21, 22, 23, 25 ] +def get_fillstyles(): + return [3004, 3003, 3325, 3144, 3244, 3444] + +def get_files(tf, filename, label): + for i, f in enumerate(filename): + tf[label[i]] = TFile(f, "read") + return tf def argument_parser(): parser = argparse.ArgumentParser( description="location of the histogram file") - parser.add_argument( - '--directory', - type=str, - default=os.getcwd(), - help='location of input tuple files') parser.add_argument( '--filename', - type=str, - default='Hlt1ForwardTrackingResolution.root', + nargs='+', + default=[], + help='name of input files') + parser.add_argument( + '--label', + nargs='+', + default=["TrackRes"], help='name of input tuple files') parser.add_argument( - '--outputfile', + '--outfile', type=str, default='TrackResolution_plots.root', - help='name of input tuple files') + help='name of output files') + parser.add_argument( + '--savepdf', + default=False, + action='store_true', + help='save plots in pdf format') parser.add_argument( '--plotstyle', default=os.getcwd(), @@ -54,92 +69,114 @@ def argument_parser(): return parser -def PrCheckerTrackResolution(directory, filename, outputfile, plotstyle): +def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): sys.path.append(os.path.abspath(plotstyle)) - from utils.LHCbStyle import setLHCbStyle + from utils.LHCbStyle import setLHCbStyle, set_style from utils.Legend import place_legend setLHCbStyle() - f = TFile.Open(os.path.join(directory, filename), 'read') - outputfile = TFile(outputfile, "recreate") + markers = get_markers() + colors = get_colors() + styles= get_fillstyles() + tf={} + tf=get_files(tf, filename, label) + outputfile = TFile(outfile, "recreate") outputfile.cd() - hres_p = f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") - hres_eta = f.Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") - - hres_p.Write() - hres_eta.Write() - hres_p.FitSlicesY() - hres_eta.FitSlicesY() - - hres_p_2 = outputfile.Get("dpoverp_vs_p_2") - hres_eta_2 = outputfile.Get("dpoverp_vs_eta_2") - + hdp_p={} + hdp_eta={} + hres_p={} + hres_eta={} + hmom={} + heta={} canvas1 = TCanvas("res_p", "res v.s. p") canvas1.cd() - for i in range(1, hres_p_2.GetNbinsX()): - hres_p_2.SetBinContent(i, hres_p_2.GetBinContent(i) * 100) - - hres_p_2.Draw("E1 p1") - hres_p_2.SetTitle("dp/p:p") - hres_p_2.GetYaxis().SetTitle("dp/p [%]") - hres_p_2.GetXaxis().SetTitle("p [GeV/c]") - hres_p_2.GetYaxis().SetRangeUser(0, 1.2) - hmom = hres_p.ProjectionX() - hmom.SetTitle("p histo.") - hmom.Scale(0.3 / hres_p.GetMaximum()) - hmom.Draw("hist same") - hmom.SetFillStyle(3004) - hmom.SetLineColor(kBlue - 10) - hmom.SetFillColor(kBlue) - hmom.SetLineWidth(2) + for idx, lab in enumerate(label): + hdp_p[lab] = tf[lab].Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") + hdp_p[lab].SetName("dpoverp_p_"+lab) + hmom[lab] = hdp_p[lab].ProjectionX() + hmom[lab].SetTitle("p histo. "+lab) + hdp_p[lab].FitSlicesY() + + hres_p[lab] = gDirectory.Get("dpoverp_p_"+lab+"_2") + hres_p[lab].GetYaxis().SetTitle("dp/p [%]") + hres_p[lab].GetXaxis().SetTitle("p [GeV/c]") + hres_p[lab].GetYaxis().SetRangeUser(0, 1.2) + hres_p[lab].SetTitle("Res. "+lab) + set_style(hres_p[lab], colors[idx], markers[idx], 0) + + if idx==0: + hres_p[lab].Draw("E1 p1") + set_style(hmom[lab], kGray, markers[idx], styles[idx]) + else: + hres_p[lab].Draw("E1 p1 same") + set_style(hmom[lab], colors[idx]-10, markers[idx], styles[idx]) + hmom[lab].Scale(gPad.GetUymax()/hmom[lab].GetMaximum()) + hmom[lab].Draw("hist same") + + for i in range(1, hres_p[lab].GetNbinsX()): + hres_p[lab].SetBinContent(i, hres_p[lab].GetBinContent(i) * 100) + + print(lab+": Track resolution (dp/p) in p region: (" + + format(hres_p[lab].GetBinLowEdge(i), '.2f') + ", " + format( + hres_p[lab].GetBinLowEdge(i) + hres_p[lab].GetBinWidth(i), '.2f') + + ") [GeV/c]" + " --- " + + format(hres_p[lab].GetBinContent(i), '.2f') + "%") + print("-----------------------------------------------------") canvas1.PlaceLegend() canvas1.SetRightMargin(0.05) canvas1.Write() + if savepdf: + canvas1.SaveAs("trackres_p.pdf") + + print("=====================================================") canvas2 = TCanvas("res_eta", "res v.s. eta") canvas2.cd() - for i in range(1, hres_eta_2.GetNbinsX()): - hres_eta_2.SetBinContent(i, hres_eta_2.GetBinContent(i) * 100) - - hres_eta_2.Draw("E1 p1") - hres_eta_2.SetTitle("dp/p:#eta") - hres_eta_2.GetYaxis().SetTitle("dp/p [%]") - hres_eta_2.GetXaxis().SetTitle("#eta") - hres_eta_2.GetYaxis().SetRangeUser(0, 1.2) - heta = hres_eta.ProjectionX() - heta.SetTitle("#eta histo.") - heta.Scale(0.1 / hres_eta.GetMaximum()) - heta.Draw("hist same") - heta.SetFillStyle(3004) - heta.SetLineColor(kBlue - 10) - heta.SetFillColor(kBlue) - heta.SetLineWidth(2) + + for idx, lab in enumerate(label): + hdp_eta[lab] = tf[lab].Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") + hdp_eta[lab].SetName("dpoverp_eta_"+lab) + hdp_eta[lab].FitSlicesY() + heta[lab] = hdp_eta[lab].ProjectionX() + heta[lab].SetTitle("#eta histo. "+lab) + + hres_eta[lab]= gDirectory.Get("dpoverp_eta_"+lab+"_2") + hres_eta[lab].GetYaxis().SetTitle("dp/p [%]") + hres_eta[lab].GetXaxis().SetTitle("#eta") + hres_eta[lab].GetYaxis().SetRangeUser(0, 1.2) + hres_eta[lab].SetTitle("Res. "+lab) + set_style(hres_eta[lab], colors[idx], markers[idx], 0) + + if idx==0: + hres_eta[lab].Draw("E1 p1") + set_style(heta[lab], kGray, markers[idx], styles[idx]) + else: + hres_eta[lab].Draw("E1 p1 same") + set_style(heta[lab], colors[idx]-10, markers[idx], styles[idx]) + + heta[lab].Scale(gPad.GetUymax()/heta[lab].GetMaximum()) + heta[lab].Draw("hist same") + + for i in range(1, hres_eta[lab].GetNbinsX()): + hres_eta[lab].SetBinContent(i, hres_eta[lab].GetBinContent(i) * 100) + + print(lab+": Track resolution (dp/p) in eta region: (" + + format(hres_eta[lab].GetBinLowEdge(i), '.2f') + ", " + format( + hres_eta[lab].GetBinLowEdge(i) + + hres_eta[lab].GetBinWidth(i), '.2f') + ")" + " --- " + + format(hres_eta[lab].GetBinContent(i), '.2f') + "%") canvas2.PlaceLegend() canvas2.SetRightMargin(0.05) canvas2.Write() - - for i in range(1, hres_p_2.GetNbinsX()): - print("Track resolution (dp/p) in p region: (" + - format(hres_p_2.GetBinLowEdge(i), '.2f') + ", " + format( - hres_p_2.GetBinLowEdge(i) + hres_p_2.GetBinWidth(i), '.2f') + - ") [GeV/c]" + " --- " + - format(hres_p_2.GetBinContent(i), '.2f') + "%") - - print("-----------------------------------") - for i in range(1, hres_eta_2.GetNbinsX()): - print("Track resolution (dp/p) in eta region: (" + - format(hres_eta_2.GetBinLowEdge(i), '.2f') + ", " + format( - hres_eta_2.GetBinLowEdge(i) + - hres_eta_2.GetBinWidth(i), '.2f') + ")" + " --- " + - format(hres_eta_2.GetBinContent(i), '.2f') + "%") + if savepdf: + canvas2.SaveAs("trackres_eta.pdf") outputfile.Write() outputfile.Close() - f.Close() if __name__ == '__main__': diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index a6d3c4c4efc..7b3ec759297 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -87,8 +87,8 @@ def getCuts(): ] basedict["MuonMatch"] = [ "02_long_muon_P>3GeV_Pt>0.5GeV", "04_long_pion_P>3GeV_Pt>0.5GeV", - "03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", "01_long", - "02_long_muon", "03_long_muon_from_strange", "04_long_pion" + "03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", + "01_long", "02_long_muon", "03_long_muon_from_strange", "04_long_pion" ] return basedict @@ -103,9 +103,9 @@ def categoriesDict(): "title"] = "Long, #mu, forward track, 2 <#eta< 5" basedict["MuonMatch"]["02_long_muon_P>3GeV_Pt>0.5GeV"][ "title"] = "Long, #mu, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" - basedict["MuonMatch"]["03_long_from_strange"][ + basedict["MuonMatch"]["03_long_muoon_from_strange"][ "title"] = "Long, #mu from strange, forward track, 2 <#eta< 5" - basedict["MuonMatch"]["03_long_from_strange_P>3GeV_Pt>0.5GeV"][ + basedict["MuonMatch"]["03_long_muon_from_strange_P>3GeV_Pt>0.5GeV"][ "title"] = "Long, #mu from strange, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" basedict["MuonMatch"]["04_long_pion"][ "title"] = "Long, #pi, forward track, 2 <#eta< 5" diff --git a/Hlt/RecoConf/scripts/utils/LHCbStyle.py b/Hlt/RecoConf/scripts/utils/LHCbStyle.py index 88799a336e2..1056556c8e5 100644 --- a/Hlt/RecoConf/scripts/utils/LHCbStyle.py +++ b/Hlt/RecoConf/scripts/utils/LHCbStyle.py @@ -10,9 +10,31 @@ ############################################################################### from ROOT import gStyle -from ROOT import gROOT +from ROOT import gROOT, TH1, TH1F, TH1D from ROOT import TStyle +def set_style(graph, color, marker, style): + graph.SetLineColor(color) + graph.SetMarkerColor(color) + graph.SetMarkerSize(1.0) + graph.SetMarkerStyle(marker) + graph.GetYaxis().SetTitleOffset(0.85) + if type(graph) == TH1F or type(graph) == TH1 or type(graph) == TH1D: + graph.SetFillColor(color) + graph.SetFillStyle(style) + graph.SetLineWidth(2) + graph.SetStats(False) + graph.GetYaxis().SetTitleOffset(1.0) + graph.GetYaxis().SetTitleSize(0.06) + graph.GetYaxis().SetLabelSize(0.06) + graph.GetXaxis().SetTitleSize(0.06) + graph.GetXaxis().SetLabelSize(0.06) + graph.GetXaxis().SetTitleFont(132) + graph.GetXaxis().SetLabelFont(132) + graph.GetYaxis().SetTitleFont(132) + graph.GetYaxis().SetLabelFont(132) + + return graph def setLHCbStyle(): global lhcbStyle @@ -83,7 +105,7 @@ def setLHCbStyle(): lhcbStyle.SetOptFit(0) #lhcbStyle.SetOptFit(1011) # order is probability, Chi2, errors, parameters #titles - lhcbStyle.SetTitleOffset(0.85, "X") + lhcbStyle.SetTitleOffset(0.95, "X") lhcbStyle.SetTitleOffset(0.85, "Y") lhcbStyle.SetTitleOffset(1.2, "Z") lhcbStyle.SetTitleFillColor(0) -- GitLab From 52704e6be75d5bfc01755ec54e45ad7d7a1176fb Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Mon, 2 Mar 2020 23:08:07 +0000 Subject: [PATCH 105/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7416971 --- .../scripts/PrCheckerEfficiency_HLT1.py | 139 +++++++++-------- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 140 ++++++++++-------- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 73 ++++----- .../scripts/PrCheckerTrackResolution.py | 81 +++++----- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 4 +- Hlt/RecoConf/scripts/utils/LHCbStyle.py | 2 + 6 files changed, 247 insertions(+), 192 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 70efeca341a..dec2ea13794 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -36,9 +36,11 @@ import subprocess def getEfficiencyHistoNames(): return ["eta", "p", "pt", "phi", "nPV"] + def getTrackers(): return ["Velo", "Upstream", "Forward"] + def getOriginFolders(): basedict = {"Velo": {}, "Upstream": {}, "Forward": {}} @@ -48,17 +50,23 @@ def getOriginFolders(): return basedict + def get_colors(): return [kBlack, kAzure, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] + def get_markers(): - return [20, 24, 21, 22, 23, 25 ] + return [20, 24, 21, 22, 23, 25] + + def get_fillstyles(): return [3004, 3003, 3325, 3144, 3244, 3444] + def getGhostHistoNames(): return ["eta", "nPV", "pt", "p"] + def argument_parser(): parser = argparse.ArgumentParser(description="location of the tuple file") parser.add_argument( @@ -73,10 +81,7 @@ def argument_parser(): default='efficiency_plots.root', help='output file') parser.add_argument( - '--label', - nargs='+', - default="EffChecker", - help='label for files') + '--label', nargs='+', default="EffChecker", help='label for files') parser.add_argument( '--plotstyle', default=os.getcwd(), @@ -98,11 +103,13 @@ def argument_parser(): help='save plots in pdf format') return parser + def get_files(tf, filename, label): for i, f in enumerate(filename): tf[label[i]] = TFile(f, "read") return tf + def get_eff(eff, hist, tf, histoName, label, var): eff = {} hist = {} @@ -119,30 +126,32 @@ def get_eff(eff, hist, tf, histoName, label, var): eff[lab] = TGraphAsymmErrors() eff[lab].SetName(lab) eff[lab].Divide(numerator, denominator, "cl=0.683 b(1,1) mode") - eff[lab].SetTitle(lab+"not elec.") + eff[lab].SetTitle(lab + "not elec.") if (histoName.find('strange') != -1): - eff[lab].SetTitle(lab+" from stranges") + eff[lab].SetTitle(lab + " from stranges") if (histoName.find('electron') != -1): - eff[lab].SetTitle(lab+" electron") + eff[lab].SetTitle(lab + " electron") - hist[lab]= denominator.Clone() + hist[lab] = denominator.Clone() hist[lab].SetName("h_numerator_notElectrons") - hist[lab].SetTitle(var +" histo. not elec.") + hist[lab].SetTitle(var + " histo. not elec.") if (histoName.find('strange') != -1): - hist[lab].SetTitle(var +" histo. stranges") + hist[lab].SetTitle(var + " histo. stranges") if (histoName.find('electron') != -1): - hist[lab].SetTitle(var +" histo. electron") + hist[lab].SetTitle(var + " histo. electron") - if var== "p": + if var == "p": eff[lab].GetXaxis().SetRangeUser(0, 50000) hist[lab].GetXaxis().SetRangeUser(0, 50000) - if var== "pt": + if var == "pt": eff[lab].GetXaxis().SetRangeUser(0, 5000) hist[lab].GetXaxis().SetRangeUser(0, 5000) return eff, hist -def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, savepdf): + +def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, + savepdf): sys.path.append(os.path.abspath(plotstyle)) from utils.LHCbStyle import setLHCbStyle, set_style from utils.ConfigHistos import (efficiencyHistoDict, ghostHistoDict, @@ -152,10 +161,10 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, sav markers = get_markers() colors = get_colors() - styles= get_fillstyles() - tf={} + styles = get_fillstyles() + tf = {} - tf=get_files(tf, filename, label) + tf = get_files(tf, filename, label) outputfile = TFile(outfile, "recreate") latex = TLatex() @@ -185,15 +194,16 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, sav # calculate efficiency for histo in efficiencyHistos: - canvastitle = "efficiency_" + histo + ", " + categories[tracker][ - cut]["title"] + canvastitle = "efficiency_" + histo + ", " + categories[ + tracker][cut]["title"] # get efficiency for not electrons category histoName = histoBaseName + "" + efficiencyHistoDict[histo][ "variable"] print("not electrons: " + histoName) - eff={} - hist_den={} - eff, hist_den = get_eff( eff, hist_den, tf, histoName, label, histo) + eff = {} + hist_den = {} + eff, hist_den = get_eff(eff, hist_den, tf, histoName, label, + histo) name = "efficiency_" + histo canvas = TCanvas(name, canvastitle) mg = TMultiGraph() @@ -210,24 +220,27 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, sav rightmax = 1.05 * hist_den[lab].GetMaximum() scale = gPad.GetUymax() / rightmax hist_den[lab].Scale(scale) - if i==0: - set_style(hist_den[lab], kGray, markers[i], styles[i]) + if i == 0: + set_style(hist_den[lab], kGray, markers[i], + styles[i]) else: - set_style(hist_den[lab], colors[i]-10, markers[i], styles[i]) + set_style(hist_den[lab], colors[i] - 10, + markers[i], styles[i]) hist_den[lab].Draw("hist SAME") else: rightmax = 0.95 * hist_den[label[0]].GetMaximum() scale = gPad.GetUymax() / rightmax - set_style(hist_den[label[0]], kBlue-10, markers[i], styles[i]) + set_style(hist_den[label[0]], kBlue - 10, markers[i], + styles[i]) hist_den[label[0]].Scale(scale) hist_den[label[0]].Draw("hist SAME") canvas.PlaceLegend() cutName = categories[tracker][cut]["title"] - latex.DrawLatex(0.7,0.85, "LHCb simultaion") - latex.DrawLatex(0.35,0.3, cutName) - canvasName=tracker+"_"+cut+"_"+histo+".pdf" - if savepdf: + latex.DrawLatex(0.7, 0.85, "LHCb simultaion") + latex.DrawLatex(0.35, 0.3, cutName) + canvasName = tracker + "_" + cut + "_" + histo + ".pdf" + if savepdf: canvas.SaveAs(canvasName) canvas.SetRightMargin(0.05) canvas.Write() @@ -239,17 +252,21 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, sav histoName = histoNameElec + "_" + efficiencyHistoDict[ histo]["variable"] print("electrons: " + histoName) - eff_elec={} - hist_elec={} - eff_elec, hist_elec=get_eff(eff_elec, hist_elec, tf, histoName, label, histo) - - #draw efficiency of electron - canvas_elec=TCanvas(name+"_elec", canvastitle+"_elec") + eff_elec = {} + hist_elec = {} + eff_elec, hist_elec = get_eff(eff_elec, hist_elec, tf, + histoName, label, histo) + + #draw efficiency of electron + canvas_elec = TCanvas(name + "_elec", + canvastitle + "_elec") mg_elec = TMultiGraph() for i, lab in enumerate(label): mg_elec.Add(eff_elec[lab]) - set_style(eff_elec[lab], colors[i], markers[i], styles[i]) - set_style(hist_elec[lab], colors[i]-10, markers[i], styles[i]) + set_style(eff_elec[lab], colors[i], markers[i], + styles[i]) + set_style(hist_elec[lab], colors[i] - 10, markers[i], + styles[i]) mg_elec.Draw("AP") mg_elec.GetYaxis().SetRangeUser(0, 1.05) mg_elec.GetXaxis().SetTitle(xtitle) @@ -265,12 +282,13 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, sav scale = gPad.GetUymax() / rightmax hist_elec[label[0]].Scale(scale) hist_elec[label[0]].Draw("hist SAME") - set_style(hist_elec[label[0]], kBlue-10, markers[i], styles[i]) + set_style(hist_elec[label[0]], kBlue - 10, markers[i], + styles[i]) canvas_elec.PlaceLegend() - latex.DrawLatex(0.7,0.85, "LHCb simultaion") - latex.DrawLatex(0.35,0.3, cutName) - canvasName_elec=tracker+"_"+cut+"_"+histo+"_elec.pdf" + latex.DrawLatex(0.7, 0.85, "LHCb simultaion") + latex.DrawLatex(0.35, 0.3, cutName) + canvasName_elec = tracker + "_" + cut + "_" + histo + "_elec.pdf" if savepdf: canvas_elec.SaveAs(canvasName_elec) canvas_elec.SetRightMargin(0.05) @@ -278,23 +296,28 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, sav #draw them both if plotelec: - canvas_com=TCanvas(name+"_combine", title+"_combine") - i=0 + canvas_com = TCanvas(name + "_combine", + title + "_combine") + i = 0 mg_comb = TMultiGraph() for lab in label: mg_comb.Add(eff[lab]) mg_comb.Add(eff_elec[lab]) - set_style(eff[lab], colors[i], markers[i], styles[i]) - set_style(eff_elec[lab], colors[i+1], markers[i+1], styles[i]) - set_style(hist_den[lab], colors[i]-10, markers[i], styles[i]) - set_style(hist_elec[lab], colors[i+1]-10, markers[i+1], styles[i]) + set_style(eff[lab], colors[i], markers[i], + styles[i]) + set_style(eff_elec[lab], colors[i + 1], + markers[i + 1], styles[i]) + set_style(hist_den[lab], colors[i] - 10, + markers[i], styles[i]) + set_style(hist_elec[lab], colors[i + 1] - 10, + markers[i + 1], styles[i]) rightmax = 1.05 * hist_den[lab].GetMaximum() scale = gPad.GetUymax() / rightmax hist_den[lab].Scale(scale) rightmax_elec = 1.05 * hist_elec[lab].GetMaximum() scale_elec = gPad.GetUymax() / rightmax_elec hist_elec[lab].Scale(scale_elec) - i=i+2 + i = i + 2 mg_comb.Draw("ap") mg_comb.GetYaxis().SetRangeUser(0, 1.05) @@ -308,8 +331,8 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, sav hist_elec[lab].Draw("hist SAME") canvas_com.PlaceLegend() - latex.DrawLatex(0.7,0.85, "LHCb simultaion") - latex.DrawLatex(0.35,0.3, cutName) + latex.DrawLatex(0.7, 0.85, "LHCb simultaion") + latex.DrawLatex(0.35, 0.3, cutName) canvas_com.SetRightMargin(0.05) canvas_com.Write() @@ -327,18 +350,18 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, sav "variable"] + "_Total" print("ghost histo: " + histoBaseName + " " + numeratorName + " " + denominatorName) - ghost={} + ghost = {} mg = TMultiGraph() for i, lab in enumerate(label): numerator = tf[lab].Get(numeratorName) denominator = tf[lab].Get(denominatorName) numerator.Sumw2() denominator.Sumw2() - - ghost[lab]= TGraphAsymmErrors() + + ghost[lab] = TGraphAsymmErrors() ghost[lab].SetName(lab) ghost[lab].Divide(numerator, denominator, - "cl=0.683 b(1,1) mode") + "cl=0.683 b(1,1) mode") set_style(ghost[lab], colors[i], markers[i], styles[i]) mg.Add(ghost[lab]) @@ -348,12 +371,12 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, sav mg.Draw("ap") canvas.PlaceLegend() if savepdf: - canvas.SaveAs("ghost_rate_"+histo+".pdf") + canvas.SaveAs("ghost_rate_" + histo + ".pdf") canvas.Write() outputfile.Write() outputfile.Close() - + if __name__ == '__main__': parser = argument_parser() diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 0ac5ccb055e..427358cb3f0 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -26,24 +26,31 @@ from ROOT import kDashed, kRed, kGreen, kBlue, kCyan, kMagenta, kBlack, kOrange, from ROOT import gDirectory, gROOT, gStyle, TStyle, TPaveText, TString from ROOT import ROOT, vector, TGraphAsymmErrors + def get_colors(): return [kBlack, kBlue, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] + def get_markers(): - return [20, 24, 21, 22, 23, 25 ] + return [20, 24, 21, 22, 23, 25] + + def get_fillstyles(): return [3004, 3003, 3325, 3144, 3244, 3444] + def get_files(tf, filename, label): for i, f in enumerate(filename): tf[label[i]] = TFile(f, "read") return tf + def get_trees(tr, tf, label): for lab in label: - tr[lab]=tf[lab].Get("TrackIPResolutionCheckerNT/tracks") + tr[lab] = tf[lab].Get("TrackIPResolutionCheckerNT/tracks") return tr + def argument_parser(): parser = argparse.ArgumentParser(description="location of the tuple file") parser.add_argument( @@ -71,12 +78,13 @@ def argument_parser(): help='location of LHCb utils plot style file') return parser + def get_resolution(resx, resy, tr, label): - resIPx={} - resIPy={} - resIPx_1={} - resIPy_1={} + resIPx = {} + resIPy = {} + resIPx_1 = {} + resIPy_1 = {} markers = get_markers() colors = get_colors() styles = get_fillstyles() @@ -84,34 +92,40 @@ def get_resolution(resx, resy, tr, label): print("Velo track from PV in acceptance: " + cutAcc) for i, lab in enumerate(label): ### typeofprefix==0 for track from PV and matched with MC - resIPx[lab] = TH2F("resIPx_"+lab, "IPx:1/pt", 20, 0, 2, 100, -300, 300) - resIPy[lab] = TH2F("resIPy_"+lab, "IPy:1/pt", 20, 0, 2, 100, -300, 300) + resIPx[lab] = TH2F("resIPx_" + lab, "IPx:1/pt", 20, 0, 2, 100, -300, + 300) + resIPy[lab] = TH2F("resIPy_" + lab, "IPy:1/pt", 20, 0, 2, 100, -300, + 300) resIPx[lab].SetMarkerStyle(1) resIPy[lab].SetMarkerStyle(1) varx = "recIPx*1000:1.0/truept" vary = "recIPy*1000:1.0/truept" - print("IPx var: " + varx +" " + " IPy var: " + vary) - tr[lab].Draw(varx + ">>resIPx_"+lab, cutAcc) - tr[lab].Draw(vary + ">>resIPy_"+lab, cutAcc) + print("IPx var: " + varx + " " + " IPy var: " + vary) + tr[lab].Draw(varx + ">>resIPx_" + lab, cutAcc) + tr[lab].Draw(vary + ">>resIPy_" + lab, cutAcc) resIPx[lab].FitSlicesY() resIPy[lab].FitSlicesY() - resx[lab] = gDirectory.Get("resIPx_"+lab+"_2") - resy[lab] = gDirectory.Get("resIPy_"+lab+"_2") - resIPx_1[lab]= gDirectory.Get("resIPx_"+lab+"_1") - resIPy_1[lab]= gDirectory.Get("resIPy_"+lab+"_1") + resx[lab] = gDirectory.Get("resIPx_" + lab + "_2") + resy[lab] = gDirectory.Get("resIPy_" + lab + "_2") + resIPx_1[lab] = gDirectory.Get("resIPx_" + lab + "_1") + resIPy_1[lab] = gDirectory.Get("resIPy_" + lab + "_1") for i in range(1, 20): - print(lab+": in 1/pT region: (" + format(resIPx_1[lab].GetBinLowEdge(i), '.2f') + - ", " + format( - resIPx_1[lab].GetBinLowEdge(i) + resIPx_1[lab].GetBinWidth(i), '.2f') + - ") [c/GeV]" + " ---- " + "resIPx for mean : " + - format(resIPx_1[lab].GetBinContent(i), '.2f') + "[\mum] width : " + - format(resx[lab].GetBinContent(i), '.2f') + "[\mum] ---- " + - "resIPy for mean : " + format(resIPy_1[lab].GetBinContent(i), '.2f') + - "[\mum] width : " + format(resy[lab].GetBinContent(i), '.2f') + - "[\mum]") + print( + lab + ": in 1/pT region: (" + + format(resIPx_1[lab].GetBinLowEdge(i), '.2f') + ", " + format( + resIPx_1[lab].GetBinLowEdge(i) + + resIPx_1[lab].GetBinWidth(i), '.2f') + ") [c/GeV]" + + " ---- " + "resIPx for mean : " + + format(resIPx_1[lab].GetBinContent(i), '.2f') + + "[\mum] width : " + format(resx[lab].GetBinContent(i), '.2f') + + "[\mum] ---- " + "resIPy for mean : " + + format(resIPy_1[lab].GetBinContent(i), '.2f') + + "[\mum] width : " + format(resy[lab].GetBinContent(i), '.2f') + + "[\mum]") return resx, resy + def PrCheckerIPresolution(filename, label, outfile, savepdf, plotstyle): sys.path.append(os.path.abspath(plotstyle)) @@ -124,102 +138,104 @@ def PrCheckerIPresolution(filename, label, outfile, savepdf, plotstyle): markers = get_markers() colors = get_colors() - styles= get_fillstyles() - tf={} - tr={} - tf=get_files(tf, filename, label) - tr=get_trees(tr, tf, label) + styles = get_fillstyles() + tf = {} + tr = {} + tf = get_files(tf, filename, label) + tr = get_trees(tr, tf, label) outputfile = TFile(outfile, "recreate") outputfile.cd() - gr_resx={} - gr_resy={} + gr_resx = {} + gr_resy = {} gr_resx, gr_resy = get_resolution(gr_resx, gr_resy, tr, label) canvas1 = TCanvas("resIPx_pT", "resIPx v.s. 1/pT") canvas2 = TCanvas("resIPy_pT", "resIPy v.s. 1/pT") canvas = TCanvas("IPChi2", "IPChi2") canvas.SetLogy() - + canvas1.cd() - latex.DrawLatex(0.7,0.85, "LHCb simultaion") - - polx={} - Par0x={} - Par1x={} - Funcx={} + latex.DrawLatex(0.7, 0.85, "LHCb simultaion") + + polx = {} + Par0x = {} + Par1x = {} + Funcx = {} gr_resx[label[0]].GetYaxis().SetTitle("#sigma_{IPx} [#mum]") gr_resx[label[0]].GetXaxis().SetTitle("1/p_{T} [c/GeV]") gr_resx[label[0]].SetTitle("#sigma(IP_{x}):1/p_{T}") for idx, lab in enumerate(label): set_style(gr_resx[lab], colors[idx], markers[idx], 0) - if idx==0: + if idx == 0: gr_resx[lab].Draw("E1 p1") else: gr_resx[lab].Draw("E1 p1 same") - polx[lab] = TF1("polx_"+lab, "pol1", 0, 3) + polx[lab] = TF1("polx_" + lab, "pol1", 0, 3) polx[lab].SetLineColor(colors[idx]) - print(lab+": Fit to Resolution of IPx v.s. 1/pT:") - gr_resx[lab].Fit("polx_"+lab, "R") + print(lab + ": Fit to Resolution of IPx v.s. 1/pT:") + gr_resx[lab].Fit("polx_" + lab, "R") Par0x[lab] = format(polx[lab].GetParameter(0), '.2f') Par1x[lab] = format(polx[lab].GetParameter(1), '.2f') - Funcx[lab] = lab+": "+ Par0x[lab] + "+" + Par1x[lab] + "/p_{T}" + Funcx[lab] = lab + ": " + Par0x[lab] + "+" + Par1x[lab] + "/p_{T}" gr_resx[lab].SetTitle(Funcx[lab]) #canvas1.PlaceLegend() - place_legend(canvas1, 0.5,0.2, 0.85, 0.45, header="LHCb simulation", option="lep") + place_legend( + canvas1, 0.5, 0.2, 0.85, 0.45, header="LHCb simulation", option="lep") canvas1.SetRightMargin(0.05) canvas1.Write() if savepdf: canvas1.SaveAs("resIPx_pt.pdf") canvas2.cd() - latex.DrawLatex(0.7,0.85, "LHCb simultaion") - poly={} - Par0y={} - Par1y={} - Funcy={} + latex.DrawLatex(0.7, 0.85, "LHCb simultaion") + poly = {} + Par0y = {} + Par1y = {} + Funcy = {} gr_resy[label[0]].GetYaxis().SetTitle("#sigma_{IPy} [#mum]") gr_resy[label[0]].GetXaxis().SetTitle("1/p_{T} [c/GeV]") gr_resy[label[0]].SetTitle("#sigma(IP_{y}):1/p_{T}") for idx, lab in enumerate(label): set_style(gr_resy[lab], colors[idx], markers[idx], 0) - if idx==0: + if idx == 0: gr_resy[lab].Draw("E1 p1") else: gr_resy[lab].Draw("E1 p1 same") - poly[lab] = TF1("poly_"+lab, "pol1", 0, 3) + poly[lab] = TF1("poly_" + lab, "pol1", 0, 3) poly[lab].SetLineColor(colors[idx]) - print(lab+": Fit to Resolution of IPy v.s. 1/pT:") - gr_resy[lab].Fit("poly_"+lab, "R") + print(lab + ": Fit to Resolution of IPy v.s. 1/pT:") + gr_resy[lab].Fit("poly_" + lab, "R") Par0y[lab] = format(poly[lab].GetParameter(0), '.2f') Par1y[lab] = format(poly[lab].GetParameter(1), '.2f') - Funcy[lab] = lab+": "+Par0y[lab] + "+" + Par1y[lab] + "/p_{T}" + Funcy[lab] = lab + ": " + Par0y[lab] + "+" + Par1y[lab] + "/p_{T}" gr_resy[lab].SetTitle(Funcy[lab]) #canvas2.PlaceLegend() - place_legend(canvas2, 0.5,0.2, 0.85, 0.45, header="LHCb simulation", option="lep") + place_legend( + canvas2, 0.5, 0.2, 0.85, 0.45, header="LHCb simulation", option="lep") canvas2.SetRightMargin(0.05) canvas2.Write() if savepdf: canvas2.SaveAs("resIPy_pt.pdf") #### rec IP chi2 distribution - recIPChi2={} + recIPChi2 = {} var = "recIPChi2" cutAcc = "trueeta<5 && trueeta>2 && typeofprefix==0" for i, lab in enumerate(label): - recIPChi2[lab] = TH1F("recIPChi2_"+lab, lab, 100, 0, 200) - tr[lab].Draw(var + ">>recIPChi2_"+lab, cutAcc) + recIPChi2[lab] = TH1F("recIPChi2_" + lab, lab, 100, 0, 200) + tr[lab].Draw(var + ">>recIPChi2_" + lab, cutAcc) recIPChi2[lab].SetLineColor(colors[i]) canvas.cd() - latex.DrawLatex(0.7,0.85, "LHCb simultaion") + latex.DrawLatex(0.7, 0.85, "LHCb simultaion") recIPChi2[label[0]].Draw() recIPChi2[label[0]].SetXTitle("#chi^{2}_{IP}") recIPChi2[label[0]].SetYTitle("N_{tracks}") for lab in label[1:]: recIPChi2[lab].Draw("hist same") - place_legend(canvas, 0.5, 0.5,0.8,0.7, "", "lep") + place_legend(canvas, 0.5, 0.5, 0.8, 0.7, "", "lep") canvas.SetRightMargin(0.05) canvas.Write() if savepdf: @@ -237,13 +253,13 @@ def PrCheckerIPresolution(filename, label, outfile, savepdf, plotstyle): if Numerator.GetEntries() == 0 or Denominator.GetEntries() == 0: continue Eff = Numerator.GetEntries() / (Denominator.GetEntries() + 0.0) - print(lab+ ": Efficiency of IPchi2<" + format(cut) + " : " + + print(lab + ": Efficiency of IPchi2<" + format(cut) + " : " + format(Eff, '.2%')) - outputfile.Write() outputfile.Close() + if __name__ == '__main__': parser = argument_parser() args = parser.parse_args() diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index 102ca195bd5..eb46c712e1a 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -37,6 +37,7 @@ import subprocess def getEfficiencyHistoNames(): return ["eta", "p", "pt", "phi", "nPV"] + def getOriginFolders(): basedict = {"Forward": {}, "MuonMatch": {}} basedict["Forward"]["folder"] = "ForwardTrackChecker/" @@ -44,15 +45,19 @@ def getOriginFolders(): return basedict + def get_colors(): return [kBlack, kAzure, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] + def get_markers(): - return [20, 24, 21, 22, 23, 25 ] + return [20, 24, 21, 22, 23, 25] + def get_fillstyles(): return [3004, 3003, 3325, 3144, 3244, 3444] + def argument_parser(): parser = argparse.ArgumentParser(description="location of the tuple file") parser.add_argument( @@ -67,10 +72,7 @@ def argument_parser(): default='MuonIDefficiency_plots.root', help='output file') parser.add_argument( - '--label', - nargs='+', - default="EffChecker", - help='label for files') + '--label', nargs='+', default="EffChecker", help='label for files') parser.add_argument( '--plotstyle', default=os.getcwd(), @@ -93,6 +95,7 @@ def get_files(tf, filename, label): tf[label[i]] = TFile(f, "read") return tf + def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): eff = {} hist = {} @@ -109,39 +112,38 @@ def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): eff[lab] = TGraphAsymmErrors() eff[lab].SetName(lab) eff[lab].Divide(numerator, denominator, "cl=0.683 b(1,1) mode") - eff[lab].SetTitle(lab+"not elec.") + eff[lab].SetTitle(lab + "not elec.") if (histoName.find('strange') != -1): - eff[lab].SetTitle(lab+" from stranges") + eff[lab].SetTitle(lab + " from stranges") if (histoName.find('electron') != -1): - eff[lab].SetTitle(lab+" electron") + eff[lab].SetTitle(lab + " electron") - hist[lab]= denominator.Clone() + hist[lab] = denominator.Clone() hist[lab].SetName("h_numerator_notElectrons") - hist[lab].SetTitle(var +" histo. not elec.") + hist[lab].SetTitle(var + " histo. not elec.") if (histoName.find('strange') != -1): - hist[lab].SetTitle(var +" histo. stranges") + hist[lab].SetTitle(var + " histo. stranges") if (histoName.find('electron') != -1): - hist[lab].SetTitle(var +" histo. electron") + hist[lab].SetTitle(var + " histo. electron") - if var== "p": + if var == "p": eff[lab].GetXaxis().SetRangeUser(0, 50000) hist[lab].GetXaxis().SetRangeUser(0, 50000) #print the muonID efficiency in each p bin - if var== "p" and printval: + if var == "p" and printval: for i in range(1, numerator.GetNbinsX()): if denominator.GetBinContent(i) == 0: continue Eff = numerator.GetBinContent(i) / ( denominator.GetBinContent(i) + 0.0) - print(lab+": Efficiency of muon ID in (" + - format(numerator.GetBinLowEdge(i), '.2f') + - ", " + format( + print(lab + ": Efficiency of muon ID in (" + + format(numerator.GetBinLowEdge(i), '.2f') + ", " + + format( numerator.GetBinLowEdge(i) + - numerator.GetBinWidth(i), '.2f') + - ") [GeV/c] : " + format(Eff, '.2%')) + numerator.GetBinWidth(i), '.2f') + ") [GeV/c] : " + + format(Eff, '.2%')) - - if var== "pt": + if var == "pt": eff[lab].GetXaxis().SetRangeUser(0, 5000) hist[lab].GetXaxis().SetRangeUser(0, 5000) @@ -151,16 +153,17 @@ def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): sys.path.append(os.path.abspath(plotstyle)) from utils.LHCbStyle import setLHCbStyle, set_style - from utils.ConfigHistos import (efficiencyHistoDict, categoriesDict, getCuts) + from utils.ConfigHistos import (efficiencyHistoDict, categoriesDict, + getCuts) from utils.Legend import place_legend setLHCbStyle() markers = get_markers() colors = get_colors() - styles= get_fillstyles() + styles = get_fillstyles() - tf={} - tf=get_files(tf, filename, label) + tf = {} + tf = get_files(tf, filename, label) outputfile = TFile(outfile, "recreate") latex = TLatex() @@ -188,17 +191,19 @@ def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): # calculate efficiency for histo in efficiencyHistos: - canvastitle = "efficiency vs. " + histo + ", " + categories[tracker][cut]["title"] - name = "efficiency_" + histo+"_"+cut + canvastitle = "efficiency vs. " + histo + ", " + categories[ + tracker][cut]["title"] + name = "efficiency_" + histo + "_" + cut # get efficiency for not electrons category histoName = histoBaseName + "" + efficiencyHistoDict[histo][ "variable"] histoName_den = histoBaseName_den + "" + efficiencyHistoDict[ histo]["variable"] print("not electrons: " + histoName) - eff={} - hist_den={} - eff, hist_den = get_eff( eff, hist_den, tf, histoName, histoName_den, label, histo, printval) + eff = {} + hist_den = {} + eff, hist_den = get_eff(eff, hist_den, tf, histoName, + histoName_den, label, histo, printval) canvas = TCanvas(name, canvastitle) mg = TMultiGraph() @@ -214,10 +219,11 @@ def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): rightmax = 1.05 * hist_den[lab].GetMaximum() scale = gPad.GetUymax() / rightmax hist_den[lab].Scale(scale) - if i==0: + if i == 0: set_style(hist_den[lab], kGray, markers[i], styles[i]) else: - set_style(hist_den[lab], colors[i]-10, markers[i], styles[i]) + set_style(hist_den[lab], colors[i] - 10, markers[i], + styles[i]) hist_den[lab].Draw("hist SAME") canvas.PlaceLegend() @@ -227,7 +233,7 @@ def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): canvas.SetRightMargin(0.05) canvas.Write() - canvasName="MuonIDEff_"+cut+"_"+histo+".pdf" + canvasName = "MuonIDEff_" + cut + "_" + histo + ".pdf" if savepdf: canvas.SaveAs(canvasName) canvas.SetRightMargin(0.05) @@ -236,6 +242,7 @@ def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): outputfile.Write() outputfile.Close() + if __name__ == '__main__': parser = argument_parser() args = parser.parse_args() diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index 816c725a77c..d368533f249 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -26,27 +26,30 @@ from ROOT import ROOT, vector, TGraphAsymmErrors from collections import defaultdict + def get_colors(): return [kBlack, kBlue, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] + def get_markers(): - return [20, 24, 21, 22, 23, 25 ] + return [20, 24, 21, 22, 23, 25] + + def get_fillstyles(): return [3004, 3003, 3325, 3144, 3244, 3444] + def get_files(tf, filename, label): for i, f in enumerate(filename): tf[label[i]] = TFile(f, "read") return tf + def argument_parser(): parser = argparse.ArgumentParser( description="location of the histogram file") parser.add_argument( - '--filename', - nargs='+', - default=[], - help='name of input files') + '--filename', nargs='+', default=[], help='name of input files') parser.add_argument( '--label', nargs='+', @@ -78,51 +81,52 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): markers = get_markers() colors = get_colors() - styles= get_fillstyles() - tf={} - tf=get_files(tf, filename, label) + styles = get_fillstyles() + tf = {} + tf = get_files(tf, filename, label) outputfile = TFile(outfile, "recreate") outputfile.cd() - hdp_p={} - hdp_eta={} - hres_p={} - hres_eta={} - hmom={} - heta={} + hdp_p = {} + hdp_eta = {} + hres_p = {} + hres_eta = {} + hmom = {} + heta = {} canvas1 = TCanvas("res_p", "res v.s. p") canvas1.cd() for idx, lab in enumerate(label): - hdp_p[lab] = tf[lab].Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") - hdp_p[lab].SetName("dpoverp_p_"+lab) + hdp_p[lab] = tf[lab].Get( + "Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") + hdp_p[lab].SetName("dpoverp_p_" + lab) hmom[lab] = hdp_p[lab].ProjectionX() - hmom[lab].SetTitle("p histo. "+lab) + hmom[lab].SetTitle("p histo. " + lab) hdp_p[lab].FitSlicesY() - hres_p[lab] = gDirectory.Get("dpoverp_p_"+lab+"_2") + hres_p[lab] = gDirectory.Get("dpoverp_p_" + lab + "_2") hres_p[lab].GetYaxis().SetTitle("dp/p [%]") hres_p[lab].GetXaxis().SetTitle("p [GeV/c]") hres_p[lab].GetYaxis().SetRangeUser(0, 1.2) - hres_p[lab].SetTitle("Res. "+lab) + hres_p[lab].SetTitle("Res. " + lab) set_style(hres_p[lab], colors[idx], markers[idx], 0) - if idx==0: + if idx == 0: hres_p[lab].Draw("E1 p1") set_style(hmom[lab], kGray, markers[idx], styles[idx]) else: hres_p[lab].Draw("E1 p1 same") - set_style(hmom[lab], colors[idx]-10, markers[idx], styles[idx]) - hmom[lab].Scale(gPad.GetUymax()/hmom[lab].GetMaximum()) + set_style(hmom[lab], colors[idx] - 10, markers[idx], styles[idx]) + hmom[lab].Scale(gPad.GetUymax() / hmom[lab].GetMaximum()) hmom[lab].Draw("hist same") for i in range(1, hres_p[lab].GetNbinsX()): hres_p[lab].SetBinContent(i, hres_p[lab].GetBinContent(i) * 100) - print(lab+": Track resolution (dp/p) in p region: (" + + print(lab + ": Track resolution (dp/p) in p region: (" + format(hres_p[lab].GetBinLowEdge(i), '.2f') + ", " + format( - hres_p[lab].GetBinLowEdge(i) + hres_p[lab].GetBinWidth(i), '.2f') + - ") [GeV/c]" + " --- " + - format(hres_p[lab].GetBinContent(i), '.2f') + "%") + hres_p[lab].GetBinLowEdge(i) + + hres_p[lab].GetBinWidth(i), '.2f') + ") [GeV/c]" + + " --- " + format(hres_p[lab].GetBinContent(i), '.2f') + "%") print("-----------------------------------------------------") canvas1.PlaceLegend() @@ -137,34 +141,37 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): canvas2.cd() for idx, lab in enumerate(label): - hdp_eta[lab] = tf[lab].Get("Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") - hdp_eta[lab].SetName("dpoverp_eta_"+lab) + hdp_eta[lab] = tf[lab].Get( + "Track/TrackResChecker/ALL/vertex/dpoverp_vs_eta") + hdp_eta[lab].SetName("dpoverp_eta_" + lab) hdp_eta[lab].FitSlicesY() heta[lab] = hdp_eta[lab].ProjectionX() - heta[lab].SetTitle("#eta histo. "+lab) + heta[lab].SetTitle("#eta histo. " + lab) - hres_eta[lab]= gDirectory.Get("dpoverp_eta_"+lab+"_2") + hres_eta[lab] = gDirectory.Get("dpoverp_eta_" + lab + "_2") hres_eta[lab].GetYaxis().SetTitle("dp/p [%]") hres_eta[lab].GetXaxis().SetTitle("#eta") hres_eta[lab].GetYaxis().SetRangeUser(0, 1.2) - hres_eta[lab].SetTitle("Res. "+lab) + hres_eta[lab].SetTitle("Res. " + lab) set_style(hres_eta[lab], colors[idx], markers[idx], 0) - if idx==0: + if idx == 0: hres_eta[lab].Draw("E1 p1") set_style(heta[lab], kGray, markers[idx], styles[idx]) else: hres_eta[lab].Draw("E1 p1 same") - set_style(heta[lab], colors[idx]-10, markers[idx], styles[idx]) + set_style(heta[lab], colors[idx] - 10, markers[idx], styles[idx]) - heta[lab].Scale(gPad.GetUymax()/heta[lab].GetMaximum()) + heta[lab].Scale(gPad.GetUymax() / heta[lab].GetMaximum()) heta[lab].Draw("hist same") for i in range(1, hres_eta[lab].GetNbinsX()): - hres_eta[lab].SetBinContent(i, hres_eta[lab].GetBinContent(i) * 100) + hres_eta[lab].SetBinContent(i, + hres_eta[lab].GetBinContent(i) * 100) - print(lab+": Track resolution (dp/p) in eta region: (" + - format(hres_eta[lab].GetBinLowEdge(i), '.2f') + ", " + format( + print(lab + ": Track resolution (dp/p) in eta region: (" + + format(hres_eta[lab].GetBinLowEdge(i), '.2f') + ", " + + format( hres_eta[lab].GetBinLowEdge(i) + hres_eta[lab].GetBinWidth(i), '.2f') + ")" + " --- " + format(hres_eta[lab].GetBinContent(i), '.2f') + "%") diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 7b3ec759297..76a38a2fb94 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -87,8 +87,8 @@ def getCuts(): ] basedict["MuonMatch"] = [ "02_long_muon_P>3GeV_Pt>0.5GeV", "04_long_pion_P>3GeV_Pt>0.5GeV", - "03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", - "01_long", "02_long_muon", "03_long_muon_from_strange", "04_long_pion" + "03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", "01_long", + "02_long_muon", "03_long_muon_from_strange", "04_long_pion" ] return basedict diff --git a/Hlt/RecoConf/scripts/utils/LHCbStyle.py b/Hlt/RecoConf/scripts/utils/LHCbStyle.py index 1056556c8e5..1429775f1be 100644 --- a/Hlt/RecoConf/scripts/utils/LHCbStyle.py +++ b/Hlt/RecoConf/scripts/utils/LHCbStyle.py @@ -13,6 +13,7 @@ from ROOT import gStyle from ROOT import gROOT, TH1, TH1F, TH1D from ROOT import TStyle + def set_style(graph, color, marker, style): graph.SetLineColor(color) graph.SetMarkerColor(color) @@ -36,6 +37,7 @@ def set_style(graph, color, marker, style): return graph + def setLHCbStyle(): global lhcbStyle -- GitLab From 4dfbb149a03de7a051b3cf26fe1422fac1462392 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 3 Mar 2020 10:23:05 +0100 Subject: [PATCH 106/171] fix bugs --- .../hlt1_rec_trackingeff_plots.qmt | 35 ------------------- .../hlt1_reco_IPresolution_plots.qmt | 2 +- .../hlt1_reco_muonIDeff_plots.qmt | 2 +- .../hlt1_reco_trackresolution_plots.qmt | 3 +- 4 files changed, 3 insertions(+), 39 deletions(-) delete mode 100644 Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_rec_trackingeff_plots.qmt diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_rec_trackingeff_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_rec_trackingeff_plots.qmt deleted file mode 100644 index 731c0006648..00000000000 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_rec_trackingeff_plots.qmt +++ /dev/null @@ -1,35 +0,0 @@ - - - - -python - - $RECOCONFROOT/scripts/PrCheckerEfficiency_HLT1.py - --filename=MCMatching_MiniBias.root - --outputfile=efficiency_plots.root - --plotstyle=$RECOCONFROOT/scripts/ - --output=hlt1_reco_trackeff_plot.opts.py - -true - - - -from Moore.qmtest.exclusions import remove_known_warnings -countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, - stdout=remove_known_warnings(stdout)) - - - - diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt index ec49d8a7ae3..5d93556337a 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt @@ -17,7 +17,7 @@ Test script to determine IP resolution on simulation. $RECOCONFROOT/scripts/PrCheckerIPresolution.py --filename=Hlt1ForwardTracking_IPresolution.root - --outputfile=IPResolution_plots.root + --outfile=IPResolution_plots.root --plotstyle=$RECOCONFROOT/scripts/ --output=hlt1_reco_IPresolution_plot.opts.py diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt index e8c326d40e1..1b10fc5c4a2 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt @@ -18,7 +18,7 @@ long reconstructed forward tracks with MC samples. $RECOCONFROOT/scripts/PrCheckerMuonIDEff.py --filename=PrChecker_MuonID_MiniBias.root - --outputfile=muonIDeff_plots.root + --outfile=muonIDeff_plots.root --plotstyle=$RECOCONFROOT/scripts/ --output=hlt1_reco_muonideff_plot.opts.py diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt index 1bdb4418760..ced5bba9249 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt @@ -17,10 +17,9 @@ Test plot script to draw the track resolution in Hlt1 and test for changes. $RECOCONFROOT/scripts/PrCheckerTrackResolution.py --filename=Hlt1ForwardTrackingResolution.root - --outputfile=TrackResolution_plots.root + --outfile=TrackResolution_plots.root --plotstyle=$RECOCONFROOT/scripts/ --output=hlt1_reco_trackresolution.opts.py - --all-opt true -- GitLab From 58976915e466902c3a69fabe53b4b31b829f43e5 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 3 Mar 2020 10:24:24 +0100 Subject: [PATCH 107/171] comment on unused cut setting --- .../scripts/PrCheckerEfficiency_HLT1.py | 2 +- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 2 +- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 25 ++++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index dec2ea13794..b290fea6729 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -162,8 +162,8 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, markers = get_markers() colors = get_colors() styles = get_fillstyles() - tf = {} + tf = {} tf = get_files(tf, filename, label) outputfile = TFile(outfile, "recreate") diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index eb46c712e1a..10b9359be01 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -63,7 +63,7 @@ def argument_parser(): parser.add_argument( '--filename', type=str, - default='MCMatching_MiniBias.root', + default='PrChecker_MuonID_MiniBias.root', nargs='+', help='input files, including path') parser.add_argument( diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 76a38a2fb94..553475aea3c 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -68,15 +68,15 @@ def getCuts(): "01_velo", "02_long", "03_long_P>5GeV", "04_long_strange", "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV", - "11_long_fromD_P>3GeV_Pt>0.5GeV", "11_long_strange_P>3GeV_Pt>0.5GeV", - "06_long_fromD" + #"11_long_fromD_P>3GeV_Pt>0.5GeV", "11_long_strange_P>3GeV_Pt>0.5GeV", + #"06_long_fromD" ] basedict["Upstream"] = [ "01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV", - "09_long_fromD", "14_long_fromD_P>3GeV_Pt>0.5GeV", - "14_long_strange_P>3GeV_Pt>0.5GeV" + #"09_long_fromD", "14_long_fromD_P>3GeV_Pt>0.5GeV", + #"14_long_strange_P>3GeV_Pt>0.5GeV" ] basedict["Forward"] = [ "01_long", "02_long_P>5GeV", "03_long_strange", @@ -86,9 +86,9 @@ def getCuts(): "10_long_strange_P>3GeV_Pt>0.5GeV" ] basedict["MuonMatch"] = [ - "02_long_muon_P>3GeV_Pt>0.5GeV", "04_long_pion_P>3GeV_Pt>0.5GeV", - "03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", "01_long", - "02_long_muon", "03_long_muon_from_strange", "04_long_pion" + #"02_long_muon_P>3GeV_Pt>0.5GeV", "04_long_pion_P>3GeV_Pt>0.5GeV", + #"03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", + "01_long", "02_long_muon", "03_long_muon_from_strange", "04_long_pion" ] return basedict @@ -139,7 +139,8 @@ def categoriesDict(): basedict["Velo"]["06_long_fromB"]["plotElectrons"] = True basedict["Velo"]["06_long_fromD"]["plotElectrons"] = False basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True - basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True + #basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True + basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False basedict["Velo"]["11_long_fromD_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False @@ -181,8 +182,8 @@ def categoriesDict(): basedict["Upstream"]["09_long_fromB"]["plotElectrons"] = True basedict["Upstream"]["09_long_fromD"]["plotElectrons"] = False basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True - basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ - "plotElectrons"] = True + #basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True + basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False basedict["Upstream"]["14_long_fromD_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Upstream"]["14_long_strange_P>3GeV_Pt>0.5GeV"][ @@ -224,8 +225,8 @@ def categoriesDict(): basedict["Forward"]["05_long_fromB"]["plotElectrons"] = True basedict["Forward"]["05_long_fromD"]["plotElectrons"] = False basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True - basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ - "plotElectrons"] = True + #basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True + basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False basedict["Forward"]["10_long_fromD_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ -- GitLab From f29f469d5d7b47d1436e6c76cdd467f052346d1d Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 3 Mar 2020 10:27:16 +0100 Subject: [PATCH 108/171] remove unused library --- Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index b290fea6729..bafe7151d64 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -28,7 +28,7 @@ import ROOT from ROOT import TMultiGraph, TMath, TAxis, TH1, TLatex, TGaxis, TROOT, TSystem, TCanvas, TFile, TTree, TObject from ROOT import kDashed, kRed, kGreen, kBlue, kBlack, kAzure, kGray, kOrange, kMagenta, kCyan, kTRUE, kFALSE, gPad from ROOT import gROOT, gStyle, TStyle, TPaveText -from ROOT import ROOT, RDataFrame, vector, TGraphAsymmErrors +from ROOT import ROOT, vector, TGraphAsymmErrors import logging import subprocess -- GitLab From b4fc74872449b2524c7aa1ebe0955f0d91eba078 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 3 Mar 2020 09:27:59 +0000 Subject: [PATCH 109/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7420696 --- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 39 ++++++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 553475aea3c..9b80e253400 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -65,16 +65,28 @@ def getCuts(): basedict = {"Velo": {}, "Upstream": {}, "Forward": {}, "MuonMatch": {}} basedict["Velo"] = [ - "01_velo", "02_long", "03_long_P>5GeV", "04_long_strange", - "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", - "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV", + "01_velo", + "02_long", + "03_long_P>5GeV", + "04_long_strange", + "05_long_strange_P>5GeV", + "06_long_fromB", + "07_long_fromB_P>5GeV", + "11_long_fromB_P>3GeV_Pt>0.5GeV", + "12_UT_long_fromB_P>3GeV_Pt>0.5GeV", #"11_long_fromD_P>3GeV_Pt>0.5GeV", "11_long_strange_P>3GeV_Pt>0.5GeV", #"06_long_fromD" ] basedict["Upstream"] = [ - "01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", - "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", - "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV", + "01_velo", + "02_velo+UT", + "03_velo+UT_P>5GeV", + "07_long", + "08_long_P>5GeV", + "09_long_fromB", + "10_long_fromB_P>5GeV", + "14_long_fromB_P>3GeV_Pt>0.5GeV", + "15_UT_long_fromB_P>3GeV_Pt>0.5GeV", #"09_long_fromD", "14_long_fromD_P>3GeV_Pt>0.5GeV", #"14_long_strange_P>3GeV_Pt>0.5GeV" ] @@ -87,8 +99,11 @@ def getCuts(): ] basedict["MuonMatch"] = [ #"02_long_muon_P>3GeV_Pt>0.5GeV", "04_long_pion_P>3GeV_Pt>0.5GeV", - #"03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", - "01_long", "02_long_muon", "03_long_muon_from_strange", "04_long_pion" + #"03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", + "01_long", + "02_long_muon", + "03_long_muon_from_strange", + "04_long_pion" ] return basedict @@ -140,7 +155,7 @@ def categoriesDict(): basedict["Velo"]["06_long_fromD"]["plotElectrons"] = False basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True #basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True - basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False basedict["Velo"]["11_long_fromD_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False @@ -183,7 +198,8 @@ def categoriesDict(): basedict["Upstream"]["09_long_fromD"]["plotElectrons"] = False basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True #basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True - basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False basedict["Upstream"]["14_long_fromD_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Upstream"]["14_long_strange_P>3GeV_Pt>0.5GeV"][ @@ -226,7 +242,8 @@ def categoriesDict(): basedict["Forward"]["05_long_fromD"]["plotElectrons"] = False basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True #basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True - basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = False basedict["Forward"]["10_long_fromD_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ -- GitLab From 5f9d81f2ed8a43bf9ac92b752f87a1858a321fa6 Mon Sep 17 00:00:00 2001 From: Agnieszka Dziurda Date: Thu, 5 Mar 2020 11:30:18 +0100 Subject: [PATCH 110/171] adding dependence plot, restructurisation --- .../scripts/PrimaryVertexCheckerEfficiency.py | 72 ++--- .../scripts/PrimaryVertexCheckerPull.py | 93 ++++-- .../scripts/PrimaryVertexCheckerResolution.py | 98 ++++-- Hlt/RecoConf/scripts/utils/pvconfig.py | 136 ++++++++ Hlt/RecoConf/scripts/utils/pvutils.py | 306 ++++++++++-------- 5 files changed, 464 insertions(+), 241 deletions(-) create mode 100644 Hlt/RecoConf/scripts/utils/pvconfig.py diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py index 56f166169fd..05ee126647e 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py @@ -78,29 +78,6 @@ parser.add_argument( ) -def get_categories(multi, smog): - cut = {} - cut["all"] = {"cut": ""} - cut["isolated"] = {"cut": "&&isol==1"} - if not smog: - cut["close"] = {"cut": "&&isol==0"} - if multi: - cut["1st"] = {"cut": "&&multimc==1"} - cut["2nd"] = {"cut": "&&multimc==2"} - cut["3rd"] = {"cut": "&&multimc==3"} - cut["4th"] = {"cut": "&&multimc==4"} - cut["5th"] = {"cut": "&&multimc==5"} - - return cut - - -def get_colors(): - return [kRed, kBlue, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] - - -def get_markers(): - return [21, 20, 22, 23, 24, 25, 26] - def get_labels(number_of_files): label = [] @@ -117,11 +94,14 @@ if __name__ == '__main__': gROOT.SetBatch() from pvutils import get_default_tree_name - from pvutils import get_files, get_trees, get_eff, plot_eff - from pvutils import set_legend + from pvutils import get_files, get_trees, get_eff, plot + + from pvconfig import get_variable_ranges + from pvconfig import get_style, get_categories + from pvconfig import set_legend - markers = get_markers() - colors = get_colors() + ranges = get_variable_ranges(args.smog) + style = get_style() label = args.label if args.label == "": @@ -132,28 +112,32 @@ if __name__ == '__main__': tf = get_files(tf, label, args.fileName) tr = get_trees(tf, tr, label, args.treeName, True) - eff_tr = {} - eff_z = {} - eff_r = {} - hist_tr = {} - hist_z = {} - hist_r = {} + eff = {} + eff["tracks"] = {} + eff["z"] = {} + eff["r"] = {} + hist = {} + hist["tracks"] = {} + hist["z"]={} + hist["r"]={} + cat = get_categories(args.multi, args.smog) - eff_tr, hist_tr = get_eff(eff_tr, hist_tr, tr, "nrectrmc", colors, markers, - args.smog, cat, label) - eff_z, hist_z = get_eff(eff_z, hist_z, tr, "zMC", colors, markers, - args.smog, cat, label) - eff_r, hist_r = get_eff(eff_r, hist_r, tr, "rMC", colors, markers, - args.smog, cat, label) + + eff["tracks"], hist["tracks"] = get_eff(eff["tracks"], hist["tracks"], tr, "nrectrmc", style, + ranges, cat, label) + eff["z"], hist["z"] = get_eff(eff["z"], hist["z"], tr, "zMC", style, + ranges, cat, label) + eff["r"], hist["r"] = get_eff(eff["r"], hist["r"], tr, "rMC", style, + ranges, cat, label) if args.dist: legend = TLegend(0.15, 0.82, 0.88, 0.98) else: legend = TLegend(0.15, 0.86, 0.88, 0.98) - legend = set_legend(legend, label, eff_tr, hist_tr, args.dist) + legend = set_legend(legend, label, eff["tracks"], "eff", hist["z"], args.dist) + - plot_eff(eff_tr, hist_tr, args.prefix, "ntracks", cat, label, legend, - args.dist) - plot_eff(eff_z, hist_z, args.prefix, "z", cat, label, legend, args.dist) - plot_eff(eff_r, hist_r, args.prefix, "r", cat, label, legend, args.dist) + plot(eff["tracks"], "eff", args.prefix, "ntracks", cat, label, legend, hist["tracks"], args.dist) + plot(eff["z"], "eff", args.prefix, "z", cat, label, legend, hist["z"], args.dist) + plot(eff["r"], "eff", args.prefix, "r", cat, label, legend, hist["r"], args.dist) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py index 0e226d931be..5c06da4eb87 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py @@ -78,30 +78,6 @@ parser.add_argument( ) -def get_categories(multi, smog): - cut = {} - cut["all"] = {"cut": ""} - cut["isolated"] = {"cut": "&&isol==1"} - if not smog: - cut["close"] = {"cut": "&&isol==0"} - if multi: - cut["1st"] = {"cut": "&&multimc==1"} - cut["2nd"] = {"cut": "&&multimc==2"} - cut["3rd"] = {"cut": "&&multimc==3"} - cut["4th"] = {"cut": "&&multimc==4"} - cut["5th"] = {"cut": "&&multimc==5"} - - return cut - - -def get_colors(): - return [kRed, kBlue, kOrange, kMagenta, kGreen, kCyan] - - -def get_markers(): - return [21, 20, 22, 23, 24, 25, 26] - - def get_labels(number_of_files): label = [] for i in range(0, number_of_files): @@ -119,9 +95,16 @@ if __name__ == '__main__': from pvutils import get_default_tree_name from pvutils import get_files, get_trees from pvutils import set_legend, get_global, plot_comparison + from pvutils import get_dependence + from pvutils import plot + + from pvconfig import get_variable_ranges + from pvconfig import get_style, get_categories + from pvconfig import get_y_axis - markers = get_markers() - colors = get_colors() + ranges = get_variable_ranges(args.smog) + style = get_style() + cat = get_categories(args.multi, args.smog) label = args.label if args.label == "": @@ -137,12 +120,58 @@ if __name__ == '__main__': hist_z = {} norm = True #to-do hist_x = get_global(hist_x, tr, "pullx", "#Delta x / #sigma_{x}", - "Candidates Normalized", colors, markers, cat, label) + "Candidates Normalized", style, ranges, cat, label) hist_y = get_global(hist_y, tr, "pully", "#Delta y / #sigma_{y}", - "Candidates Normalized", colors, markers, cat, label) + "Candidates Normalized", style, ranges, cat, label) hist_z = get_global(hist_z, tr, "pullz", "#Delta z / #sigma_{z}", - "Candidates Normalized", colors, markers, cat, label) + "Candidates Normalized", style, ranges, cat, label) + + plot_comparison(hist_x, args.prefix, "pullx", cat, label, style, norm) + plot_comparison(hist_y, args.prefix, "pully", cat, label, style, norm) + plot_comparison(hist_z, args.prefix, "pullz", cat, label, style, norm) + + + from ROOT import gEnv + gEnv.SetValue("Hist.Binning.1D.x","100") + + + graph = {} + graph["tracks"] = {} + graph["tracks"]["pullx"] = {} + graph["tracks"]["pully"] = {} + graph["tracks"]["pullz"] = {} + graph["tracks"]["pullx"] = get_dependence(graph["tracks"]["pullx"], tr, "pullx", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["pully"] = get_dependence(graph["tracks"]["pully"], tr, "pully", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["pullz"] = get_dependence(graph["tracks"]["pullz"], tr, "pullz", "nrectrmc", ranges, style, cat, label) + + legend = TLegend(0.15, 0.86, 0.88, 0.98) + legend = set_legend(legend, label, graph["tracks"]["pullz"], "sigma") + + plot(graph["tracks"]["pullx"], "mean", args.prefix+"_ntracks_mean", "pullx", cat, label, legend) + plot(graph["tracks"]["pullx"], "sigma", args.prefix+"_ntracks_sigma", "pullx", cat, label, legend) + + plot(graph["tracks"]["pully"], "mean", args.prefix+"_ntracks_mean", "pully", cat, label, legend) + plot(graph["tracks"]["pully"], "sigma", args.prefix+"_ntracks_sigma", "pully", cat, label, legend) + + plot(graph["tracks"]["pullz"], "mean", args.prefix+"_ntracks_mean", "pullz", cat, label, legend) + plot(graph["tracks"]["pullz"], "sigma", args.prefix+"_ntracks_sigma", "pullz", cat, label, legend) + + + graph["z"] = {} + graph["z"]["pullx"] = {} + graph["z"]["pully"] = {} + graph["z"]["pullz"] = {} + graph["z"]["pullx"] = get_dependence(graph["z"]["pullx"], tr, "pullx", "zMC", ranges, style, cat, label) + graph["z"]["pully"] = get_dependence(graph["z"]["pully"], tr, "pully", "zMC", ranges, style, cat, label) + graph["z"]["pullz"] = get_dependence(graph["z"]["pullz"], tr, "pullz", "zMC", ranges, style, cat, label) + + plot(graph["z"]["pullx"], "mean", args.prefix+"_z_mean", "pullx", cat, label, legend) + plot(graph["z"]["pullx"], "sigma", args.prefix+"_z_sigma", "pullx", cat, label, legend) + + plot(graph["z"]["pully"], "mean", args.prefix+"_z_mean", "pully", cat, label, legend) + plot(graph["z"]["pully"], "sigma", args.prefix+"_z_sigma", "pully", cat, label, legend) + + plot(graph["z"]["pullz"], "mean", args.prefix+"_z_mean", "pullz", cat, label, legend) + plot(graph["z"]["pullz"], "sigma", args.prefix+"_z_sigma", "pullz", cat, label, legend) + - plot_comparison(hist_x, args.prefix, "pullx", cat, label, colors, norm) - plot_comparison(hist_y, args.prefix, "pully", cat, label, colors, norm) - plot_comparison(hist_z, args.prefix, "pullz", cat, label, colors, norm) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py index e89588da0e6..119963274c0 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py @@ -78,34 +78,10 @@ parser.add_argument( ) -def get_categories(multi, smog): - cut = {} - cut["all"] = {"cut": ""} - cut["isolated"] = {"cut": "&&isol==1"} - if not smog: - cut["close"] = {"cut": "&&isol==0"} - if multi: - cut["1st"] = {"cut": "&&multimc==1"} - cut["2nd"] = {"cut": "&&multimc==2"} - cut["3rd"] = {"cut": "&&multimc==3"} - cut["4th"] = {"cut": "&&multimc==4"} - cut["5th"] = {"cut": "&&multimc==5"} - - return cut - - -def get_colors(): - return [kRed, kBlue, kOrange, kMagenta, kGreen, kCyan] - - -def get_markers(): - return [21, 20, 22, 23, 24, 25, 26] - - def get_labels(number_of_files): label = [] for i in range(0, number_of_files): - label.append("PV Checker {number}".format(number=str(i + 1))) + label.append("PVChecker{number}".format(number=str(i + 1))) return label @@ -119,14 +95,21 @@ if __name__ == '__main__': from pvutils import get_default_tree_name from pvutils import get_files, get_trees from pvutils import set_legend, get_global, plot_comparison + from pvutils import get_dependence + from pvutils import plot + + from pvconfig import get_variable_ranges + from pvconfig import get_style, get_categories - markers = get_markers() - colors = get_colors() + ranges = get_variable_ranges(args.smog) + style = get_style() + cat = get_categories(args.multi, args.smog) label = args.label if args.label == "": label = get_labels(len(args.fileName)) + tr = {} tf = {} tf = get_files(tf, label, args.fileName) @@ -136,13 +119,60 @@ if __name__ == '__main__': hist_y = {} hist_z = {} norm = True + + hist_x = get_global(hist_x, tr, "dx", "#Delta x [mm]", - "Candidates Normalized", colors, markers, cat, label) + "Candidates Normalized", style, ranges, cat, label) hist_y = get_global(hist_y, tr, "dy", "#Delta y [mm]", - "Candidates Normalized", colors, markers, cat, label) + "Candidates Normalized", style, ranges, cat, label) hist_z = get_global(hist_z, tr, "dz", "#Delta z [mm]", - "Candidates Normalized", colors, markers, cat, label) - - plot_comparison(hist_x, args.prefix, "dx", cat, label, colors, norm) - plot_comparison(hist_y, args.prefix, "dy", cat, label, colors, norm) - plot_comparison(hist_z, args.prefix, "dz", cat, label, colors, norm) + "Candidates Normalized", style, ranges, cat, label) + + plot_comparison(hist_x, args.prefix, "dx", cat, label, style, norm) + plot_comparison(hist_y, args.prefix, "dy", cat, label, style, norm) + plot_comparison(hist_z, args.prefix, "dz", cat, label, style, norm) + + + from ROOT import gEnv + gEnv.SetValue("Hist.Binning.1D.x","100") + + graph = {} + graph["tracks"] = {} + graph["tracks"]["dx"] = {} + graph["tracks"]["dy"] = {} + graph["tracks"]["dz"] = {} + graph["tracks"]["dx"] = get_dependence(graph["tracks"]["dx"], tr, "dx", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["dy"] = get_dependence(graph["tracks"]["dy"], tr, "dy", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["dz"] = get_dependence(graph["tracks"]["dz"], tr, "dz", "nrectrmc", ranges, style, cat, label) + + legend = TLegend(0.15, 0.86, 0.88, 0.98) + legend = set_legend(legend, label, graph["tracks"]["dz"], "sigma") + + plot(graph["tracks"]["dx"], "mean", args.prefix+"_ntracks_mean", "dx", cat, label, legend) + plot(graph["tracks"]["dx"], "sigma", args.prefix+"_ntracks_sigma", "dx", cat, label, legend) + + plot(graph["tracks"]["dy"], "mean", args.prefix+"_ntracks_mean", "dy", cat, label, legend) + plot(graph["tracks"]["dy"], "sigma", args.prefix+"_ntracks_sigma", "dy", cat, label, legend) + + plot(graph["tracks"]["dz"], "mean", args.prefix+"_ntracks_mean", "dz", cat, label, legend) + plot(graph["tracks"]["dz"], "sigma", args.prefix+"_ntracks_sigma", "dz", cat, label, legend) + + + graph["z"] = {} + graph["z"]["dx"] = {} + graph["z"]["dy"] = {} + graph["z"]["dz"] = {} + graph["z"]["dx"] = get_dependence(graph["z"]["dx"], tr, "dx", "zMC", ranges, style, cat, label) + graph["z"]["dy"] = get_dependence(graph["z"]["dy"], tr, "dy", "zMC", ranges, style, cat, label) + graph["z"]["dz"] = get_dependence(graph["z"]["dz"], tr, "dz", "zMC", ranges, style, cat, label) + + plot(graph["z"]["dx"], "mean", args.prefix+"_z_mean", "dx", cat, label, legend) + plot(graph["z"]["dx"], "sigma", args.prefix+"_z_sigma", "dx", cat, label, legend) + + plot(graph["z"]["dy"], "mean", args.prefix+"_z_mean", "dy", cat, label, legend) + plot(graph["z"]["dy"], "sigma", args.prefix+"_z_sigma", "dy", cat, label, legend) + + plot(graph["z"]["dz"], "mean", args.prefix+"_z_mean", "dz", cat, label, legend) + plot(graph["z"]["dz"], "sigma", args.prefix+"_z_sigma", "dz", cat, label, legend) + + diff --git a/Hlt/RecoConf/scripts/utils/pvconfig.py b/Hlt/RecoConf/scripts/utils/pvconfig.py new file mode 100644 index 00000000000..0b7f6890670 --- /dev/null +++ b/Hlt/RecoConf/scripts/utils/pvconfig.py @@ -0,0 +1,136 @@ +############################################################################### +# (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. # +############################################################################### +#!/usr/bin/python + +from ROOT import TH1F, TLegend +from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow + +def get_categories(multi, smog): + cut = {} + cut["all"] = {"cut": ""} +# cut["isolated"] = {"cut": "&&isol==1"} +# if not smog: +# cut["close"] = {"cut": "&&isol==0"} + if multi: + cut["1st"] = {"cut": "&&multimc==1"} + cut["2nd"] = {"cut": "&&multimc==2"} + cut["3rd"] = {"cut": "&&multimc==3"} + cut["4th"] = {"cut": "&&multimc==4"} + cut["5th"] = {"cut": "&&multimc==5"} + + return cut + + +def get_style(): + return {"color" :[kRed, kBlue, kOrange, kMagenta, kGreen, kCyan], + "marker":[21, 20, 22, 23, 24, 25 ]} + +def get_default_tree_name(is_checker): + if is_checker: + return "PrimaryVertexChecker/101" + else: + return "VertexCompare/102" + +def transfer_variable(dep): + dictionary = {"pullx":"dx/errx", + "pully":"dy/erry", + "pullz":"dz/errz", + "dx":"dx", + "dy":"dy", + "dz":"dz", } + return dictionary[dep] + +def get_variable_ranges(smog): + dictionary = {"zMC" :{"bins":50, "min":-200, "max":200}, + "rMC" :{"bins":50, "min":0.0, "max":0.2}, + "dx" :{"bins":50, "min":-0.10, "max":0.10}, + "dy" :{"bins":50, "min":-0.10, "max":0.10}, + "dz" :{"bins":50, "min":-0.40, "max":0.40}, + "pullx" :{"bins":50, "min":-3.50, "max":3.50}, + "pully" :{"bins":50, "min":-3.50, "max":3.50}, + "pullz" :{"bins":50, "min":-3.50, "max":3.50}, + "nrectrmc":{"bins":66, "min":4.0, "max":70.0}} + if smog: + dictionary["zMC"] = {"bins":100,"min":-500, "max":200} + + return dictionary + +def get_y_axis(dependence): + dictionary = {"dx":"Resolution #Delta x [#mu m]", + "dy":"Resolution #Delta y [#mu m]", + "dz":"Resolution #Delta z [#mu m]", + "pullx":"Pull #Delta x/#sigma_{x}", + "pully":"Pull #Delta y/#sigma_{y}", + "pullz":"Pull #Delta z/#sigma_{z}"} + return dictionary[dependence] + +def get_x_axis(dependence): + dictionary= {"zMC":"z [mm]", + "rMC":"radial distance [mm]", + "nrectrmc":"number of tracks in Primary Vertex"} + return dictionary[dependence] + +def set_style(graph, color, marker, xaxis, yaxis, title): + graph.SetTitle("") + graph.SetLineColor(color) + graph.SetMarkerColor(color) + graph.SetMarkerSize(1.3) + graph.SetMarkerStyle(marker) + graph.GetYaxis().SetTitleOffset(0.85) + if type(graph) == TH1F: + graph.SetFillColor(color) + graph.SetLineWidth(1) + graph.SetStats(False) + graph.GetYaxis().SetTitleOffset(1.1) + graph.GetYaxis().SetTitleSize(0.06) + graph.GetYaxis().SetLabelSize(0.06) + graph.GetXaxis().SetTitleSize(0.06) + graph.GetXaxis().SetLabelSize(0.06) + graph.GetXaxis().SetTitleFont(132) + graph.GetXaxis().SetLabelFont(132) + graph.GetYaxis().SetTitleFont(132) + graph.GetYaxis().SetLabelFont(132) + + if title != "": + graph.SetTitle(title) + if xaxis != "": + graph.GetXaxis().SetTitle(xaxis) + if yaxis != "": + graph.GetYaxis().SetTitle(yaxis) + +def set_legend(legend, label, gr, gr_type, + hist = None, dist = False): + legend.SetTextSize(0.04) + legend.SetTextFont(12) + legend.SetFillColor(4000) + legend.SetShadowColor(0) + legend.SetBorderSize(0) + legend.SetTextFont(132) + legend.SetNColumns(2) + for lab in label: + legend.AddEntry(gr["all"][lab][gr_type], "{lab}".format(lab=lab), + "lep") + if dist: + legend.AddEntry(hist["all"][label[0]]["den"], "Distribution MC", "f") + for lab in label: + legend.AddEntry(hist["all"][lab]["nom"], + "Distribution {lab}".format(lab=lab), "f") + + return legend + +def get_text_cor(): + return {"x": [0.17, 0.65, 0.17, 0.65], + "y": [0.92, 0.92, 0.75, 0.75]} + + + +def basic_cut(): + return "nrectrmc>=4 && dz < 2.0" diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py index 124731fe94f..d734f3e7a62 100644 --- a/Hlt/RecoConf/scripts/utils/pvutils.py +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -20,13 +20,15 @@ from ROOT import TCanvas from ROOT import TGraphErrors, TLegend from ROOT import gPad, kGray, TLatex +from pvconfig import get_default_tree_name +from pvconfig import transfer_variable +from pvconfig import get_x_axis, get_y_axis +from pvconfig import set_style +from pvconfig import set_legend +from pvconfig import get_text_cor +from pvconfig import basic_cut -def get_default_tree_name(is_checker): - if is_checker: - return "PrimaryVertexChecker/101" - else: - return "VertexCompare/102" - +from array import array def get_files(tf, label, files): i = 0 @@ -47,88 +49,33 @@ def get_trees(tf, tr, label, trees, is_checker): return tr -def set_style(graph, color, marker, xaxis, yaxis, title): - graph.SetTitle("") - graph.SetLineColor(color) - graph.SetMarkerColor(color) - graph.SetMarkerSize(1.3) - graph.SetMarkerStyle(marker) - graph.GetYaxis().SetTitleOffset(0.85) - if type(graph) == TH1F: - graph.SetFillColor(color) - graph.SetLineWidth(4) - graph.SetStats(False) - graph.GetYaxis().SetTitleOffset(1.1) - graph.GetYaxis().SetTitleSize(0.06) - graph.GetYaxis().SetLabelSize(0.06) - graph.GetXaxis().SetTitleSize(0.06) - graph.GetXaxis().SetLabelSize(0.06) - graph.GetXaxis().SetTitleFont(132) - graph.GetXaxis().SetLabelFont(132) - graph.GetYaxis().SetTitleFont(132) - graph.GetYaxis().SetLabelFont(132) - - if title != "": - graph.SetTitle(title) - if xaxis != "": - graph.GetXaxis().SetTitle(xaxis) - if yaxis != "": - graph.GetYaxis().SetTitle(yaxis) - - -def get_range(dependence, smog): - if dependence == "zMC": - if smog: - return "(100,-500,200)" - else: - return "(50,-200,200)" - elif dependence == "rMC": - return "(50,0.0,0.2)" - elif (dependence == "dx" or dependence == "dy"): - return "(50,-0.10,0.10)" - elif dependence == "dz": - return "(50,-0.5,0.5)" - elif "err" in dependence or "pull" in dependence: - return "(50,-3.5,3.5)" - else: - return "(66,4,70)" - - -def get_x_axis(dependence): - if dependence == "zMC": - return "z [mm]" - elif dependence == "rMC": - return "radial distance [mm]" - else: - return "number of tracks in Primary Vertex" - - -def get_eff(eff, hist, trees, dependence, colors, markers, smog, categories, - label): - - hist_range = get_range(dependence, smog) +def get_eff(eff, hist, trees, dependence, style, ranges, categories, label): for cat in categories: eff[cat] = {} hist[cat] = {} i = 0 for lab in label: - var_den = '{dependence}>>hist{code}_{dep}_{cat}_{lab}{hist_range}'.format( + var_den = '{dependence}>>hist{code}_{dep}_{cat}_{lab}({bins},{mins},{maxs})'.format( dependence=dependence, code="den", dep=dependence, cat=cat, lab=lab, - hist_range=hist_range) - var_nom = '{dependence}>>hist{code}_{dep}_{cat}_{lab}{hist_range}'.format( + bins=ranges[dependence]["bins"], + mins=ranges[dependence]["min"], + maxs=ranges[dependence]["max"]) + var_nom = '{dependence}>>hist{code}_{dep}_{cat}_{lab}({bins},{mins},{maxs})'.format( dependence=dependence, code="nom", dep=dependence, cat=cat, lab=lab, - hist_range=hist_range) + bins=ranges[dependence]["bins"], + mins=ranges[dependence]["min"], + maxs=ranges[dependence]["max"]) - cut_den = 'nrectrmc>=4 {cuts}'.format(cuts=categories[cat]["cut"]) + cut_den = 'nrectrmc>=4 && dz < 2.0 {cuts}'.format(cuts=categories[cat]["cut"]) cut_nom = cut_den + ' && reco == 1' trees[lab].Draw(var_nom, cut_nom) @@ -142,47 +89,42 @@ def get_eff(eff, hist, trees, dependence, colors, markers, smog, categories, g_eff = TGraphAsymmErrors() g_eff.Divide(h_nom, h_den, "cl=0.683 b(1,1) mode") - set_style(h_nom, colors[i] - 8, markers[i], get_x_axis(dependence), + set_style(h_nom, style["color"][i] - 8, style["marker"][i], get_x_axis(dependence), "Efficiency", "") - set_style(h_den, kGray, markers[i], get_x_axis(dependence), + set_style(h_den, kGray, style["marker"][i], get_x_axis(dependence), "Efficiency", "") hist[cat][lab] = {} hist[cat][lab]["nom"] = h_nom hist[cat][lab]["den"] = h_den - set_style(g_eff, colors[i], markers[i], get_x_axis(dependence), + set_style(g_eff, style["color"][i], style["marker"][i], get_x_axis(dependence), "Efficiency", "") - eff[cat][lab] = g_eff + eff[cat][lab] = {} + eff[cat][lab]["eff"] = g_eff i += 1 return eff, hist - -def set_legend(legend, label, gr, hist, dist): - legend.SetTextSize(0.04) - legend.SetTextFont(12) - legend.SetFillColor(4000) - legend.SetShadowColor(0) - legend.SetBorderSize(0) - legend.SetTextFont(132) - legend.SetNColumns(2) - #legend.SetHeader("LHCb Preliminary"); +def find_max(gr, gr_type, label): + m = -999999.0 for lab in label: - legend.AddEntry(gr["all"][lab], "Efficiency {lab}".format(lab=lab), - "lep") - if dist: - legend.AddEntry(hist["all"][label[0]]["den"], "Distribution MC", "f") - for lab in label: - legend.AddEntry(hist["all"][lab]["nom"], - "Distribution {lab}".format(lab=lab), "f") + if ( gr[lab][gr_type].GetYaxis().GetXmax() > m ): + m = gr[lab][gr_type].GetYaxis().GetXmax() - return legend + return m +def find_min(gr, gr_type, label): + m =999999.0 + for lab in label: + if ( gr[lab][gr_type].GetYaxis().GetXmin() < m ): + m = gr[lab][gr_type].GetYaxis().GetXmin() + return m + -def plot_eff(eff, hist, prefix, dependence, categories, label, legend, dist): +def plot(gr, gr_type, prefix, dependence, categories, label, legend=None, hist=None, dist=False): for cat in categories: - can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence, cat=cat), + can = TCanvas('canvas_{depen}_{prefix}_{gr_type}_{cat}'.format(depen=dependence, prefix=prefix, gr_type=gr_type, cat=cat), "cR", 1200, 800) can.SetBottomMargin(0.15) can.SetLeftMargin(0.12) @@ -192,11 +134,20 @@ def plot_eff(eff, hist, prefix, dependence, categories, label, legend, dist): can.SetRightMargin(0.05) can.cd() - eff[cat][label[0]].GetYaxis().SetRangeUser(0.0, 1.1) - eff[cat][label[0]].Draw("AP") + maximum = find_max(gr[cat],gr_type,label) + minimum = find_min(gr[cat],gr_type,label) + if ( abs(maximum) > abs(minimum) and minimum<0): + minimum = -maximum + + gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser(minimum*1.1, maximum*1.1) + if ( gr_type == "eff" ): + gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser(0.0, 1.1) + if ( gr_type == "sigma"): + gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser(0.0, maximum*1.1) + gr[cat][label[0]][gr_type].Draw("AP") for lab in label: - eff[cat][lab].Draw("SAME P") + gr[cat][lab][gr_type].Draw("SAME P") if dist: histmax_den = 1.1 * hist[cat][label[0]]["den"].GetMaximum() @@ -210,54 +161,47 @@ def plot_eff(eff, hist, prefix, dependence, categories, label, legend, dist): hist[cat][lab]["nom"].Scale(scale * 0.75) hist[cat][lab]["nom"].Draw("SAME") - eff[cat][lab].Draw("SAME P") + gr[cat][lab][gr_type].Draw("SAME P") - legend.Draw("SAME") + if legend: + legend.Draw("SAME") saveName = '{prefix}_{dependence}_{cat}.pdf'.format( prefix=prefix, dependence=dependence, cat=cat) can.SaveAs(saveName) -def transfer_dependence(dep): - if dep == "pullx": - return "dx/errx" - elif dep == "pully": - return "dy/erry" - elif dep == "pullz": - return "dz/errz" - else: - return dep - -def get_global(hist, trees, dependence, x_axis, y_axis, colors, markers, +def get_global(hist, trees, dependence, x_axis, y_axis, style, ranges, categories, label): - hist_range = get_range(dependence, False) - dep = transfer_dependence(dependence) + dep = transfer_variable(dependence) for cat in categories: hist[cat] = {} i = 0 for lab in label: - var = '{dependence}>>hist_{dep}_{cat}_{lab}{hist_range}'.format( + var = '{dependence}>>hist_{dep}_{cat}_{lab}({bins},{mins},{maxs})'.format( dependence=dep, dep=dependence, cat=cat, lab=lab, - hist_range=hist_range) + bins=ranges[dependence]["bins"], + mins=ranges[dependence]["min"], + maxs=ranges[dependence]["max"] + ) - cut = 'nrectrmc>=4 && reco == 1 {cuts}'.format( + cut = 'nrectrmc>=4 && dz < 2.0 && reco == 1 {cuts}'.format( cuts=categories[cat]["cut"]) trees[lab].Draw(var, cut) h = gDirectory.Get('hist_{dep}_{cat}_{lab}'.format( dep=dependence, cat=cat, lab=lab)) if i == 0: - col = colors[i] - 10 + col = style["color"][i] - 10 else: - col = colors[i] - set_style(h, col, markers[i], x_axis, y_axis, "") + col = style["color"][i] + set_style(h, col, style["marker"][i], x_axis, y_axis, "") hist[cat][lab] = h i += 1 @@ -265,19 +209,17 @@ def get_global(hist, trees, dependence, x_axis, y_axis, colors, markers, return hist -def get_text_cor(): - return {"x": [0.17, 0.65, 0.17, 0.65], "y": [0.92, 0.92, 0.75, 0.75]} - - def set_text(text, color, x, y, lab, mean, mean_err, rms, rms_err, scale, units): s = 1.0 if scale: s = 1000.0 - u = "" + ur = "" + um = "#times 10^{-3}" if units: - u = "[#mu m]" + ur = "[#mu m]" + um = "[#mu m]" text.SetNDC() text.SetTextFont(132) @@ -285,15 +227,15 @@ def set_text(text, color, x, y, lab, mean, mean_err, rms, rms_err, scale, text.DrawLatex(x, y * 1.0, lab) text.DrawLatex( - x, y * 0.95, "#mu = {0:0.2f} #pm {1:0.2f} {unit}".format( - mean * 1000.0, mean_err * 1000.0, unit=u)) + x, y * 0.95, "#mu = ({0:0.2f} #pm {1:0.2f}) {unit}".format( + mean * 1000.0, mean_err * 1000.0, unit=um)) text.DrawLatex( - x, y * 0.90, "#sigma = {0:0.2f} #pm {1:0.2f} {unit}".format( - rms * s, rms_err * s, unit=u)) + x, y * 0.90, "#sigma = ({0:0.2f} #pm {1:0.2f}) {unit}".format( + rms * s, rms_err * s, unit=ur)) return text -def plot_comparison(hist, prefix, dependence, categories, label, colors, norm): +def plot_comparison(hist, prefix, dependence, categories, label, style, norm): for cat in categories: can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence, cat=cat), @@ -320,7 +262,7 @@ def plot_comparison(hist, prefix, dependence, categories, label, colors, norm): for lab in label: hist[cat][lab].DrawNormalized("SAME PE") text = TLatex() - text = set_text(text, colors[i], cor["x"][i], cor["y"][i], lab, + text = set_text(text, style["color"][i], cor["x"][i], cor["y"][i], lab, hist[cat][lab].GetMean(), hist[cat][lab].GetMeanError(), hist[cat][lab].GetRMS(), @@ -336,3 +278,105 @@ def plot_comparison(hist, prefix, dependence, categories, label, colors, norm): saveName = '{prefix}_{dependence}_{cat}.pdf'.format( prefix=prefix, dependence=dependence, cat=cat) can.SaveAs(saveName) + + +def get_robust_sigma(hist, resol): + + y = array('d',[0.]*3) + x = array('d',[0.]*3) + x[0] = 0.25 + x[1] = 0.50 + x[2] = 0.75 + + hist.GetQuantiles(3, y, x) + + _median = y[1] + _approxstdev = (y[2] - y[0]) / 1.34898; #factor gives correspondence between IQR and stdev for a Gaussian + mult = 4.0 + + histclone = hist.Clone() + nb = histclone.GetNbinsX() + + for i in range(1,nb+1): + if ((histclone.GetBinCenter(i) < (_median - _approxstdev * mult)) or (histclone.GetBinCenter(i) > (_median + _approxstdev * mult))): + histclone.SetBinContent(i, 0) + + if resol: + robustsigma = {"sigma": {"var":histclone.GetRMS()*1000.0, "err":histclone.GetRMSError()*1000.0}, + "mean": {"var":histclone.GetMean()*1000.0, "err":histclone.GetMeanError()*1000.0}} + + else: + robustsigma = {"sigma": {"var":histclone.GetRMS()*1.0, "err":histclone.GetRMSError()*1.0}, + "mean": {"var":histclone.GetMean(), "err":histclone.GetMeanError()}} + + return robustsigma; + +def get_dependence(graph, trees, variable, dependence, ranges, style, categories, label): + + var = transfer_variable(variable) + bin_width = (ranges[dependence]["max"]-ranges[dependence]["min"])/ranges[dependence]["bins"] + + resol = True + mean = "Mean [#mu m]" + if "pull" in variable: + resol = False + mean = "Mean" + + for cat in categories: + graph[cat] = {} + i = 0 + for lab in label: + graph[cat][lab] = {} + graph_rms = TGraphAsymmErrors(ranges[dependence]["bins"]) + graph_mean = TGraphAsymmErrors(ranges[dependence]["bins"]) + + bin_min = ranges[dependence]["min"] + for b in range(0,ranges[dependence]["bins"]): + + cut_bin = '{variable1}>={mins} && {variable2}<{maxs}'.format( + variable1 = dependence, + mins = bin_min, + variable2 = dependence, + maxs = bin_min+bin_width) + + hist_string = '{dependence}>>hist_{dep}_{cat}_{lab}_{number}'.format( + dependence=var, + dep=variable, + cat=cat, + lab=lab, + number=int(b), + ) + + cut = '{basic} && reco == 1 && {bin_cut} {cuts}'.format( + basic = basic_cut(), + bin_cut = cut_bin, + cuts=categories[cat]["cut"]) + + + a = trees[lab].Draw(hist_string, cut) + + bin_min += bin_width + + h = gDirectory.Get('hist_{dep}_{cat}_{lab}_{number}'.format( + dep=variable, + cat=cat, + lab=lab, + number=int(b) )) + + robust_sigma = get_robust_sigma(h, resol) + + graph_mean.SetPoint(b, bin_min+bin_width/2.0, robust_sigma["mean"]["var"]) + graph_mean.SetPointError(b, bin_width/2.0, bin_width/2.0, robust_sigma["mean"]["err"],robust_sigma["mean"]["err"]) + + graph_rms.SetPoint(b, bin_min+bin_width/2.0, robust_sigma["sigma"]["var"]) + graph_rms.SetPointError(b, bin_width/2.0, bin_width/2.0, robust_sigma["sigma"]["err"],robust_sigma["sigma"]["err"]) + + set_style(graph_rms, style["color"][i], style["marker"][i], get_x_axis(dependence), get_y_axis(variable), "") + set_style(graph_mean, style["color"][i], style["marker"][i], get_x_axis(dependence), mean, "") + + graph[cat][lab]["sigma"] = graph_rms + graph[cat][lab]["mean"] = graph_mean + i+=1 + + + return graph -- GitLab From 3e137afa1ecdf95fea7e8b457dc1d770716cdc66 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 5 Mar 2020 10:34:53 +0000 Subject: [PATCH 111/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7460832 --- .../scripts/PrimaryVertexCheckerEfficiency.py | 43 ++-- .../scripts/PrimaryVertexCheckerPull.py | 74 ++++--- .../scripts/PrimaryVertexCheckerResolution.py | 82 ++++---- Hlt/RecoConf/scripts/utils/pvconfig.py | 126 ++++++++---- Hlt/RecoConf/scripts/utils/pvutils.py | 185 +++++++++++------- 5 files changed, 316 insertions(+), 194 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py index 05ee126647e..a8870f7bcfa 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py @@ -78,7 +78,6 @@ parser.add_argument( ) - def get_labels(number_of_files): label = [] for i in range(0, number_of_files): @@ -95,7 +94,7 @@ if __name__ == '__main__': from pvutils import get_default_tree_name from pvutils import get_files, get_trees, get_eff, plot - + from pvconfig import get_variable_ranges from pvconfig import get_style, get_categories from pvconfig import set_legend @@ -112,32 +111,36 @@ if __name__ == '__main__': tf = get_files(tf, label, args.fileName) tr = get_trees(tf, tr, label, args.treeName, True) - eff = {} + eff = {} eff["tracks"] = {} - eff["z"] = {} - eff["r"] = {} + eff["z"] = {} + eff["r"] = {} hist = {} hist["tracks"] = {} - hist["z"]={} - hist["r"]={} - + hist["z"] = {} + hist["r"] = {} + cat = get_categories(args.multi, args.smog) - eff["tracks"], hist["tracks"] = get_eff(eff["tracks"], hist["tracks"], tr, "nrectrmc", style, - ranges, cat, label) - eff["z"], hist["z"] = get_eff(eff["z"], hist["z"], tr, "zMC", style, - ranges, cat, label) - eff["r"], hist["r"] = get_eff(eff["r"], hist["r"], tr, "rMC", style, - ranges, cat, label) + eff["tracks"], hist["tracks"] = get_eff(eff["tracks"], hist["tracks"], tr, + "nrectrmc", style, ranges, cat, + label) + eff["z"], hist["z"] = get_eff(eff["z"], hist["z"], tr, "zMC", style, + ranges, cat, label) + eff["r"], hist["r"] = get_eff(eff["r"], hist["r"], tr, "rMC", style, + ranges, cat, label) if args.dist: legend = TLegend(0.15, 0.82, 0.88, 0.98) else: legend = TLegend(0.15, 0.86, 0.88, 0.98) - legend = set_legend(legend, label, eff["tracks"], "eff", hist["z"], args.dist) - - - plot(eff["tracks"], "eff", args.prefix, "ntracks", cat, label, legend, hist["tracks"], args.dist) - plot(eff["z"], "eff", args.prefix, "z", cat, label, legend, hist["z"], args.dist) - plot(eff["r"], "eff", args.prefix, "r", cat, label, legend, hist["r"], args.dist) + legend = set_legend(legend, label, eff["tracks"], "eff", hist["z"], + args.dist) + + plot(eff["tracks"], "eff", args.prefix, "ntracks", cat, label, legend, + hist["tracks"], args.dist) + plot(eff["z"], "eff", args.prefix, "z", cat, label, legend, hist["z"], + args.dist) + plot(eff["r"], "eff", args.prefix, "r", cat, label, legend, hist["r"], + args.dist) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py index 5c06da4eb87..6b6b2f7532d 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py @@ -100,11 +100,11 @@ if __name__ == '__main__': from pvconfig import get_variable_ranges from pvconfig import get_style, get_categories - from pvconfig import get_y_axis + from pvconfig import get_y_axis ranges = get_variable_ranges(args.smog) style = get_style() - + cat = get_categories(args.multi, args.smog) label = args.label if args.label == "": @@ -130,48 +130,64 @@ if __name__ == '__main__': plot_comparison(hist_y, args.prefix, "pully", cat, label, style, norm) plot_comparison(hist_z, args.prefix, "pullz", cat, label, style, norm) - from ROOT import gEnv - gEnv.SetValue("Hist.Binning.1D.x","100") - + gEnv.SetValue("Hist.Binning.1D.x", "100") graph = {} graph["tracks"] = {} graph["tracks"]["pullx"] = {} graph["tracks"]["pully"] = {} graph["tracks"]["pullz"] = {} - graph["tracks"]["pullx"] = get_dependence(graph["tracks"]["pullx"], tr, "pullx", "nrectrmc", ranges, style, cat, label) - graph["tracks"]["pully"] = get_dependence(graph["tracks"]["pully"], tr, "pully", "nrectrmc", ranges, style, cat, label) - graph["tracks"]["pullz"] = get_dependence(graph["tracks"]["pullz"], tr, "pullz", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["pullx"] = get_dependence(graph["tracks"]["pullx"], tr, + "pullx", "nrectrmc", ranges, + style, cat, label) + graph["tracks"]["pully"] = get_dependence(graph["tracks"]["pully"], tr, + "pully", "nrectrmc", ranges, + style, cat, label) + graph["tracks"]["pullz"] = get_dependence(graph["tracks"]["pullz"], tr, + "pullz", "nrectrmc", ranges, + style, cat, label) legend = TLegend(0.15, 0.86, 0.88, 0.98) legend = set_legend(legend, label, graph["tracks"]["pullz"], "sigma") - plot(graph["tracks"]["pullx"], "mean", args.prefix+"_ntracks_mean", "pullx", cat, label, legend) - plot(graph["tracks"]["pullx"], "sigma", args.prefix+"_ntracks_sigma", "pullx", cat, label, legend) + plot(graph["tracks"]["pullx"], "mean", args.prefix + "_ntracks_mean", + "pullx", cat, label, legend) + plot(graph["tracks"]["pullx"], "sigma", args.prefix + "_ntracks_sigma", + "pullx", cat, label, legend) - plot(graph["tracks"]["pully"], "mean", args.prefix+"_ntracks_mean", "pully", cat, label, legend) - plot(graph["tracks"]["pully"], "sigma", args.prefix+"_ntracks_sigma", "pully", cat, label, legend) - - plot(graph["tracks"]["pullz"], "mean", args.prefix+"_ntracks_mean", "pullz", cat, label, legend) - plot(graph["tracks"]["pullz"], "sigma", args.prefix+"_ntracks_sigma", "pullz", cat, label, legend) + plot(graph["tracks"]["pully"], "mean", args.prefix + "_ntracks_mean", + "pully", cat, label, legend) + plot(graph["tracks"]["pully"], "sigma", args.prefix + "_ntracks_sigma", + "pully", cat, label, legend) + plot(graph["tracks"]["pullz"], "mean", args.prefix + "_ntracks_mean", + "pullz", cat, label, legend) + plot(graph["tracks"]["pullz"], "sigma", args.prefix + "_ntracks_sigma", + "pullz", cat, label, legend) graph["z"] = {} graph["z"]["pullx"] = {} graph["z"]["pully"] = {} graph["z"]["pullz"] = {} - graph["z"]["pullx"] = get_dependence(graph["z"]["pullx"], tr, "pullx", "zMC", ranges, style, cat, label) - graph["z"]["pully"] = get_dependence(graph["z"]["pully"], tr, "pully", "zMC", ranges, style, cat, label) - graph["z"]["pullz"] = get_dependence(graph["z"]["pullz"], tr, "pullz", "zMC", ranges, style, cat, label) - - plot(graph["z"]["pullx"], "mean", args.prefix+"_z_mean", "pullx", cat, label, legend) - plot(graph["z"]["pullx"], "sigma", args.prefix+"_z_sigma", "pullx", cat, label, legend) - - plot(graph["z"]["pully"], "mean", args.prefix+"_z_mean", "pully", cat, label, legend) - plot(graph["z"]["pully"], "sigma", args.prefix+"_z_sigma", "pully", cat, label, legend) - - plot(graph["z"]["pullz"], "mean", args.prefix+"_z_mean", "pullz", cat, label, legend) - plot(graph["z"]["pullz"], "sigma", args.prefix+"_z_sigma", "pullz", cat, label, legend) - - + graph["z"]["pullx"] = get_dependence(graph["z"]["pullx"], tr, "pullx", + "zMC", ranges, style, cat, label) + graph["z"]["pully"] = get_dependence(graph["z"]["pully"], tr, "pully", + "zMC", ranges, style, cat, label) + graph["z"]["pullz"] = get_dependence(graph["z"]["pullz"], tr, "pullz", + "zMC", ranges, style, cat, label) + + plot(graph["z"]["pullx"], "mean", args.prefix + "_z_mean", "pullx", cat, + label, legend) + plot(graph["z"]["pullx"], "sigma", args.prefix + "_z_sigma", "pullx", cat, + label, legend) + + plot(graph["z"]["pully"], "mean", args.prefix + "_z_mean", "pully", cat, + label, legend) + plot(graph["z"]["pully"], "sigma", args.prefix + "_z_sigma", "pully", cat, + label, legend) + + plot(graph["z"]["pullz"], "mean", args.prefix + "_z_mean", "pullz", cat, + label, legend) + plot(graph["z"]["pullz"], "sigma", args.prefix + "_z_sigma", "pullz", cat, + label, legend) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py index 119963274c0..7a753cf251e 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py @@ -95,21 +95,20 @@ if __name__ == '__main__': from pvutils import get_default_tree_name from pvutils import get_files, get_trees from pvutils import set_legend, get_global, plot_comparison - from pvutils import get_dependence - from pvutils import plot + from pvutils import get_dependence + from pvutils import plot from pvconfig import get_variable_ranges from pvconfig import get_style, get_categories - ranges = get_variable_ranges(args.smog) + ranges = get_variable_ranges(args.smog) style = get_style() - + cat = get_categories(args.multi, args.smog) label = args.label if args.label == "": label = get_labels(len(args.fileName)) - tr = {} tf = {} tf = get_files(tf, label, args.fileName) @@ -120,59 +119,72 @@ if __name__ == '__main__': hist_z = {} norm = True - hist_x = get_global(hist_x, tr, "dx", "#Delta x [mm]", "Candidates Normalized", style, ranges, cat, label) hist_y = get_global(hist_y, tr, "dy", "#Delta y [mm]", "Candidates Normalized", style, ranges, cat, label) hist_z = get_global(hist_z, tr, "dz", "#Delta z [mm]", "Candidates Normalized", style, ranges, cat, label) - + plot_comparison(hist_x, args.prefix, "dx", cat, label, style, norm) plot_comparison(hist_y, args.prefix, "dy", cat, label, style, norm) plot_comparison(hist_z, args.prefix, "dz", cat, label, style, norm) - from ROOT import gEnv - gEnv.SetValue("Hist.Binning.1D.x","100") - + gEnv.SetValue("Hist.Binning.1D.x", "100") + graph = {} graph["tracks"] = {} graph["tracks"]["dx"] = {} graph["tracks"]["dy"] = {} graph["tracks"]["dz"] = {} - graph["tracks"]["dx"] = get_dependence(graph["tracks"]["dx"], tr, "dx", "nrectrmc", ranges, style, cat, label) - graph["tracks"]["dy"] = get_dependence(graph["tracks"]["dy"], tr, "dy", "nrectrmc", ranges, style, cat, label) - graph["tracks"]["dz"] = get_dependence(graph["tracks"]["dz"], tr, "dz", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["dx"] = get_dependence( + graph["tracks"]["dx"], tr, "dx", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["dy"] = get_dependence( + graph["tracks"]["dy"], tr, "dy", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["dz"] = get_dependence( + graph["tracks"]["dz"], tr, "dz", "nrectrmc", ranges, style, cat, label) legend = TLegend(0.15, 0.86, 0.88, 0.98) - legend = set_legend(legend, label, graph["tracks"]["dz"], "sigma") + legend = set_legend(legend, label, graph["tracks"]["dz"], "sigma") - plot(graph["tracks"]["dx"], "mean", args.prefix+"_ntracks_mean", "dx", cat, label, legend) - plot(graph["tracks"]["dx"], "sigma", args.prefix+"_ntracks_sigma", "dx", cat, label, legend) - - plot(graph["tracks"]["dy"], "mean", args.prefix+"_ntracks_mean", "dy", cat, label, legend) - plot(graph["tracks"]["dy"], "sigma", args.prefix+"_ntracks_sigma", "dy", cat, label, legend) + plot(graph["tracks"]["dx"], "mean", args.prefix + "_ntracks_mean", "dx", + cat, label, legend) + plot(graph["tracks"]["dx"], "sigma", args.prefix + "_ntracks_sigma", "dx", + cat, label, legend) - plot(graph["tracks"]["dz"], "mean", args.prefix+"_ntracks_mean", "dz", cat, label, legend) - plot(graph["tracks"]["dz"], "sigma", args.prefix+"_ntracks_sigma", "dz", cat, label, legend) + plot(graph["tracks"]["dy"], "mean", args.prefix + "_ntracks_mean", "dy", + cat, label, legend) + plot(graph["tracks"]["dy"], "sigma", args.prefix + "_ntracks_sigma", "dy", + cat, label, legend) + plot(graph["tracks"]["dz"], "mean", args.prefix + "_ntracks_mean", "dz", + cat, label, legend) + plot(graph["tracks"]["dz"], "sigma", args.prefix + "_ntracks_sigma", "dz", + cat, label, legend) graph["z"] = {} graph["z"]["dx"] = {} graph["z"]["dy"] = {} graph["z"]["dz"] = {} - graph["z"]["dx"] = get_dependence(graph["z"]["dx"], tr, "dx", "zMC", ranges, style, cat, label) - graph["z"]["dy"] = get_dependence(graph["z"]["dy"], tr, "dy", "zMC", ranges, style, cat, label) - graph["z"]["dz"] = get_dependence(graph["z"]["dz"], tr, "dz", "zMC", ranges, style, cat, label) - - plot(graph["z"]["dx"], "mean", args.prefix+"_z_mean", "dx", cat, label, legend) - plot(graph["z"]["dx"], "sigma", args.prefix+"_z_sigma", "dx", cat, label, legend) - - plot(graph["z"]["dy"], "mean", args.prefix+"_z_mean", "dy", cat, label, legend) - plot(graph["z"]["dy"], "sigma", args.prefix+"_z_sigma", "dy", cat, label, legend) - - plot(graph["z"]["dz"], "mean", args.prefix+"_z_mean", "dz", cat, label, legend) - plot(graph["z"]["dz"], "sigma", args.prefix+"_z_sigma", "dz", cat, label, legend) - - + graph["z"]["dx"] = get_dependence(graph["z"]["dx"], tr, "dx", "zMC", + ranges, style, cat, label) + graph["z"]["dy"] = get_dependence(graph["z"]["dy"], tr, "dy", "zMC", + ranges, style, cat, label) + graph["z"]["dz"] = get_dependence(graph["z"]["dz"], tr, "dz", "zMC", + ranges, style, cat, label) + + plot(graph["z"]["dx"], "mean", args.prefix + "_z_mean", "dx", cat, label, + legend) + plot(graph["z"]["dx"], "sigma", args.prefix + "_z_sigma", "dx", cat, label, + legend) + + plot(graph["z"]["dy"], "mean", args.prefix + "_z_mean", "dy", cat, label, + legend) + plot(graph["z"]["dy"], "sigma", args.prefix + "_z_sigma", "dy", cat, label, + legend) + + plot(graph["z"]["dz"], "mean", args.prefix + "_z_mean", "dz", cat, label, + legend) + plot(graph["z"]["dz"], "sigma", args.prefix + "_z_sigma", "dz", cat, label, + legend) diff --git a/Hlt/RecoConf/scripts/utils/pvconfig.py b/Hlt/RecoConf/scripts/utils/pvconfig.py index 0b7f6890670..aa85884257c 100644 --- a/Hlt/RecoConf/scripts/utils/pvconfig.py +++ b/Hlt/RecoConf/scripts/utils/pvconfig.py @@ -13,12 +13,13 @@ from ROOT import TH1F, TLegend from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow + def get_categories(multi, smog): cut = {} cut["all"] = {"cut": ""} -# cut["isolated"] = {"cut": "&&isol==1"} -# if not smog: -# cut["close"] = {"cut": "&&isol==0"} + # cut["isolated"] = {"cut": "&&isol==1"} + # if not smog: + # cut["close"] = {"cut": "&&isol==0"} if multi: cut["1st"] = {"cut": "&&multimc==1"} cut["2nd"] = {"cut": "&&multimc==2"} @@ -30,8 +31,11 @@ def get_categories(multi, smog): def get_style(): - return {"color" :[kRed, kBlue, kOrange, kMagenta, kGreen, kCyan], - "marker":[21, 20, 22, 23, 24, 25 ]} + return { + "color": [kRed, kBlue, kOrange, kMagenta, kGreen, kCyan], + "marker": [21, 20, 22, 23, 24, 25] + } + def get_default_tree_name(is_checker): if is_checker: @@ -39,45 +43,94 @@ def get_default_tree_name(is_checker): else: return "VertexCompare/102" + def transfer_variable(dep): - dictionary = {"pullx":"dx/errx", - "pully":"dy/erry", - "pullz":"dz/errz", - "dx":"dx", - "dy":"dy", - "dz":"dz", } + dictionary = { + "pullx": "dx/errx", + "pully": "dy/erry", + "pullz": "dz/errz", + "dx": "dx", + "dy": "dy", + "dz": "dz", + } return dictionary[dep] + def get_variable_ranges(smog): - dictionary = {"zMC" :{"bins":50, "min":-200, "max":200}, - "rMC" :{"bins":50, "min":0.0, "max":0.2}, - "dx" :{"bins":50, "min":-0.10, "max":0.10}, - "dy" :{"bins":50, "min":-0.10, "max":0.10}, - "dz" :{"bins":50, "min":-0.40, "max":0.40}, - "pullx" :{"bins":50, "min":-3.50, "max":3.50}, - "pully" :{"bins":50, "min":-3.50, "max":3.50}, - "pullz" :{"bins":50, "min":-3.50, "max":3.50}, - "nrectrmc":{"bins":66, "min":4.0, "max":70.0}} + dictionary = { + "zMC": { + "bins": 50, + "min": -200, + "max": 200 + }, + "rMC": { + "bins": 50, + "min": 0.0, + "max": 0.2 + }, + "dx": { + "bins": 50, + "min": -0.10, + "max": 0.10 + }, + "dy": { + "bins": 50, + "min": -0.10, + "max": 0.10 + }, + "dz": { + "bins": 50, + "min": -0.40, + "max": 0.40 + }, + "pullx": { + "bins": 50, + "min": -3.50, + "max": 3.50 + }, + "pully": { + "bins": 50, + "min": -3.50, + "max": 3.50 + }, + "pullz": { + "bins": 50, + "min": -3.50, + "max": 3.50 + }, + "nrectrmc": { + "bins": 66, + "min": 4.0, + "max": 70.0 + } + } if smog: - dictionary["zMC"] = {"bins":100,"min":-500, "max":200} - + dictionary["zMC"] = {"bins": 100, "min": -500, "max": 200} + return dictionary + def get_y_axis(dependence): - dictionary = {"dx":"Resolution #Delta x [#mu m]", - "dy":"Resolution #Delta y [#mu m]", - "dz":"Resolution #Delta z [#mu m]", - "pullx":"Pull #Delta x/#sigma_{x}", - "pully":"Pull #Delta y/#sigma_{y}", - "pullz":"Pull #Delta z/#sigma_{z}"} + dictionary = { + "dx": "Resolution #Delta x [#mu m]", + "dy": "Resolution #Delta y [#mu m]", + "dz": "Resolution #Delta z [#mu m]", + "pullx": "Pull #Delta x/#sigma_{x}", + "pully": "Pull #Delta y/#sigma_{y}", + "pullz": "Pull #Delta z/#sigma_{z}" + } return dictionary[dependence] + def get_x_axis(dependence): - dictionary= {"zMC":"z [mm]", - "rMC":"radial distance [mm]", - "nrectrmc":"number of tracks in Primary Vertex"} + dictionary = { + "zMC": "z [mm]", + "rMC": "radial distance [mm]", + "nrectrmc": "number of tracks in Primary Vertex" + } return dictionary[dependence] + def set_style(graph, color, marker, xaxis, yaxis, title): graph.SetTitle("") graph.SetLineColor(color) @@ -106,8 +159,8 @@ def set_style(graph, color, marker, xaxis, yaxis, title): if yaxis != "": graph.GetYaxis().SetTitle(yaxis) -def set_legend(legend, label, gr, gr_type, - hist = None, dist = False): + +def set_legend(legend, label, gr, gr_type, hist=None, dist=False): legend.SetTextSize(0.04) legend.SetTextFont(12) legend.SetFillColor(4000) @@ -126,11 +179,10 @@ def set_legend(legend, label, gr, gr_type, return legend + def get_text_cor(): - return {"x": [0.17, 0.65, 0.17, 0.65], - "y": [0.92, 0.92, 0.75, 0.75]} + return {"x": [0.17, 0.65, 0.17, 0.65], "y": [0.92, 0.92, 0.75, 0.75]} - def basic_cut(): - return "nrectrmc>=4 && dz < 2.0" + return "nrectrmc>=4 && dz < 2.0" diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py index d734f3e7a62..5065d911ddf 100644 --- a/Hlt/RecoConf/scripts/utils/pvutils.py +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -20,7 +20,7 @@ from ROOT import TCanvas from ROOT import TGraphErrors, TLegend from ROOT import gPad, kGray, TLatex -from pvconfig import get_default_tree_name +from pvconfig import get_default_tree_name from pvconfig import transfer_variable from pvconfig import get_x_axis, get_y_axis from pvconfig import set_style @@ -30,6 +30,7 @@ from pvconfig import basic_cut from array import array + def get_files(tf, label, files): i = 0 for f in files: @@ -75,7 +76,8 @@ def get_eff(eff, hist, trees, dependence, style, ranges, categories, label): mins=ranges[dependence]["min"], maxs=ranges[dependence]["max"]) - cut_den = 'nrectrmc>=4 && dz < 2.0 {cuts}'.format(cuts=categories[cat]["cut"]) + cut_den = 'nrectrmc>=4 && dz < 2.0 {cuts}'.format( + cuts=categories[cat]["cut"]) cut_nom = cut_den + ' && reco == 1' trees[lab].Draw(var_nom, cut_nom) @@ -89,43 +91,55 @@ def get_eff(eff, hist, trees, dependence, style, ranges, categories, label): g_eff = TGraphAsymmErrors() g_eff.Divide(h_nom, h_den, "cl=0.683 b(1,1) mode") - set_style(h_nom, style["color"][i] - 8, style["marker"][i], get_x_axis(dependence), - "Efficiency", "") + set_style(h_nom, style["color"][i] - 8, style["marker"][i], + get_x_axis(dependence), "Efficiency", "") set_style(h_den, kGray, style["marker"][i], get_x_axis(dependence), "Efficiency", "") hist[cat][lab] = {} hist[cat][lab]["nom"] = h_nom hist[cat][lab]["den"] = h_den - set_style(g_eff, style["color"][i], style["marker"][i], get_x_axis(dependence), - "Efficiency", "") - eff[cat][lab] = {} + set_style(g_eff, style["color"][i], style["marker"][i], + get_x_axis(dependence), "Efficiency", "") + eff[cat][lab] = {} eff[cat][lab]["eff"] = g_eff i += 1 return eff, hist + def find_max(gr, gr_type, label): m = -999999.0 for lab in label: - if ( gr[lab][gr_type].GetYaxis().GetXmax() > m ): + if (gr[lab][gr_type].GetYaxis().GetXmax() > m): m = gr[lab][gr_type].GetYaxis().GetXmax() - return m + return m + def find_min(gr, gr_type, label): - m =999999.0 + m = 999999.0 for lab in label: - if ( gr[lab][gr_type].GetYaxis().GetXmin() < m ): + if (gr[lab][gr_type].GetYaxis().GetXmin() < m): m = gr[lab][gr_type].GetYaxis().GetXmin() return m - -def plot(gr, gr_type, prefix, dependence, categories, label, legend=None, hist=None, dist=False): + +def plot(gr, + gr_type, + prefix, + dependence, + categories, + label, + legend=None, + hist=None, + dist=False): for cat in categories: - can = TCanvas('canvas_{depen}_{prefix}_{gr_type}_{cat}'.format(depen=dependence, prefix=prefix, gr_type=gr_type, cat=cat), - "cR", 1200, 800) + can = TCanvas( + 'canvas_{depen}_{prefix}_{gr_type}_{cat}'.format( + depen=dependence, prefix=prefix, gr_type=gr_type, cat=cat), + "cR", 1200, 800) can.SetBottomMargin(0.15) can.SetLeftMargin(0.12) can.SetTopMargin(0.15) @@ -134,16 +148,18 @@ def plot(gr, gr_type, prefix, dependence, categories, label, legend=None, hist=N can.SetRightMargin(0.05) can.cd() - maximum = find_max(gr[cat],gr_type,label) - minimum = find_min(gr[cat],gr_type,label) - if ( abs(maximum) > abs(minimum) and minimum<0): + maximum = find_max(gr[cat], gr_type, label) + minimum = find_min(gr[cat], gr_type, label) + if (abs(maximum) > abs(minimum) and minimum < 0): minimum = -maximum - - gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser(minimum*1.1, maximum*1.1) - if ( gr_type == "eff" ): + + gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser( + minimum * 1.1, maximum * 1.1) + if (gr_type == "eff"): gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser(0.0, 1.1) - if ( gr_type == "sigma"): - gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser(0.0, maximum*1.1) + if (gr_type == "sigma"): + gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser( + 0.0, maximum * 1.1) gr[cat][label[0]][gr_type].Draw("AP") for lab in label: @@ -171,7 +187,6 @@ def plot(gr, gr_type, prefix, dependence, categories, label, legend=None, hist=N can.SaveAs(saveName) - def get_global(hist, trees, dependence, x_axis, y_axis, style, ranges, categories, label): @@ -188,8 +203,7 @@ def get_global(hist, trees, dependence, x_axis, y_axis, style, ranges, lab=lab, bins=ranges[dependence]["bins"], mins=ranges[dependence]["min"], - maxs=ranges[dependence]["max"] - ) + maxs=ranges[dependence]["max"]) cut = 'nrectrmc>=4 && dz < 2.0 && reco == 1 {cuts}'.format( cuts=categories[cat]["cut"]) @@ -262,8 +276,8 @@ def plot_comparison(hist, prefix, dependence, categories, label, style, norm): for lab in label: hist[cat][lab].DrawNormalized("SAME PE") text = TLatex() - text = set_text(text, style["color"][i], cor["x"][i], cor["y"][i], lab, - hist[cat][lab].GetMean(), + text = set_text(text, style["color"][i], cor["x"][i], + cor["y"][i], lab, hist[cat][lab].GetMean(), hist[cat][lab].GetMeanError(), hist[cat][lab].GetRMS(), hist[cat][lab].GetRMSError(), scale, units) @@ -281,63 +295,85 @@ def plot_comparison(hist, prefix, dependence, categories, label, style, norm): def get_robust_sigma(hist, resol): - - y = array('d',[0.]*3) - x = array('d',[0.]*3) + + y = array('d', [0.] * 3) + x = array('d', [0.] * 3) x[0] = 0.25 x[1] = 0.50 x[2] = 0.75 hist.GetQuantiles(3, y, x) - + _median = y[1] - _approxstdev = (y[2] - y[0]) / 1.34898; #factor gives correspondence between IQR and stdev for a Gaussian + _approxstdev = (y[2] - y[0]) / 1.34898 + #factor gives correspondence between IQR and stdev for a Gaussian mult = 4.0 histclone = hist.Clone() nb = histclone.GetNbinsX() - for i in range(1,nb+1): - if ((histclone.GetBinCenter(i) < (_median - _approxstdev * mult)) or (histclone.GetBinCenter(i) > (_median + _approxstdev * mult))): + for i in range(1, nb + 1): + if ((histclone.GetBinCenter(i) < (_median - _approxstdev * mult)) + or (histclone.GetBinCenter(i) > + (_median + _approxstdev * mult))): histclone.SetBinContent(i, 0) if resol: - robustsigma = {"sigma": {"var":histclone.GetRMS()*1000.0, "err":histclone.GetRMSError()*1000.0}, - "mean": {"var":histclone.GetMean()*1000.0, "err":histclone.GetMeanError()*1000.0}} + robustsigma = { + "sigma": { + "var": histclone.GetRMS() * 1000.0, + "err": histclone.GetRMSError() * 1000.0 + }, + "mean": { + "var": histclone.GetMean() * 1000.0, + "err": histclone.GetMeanError() * 1000.0 + } + } else: - robustsigma = {"sigma": {"var":histclone.GetRMS()*1.0, "err":histclone.GetRMSError()*1.0}, - "mean": {"var":histclone.GetMean(), "err":histclone.GetMeanError()}} - - return robustsigma; + robustsigma = { + "sigma": { + "var": histclone.GetRMS() * 1.0, + "err": histclone.GetRMSError() * 1.0 + }, + "mean": { + "var": histclone.GetMean(), + "err": histclone.GetMeanError() + } + } -def get_dependence(graph, trees, variable, dependence, ranges, style, categories, label): - - var = transfer_variable(variable) - bin_width = (ranges[dependence]["max"]-ranges[dependence]["min"])/ranges[dependence]["bins"] + return robustsigma - resol = True + +def get_dependence(graph, trees, variable, dependence, ranges, style, + categories, label): + + var = transfer_variable(variable) + bin_width = (ranges[dependence]["max"] - + ranges[dependence]["min"]) / ranges[dependence]["bins"] + + resol = True mean = "Mean [#mu m]" if "pull" in variable: resol = False - mean = "Mean" + mean = "Mean" for cat in categories: graph[cat] = {} i = 0 for lab in label: graph[cat][lab] = {} - graph_rms = TGraphAsymmErrors(ranges[dependence]["bins"]) + graph_rms = TGraphAsymmErrors(ranges[dependence]["bins"]) graph_mean = TGraphAsymmErrors(ranges[dependence]["bins"]) bin_min = ranges[dependence]["min"] - for b in range(0,ranges[dependence]["bins"]): + for b in range(0, ranges[dependence]["bins"]): cut_bin = '{variable1}>={mins} && {variable2}<{maxs}'.format( - variable1 = dependence, - mins = bin_min, - variable2 = dependence, - maxs = bin_min+bin_width) + variable1=dependence, + mins=bin_min, + variable2=dependence, + maxs=bin_min + bin_width) hist_string = '{dependence}>>hist_{dep}_{cat}_{lab}_{number}'.format( dependence=var, @@ -346,37 +382,40 @@ def get_dependence(graph, trees, variable, dependence, ranges, style, categories lab=lab, number=int(b), ) - + cut = '{basic} && reco == 1 && {bin_cut} {cuts}'.format( - basic = basic_cut(), - bin_cut = cut_bin, + basic=basic_cut(), + bin_cut=cut_bin, cuts=categories[cat]["cut"]) - a = trees[lab].Draw(hist_string, cut) bin_min += bin_width - + h = gDirectory.Get('hist_{dep}_{cat}_{lab}_{number}'.format( - dep=variable, - cat=cat, - lab=lab, - number=int(b) )) + dep=variable, cat=cat, lab=lab, number=int(b))) robust_sigma = get_robust_sigma(h, resol) - - graph_mean.SetPoint(b, bin_min+bin_width/2.0, robust_sigma["mean"]["var"]) - graph_mean.SetPointError(b, bin_width/2.0, bin_width/2.0, robust_sigma["mean"]["err"],robust_sigma["mean"]["err"]) - - graph_rms.SetPoint(b, bin_min+bin_width/2.0, robust_sigma["sigma"]["var"]) - graph_rms.SetPointError(b, bin_width/2.0, bin_width/2.0, robust_sigma["sigma"]["err"],robust_sigma["sigma"]["err"]) - - set_style(graph_rms, style["color"][i], style["marker"][i], get_x_axis(dependence), get_y_axis(variable), "") - set_style(graph_mean, style["color"][i], style["marker"][i], get_x_axis(dependence), mean, "") + + graph_mean.SetPoint(b, bin_min + bin_width / 2.0, + robust_sigma["mean"]["var"]) + graph_mean.SetPointError(b, bin_width / 2.0, bin_width / 2.0, + robust_sigma["mean"]["err"], + robust_sigma["mean"]["err"]) + + graph_rms.SetPoint(b, bin_min + bin_width / 2.0, + robust_sigma["sigma"]["var"]) + graph_rms.SetPointError(b, bin_width / 2.0, bin_width / 2.0, + robust_sigma["sigma"]["err"], + robust_sigma["sigma"]["err"]) + + set_style(graph_rms, style["color"][i], style["marker"][i], + get_x_axis(dependence), get_y_axis(variable), "") + set_style(graph_mean, style["color"][i], style["marker"][i], + get_x_axis(dependence), mean, "") graph[cat][lab]["sigma"] = graph_rms graph[cat][lab]["mean"] = graph_mean - i+=1 - + i += 1 return graph -- GitLab From a3db2f3fb4197cf2183b0e3dfaf33abfe0f43e1b Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 6 Mar 2020 12:01:56 +0100 Subject: [PATCH 112/171] modify the plotting scripts --- .../scripts/PrCheckerEfficiency_HLT1.py | 18 ++++---- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 10 ++--- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 21 ++++----- .../scripts/PrCheckerTrackResolution.py | 28 ++++++------ Hlt/RecoConf/scripts/utils/ConfigHistos.py | 43 +++---------------- Hlt/RecoConf/scripts/utils/LHCbStyle.py | 2 + Hlt/RecoConf/scripts/utils/Legend.py | 11 +++++ .../hlt1_reco_IPresolution_plots.qmt | 2 +- 8 files changed, 58 insertions(+), 77 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index bafe7151d64..4997a74d4d8 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -52,7 +52,7 @@ def getOriginFolders(): def get_colors(): - return [kBlack, kAzure, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] + return [kBlack, kAzure, kGreen+3, kMagenta + 2, kOrange, kCyan + 2] def get_markers(): @@ -140,13 +140,6 @@ def get_eff(eff, hist, tf, histoName, label, var): if (histoName.find('electron') != -1): hist[lab].SetTitle(var + " histo. electron") - if var == "p": - eff[lab].GetXaxis().SetRangeUser(0, 50000) - hist[lab].GetXaxis().SetRangeUser(0, 50000) - if var == "pt": - eff[lab].GetXaxis().SetRangeUser(0, 5000) - hist[lab].GetXaxis().SetRangeUser(0, 5000) - return eff, hist @@ -221,7 +214,7 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, scale = gPad.GetUymax() / rightmax hist_den[lab].Scale(scale) if i == 0: - set_style(hist_den[lab], kGray, markers[i], + set_style(hist_den[lab], kGray+1, markers[i], styles[i]) else: set_style(hist_den[lab], colors[i] - 10, @@ -236,6 +229,8 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, hist_den[label[0]].Draw("hist SAME") canvas.PlaceLegend() + for lab in label: + eff[lab].Draw("P SAME") cutName = categories[tracker][cut]["title"] latex.DrawLatex(0.7, 0.85, "LHCb simultaion") latex.DrawLatex(0.35, 0.3, cutName) @@ -286,6 +281,8 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, styles[i]) canvas_elec.PlaceLegend() + for lab in label: + eff_elec[lab].Draw("P SAME") latex.DrawLatex(0.7, 0.85, "LHCb simultaion") latex.DrawLatex(0.35, 0.3, cutName) canvasName_elec = tracker + "_" + cut + "_" + histo + "_elec.pdf" @@ -331,6 +328,9 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, hist_elec[lab].Draw("hist SAME") canvas_com.PlaceLegend() + for lab in label: + eff[lab].Draw("P SAME") + eff_elec[lab].Draw("P SAME") latex.DrawLatex(0.7, 0.85, "LHCb simultaion") latex.DrawLatex(0.35, 0.3, cutName) canvas_com.SetRightMargin(0.05) diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 427358cb3f0..f46f699e348 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -28,7 +28,7 @@ from ROOT import ROOT, vector, TGraphAsymmErrors def get_colors(): - return [kBlack, kBlue, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] + return [kBlack, kBlue, kGreen+3, kMagenta + 2, kOrange, kCyan + 2] def get_markers(): @@ -92,9 +92,9 @@ def get_resolution(resx, resy, tr, label): print("Velo track from PV in acceptance: " + cutAcc) for i, lab in enumerate(label): ### typeofprefix==0 for track from PV and matched with MC - resIPx[lab] = TH2F("resIPx_" + lab, "IPx:1/pt", 20, 0, 2, 100, -300, + resIPx[lab] = TH2F("resIPx_" + lab, "IPx:1/pt", 20, 0, 2.0, 100, -300, 300) - resIPy[lab] = TH2F("resIPy_" + lab, "IPy:1/pt", 20, 0, 2, 100, -300, + resIPy[lab] = TH2F("resIPy_" + lab, "IPy:1/pt", 20, 0, 2.0, 100, -300, 300) resIPx[lab].SetMarkerStyle(1) resIPy[lab].SetMarkerStyle(1) @@ -109,7 +109,7 @@ def get_resolution(resx, resy, tr, label): resy[lab] = gDirectory.Get("resIPy_" + lab + "_2") resIPx_1[lab] = gDirectory.Get("resIPx_" + lab + "_1") resIPy_1[lab] = gDirectory.Get("resIPy_" + lab + "_1") - for i in range(1, 20): + for i in range(1, resIPx_1[lab].GetNbinsX()): print( lab + ": in 1/pT region: (" + format(resIPx_1[lab].GetBinLowEdge(i), '.2f') + ", " + format( @@ -180,7 +180,6 @@ def PrCheckerIPresolution(filename, label, outfile, savepdf, plotstyle): Par1x[lab] = format(polx[lab].GetParameter(1), '.2f') Funcx[lab] = lab + ": " + Par0x[lab] + "+" + Par1x[lab] + "/p_{T}" gr_resx[lab].SetTitle(Funcx[lab]) - #canvas1.PlaceLegend() place_legend( canvas1, 0.5, 0.2, 0.85, 0.45, header="LHCb simulation", option="lep") canvas1.SetRightMargin(0.05) @@ -211,7 +210,6 @@ def PrCheckerIPresolution(filename, label, outfile, savepdf, plotstyle): Par1y[lab] = format(poly[lab].GetParameter(1), '.2f') Funcy[lab] = lab + ": " + Par0y[lab] + "+" + Par1y[lab] + "/p_{T}" gr_resy[lab].SetTitle(Funcy[lab]) - #canvas2.PlaceLegend() place_legend( canvas2, 0.5, 0.2, 0.85, 0.45, header="LHCb simulation", option="lep") canvas2.SetRightMargin(0.05) diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index 10b9359be01..be63684d4cd 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -47,7 +47,7 @@ def getOriginFolders(): def get_colors(): - return [kBlack, kAzure, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] + return [kBlack, kBlue, kGreen+3, kMagenta + 2, kOrange, kCyan + 2] def get_markers(): @@ -72,7 +72,7 @@ def argument_parser(): default='MuonIDefficiency_plots.root', help='output file') parser.add_argument( - '--label', nargs='+', default="EffChecker", help='label for files') + '--label', nargs='+', default="MuonIDEff", help='label for files') parser.add_argument( '--plotstyle', default=os.getcwd(), @@ -84,7 +84,7 @@ def argument_parser(): help='save plots in pdf format') parser.add_argument( '--printval', - default=False, + default=True, action='store_true', help='print out the muon ID efficiency in momentum bins ') return parser @@ -126,9 +126,6 @@ def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): if (histoName.find('electron') != -1): hist[lab].SetTitle(var + " histo. electron") - if var == "p": - eff[lab].GetXaxis().SetRangeUser(0, 50000) - hist[lab].GetXaxis().SetRangeUser(0, 50000) #print the muonID efficiency in each p bin if var == "p" and printval: for i in range(1, numerator.GetNbinsX()): @@ -143,10 +140,6 @@ def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): numerator.GetBinWidth(i), '.2f') + ") [GeV/c] : " + format(Eff, '.2%')) - if var == "pt": - eff[lab].GetXaxis().SetRangeUser(0, 5000) - hist[lab].GetXaxis().SetRangeUser(0, 5000) - return eff, hist @@ -220,21 +213,23 @@ def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): scale = gPad.GetUymax() / rightmax hist_den[lab].Scale(scale) if i == 0: - set_style(hist_den[lab], kGray, markers[i], styles[i]) + set_style(hist_den[lab], kGray+1, markers[i], styles[i]) else: - set_style(hist_den[lab], colors[i] - 10, markers[i], + set_style(hist_den[lab], colors[i]-10, markers[i], styles[i]) hist_den[lab].Draw("hist SAME") canvas.PlaceLegend() + for lab in label: + eff[lab].Draw("P SAME") cutName = categories[tracker][cut]["title"] latex.DrawLatex(0.35, 0.3, cutName) latex.DrawLatex(0.7, 0.85, "LHCb simulation") canvas.SetRightMargin(0.05) canvas.Write() - canvasName = "MuonIDEff_" + cut + "_" + histo + ".pdf" if savepdf: + canvasName = "MuonIDEff_" + cut + "_" + histo + ".pdf" canvas.SaveAs(canvasName) canvas.SetRightMargin(0.05) canvas.Write() diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index d368533f249..a07106891a1 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -28,8 +28,7 @@ from collections import defaultdict def get_colors(): - return [kBlack, kBlue, kOrange, kMagenta + 2, kGreen + 3, kCyan + 2] - + return [kBlack, kBlue, kGreen+3, kMagenta + 2, kOrange, kCyan + 2] def get_markers(): return [20, 24, 21, 22, 23, 25] @@ -107,12 +106,12 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): hres_p[lab].GetYaxis().SetTitle("dp/p [%]") hres_p[lab].GetXaxis().SetTitle("p [GeV/c]") hres_p[lab].GetYaxis().SetRangeUser(0, 1.2) - hres_p[lab].SetTitle("Res. " + lab) + hres_p[lab].SetTitle(lab) set_style(hres_p[lab], colors[idx], markers[idx], 0) if idx == 0: hres_p[lab].Draw("E1 p1") - set_style(hmom[lab], kGray, markers[idx], styles[idx]) + set_style(hmom[lab], kGray+1, markers[idx], styles[idx]) else: hres_p[lab].Draw("E1 p1 same") set_style(hmom[lab], colors[idx] - 10, markers[idx], styles[idx]) @@ -121,21 +120,23 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): for i in range(1, hres_p[lab].GetNbinsX()): hres_p[lab].SetBinContent(i, hres_p[lab].GetBinContent(i) * 100) + hres_p[lab].SetBinError(i, hres_p[lab].GetBinError(i) * 100) print(lab + ": Track resolution (dp/p) in p region: (" + format(hres_p[lab].GetBinLowEdge(i), '.2f') + ", " + format( hres_p[lab].GetBinLowEdge(i) + hres_p[lab].GetBinWidth(i), '.2f') + ") [GeV/c]" + - " --- " + format(hres_p[lab].GetBinContent(i), '.2f') + "%") + " --- (" + format(hres_p[lab].GetBinContent(i), '.2f') + "+-"+ format(hres_p[lab].GetBinError(i),'.2f' )+ ")%") print("-----------------------------------------------------") canvas1.PlaceLegend() + for lab in label: + hres_p[lab].Draw("E1 p1 same") canvas1.SetRightMargin(0.05) canvas1.Write() if savepdf: canvas1.SaveAs("trackres_p.pdf") - print("=====================================================") canvas2 = TCanvas("res_eta", "res v.s. eta") canvas2.cd() @@ -152,12 +153,12 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): hres_eta[lab].GetYaxis().SetTitle("dp/p [%]") hres_eta[lab].GetXaxis().SetTitle("#eta") hres_eta[lab].GetYaxis().SetRangeUser(0, 1.2) - hres_eta[lab].SetTitle("Res. " + lab) + hres_eta[lab].SetTitle(lab) set_style(hres_eta[lab], colors[idx], markers[idx], 0) if idx == 0: hres_eta[lab].Draw("E1 p1") - set_style(heta[lab], kGray, markers[idx], styles[idx]) + set_style(heta[lab], kGray+1, markers[idx], styles[idx]) else: hres_eta[lab].Draw("E1 p1 same") set_style(heta[lab], colors[idx] - 10, markers[idx], styles[idx]) @@ -166,17 +167,20 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): heta[lab].Draw("hist same") for i in range(1, hres_eta[lab].GetNbinsX()): - hres_eta[lab].SetBinContent(i, - hres_eta[lab].GetBinContent(i) * 100) + hres_eta[lab].SetBinContent(i, hres_eta[lab].GetBinContent(i) * 100) + hres_eta[lab].SetBinError(i, hres_eta[lab].GetBinError(i) * 100) print(lab + ": Track resolution (dp/p) in eta region: (" + format(hres_eta[lab].GetBinLowEdge(i), '.2f') + ", " + format( hres_eta[lab].GetBinLowEdge(i) + - hres_eta[lab].GetBinWidth(i), '.2f') + ")" + " --- " + - format(hres_eta[lab].GetBinContent(i), '.2f') + "%") + hres_eta[lab].GetBinWidth(i), '.2f') + ")" + " --- (" + + format(hres_eta[lab].GetBinContent(i), '.2f') + "+-"+format(hres_eta[lab].GetBinError(i), '.2f') + ")%") + print("-----------------------------------------------------") canvas2.PlaceLegend() + for lab in label: + hres_eta[lab].Draw("E1 p1 same") canvas2.SetRightMargin(0.05) canvas2.Write() if savepdf: diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 9b80e253400..28ab9fb16b9 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -73,9 +73,7 @@ def getCuts(): "06_long_fromB", "07_long_fromB_P>5GeV", "11_long_fromB_P>3GeV_Pt>0.5GeV", - "12_UT_long_fromB_P>3GeV_Pt>0.5GeV", - #"11_long_fromD_P>3GeV_Pt>0.5GeV", "11_long_strange_P>3GeV_Pt>0.5GeV", - #"06_long_fromD" + "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Upstream"] = [ "01_velo", @@ -86,20 +84,14 @@ def getCuts(): "09_long_fromB", "10_long_fromB_P>5GeV", "14_long_fromB_P>3GeV_Pt>0.5GeV", - "15_UT_long_fromB_P>3GeV_Pt>0.5GeV", - #"09_long_fromD", "14_long_fromD_P>3GeV_Pt>0.5GeV", - #"14_long_strange_P>3GeV_Pt>0.5GeV" + "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Forward"] = [ "01_long", "02_long_P>5GeV", "03_long_strange", "04_long_strange_P>5GeV", "05_long_fromB", "06_long_fromB_P>5GeV", - "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV", - "05_long_fromD", "10_long_fromD_P>3GeV_Pt>0.5GeV", - "10_long_strange_P>3GeV_Pt>0.5GeV" + "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["MuonMatch"] = [ - #"02_long_muon_P>3GeV_Pt>0.5GeV", "04_long_pion_P>3GeV_Pt>0.5GeV", - #"03_long_muon_from_strange_P>3GeV_Pt>0.5GeV", "01_long", "02_long_muon", "03_long_muon_from_strange", @@ -118,7 +110,7 @@ def categoriesDict(): "title"] = "Long, #mu, forward track, 2 <#eta< 5" basedict["MuonMatch"]["02_long_muon_P>3GeV_Pt>0.5GeV"][ "title"] = "Long, #mu, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" - basedict["MuonMatch"]["03_long_muoon_from_strange"][ + basedict["MuonMatch"]["03_long_muon_from_strange"][ "title"] = "Long, #mu from strange, forward track, 2 <#eta< 5" basedict["MuonMatch"]["03_long_muon_from_strange_P>3GeV_Pt>0.5GeV"][ "title"] = "Long, #mu from strange, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" @@ -135,12 +127,10 @@ def categoriesDict(): basedict["Velo"]["05_long_strange_P>5GeV"][ "title"] = "Long, from Strange, p>5GeV, 2 <#eta < 5" basedict["Velo"]["06_long_fromB"]["title"] = "Long from B, 2<#eta<5" - basedict["Velo"]["06_long_fromD"]["title"] = "Long from D, 2<#eta<5" basedict["Velo"]["07_long_fromB_P>5GeV"][ "title"] = "Long from B, p>5GeV, 2<#eta<5" basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from B, p>3GeV, pt>0.5GeV, 2<#eta<5" - basedict["Velo"]["11_long_fromD_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from D, p>3GeV, pt>0.5GeV, 2<#eta<5" basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from strange, p>3GeV, pt>0.5GeV, 2<#eta<5" @@ -152,11 +142,8 @@ def categoriesDict(): basedict["Velo"]["04_long_strange"]["plotElectrons"] = False basedict["Velo"]["05_long_strange_P>5GeV"]["plotElectrons"] = False basedict["Velo"]["06_long_fromB"]["plotElectrons"] = True - basedict["Velo"]["06_long_fromD"]["plotElectrons"] = False basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True - #basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True - basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False - basedict["Velo"]["11_long_fromD_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False + basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -177,13 +164,10 @@ def categoriesDict(): basedict["Upstream"]["08_long_P>5GeV"][ "title"] = "Long, p>5GeV, 2 <#eta < 5" basedict["Upstream"]["09_long_fromB"]["title"] = "Long from B, 2 <#eta < 5" - basedict["Upstream"]["09_long_fromD"]["title"] = "Long from D, 2 <#eta < 5" basedict["Upstream"]["10_long_fromB_P>5GeV"][ "title"] = "Long from B, p>5GeV, 2 <#eta < 5" basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ "title"] = "Long, from B, p>3GeV, pt>0.5GeV" - basedict["Upstream"]["14_long_fromD_P>3GeV_Pt>0.5GeV"][ - "title"] = "Long, from D, p>3GeV, pt>0.5GeV" basedict["Upstream"]["14_long_strange_P>3GeV_Pt>0.5GeV"][ "title"] = "Long, from strange, p>3GeV, pt>0.5GeV" basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -195,13 +179,8 @@ def categoriesDict(): basedict["Upstream"]["07_long"]["plotElectrons"] = True basedict["Upstream"]["08_long_P>5GeV"]["plotElectrons"] = False basedict["Upstream"]["09_long_fromB"]["plotElectrons"] = True - basedict["Upstream"]["09_long_fromD"]["plotElectrons"] = False basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True - #basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True - basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ - "plotElectrons"] = False - basedict["Upstream"]["14_long_fromD_P>3GeV_Pt>0.5GeV"][ - "plotElectrons"] = False + basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True basedict["Upstream"]["14_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -222,13 +201,10 @@ def categoriesDict(): basedict["Forward"]["04_long_strange_P>5GeV"][ "title"] = "Long, from strange, p>5GeV, 2 <#eta < 5" basedict["Forward"]["05_long_fromB"]["title"] = "Long from B, 2 <#eta < 5" - basedict["Forward"]["05_long_fromD"]["title"] = "Long from D, 2 <#eta < 5" basedict["Forward"]["06_long_fromB_P>5GeV"][ "title"] = "Long from B, p>5GeV 2 <#eta < 5" basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from B, p>3GeV, pt>0.5GeV, 2 <#eta < 5" - basedict["Forward"]["10_long_fromD_P>3GeV_Pt>0.5GeV"][ - "title"] = "Long from D, p>3GeV, pt>0.5GeV, 2 <#eta < 5" basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from strange, p>3GeV, pt>0.5GeV, 2 <#eta < 5" basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -239,13 +215,8 @@ def categoriesDict(): basedict["Forward"]["03_long_strange"]["plotElectrons"] = False basedict["Forward"]["04_long_strange_P>5GeV"]["plotElectrons"] = False basedict["Forward"]["05_long_fromB"]["plotElectrons"] = True - basedict["Forward"]["05_long_fromD"]["plotElectrons"] = False basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True - #basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True - basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ - "plotElectrons"] = False - basedict["Forward"]["10_long_fromD_P>3GeV_Pt>0.5GeV"][ - "plotElectrons"] = False + basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ diff --git a/Hlt/RecoConf/scripts/utils/LHCbStyle.py b/Hlt/RecoConf/scripts/utils/LHCbStyle.py index 1429775f1be..467f0401be1 100644 --- a/Hlt/RecoConf/scripts/utils/LHCbStyle.py +++ b/Hlt/RecoConf/scripts/utils/LHCbStyle.py @@ -24,6 +24,8 @@ def set_style(graph, color, marker, style): graph.SetFillColor(color) graph.SetFillStyle(style) graph.SetLineWidth(2) + if style==0: + graph.SetFillColor(0) graph.SetStats(False) graph.GetYaxis().SetTitleOffset(1.0) graph.GetYaxis().SetTitleSize(0.06) diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index ac205a555f5..9126948a61a 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -138,3 +138,14 @@ ROOT.TH1.Overlap = overlap_h ROOT.TGraph.Overlap = overlap_g ROOT.TPad.PadtoU = transform_to_user ROOT.TPad.PlaceLegend = place_legend + +def set_legend(legend, gr, title, colors, label): + legend.SetTextSize(0.05) + legend.SetFillColor(0) + legend.SetShadowColor(0) + legend.SetBorderSize(0) + legend.SetTextFont(132) + for idx, lab in enumerate(label): + legend.AddEntry(gr[lab], title[lab], "lep").SetTextColor(colors[idx]) + + return legend diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt index 5d93556337a..b74bfb4e09b 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt @@ -10,7 +10,7 @@ or submit itself to any jurisdiction. --> python -- GitLab From 09c0847d13d2f98062836015f57f6e432aa65488 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 6 Mar 2020 11:02:40 +0000 Subject: [PATCH 113/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7480556 --- .../scripts/PrCheckerEfficiency_HLT1.py | 4 ++-- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 2 +- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 6 +++--- .../scripts/PrCheckerTrackResolution.py | 17 ++++++++++------- Hlt/RecoConf/scripts/utils/LHCbStyle.py | 2 +- Hlt/RecoConf/scripts/utils/Legend.py | 1 + 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 4997a74d4d8..98153faeb90 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -52,7 +52,7 @@ def getOriginFolders(): def get_colors(): - return [kBlack, kAzure, kGreen+3, kMagenta + 2, kOrange, kCyan + 2] + return [kBlack, kAzure, kGreen + 3, kMagenta + 2, kOrange, kCyan + 2] def get_markers(): @@ -214,7 +214,7 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, scale = gPad.GetUymax() / rightmax hist_den[lab].Scale(scale) if i == 0: - set_style(hist_den[lab], kGray+1, markers[i], + set_style(hist_den[lab], kGray + 1, markers[i], styles[i]) else: set_style(hist_den[lab], colors[i] - 10, diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index f46f699e348..d4a74b52995 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -28,7 +28,7 @@ from ROOT import ROOT, vector, TGraphAsymmErrors def get_colors(): - return [kBlack, kBlue, kGreen+3, kMagenta + 2, kOrange, kCyan + 2] + return [kBlack, kBlue, kGreen + 3, kMagenta + 2, kOrange, kCyan + 2] def get_markers(): diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index be63684d4cd..44aeabafd77 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -47,7 +47,7 @@ def getOriginFolders(): def get_colors(): - return [kBlack, kBlue, kGreen+3, kMagenta + 2, kOrange, kCyan + 2] + return [kBlack, kBlue, kGreen + 3, kMagenta + 2, kOrange, kCyan + 2] def get_markers(): @@ -213,9 +213,9 @@ def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): scale = gPad.GetUymax() / rightmax hist_den[lab].Scale(scale) if i == 0: - set_style(hist_den[lab], kGray+1, markers[i], styles[i]) + set_style(hist_den[lab], kGray + 1, markers[i], styles[i]) else: - set_style(hist_den[lab], colors[i]-10, markers[i], + set_style(hist_den[lab], colors[i] - 10, markers[i], styles[i]) hist_den[lab].Draw("hist SAME") diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index a07106891a1..821ad3c7a61 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -28,7 +28,8 @@ from collections import defaultdict def get_colors(): - return [kBlack, kBlue, kGreen+3, kMagenta + 2, kOrange, kCyan + 2] + return [kBlack, kBlue, kGreen + 3, kMagenta + 2, kOrange, kCyan + 2] + def get_markers(): return [20, 24, 21, 22, 23, 25] @@ -111,7 +112,7 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): if idx == 0: hres_p[lab].Draw("E1 p1") - set_style(hmom[lab], kGray+1, markers[idx], styles[idx]) + set_style(hmom[lab], kGray + 1, markers[idx], styles[idx]) else: hres_p[lab].Draw("E1 p1 same") set_style(hmom[lab], colors[idx] - 10, markers[idx], styles[idx]) @@ -126,7 +127,8 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): format(hres_p[lab].GetBinLowEdge(i), '.2f') + ", " + format( hres_p[lab].GetBinLowEdge(i) + hres_p[lab].GetBinWidth(i), '.2f') + ") [GeV/c]" + - " --- (" + format(hres_p[lab].GetBinContent(i), '.2f') + "+-"+ format(hres_p[lab].GetBinError(i),'.2f' )+ ")%") + " --- (" + format(hres_p[lab].GetBinContent(i), '.2f') + + "+-" + format(hres_p[lab].GetBinError(i), '.2f') + ")%") print("-----------------------------------------------------") canvas1.PlaceLegend() @@ -137,7 +139,6 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): if savepdf: canvas1.SaveAs("trackres_p.pdf") - canvas2 = TCanvas("res_eta", "res v.s. eta") canvas2.cd() @@ -158,7 +159,7 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): if idx == 0: hres_eta[lab].Draw("E1 p1") - set_style(heta[lab], kGray+1, markers[idx], styles[idx]) + set_style(heta[lab], kGray + 1, markers[idx], styles[idx]) else: hres_eta[lab].Draw("E1 p1 same") set_style(heta[lab], colors[idx] - 10, markers[idx], styles[idx]) @@ -167,7 +168,8 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): heta[lab].Draw("hist same") for i in range(1, hres_eta[lab].GetNbinsX()): - hres_eta[lab].SetBinContent(i, hres_eta[lab].GetBinContent(i) * 100) + hres_eta[lab].SetBinContent(i, + hres_eta[lab].GetBinContent(i) * 100) hres_eta[lab].SetBinError(i, hres_eta[lab].GetBinError(i) * 100) print(lab + ": Track resolution (dp/p) in eta region: (" + @@ -175,7 +177,8 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): format( hres_eta[lab].GetBinLowEdge(i) + hres_eta[lab].GetBinWidth(i), '.2f') + ")" + " --- (" + - format(hres_eta[lab].GetBinContent(i), '.2f') + "+-"+format(hres_eta[lab].GetBinError(i), '.2f') + ")%") + format(hres_eta[lab].GetBinContent(i), '.2f') + "+-" + + format(hres_eta[lab].GetBinError(i), '.2f') + ")%") print("-----------------------------------------------------") canvas2.PlaceLegend() diff --git a/Hlt/RecoConf/scripts/utils/LHCbStyle.py b/Hlt/RecoConf/scripts/utils/LHCbStyle.py index 467f0401be1..f5dd4fceeee 100644 --- a/Hlt/RecoConf/scripts/utils/LHCbStyle.py +++ b/Hlt/RecoConf/scripts/utils/LHCbStyle.py @@ -24,7 +24,7 @@ def set_style(graph, color, marker, style): graph.SetFillColor(color) graph.SetFillStyle(style) graph.SetLineWidth(2) - if style==0: + if style == 0: graph.SetFillColor(0) graph.SetStats(False) graph.GetYaxis().SetTitleOffset(1.0) diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index 9126948a61a..cba662ae1bf 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -139,6 +139,7 @@ ROOT.TGraph.Overlap = overlap_g ROOT.TPad.PadtoU = transform_to_user ROOT.TPad.PlaceLegend = place_legend + def set_legend(legend, gr, title, colors, label): legend.SetTextSize(0.05) legend.SetFillColor(0) -- GitLab From a656c52d31ca711b849dc05e7a267ca766ad2230 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Fri, 6 Mar 2020 15:41:06 +0100 Subject: [PATCH 114/171] add one more checker for fitted tracks --- Hlt/RecoConf/options/hlt1_reco_trackresolution.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py index a18e2d82c1d..ecabf4285b5 100644 --- a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py @@ -10,7 +10,7 @@ ############################################################################### from Moore import options, run_reconstruction from Moore.config import Reconstruction -from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks +from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks from RecoConf.mc_checking import monitor_track_resolution from PyConf.application import make_data_with_FetchDataFromFile @@ -18,16 +18,13 @@ from PyConf.application import make_data_with_FetchDataFromFile def hlt1_reco_trackresolution(): track_type = "Forward" tracks = make_hlt1_tracks()[track_type] + fitted_tracks = make_VeloKalman_fitted_tracks(make_hlt1_tracks()) pr_checker = monitor_track_resolution(tracks) + pr_checker_fitted = monitor_track_resolution(fitted_tracks) - #return CompositeNode( - # name='hlt1_trackRes', - # children=pr_checker, - # combineLogic=NodeLogic.NONLAZY_OR, - # forceOrder=False) return Reconstruction( 'track_resolution', - [make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), pr_checker], + [make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), pr_checker, pr_checker_fitted], [require_gec()]) -- GitLab From 5385c6dceacaf4d9e16bc4ffbfafc3e2d57616df Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 6 Mar 2020 14:41:32 +0000 Subject: [PATCH 115/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7484887 --- Hlt/RecoConf/options/hlt1_reco_trackresolution.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py index ecabf4285b5..ffae042d4ab 100644 --- a/Hlt/RecoConf/options/hlt1_reco_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_trackresolution.py @@ -22,10 +22,10 @@ def hlt1_reco_trackresolution(): pr_checker = monitor_track_resolution(tracks) pr_checker_fitted = monitor_track_resolution(fitted_tracks) - return Reconstruction( - 'track_resolution', - [make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), pr_checker, pr_checker_fitted], - [require_gec()]) + return Reconstruction('track_resolution', [ + make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), pr_checker, + pr_checker_fitted + ], [require_gec()]) options.histo_file = "Hlt1ForwardTrackingResolution.root" -- GitLab From 63cba550c846fd3dff1e42ad8293071f4f10dfe1 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Mon, 9 Mar 2020 10:15:03 +0100 Subject: [PATCH 116/171] fix errors --- .../qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt | 1 - .../tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt | 1 - .../qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt | 1 - 3 files changed, 3 deletions(-) diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt index b74bfb4e09b..33c09038fc3 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt @@ -19,7 +19,6 @@ Plotting script to determine IP resolution in each p or eta bin on MC simulation --filename=Hlt1ForwardTracking_IPresolution.root --outfile=IPResolution_plots.root --plotstyle=$RECOCONFROOT/scripts/ - --output=hlt1_reco_IPresolution_plot.opts.py true diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt index 1b10fc5c4a2..3dfcb8d3558 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_muonIDeff_plots.qmt @@ -20,7 +20,6 @@ long reconstructed forward tracks with MC samples. --filename=PrChecker_MuonID_MiniBias.root --outfile=muonIDeff_plots.root --plotstyle=$RECOCONFROOT/scripts/ - --output=hlt1_reco_muonideff_plot.opts.py true diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt index ced5bba9249..6e5c27752fa 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_trackresolution_plots.qmt @@ -19,7 +19,6 @@ Test plot script to draw the track resolution in Hlt1 and test for changes. --filename=Hlt1ForwardTrackingResolution.root --outfile=TrackResolution_plots.root --plotstyle=$RECOCONFROOT/scripts/ - --output=hlt1_reco_trackresolution.opts.py true -- GitLab From f1dde206bf11b24daabb73486bbbb57cff790fe9 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Mon, 9 Mar 2020 16:23:24 +0100 Subject: [PATCH 117/171] add ntuple_file to enable NTupleSvc --- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 7 +------ .../hlt1_reco_IPresolution_plots.qmt | 2 +- PyConf/python/PyConf/application.py | 13 ++++++++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index 2cc6d335657..ecd89155137 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -26,10 +26,5 @@ def hlt1_reco_IPresolution(): return Reconstruction('IPresolution', [pr_checker], [require_gec()]) +options.ntuple_file = "Hlt1_IPresolution.root" run_reconstruction(options, hlt1_reco_IPresolution) - -NTupleSvc().Output += [ - "FILE1 DATAFILE='Hlt1ForwardTracking_IPresolution.root' TYPE='ROOT' OPT='NEW'" -] -ApplicationMgr().ExtSvc += [NTupleSvc()] -ApplicationMgr().HistogramPersistency = "ROOT" diff --git a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt index 33c09038fc3..4fb968ddb36 100644 --- a/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt +++ b/Hlt/RecoConf/tests/qmtest/performance.qms/hlt1_reco_IPresolution_plots.qmt @@ -16,7 +16,7 @@ Plotting script to determine IP resolution in each p or eta bin on MC simulation python $RECOCONFROOT/scripts/PrCheckerIPresolution.py - --filename=Hlt1ForwardTracking_IPresolution.root + --filename=Hlt1_IPresolution.root --outfile=IPResolution_plots.root --plotstyle=$RECOCONFROOT/scripts/ diff --git a/PyConf/python/PyConf/application.py b/PyConf/python/PyConf/application.py index 69470536ffa..38993dc143c 100644 --- a/PyConf/python/PyConf/application.py +++ b/PyConf/python/PyConf/application.py @@ -43,6 +43,7 @@ from Configurables import ( LHCb__Tests__FakeEventTimeProducer as DummyEventTime, Gaudi__Hive__FetchDataFromFile, ApplicationMgr, + NTupleSvc, DataOnDemandSvc, ) @@ -137,6 +138,7 @@ class ApplicationOptions(ConfigurableUser): 'output_file': '', 'output_type': '', 'histo_file': '', + 'ntuple_file': '', 'output_level': INFO, 'python_logging_level': logging.WARNING, # multithreaded processing @@ -505,8 +507,10 @@ def configure(options, control_flow_node, public_tools=[]): appMgr = config.add( ApplicationMgr(OutputLevel=options.output_level, EventLoop=scheduler)) appMgr.ExtSvc.insert( - 0, whiteboard + 0, whiteboard ) # FIXME this cannot work when configurables are not singletons + appMgr.ExtSvc.insert(0, NTupleSvc()) + config.add(setup_component('UpdateManagerSvc', WithoutBeginEvent=True)) config.add( setup_component('HiveDataBrokerSvc', DataProducers=configurable_algs)) @@ -516,6 +520,7 @@ def configure(options, control_flow_node, public_tools=[]): # Give more space for component names in stdout config.add(setup_component('MessageSvc', Format='% F%35W%S %7W%R%T %0W%M')) config.add(setup_component('HistogramPersistencySvc', OutputLevel=5)) + config.add(setup_component('NTupleSvc', OutputLevel=0)) config.add( setup_component('EventClockSvc', InitialTime=int(INITIAL_TIME * 1e9))) @@ -525,6 +530,12 @@ def configure(options, control_flow_node, public_tools=[]): 'HistogramPersistencySvc', OutputFile=options.histo_file)) config.add(ApplicationMgr(HistogramPersistency="ROOT")) + if options.ntuple_file: + config.add( + setup_component( + 'NTupleSvc', Output=["FILE1 DATAFILE='{}' TYPE='ROOT' OPT='NEW'".format(options.ntuple_file)])) + config.add(ApplicationMgr(HistogramPersistency="ROOT")) + if options.control_flow_file: fn_root, fn_ext = os.path.splitext(options.control_flow_file) plot_control_flow( -- GitLab From 150ef2f901b9f678ee8e53c45be7cef98584faa5 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Mon, 9 Mar 2020 15:24:29 +0000 Subject: [PATCH 118/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7513723 --- PyConf/python/PyConf/application.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PyConf/python/PyConf/application.py b/PyConf/python/PyConf/application.py index 38993dc143c..c91cb5a2add 100644 --- a/PyConf/python/PyConf/application.py +++ b/PyConf/python/PyConf/application.py @@ -507,7 +507,7 @@ def configure(options, control_flow_node, public_tools=[]): appMgr = config.add( ApplicationMgr(OutputLevel=options.output_level, EventLoop=scheduler)) appMgr.ExtSvc.insert( - 0, whiteboard + 0, whiteboard ) # FIXME this cannot work when configurables are not singletons appMgr.ExtSvc.insert(0, NTupleSvc()) @@ -533,7 +533,11 @@ def configure(options, control_flow_node, public_tools=[]): if options.ntuple_file: config.add( setup_component( - 'NTupleSvc', Output=["FILE1 DATAFILE='{}' TYPE='ROOT' OPT='NEW'".format(options.ntuple_file)])) + 'NTupleSvc', + Output=[ + "FILE1 DATAFILE='{}' TYPE='ROOT' OPT='NEW'".format( + options.ntuple_file) + ])) config.add(ApplicationMgr(HistogramPersistency="ROOT")) if options.control_flow_file: -- GitLab From 725f40f9099fe40a82565354048dc2b9006d15a3 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Mon, 9 Mar 2020 17:11:43 +0100 Subject: [PATCH 119/171] fix the warnning --- PyConf/python/PyConf/application.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PyConf/python/PyConf/application.py b/PyConf/python/PyConf/application.py index c91cb5a2add..34e73517cdc 100644 --- a/PyConf/python/PyConf/application.py +++ b/PyConf/python/PyConf/application.py @@ -538,6 +538,9 @@ def configure(options, control_flow_node, public_tools=[]): "FILE1 DATAFILE='{}' TYPE='ROOT' OPT='NEW'".format( options.ntuple_file) ])) + config.add( + setup_component( + 'HistogramPersistencySvc', OutputFile=options.ntuple_file)) config.add(ApplicationMgr(HistogramPersistency="ROOT")) if options.control_flow_file: -- GitLab From d1ff3ae308d6a047e8dfd4a079967742281535e3 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 10 Mar 2020 11:10:37 +0100 Subject: [PATCH 120/171] adapt the scripts to run also for python 2 --- Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py | 10 +++++----- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 7 ++++--- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 10 +++++----- Hlt/RecoConf/scripts/PrCheckerTrackResolution.py | 6 +++--- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 1 - Hlt/RecoConf/scripts/utils/Legend.py | 5 ++--- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 98153faeb90..3153fab9215 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -145,11 +145,11 @@ def get_eff(eff, hist, tf, histoName, label, var): def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, savepdf): - sys.path.append(os.path.abspath(plotstyle)) - from utils.LHCbStyle import setLHCbStyle, set_style - from utils.ConfigHistos import (efficiencyHistoDict, ghostHistoDict, - categoriesDict, getCuts) - from utils.Legend import place_legend + sys.path.append(os.path.abspath(plotstyle+"/utils/")) + from LHCbStyle import setLHCbStyle, set_style + from ConfigHistos import (efficiencyHistoDict, ghostHistoDict, + categoriesDict, getCuts) + from Legend import place_legend setLHCbStyle() markers = get_markers() diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index d4a74b52995..7026cb730ba 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -128,10 +128,10 @@ def get_resolution(resx, resy, tr, label): def PrCheckerIPresolution(filename, label, outfile, savepdf, plotstyle): - sys.path.append(os.path.abspath(plotstyle)) - from utils.LHCbStyle import setLHCbStyle, set_style + sys.path.append(os.path.abspath(plotstyle+"/utils/")) + from LHCbStyle import setLHCbStyle, set_style setLHCbStyle() - from utils.Legend import place_legend + from Legend import place_legend latex = TLatex() latex.SetNDC() latex.SetTextSize(0.05) @@ -225,6 +225,7 @@ def PrCheckerIPresolution(filename, label, outfile, savepdf, plotstyle): recIPChi2[lab] = TH1F("recIPChi2_" + lab, lab, 100, 0, 200) tr[lab].Draw(var + ">>recIPChi2_" + lab, cutAcc) recIPChi2[lab].SetLineColor(colors[i]) + recIPChi2[lab].SetMarkerColor(colors[i]) canvas.cd() latex.DrawLatex(0.7, 0.85, "LHCb simultaion") recIPChi2[label[0]].Draw() diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index 44aeabafd77..86d2fcd5932 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -144,11 +144,11 @@ def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): - sys.path.append(os.path.abspath(plotstyle)) - from utils.LHCbStyle import setLHCbStyle, set_style - from utils.ConfigHistos import (efficiencyHistoDict, categoriesDict, - getCuts) - from utils.Legend import place_legend + sys.path.append(os.path.abspath(plotstyle+"/utils/")) + from LHCbStyle import setLHCbStyle, set_style + from ConfigHistos import (efficiencyHistoDict, categoriesDict, + getCuts) + from Legend import place_legend setLHCbStyle() markers = get_markers() diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index 821ad3c7a61..5c9867f43b7 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -74,9 +74,9 @@ def argument_parser(): def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): - sys.path.append(os.path.abspath(plotstyle)) - from utils.LHCbStyle import setLHCbStyle, set_style - from utils.Legend import place_legend + sys.path.append(os.path.abspath(plotstyle+"/utils/")) + from LHCbStyle import setLHCbStyle, set_style + from Legend import place_legend setLHCbStyle() markers = get_markers() diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 28ab9fb16b9..edcd947e4b4 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -131,7 +131,6 @@ def categoriesDict(): "title"] = "Long from B, p>5GeV, 2<#eta<5" basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from B, p>3GeV, pt>0.5GeV, 2<#eta<5" - "title"] = "Long from D, p>3GeV, pt>0.5GeV, 2<#eta<5" basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from strange, p>3GeV, pt>0.5GeV, 2<#eta<5" basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index cba662ae1bf..e5daba27c99 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -107,7 +107,7 @@ def place_legend(canvas, gStyle.SetTextSize(0.06) # If position is specified, use that if all(x is not None for x in (x1, x2, y1, y2)): - return canvas.BuildLegend(x1, y1, x2, y2, header, option) + return canvas.BuildLegend(x1, y1, x2, y2, header ) # Make sure all objects are correctly registered canvas.Update() @@ -125,8 +125,7 @@ def place_legend(canvas, # Make sure there are no overlaps if any(obj.Overlap(*place_user) for obj in objects): continue - return canvas.BuildLegend(place[0], place[1], place[2], place[3], - header, option) + return canvas.BuildLegend(place[0], place[1], place[2], place[3], header) # As a fallback, use the default values, taken from TCanvas::BuildLegend return canvas.BuildLegend(0.4, 0.37, 0.88, 0.68, header, option) -- GitLab From b22c48f764d32a3e82cebc4bb1124098d56e4574 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 10 Mar 2020 10:11:02 +0000 Subject: [PATCH 121/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7525194 --- .../scripts/PrCheckerEfficiency_HLT1.py | 4 +-- Hlt/RecoConf/scripts/PrCheckerIPresolution.py | 2 +- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 5 ++- .../scripts/PrCheckerTrackResolution.py | 2 +- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 35 ++++++------------- Hlt/RecoConf/scripts/utils/Legend.py | 5 +-- 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 3153fab9215..cc411059e95 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -145,10 +145,10 @@ def get_eff(eff, hist, tf, histoName, label, var): def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, savepdf): - sys.path.append(os.path.abspath(plotstyle+"/utils/")) + sys.path.append(os.path.abspath(plotstyle + "/utils/")) from LHCbStyle import setLHCbStyle, set_style from ConfigHistos import (efficiencyHistoDict, ghostHistoDict, - categoriesDict, getCuts) + categoriesDict, getCuts) from Legend import place_legend setLHCbStyle() diff --git a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py index 7026cb730ba..b5a5f20ed60 100644 --- a/Hlt/RecoConf/scripts/PrCheckerIPresolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerIPresolution.py @@ -128,7 +128,7 @@ def get_resolution(resx, resy, tr, label): def PrCheckerIPresolution(filename, label, outfile, savepdf, plotstyle): - sys.path.append(os.path.abspath(plotstyle+"/utils/")) + sys.path.append(os.path.abspath(plotstyle + "/utils/")) from LHCbStyle import setLHCbStyle, set_style setLHCbStyle() from Legend import place_legend diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index 86d2fcd5932..1d92522d758 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -144,10 +144,9 @@ def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): def PrCheckerMuonIDEff(filename, outfile, label, plotstyle, savepdf, printval): - sys.path.append(os.path.abspath(plotstyle+"/utils/")) + sys.path.append(os.path.abspath(plotstyle + "/utils/")) from LHCbStyle import setLHCbStyle, set_style - from ConfigHistos import (efficiencyHistoDict, categoriesDict, - getCuts) + from ConfigHistos import (efficiencyHistoDict, categoriesDict, getCuts) from Legend import place_legend setLHCbStyle() diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index 5c9867f43b7..f43ad7c863b 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -74,7 +74,7 @@ def argument_parser(): def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): - sys.path.append(os.path.abspath(plotstyle+"/utils/")) + sys.path.append(os.path.abspath(plotstyle + "/utils/")) from LHCbStyle import setLHCbStyle, set_style from Legend import place_legend setLHCbStyle() diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index edcd947e4b4..0b00fcc07a6 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -65,26 +65,14 @@ def getCuts(): basedict = {"Velo": {}, "Upstream": {}, "Forward": {}, "MuonMatch": {}} basedict["Velo"] = [ - "01_velo", - "02_long", - "03_long_P>5GeV", - "04_long_strange", - "05_long_strange_P>5GeV", - "06_long_fromB", - "07_long_fromB_P>5GeV", - "11_long_fromB_P>3GeV_Pt>0.5GeV", - "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "01_velo", "02_long", "03_long_P>5GeV", "04_long_strange", + "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", + "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Upstream"] = [ - "01_velo", - "02_velo+UT", - "03_velo+UT_P>5GeV", - "07_long", - "08_long_P>5GeV", - "09_long_fromB", - "10_long_fromB_P>5GeV", - "14_long_fromB_P>3GeV_Pt>0.5GeV", - "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", + "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", + "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Forward"] = [ "01_long", "02_long_P>5GeV", "03_long_strange", @@ -92,10 +80,7 @@ def getCuts(): "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["MuonMatch"] = [ - "01_long", - "02_long_muon", - "03_long_muon_from_strange", - "04_long_pion" + "01_long", "02_long_muon", "03_long_muon_from_strange", "04_long_pion" ] return basedict @@ -179,7 +164,8 @@ def categoriesDict(): basedict["Upstream"]["08_long_P>5GeV"]["plotElectrons"] = False basedict["Upstream"]["09_long_fromB"]["plotElectrons"] = True basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True - basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True + basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = True basedict["Upstream"]["14_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Upstream"]["15_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -215,7 +201,8 @@ def categoriesDict(): basedict["Forward"]["04_long_strange_P>5GeV"]["plotElectrons"] = False basedict["Forward"]["05_long_fromB"]["plotElectrons"] = True basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True - basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True + basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ + "plotElectrons"] = True basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ diff --git a/Hlt/RecoConf/scripts/utils/Legend.py b/Hlt/RecoConf/scripts/utils/Legend.py index e5daba27c99..5d31c8dde3d 100644 --- a/Hlt/RecoConf/scripts/utils/Legend.py +++ b/Hlt/RecoConf/scripts/utils/Legend.py @@ -107,7 +107,7 @@ def place_legend(canvas, gStyle.SetTextSize(0.06) # If position is specified, use that if all(x is not None for x in (x1, x2, y1, y2)): - return canvas.BuildLegend(x1, y1, x2, y2, header ) + return canvas.BuildLegend(x1, y1, x2, y2, header) # Make sure all objects are correctly registered canvas.Update() @@ -125,7 +125,8 @@ def place_legend(canvas, # Make sure there are no overlaps if any(obj.Overlap(*place_user) for obj in objects): continue - return canvas.BuildLegend(place[0], place[1], place[2], place[3], header) + return canvas.BuildLegend(place[0], place[1], place[2], place[3], + header) # As a fallback, use the default values, taken from TCanvas::BuildLegend return canvas.BuildLegend(0.4, 0.37, 0.88, 0.68, header, option) -- GitLab From bcb4de5e49aa7f802cf478bc7aa8c91a11f84aac Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 10 Mar 2020 12:14:03 +0100 Subject: [PATCH 122/171] remove duplicated line --- PyConf/python/PyConf/application.py | 1 - 1 file changed, 1 deletion(-) diff --git a/PyConf/python/PyConf/application.py b/PyConf/python/PyConf/application.py index 34e73517cdc..6d974c7a853 100644 --- a/PyConf/python/PyConf/application.py +++ b/PyConf/python/PyConf/application.py @@ -520,7 +520,6 @@ def configure(options, control_flow_node, public_tools=[]): # Give more space for component names in stdout config.add(setup_component('MessageSvc', Format='% F%35W%S %7W%R%T %0W%M')) config.add(setup_component('HistogramPersistencySvc', OutputLevel=5)) - config.add(setup_component('NTupleSvc', OutputLevel=0)) config.add( setup_component('EventClockSvc', InitialTime=int(INITIAL_TIME * 1e9))) -- GitLab From 277e430e0b42eaa9d420adb735411359e749beb5 Mon Sep 17 00:00:00 2001 From: Peilian LI Date: Tue, 10 Mar 2020 12:30:04 +0100 Subject: [PATCH 123/171] remove useless import --- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index ecd89155137..23d97c2124b 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -12,9 +12,6 @@ from Moore import options, run_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks, make_pvs from RecoConf.mc_checking import monitor_IPresolution -from Configurables import ApplicationMgr -from Configurables import NTupleSvc - def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() -- GitLab From 8a03fbb5c45fa53c5d4a9944d23181784ab4ae93 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 10 Mar 2020 11:30:50 +0000 Subject: [PATCH 124/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7526872 --- Hlt/RecoConf/options/hlt1_reco_IPresolution.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py index 23d97c2124b..b47cf35c7e1 100644 --- a/Hlt/RecoConf/options/hlt1_reco_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_IPresolution.py @@ -13,6 +13,7 @@ from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec, make_hlt1_tracks, make_VeloKalman_fitted_tracks, make_pvs from RecoConf.mc_checking import monitor_IPresolution + def hlt1_reco_IPresolution(): hlt1_tracks = make_hlt1_tracks() fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) -- GitLab From 3f8159b924a5529cdc79e45d59aba34f08a03abf Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 12 Mar 2020 15:25:16 +0100 Subject: [PATCH 125/171] cleanup --- Hlt/Moore/tests/options/default_input_and_conds_hlt1.py | 2 +- Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 643c5f2a33a..b42bae71350 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -14,6 +14,6 @@ from Moore import options options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') #options.set_input_from_testfiledb("Upgrade_BsPhiPhi_MD_FTv4_DIGI") -options.evt_max = 10000 +options.evt_max = 1000 execfile(os.path.expandvars('$MOOREROOT/tests/options/default_conds.py')) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py index 7cf6d85fd1a..3623fbe7361 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py @@ -25,11 +25,6 @@ def hlt1_reco_allen_trackresolution(): tracks = make_allen_tracks()[track_type] pr_checker = monitor_track_resolution(tracks) - #return CompositeNode( - # name='hlt1_trackRes', - # children=pr_checker, - # combineLogic=NodeLogic.NONLAZY_OR, - # forceOrder=False) return Reconstruction('track_resolution', [pr_checker], [require_gec()]) -- GitLab From 3aae0cde193ab9c7d51e89bcde3498c2908c3eb9 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 13 Mar 2020 13:16:28 +0100 Subject: [PATCH 126/171] fix track resolution options script for Allen --- .../hlt1_reco_allen_trackresolution.py | 5 ++- ...reco_baseline_and_Allen_with_mcchecking.py | 32 ------------------- 2 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py index 3623fbe7361..65f8af35809 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py @@ -18,15 +18,14 @@ from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable from Configurables import DumpMuonGeometry, DumpVPGeometry from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import AllenUpdater - +from PyConf.application import make_data_with_FetchDataFromFile def hlt1_reco_allen_trackresolution(): track_type = "Forward" tracks = make_allen_tracks()[track_type] pr_checker = monitor_track_resolution(tracks) - return Reconstruction('track_resolution', [pr_checker], [require_gec()]) - + return Reconstruction('track_resolution', [make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), pr_checker], [require_gec()]) options.histo_file = "Hlt1ForwardTrackingResolutionAllen.root" run_reconstruction(options, hlt1_reco_allen_trackresolution) diff --git a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py b/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py deleted file mode 100644 index 3d3321275af..00000000000 --- a/Hlt/RecoConf/options/hlt1_reco_baseline_and_Allen_with_mcchecking.py +++ /dev/null @@ -1,32 +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. # -############################################################################### -from Moore import options, run_reconstruction -from RecoConf.standalone import standalone_hlt1_reco_and_allen -from Configurables import ApplicationMgr -from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable -from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks - -with standalone_hlt1_reco_and_allen.bind(do_mc_checking=True): - run_reconstruction(options, standalone_hlt1_reco_and_allen) - -producers = [ - p(DumpToFile=False) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) -] - -# Add the services that will produce the non-event-data -ApplicationMgr().ExtSvc += [ - AllenUpdater(OutputLevel=2), -] + producers -- GitLab From 97659f4525c0a39f6124e8eee2636a8d9cdc620a Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 13 Mar 2020 13:17:08 +0100 Subject: [PATCH 127/171] only call Allen algorithms for track reconstruction check for Allen --- Hlt/RecoConf/options/hlt1_reco_allen.py | 41 ++++++++++++++++++++++ Hlt/RecoConf/python/RecoConf/standalone.py | 15 ++------ 2 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 Hlt/RecoConf/options/hlt1_reco_allen.py diff --git a/Hlt/RecoConf/options/hlt1_reco_allen.py b/Hlt/RecoConf/options/hlt1_reco_allen.py new file mode 100644 index 00000000000..cb016107cd3 --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_allen.py @@ -0,0 +1,41 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from RecoConf.standalone import standalone_hlt1_allen +from Configurables import ApplicationMgr, HltANNSvc +from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable +from Configurables import DumpMuonGeometry, DumpVPGeometry +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks + +with standalone_hlt1_allen.bind(): + run_reconstruction(options, standalone_hlt1_allen) + +producers = [ + p(DumpToFile=False) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) +] + +# Add the services that will produce the non-event-data +ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), +] + producers + +Hlt1SelectionIDs = {'Hlt1DisplacedDiMuonLine': 4, + 'Hlt1HighMassDiMuonLine': 5, + 'Hlt1OneTrackMVALine': 1, + 'Hlt1PassThroughLine': 0, + 'Hlt1SingleMuonLine': 3, + 'Hlt1TwoTrackMVALine': 2} + +HltANNSvc().Hlt1SelectionID = Hlt1SelectionIDs diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 5fd1c3ccf8f..05790664b8b 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -70,23 +70,14 @@ def standalone_hlt1_reco(do_mc_checking=False): @configurable -def standalone_hlt1_reco_and_allen(do_mc_checking=False): - """ Run the Hlt1 reconstruction, i.e. tracking and muon id, MC checking optional both with the baseline and the Allen sequence +def standalone_hlt1_reco_allen(do_mc_checking=False): + """ Run the Hlt1 reconstruction, i.e. tracking and muon id, MC checking optional with the Allen sequence Args: do_mc_checking (bool): Enable MC checking. Returns: Reconstruction: Data and control flow of Hlt1 reconstruction. """ - # baseline hlt1 - hlt1_tracks = make_hlt1_tracks() - pvs = make_pvs() - fitted_tracks = make_VeloKalman_fitted_tracks(hlt1_tracks) - muon_ids = make_muon_id(hlt1_tracks["Forward"]) - tracks_with_muon_id = make_tracks_with_muon_id(fitted_tracks, muon_ids) - - data = [pvs, fitted_tracks["Pr"], tracks_with_muon_id] - # Allen hlt1 allen_tracks = make_allen_tracks() allen_pvs = make_allen_pvs() @@ -97,7 +88,7 @@ def standalone_hlt1_reco_and_allen(do_mc_checking=False): "Upstream": allen_tracks["Upstream"], "Forward": allen_tracks["Forward"], } - data += get_track_checkers(types_and_locations_for_checkers) + data = get_track_checkers(types_and_locations_for_checkers) return Reconstruction('hlt1_reco', data, reco_prefilters()) -- GitLab From 31be15554737d2c4848c58aa10cca7f243824cbd Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 13 Mar 2020 13:18:07 +0100 Subject: [PATCH 128/171] small fixes in plotting scripts, add fromD category to track reconstruction plots --- Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py | 6 ++++-- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 3 ++- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 13 ++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index cc411059e95..71f9c62aea5 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -126,7 +126,7 @@ def get_eff(eff, hist, tf, histoName, label, var): eff[lab] = TGraphAsymmErrors() eff[lab].SetName(lab) eff[lab].Divide(numerator, denominator, "cl=0.683 b(1,1) mode") - eff[lab].SetTitle(lab + "not elec.") + eff[lab].SetTitle(lab + ", not elec.") if (histoName.find('strange') != -1): eff[lab].SetTitle(lab + " from stranges") if (histoName.find('electron') != -1): @@ -210,7 +210,7 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, mg.GetYaxis().SetTitle("Efficiency") if dist: for i, lab in enumerate(label): - rightmax = 1.05 * hist_den[lab].GetMaximum() + rightmax = 1.1 * hist_den[lab].GetMaximum() scale = gPad.GetUymax() / rightmax hist_den[lab].Scale(scale) if i == 0: @@ -272,6 +272,8 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, scale = gPad.GetUymax() / rightmax hist_elec[lab].Scale(scale) hist_elec[lab].Draw("hist SAME") + set_style(hist_elec[label[0]], kGray + 1, markers[i], + styles[i]) else: rightmax = 1.05 * hist_elec[label[0]].GetMaximum() scale = gPad.GetUymax() / rightmax diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index 1d92522d758..bffa36ab54b 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -100,6 +100,7 @@ def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): eff = {} hist = {} for i, lab in enumerate(label): + print(histoName) numeratorName = histoName + "_reconstructed" numerator = tf[lab].Get(numeratorName) denominatorName = histoName_Den + "_reconstructed" @@ -112,7 +113,7 @@ def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): eff[lab] = TGraphAsymmErrors() eff[lab].SetName(lab) eff[lab].Divide(numerator, denominator, "cl=0.683 b(1,1) mode") - eff[lab].SetTitle(lab + "not elec.") + eff[lab].SetTitle(lab + ", not elec.") if (histoName.find('strange') != -1): eff[lab].SetTitle(lab + " from stranges") if (histoName.find('electron') != -1): diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 0b00fcc07a6..5e6f99d59c7 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -66,17 +66,17 @@ def getCuts(): basedict["Velo"] = [ "01_velo", "02_long", "03_long_P>5GeV", "04_long_strange", - "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", + "05_long_strange_P>5GeV", "06_long_fromB", "06_long_fromD", "07_long_fromB_P>5GeV", "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Upstream"] = [ "01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", - "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", + "08_long_P>5GeV", "09_long_fromB", "09_long_fromD", "10_long_fromB_P>5GeV", "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Forward"] = [ "01_long", "02_long_P>5GeV", "03_long_strange", - "04_long_strange_P>5GeV", "05_long_fromB", "06_long_fromB_P>5GeV", + "04_long_strange_P>5GeV", "05_long_fromB", "05_long_fromD", "06_long_fromB_P>5GeV", "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["MuonMatch"] = [ @@ -112,6 +112,7 @@ def categoriesDict(): basedict["Velo"]["05_long_strange_P>5GeV"][ "title"] = "Long, from Strange, p>5GeV, 2 <#eta < 5" basedict["Velo"]["06_long_fromB"]["title"] = "Long from B, 2<#eta<5" + basedict["Velo"]["06_long_fromD"]["title"] = "Long from D, 2<#eta<5" basedict["Velo"]["07_long_fromB_P>5GeV"][ "title"] = "Long from B, p>5GeV, 2<#eta<5" basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -120,12 +121,14 @@ def categoriesDict(): "title"] = "Long from strange, p>3GeV, pt>0.5GeV, 2<#eta<5" basedict["Velo"]["12_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ "title"] = "UT Long, from B, p>3GeV, pt>0.5GeV, 2<#eta<5" + basedict["Velo"]["01_velo"]["plotElectrons"] = False basedict["Velo"]["02_long"]["plotElectrons"] = True basedict["Velo"]["03_long_P>5GeV"]["plotElectrons"] = False basedict["Velo"]["04_long_strange"]["plotElectrons"] = False basedict["Velo"]["05_long_strange_P>5GeV"]["plotElectrons"] = False basedict["Velo"]["06_long_fromB"]["plotElectrons"] = True + basedict["Velo"]["06_long_fromD"]["plotElectrons"] = False basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = True basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"][ @@ -148,6 +151,7 @@ def categoriesDict(): basedict["Upstream"]["08_long_P>5GeV"][ "title"] = "Long, p>5GeV, 2 <#eta < 5" basedict["Upstream"]["09_long_fromB"]["title"] = "Long from B, 2 <#eta < 5" + basedict["Upstream"]["09_long_fromD"]["title"] = "Long from D, 2 <#eta < 5" basedict["Upstream"]["10_long_fromB_P>5GeV"][ "title"] = "Long from B, p>5GeV, 2 <#eta < 5" basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -163,6 +167,7 @@ def categoriesDict(): basedict["Upstream"]["07_long"]["plotElectrons"] = True basedict["Upstream"]["08_long_P>5GeV"]["plotElectrons"] = False basedict["Upstream"]["09_long_fromB"]["plotElectrons"] = True + basedict["Upstream"]["09_long_fromD"]["plotElectrons"] = False basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = True @@ -190,6 +195,7 @@ def categoriesDict(): "title"] = "Long from B, p>5GeV 2 <#eta < 5" basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from B, p>3GeV, pt>0.5GeV, 2 <#eta < 5" + basedict["Forward"]["05_long_fromD"]["title"] = "Long from D, 2 <#eta < 5" basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from strange, p>3GeV, pt>0.5GeV, 2 <#eta < 5" basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -203,6 +209,7 @@ def categoriesDict(): basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = True + basedict["Forward"]["05_long_fromD"]["plotElectrons"] = False basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ -- GitLab From 4b1551c1aab469f1a8e1fb27c5cf48ede3aa89ed Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Mon, 16 Mar 2020 14:51:52 +0100 Subject: [PATCH 129/171] typo fix, add efficiency versus z figure --- Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py | 4 ++-- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 71f9c62aea5..1d12505bf09 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -34,7 +34,7 @@ import subprocess def getEfficiencyHistoNames(): - return ["eta", "p", "pt", "phi", "nPV"] + return ["eta", "p", "pt", "phi", "nPV", "z", "docaz"] def getTrackers(): @@ -232,7 +232,7 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, for lab in label: eff[lab].Draw("P SAME") cutName = categories[tracker][cut]["title"] - latex.DrawLatex(0.7, 0.85, "LHCb simultaion") + latex.DrawLatex(0.7, 0.85, "LHCb simulation") latex.DrawLatex(0.35, 0.3, cutName) canvasName = tracker + "_" + cut + "_" + histo + ".pdf" if savepdf: diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 5e6f99d59c7..84909443889 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -19,7 +19,8 @@ def efficiencyHistoDict(): "pt": {}, "phi": {}, "nPV": {}, - "docaz": {} + "docaz": {}, + "z": {} } basedict["eta"]["xTitle"] = "#eta" @@ -35,11 +36,14 @@ def efficiencyHistoDict(): basedict["phi"]["variable"] = "Phi" basedict["nPV"]["xTitle"] = "# of PVs" - basedict["nPV"]["variable"] = "nPV" + basedict["nPV"]["variable"] = "nPV" - basedict["docaz"]["xTitle"] = "docaz (mm)" + basedict["docaz"]["xTitle"] = "docaz [mm]" basedict["docaz"]["variable"] = "docaz" + basedict["z"]["xTitle"] = "PV z coordinate [mm]" + basedict["z"]["variable"] = "z" + return basedict -- GitLab From 74aaddadcb8c9c802655086fba06cb3c9e2c4bbb Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Tue, 17 Mar 2020 09:49:59 +0100 Subject: [PATCH 130/171] typo fix --- Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 1d12505bf09..f72d451bfa0 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -34,7 +34,7 @@ import subprocess def getEfficiencyHistoNames(): - return ["eta", "p", "pt", "phi", "nPV", "z", "docaz"] + return ["eta", "p", "pt", "phi", "nPV", "docaz"] def getTrackers(): @@ -285,7 +285,7 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, canvas_elec.PlaceLegend() for lab in label: eff_elec[lab].Draw("P SAME") - latex.DrawLatex(0.7, 0.85, "LHCb simultaion") + latex.DrawLatex(0.7, 0.85, "LHCb simulation") latex.DrawLatex(0.35, 0.3, cutName) canvasName_elec = tracker + "_" + cut + "_" + histo + "_elec.pdf" if savepdf: @@ -333,7 +333,7 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, for lab in label: eff[lab].Draw("P SAME") eff_elec[lab].Draw("P SAME") - latex.DrawLatex(0.7, 0.85, "LHCb simultaion") + latex.DrawLatex(0.7, 0.85, "LHCb simulation") latex.DrawLatex(0.35, 0.3, cutName) canvas_com.SetRightMargin(0.05) canvas_com.Write() -- GitLab From 75a8d4e954bc19409e056b8532f43abfb09c1d34 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 17 Mar 2020 08:51:04 +0000 Subject: [PATCH 131/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7610865 --- Hlt/RecoConf/options/hlt1_reco_allen.py | 14 ++++++++------ .../hlt1_reco_allen_trackresolution.py | 9 +++++++-- .../scripts/PrCheckerEfficiency_HLT1.py | 4 ++-- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 19 +++++++++++-------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen.py b/Hlt/RecoConf/options/hlt1_reco_allen.py index cb016107cd3..2512654155d 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen.py @@ -31,11 +31,13 @@ ApplicationMgr().ExtSvc += [ AllenUpdater(OutputLevel=2), ] + producers -Hlt1SelectionIDs = {'Hlt1DisplacedDiMuonLine': 4, - 'Hlt1HighMassDiMuonLine': 5, - 'Hlt1OneTrackMVALine': 1, - 'Hlt1PassThroughLine': 0, - 'Hlt1SingleMuonLine': 3, - 'Hlt1TwoTrackMVALine': 2} +Hlt1SelectionIDs = { + 'Hlt1DisplacedDiMuonLine': 4, + 'Hlt1HighMassDiMuonLine': 5, + 'Hlt1OneTrackMVALine': 1, + 'Hlt1PassThroughLine': 0, + 'Hlt1SingleMuonLine': 3, + 'Hlt1TwoTrackMVALine': 2 +} HltANNSvc().Hlt1SelectionID = Hlt1SelectionIDs diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py index 65f8af35809..d9c02262ed9 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py @@ -18,14 +18,19 @@ from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable from Configurables import DumpMuonGeometry, DumpVPGeometry from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import AllenUpdater -from PyConf.application import make_data_with_FetchDataFromFile +from PyConf.application import make_data_with_FetchDataFromFile + def hlt1_reco_allen_trackresolution(): track_type = "Forward" tracks = make_allen_tracks()[track_type] pr_checker = monitor_track_resolution(tracks) - return Reconstruction('track_resolution', [make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), pr_checker], [require_gec()]) + return Reconstruction( + 'track_resolution', + [make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), pr_checker], + [require_gec()]) + options.histo_file = "Hlt1ForwardTrackingResolutionAllen.root" run_reconstruction(options, hlt1_reco_allen_trackresolution) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index f72d451bfa0..b2fbc600ccb 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -272,8 +272,8 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, scale = gPad.GetUymax() / rightmax hist_elec[lab].Scale(scale) hist_elec[lab].Draw("hist SAME") - set_style(hist_elec[label[0]], kGray + 1, markers[i], - styles[i]) + set_style(hist_elec[label[0]], kGray + 1, + markers[i], styles[i]) else: rightmax = 1.05 * hist_elec[label[0]].GetMaximum() scale = gPad.GetUymax() / rightmax diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 84909443889..58df4386502 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -36,13 +36,13 @@ def efficiencyHistoDict(): basedict["phi"]["variable"] = "Phi" basedict["nPV"]["xTitle"] = "# of PVs" - basedict["nPV"]["variable"] = "nPV" + basedict["nPV"]["variable"] = "nPV" basedict["docaz"]["xTitle"] = "docaz [mm]" basedict["docaz"]["variable"] = "docaz" basedict["z"]["xTitle"] = "PV z coordinate [mm]" - basedict["z"]["variable"] = "z" + basedict["z"]["variable"] = "z" return basedict @@ -70,18 +70,21 @@ def getCuts(): basedict["Velo"] = [ "01_velo", "02_long", "03_long_P>5GeV", "04_long_strange", - "05_long_strange_P>5GeV", "06_long_fromB", "06_long_fromD", "07_long_fromB_P>5GeV", - "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "05_long_strange_P>5GeV", "06_long_fromB", "06_long_fromD", + "07_long_fromB_P>5GeV", "11_long_fromB_P>3GeV_Pt>0.5GeV", + "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Upstream"] = [ "01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", - "08_long_P>5GeV", "09_long_fromB", "09_long_fromD", "10_long_fromB_P>5GeV", - "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "08_long_P>5GeV", "09_long_fromB", "09_long_fromD", + "10_long_fromB_P>5GeV", "14_long_fromB_P>3GeV_Pt>0.5GeV", + "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Forward"] = [ "01_long", "02_long_P>5GeV", "03_long_strange", - "04_long_strange_P>5GeV", "05_long_fromB", "05_long_fromD", "06_long_fromB_P>5GeV", - "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "04_long_strange_P>5GeV", "05_long_fromB", "05_long_fromD", + "06_long_fromB_P>5GeV", "10_long_fromB_P>3GeV_Pt>0.5GeV", + "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["MuonMatch"] = [ "01_long", "02_long_muon", "03_long_muon_from_strange", "04_long_pion" -- GitLab From 7729565e9b939918e4840e1176219688cc38c669 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 3 Apr 2020 12:32:28 +0200 Subject: [PATCH 132/171] adjust to parameter name changes in RunAllen --- Hlt/RecoConf/options/hlt1_reco_allen.py | 43 ---------------------- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 4 +- 2 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 Hlt/RecoConf/options/hlt1_reco_allen.py diff --git a/Hlt/RecoConf/options/hlt1_reco_allen.py b/Hlt/RecoConf/options/hlt1_reco_allen.py deleted file mode 100644 index 2512654155d..00000000000 --- a/Hlt/RecoConf/options/hlt1_reco_allen.py +++ /dev/null @@ -1,43 +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. # -############################################################################### -from Moore import options, run_reconstruction -from RecoConf.standalone import standalone_hlt1_allen -from Configurables import ApplicationMgr, HltANNSvc -from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable -from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks - -with standalone_hlt1_allen.bind(): - run_reconstruction(options, standalone_hlt1_allen) - -producers = [ - p(DumpToFile=False) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) -] - -# Add the services that will produce the non-event-data -ApplicationMgr().ExtSvc += [ - AllenUpdater(OutputLevel=2), -] + producers - -Hlt1SelectionIDs = { - 'Hlt1DisplacedDiMuonLine': 4, - 'Hlt1HighMassDiMuonLine': 5, - 'Hlt1OneTrackMVALine': 1, - 'Hlt1PassThroughLine': 0, - 'Hlt1SingleMuonLine': 3, - 'Hlt1TwoTrackMVALine': 2 -} - -HltANNSvc().Hlt1SelectionID = Hlt1SelectionIDs diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 391461b636c..5fa88c2b974 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -35,8 +35,8 @@ def make_allen_output(odin_location=make_odin, return RunAllen( AllenRawInput=dumped_raw_banks(), ODINLocation=odin_location(), - filter_HLT1=filter_hlt1, - ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", + FILTERHLT1=filter_hlt1, + PARAMDIR="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", JSON="${ALLEN_PROJECT_ROOT}/configuration/constants/default.json" ).AllenOutput -- GitLab From 66cfbc0c11814b7e52869da29863d3857dc21dc6 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 8 Apr 2020 10:54:29 +0200 Subject: [PATCH 133/171] add missing options file for track reconstruction efficiency check with Allen --- .../hlt1_reco_allen_track_reconstruction.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py new file mode 100644 index 00000000000..d14d33f9bd9 --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py @@ -0,0 +1,32 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from RecoConf.standalone import standalone_hlt1_reco_allen +from Configurables import ApplicationMgr +from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable +from Configurables import DumpMuonGeometry, DumpVPGeometry +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks + +with standalone_hlt1_reco_allen.bind(do_mc_checking=True): + run_reconstruction(options, standalone_hlt1_reco_allen) + +producers = [ + p(DumpToFile=False) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) +] + +# Add the services that will produce the non-event-data +ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), +] + producers -- GitLab From 0f90d5b653bfcb3518e7841921f1c0073c9fd513 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 8 Apr 2020 20:20:23 +0200 Subject: [PATCH 134/171] add tracker_dumper to mc_checking --- .../hlt1_reco_allen_track_reconstruction.py | 4 ++- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 36 +++++++++++-------- Hlt/RecoConf/python/RecoConf/mc_checking.py | 28 +++++++++++---- Hlt/RecoConf/python/RecoConf/standalone.py | 6 ++-- 4 files changed, 49 insertions(+), 25 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py index d14d33f9bd9..c2b40b4a844 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py @@ -16,7 +16,9 @@ from Configurables import DumpMuonGeometry, DumpVPGeometry from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks -with standalone_hlt1_reco_allen.bind(do_mc_checking=True): +dumpBinaries = True + +with standalone_hlt1_reco_allen.bind(do_mc_checking=True, dump_binaries=dumpBinaries): run_reconstruction(options, standalone_hlt1_reco_allen) producers = [ diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 5fa88c2b974..d94c83092e8 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -14,6 +14,8 @@ from PyConf.application import default_raw_event, make_odin from Configurables import (VPClus, createODIN, DumpRawBanks, RunAllen) +from RecoConf.mc_checking import tracker_dumper + from PyConf.Algorithms import ( LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track, AllenVeloToV2Tracks, AllenUTToV2Tracks, AllenForwardToV2Tracks, @@ -22,27 +24,28 @@ from PyConf.Algorithms import HltDecReportsDecoder @configurable -def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin): +def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin, dump_to_file=False): return DumpRawBanks( RawEventLocation=make_raw(), ODINLocation=odin_location(), - DumpToFile=False).AllenRawInput + DumpToFile=dump_to_file).AllenRawInput def make_allen_output(odin_location=make_odin, dumped_raw_banks=make_dumped_raw_banks, - filter_hlt1=False): + filter_hlt1=False, + dump_to_file=False): return RunAllen( - AllenRawInput=dumped_raw_banks(), - ODINLocation=odin_location(), + AllenRawInput=dumped_raw_banks(dump_to_file=dump_to_file), + ODINLocation=odin_location(), FILTERHLT1=filter_hlt1, PARAMDIR="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", JSON="${ALLEN_PROJECT_ROOT}/configuration/constants/default.json" ).AllenOutput -def make_allen_velo_tracks(): - allen_output = make_allen_output() +def make_allen_velo_tracks(dumpToFile=False): + allen_output = make_allen_output(dump_to_file=dumpToFile) velo_tracks_v2 = AllenVeloToV2Tracks(AllenOutput=allen_output).OutputTracks velo_tracks_v1 = FromV2TrackV1Track( InputTracksName=velo_tracks_v2).OutputTracksName @@ -50,8 +53,8 @@ def make_allen_velo_tracks(): return {"v2": velo_tracks_v2, "v1": velo_tracks_v1} -def make_allen_veloUT_tracks(): - allen_output = make_allen_output() +def make_allen_veloUT_tracks(dumpToFile=False): + allen_output = make_allen_output(dump_to_file=dumpToFile) veloUT_tracks_v2 = AllenUTToV2Tracks(AllenOutput=allen_output).OutputTracks veloUT_tracks_v1 = FromV2TrackV1Track( InputTracksName=veloUT_tracks_v2).OutputTracksName @@ -59,8 +62,8 @@ def make_allen_veloUT_tracks(): return {"v2": veloUT_tracks_v2, "v1": veloUT_tracks_v1} -def make_allen_forward_tracks(): - allen_output = make_allen_output() +def make_allen_forward_tracks(dumpToFile=False): + allen_output = make_allen_output(dump_to_file=dumpToFile) forward_tracks_v2 = AllenForwardToV2Tracks( AllenOutput=allen_output).OutputTracks forward_tracks_v1 = FromV2TrackV1Track( @@ -79,10 +82,13 @@ def make_allen_forward_muon_tracks(): return {"v2": forward_muon_tracks_v2, "v1": forward_muon_tracks_v1} -def make_allen_tracks(): - velo_tracks = make_allen_velo_tracks() - velo_ut_tracks = make_allen_veloUT_tracks() - forward_tracks = make_allen_forward_tracks() +def make_allen_tracks(dump_to_file=False): + velo_tracks = make_allen_velo_tracks(dumpToFile=dump_to_file) + velo_ut_tracks = make_allen_veloUT_tracks(dumpToFile=dump_to_file) + forward_tracks = make_allen_forward_tracks(dumpToFile=dump_to_file) + + if dump_to_file: + tracker_dumper(dump_to_root=True, dump_to_binary=True) return { "Velo": velo_tracks, diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 2d3e5038326..ed699475bcf 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -16,21 +16,22 @@ from PyConf.tonic import (configurable) from PyConf.dataflow import DataHandle from PyConf.components import Tool -from PyConf.application import default_raw_event +from PyConf.application import default_raw_event, make_odin from PyConf.application import make_data_with_FetchDataFromFile from PyConf.Algorithms import ( VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, PrTrackAssociator, PrLHCbID2MCParticleVPUTFTMU, PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, - DataPacking__Unpack_LHCb__MCVPHitPacker_, PrimaryVertexChecker) + DataPacking__Unpack_LHCb__MCVPHitPacker_, PrimaryVertexChecker, PrTrackerDumper) from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector from RecoConf.hlt1_tracking import (make_PrStoreUTHit_hits, make_FTRawBankDecoder_clusters, - make_velo_full_clusters) + make_velo_full_clusters, + make_VPClus_hits, make_PrStoreFTHit_hits) from Hlt2Conf.data_from_file import mc_unpackers @@ -64,7 +65,7 @@ def make_links_lhcbids_mcparticles_tracking_system(): MCParticlesLocation=mc_unpackers()["MCParticles"], VPFullClustersLocation=make_velo_full_clusters(), VPFullClustersLinkLocation=make_links_veloclusters_mcparticles(), - UTHitsLocation=make_PrStoreUTHit_hits(), + UTHitsLocation=make_PrStoreUTHit_hits(), UTHitsLinkLocation=make_data_with_FetchDataFromFile( '/Event/Link/Raw/UT/Clusters'), FTLiteClustersLocation=make_FTRawBankDecoder_clusters(), @@ -78,7 +79,7 @@ def make_links_lhcbids_mcparticles_tracking_and_muon_system(): """ return PrLHCbID2MCParticleVPUTFTMU( MCParticlesLocation=mc_unpackers()["MCParticles"], - VPFullClustersLocation=make_velo_full_clusters(), + VPFullClustersLocation=make_velo_full_clusters(), VPFullClustersLinkLocation=make_links_veloclusters_mcparticles(), UTHitsLocation=make_PrStoreUTHit_hits(), UTHitsLinkLocation=make_data_with_FetchDataFromFile( @@ -273,7 +274,7 @@ def get_pv_checkers( assert isinstance( pvs, DataHandle), "Please provide reconstructed primary verticies" - links_to_lhcbids = make_links_lhcbids_mcparticles() + links_to_lhcbids = make_links_lhcbids_mcparticles() links_to_tracks = make_links_tracks_mcparticles( InputTracks=tracks, LinksToLHCbIDs=links_to_lhcbids) pv_checkers = [] @@ -330,3 +331,18 @@ def monitor_IPresolution(InputTracks, InputPVs, VeloTracks): PVContainer=vertexConverter, NTupleLUN="FILE1") return IPres_checker + +def tracker_dumper(odin_location=make_odin, dump_to_root=True, dump_to_binary=False): + links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() + + return PrTrackerDumper( + MCParticlesLocation=mc_unpackers()["MCParticles"], + VPLightClusterLocation=make_VPClus_hits(), + FTHitsLocation=make_PrStoreFTHit_hits(), + UTHitsLocation=make_PrStoreUTHit_hits(), + ODINLocation=odin_location(), + LinkerLocation=links_to_lhcbids, + DumpToROOT=dump_to_root, + DumpToBinary=dump_to_binary + ) + diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 80677ec549c..a53b791137b 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -17,7 +17,7 @@ from .hlt1_tracking import ( all_hlt1_forward_track_types, make_TrackEventFitter_fitted_tracks, make_hlt1_fitted_tracks) from .hlt1_allen import (make_allen_tracks, make_allen_pvs, - make_allen_dec_reports) + make_allen_dec_reports, make_dumped_raw_banks) from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks @@ -71,7 +71,7 @@ def standalone_hlt1_reco(do_mc_checking=False): @configurable -def standalone_hlt1_reco_allen(do_mc_checking=False): +def standalone_hlt1_reco_allen(do_mc_checking=False, dump_binaries=False): """ Run the Hlt1 reconstruction, i.e. tracking and muon id, MC checking optional with the Allen sequence Args: do_mc_checking (bool): Enable MC checking. @@ -80,7 +80,7 @@ def standalone_hlt1_reco_allen(do_mc_checking=False): """ # Allen hlt1 - allen_tracks = make_allen_tracks() + allen_tracks = make_allen_tracks(dump_to_file=dump_binaries) allen_pvs = make_allen_pvs() if do_mc_checking: -- GitLab From 88742ab50ada0c585044bf018670ea11b2b6da2c Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 8 Apr 2020 18:20:57 +0000 Subject: [PATCH 135/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7924502 --- .../hlt1_reco_allen_track_reconstruction.py | 3 +- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 6 ++-- Hlt/RecoConf/python/RecoConf/mc_checking.py | 33 ++++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py index c2b40b4a844..4599fcdd371 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py @@ -18,7 +18,8 @@ from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenV dumpBinaries = True -with standalone_hlt1_reco_allen.bind(do_mc_checking=True, dump_binaries=dumpBinaries): +with standalone_hlt1_reco_allen.bind( + do_mc_checking=True, dump_binaries=dumpBinaries): run_reconstruction(options, standalone_hlt1_reco_allen) producers = [ diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index d94c83092e8..a0790462456 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -24,7 +24,9 @@ from PyConf.Algorithms import HltDecReportsDecoder @configurable -def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin, dump_to_file=False): +def make_dumped_raw_banks(make_raw=default_raw_event, + odin_location=make_odin, + dump_to_file=False): return DumpRawBanks( RawEventLocation=make_raw(), ODINLocation=odin_location(), @@ -37,7 +39,7 @@ def make_allen_output(odin_location=make_odin, dump_to_file=False): return RunAllen( AllenRawInput=dumped_raw_banks(dump_to_file=dump_to_file), - ODINLocation=odin_location(), + ODINLocation=odin_location(), FILTERHLT1=filter_hlt1, PARAMDIR="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", JSON="${ALLEN_PROJECT_ROOT}/configuration/constants/default.json" diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index ed699475bcf..096ea89b5ed 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -23,15 +23,15 @@ from PyConf.Algorithms import ( VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, PrTrackAssociator, PrLHCbID2MCParticleVPUTFTMU, PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, - DataPacking__Unpack_LHCb__MCVPHitPacker_, PrimaryVertexChecker, PrTrackerDumper) + DataPacking__Unpack_LHCb__MCVPHitPacker_, PrimaryVertexChecker, + PrTrackerDumper) from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector -from RecoConf.hlt1_tracking import (make_PrStoreUTHit_hits, - make_FTRawBankDecoder_clusters, - make_velo_full_clusters, - make_VPClus_hits, make_PrStoreFTHit_hits) +from RecoConf.hlt1_tracking import ( + make_PrStoreUTHit_hits, make_FTRawBankDecoder_clusters, + make_velo_full_clusters, make_VPClus_hits, make_PrStoreFTHit_hits) from Hlt2Conf.data_from_file import mc_unpackers @@ -65,7 +65,7 @@ def make_links_lhcbids_mcparticles_tracking_system(): MCParticlesLocation=mc_unpackers()["MCParticles"], VPFullClustersLocation=make_velo_full_clusters(), VPFullClustersLinkLocation=make_links_veloclusters_mcparticles(), - UTHitsLocation=make_PrStoreUTHit_hits(), + UTHitsLocation=make_PrStoreUTHit_hits(), UTHitsLinkLocation=make_data_with_FetchDataFromFile( '/Event/Link/Raw/UT/Clusters'), FTLiteClustersLocation=make_FTRawBankDecoder_clusters(), @@ -79,7 +79,7 @@ def make_links_lhcbids_mcparticles_tracking_and_muon_system(): """ return PrLHCbID2MCParticleVPUTFTMU( MCParticlesLocation=mc_unpackers()["MCParticles"], - VPFullClustersLocation=make_velo_full_clusters(), + VPFullClustersLocation=make_velo_full_clusters(), VPFullClustersLinkLocation=make_links_veloclusters_mcparticles(), UTHitsLocation=make_PrStoreUTHit_hits(), UTHitsLinkLocation=make_data_with_FetchDataFromFile( @@ -274,7 +274,7 @@ def get_pv_checkers( assert isinstance( pvs, DataHandle), "Please provide reconstructed primary verticies" - links_to_lhcbids = make_links_lhcbids_mcparticles() + links_to_lhcbids = make_links_lhcbids_mcparticles() links_to_tracks = make_links_tracks_mcparticles( InputTracks=tracks, LinksToLHCbIDs=links_to_lhcbids) pv_checkers = [] @@ -332,17 +332,18 @@ def monitor_IPresolution(InputTracks, InputPVs, VeloTracks): NTupleLUN="FILE1") return IPres_checker -def tracker_dumper(odin_location=make_odin, dump_to_root=True, dump_to_binary=False): - links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() - + +def tracker_dumper(odin_location=make_odin, + dump_to_root=True, + dump_to_binary=False): + links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() + return PrTrackerDumper( MCParticlesLocation=mc_unpackers()["MCParticles"], VPLightClusterLocation=make_VPClus_hits(), FTHitsLocation=make_PrStoreFTHit_hits(), - UTHitsLocation=make_PrStoreUTHit_hits(), - ODINLocation=odin_location(), + UTHitsLocation=make_PrStoreUTHit_hits(), + ODINLocation=odin_location(), LinkerLocation=links_to_lhcbids, DumpToROOT=dump_to_root, - DumpToBinary=dump_to_binary - ) - + DumpToBinary=dump_to_binary) -- GitLab From f102e403cb40cc32f5b32d0194c5aef707d8b8ca Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 9 Apr 2020 10:45:10 +0200 Subject: [PATCH 136/171] dump banks and info from TrackerDumper into 'dump' directory --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 13 +++++-------- Hlt/RecoConf/python/RecoConf/mc_checking.py | 7 ++++++- Hlt/RecoConf/python/RecoConf/standalone.py | 6 +++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index a0790462456..0b605a1b71a 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -14,8 +14,6 @@ from PyConf.application import default_raw_event, make_odin from Configurables import (VPClus, createODIN, DumpRawBanks, RunAllen) -from RecoConf.mc_checking import tracker_dumper - from PyConf.Algorithms import ( LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track, AllenVeloToV2Tracks, AllenUTToV2Tracks, AllenForwardToV2Tracks, @@ -26,11 +24,13 @@ from PyConf.Algorithms import HltDecReportsDecoder @configurable def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin, - dump_to_file=False): + dump_to_file=False, + output_dir="dump/banks"): return DumpRawBanks( RawEventLocation=make_raw(), ODINLocation=odin_location(), - DumpToFile=dump_to_file).AllenRawInput + DumpToFile=dump_to_file, + OutputDirectory=output_dir).AllenRawInput def make_allen_output(odin_location=make_odin, @@ -88,10 +88,7 @@ def make_allen_tracks(dump_to_file=False): velo_tracks = make_allen_velo_tracks(dumpToFile=dump_to_file) velo_ut_tracks = make_allen_veloUT_tracks(dumpToFile=dump_to_file) forward_tracks = make_allen_forward_tracks(dumpToFile=dump_to_file) - - if dump_to_file: - tracker_dumper(dump_to_root=True, dump_to_binary=True) - + return { "Velo": velo_tracks, "Upstream": velo_ut_tracks, diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 096ea89b5ed..2d38fd04048 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -334,6 +334,8 @@ def monitor_IPresolution(InputTracks, InputPVs, VeloTracks): def tracker_dumper(odin_location=make_odin, + root_output_dir="dump/TrackerDumper", + bin_output_dir="dump/MC_info/tracks", dump_to_root=True, dump_to_binary=False): links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() @@ -346,4 +348,7 @@ def tracker_dumper(odin_location=make_odin, ODINLocation=odin_location(), LinkerLocation=links_to_lhcbids, DumpToROOT=dump_to_root, - DumpToBinary=dump_to_binary) + DumpToBinary=dump_to_binary, + OutputDirectory=root_output_dir, + MCOutputDirectory=bin_output_dir) + diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index a53b791137b..27d98f4b6ff 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -22,7 +22,7 @@ from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks from .calorimeter_reconstruction import make_calo -from .mc_checking import get_track_checkers, get_best_tracks_checkers, get_pv_checkers +from .mc_checking import get_track_checkers, get_best_tracks_checkers, get_pv_checkers, tracker_dumper from .reco_objects_from_file import reconstruction from PyConf.application import default_raw_event from .rich_reconstruction import make_rich_pids, make_rich_pixels, default_rich_reco_options @@ -90,7 +90,11 @@ def standalone_hlt1_reco_allen(do_mc_checking=False, dump_binaries=False): "Forward": allen_tracks["Forward"], } data = get_track_checkers(types_and_locations_for_checkers) + + if dump_binaries: + data.append(tracker_dumper(dump_to_root=False, dump_to_binary=True)) + return Reconstruction('hlt1_reco', data, reco_prefilters()) -- GitLab From 92ea97ff76f79ba4e9529629187ef0f2fa0aabf1 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 9 Apr 2020 11:52:33 +0200 Subject: [PATCH 137/171] add pv dumper --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 2 +- Hlt/RecoConf/python/RecoConf/mc_checking.py | 11 +++++++++++ Hlt/RecoConf/python/RecoConf/standalone.py | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 0b605a1b71a..7be9ad93414 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -20,7 +20,6 @@ from PyConf.Algorithms import ( AllenPVsToRecVertexV2, AllenDecReportsToTES, DumpRawBanks, RunAllen) from PyConf.Algorithms import HltDecReportsDecoder - @configurable def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin, @@ -108,3 +107,4 @@ def make_allen_dec_reports(): return HltDecReportsDecoder( RawEventLocations=allen_dec_reports_raw, SourceID=1).OutputHltDecReportsLocation + diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 2d38fd04048..c57febdc3a2 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -40,6 +40,7 @@ from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask from RecoConf.hlt1_muonid import make_muon_hits from PyConf.Tools import VisPrimVertTool +from Configurables import PVDumper def get_item(x, key): """Return `key` from `x` if `x` is a dict, otherwise return `x`. @@ -352,3 +353,13 @@ def tracker_dumper(odin_location=make_odin, OutputDirectory=root_output_dir, MCOutputDirectory=bin_output_dir) +def pv_dumper(odin_location=make_odin, + output_dir="dump/MC_info/PVs"): + mc_vertices = mc_unpackers()["MCVertices"] + mc_property_location = make_data_with_FetchDataFromFile("/Event/MC/TrackInfo") + return PVDumper( + MCVerticesLocation=mc_vertices, + MCPropertyLocation=mc_property_location, + ODINLocation=odin_location()) + + diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 27d98f4b6ff..08f11d27be0 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -22,7 +22,7 @@ from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut from .hlt1_muonid import make_muon_id, make_tracks_with_muon_id from .hlt2_tracking import make_hlt2_tracks, make_TrackBestTrackCreator_tracks from .calorimeter_reconstruction import make_calo -from .mc_checking import get_track_checkers, get_best_tracks_checkers, get_pv_checkers, tracker_dumper +from .mc_checking import get_track_checkers, get_best_tracks_checkers, get_pv_checkers, tracker_dumper, pv_dumper from .reco_objects_from_file import reconstruction from PyConf.application import default_raw_event from .rich_reconstruction import make_rich_pids, make_rich_pixels, default_rich_reco_options @@ -93,7 +93,7 @@ def standalone_hlt1_reco_allen(do_mc_checking=False, dump_binaries=False): if dump_binaries: data.append(tracker_dumper(dump_to_root=False, dump_to_binary=True)) - + data.append(pv_dumper()) return Reconstruction('hlt1_reco', data, reco_prefilters()) -- GitLab From 1d32737f276d91f2cf283a55184d62982c87bc29 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 9 Apr 2020 17:24:56 +0200 Subject: [PATCH 138/171] no import from Configurables --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 2 -- Hlt/RecoConf/python/RecoConf/mc_checking.py | 13 +++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 7be9ad93414..0c19185cf97 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -12,8 +12,6 @@ from PyConf import configurable from PyConf.application import default_raw_event, make_odin -from Configurables import (VPClus, createODIN, DumpRawBanks, RunAllen) - from PyConf.Algorithms import ( LHCb__Converters__Track__v1__fromV2TrackV1Track as FromV2TrackV1Track, AllenVeloToV2Tracks, AllenUTToV2Tracks, AllenForwardToV2Tracks, diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index c57febdc3a2..7abb9dbeda5 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -24,7 +24,7 @@ from PyConf.Algorithms import ( PrLHCbID2MCParticleVPUTFTMU, PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, DataPacking__Unpack_LHCb__MCVPHitPacker_, PrimaryVertexChecker, - PrTrackerDumper) + PrTrackerDumper, PVDumper) from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector @@ -40,8 +40,6 @@ from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask from RecoConf.hlt1_muonid import make_muon_hits from PyConf.Tools import VisPrimVertTool -from Configurables import PVDumper - def get_item(x, key): """Return `key` from `x` if `x` is a dict, otherwise return `x`. @@ -355,11 +353,10 @@ def tracker_dumper(odin_location=make_odin, def pv_dumper(odin_location=make_odin, output_dir="dump/MC_info/PVs"): - mc_vertices = mc_unpackers()["MCVertices"] - mc_property_location = make_data_with_FetchDataFromFile("/Event/MC/TrackInfo") return PVDumper( - MCVerticesLocation=mc_vertices, - MCPropertyLocation=mc_property_location, - ODINLocation=odin_location()) + MCVerticesLocation=mc_unpackers()["MCVertices"], + MCPropertyLocation=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), + ODINLocation=odin_location(), + OutputDirectory=output_dir) -- GitLab From 6d50bf6d3656fc467f6351a69e6a10b2809890d7 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 15 Apr 2020 18:23:20 +0200 Subject: [PATCH 139/171] enable dumping of all binaries required for standalone Allen running together --- .../options/hlt1_reco_allen_pvchecker.py | 4 +-- .../hlt1_reco_allen_track_reconstruction.py | 32 +++++++++++++++---- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 4 +-- Hlt/RecoConf/python/RecoConf/standalone.py | 5 ++- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py index ce1bc77ceea..3128aa585d1 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py @@ -11,8 +11,8 @@ from Moore import options, run_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec -from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs -from RecoConf.mc_checking import get_pv_checkers, get_track_checkers +from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs +from RecoConf.mc_checking import get_pv_checkers, get_track_checkers from Configurables import ApplicationMgr from Configurables import NTupleSvc from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py index 4599fcdd371..4b9e0d184bd 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py @@ -9,21 +9,41 @@ # or submit itself to any jurisdiction. # ############################################################################### from Moore import options, run_reconstruction -from RecoConf.standalone import standalone_hlt1_reco_allen +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec +from RecoConf.hlt1_allen import make_allen_tracks, make_dumped_raw_banks +from RecoConf.mc_checking import tracker_dumper, pv_dumper, get_track_checkers from Configurables import ApplicationMgr from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable from Configurables import DumpMuonGeometry, DumpVPGeometry from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks -dumpBinaries = True +dumpBinaries = False +outputDir = "dump/" -with standalone_hlt1_reco_allen.bind( - do_mc_checking=True, dump_binaries=dumpBinaries): - run_reconstruction(options, standalone_hlt1_reco_allen) +def hlt1_reco_allen_tracks(): + + allen_tracks = make_allen_tracks() + + types_and_locations_for_checkers = { + "Velo": allen_tracks["Velo"], + "Upstream": allen_tracks["Upstream"], + "Forward": allen_tracks["Forward"], + } + data = get_track_checkers(types_and_locations_for_checkers) + + if dumpBinaries: + data.append(make_dumped_raw_banks(dump_to_file=True, output_dir=outputDir + "banks")) + data.append(tracker_dumper(dump_to_root=False, dump_to_binary=True, bin_output_dir=outputDir + "MC_info/tracks")) + data.append(pv_dumper(output_dir=outputDir + "MC_info/PVs")) + + return Reconstruction('allen_reco', data, [require_gec()]) + +run_reconstruction(options, hlt1_reco_allen_tracks) producers = [ - p(DumpToFile=False) + p(DumpToFile=dumpBinaries) for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, DumpMuonTable, DumpMagneticField, DumpBeamline, DumpUTLookupTables) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 0c19185cf97..616372fc655 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -37,8 +37,8 @@ def make_allen_output(odin_location=make_odin, return RunAllen( AllenRawInput=dumped_raw_banks(dump_to_file=dump_to_file), ODINLocation=odin_location(), - FILTERHLT1=filter_hlt1, - PARAMDIR="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", + FilterHLT1=filter_hlt1, + ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", JSON="${ALLEN_PROJECT_ROOT}/configuration/constants/default.json" ).AllenOutput diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 08f11d27be0..d788908319d 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -81,7 +81,6 @@ def standalone_hlt1_reco_allen(do_mc_checking=False, dump_binaries=False): """ # Allen hlt1 allen_tracks = make_allen_tracks(dump_to_file=dump_binaries) - allen_pvs = make_allen_pvs() if do_mc_checking: types_and_locations_for_checkers = { @@ -94,8 +93,8 @@ def standalone_hlt1_reco_allen(do_mc_checking=False, dump_binaries=False): if dump_binaries: data.append(tracker_dumper(dump_to_root=False, dump_to_binary=True)) data.append(pv_dumper()) - - return Reconstruction('hlt1_reco', data, reco_prefilters()) + + return Reconstruction('hlt1_reco', data, reco_prefilters()) def standalone_hlt1_allen(): -- GitLab From 33ea4ef9bc9a513beca419bc06fcc9b3fae65e43 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 15 Apr 2020 16:24:21 +0000 Subject: [PATCH 140/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/7994193 --- .../options/hlt1_reco_allen_pvchecker.py | 4 ++-- .../hlt1_reco_allen_track_reconstruction.py | 22 +++++++++++++------ Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 4 ++-- Hlt/RecoConf/python/RecoConf/mc_checking.py | 12 +++++----- Hlt/RecoConf/python/RecoConf/standalone.py | 9 ++++---- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py index 3128aa585d1..ce1bc77ceea 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py @@ -11,8 +11,8 @@ from Moore import options, run_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec -from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs -from RecoConf.mc_checking import get_pv_checkers, get_track_checkers +from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs +from RecoConf.mc_checking import get_pv_checkers, get_track_checkers from Configurables import ApplicationMgr from Configurables import NTupleSvc from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py index 4b9e0d184bd..462085b7930 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py @@ -20,10 +20,11 @@ from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks dumpBinaries = False -outputDir = "dump/" +outputDir = "dump/" + def hlt1_reco_allen_tracks(): - + allen_tracks = make_allen_tracks() types_and_locations_for_checkers = { @@ -32,14 +33,21 @@ def hlt1_reco_allen_tracks(): "Forward": allen_tracks["Forward"], } data = get_track_checkers(types_and_locations_for_checkers) - + if dumpBinaries: - data.append(make_dumped_raw_banks(dump_to_file=True, output_dir=outputDir + "banks")) - data.append(tracker_dumper(dump_to_root=False, dump_to_binary=True, bin_output_dir=outputDir + "MC_info/tracks")) + data.append( + make_dumped_raw_banks( + dump_to_file=True, output_dir=outputDir + "banks")) + data.append( + tracker_dumper( + dump_to_root=False, + dump_to_binary=True, + bin_output_dir=outputDir + "MC_info/tracks")) data.append(pv_dumper(output_dir=outputDir + "MC_info/PVs")) - return Reconstruction('allen_reco', data, [require_gec()]) - + return Reconstruction('allen_reco', data, [require_gec()]) + + run_reconstruction(options, hlt1_reco_allen_tracks) producers = [ diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 616372fc655..8612ac71eaa 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -18,6 +18,7 @@ from PyConf.Algorithms import ( AllenPVsToRecVertexV2, AllenDecReportsToTES, DumpRawBanks, RunAllen) from PyConf.Algorithms import HltDecReportsDecoder + @configurable def make_dumped_raw_banks(make_raw=default_raw_event, odin_location=make_odin, @@ -85,7 +86,7 @@ def make_allen_tracks(dump_to_file=False): velo_tracks = make_allen_velo_tracks(dumpToFile=dump_to_file) velo_ut_tracks = make_allen_veloUT_tracks(dumpToFile=dump_to_file) forward_tracks = make_allen_forward_tracks(dumpToFile=dump_to_file) - + return { "Velo": velo_tracks, "Upstream": velo_ut_tracks, @@ -105,4 +106,3 @@ def make_allen_dec_reports(): return HltDecReportsDecoder( RawEventLocations=allen_dec_reports_raw, SourceID=1).OutputHltDecReportsLocation - diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 7abb9dbeda5..3fa54ff5e9f 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -40,6 +40,7 @@ from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask from RecoConf.hlt1_muonid import make_muon_hits from PyConf.Tools import VisPrimVertTool + def get_item(x, key): """Return `key` from `x` if `x` is a dict, otherwise return `x`. @@ -350,13 +351,12 @@ def tracker_dumper(odin_location=make_odin, DumpToBinary=dump_to_binary, OutputDirectory=root_output_dir, MCOutputDirectory=bin_output_dir) - -def pv_dumper(odin_location=make_odin, - output_dir="dump/MC_info/PVs"): + + +def pv_dumper(odin_location=make_odin, output_dir="dump/MC_info/PVs"): return PVDumper( MCVerticesLocation=mc_unpackers()["MCVertices"], - MCPropertyLocation=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"), + MCPropertyLocation=make_data_with_FetchDataFromFile( + "/Event/MC/TrackInfo"), ODINLocation=odin_location(), OutputDirectory=output_dir) - - diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index d788908319d..da7f89cf701 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -89,12 +89,13 @@ def standalone_hlt1_reco_allen(do_mc_checking=False, dump_binaries=False): "Forward": allen_tracks["Forward"], } data = get_track_checkers(types_and_locations_for_checkers) - + if dump_binaries: - data.append(tracker_dumper(dump_to_root=False, dump_to_binary=True)) + data.append( + tracker_dumper(dump_to_root=False, dump_to_binary=True)) data.append(pv_dumper()) - - return Reconstruction('hlt1_reco', data, reco_prefilters()) + + return Reconstruction('hlt1_reco', data, reco_prefilters()) def standalone_hlt1_allen(): -- GitLab From 17ef839d4bba2f6621d2d46c34c8e965c7aeedd7 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Mon, 27 Apr 2020 14:34:33 +0200 Subject: [PATCH 141/171] add options script to dump binary input for standalone Allen --- .../dump_binary_input_for_standalone_Allen.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py diff --git a/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py new file mode 100644 index 00000000000..01425ac48b3 --- /dev/null +++ b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py @@ -0,0 +1,51 @@ +############################################################################### +# (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 Moore import options, run_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_allen import make_dumped_raw_banks +from RecoConf.mc_checking import tracker_dumper, pv_dumper +from Configurables import ApplicationMgr +from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable +from Configurables import DumpMuonGeometry, DumpVPGeometry +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import AllenUpdater + +outputDir = "dump/" + +def dump_allen_binary_input(): + + data = [] + data.append( + make_dumped_raw_banks( + dump_to_file=True, output_dir=outputDir + "banks")) + data.append( + tracker_dumper( + dump_to_root=False, + dump_to_binary=True, + bin_output_dir=outputDir + "MC_info/tracks")) + data.append(pv_dumper(output_dir=outputDir + "MC_info/PVs")) + + return Reconstruction('allen_dump', data) + + +run_reconstruction(options, dump_allen_binary_input) + +producers = [ + p(DumpToFile=True) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) +] + +# Add the services that will produce the non-event-data +ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), +] + producers -- GitLab From f94c45564c931ca204846a96bfd4499c382816da Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Mon, 27 Apr 2020 14:57:13 +0200 Subject: [PATCH 142/171] cleanup --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 8612ac71eaa..c9d7e902a4d 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -44,8 +44,8 @@ def make_allen_output(odin_location=make_odin, ).AllenOutput -def make_allen_velo_tracks(dumpToFile=False): - allen_output = make_allen_output(dump_to_file=dumpToFile) +def make_allen_velo_tracks(): + allen_output = make_allen_output() velo_tracks_v2 = AllenVeloToV2Tracks(AllenOutput=allen_output).OutputTracks velo_tracks_v1 = FromV2TrackV1Track( InputTracksName=velo_tracks_v2).OutputTracksName @@ -53,8 +53,8 @@ def make_allen_velo_tracks(dumpToFile=False): return {"v2": velo_tracks_v2, "v1": velo_tracks_v1} -def make_allen_veloUT_tracks(dumpToFile=False): - allen_output = make_allen_output(dump_to_file=dumpToFile) +def make_allen_veloUT_tracks(): + allen_output = make_allen_output() veloUT_tracks_v2 = AllenUTToV2Tracks(AllenOutput=allen_output).OutputTracks veloUT_tracks_v1 = FromV2TrackV1Track( InputTracksName=veloUT_tracks_v2).OutputTracksName @@ -62,8 +62,8 @@ def make_allen_veloUT_tracks(dumpToFile=False): return {"v2": veloUT_tracks_v2, "v1": veloUT_tracks_v1} -def make_allen_forward_tracks(dumpToFile=False): - allen_output = make_allen_output(dump_to_file=dumpToFile) +def make_allen_forward_tracks(): + allen_output = make_allen_output() forward_tracks_v2 = AllenForwardToV2Tracks( AllenOutput=allen_output).OutputTracks forward_tracks_v1 = FromV2TrackV1Track( @@ -82,10 +82,10 @@ def make_allen_forward_muon_tracks(): return {"v2": forward_muon_tracks_v2, "v1": forward_muon_tracks_v1} -def make_allen_tracks(dump_to_file=False): - velo_tracks = make_allen_velo_tracks(dumpToFile=dump_to_file) - velo_ut_tracks = make_allen_veloUT_tracks(dumpToFile=dump_to_file) - forward_tracks = make_allen_forward_tracks(dumpToFile=dump_to_file) +def make_allen_tracks(): + velo_tracks = make_allen_velo_tracks() + velo_ut_tracks = make_allen_veloUT_tracks() + forward_tracks = make_allen_forward_tracks() return { "Velo": velo_tracks, -- GitLab From 134c4ddeb9eced953ed78d3fdca39bb3edaf113b Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 5 May 2020 09:42:33 +0000 Subject: [PATCH 143/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/8245710 --- .../options/dump_binary_input_for_standalone_Allen.py | 7 ++++--- Hlt/RecoConf/python/RecoConf/standalone.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py index 01425ac48b3..1d0ddeee1f0 100644 --- a/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py +++ b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py @@ -20,19 +20,20 @@ from Configurables import AllenUpdater outputDir = "dump/" + def dump_allen_binary_input(): - + data = [] data.append( make_dumped_raw_banks( dump_to_file=True, output_dir=outputDir + "banks")) data.append( tracker_dumper( - dump_to_root=False, + dump_to_root=False, dump_to_binary=True, bin_output_dir=outputDir + "MC_info/tracks")) data.append(pv_dumper(output_dir=outputDir + "MC_info/PVs")) - + return Reconstruction('allen_dump', data) diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 56b98e9ae24..b07dd9d23f6 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -24,9 +24,9 @@ from .calorimeter_mc_checking import (monitor_calo_cluster_resolution, monitor_calo_photon_resolution, monitor_calo_pi0_resolution) from PyConf.Algorithms import CaloDigit2MCLinks2Table -from .mc_checking import get_track_checkers, get_best_tracks_checkers, tracker_dumper, pv_dumper +from .mc_checking import get_track_checkers, get_best_tracks_checkers, tracker_dumper, pv_dumper from .hlt1_allen import (make_allen_tracks, make_allen_pvs, - make_allen_dec_reports, make_dumped_raw_banks) + make_allen_dec_reports, make_dumped_raw_banks) from .reco_objects_from_file import reconstruction from .rich_reconstruction import make_rich_pids, make_rich_pixels, default_rich_reco_options from .rich_data_monitoring import (make_rich_pixel_monitors, -- GitLab From e1edab0e3890ee45532431deb1800b09080f4998 Mon Sep 17 00:00:00 2001 From: Florian Reiss Date: Tue, 5 May 2020 22:38:52 +0200 Subject: [PATCH 144/171] updates to PV plotting scripts to create plots for figure document --- .../scripts/PrimaryVertexCheckerEfficiency.py | 14 +++- .../scripts/PrimaryVertexCheckerPull.py | 58 +++++++------- .../scripts/PrimaryVertexCheckerResolution.py | 60 +++++++++------ Hlt/RecoConf/scripts/utils/pvconfig.py | 2 +- Hlt/RecoConf/scripts/utils/pvutils.py | 75 ++++++++++++------- 5 files changed, 127 insertions(+), 82 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py index a8870f7bcfa..bfc3151734f 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py @@ -77,6 +77,13 @@ parser.add_argument( help='tree name to plot', ) +parser.add_argument( + '--offset', + dest='offset', + default=0, + help='offset for plot colors', +) + def get_labels(number_of_files): label = [] @@ -89,6 +96,7 @@ if __name__ == '__main__': args = parser.parse_args() path = args.directory + "/utils/" sys.path.append(os.path.abspath(path)) + offset = int(args.offset) gROOT.SetBatch() @@ -125,11 +133,11 @@ if __name__ == '__main__': eff["tracks"], hist["tracks"] = get_eff(eff["tracks"], hist["tracks"], tr, "nrectrmc", style, ranges, cat, - label) + label, offset) eff["z"], hist["z"] = get_eff(eff["z"], hist["z"], tr, "zMC", style, - ranges, cat, label) + ranges, cat, label, offset) eff["r"], hist["r"] = get_eff(eff["r"], hist["r"], tr, "rMC", style, - ranges, cat, label) + ranges, cat, label, offset) if args.dist: legend = TLegend(0.15, 0.82, 0.88, 0.98) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py index 6b6b2f7532d..127154700bb 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py @@ -77,6 +77,13 @@ parser.add_argument( help='tree name to plot', ) +parser.add_argument( + '--offset', + dest='offset', + default=0, + help='offset for plot colors', +) + def get_labels(number_of_files): label = [] @@ -89,7 +96,7 @@ if __name__ == '__main__': args = parser.parse_args() path = args.directory + "/utils/" sys.path.append(os.path.abspath(path)) - + offset = int(args.offset) gROOT.SetBatch() from pvutils import get_default_tree_name @@ -120,15 +127,15 @@ if __name__ == '__main__': hist_z = {} norm = True #to-do hist_x = get_global(hist_x, tr, "pullx", "#Delta x / #sigma_{x}", - "Candidates Normalized", style, ranges, cat, label) + "Candidates Normalized", style, ranges, cat, label, offset) hist_y = get_global(hist_y, tr, "pully", "#Delta y / #sigma_{y}", - "Candidates Normalized", style, ranges, cat, label) + "Candidates Normalized", style, ranges, cat, label, offset) hist_z = get_global(hist_z, tr, "pullz", "#Delta z / #sigma_{z}", - "Candidates Normalized", style, ranges, cat, label) + "Candidates Normalized", style, ranges, cat, label, offset) - plot_comparison(hist_x, args.prefix, "pullx", cat, label, style, norm) - plot_comparison(hist_y, args.prefix, "pully", cat, label, style, norm) - plot_comparison(hist_z, args.prefix, "pullz", cat, label, style, norm) + plot_comparison(hist_x, args.prefix, "pullx", cat, label, style, norm, offset) + plot_comparison(hist_y, args.prefix, "pully", cat, label, style, norm, offset) + plot_comparison(hist_z, args.prefix, "pullz", cat, label, style, norm, offset) from ROOT import gEnv gEnv.SetValue("Hist.Binning.1D.x", "100") @@ -140,54 +147,55 @@ if __name__ == '__main__': graph["tracks"]["pullz"] = {} graph["tracks"]["pullx"] = get_dependence(graph["tracks"]["pullx"], tr, "pullx", "nrectrmc", ranges, - style, cat, label) + style, cat, label, offset) graph["tracks"]["pully"] = get_dependence(graph["tracks"]["pully"], tr, "pully", "nrectrmc", ranges, - style, cat, label) + style, cat, label, offset) graph["tracks"]["pullz"] = get_dependence(graph["tracks"]["pullz"], tr, "pullz", "nrectrmc", ranges, - style, cat, label) + style, cat, label, offset) legend = TLegend(0.15, 0.86, 0.88, 0.98) legend = set_legend(legend, label, graph["tracks"]["pullz"], "sigma") + labelpos=(0.75, 0.75,0.9,0.87) plot(graph["tracks"]["pullx"], "mean", args.prefix + "_ntracks_mean", - "pullx", cat, label, legend) + "pullx", cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["pullx"], "sigma", args.prefix + "_ntracks_sigma", - "pullx", cat, label, legend) + "pullx", cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["pully"], "mean", args.prefix + "_ntracks_mean", - "pully", cat, label, legend) + "pully", cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["pully"], "sigma", args.prefix + "_ntracks_sigma", - "pully", cat, label, legend) + "pully", cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["pullz"], "mean", args.prefix + "_ntracks_mean", - "pullz", cat, label, legend) + "pullz", cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["pullz"], "sigma", args.prefix + "_ntracks_sigma", - "pullz", cat, label, legend) + "pullz", cat, label, legend, labelpos=labelpos) graph["z"] = {} graph["z"]["pullx"] = {} graph["z"]["pully"] = {} graph["z"]["pullz"] = {} graph["z"]["pullx"] = get_dependence(graph["z"]["pullx"], tr, "pullx", - "zMC", ranges, style, cat, label) + "zMC", ranges, style, cat, label, offset) graph["z"]["pully"] = get_dependence(graph["z"]["pully"], tr, "pully", - "zMC", ranges, style, cat, label) + "zMC", ranges, style, cat, label, offset) graph["z"]["pullz"] = get_dependence(graph["z"]["pullz"], tr, "pullz", - "zMC", ranges, style, cat, label) + "zMC", ranges, style, cat, label, offset) plot(graph["z"]["pullx"], "mean", args.prefix + "_z_mean", "pullx", cat, - label, legend) + label, legend, labelpos=labelpos) plot(graph["z"]["pullx"], "sigma", args.prefix + "_z_sigma", "pullx", cat, - label, legend) + label, legend, labelpos=labelpos) plot(graph["z"]["pully"], "mean", args.prefix + "_z_mean", "pully", cat, - label, legend) + label, legend, labelpos=labelpos) plot(graph["z"]["pully"], "sigma", args.prefix + "_z_sigma", "pully", cat, - label, legend) + label, legend, labelpos=labelpos) plot(graph["z"]["pullz"], "mean", args.prefix + "_z_mean", "pullz", cat, - label, legend) + label, legend, labelpos=labelpos) plot(graph["z"]["pullz"], "sigma", args.prefix + "_z_sigma", "pullz", cat, - label, legend) + label, legend, labelpos=labelpos) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py index 7a753cf251e..f195826d0df 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py @@ -77,6 +77,13 @@ parser.add_argument( help='tree name to plot', ) +parser.add_argument( + '--offset', + dest='offset', + default=0, + help='offset for plot colors', +) + def get_labels(number_of_files): label = [] @@ -89,6 +96,7 @@ if __name__ == '__main__': args = parser.parse_args() path = args.directory + "/utils/" sys.path.append(os.path.abspath(path)) + offset = int(args.offset) gROOT.SetBatch() @@ -120,15 +128,15 @@ if __name__ == '__main__': norm = True hist_x = get_global(hist_x, tr, "dx", "#Delta x [mm]", - "Candidates Normalized", style, ranges, cat, label) + "Candidates Normalized", style, ranges, cat, label, offset) hist_y = get_global(hist_y, tr, "dy", "#Delta y [mm]", - "Candidates Normalized", style, ranges, cat, label) + "Candidates Normalized", style, ranges, cat, label, offset) hist_z = get_global(hist_z, tr, "dz", "#Delta z [mm]", - "Candidates Normalized", style, ranges, cat, label) + "Candidates Normalized", style, ranges, cat, label, offset) - plot_comparison(hist_x, args.prefix, "dx", cat, label, style, norm) - plot_comparison(hist_y, args.prefix, "dy", cat, label, style, norm) - plot_comparison(hist_z, args.prefix, "dz", cat, label, style, norm) + plot_comparison(hist_x, args.prefix, "dx", cat, label, style, norm, offset) + plot_comparison(hist_y, args.prefix, "dy", cat, label, style, norm, offset) + plot_comparison(hist_z, args.prefix, "dz", cat, label, style, norm, offset) from ROOT import gEnv gEnv.SetValue("Hist.Binning.1D.x", "100") @@ -139,52 +147,56 @@ if __name__ == '__main__': graph["tracks"]["dy"] = {} graph["tracks"]["dz"] = {} graph["tracks"]["dx"] = get_dependence( - graph["tracks"]["dx"], tr, "dx", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["dx"], tr, "dx", "nrectrmc", ranges, style, cat, label, offset) graph["tracks"]["dy"] = get_dependence( - graph["tracks"]["dy"], tr, "dy", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["dy"], tr, "dy", "nrectrmc", ranges, style, cat, label, offset) graph["tracks"]["dz"] = get_dependence( - graph["tracks"]["dz"], tr, "dz", "nrectrmc", ranges, style, cat, label) + graph["tracks"]["dz"], tr, "dz", "nrectrmc", ranges, style, cat, label, offset) legend = TLegend(0.15, 0.86, 0.88, 0.98) legend = set_legend(legend, label, graph["tracks"]["dz"], "sigma") + + labelpos=(0.73, 0.75,0.88,0.87) plot(graph["tracks"]["dx"], "mean", args.prefix + "_ntracks_mean", "dx", - cat, label, legend) + cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["dx"], "sigma", args.prefix + "_ntracks_sigma", "dx", - cat, label, legend) + cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["dy"], "mean", args.prefix + "_ntracks_mean", "dy", - cat, label, legend) + cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["dy"], "sigma", args.prefix + "_ntracks_sigma", "dy", - cat, label, legend) + cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["dz"], "mean", args.prefix + "_ntracks_mean", "dz", - cat, label, legend) + cat, label, legend, labelpos=labelpos) plot(graph["tracks"]["dz"], "sigma", args.prefix + "_ntracks_sigma", "dz", - cat, label, legend) + cat, label, legend, labelpos=labelpos) graph["z"] = {} graph["z"]["dx"] = {} graph["z"]["dy"] = {} graph["z"]["dz"] = {} graph["z"]["dx"] = get_dependence(graph["z"]["dx"], tr, "dx", "zMC", - ranges, style, cat, label) + ranges, style, cat, label, offset) graph["z"]["dy"] = get_dependence(graph["z"]["dy"], tr, "dy", "zMC", - ranges, style, cat, label) + ranges, style, cat, label, offset) graph["z"]["dz"] = get_dependence(graph["z"]["dz"], tr, "dz", "zMC", - ranges, style, cat, label) + ranges, style, cat, label, offset) + plot(graph["z"]["dx"], "mean", args.prefix + "_z_mean", "dx", cat, label, - legend) + legend, labelpos=labelpos) plot(graph["z"]["dx"], "sigma", args.prefix + "_z_sigma", "dx", cat, label, - legend) + legend, labelpos=labelpos) plot(graph["z"]["dy"], "mean", args.prefix + "_z_mean", "dy", cat, label, - legend) + legend, labelpos=labelpos) plot(graph["z"]["dy"], "sigma", args.prefix + "_z_sigma", "dy", cat, label, - legend) + legend, labelpos=labelpos) + plot(graph["z"]["dz"], "mean", args.prefix + "_z_mean", "dz", cat, label, - legend) + legend, labelpos=labelpos) plot(graph["z"]["dz"], "sigma", args.prefix + "_z_sigma", "dz", cat, label, - legend) + legend, labelpos=labelpos) diff --git a/Hlt/RecoConf/scripts/utils/pvconfig.py b/Hlt/RecoConf/scripts/utils/pvconfig.py index aa85884257c..09bccd2963f 100644 --- a/Hlt/RecoConf/scripts/utils/pvconfig.py +++ b/Hlt/RecoConf/scripts/utils/pvconfig.py @@ -175,7 +175,7 @@ def set_legend(legend, label, gr, gr_type, hist=None, dist=False): legend.AddEntry(hist["all"][label[0]]["den"], "Distribution MC", "f") for lab in label: legend.AddEntry(hist["all"][lab]["nom"], - "Distribution {lab}".format(lab=lab), "f") + "Distribution {lab}".format(lab=lab), "lep") return legend diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py index 5065d911ddf..02e0ab776a1 100644 --- a/Hlt/RecoConf/scripts/utils/pvutils.py +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -15,7 +15,7 @@ # date: 02/2020 # -from ROOT import TFile, TTree, TH1F, gDirectory, TGraphAsymmErrors +from ROOT import TFile, TTree, TH1F, gDirectory, TGraphAsymmErrors, TPaveText, gStyle from ROOT import TCanvas from ROOT import TGraphErrors, TLegend from ROOT import gPad, kGray, TLatex @@ -50,14 +50,14 @@ def get_trees(tf, tr, label, trees, is_checker): return tr -def get_eff(eff, hist, trees, dependence, style, ranges, categories, label): +def get_eff(eff, hist, trees, dependence, style, ranges, categories, label, offset): for cat in categories: eff[cat] = {} hist[cat] = {} - i = 0 + i = offset for lab in label: - var_den = '{dependence}>>hist{code}_{dep}_{cat}_{lab}({bins},{mins},{maxs})'.format( + var_den = '{dependence}>>hist{code}_{dep}_{cat}_denom{i}({bins},{mins},{maxs})'.format( dependence=dependence, code="den", dep=dependence, @@ -65,8 +65,9 @@ def get_eff(eff, hist, trees, dependence, style, ranges, categories, label): lab=lab, bins=ranges[dependence]["bins"], mins=ranges[dependence]["min"], - maxs=ranges[dependence]["max"]) - var_nom = '{dependence}>>hist{code}_{dep}_{cat}_{lab}({bins},{mins},{maxs})'.format( + maxs=ranges[dependence]["max"], + i=i) + var_nom = '{dependence}>>hist{code}_{dep}_{cat}_num{i}({bins},{mins},{maxs})'.format( dependence=dependence, code="nom", dep=dependence, @@ -74,7 +75,8 @@ def get_eff(eff, hist, trees, dependence, style, ranges, categories, label): lab=lab, bins=ranges[dependence]["bins"], mins=ranges[dependence]["min"], - maxs=ranges[dependence]["max"]) + maxs=ranges[dependence]["max"], + i=i) cut_den = 'nrectrmc>=4 && dz < 2.0 {cuts}'.format( cuts=categories[cat]["cut"]) @@ -83,15 +85,15 @@ def get_eff(eff, hist, trees, dependence, style, ranges, categories, label): trees[lab].Draw(var_nom, cut_nom) trees[lab].Draw(var_den, cut_den) - h_nom = gDirectory.Get('hist{code}_{dep}_{cat}_{lab}'.format( - code="nom", dep=dependence, cat=cat, lab=lab)) - h_den = gDirectory.Get('hist{code}_{dep}_{cat}_{lab}'.format( - code="den", dep=dependence, cat=cat, lab=lab)) + h_nom = gDirectory.Get('hist{code}_{dep}_{cat}_num{i}'.format( + code="nom", dep=dependence, cat=cat, lab=lab, i=i)) + h_den = gDirectory.Get('hist{code}_{dep}_{cat}_denom{i}'.format( + code="den", dep=dependence, cat=cat, lab=lab, i=i)) g_eff = TGraphAsymmErrors() g_eff.Divide(h_nom, h_den, "cl=0.683 b(1,1) mode") - set_style(h_nom, style["color"][i] - 8, style["marker"][i], + set_style(h_nom, style["color"][i]-7, style["marker"][i]+4, get_x_axis(dependence), "Efficiency", "") set_style(h_den, kGray, style["marker"][i], get_x_axis(dependence), "Efficiency", "") @@ -133,7 +135,8 @@ def plot(gr, label, legend=None, hist=None, - dist=False): + dist=False, + labelpos=(0.75, 0.78,0.9,0.9)): for cat in categories: can = TCanvas( @@ -173,14 +176,21 @@ def plot(gr, for lab in label: histmax_nom = 1.1 * hist[cat][lab]["nom"].GetMaximum() - scale = gPad.GetUymax() / histmax_nom + #scale = gPad.GetUymax() / histmax_nom hist[cat][lab]["nom"].Scale(scale * 0.75) - hist[cat][lab]["nom"].Draw("SAME") + hist[cat][lab]["nom"].Draw("ep SAME") gr[cat][lab][gr_type].Draw("SAME P") if legend: legend.Draw("SAME") + pavetext = TPaveText(labelpos[0],labelpos[1],labelpos[2],labelpos[3], "NBNDC") + pavetext.AddText("LHCb simulation") + pavetext.SetFillColor(0) + pavetext.SetFillStyle(3000) + pavetext.SetTextSize(0.06) + pavetext.SetTextFont(132) + pavetext.Draw() saveName = '{prefix}_{dependence}_{cat}.pdf'.format( prefix=prefix, dependence=dependence, cat=cat) @@ -188,29 +198,30 @@ def plot(gr, def get_global(hist, trees, dependence, x_axis, y_axis, style, ranges, - categories, label): + categories, label, offset): dep = transfer_variable(dependence) for cat in categories: hist[cat] = {} - i = 0 + i = offset for lab in label: - var = '{dependence}>>hist_{dep}_{cat}_{lab}({bins},{mins},{maxs})'.format( + var = '{dependence}>>hist_{dep}_{cat}_{i}({bins},{mins},{maxs})'.format( dependence=dep, dep=dependence, cat=cat, lab=lab, bins=ranges[dependence]["bins"], mins=ranges[dependence]["min"], - maxs=ranges[dependence]["max"]) + maxs=ranges[dependence]["max"], + i=i) cut = 'nrectrmc>=4 && dz < 2.0 && reco == 1 {cuts}'.format( cuts=categories[cat]["cut"]) trees[lab].Draw(var, cut) - h = gDirectory.Get('hist_{dep}_{cat}_{lab}'.format( - dep=dependence, cat=cat, lab=lab)) + h = gDirectory.Get('hist_{dep}_{cat}_{i}'.format( + dep=dependence, cat=cat, lab=lab, i=i)) if i == 0: col = style["color"][i] - 10 else: @@ -249,7 +260,7 @@ def set_text(text, color, x, y, lab, mean, mean_err, rms, rms_err, scale, return text -def plot_comparison(hist, prefix, dependence, categories, label, style, norm): +def plot_comparison(hist, prefix, dependence, categories, label, style, norm, offset): for cat in categories: can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence, cat=cat), @@ -272,7 +283,7 @@ def plot_comparison(hist, prefix, dependence, categories, label, style, norm): if norm: hist[cat][label[0]].DrawNormalized("hist") hist_max = hist[cat][label[0]].GetMaximum() - i = 0 + i = offset for lab in label: hist[cat][lab].DrawNormalized("SAME PE") text = TLatex() @@ -287,6 +298,12 @@ def plot_comparison(hist, prefix, dependence, categories, label, style, norm): hist[cat][label[0]].Draw("hist") for lab in label: hist[cat][lab].Draw("SAME PE") + pavetext = TPaveText(0.72, 0.77 - gStyle.GetPadTopMargin(), 0.87, 0.89 - gStyle.GetPadTopMargin(), "NBNDC") + pavetext.AddText("LHCb simulation") + pavetext.SetFillColor(0) + pavetext.SetTextSize(0.06) + pavetext.SetTextFont(132) + pavetext.Draw() can.Update() saveName = '{prefix}_{dependence}_{cat}.pdf'.format( @@ -346,7 +363,7 @@ def get_robust_sigma(hist, resol): def get_dependence(graph, trees, variable, dependence, ranges, style, - categories, label): + categories, label, offset): var = transfer_variable(variable) bin_width = (ranges[dependence]["max"] - @@ -360,7 +377,7 @@ def get_dependence(graph, trees, variable, dependence, ranges, style, for cat in categories: graph[cat] = {} - i = 0 + i = offset for lab in label: graph[cat][lab] = {} graph_rms = TGraphAsymmErrors(ranges[dependence]["bins"]) @@ -375,11 +392,11 @@ def get_dependence(graph, trees, variable, dependence, ranges, style, variable2=dependence, maxs=bin_min + bin_width) - hist_string = '{dependence}>>hist_{dep}_{cat}_{lab}_{number}'.format( + hist_string = '{dependence}>>hist_{dep}_{cat}_{i}_{number}'.format( dependence=var, dep=variable, cat=cat, - lab=lab, + i=i, number=int(b), ) @@ -392,8 +409,8 @@ def get_dependence(graph, trees, variable, dependence, ranges, style, bin_min += bin_width - h = gDirectory.Get('hist_{dep}_{cat}_{lab}_{number}'.format( - dep=variable, cat=cat, lab=lab, number=int(b))) + h = gDirectory.Get('hist_{dep}_{cat}_{i}_{number}'.format( + dep=variable, cat=cat, i=i, number=int(b))) robust_sigma = get_robust_sigma(h, resol) -- GitLab From 37efe35e2a9bcefbc0549b9ff0265548ac4c9562 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 6 May 2020 08:20:23 +0000 Subject: [PATCH 145/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/8259820 --- .../scripts/PrimaryVertexCheckerPull.py | 167 ++++++++++++++---- .../scripts/PrimaryVertexCheckerResolution.py | 161 +++++++++++++---- Hlt/RecoConf/scripts/utils/pvutils.py | 16 +- 3 files changed, 264 insertions(+), 80 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py index 127154700bb..cf30de6cca3 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py @@ -127,15 +127,21 @@ if __name__ == '__main__': hist_z = {} norm = True #to-do hist_x = get_global(hist_x, tr, "pullx", "#Delta x / #sigma_{x}", - "Candidates Normalized", style, ranges, cat, label, offset) + "Candidates Normalized", style, ranges, cat, label, + offset) hist_y = get_global(hist_y, tr, "pully", "#Delta y / #sigma_{y}", - "Candidates Normalized", style, ranges, cat, label, offset) + "Candidates Normalized", style, ranges, cat, label, + offset) hist_z = get_global(hist_z, tr, "pullz", "#Delta z / #sigma_{z}", - "Candidates Normalized", style, ranges, cat, label, offset) + "Candidates Normalized", style, ranges, cat, label, + offset) - plot_comparison(hist_x, args.prefix, "pullx", cat, label, style, norm, offset) - plot_comparison(hist_y, args.prefix, "pully", cat, label, style, norm, offset) - plot_comparison(hist_z, args.prefix, "pullz", cat, label, style, norm, offset) + plot_comparison(hist_x, args.prefix, "pullx", cat, label, style, norm, + offset) + plot_comparison(hist_y, args.prefix, "pully", cat, label, style, norm, + offset) + plot_comparison(hist_z, args.prefix, "pullz", cat, label, style, norm, + offset) from ROOT import gEnv gEnv.SetValue("Hist.Binning.1D.x", "100") @@ -158,44 +164,131 @@ if __name__ == '__main__': legend = TLegend(0.15, 0.86, 0.88, 0.98) legend = set_legend(legend, label, graph["tracks"]["pullz"], "sigma") - labelpos=(0.75, 0.75,0.9,0.87) - plot(graph["tracks"]["pullx"], "mean", args.prefix + "_ntracks_mean", - "pullx", cat, label, legend, labelpos=labelpos) - plot(graph["tracks"]["pullx"], "sigma", args.prefix + "_ntracks_sigma", - "pullx", cat, label, legend, labelpos=labelpos) + labelpos = (0.75, 0.75, 0.9, 0.87) + plot( + graph["tracks"]["pullx"], + "mean", + args.prefix + "_ntracks_mean", + "pullx", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["pullx"], + "sigma", + args.prefix + "_ntracks_sigma", + "pullx", + cat, + label, + legend, + labelpos=labelpos) - plot(graph["tracks"]["pully"], "mean", args.prefix + "_ntracks_mean", - "pully", cat, label, legend, labelpos=labelpos) - plot(graph["tracks"]["pully"], "sigma", args.prefix + "_ntracks_sigma", - "pully", cat, label, legend, labelpos=labelpos) + plot( + graph["tracks"]["pully"], + "mean", + args.prefix + "_ntracks_mean", + "pully", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["pully"], + "sigma", + args.prefix + "_ntracks_sigma", + "pully", + cat, + label, + legend, + labelpos=labelpos) - plot(graph["tracks"]["pullz"], "mean", args.prefix + "_ntracks_mean", - "pullz", cat, label, legend, labelpos=labelpos) - plot(graph["tracks"]["pullz"], "sigma", args.prefix + "_ntracks_sigma", - "pullz", cat, label, legend, labelpos=labelpos) + plot( + graph["tracks"]["pullz"], + "mean", + args.prefix + "_ntracks_mean", + "pullz", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["pullz"], + "sigma", + args.prefix + "_ntracks_sigma", + "pullz", + cat, + label, + legend, + labelpos=labelpos) graph["z"] = {} graph["z"]["pullx"] = {} graph["z"]["pully"] = {} graph["z"]["pullz"] = {} graph["z"]["pullx"] = get_dependence(graph["z"]["pullx"], tr, "pullx", - "zMC", ranges, style, cat, label, offset) + "zMC", ranges, style, cat, label, + offset) graph["z"]["pully"] = get_dependence(graph["z"]["pully"], tr, "pully", - "zMC", ranges, style, cat, label, offset) + "zMC", ranges, style, cat, label, + offset) graph["z"]["pullz"] = get_dependence(graph["z"]["pullz"], tr, "pullz", - "zMC", ranges, style, cat, label, offset) - - plot(graph["z"]["pullx"], "mean", args.prefix + "_z_mean", "pullx", cat, - label, legend, labelpos=labelpos) - plot(graph["z"]["pullx"], "sigma", args.prefix + "_z_sigma", "pullx", cat, - label, legend, labelpos=labelpos) - - plot(graph["z"]["pully"], "mean", args.prefix + "_z_mean", "pully", cat, - label, legend, labelpos=labelpos) - plot(graph["z"]["pully"], "sigma", args.prefix + "_z_sigma", "pully", cat, - label, legend, labelpos=labelpos) - - plot(graph["z"]["pullz"], "mean", args.prefix + "_z_mean", "pullz", cat, - label, legend, labelpos=labelpos) - plot(graph["z"]["pullz"], "sigma", args.prefix + "_z_sigma", "pullz", cat, - label, legend, labelpos=labelpos) + "zMC", ranges, style, cat, label, + offset) + + plot( + graph["z"]["pullx"], + "mean", + args.prefix + "_z_mean", + "pullx", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["pullx"], + "sigma", + args.prefix + "_z_sigma", + "pullx", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["z"]["pully"], + "mean", + args.prefix + "_z_mean", + "pully", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["pully"], + "sigma", + args.prefix + "_z_sigma", + "pully", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["z"]["pullz"], + "mean", + args.prefix + "_z_mean", + "pullz", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["pullz"], + "sigma", + args.prefix + "_z_sigma", + "pullz", + cat, + label, + legend, + labelpos=labelpos) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py index f195826d0df..e1bdce35d1c 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py @@ -128,11 +128,14 @@ if __name__ == '__main__': norm = True hist_x = get_global(hist_x, tr, "dx", "#Delta x [mm]", - "Candidates Normalized", style, ranges, cat, label, offset) + "Candidates Normalized", style, ranges, cat, label, + offset) hist_y = get_global(hist_y, tr, "dy", "#Delta y [mm]", - "Candidates Normalized", style, ranges, cat, label, offset) + "Candidates Normalized", style, ranges, cat, label, + offset) hist_z = get_global(hist_z, tr, "dz", "#Delta z [mm]", - "Candidates Normalized", style, ranges, cat, label, offset) + "Candidates Normalized", style, ranges, cat, label, + offset) plot_comparison(hist_x, args.prefix, "dx", cat, label, style, norm, offset) plot_comparison(hist_y, args.prefix, "dy", cat, label, style, norm, offset) @@ -146,32 +149,76 @@ if __name__ == '__main__': graph["tracks"]["dx"] = {} graph["tracks"]["dy"] = {} graph["tracks"]["dz"] = {} - graph["tracks"]["dx"] = get_dependence( - graph["tracks"]["dx"], tr, "dx", "nrectrmc", ranges, style, cat, label, offset) - graph["tracks"]["dy"] = get_dependence( - graph["tracks"]["dy"], tr, "dy", "nrectrmc", ranges, style, cat, label, offset) - graph["tracks"]["dz"] = get_dependence( - graph["tracks"]["dz"], tr, "dz", "nrectrmc", ranges, style, cat, label, offset) + graph["tracks"]["dx"] = get_dependence(graph["tracks"]["dx"], tr, "dx", + "nrectrmc", ranges, style, cat, + label, offset) + graph["tracks"]["dy"] = get_dependence(graph["tracks"]["dy"], tr, "dy", + "nrectrmc", ranges, style, cat, + label, offset) + graph["tracks"]["dz"] = get_dependence(graph["tracks"]["dz"], tr, "dz", + "nrectrmc", ranges, style, cat, + label, offset) legend = TLegend(0.15, 0.86, 0.88, 0.98) legend = set_legend(legend, label, graph["tracks"]["dz"], "sigma") + labelpos = (0.73, 0.75, 0.88, 0.87) + plot( + graph["tracks"]["dx"], + "mean", + args.prefix + "_ntracks_mean", + "dx", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["dx"], + "sigma", + args.prefix + "_ntracks_sigma", + "dx", + cat, + label, + legend, + labelpos=labelpos) - labelpos=(0.73, 0.75,0.88,0.87) - plot(graph["tracks"]["dx"], "mean", args.prefix + "_ntracks_mean", "dx", - cat, label, legend, labelpos=labelpos) - plot(graph["tracks"]["dx"], "sigma", args.prefix + "_ntracks_sigma", "dx", - cat, label, legend, labelpos=labelpos) + plot( + graph["tracks"]["dy"], + "mean", + args.prefix + "_ntracks_mean", + "dy", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["dy"], + "sigma", + args.prefix + "_ntracks_sigma", + "dy", + cat, + label, + legend, + labelpos=labelpos) - plot(graph["tracks"]["dy"], "mean", args.prefix + "_ntracks_mean", "dy", - cat, label, legend, labelpos=labelpos) - plot(graph["tracks"]["dy"], "sigma", args.prefix + "_ntracks_sigma", "dy", - cat, label, legend, labelpos=labelpos) - - plot(graph["tracks"]["dz"], "mean", args.prefix + "_ntracks_mean", "dz", - cat, label, legend, labelpos=labelpos) - plot(graph["tracks"]["dz"], "sigma", args.prefix + "_ntracks_sigma", "dz", - cat, label, legend, labelpos=labelpos) + plot( + graph["tracks"]["dz"], + "mean", + args.prefix + "_ntracks_mean", + "dz", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["dz"], + "sigma", + args.prefix + "_ntracks_sigma", + "dz", + cat, + label, + legend, + labelpos=labelpos) graph["z"] = {} graph["z"]["dx"] = {} @@ -184,19 +231,59 @@ if __name__ == '__main__': graph["z"]["dz"] = get_dependence(graph["z"]["dz"], tr, "dz", "zMC", ranges, style, cat, label, offset) + plot( + graph["z"]["dx"], + "mean", + args.prefix + "_z_mean", + "dx", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["dx"], + "sigma", + args.prefix + "_z_sigma", + "dx", + cat, + label, + legend, + labelpos=labelpos) - plot(graph["z"]["dx"], "mean", args.prefix + "_z_mean", "dx", cat, label, - legend, labelpos=labelpos) - plot(graph["z"]["dx"], "sigma", args.prefix + "_z_sigma", "dx", cat, label, - legend, labelpos=labelpos) - - plot(graph["z"]["dy"], "mean", args.prefix + "_z_mean", "dy", cat, label, - legend, labelpos=labelpos) - plot(graph["z"]["dy"], "sigma", args.prefix + "_z_sigma", "dy", cat, label, - legend, labelpos=labelpos) - + plot( + graph["z"]["dy"], + "mean", + args.prefix + "_z_mean", + "dy", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["dy"], + "sigma", + args.prefix + "_z_sigma", + "dy", + cat, + label, + legend, + labelpos=labelpos) - plot(graph["z"]["dz"], "mean", args.prefix + "_z_mean", "dz", cat, label, - legend, labelpos=labelpos) - plot(graph["z"]["dz"], "sigma", args.prefix + "_z_sigma", "dz", cat, label, - legend, labelpos=labelpos) + plot( + graph["z"]["dz"], + "mean", + args.prefix + "_z_mean", + "dz", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["dz"], + "sigma", + args.prefix + "_z_sigma", + "dz", + cat, + label, + legend, + labelpos=labelpos) diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py index 02e0ab776a1..16d61773c5a 100644 --- a/Hlt/RecoConf/scripts/utils/pvutils.py +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -50,7 +50,8 @@ def get_trees(tf, tr, label, trees, is_checker): return tr -def get_eff(eff, hist, trees, dependence, style, ranges, categories, label, offset): +def get_eff(eff, hist, trees, dependence, style, ranges, categories, label, + offset): for cat in categories: eff[cat] = {} @@ -93,7 +94,7 @@ def get_eff(eff, hist, trees, dependence, style, ranges, categories, label, offs g_eff = TGraphAsymmErrors() g_eff.Divide(h_nom, h_den, "cl=0.683 b(1,1) mode") - set_style(h_nom, style["color"][i]-7, style["marker"][i]+4, + set_style(h_nom, style["color"][i] - 7, style["marker"][i] + 4, get_x_axis(dependence), "Efficiency", "") set_style(h_den, kGray, style["marker"][i], get_x_axis(dependence), "Efficiency", "") @@ -136,7 +137,7 @@ def plot(gr, legend=None, hist=None, dist=False, - labelpos=(0.75, 0.78,0.9,0.9)): + labelpos=(0.75, 0.78, 0.9, 0.9)): for cat in categories: can = TCanvas( @@ -184,7 +185,8 @@ def plot(gr, if legend: legend.Draw("SAME") - pavetext = TPaveText(labelpos[0],labelpos[1],labelpos[2],labelpos[3], "NBNDC") + pavetext = TPaveText(labelpos[0], labelpos[1], labelpos[2], + labelpos[3], "NBNDC") pavetext.AddText("LHCb simulation") pavetext.SetFillColor(0) pavetext.SetFillStyle(3000) @@ -260,7 +262,8 @@ def set_text(text, color, x, y, lab, mean, mean_err, rms, rms_err, scale, return text -def plot_comparison(hist, prefix, dependence, categories, label, style, norm, offset): +def plot_comparison(hist, prefix, dependence, categories, label, style, norm, + offset): for cat in categories: can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence, cat=cat), @@ -298,7 +301,8 @@ def plot_comparison(hist, prefix, dependence, categories, label, style, norm, of hist[cat][label[0]].Draw("hist") for lab in label: hist[cat][lab].Draw("SAME PE") - pavetext = TPaveText(0.72, 0.77 - gStyle.GetPadTopMargin(), 0.87, 0.89 - gStyle.GetPadTopMargin(), "NBNDC") + pavetext = TPaveText(0.72, 0.77 - gStyle.GetPadTopMargin(), 0.87, + 0.89 - gStyle.GetPadTopMargin(), "NBNDC") pavetext.AddText("LHCb simulation") pavetext.SetFillColor(0) pavetext.SetTextSize(0.06) -- GitLab From b52d72059b352c68502d3c6592683d227537543d Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Mon, 11 May 2020 13:57:12 +0200 Subject: [PATCH 146/171] remove json file location from make_allen_output parameters --- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index c9d7e902a4d..960d1827d9e 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -38,9 +38,8 @@ def make_allen_output(odin_location=make_odin, return RunAllen( AllenRawInput=dumped_raw_banks(dump_to_file=dump_to_file), ODINLocation=odin_location(), - FilterHLT1=filter_hlt1, ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", - JSON="${ALLEN_PROJECT_ROOT}/configuration/constants/default.json" + FilterHLT1=filter_hlt1 ).AllenOutput -- GitLab From 43ae06918f4a2e560c7bb4026cc09eac2c19ed80 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Tue, 12 May 2020 10:56:35 +0200 Subject: [PATCH 147/171] call Allen as trigger --- Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py | 39 +++++++++++++++++++ Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py | 27 +++++++++++++ .../python/Hlt1Conf/lines/luminosity.py | 14 +++++++ Hlt/Hlt1Conf/python/Hlt1Conf/settings.py | 7 +++- .../hlt1_reco_allen_track_reconstruction.py | 5 ++- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 10 +++-- 6 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py create mode 100644 Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py diff --git a/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py new file mode 100644 index 00000000000..b1ce5004505 --- /dev/null +++ b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py @@ -0,0 +1,39 @@ +############################################################################### +# (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. # +############################################################################### +import os, json + +from Moore import options, run_moore +from Hlt1Conf.settings import allen_lines + +from Configurables import ApplicationMgr +from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable +from Configurables import DumpMuonGeometry, DumpVPGeometry +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import RunAllen, AllenUpdater +from Configurables import HltANNSvc + +options.scheduler_legacy_mode = False +run_moore(options, allen_lines) + +producers = [ + p(DumpToFile=False) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) +] + +# Add the services that will produce the non-event-data +ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), +] + producers + + + diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py new file mode 100644 index 00000000000..f5f3936c653 --- /dev/null +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py @@ -0,0 +1,27 @@ +############################################################################### +# (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 Moore.config import HltLine + +from RecoConf.hlt1_allen import make_allen_dec_reports + + +def allen_line( + name='Hlt1Allen', + prescale=1): + + allen = make_allen_dec_reports(filterHLT1=True) + + return HltLine( + name=name, + algs=[allen], + prescale=prescale) + + diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py index db67a9e1c1c..e402a68e55a 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py @@ -57,3 +57,17 @@ def luminosity_line(name="Hlt1LuminosityLine", prescale=1): InputSummaries=[velo_summary, pv_summary]) return HltLine(name=name, algs=[lumi, merged_summary], prescale=prescale) + +from RecoConf.hlt1_allen import make_allen_dec_reports + +def allen_line( + name='Hlt1Allen', + prescale=1): + + allen = make_allen_dec_reports(filterHLT1=True) + + return HltLine( + name=name, + algs=[allen], + prescale=prescale) + diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py b/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py index 5367922e3f7..564962d7449 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py @@ -21,8 +21,9 @@ from Hlt1Conf.lines.minimum_bias import ( low_multiplicity_velo_line, no_bias_line, ) -from Hlt1Conf.lines.luminosity import luminosity_line +from Hlt1Conf.lines.luminosity import luminosity_line, allen_line +#from HLT1Conf.lines.allen import allen_line def track_mva_lines(): return [ @@ -83,3 +84,7 @@ def comparison_lines(): one_track_muon_highpt_line(), #gec_passthrough_line() ] + +def allen_lines(): + return [allen_line()] + diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py index 462085b7930..8c602eeedd8 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py @@ -16,8 +16,8 @@ from RecoConf.mc_checking import tracker_dumper, pv_dumper, get_track_checkers from Configurables import ApplicationMgr from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks +from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables +from Configurables import RunAllen, AllenUpdater dumpBinaries = False outputDir = "dump/" @@ -61,3 +61,4 @@ producers = [ ApplicationMgr().ExtSvc += [ AllenUpdater(OutputLevel=2), ] + producers + diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 960d1827d9e..a4da62814a2 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -98,10 +98,14 @@ def make_allen_pvs(): return AllenPVsToRecVertexV2(AllenOutput=allen_output).OutputPVs -def make_allen_dec_reports(): - allen_output = make_allen_output() +def make_allen_dec_reports(filterHLT1=False): + allen_output = make_allen_output(filter_hlt1=filterHLT1) allen_dec_reports_raw = AllenDecReportsToTES( AllenOutput=allen_output).OutputDecReports + return allen_dec_reports_raw + +def decode_allen_dec_reports(): + allen_dec_reports_raw = make_allen_dec_reports() return HltDecReportsDecoder( RawEventLocations=allen_dec_reports_raw, - SourceID=1).OutputHltDecReportsLocation + SourceID=1).OutputHltDecReportsLocation -- GitLab From 62a105829f78b7cf6892415f395d7ff716457815 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Tue, 12 May 2020 13:38:24 +0200 Subject: [PATCH 148/171] add run_allen and run_allen_reconstruction to config, where ApplicationMgr and Hlt1ANN are configured --- Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py | 25 +---- .../python/Hlt1Conf/lines/luminosity.py | 4 +- Hlt/Hlt1Conf/tests/options/test_decreports.py | 2 +- Hlt/Moore/python/Moore/__init__.py | 2 +- Hlt/Moore/python/Moore/config.py | 97 ++++++++++++++++++- .../options/hlt1_reco_allen_IPresolution.py | 22 +---- .../hlt1_reco_allen_muonid_efficiency.py | 38 +------- .../options/hlt1_reco_allen_pvchecker.py | 24 +---- .../hlt1_reco_allen_track_reconstruction.py | 23 +---- .../hlt1_reco_allen_trackresolution.py | 21 +--- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 2 + 11 files changed, 116 insertions(+), 144 deletions(-) diff --git a/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py index b1ce5004505..dada8675c19 100644 --- a/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py +++ b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py @@ -10,30 +10,15 @@ ############################################################################### import os, json -from Moore import options, run_moore +from Moore import options, run_allen from Hlt1Conf.settings import allen_lines -from Configurables import ApplicationMgr -from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable -from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import RunAllen, AllenUpdater -from Configurables import HltANNSvc -options.scheduler_legacy_mode = False -run_moore(options, allen_lines) +from Configurables import RunAllen -producers = [ - p(DumpToFile=False) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) -] +options.scheduler_legacy_mode = False +run_allen(options, allen_lines) -# Add the services that will produce the non-event-data -ApplicationMgr().ExtSvc += [ - AllenUpdater(OutputLevel=2), -] + producers - + diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py index e402a68e55a..012cd24e52f 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py @@ -58,13 +58,13 @@ def luminosity_line(name="Hlt1LuminosityLine", prescale=1): return HltLine(name=name, algs=[lumi, merged_summary], prescale=prescale) -from RecoConf.hlt1_allen import make_allen_dec_reports +from RecoConf.hlt1_allen import make_allen_dec_reports, decode_allen_dec_reports def allen_line( name='Hlt1Allen', prescale=1): - allen = make_allen_dec_reports(filterHLT1=True) + allen = decode_allen_dec_reports() return HltLine( name=name, diff --git a/Hlt/Hlt1Conf/tests/options/test_decreports.py b/Hlt/Hlt1Conf/tests/options/test_decreports.py index 323f3efb88a..fa8883e4376 100644 --- a/Hlt/Hlt1Conf/tests/options/test_decreports.py +++ b/Hlt/Hlt1Conf/tests/options/test_decreports.py @@ -26,7 +26,7 @@ from Configurables import ( IODataManager, LHCbApp, ) -from DAQSys.Decoders import DecoderDB +from DAQSys.Decoders import DecoderDB from GaudiConf import IOHelper import GaudiPython diff --git a/Hlt/Moore/python/Moore/__init__.py b/Hlt/Moore/python/Moore/__init__.py index 7d6c6220b3e..a04131838cc 100644 --- a/Hlt/Moore/python/Moore/__init__.py +++ b/Hlt/Moore/python/Moore/__init__.py @@ -12,4 +12,4 @@ """ from .config import (options, run_moore, run_reconstruction, - moore_control_flow) # noqa + moore_control_flow, run_allen, run_allen_reconstruction) # noqa diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index a45613a638f..1d14ea7aacd 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -208,7 +208,7 @@ def report_writers_node(lines, line.decision_name: n for n, line in enumerate(lines, 1) }) - + lines_with_output = [l for l in lines if l.produces_output()] lumi_lines = [ l for l in lines_with_output @@ -303,7 +303,7 @@ def moore_control_flow(options, lines): combineLogic=NodeLogic.LAZY_AND, children=[dec] + writers, forceOrder=True) - + def run_moore(options, make_lines, public_tools=[]): """Configure Moore's entire control and data flow. @@ -318,14 +318,101 @@ def run_moore(options, make_lines, public_tools=[]): public_tools (list): list of public `Tool` instances to configure """ - + config = configure_input(options) lines = make_lines() top_cf_node = moore_control_flow(options, lines) config.update(configure(options, top_cf_node, public_tools=public_tools)) # TODO pass config to gaudi explicitly when that is supported return config + +def setup_allen_non_event_data_service(dump_binaries=False): + """Setup Allen non-event data + + An ExtSvc is added to the ApplicationMgr to provide the Allen non-event data (geometries etc.) + """ + from Configurables import ApplicationMgr + from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable + from Configurables import DumpMuonGeometry, DumpVPGeometry + from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables + from Configurables import AllenUpdater + producers = [ + p(DumpToFile=dump_binaries) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, + DumpMuonTable, DumpMagneticField, DumpBeamline, + DumpUTLookupTables) + ] + ApplicationMgr().ExtSvc += [ + AllenUpdater(OutputLevel=2), + ] + producers + + +def setup_allen_Hlt1ANN(): + """Configure HltANN service from Allen configuration json file + + """ + import os, json + Hlt1SelectionIDs = {} + with open(os.path.expandvars( + "$ALLEN_INSTALL_DIR/constants/Sequence.json")) as config_file: + config = (json.load(config_file)) + index = 0 + for line in config["configured_lines"]: + line_name = "Hlt1" + str(line) + "Decision" + Hlt1SelectionIDs[line_name] = index + index += 1 + + print Hlt1SelectionIDs + + hlt_ann_svc = setup_component( + "HltANNSvc", + Hlt1SelectionID=Hlt1SelectionIDs) + + +def run_allen(options, make_lines): + """Configure Allen within Mooore. + + Convenience function that sets up an Allen node and sets up services + + Args: + options (ApplicationOptions): holder of application options + make_lines: function returning a list of `HltLine` objects + + """ + + setup_allen_non_event_data_service() + + setup_allen_Hlt1ANN() + + config = configure_input(options) + lines = make_lines() + + options.finalize() + + top_cf_node = CompositeNode( + 'allen', + combineLogic=NodeLogic.NONLAZY_OR, + children=[line.node for line in lines], + forceOrder=False) + + config.update(configure(options, top_cf_node)) + # TODO pass config to gaudi explicitly when that is supported + return config + +def run_allen_reconstruction(options, make_reconstruction, dumpBinaries=False, public_tools=[]): + """Configure the Allen reconstruction data flow + Convenience function that configures all services and creates a data flow. + + Args: + options (ApplicationOptions): holder of application options + make_reconstruction: function returning a single CompositeNode object + public_tools (list): list of public `Tool` instances to configure + + """ + + setup_allen_non_event_data_service(dump_binaries=dumpBinaries) + return run_reconstruction(options, make_reconstruction, public_tools=public_tools) def run_reconstruction(options, make_reconstruction, public_tools=[]): """Configure the reconstruction data flow with a simple control flow. @@ -338,14 +425,14 @@ def run_reconstruction(options, make_reconstruction, public_tools=[]): public_tools (list): list of public `Tool` instances to configure """ - + config = configure_input(options) reconstruction = make_reconstruction() config.update( configure(options, reconstruction.node, public_tools=public_tools)) # TODO pass config to gaudi explicitly when that is supported return config - + #: Regular expression (compiled) defining the valid line names HLT_LINE_NAME_PATTERN = re.compile(r'^Hlt[12][A-Za-z0-9_]+Line$') diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py index dd5082b9ef8..8b5841e422d 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py @@ -8,17 +8,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -from Moore import options, run_reconstruction +from Moore import options, run_allen_reconstruction from Moore.config import Reconstruction -from RecoConf.hlt1_tracking import require_gec, make_VeloKalman_fitted_tracks +from RecoConf.hlt1_tracking import require_gec from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs from RecoConf.mc_checking import monitor_IPresolution -from Configurables import ApplicationMgr from Configurables import NTupleSvc -from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable -from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import AllenUpdater def hlt1_reco_allen_IPresolution(): @@ -31,16 +26,5 @@ def hlt1_reco_allen_IPresolution(): options.histo_file = "Hlt1ForwardTracking_IPresolution_Allen.root" -run_reconstruction(options, hlt1_reco_allen_IPresolution) +run_allen_reconstruction(options, hlt1_reco_allen_IPresolution) -producers = [ - p(DumpToFile=False) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) -] - -# Add the services that will produce the non-event-data -ApplicationMgr().ExtSvc += [ - AllenUpdater(OutputLevel=2), -] + producers diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py b/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py index 4893320ef90..6553218a8da 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py @@ -8,46 +8,14 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -from Moore import options, run_reconstruction +from Moore import options, run_allen_reconstruction from Moore.config import Reconstruction -from PyConf.application import configure_input, configure -from PyConf.control_flow import CompositeNode, NodeLogic -from RecoConf.hlt1_tracking import (require_gec, make_hlt1_tracks, - make_VeloClusterTrackingSIMD_hits) +from RecoConf.hlt1_tracking import require_gec from RecoConf.mc_checking import monitor_tracking_efficiency, make_links_tracks_mcparticles, make_links_lhcbids_mcparticles_tracking_system from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask -from RecoConf.hlt1_muonid import make_fitted_tracks_with_muon_id -from Configurables import ApplicationMgr -from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable -from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks from RecoConf.hlt1_allen import (make_allen_forward_tracks, make_allen_forward_muon_tracks) -from Hlt1Conf.algorithms import Filter - -from Functors import ISMUON - -from PyConf.Algorithms import ( - LHCb__Converters__Track__v1__fromV2TrackV1Track as - trackV1FromV2TrackV1Track, - LHCb__Converters__Track__v2__fromPrFittedForwardTrackWithMuonID as - trackV2FromPrFittedForwardTrackWithMuonID) - -producers = [ - p(DumpToFile=False) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) -] - -# Add the services that will produce the non-event-data -ApplicationMgr().ExtSvc += [ - AllenUpdater(OutputLevel=2), -] + producers - - def hlt1_reco_allen_muonid_efficiency(): # get the fitted tracks with muon ID forward_muon_tracks = make_allen_forward_muon_tracks() @@ -89,4 +57,4 @@ def hlt1_reco_allen_muonid_efficiency(): options.histo_file = "PrChecker_MuonID.root" -run_reconstruction(options, hlt1_reco_allen_muonid_efficiency) +run_allen_reconstruction(options, hlt1_reco_allen_muonid_efficiency) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py index ce1bc77ceea..69aa6b21276 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py @@ -8,17 +8,11 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -from Moore import options, run_reconstruction +from Moore import options, run_allen_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs from RecoConf.mc_checking import get_pv_checkers, get_track_checkers -from Configurables import ApplicationMgr -from Configurables import NTupleSvc -from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable -from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import AllenUpdater def hlt1_reco_pvchecker(): @@ -33,22 +27,8 @@ def hlt1_reco_pvchecker(): return Reconstruction('PVperformance', data, [require_gec()]) -run_reconstruction(options, hlt1_reco_pvchecker) +run_allen_reconstruction(options, hlt1_reco_pvchecker) NTupleSvc().Output += [ "FILE1 DATAFILE='Hlt1_PVperformance.root' TYPE='ROOT' OPT='NEW'" ] -ApplicationMgr().ExtSvc += [NTupleSvc()] -ApplicationMgr().HistogramPersistency = "ROOT" - -producers = [ - p(DumpToFile=False) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) -] - -# Add the services that will produce the non-event-data -ApplicationMgr().ExtSvc += [ - AllenUpdater(OutputLevel=2), -] + producers diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py index 8c602eeedd8..8a9575fb8b3 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py @@ -8,16 +8,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -from Moore import options, run_reconstruction +from Moore import options, run_allen_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec from RecoConf.hlt1_allen import make_allen_tracks, make_dumped_raw_banks from RecoConf.mc_checking import tracker_dumper, pv_dumper, get_track_checkers -from Configurables import ApplicationMgr -from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable -from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import RunAllen, AllenUpdater +from Configurables import RunAllen dumpBinaries = False outputDir = "dump/" @@ -48,17 +44,4 @@ def hlt1_reco_allen_tracks(): return Reconstruction('allen_reco', data, [require_gec()]) -run_reconstruction(options, hlt1_reco_allen_tracks) - -producers = [ - p(DumpToFile=dumpBinaries) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) -] - -# Add the services that will produce the non-event-data -ApplicationMgr().ExtSvc += [ - AllenUpdater(OutputLevel=2), -] + producers - +run_allen_reconstruction(options, hlt1_reco_allen_tracks) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py index d9c02262ed9..46b66781294 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_trackresolution.py @@ -8,16 +8,11 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -from Moore import options, run_reconstruction +from Moore import options, run_allen_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_tracking import require_gec from RecoConf.hlt1_allen import make_allen_tracks from RecoConf.mc_checking import monitor_track_resolution -from Configurables import ApplicationMgr -from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable -from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import AllenUpdater from PyConf.application import make_data_with_FetchDataFromFile @@ -33,16 +28,4 @@ def hlt1_reco_allen_trackresolution(): options.histo_file = "Hlt1ForwardTrackingResolutionAllen.root" -run_reconstruction(options, hlt1_reco_allen_trackresolution) - -producers = [ - p(DumpToFile=False) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) -] - -# Add the services that will produce the non-event-data -ApplicationMgr().ExtSvc += [ - AllenUpdater(OutputLevel=2), -] + producers +run_allen_reconstruction(options, hlt1_reco_allen_trackresolution) diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index a4da62814a2..2f51282b6b1 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -109,3 +109,5 @@ def decode_allen_dec_reports(): return HltDecReportsDecoder( RawEventLocations=allen_dec_reports_raw, SourceID=1).OutputHltDecReportsLocation + + -- GitLab From d66a8a686bd204135bd48942f877bba350eeb1f1 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 13 May 2020 12:53:54 +0200 Subject: [PATCH 149/171] write Allen DecReports to MDF file --- .../python/Hlt1Conf/lines/luminosity.py | 4 +- .../tests/options/allen_hlt1_mdf_output.py | 16 ++++++++ .../persistency.qms/allen_mdf_write.qmt | 29 ++++++++++++++ Hlt/Moore/python/Moore/config.py | 40 ++++++++++++++----- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 2 - 5 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 Hlt/Hlt1Conf/tests/options/allen_hlt1_mdf_output.py create mode 100644 Hlt/Hlt1Conf/tests/qmtest/persistency.qms/allen_mdf_write.qmt diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py index 012cd24e52f..a76252a462d 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py @@ -64,8 +64,8 @@ def allen_line( name='Hlt1Allen', prescale=1): - allen = decode_allen_dec_reports() - + allen = make_allen_dec_reports() + return HltLine( name=name, algs=[allen], diff --git a/Hlt/Hlt1Conf/tests/options/allen_hlt1_mdf_output.py b/Hlt/Hlt1Conf/tests/options/allen_hlt1_mdf_output.py new file mode 100644 index 00000000000..0a3fa274de1 --- /dev/null +++ b/Hlt/Hlt1Conf/tests/options/allen_hlt1_mdf_output.py @@ -0,0 +1,16 @@ +############################################################################### +# (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. # +############################################################################### +"""Write an HLT1-filtered MDF file.""" +from Moore import options + +options.output_file = 'test_allen_hlt1_persistence_mdf_write.mdf' +options.output_type = 'MDF' + diff --git a/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/allen_mdf_write.qmt b/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/allen_mdf_write.qmt new file mode 100644 index 00000000000..bdc38125521 --- /dev/null +++ b/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/allen_mdf_write.qmt @@ -0,0 +1,29 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $HLT1CONFROOT/tests/options/allen_hlt1_mdf_output.py + $HLT1CONFROOT/options/allen_hlt1_pp_default.py + --output=allen_mdf_write.opts.py + --all-opts + +true + + + + + diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 1d14ea7aacd..86fc2121195 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -192,12 +192,12 @@ def report_writers_node(lines, erw = ExecutionReportsWriter( Persist=[line.name for line in lines], ANNSvcKey="Hlt1SelectionID", - ) + ) drw = HltDecReportsWriter( InputHltDecReportsLocation=erw.DecReportsLocation, outputs=dict( OutputRawEventLocation=force_location(reports_raw_event.location)), - ) + ) algs.extend([erw, drw]) locations_to_persist.append(drw.OutputRawEventLocation) @@ -269,7 +269,7 @@ def report_writers_node(lines, # Transform to a list of unique str locations_to_persist = list( set(map(_format_location, locations_to_persist))) - + return node, locations_to_persist @@ -346,9 +346,8 @@ def setup_allen_non_event_data_service(dump_binaries=False): AllenUpdater(OutputLevel=2), ] + producers - -def setup_allen_Hlt1ANN(): - """Configure HltANN service from Allen configuration json file +def get_allen_hlt1_lines(): + """Read Allen HLT1 lines from json configuration file """ import os, json @@ -361,13 +360,20 @@ def setup_allen_Hlt1ANN(): line_name = "Hlt1" + str(line) + "Decision" Hlt1SelectionIDs[line_name] = index index += 1 - print Hlt1SelectionIDs + + return Hlt1SelectionIDs + +def setup_allen_Hlt1ANN(): + """Configure HltANN service for Allen + """ + Hlt1SelectionIDs = get_allen_hlt1_lines() hlt_ann_svc = setup_component( "HltANNSvc", Hlt1SelectionID=Hlt1SelectionIDs) + return Hlt1SelectionIDs def run_allen(options, make_lines): """Configure Allen within Mooore. @@ -382,19 +388,33 @@ def run_allen(options, make_lines): setup_allen_non_event_data_service() - setup_allen_Hlt1ANN() + Hlt1SelectionIDs = setup_allen_Hlt1ANN() config = configure_input(options) lines = make_lines() + from RecoConf.hlt1_allen import make_allen_dec_reports + locations_to_persist = [make_allen_dec_reports()] + # Transform to a list of unique str + locations_to_persist = list( + set(map(_format_location, locations_to_persist))) + writers = [] + writers.extend(output_writers(options, locations_to_persist)) + options.finalize() - top_cf_node = CompositeNode( - 'allen', + dec = CompositeNode( + 'hlt_decision', combineLogic=NodeLogic.NONLAZY_OR, children=[line.node for line in lines], forceOrder=False) + top_cf_node = CompositeNode( + 'allen', + combineLogic=NodeLogic.NONLAZY_OR, + children = [dec] + writers, + forceOrder=True) + config.update(configure(options, top_cf_node)) # TODO pass config to gaudi explicitly when that is supported return config diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 2f51282b6b1..a4da62814a2 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -109,5 +109,3 @@ def decode_allen_dec_reports(): return HltDecReportsDecoder( RawEventLocations=allen_dec_reports_raw, SourceID=1).OutputHltDecReportsLocation - - -- GitLab From cb8f8ab79c2924e3ac7e6bac3ed7852a77fc51b3 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 13 May 2020 13:04:01 +0200 Subject: [PATCH 150/171] cleanup --- .../dump_binary_input_for_standalone_Allen.py | 21 +------- .../hlt1_reco_allen_track_reconstruction.py | 2 +- Hlt/RecoConf/python/RecoConf/standalone.py | 48 ------------------- 3 files changed, 3 insertions(+), 68 deletions(-) diff --git a/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py index 1d0ddeee1f0..7182200855a 100644 --- a/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py +++ b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py @@ -8,15 +8,10 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -from Moore import options, run_reconstruction +from Moore import options, run_allen_reconstruction from Moore.config import Reconstruction from RecoConf.hlt1_allen import make_dumped_raw_banks from RecoConf.mc_checking import tracker_dumper, pv_dumper -from Configurables import ApplicationMgr -from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable -from Configurables import DumpMuonGeometry, DumpVPGeometry -from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables -from Configurables import AllenUpdater outputDir = "dump/" @@ -37,16 +32,4 @@ def dump_allen_binary_input(): return Reconstruction('allen_dump', data) -run_reconstruction(options, dump_allen_binary_input) - -producers = [ - p(DumpToFile=True) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) -] - -# Add the services that will produce the non-event-data -ApplicationMgr().ExtSvc += [ - AllenUpdater(OutputLevel=2), -] + producers +run_allen_reconstruction(options, dump_allen_binary_input, True) diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py index 8a9575fb8b3..4e2a9a44111 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_track_reconstruction.py @@ -44,4 +44,4 @@ def hlt1_reco_allen_tracks(): return Reconstruction('allen_reco', data, [require_gec()]) -run_allen_reconstruction(options, hlt1_reco_allen_tracks) +run_allen_reconstruction(options, hlt1_reco_allen_tracks, dumpBinaries) diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index b07dd9d23f6..831605641d3 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -74,54 +74,6 @@ def standalone_hlt1_reco(do_mc_checking=False): return Reconstruction('hlt1_reco', data, reco_prefilters()) - -@configurable -def standalone_hlt1_reco_allen(do_mc_checking=False, dump_binaries=False): - """ Run the Hlt1 reconstruction, i.e. tracking and muon id, MC checking optional with the Allen sequence - Args: - do_mc_checking (bool): Enable MC checking. - Returns: - Reconstruction: Data and control flow of Hlt1 reconstruction. - - """ - # Allen hlt1 - allen_tracks = make_allen_tracks(dump_to_file=dump_binaries) - - if do_mc_checking: - types_and_locations_for_checkers = { - "Velo": allen_tracks["Velo"], - "Upstream": allen_tracks["Upstream"], - "Forward": allen_tracks["Forward"], - } - data = get_track_checkers(types_and_locations_for_checkers) - - if dump_binaries: - data.append( - tracker_dumper(dump_to_root=False, dump_to_binary=True)) - data.append(pv_dumper()) - - return Reconstruction('hlt1_reco', data, reco_prefilters()) - - -def standalone_hlt1_allen(): - """ Run the Allen HLT1 sequence - Returns: - Reconstruction: Data and control flow of Hlt1 reconstruction. - - """ - # Allen hlt1 - allen_dec_reports_raw = make_allen_dec_reports() - allen_dec_reports = HltDecReportsDecoder( - RawEventLocations=allen_dec_reports_raw) - data = [allen_dec_reports] - - return CompositeNode( - 'allen', - combineLogic=NodeLogic.LAZY_AND, - children=data + reco_prefilters(), - forceOrder=True) - - def standalone_hlt1_reco_velo_only(): """ Run the default Hlt1 Velo reconstruction Returns: -- GitLab From 029f91a6ed20ae54329c2914570b7225e8dca0cd Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 13 May 2020 11:04:58 +0000 Subject: [PATCH 151/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/8359677 --- Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py | 5 -- Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py | 15 +--- .../python/Hlt1Conf/lines/luminosity.py | 14 ++- Hlt/Hlt1Conf/python/Hlt1Conf/settings.py | 3 +- .../tests/options/allen_hlt1_mdf_output.py | 1 - Hlt/Hlt1Conf/tests/options/test_decreports.py | 2 +- Hlt/Moore/python/Moore/__init__.py | 3 +- Hlt/Moore/python/Moore/config.py | 86 +++++++++++-------- .../options/hlt1_reco_allen_IPresolution.py | 1 - .../hlt1_reco_allen_muonid_efficiency.py | 1 + Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 6 +- Hlt/RecoConf/python/RecoConf/standalone.py | 1 + 12 files changed, 67 insertions(+), 71 deletions(-) diff --git a/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py index dada8675c19..07051514a87 100644 --- a/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py +++ b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py @@ -13,12 +13,7 @@ import os, json from Moore import options, run_allen from Hlt1Conf.settings import allen_lines - from Configurables import RunAllen options.scheduler_legacy_mode = False run_allen(options, allen_lines) - - - - diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py index f5f3936c653..f4d36d4247b 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py @@ -10,18 +10,11 @@ ############################################################################### from Moore.config import HltLine -from RecoConf.hlt1_allen import make_allen_dec_reports +from RecoConf.hlt1_allen import make_allen_dec_reports -def allen_line( - name='Hlt1Allen', - prescale=1): +def allen_line(name='Hlt1Allen', prescale=1): allen = make_allen_dec_reports(filterHLT1=True) - - return HltLine( - name=name, - algs=[allen], - prescale=prescale) - - + + return HltLine(name=name, algs=[allen], prescale=prescale) diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py index a76252a462d..3ac45f8fe35 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py @@ -58,16 +58,12 @@ def luminosity_line(name="Hlt1LuminosityLine", prescale=1): return HltLine(name=name, algs=[lumi, merged_summary], prescale=prescale) + from RecoConf.hlt1_allen import make_allen_dec_reports, decode_allen_dec_reports -def allen_line( - name='Hlt1Allen', - prescale=1): + +def allen_line(name='Hlt1Allen', prescale=1): allen = make_allen_dec_reports() - - return HltLine( - name=name, - algs=[allen], - prescale=prescale) - + + return HltLine(name=name, algs=[allen], prescale=prescale) diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py b/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py index 564962d7449..f976a00f8fe 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py @@ -25,6 +25,7 @@ from Hlt1Conf.lines.luminosity import luminosity_line, allen_line #from HLT1Conf.lines.allen import allen_line + def track_mva_lines(): return [ one_track_mva_line(), @@ -85,6 +86,6 @@ def comparison_lines(): #gec_passthrough_line() ] + def allen_lines(): return [allen_line()] - diff --git a/Hlt/Hlt1Conf/tests/options/allen_hlt1_mdf_output.py b/Hlt/Hlt1Conf/tests/options/allen_hlt1_mdf_output.py index 0a3fa274de1..b6d0fd56e7d 100644 --- a/Hlt/Hlt1Conf/tests/options/allen_hlt1_mdf_output.py +++ b/Hlt/Hlt1Conf/tests/options/allen_hlt1_mdf_output.py @@ -13,4 +13,3 @@ from Moore import options options.output_file = 'test_allen_hlt1_persistence_mdf_write.mdf' options.output_type = 'MDF' - diff --git a/Hlt/Hlt1Conf/tests/options/test_decreports.py b/Hlt/Hlt1Conf/tests/options/test_decreports.py index fa8883e4376..323f3efb88a 100644 --- a/Hlt/Hlt1Conf/tests/options/test_decreports.py +++ b/Hlt/Hlt1Conf/tests/options/test_decreports.py @@ -26,7 +26,7 @@ from Configurables import ( IODataManager, LHCbApp, ) -from DAQSys.Decoders import DecoderDB +from DAQSys.Decoders import DecoderDB from GaudiConf import IOHelper import GaudiPython diff --git a/Hlt/Moore/python/Moore/__init__.py b/Hlt/Moore/python/Moore/__init__.py index a04131838cc..cf5f1bff822 100644 --- a/Hlt/Moore/python/Moore/__init__.py +++ b/Hlt/Moore/python/Moore/__init__.py @@ -12,4 +12,5 @@ """ from .config import (options, run_moore, run_reconstruction, - moore_control_flow, run_allen, run_allen_reconstruction) # noqa + moore_control_flow, run_allen, + run_allen_reconstruction) # noqa diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 86fc2121195..683c3af10e3 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -192,12 +192,12 @@ def report_writers_node(lines, erw = ExecutionReportsWriter( Persist=[line.name for line in lines], ANNSvcKey="Hlt1SelectionID", - ) + ) drw = HltDecReportsWriter( InputHltDecReportsLocation=erw.DecReportsLocation, outputs=dict( OutputRawEventLocation=force_location(reports_raw_event.location)), - ) + ) algs.extend([erw, drw]) locations_to_persist.append(drw.OutputRawEventLocation) @@ -208,7 +208,7 @@ def report_writers_node(lines, line.decision_name: n for n, line in enumerate(lines, 1) }) - + lines_with_output = [l for l in lines if l.produces_output()] lumi_lines = [ l for l in lines_with_output @@ -269,7 +269,7 @@ def report_writers_node(lines, # Transform to a list of unique str locations_to_persist = list( set(map(_format_location, locations_to_persist))) - + return node, locations_to_persist @@ -303,7 +303,7 @@ def moore_control_flow(options, lines): combineLogic=NodeLogic.LAZY_AND, children=[dec] + writers, forceOrder=True) - + def run_moore(options, make_lines, public_tools=[]): """Configure Moore's entire control and data flow. @@ -318,42 +318,45 @@ def run_moore(options, make_lines, public_tools=[]): public_tools (list): list of public `Tool` instances to configure """ - + config = configure_input(options) lines = make_lines() top_cf_node = moore_control_flow(options, lines) config.update(configure(options, top_cf_node, public_tools=public_tools)) # TODO pass config to gaudi explicitly when that is supported return config - + + def setup_allen_non_event_data_service(dump_binaries=False): """Setup Allen non-event data - An ExtSvc is added to the ApplicationMgr to provide the Allen non-event data (geometries etc.) - """ + An ExtSvc is added to the ApplicationMgr to provide the Allen non-event data (geometries etc.) + """ from Configurables import ApplicationMgr from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable from Configurables import DumpMuonGeometry, DumpVPGeometry - from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables + from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables from Configurables import AllenUpdater producers = [ p(DumpToFile=dump_binaries) - for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, DumpMuonGeometry, - DumpMuonTable, DumpMagneticField, DumpBeamline, - DumpUTLookupTables) + for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, + DumpMuonGeometry, DumpMuonTable, DumpMagneticField, + DumpBeamline, DumpUTLookupTables) ] ApplicationMgr().ExtSvc += [ AllenUpdater(OutputLevel=2), ] + producers - + + def get_allen_hlt1_lines(): - """Read Allen HLT1 lines from json configuration file + """Read Allen HLT1 lines from json configuration file - """ + """ import os, json Hlt1SelectionIDs = {} - with open(os.path.expandvars( - "$ALLEN_INSTALL_DIR/constants/Sequence.json")) as config_file: + with open( + os.path.expandvars( + "$ALLEN_INSTALL_DIR/constants/Sequence.json")) as config_file: config = (json.load(config_file)) index = 0 for line in config["configured_lines"]: @@ -361,35 +364,36 @@ def get_allen_hlt1_lines(): Hlt1SelectionIDs[line_name] = index index += 1 print Hlt1SelectionIDs - + return Hlt1SelectionIDs -def setup_allen_Hlt1ANN(): - """Configure HltANN service for Allen - """ +def setup_allen_Hlt1ANN(): + """Configure HltANN service for Allen + + """ Hlt1SelectionIDs = get_allen_hlt1_lines() hlt_ann_svc = setup_component( - "HltANNSvc", - Hlt1SelectionID=Hlt1SelectionIDs) - + "HltANNSvc", Hlt1SelectionID=Hlt1SelectionIDs) + return Hlt1SelectionIDs + def run_allen(options, make_lines): """Configure Allen within Mooore. Convenience function that sets up an Allen node and sets up services - + Args: options (ApplicationOptions): holder of application options make_lines: function returning a list of `HltLine` objects """ - + setup_allen_non_event_data_service() - + Hlt1SelectionIDs = setup_allen_Hlt1ANN() - + config = configure_input(options) lines = make_lines() @@ -400,9 +404,9 @@ def run_allen(options, make_lines): set(map(_format_location, locations_to_persist))) writers = [] writers.extend(output_writers(options, locations_to_persist)) - + options.finalize() - + dec = CompositeNode( 'hlt_decision', combineLogic=NodeLogic.NONLAZY_OR, @@ -412,14 +416,18 @@ def run_allen(options, make_lines): top_cf_node = CompositeNode( 'allen', combineLogic=NodeLogic.NONLAZY_OR, - children = [dec] + writers, + children=[dec] + writers, forceOrder=True) config.update(configure(options, top_cf_node)) # TODO pass config to gaudi explicitly when that is supported return config - -def run_allen_reconstruction(options, make_reconstruction, dumpBinaries=False, public_tools=[]): + + +def run_allen_reconstruction(options, + make_reconstruction, + dumpBinaries=False, + public_tools=[]): """Configure the Allen reconstruction data flow Convenience function that configures all services and creates a data flow. @@ -430,9 +438,11 @@ def run_allen_reconstruction(options, make_reconstruction, dumpBinaries=False, p public_tools (list): list of public `Tool` instances to configure """ - + setup_allen_non_event_data_service(dump_binaries=dumpBinaries) - return run_reconstruction(options, make_reconstruction, public_tools=public_tools) + return run_reconstruction( + options, make_reconstruction, public_tools=public_tools) + def run_reconstruction(options, make_reconstruction, public_tools=[]): """Configure the reconstruction data flow with a simple control flow. @@ -445,14 +455,14 @@ def run_reconstruction(options, make_reconstruction, public_tools=[]): public_tools (list): list of public `Tool` instances to configure """ - + config = configure_input(options) reconstruction = make_reconstruction() config.update( configure(options, reconstruction.node, public_tools=public_tools)) # TODO pass config to gaudi explicitly when that is supported return config - + #: Regular expression (compiled) defining the valid line names HLT_LINE_NAME_PATTERN = re.compile(r'^Hlt[12][A-Za-z0-9_]+Line$') diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py index 8b5841e422d..3eccd94a1e6 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_IPresolution.py @@ -27,4 +27,3 @@ def hlt1_reco_allen_IPresolution(): options.histo_file = "Hlt1ForwardTracking_IPresolution_Allen.root" run_allen_reconstruction(options, hlt1_reco_allen_IPresolution) - diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py b/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py index 6553218a8da..58e191415c2 100644 --- a/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py +++ b/Hlt/RecoConf/options/hlt1_reco_allen_muonid_efficiency.py @@ -16,6 +16,7 @@ from RecoConf.mc_checking_categories import get_mc_categories, get_hit_type_mask from RecoConf.hlt1_allen import (make_allen_forward_tracks, make_allen_forward_muon_tracks) + def hlt1_reco_allen_muonid_efficiency(): # get the fitted tracks with muon ID forward_muon_tracks = make_allen_forward_muon_tracks() diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index a4da62814a2..43bc08747a9 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -39,8 +39,7 @@ def make_allen_output(odin_location=make_odin, AllenRawInput=dumped_raw_banks(dump_to_file=dump_to_file), ODINLocation=odin_location(), ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", - FilterHLT1=filter_hlt1 - ).AllenOutput + FilterHLT1=filter_hlt1).AllenOutput def make_allen_velo_tracks(): @@ -104,8 +103,9 @@ def make_allen_dec_reports(filterHLT1=False): AllenOutput=allen_output).OutputDecReports return allen_dec_reports_raw + def decode_allen_dec_reports(): allen_dec_reports_raw = make_allen_dec_reports() return HltDecReportsDecoder( RawEventLocations=allen_dec_reports_raw, - SourceID=1).OutputHltDecReportsLocation + SourceID=1).OutputHltDecReportsLocation diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 831605641d3..882709c61c7 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -74,6 +74,7 @@ def standalone_hlt1_reco(do_mc_checking=False): return Reconstruction('hlt1_reco', data, reco_prefilters()) + def standalone_hlt1_reco_velo_only(): """ Run the default Hlt1 Velo reconstruction Returns: -- GitLab From 9af82647a8cd7163cdfda7c3086adc54a069dfbf Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 15 May 2020 17:51:55 +0200 Subject: [PATCH 152/171] Give LHCb::HltDecReports as input to HltDecReportsWriter --- Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py | 2 - Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py | 2 +- .../python/Hlt1Conf/lines/luminosity.py | 2 +- Hlt/Moore/python/Moore/config.py | 67 ++++++++++++++----- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 16 ++++- 5 files changed, 66 insertions(+), 23 deletions(-) diff --git a/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py index 07051514a87..13ab4148750 100644 --- a/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py +++ b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py @@ -13,7 +13,5 @@ import os, json from Moore import options, run_allen from Hlt1Conf.settings import allen_lines -from Configurables import RunAllen - options.scheduler_legacy_mode = False run_allen(options, allen_lines) diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py index f4d36d4247b..0289752f1f1 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/allen.py @@ -15,6 +15,6 @@ from RecoConf.hlt1_allen import make_allen_dec_reports def allen_line(name='Hlt1Allen', prescale=1): - allen = make_allen_dec_reports(filterHLT1=True) + allen = make_allen_dec_reports() return HltLine(name=name, algs=[allen], prescale=prescale) diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py index 3ac45f8fe35..2e9e17628fa 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py @@ -59,7 +59,7 @@ def luminosity_line(name="Hlt1LuminosityLine", prescale=1): return HltLine(name=name, algs=[lumi, merged_summary], prescale=prescale) -from RecoConf.hlt1_allen import make_allen_dec_reports, decode_allen_dec_reports +from RecoConf.hlt1_allen import make_allen_dec_reports def allen_line(name='Hlt1Allen', prescale=1): diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 683c3af10e3..7fbaf5c0564 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -174,7 +174,7 @@ def report_writers_node(lines, report_banks_to_write = ['HltDecReports', 'HltSelReports'] routing_bits_banks_to_write = ['HltRoutingBits'] lumi_banks_to_write = ['HltLumiSummary'] - reports_raw_event = default_raw_event(report_banks_to_write) + reports_raw_event = default_raw_event(report_banks_to_write) routing_bits_raw_event = default_raw_event(routing_bits_banks_to_write) lumi_raw_event = default_raw_event(lumi_banks_to_write) # TODO we probably shouldn't write in Trigger/RawEvent when @@ -200,7 +200,7 @@ def report_writers_node(lines, ) algs.extend([erw, drw]) locations_to_persist.append(drw.OutputRawEventLocation) - + hlt_ann_svc = setup_component( "HltANNSvc", # Zero is an invalid DecReport ID, so start from 1 @@ -265,7 +265,7 @@ def report_writers_node(lines, combineLogic=NodeLogic.NONLAZY_OR, children=algs, forceOrder=True) - + # Transform to a list of unique str locations_to_persist = list( set(map(_format_location, locations_to_persist))) @@ -366,8 +366,7 @@ def get_allen_hlt1_lines(): print Hlt1SelectionIDs return Hlt1SelectionIDs - - + def setup_allen_Hlt1ANN(): """Configure HltANN service for Allen @@ -397,27 +396,63 @@ def run_allen(options, make_lines): config = configure_input(options) lines = make_lines() + # Write DecReports raw banks from RecoConf.hlt1_allen import make_allen_dec_reports - locations_to_persist = [make_allen_dec_reports()] + allen_dec_reports = make_allen_dec_reports() + + # We will write the reports to raw banks at these locations + algs = [] + locations_to_persist = [] + report_banks_to_write = ['HltDecReports'] + #routing_bits_banks_to_write = ['HltRoutingBits'] + #lumi_banks_to_write = ['HltLumiSummary'] + reports_raw_event = default_raw_event(report_banks_to_write) + #routing_bits_raw_event = default_raw_event(routing_bits_banks_to_write) + #lumi_raw_event = default_raw_event(lumi_banks_to_write) + + # TODO we probably shouldn't write in Trigger/RawEvent when + # running on reconstructed data. Instead, we should create a + # RawEvent at DAQ/RawEvent, which would make HltDecReportsWriter + # happy, or make raw events/banks const and adapt everything. + kill_existing = True + if kill_existing: + all_banks_to_write = (report_banks_to_write) # + lumi_banks_to_write + routing_bits_banks_to_write) + algs.append( + bankKiller( + RawEventLocations=[reports_raw_event], + BankTypes=all_banks_to_write)) + + # erw = ExecutionReportsWriter( + # Persist=[line.name for line in lines], + # ANNSvcKey="Hlt1SelectionID", + # ) + drw = HltDecReportsWriter( + InputHltDecReportsLocation=allen_dec_reports, + outputs=dict( + OutputRawEventLocation=force_location(reports_raw_event.location)), + ) + algs.extend([drw]) + report_writers_node = CompositeNode( + 'report_writers', + combineLogic=NodeLogic.NONLAZY_OR, + children=algs, + forceOrder=True) + + locations_to_persist.append(drw.OutputRawEventLocation) + # Transform to a list of unique str locations_to_persist = list( set(map(_format_location, locations_to_persist))) - writers = [] + writers = [report_writers_node] writers.extend(output_writers(options, locations_to_persist)) - options.finalize() - - dec = CompositeNode( - 'hlt_decision', - combineLogic=NodeLogic.NONLAZY_OR, - children=[line.node for line in lines], - forceOrder=False) + options.finalize() top_cf_node = CompositeNode( 'allen', combineLogic=NodeLogic.NONLAZY_OR, - children=[dec] + writers, - forceOrder=True) + children=[make_allen_dec_reports()] + writers, + forceOrder=False) config.update(configure(options, top_cf_node)) # TODO pass config to gaudi explicitly when that is supported diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 43bc08747a9..93a05b376b6 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -40,7 +40,17 @@ def make_allen_output(odin_location=make_odin, ODINLocation=odin_location(), ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", FilterHLT1=filter_hlt1).AllenOutput - + +def make_allen_dec_reports(odin_location=make_odin, + dumped_raw_banks=make_dumped_raw_banks, + filter_hlt1=False, + dump_to_file=False): + return RunAllen( + AllenRawInput=dumped_raw_banks(dump_to_file=dump_to_file), + ODINLocation=odin_location(), + ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", + FilterHLT1=filter_hlt1).DecReportsLocation + def make_allen_velo_tracks(): allen_output = make_allen_output() @@ -97,7 +107,7 @@ def make_allen_pvs(): return AllenPVsToRecVertexV2(AllenOutput=allen_output).OutputPVs -def make_allen_dec_reports(filterHLT1=False): +def make_allen_raw_dec_reports(filterHLT1=False): allen_output = make_allen_output(filter_hlt1=filterHLT1) allen_dec_reports_raw = AllenDecReportsToTES( AllenOutput=allen_output).OutputDecReports @@ -105,7 +115,7 @@ def make_allen_dec_reports(filterHLT1=False): def decode_allen_dec_reports(): - allen_dec_reports_raw = make_allen_dec_reports() + allen_dec_reports_raw = make_allen_raw_dec_reports() return HltDecReportsDecoder( RawEventLocations=allen_dec_reports_raw, SourceID=1).OutputHltDecReportsLocation -- GitLab From fcee1bdc7841fa8fc01e2f8a7377fb9310c39160 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 15 May 2020 15:54:21 +0000 Subject: [PATCH 153/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/8398385 --- Hlt/Moore/python/Moore/config.py | 25 ++++++++++++---------- Hlt/RecoConf/python/RecoConf/hlt1_allen.py | 11 +++++----- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 7fbaf5c0564..6a63dc1f920 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -174,7 +174,7 @@ def report_writers_node(lines, report_banks_to_write = ['HltDecReports', 'HltSelReports'] routing_bits_banks_to_write = ['HltRoutingBits'] lumi_banks_to_write = ['HltLumiSummary'] - reports_raw_event = default_raw_event(report_banks_to_write) + reports_raw_event = default_raw_event(report_banks_to_write) routing_bits_raw_event = default_raw_event(routing_bits_banks_to_write) lumi_raw_event = default_raw_event(lumi_banks_to_write) # TODO we probably shouldn't write in Trigger/RawEvent when @@ -200,7 +200,7 @@ def report_writers_node(lines, ) algs.extend([erw, drw]) locations_to_persist.append(drw.OutputRawEventLocation) - + hlt_ann_svc = setup_component( "HltANNSvc", # Zero is an invalid DecReport ID, so start from 1 @@ -265,7 +265,7 @@ def report_writers_node(lines, combineLogic=NodeLogic.NONLAZY_OR, children=algs, forceOrder=True) - + # Transform to a list of unique str locations_to_persist = list( set(map(_format_location, locations_to_persist))) @@ -366,7 +366,8 @@ def get_allen_hlt1_lines(): print Hlt1SelectionIDs return Hlt1SelectionIDs - + + def setup_allen_Hlt1ANN(): """Configure HltANN service for Allen @@ -406,17 +407,19 @@ def run_allen(options, make_lines): report_banks_to_write = ['HltDecReports'] #routing_bits_banks_to_write = ['HltRoutingBits'] #lumi_banks_to_write = ['HltLumiSummary'] - reports_raw_event = default_raw_event(report_banks_to_write) + reports_raw_event = default_raw_event(report_banks_to_write) #routing_bits_raw_event = default_raw_event(routing_bits_banks_to_write) #lumi_raw_event = default_raw_event(lumi_banks_to_write) - + # TODO we probably shouldn't write in Trigger/RawEvent when # running on reconstructed data. Instead, we should create a # RawEvent at DAQ/RawEvent, which would make HltDecReportsWriter # happy, or make raw events/banks const and adapt everything. kill_existing = True if kill_existing: - all_banks_to_write = (report_banks_to_write) # + lumi_banks_to_write + routing_bits_banks_to_write) + all_banks_to_write = ( + report_banks_to_write + ) # + lumi_banks_to_write + routing_bits_banks_to_write) algs.append( bankKiller( RawEventLocations=[reports_raw_event], @@ -425,7 +428,7 @@ def run_allen(options, make_lines): # erw = ExecutionReportsWriter( # Persist=[line.name for line in lines], # ANNSvcKey="Hlt1SelectionID", - # ) + # ) drw = HltDecReportsWriter( InputHltDecReportsLocation=allen_dec_reports, outputs=dict( @@ -437,16 +440,16 @@ def run_allen(options, make_lines): combineLogic=NodeLogic.NONLAZY_OR, children=algs, forceOrder=True) - + locations_to_persist.append(drw.OutputRawEventLocation) - + # Transform to a list of unique str locations_to_persist = list( set(map(_format_location, locations_to_persist))) writers = [report_writers_node] writers.extend(output_writers(options, locations_to_persist)) - options.finalize() + options.finalize() top_cf_node = CompositeNode( 'allen', diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py index 93a05b376b6..497131f5401 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt1_allen.py +++ b/Hlt/RecoConf/python/RecoConf/hlt1_allen.py @@ -40,17 +40,18 @@ def make_allen_output(odin_location=make_odin, ODINLocation=odin_location(), ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", FilterHLT1=filter_hlt1).AllenOutput - + + def make_allen_dec_reports(odin_location=make_odin, - dumped_raw_banks=make_dumped_raw_banks, - filter_hlt1=False, - dump_to_file=False): + dumped_raw_banks=make_dumped_raw_banks, + filter_hlt1=False, + dump_to_file=False): return RunAllen( AllenRawInput=dumped_raw_banks(dump_to_file=dump_to_file), ODINLocation=odin_location(), ParamDir="${ALLEN_PROJECT_ROOT}/input/detector_configuration/down/", FilterHLT1=filter_hlt1).DecReportsLocation - + def make_allen_velo_tracks(): allen_output = make_allen_output() -- GitLab From 21f72bf2bbd40859d1fd932393b91a8b2949f845 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Tue, 19 May 2020 09:36:51 +0200 Subject: [PATCH 154/171] fix typo in allen import --- Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py | 9 --------- Hlt/Hlt1Conf/python/Hlt1Conf/settings.py | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py index 2e9e17628fa..743b0e6ca7e 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py @@ -58,12 +58,3 @@ def luminosity_line(name="Hlt1LuminosityLine", prescale=1): return HltLine(name=name, algs=[lumi, merged_summary], prescale=prescale) - -from RecoConf.hlt1_allen import make_allen_dec_reports - - -def allen_line(name='Hlt1Allen', prescale=1): - - allen = make_allen_dec_reports() - - return HltLine(name=name, algs=[allen], prescale=prescale) diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py b/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py index f976a00f8fe..f620aefcd77 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/settings.py @@ -21,9 +21,9 @@ from Hlt1Conf.lines.minimum_bias import ( low_multiplicity_velo_line, no_bias_line, ) -from Hlt1Conf.lines.luminosity import luminosity_line, allen_line +from Hlt1Conf.lines.luminosity import luminosity_line -#from HLT1Conf.lines.allen import allen_line +from Hlt1Conf.lines.allen import allen_line def track_mva_lines(): -- GitLab From 500735b02d3008400cffb48ee9013a0abdfbdf40 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Tue, 19 May 2020 18:41:40 +0200 Subject: [PATCH 155/171] towards an MDF DecReport reading test for Allen --- .../tests/options/test_allen_decreports.py | 118 ++++++++++++++++++ .../persistency.qms/mdf_read_decs_allen.qmt | 32 +++++ Hlt/Moore/python/Moore/config.py | 34 ++--- 3 files changed, 162 insertions(+), 22 deletions(-) create mode 100644 Hlt/Hlt1Conf/tests/options/test_allen_decreports.py create mode 100644 Hlt/Hlt1Conf/tests/qmtest/persistency.qms/mdf_read_decs_allen.qmt diff --git a/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py new file mode 100644 index 00000000000..31e76a83d32 --- /dev/null +++ b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py @@ -0,0 +1,118 @@ +############################################################################### +# (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. # +############################################################################### +"""Compare decisions from a log file to those stored in a MDF. + +Takes three outputs from a previously-ran job: the options dump, the log +file, and the MDF. The decisions printed by the control flow manager are +compared to those taken from the DecReports found in the MDF. Any difference +between the two is considered a failure. The options dump is used to +configure the HltANNSvc for the job ran by this script. +""" +from __future__ import print_function +import argparse + +from Configurables import ( + ApplicationMgr, + HistogramPersistencySvc, + HltANNSvc, + IODataManager, + LHCbApp, +) +from DAQSys.Decoders import DecoderDB +from GaudiConf import IOHelper +import GaudiPython + +from PyConf.utilities import read_options + +# Top-level control flow node +MOORE_KEY = "moore" + + +def get_counts_from_log(f): + """Return the decisions of each line as extracted from a log file.""" + counts = {} + with open(f) as f: + for line in filter(lambda l: "LAZY_AND:" in l, f): + columns = line.split() + hlt_line = columns[1] + count = int(columns[3].replace("Sum=", "")) + counts[hlt_line] = count + return counts + + +parser = argparse.ArgumentParser() +parser.add_argument("--input-mdf", help="Input MDF file") +args = parser.parse_args() + +# Configure basic application with inputs +LHCbApp(DataType="Upgrade") +IOHelper("MDF").inputFiles([args.input_mdf]) +# Disable warning about not being able to navigate ancestors +IODataManager(DisablePFNWarning=True) +# Disable warning about histogram saving not being required +HistogramPersistencySvc(OutputLevel=5) +# Decode Hlt DecReports +ApplicationMgr( + TopAlg=[DecoderDB["HltDecReportsDecoder/Hlt1DecReportsDecoder"].setup()]) + +# Get expected lines and HltANNSvc configuration from the previous job +from Moore.config import get_allen_hlt1_lines +Hlt1SelectionIDs = get_allen_hlt1_lines() +HltANNSvc().Hlt1SelectionID = Hlt1SelectionIDs + +# Set up counters for recording decisions from MDF +counts_from_mdf = {key: 0 for key in Hlt1SelectionIDs} +counts_from_mdf[MOORE_KEY] = 0 +# Extract counters from log file of the previous job +#counts_from_log = get_counts_from_log(args.input_log) + +gaudi = GaudiPython.AppMgr() +TES = gaudi.evtSvc() +gaudi.run(1) + +error = False +while TES["/Event"]: + decs = TES["/Event/Hlt1/DecReports"] + if not decs: + print("DecReports TES location not found") + error = True + break + + triggered = False + for key in counts_from_mdf.keys(): + if key == MOORE_KEY: + continue + counts_from_mdf[key] += int(decs.decReport(key).decision()) + if decs.decReport(key).decision(): + triggered = True + if triggered: + counts_from_mdf[MOORE_KEY] += 1 + + gaudi.run(1) + +for key in counts_from_mdf.keys(): + line_name = key[:-8] if key.endswith("Decision") else key + # if line_name not in counts_from_log.keys(): + # error = True + # print("Test ERROR: Line {} missing".format(line_name)) + # else: + # if counts_from_mdf[key] != counts_from_log[line_name]: + # error = True + # print("Test ERROR: Counts of {} wrong, log = {}, mdf = {}".format( + # key, counts_from_log[line_name], counts_from_mdf[key])) + # else: + # print("Counts of {}, log = {}, mdf = {}".format( + # key, counts_from_log[line_name], counts_from_mdf[key])) + + print("Counts of (), mdf = ()".format(key, counts_from_mdf[key])) + +if error: + exit("Test failed") # exit with a non-zero code diff --git a/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/mdf_read_decs_allen.qmt b/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/mdf_read_decs_allen.qmt new file mode 100644 index 00000000000..db9365ed34b --- /dev/null +++ b/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/mdf_read_decs_allen.qmt @@ -0,0 +1,32 @@ + + + + + + persistency.allen_mdf_writePASS + +python + + $HLT1CONFROOT/tests/options/test_allen_decreports.py + --input-mdf=test_allen_hlt1_persistence_mdf_write.mdf + +true + + +from Moore.qmtest.exclusions import preprocessor +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=preprocessor(stdout)) + + + diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 6a63dc1f920..2d613740b30 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -389,14 +389,11 @@ def run_allen(options, make_lines): make_lines: function returning a list of `HltLine` objects """ + config = configure_input(options) + options.finalize() setup_allen_non_event_data_service() - - Hlt1SelectionIDs = setup_allen_Hlt1ANN() - - config = configure_input(options) - lines = make_lines() - + # Write DecReports raw banks from RecoConf.hlt1_allen import make_allen_dec_reports allen_dec_reports = make_allen_dec_reports() @@ -405,11 +402,7 @@ def run_allen(options, make_lines): algs = [] locations_to_persist = [] report_banks_to_write = ['HltDecReports'] - #routing_bits_banks_to_write = ['HltRoutingBits'] - #lumi_banks_to_write = ['HltLumiSummary'] reports_raw_event = default_raw_event(report_banks_to_write) - #routing_bits_raw_event = default_raw_event(routing_bits_banks_to_write) - #lumi_raw_event = default_raw_event(lumi_banks_to_write) # TODO we probably shouldn't write in Trigger/RawEvent when # running on reconstructed data. Instead, we should create a @@ -417,40 +410,37 @@ def run_allen(options, make_lines): # happy, or make raw events/banks const and adapt everything. kill_existing = True if kill_existing: - all_banks_to_write = ( - report_banks_to_write - ) # + lumi_banks_to_write + routing_bits_banks_to_write) + all_banks_to_write = (report_banks_to_write) algs.append( bankKiller( RawEventLocations=[reports_raw_event], BankTypes=all_banks_to_write)) - # erw = ExecutionReportsWriter( - # Persist=[line.name for line in lines], - # ANNSvcKey="Hlt1SelectionID", - # ) drw = HltDecReportsWriter( InputHltDecReportsLocation=allen_dec_reports, outputs=dict( - OutputRawEventLocation=force_location(reports_raw_event.location)), + OutputRawEventLocation=force_location(reports_raw_event.location)), ) algs.extend([drw]) + locations_to_persist.append(drw.OutputRawEventLocation) + + Hlt1SelectionIDs = setup_allen_Hlt1ANN() + + locations_to_persist.append(reports_raw_event) + report_writers_node = CompositeNode( 'report_writers', combineLogic=NodeLogic.NONLAZY_OR, children=algs, forceOrder=True) - locations_to_persist.append(drw.OutputRawEventLocation) - # Transform to a list of unique str locations_to_persist = list( set(map(_format_location, locations_to_persist))) + writers = [report_writers_node] writers.extend(output_writers(options, locations_to_persist)) - options.finalize() - top_cf_node = CompositeNode( 'allen', combineLogic=NodeLogic.NONLAZY_OR, -- GitLab From 29888df85ecba94f6c45f9135f0bc3a2e21e947f Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Tue, 19 May 2020 16:42:38 +0000 Subject: [PATCH 156/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/8447442 --- Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py | 1 - .../tests/options/test_allen_decreports.py | 8 ++++---- Hlt/Moore/python/Moore/config.py | 14 +++++++------- Hlt/RecoConf/python/RecoConf/standalone.py | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py index 743b0e6ca7e..db67a9e1c1c 100644 --- a/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py +++ b/Hlt/Hlt1Conf/python/Hlt1Conf/lines/luminosity.py @@ -57,4 +57,3 @@ def luminosity_line(name="Hlt1LuminosityLine", prescale=1): InputSummaries=[velo_summary, pv_summary]) return HltLine(name=name, algs=[lumi, merged_summary], prescale=prescale) - diff --git a/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py index 31e76a83d32..2c2f101ca41 100644 --- a/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py +++ b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py @@ -26,7 +26,7 @@ from Configurables import ( IODataManager, LHCbApp, ) -from DAQSys.Decoders import DecoderDB +from DAQSys.Decoders import DecoderDB from GaudiConf import IOHelper import GaudiPython @@ -70,7 +70,7 @@ HltANNSvc().Hlt1SelectionID = Hlt1SelectionIDs # Set up counters for recording decisions from MDF counts_from_mdf = {key: 0 for key in Hlt1SelectionIDs} -counts_from_mdf[MOORE_KEY] = 0 +counts_from_mdf[MOORE_KEY] = 0 # Extract counters from log file of the previous job #counts_from_log = get_counts_from_log(args.input_log) @@ -95,7 +95,7 @@ while TES["/Event"]: triggered = True if triggered: counts_from_mdf[MOORE_KEY] += 1 - + gaudi.run(1) for key in counts_from_mdf.keys(): @@ -111,7 +111,7 @@ for key in counts_from_mdf.keys(): # else: # print("Counts of {}, log = {}, mdf = {}".format( # key, counts_from_log[line_name], counts_from_mdf[key])) - + print("Counts of (), mdf = ()".format(key, counts_from_mdf[key])) if error: diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 2d613740b30..62e62a5fba7 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -389,11 +389,11 @@ def run_allen(options, make_lines): make_lines: function returning a list of `HltLine` objects """ - config = configure_input(options) - options.finalize() + config = configure_input(options) + options.finalize() setup_allen_non_event_data_service() - + # Write DecReports raw banks from RecoConf.hlt1_allen import make_allen_dec_reports allen_dec_reports = make_allen_dec_reports() @@ -410,7 +410,7 @@ def run_allen(options, make_lines): # happy, or make raw events/banks const and adapt everything. kill_existing = True if kill_existing: - all_banks_to_write = (report_banks_to_write) + all_banks_to_write = (report_banks_to_write) algs.append( bankKiller( RawEventLocations=[reports_raw_event], @@ -419,13 +419,13 @@ def run_allen(options, make_lines): drw = HltDecReportsWriter( InputHltDecReportsLocation=allen_dec_reports, outputs=dict( - OutputRawEventLocation=force_location(reports_raw_event.location)), + OutputRawEventLocation=force_location(reports_raw_event.location)), ) algs.extend([drw]) locations_to_persist.append(drw.OutputRawEventLocation) - Hlt1SelectionIDs = setup_allen_Hlt1ANN() - + Hlt1SelectionIDs = setup_allen_Hlt1ANN() + locations_to_persist.append(reports_raw_event) report_writers_node = CompositeNode( diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 3408a13e4c1..c1222a6090d 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -27,7 +27,7 @@ from PyConf.Algorithms import CaloFutureDigit2MCLinks2Table from PyConf.Algorithms import CaloClusterMCTruth from .mc_checking import get_track_checkers, get_best_tracks_checkers, tracker_dumper, pv_dumper from .hlt1_allen import (make_allen_tracks, make_allen_pvs, - make_allen_dec_reports, make_dumped_raw_banks) + make_allen_dec_reports, make_dumped_raw_banks) from .reco_objects_from_file import reconstruction from .rich_reconstruction import make_rich_pids, make_rich_pixels, default_rich_reco_options from .rich_data_monitoring import (make_rich_pixel_monitors, -- GitLab From e4d66b2dfd2851cdf27d5a1fdbae7e334e6241cf Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 20 May 2020 10:41:37 +0200 Subject: [PATCH 157/171] index lines in DecReports from 1 --- Hlt/Moore/python/Moore/config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 62e62a5fba7..5f4379fb1f2 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -358,7 +358,7 @@ def get_allen_hlt1_lines(): os.path.expandvars( "$ALLEN_INSTALL_DIR/constants/Sequence.json")) as config_file: config = (json.load(config_file)) - index = 0 + index = 1 for line in config["configured_lines"]: line_name = "Hlt1" + str(line) + "Decision" Hlt1SelectionIDs[line_name] = index @@ -376,6 +376,8 @@ def setup_allen_Hlt1ANN(): hlt_ann_svc = setup_component( "HltANNSvc", Hlt1SelectionID=Hlt1SelectionIDs) + print Hlt1SelectionIDs + return Hlt1SelectionIDs @@ -418,6 +420,7 @@ def run_allen(options, make_lines): drw = HltDecReportsWriter( InputHltDecReportsLocation=allen_dec_reports, + OutputLevel=1, outputs=dict( OutputRawEventLocation=force_location(reports_raw_event.location)), ) -- GitLab From e43503020d7f7445e820f03d71eda82cf25044f3 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 20 May 2020 17:19:47 +0200 Subject: [PATCH 158/171] forceOrder in top Allen node --- Hlt/Moore/python/Moore/config.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 5f4379fb1f2..535e5b49558 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -200,7 +200,6 @@ def report_writers_node(lines, ) algs.extend([erw, drw]) locations_to_persist.append(drw.OutputRawEventLocation) - hlt_ann_svc = setup_component( "HltANNSvc", # Zero is an invalid DecReport ID, so start from 1 @@ -363,7 +362,6 @@ def get_allen_hlt1_lines(): line_name = "Hlt1" + str(line) + "Decision" Hlt1SelectionIDs[line_name] = index index += 1 - print Hlt1SelectionIDs return Hlt1SelectionIDs @@ -424,6 +422,7 @@ def run_allen(options, make_lines): outputs=dict( OutputRawEventLocation=force_location(reports_raw_event.location)), ) + algs.extend([drw]) locations_to_persist.append(drw.OutputRawEventLocation) @@ -448,7 +447,7 @@ def run_allen(options, make_lines): 'allen', combineLogic=NodeLogic.NONLAZY_OR, children=[make_allen_dec_reports()] + writers, - forceOrder=False) + forceOrder=True) config.update(configure(options, top_cf_node)) # TODO pass config to gaudi explicitly when that is supported -- GitLab From 1d026e847d3340d248ad0db68969a2c791d51f7e Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 20 May 2020 18:41:21 +0200 Subject: [PATCH 159/171] finish test comparing log file selection counts with DecReports in MDF file --- .../tests/options/test_allen_decreports.py | 56 +++++++++++-------- .../persistency.qms/allen_mdf_write.qmt | 4 +- .../persistency.qms/mdf_read_decs_allen.qmt | 2 + 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py index 2c2f101ca41..9cc57267f0d 100644 --- a/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py +++ b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py @@ -33,23 +33,32 @@ import GaudiPython from PyConf.utilities import read_options # Top-level control flow node -MOORE_KEY = "moore" +ALLEN_KEY = "allen" def get_counts_from_log(f): """Return the decisions of each line as extracted from a log file.""" counts = {} with open(f) as f: - for line in filter(lambda l: "LAZY_AND:" in l, f): + for line in filter(lambda l: "Selected by" in l, f): + columns = line.split() + hlt_line = columns[2].replace('"', '') + count = int(columns[6]) + counts[hlt_line] = count + f.seek(0) + for line in filter(lambda l: "NONLAZY_OR: allen" in l, f): columns = line.split() hlt_line = columns[1] count = int(columns[3].replace("Sum=", "")) - counts[hlt_line] = count + counts[hlt_line] = count return counts parser = argparse.ArgumentParser() parser.add_argument("--input-mdf", help="Input MDF file") +parser.add_argument("--input-log", help="Input log file") +parser.add_argument( + "--input-options", help="Input options file (Python format)") args = parser.parse_args() # Configure basic application with inputs @@ -64,15 +73,16 @@ ApplicationMgr( TopAlg=[DecoderDB["HltDecReportsDecoder/Hlt1DecReportsDecoder"].setup()]) # Get expected lines and HltANNSvc configuration from the previous job -from Moore.config import get_allen_hlt1_lines -Hlt1SelectionIDs = get_allen_hlt1_lines() +options = read_options(args.input_options) +Hlt1SelectionIDs = options["HltANNSvc"]["Hlt1SelectionID"] HltANNSvc().Hlt1SelectionID = Hlt1SelectionIDs +print(Hlt1SelectionIDs) # Set up counters for recording decisions from MDF counts_from_mdf = {key: 0 for key in Hlt1SelectionIDs} -counts_from_mdf[MOORE_KEY] = 0 +counts_from_mdf[ALLEN_KEY] = 0 # Extract counters from log file of the previous job -#counts_from_log = get_counts_from_log(args.input_log) +counts_from_log = get_counts_from_log(args.input_log) gaudi = GaudiPython.AppMgr() TES = gaudi.evtSvc() @@ -88,31 +98,29 @@ while TES["/Event"]: triggered = False for key in counts_from_mdf.keys(): - if key == MOORE_KEY: + if key == ALLEN_KEY: continue counts_from_mdf[key] += int(decs.decReport(key).decision()) if decs.decReport(key).decision(): triggered = True if triggered: - counts_from_mdf[MOORE_KEY] += 1 + counts_from_mdf[ALLEN_KEY] += 1 gaudi.run(1) for key in counts_from_mdf.keys(): - line_name = key[:-8] if key.endswith("Decision") else key - # if line_name not in counts_from_log.keys(): - # error = True - # print("Test ERROR: Line {} missing".format(line_name)) - # else: - # if counts_from_mdf[key] != counts_from_log[line_name]: - # error = True - # print("Test ERROR: Counts of {} wrong, log = {}, mdf = {}".format( - # key, counts_from_log[line_name], counts_from_mdf[key])) - # else: - # print("Counts of {}, log = {}, mdf = {}".format( - # key, counts_from_log[line_name], counts_from_mdf[key])) - - print("Counts of (), mdf = ()".format(key, counts_from_mdf[key])) - + line_name = key + if line_name not in counts_from_log.keys(): + error = True + print("Test ERROR: Line {} missing".format(line_name)) + else: + if counts_from_mdf[key] != counts_from_log[line_name]: + error = True + print("Test ERROR: Counts of {} wrong, log = {}, mdf = {}".format( + key, counts_from_log[line_name], counts_from_mdf[key])) + else: + print("Counts of {}, log = {}, mdf = {}".format( + key, counts_from_log[line_name], counts_from_mdf[key])) + if error: exit("Test failed") # exit with a non-zero code diff --git a/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/allen_mdf_write.qmt b/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/allen_mdf_write.qmt index bdc38125521..734f66e2c58 100644 --- a/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/allen_mdf_write.qmt +++ b/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/allen_mdf_write.qmt @@ -23,7 +23,9 @@ Run Allen HLT1 and save an MDF file. true - +with open('test_hlt1_persistence_allen_mdf_write.stdout', 'w') as f: + f.write(stdout) + diff --git a/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/mdf_read_decs_allen.qmt b/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/mdf_read_decs_allen.qmt index db9365ed34b..d1905fbab4c 100644 --- a/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/mdf_read_decs_allen.qmt +++ b/Hlt/Hlt1Conf/tests/qmtest/persistency.qms/mdf_read_decs_allen.qmt @@ -19,7 +19,9 @@ Check content of Allen DecReports rawbank and check that they agree with logfile python $HLT1CONFROOT/tests/options/test_allen_decreports.py + --input-log=test_hlt1_persistence_allen_mdf_write.stdout --input-mdf=test_allen_hlt1_persistence_mdf_write.mdf + --input-options=allen_mdf_write.opts.py true -- GitLab From 3d2b2016a19ab06cb8e28abea9b98f1690de5a23 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 20 May 2020 20:56:25 +0200 Subject: [PATCH 160/171] no verbose output from HltDecReportsWriter --- Hlt/Moore/python/Moore/config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 535e5b49558..125ab066141 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -418,7 +418,6 @@ def run_allen(options, make_lines): drw = HltDecReportsWriter( InputHltDecReportsLocation=allen_dec_reports, - OutputLevel=1, outputs=dict( OutputRawEventLocation=force_location(reports_raw_event.location)), ) -- GitLab From 1fe1de1f123415cf7370b48df466d66cc6980227 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 20 May 2020 18:57:34 +0000 Subject: [PATCH 161/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/8464922 --- Hlt/Hlt1Conf/tests/options/test_allen_decreports.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py index 9cc57267f0d..431e910d371 100644 --- a/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py +++ b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py @@ -50,7 +50,7 @@ def get_counts_from_log(f): columns = line.split() hlt_line = columns[1] count = int(columns[3].replace("Sum=", "")) - counts[hlt_line] = count + counts[hlt_line] = count return counts @@ -58,7 +58,7 @@ parser = argparse.ArgumentParser() parser.add_argument("--input-mdf", help="Input MDF file") parser.add_argument("--input-log", help="Input log file") parser.add_argument( - "--input-options", help="Input options file (Python format)") + "--input-options", help="Input options file (Python format)") args = parser.parse_args() # Configure basic application with inputs @@ -76,7 +76,7 @@ ApplicationMgr( options = read_options(args.input_options) Hlt1SelectionIDs = options["HltANNSvc"]["Hlt1SelectionID"] HltANNSvc().Hlt1SelectionID = Hlt1SelectionIDs -print(Hlt1SelectionIDs) +print(Hlt1SelectionIDs) # Set up counters for recording decisions from MDF counts_from_mdf = {key: 0 for key in Hlt1SelectionIDs} @@ -120,7 +120,7 @@ for key in counts_from_mdf.keys(): key, counts_from_log[line_name], counts_from_mdf[key])) else: print("Counts of {}, log = {}, mdf = {}".format( - key, counts_from_log[line_name], counts_from_mdf[key])) - + key, counts_from_log[line_name], counts_from_mdf[key])) + if error: exit("Test failed") # exit with a non-zero code -- GitLab From 9ddd32ecd16f85ec6561922b64bab49377d65eca Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 22 May 2020 12:14:55 +0200 Subject: [PATCH 162/171] remove dependency from Rec MR 1925 and Moore MR 388 --- .../options/hlt1_reco_allen_pvchecker.py | 34 -- Hlt/RecoConf/python/RecoConf/mc_checking.py | 33 +- .../scripts/PrimaryVertexCheckerEfficiency.py | 154 ------ .../scripts/PrimaryVertexCheckerPull.py | 294 ------------ .../scripts/PrimaryVertexCheckerResolution.py | 289 ------------ Hlt/RecoConf/scripts/utils/pvconfig.py | 188 -------- Hlt/RecoConf/scripts/utils/pvutils.py | 442 ------------------ 7 files changed, 1 insertion(+), 1433 deletions(-) delete mode 100644 Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py delete mode 100644 Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py delete mode 100644 Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py delete mode 100644 Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py delete mode 100644 Hlt/RecoConf/scripts/utils/pvconfig.py delete mode 100644 Hlt/RecoConf/scripts/utils/pvutils.py diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py deleted file mode 100644 index 69aa6b21276..00000000000 --- a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py +++ /dev/null @@ -1,34 +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. # -############################################################################### -from Moore import options, run_allen_reconstruction -from Moore.config import Reconstruction -from RecoConf.hlt1_tracking import require_gec -from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs -from RecoConf.mc_checking import get_pv_checkers, get_track_checkers - - -def hlt1_reco_pvchecker(): - - allen_tracks = make_allen_tracks() - allen_pvs = make_allen_pvs() - - data = [allen_pvs] - data += get_pv_checkers( - allen_pvs, allen_tracks["Velo"], produce_ntuple=True) - - return Reconstruction('PVperformance', data, [require_gec()]) - - -run_allen_reconstruction(options, hlt1_reco_pvchecker) - -NTupleSvc().Output += [ - "FILE1 DATAFILE='Hlt1_PVperformance.root' TYPE='ROOT' OPT='NEW'" -] diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 3fa54ff5e9f..834a5af0829 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -23,7 +23,7 @@ from PyConf.Algorithms import ( VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, PrTrackAssociator, PrLHCbID2MCParticleVPUTFTMU, PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, - DataPacking__Unpack_LHCb__MCVPHitPacker_, PrimaryVertexChecker, + DataPacking__Unpack_LHCb__MCVPHitPacker_, PrTrackerDumper, PVDumper) from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool @@ -262,37 +262,6 @@ def get_best_tracks_checkers( efficiency_checkers.append(checker) return efficiency_checkers - -@configurable -def get_pv_checkers( - pvs, - tracks, - produce_ntuple=False, - make_links_lhcbids_mcparticles=make_links_lhcbids_mcparticles_tracking_system -): - - assert isinstance( - pvs, DataHandle), "Please provide reconstructed primary verticies" - - links_to_lhcbids = make_links_lhcbids_mcparticles() - links_to_tracks = make_links_tracks_mcparticles( - InputTracks=tracks, LinksToLHCbIDs=links_to_lhcbids) - pv_checkers = [] - - pvchecker = PrimaryVertexChecker( - produceNtuple=produce_ntuple, - inputVerticesName=pvs, - inputTracksName=tracks["v1"], - MCVertexInput=mc_unpackers()["MCVertices"], - MCParticleInput=mc_unpackers()["MCParticles"], - MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), - MCPropertyInput=make_data_with_FetchDataFromFile( - "/Event/MC/TrackInfo")) - - pv_checkers.append(pvchecker) - return pv_checkers - - def make_track_filter(InputTracks, code): selector = LoKiTrackSelector(Code=code, StatPrint=True) filtered_tracks = TrackListRefiner( diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py deleted file mode 100644 index bfc3151734f..00000000000 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py +++ /dev/null @@ -1,154 +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. # -############################################################################### -#!/usr/bin/python - -# The script for plotting PV efficinecy as the function -# of various distributions: nTracks, z, r. -# As input the NTuple created by hlt1_reco_pvchecker.py -# is needed. -# -# The efficency is calculated usig TGraphAsymmErrors -# and Bayesian error bars -# -# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) -# date: 02/2020 -# -# Example of usage: -# ../../../run python PrimaryVertexCheckerEfficiency.py -# --file file1.root file2.root --label name1 name2 --dist -# - -import os, sys -import argparse -import ROOT - -from ROOT import TFile, TTree -from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray -from ROOT import gROOT, TLegend - -parser = argparse.ArgumentParser() -parser.add_argument( - '--file', dest='fileName', default="", nargs='+', help='filename to plot') -parser.add_argument( - '--label', dest='label', default="", nargs='+', help='labels for files') -parser.add_argument( - '--tree', - dest='treeName', - default="", - nargs='+', - help='tree name to plot', -) -parser.add_argument( - '--smog', - dest='smog', - default=False, - action='store_true', - help='set true for SMOG') -parser.add_argument( - '--multi', - dest='multi', - default=False, - action='store_true', - help='add multiplicity plots') -parser.add_argument( - '--dist', - dest='dist', - default=False, - action='store_true', - help='plot distributions in the canvas') -parser.add_argument( - '--prefix', - dest='prefix', - default="pv_eff", - help='prefix for the plot name', -) -parser.add_argument( - '--dir', - dest='directory', - default=os.getcwd(), - help='tree name to plot', -) - -parser.add_argument( - '--offset', - dest='offset', - default=0, - help='offset for plot colors', -) - - -def get_labels(number_of_files): - label = [] - for i in range(0, number_of_files): - label.append("PV Checker {number}".format(number=str(i + 1))) - return label - - -if __name__ == '__main__': - args = parser.parse_args() - path = args.directory + "/utils/" - sys.path.append(os.path.abspath(path)) - offset = int(args.offset) - - gROOT.SetBatch() - - from pvutils import get_default_tree_name - from pvutils import get_files, get_trees, get_eff, plot - - from pvconfig import get_variable_ranges - from pvconfig import get_style, get_categories - from pvconfig import set_legend - - ranges = get_variable_ranges(args.smog) - style = get_style() - - label = args.label - if args.label == "": - label = get_labels(len(args.fileName)) - - tr = {} - tf = {} - tf = get_files(tf, label, args.fileName) - tr = get_trees(tf, tr, label, args.treeName, True) - - eff = {} - eff["tracks"] = {} - eff["z"] = {} - eff["r"] = {} - - hist = {} - hist["tracks"] = {} - hist["z"] = {} - hist["r"] = {} - - cat = get_categories(args.multi, args.smog) - - eff["tracks"], hist["tracks"] = get_eff(eff["tracks"], hist["tracks"], tr, - "nrectrmc", style, ranges, cat, - label, offset) - eff["z"], hist["z"] = get_eff(eff["z"], hist["z"], tr, "zMC", style, - ranges, cat, label, offset) - eff["r"], hist["r"] = get_eff(eff["r"], hist["r"], tr, "rMC", style, - ranges, cat, label, offset) - - if args.dist: - legend = TLegend(0.15, 0.82, 0.88, 0.98) - else: - legend = TLegend(0.15, 0.86, 0.88, 0.98) - legend = set_legend(legend, label, eff["tracks"], "eff", hist["z"], - args.dist) - - plot(eff["tracks"], "eff", args.prefix, "ntracks", cat, label, legend, - hist["tracks"], args.dist) - plot(eff["z"], "eff", args.prefix, "z", cat, label, legend, hist["z"], - args.dist) - plot(eff["r"], "eff", args.prefix, "r", cat, label, legend, hist["r"], - args.dist) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py deleted file mode 100644 index cf30de6cca3..00000000000 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py +++ /dev/null @@ -1,294 +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. # -############################################################################### -#!/usr/bin/python - -# The script for plotting PV efficinecy as the function -# of various distributions: nTracks, z, r. -# As input the NTuple created by hlt1_reco_pvchecker.py -# is needed. -# -# The efficency is calculated usig TGraphAsymmErrors -# and Bayesian error bars -# -# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) -# date: 02/2020 -# -# Example of usage: -# ../../../run python PrimaryVertexCheckerPull.py -# --file file1.root file2.root --label name1 name2 -# - -import os, sys -import argparse -import ROOT - -from ROOT import TFile, TTree -from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow -from ROOT import gROOT, TLegend - -parser = argparse.ArgumentParser() -parser.add_argument( - '--file', dest='fileName', default="", nargs='+', help='filename to plot') -parser.add_argument( - '--label', dest='label', default="", nargs='+', help='labels for files') -parser.add_argument( - '--tree', - dest='treeName', - default="", - nargs='+', - help='tree name to plot', -) -parser.add_argument( - '--smog', - dest='smog', - default=False, - action='store_true', - help='set true for SMOG') -parser.add_argument( - '--multi', - dest='multi', - default=False, - action='store_true', - help='add multiplicity plots') -parser.add_argument( - '--dist', - dest='dist', - default=False, - action='store_true', - help='plot distributions in the canvas') -parser.add_argument( - '--prefix', - dest='prefix', - default="pv_pull", - help='prefix for the plot name', -) -parser.add_argument( - '--dir', - dest='directory', - default=os.getcwd(), - help='tree name to plot', -) - -parser.add_argument( - '--offset', - dest='offset', - default=0, - help='offset for plot colors', -) - - -def get_labels(number_of_files): - label = [] - for i in range(0, number_of_files): - label.append("PV Checker {number}".format(number=str(i + 1))) - return label - - -if __name__ == '__main__': - args = parser.parse_args() - path = args.directory + "/utils/" - sys.path.append(os.path.abspath(path)) - offset = int(args.offset) - gROOT.SetBatch() - - from pvutils import get_default_tree_name - from pvutils import get_files, get_trees - from pvutils import set_legend, get_global, plot_comparison - from pvutils import get_dependence - from pvutils import plot - - from pvconfig import get_variable_ranges - from pvconfig import get_style, get_categories - from pvconfig import get_y_axis - - ranges = get_variable_ranges(args.smog) - style = get_style() - - cat = get_categories(args.multi, args.smog) - label = args.label - if args.label == "": - label = get_labels(len(args.fileName)) - - tr = {} - tf = {} - tf = get_files(tf, label, args.fileName) - tr = get_trees(tf, tr, label, args.treeName, True) - - hist_x = {} - hist_y = {} - hist_z = {} - norm = True #to-do - hist_x = get_global(hist_x, tr, "pullx", "#Delta x / #sigma_{x}", - "Candidates Normalized", style, ranges, cat, label, - offset) - hist_y = get_global(hist_y, tr, "pully", "#Delta y / #sigma_{y}", - "Candidates Normalized", style, ranges, cat, label, - offset) - hist_z = get_global(hist_z, tr, "pullz", "#Delta z / #sigma_{z}", - "Candidates Normalized", style, ranges, cat, label, - offset) - - plot_comparison(hist_x, args.prefix, "pullx", cat, label, style, norm, - offset) - plot_comparison(hist_y, args.prefix, "pully", cat, label, style, norm, - offset) - plot_comparison(hist_z, args.prefix, "pullz", cat, label, style, norm, - offset) - - from ROOT import gEnv - gEnv.SetValue("Hist.Binning.1D.x", "100") - - graph = {} - graph["tracks"] = {} - graph["tracks"]["pullx"] = {} - graph["tracks"]["pully"] = {} - graph["tracks"]["pullz"] = {} - graph["tracks"]["pullx"] = get_dependence(graph["tracks"]["pullx"], tr, - "pullx", "nrectrmc", ranges, - style, cat, label, offset) - graph["tracks"]["pully"] = get_dependence(graph["tracks"]["pully"], tr, - "pully", "nrectrmc", ranges, - style, cat, label, offset) - graph["tracks"]["pullz"] = get_dependence(graph["tracks"]["pullz"], tr, - "pullz", "nrectrmc", ranges, - style, cat, label, offset) - - legend = TLegend(0.15, 0.86, 0.88, 0.98) - legend = set_legend(legend, label, graph["tracks"]["pullz"], "sigma") - - labelpos = (0.75, 0.75, 0.9, 0.87) - plot( - graph["tracks"]["pullx"], - "mean", - args.prefix + "_ntracks_mean", - "pullx", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["tracks"]["pullx"], - "sigma", - args.prefix + "_ntracks_sigma", - "pullx", - cat, - label, - legend, - labelpos=labelpos) - - plot( - graph["tracks"]["pully"], - "mean", - args.prefix + "_ntracks_mean", - "pully", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["tracks"]["pully"], - "sigma", - args.prefix + "_ntracks_sigma", - "pully", - cat, - label, - legend, - labelpos=labelpos) - - plot( - graph["tracks"]["pullz"], - "mean", - args.prefix + "_ntracks_mean", - "pullz", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["tracks"]["pullz"], - "sigma", - args.prefix + "_ntracks_sigma", - "pullz", - cat, - label, - legend, - labelpos=labelpos) - - graph["z"] = {} - graph["z"]["pullx"] = {} - graph["z"]["pully"] = {} - graph["z"]["pullz"] = {} - graph["z"]["pullx"] = get_dependence(graph["z"]["pullx"], tr, "pullx", - "zMC", ranges, style, cat, label, - offset) - graph["z"]["pully"] = get_dependence(graph["z"]["pully"], tr, "pully", - "zMC", ranges, style, cat, label, - offset) - graph["z"]["pullz"] = get_dependence(graph["z"]["pullz"], tr, "pullz", - "zMC", ranges, style, cat, label, - offset) - - plot( - graph["z"]["pullx"], - "mean", - args.prefix + "_z_mean", - "pullx", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["z"]["pullx"], - "sigma", - args.prefix + "_z_sigma", - "pullx", - cat, - label, - legend, - labelpos=labelpos) - - plot( - graph["z"]["pully"], - "mean", - args.prefix + "_z_mean", - "pully", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["z"]["pully"], - "sigma", - args.prefix + "_z_sigma", - "pully", - cat, - label, - legend, - labelpos=labelpos) - - plot( - graph["z"]["pullz"], - "mean", - args.prefix + "_z_mean", - "pullz", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["z"]["pullz"], - "sigma", - args.prefix + "_z_sigma", - "pullz", - cat, - label, - legend, - labelpos=labelpos) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py deleted file mode 100644 index e1bdce35d1c..00000000000 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py +++ /dev/null @@ -1,289 +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. # -############################################################################### -#!/usr/bin/python - -# The script for plotting PV efficinecy as the function -# of various distributions: nTracks, z, r. -# As input the NTuple created by hlt1_reco_pvchecker.py -# is needed. -# -# The efficency is calculated usig TGraphAsymmErrors -# and Bayesian error bars -# -# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) -# date: 02/2020 -# -# Example of usage: -# ../../../run python PrimaryVertexCheckerResolution.py -# --file file1.root file2.root --label name1 name2 -# - -import os, sys -import argparse -import ROOT - -from ROOT import TFile, TTree -from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow -from ROOT import gROOT, TLegend - -parser = argparse.ArgumentParser() -parser.add_argument( - '--file', dest='fileName', default="", nargs='+', help='filename to plot') -parser.add_argument( - '--label', dest='label', default="", nargs='+', help='labels for files') -parser.add_argument( - '--tree', - dest='treeName', - default="", - nargs='+', - help='tree name to plot', -) -parser.add_argument( - '--smog', - dest='smog', - default=False, - action='store_true', - help='set true for SMOG') -parser.add_argument( - '--multi', - dest='multi', - default=False, - action='store_true', - help='add multiplicity plots') -parser.add_argument( - '--dist', - dest='dist', - default=False, - action='store_true', - help='plot distributions in the canvas') -parser.add_argument( - '--prefix', - dest='prefix', - default="pv_resol", - help='prefix for the plot name', -) -parser.add_argument( - '--dir', - dest='directory', - default=os.getcwd(), - help='tree name to plot', -) - -parser.add_argument( - '--offset', - dest='offset', - default=0, - help='offset for plot colors', -) - - -def get_labels(number_of_files): - label = [] - for i in range(0, number_of_files): - label.append("PVChecker{number}".format(number=str(i + 1))) - return label - - -if __name__ == '__main__': - args = parser.parse_args() - path = args.directory + "/utils/" - sys.path.append(os.path.abspath(path)) - offset = int(args.offset) - - gROOT.SetBatch() - - from pvutils import get_default_tree_name - from pvutils import get_files, get_trees - from pvutils import set_legend, get_global, plot_comparison - from pvutils import get_dependence - from pvutils import plot - - from pvconfig import get_variable_ranges - from pvconfig import get_style, get_categories - - ranges = get_variable_ranges(args.smog) - style = get_style() - - cat = get_categories(args.multi, args.smog) - label = args.label - if args.label == "": - label = get_labels(len(args.fileName)) - - tr = {} - tf = {} - tf = get_files(tf, label, args.fileName) - tr = get_trees(tf, tr, label, args.treeName, True) - - hist_x = {} - hist_y = {} - hist_z = {} - norm = True - - hist_x = get_global(hist_x, tr, "dx", "#Delta x [mm]", - "Candidates Normalized", style, ranges, cat, label, - offset) - hist_y = get_global(hist_y, tr, "dy", "#Delta y [mm]", - "Candidates Normalized", style, ranges, cat, label, - offset) - hist_z = get_global(hist_z, tr, "dz", "#Delta z [mm]", - "Candidates Normalized", style, ranges, cat, label, - offset) - - plot_comparison(hist_x, args.prefix, "dx", cat, label, style, norm, offset) - plot_comparison(hist_y, args.prefix, "dy", cat, label, style, norm, offset) - plot_comparison(hist_z, args.prefix, "dz", cat, label, style, norm, offset) - - from ROOT import gEnv - gEnv.SetValue("Hist.Binning.1D.x", "100") - - graph = {} - graph["tracks"] = {} - graph["tracks"]["dx"] = {} - graph["tracks"]["dy"] = {} - graph["tracks"]["dz"] = {} - graph["tracks"]["dx"] = get_dependence(graph["tracks"]["dx"], tr, "dx", - "nrectrmc", ranges, style, cat, - label, offset) - graph["tracks"]["dy"] = get_dependence(graph["tracks"]["dy"], tr, "dy", - "nrectrmc", ranges, style, cat, - label, offset) - graph["tracks"]["dz"] = get_dependence(graph["tracks"]["dz"], tr, "dz", - "nrectrmc", ranges, style, cat, - label, offset) - - legend = TLegend(0.15, 0.86, 0.88, 0.98) - legend = set_legend(legend, label, graph["tracks"]["dz"], "sigma") - - labelpos = (0.73, 0.75, 0.88, 0.87) - plot( - graph["tracks"]["dx"], - "mean", - args.prefix + "_ntracks_mean", - "dx", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["tracks"]["dx"], - "sigma", - args.prefix + "_ntracks_sigma", - "dx", - cat, - label, - legend, - labelpos=labelpos) - - plot( - graph["tracks"]["dy"], - "mean", - args.prefix + "_ntracks_mean", - "dy", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["tracks"]["dy"], - "sigma", - args.prefix + "_ntracks_sigma", - "dy", - cat, - label, - legend, - labelpos=labelpos) - - plot( - graph["tracks"]["dz"], - "mean", - args.prefix + "_ntracks_mean", - "dz", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["tracks"]["dz"], - "sigma", - args.prefix + "_ntracks_sigma", - "dz", - cat, - label, - legend, - labelpos=labelpos) - - graph["z"] = {} - graph["z"]["dx"] = {} - graph["z"]["dy"] = {} - graph["z"]["dz"] = {} - graph["z"]["dx"] = get_dependence(graph["z"]["dx"], tr, "dx", "zMC", - ranges, style, cat, label, offset) - graph["z"]["dy"] = get_dependence(graph["z"]["dy"], tr, "dy", "zMC", - ranges, style, cat, label, offset) - graph["z"]["dz"] = get_dependence(graph["z"]["dz"], tr, "dz", "zMC", - ranges, style, cat, label, offset) - - plot( - graph["z"]["dx"], - "mean", - args.prefix + "_z_mean", - "dx", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["z"]["dx"], - "sigma", - args.prefix + "_z_sigma", - "dx", - cat, - label, - legend, - labelpos=labelpos) - - plot( - graph["z"]["dy"], - "mean", - args.prefix + "_z_mean", - "dy", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["z"]["dy"], - "sigma", - args.prefix + "_z_sigma", - "dy", - cat, - label, - legend, - labelpos=labelpos) - - plot( - graph["z"]["dz"], - "mean", - args.prefix + "_z_mean", - "dz", - cat, - label, - legend, - labelpos=labelpos) - plot( - graph["z"]["dz"], - "sigma", - args.prefix + "_z_sigma", - "dz", - cat, - label, - legend, - labelpos=labelpos) diff --git a/Hlt/RecoConf/scripts/utils/pvconfig.py b/Hlt/RecoConf/scripts/utils/pvconfig.py deleted file mode 100644 index 09bccd2963f..00000000000 --- a/Hlt/RecoConf/scripts/utils/pvconfig.py +++ /dev/null @@ -1,188 +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. # -############################################################################### -#!/usr/bin/python - -from ROOT import TH1F, TLegend -from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow - - -def get_categories(multi, smog): - cut = {} - cut["all"] = {"cut": ""} - # cut["isolated"] = {"cut": "&&isol==1"} - # if not smog: - # cut["close"] = {"cut": "&&isol==0"} - if multi: - cut["1st"] = {"cut": "&&multimc==1"} - cut["2nd"] = {"cut": "&&multimc==2"} - cut["3rd"] = {"cut": "&&multimc==3"} - cut["4th"] = {"cut": "&&multimc==4"} - cut["5th"] = {"cut": "&&multimc==5"} - - return cut - - -def get_style(): - return { - "color": [kRed, kBlue, kOrange, kMagenta, kGreen, kCyan], - "marker": [21, 20, 22, 23, 24, 25] - } - - -def get_default_tree_name(is_checker): - if is_checker: - return "PrimaryVertexChecker/101" - else: - return "VertexCompare/102" - - -def transfer_variable(dep): - dictionary = { - "pullx": "dx/errx", - "pully": "dy/erry", - "pullz": "dz/errz", - "dx": "dx", - "dy": "dy", - "dz": "dz", - } - return dictionary[dep] - - -def get_variable_ranges(smog): - dictionary = { - "zMC": { - "bins": 50, - "min": -200, - "max": 200 - }, - "rMC": { - "bins": 50, - "min": 0.0, - "max": 0.2 - }, - "dx": { - "bins": 50, - "min": -0.10, - "max": 0.10 - }, - "dy": { - "bins": 50, - "min": -0.10, - "max": 0.10 - }, - "dz": { - "bins": 50, - "min": -0.40, - "max": 0.40 - }, - "pullx": { - "bins": 50, - "min": -3.50, - "max": 3.50 - }, - "pully": { - "bins": 50, - "min": -3.50, - "max": 3.50 - }, - "pullz": { - "bins": 50, - "min": -3.50, - "max": 3.50 - }, - "nrectrmc": { - "bins": 66, - "min": 4.0, - "max": 70.0 - } - } - if smog: - dictionary["zMC"] = {"bins": 100, "min": -500, "max": 200} - - return dictionary - - -def get_y_axis(dependence): - dictionary = { - "dx": "Resolution #Delta x [#mu m]", - "dy": "Resolution #Delta y [#mu m]", - "dz": "Resolution #Delta z [#mu m]", - "pullx": "Pull #Delta x/#sigma_{x}", - "pully": "Pull #Delta y/#sigma_{y}", - "pullz": "Pull #Delta z/#sigma_{z}" - } - return dictionary[dependence] - - -def get_x_axis(dependence): - dictionary = { - "zMC": "z [mm]", - "rMC": "radial distance [mm]", - "nrectrmc": "number of tracks in Primary Vertex" - } - return dictionary[dependence] - - -def set_style(graph, color, marker, xaxis, yaxis, title): - graph.SetTitle("") - graph.SetLineColor(color) - graph.SetMarkerColor(color) - graph.SetMarkerSize(1.3) - graph.SetMarkerStyle(marker) - graph.GetYaxis().SetTitleOffset(0.85) - if type(graph) == TH1F: - graph.SetFillColor(color) - graph.SetLineWidth(1) - graph.SetStats(False) - graph.GetYaxis().SetTitleOffset(1.1) - graph.GetYaxis().SetTitleSize(0.06) - graph.GetYaxis().SetLabelSize(0.06) - graph.GetXaxis().SetTitleSize(0.06) - graph.GetXaxis().SetLabelSize(0.06) - graph.GetXaxis().SetTitleFont(132) - graph.GetXaxis().SetLabelFont(132) - graph.GetYaxis().SetTitleFont(132) - graph.GetYaxis().SetLabelFont(132) - - if title != "": - graph.SetTitle(title) - if xaxis != "": - graph.GetXaxis().SetTitle(xaxis) - if yaxis != "": - graph.GetYaxis().SetTitle(yaxis) - - -def set_legend(legend, label, gr, gr_type, hist=None, dist=False): - legend.SetTextSize(0.04) - legend.SetTextFont(12) - legend.SetFillColor(4000) - legend.SetShadowColor(0) - legend.SetBorderSize(0) - legend.SetTextFont(132) - legend.SetNColumns(2) - for lab in label: - legend.AddEntry(gr["all"][lab][gr_type], "{lab}".format(lab=lab), - "lep") - if dist: - legend.AddEntry(hist["all"][label[0]]["den"], "Distribution MC", "f") - for lab in label: - legend.AddEntry(hist["all"][lab]["nom"], - "Distribution {lab}".format(lab=lab), "lep") - - return legend - - -def get_text_cor(): - return {"x": [0.17, 0.65, 0.17, 0.65], "y": [0.92, 0.92, 0.75, 0.75]} - - -def basic_cut(): - return "nrectrmc>=4 && dz < 2.0" diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py deleted file mode 100644 index 16d61773c5a..00000000000 --- a/Hlt/RecoConf/scripts/utils/pvutils.py +++ /dev/null @@ -1,442 +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. # -############################################################################### - -# The utils for processing output of the PrimaryVertexChecker output -# -# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) -# date: 02/2020 -# - -from ROOT import TFile, TTree, TH1F, gDirectory, TGraphAsymmErrors, TPaveText, gStyle -from ROOT import TCanvas -from ROOT import TGraphErrors, TLegend -from ROOT import gPad, kGray, TLatex - -from pvconfig import get_default_tree_name -from pvconfig import transfer_variable -from pvconfig import get_x_axis, get_y_axis -from pvconfig import set_style -from pvconfig import set_legend -from pvconfig import get_text_cor -from pvconfig import basic_cut - -from array import array - - -def get_files(tf, label, files): - i = 0 - for f in files: - tf[label[i]] = TFile(f) - i += 1 - return tf - - -def get_trees(tf, tr, label, trees, is_checker): - i = 0 - for lab in label: - if len(tf) == len(trees): - tr[lab] = tf[lab].Get(trees[i]) - else: - tr[lab] = tf[lab].Get(get_default_tree_name(is_checker)) - i += 1 - return tr - - -def get_eff(eff, hist, trees, dependence, style, ranges, categories, label, - offset): - - for cat in categories: - eff[cat] = {} - hist[cat] = {} - i = offset - for lab in label: - var_den = '{dependence}>>hist{code}_{dep}_{cat}_denom{i}({bins},{mins},{maxs})'.format( - dependence=dependence, - code="den", - dep=dependence, - cat=cat, - lab=lab, - bins=ranges[dependence]["bins"], - mins=ranges[dependence]["min"], - maxs=ranges[dependence]["max"], - i=i) - var_nom = '{dependence}>>hist{code}_{dep}_{cat}_num{i}({bins},{mins},{maxs})'.format( - dependence=dependence, - code="nom", - dep=dependence, - cat=cat, - lab=lab, - bins=ranges[dependence]["bins"], - mins=ranges[dependence]["min"], - maxs=ranges[dependence]["max"], - i=i) - - cut_den = 'nrectrmc>=4 && dz < 2.0 {cuts}'.format( - cuts=categories[cat]["cut"]) - cut_nom = cut_den + ' && reco == 1' - - trees[lab].Draw(var_nom, cut_nom) - trees[lab].Draw(var_den, cut_den) - - h_nom = gDirectory.Get('hist{code}_{dep}_{cat}_num{i}'.format( - code="nom", dep=dependence, cat=cat, lab=lab, i=i)) - h_den = gDirectory.Get('hist{code}_{dep}_{cat}_denom{i}'.format( - code="den", dep=dependence, cat=cat, lab=lab, i=i)) - - g_eff = TGraphAsymmErrors() - g_eff.Divide(h_nom, h_den, "cl=0.683 b(1,1) mode") - - set_style(h_nom, style["color"][i] - 7, style["marker"][i] + 4, - get_x_axis(dependence), "Efficiency", "") - set_style(h_den, kGray, style["marker"][i], get_x_axis(dependence), - "Efficiency", "") - hist[cat][lab] = {} - hist[cat][lab]["nom"] = h_nom - hist[cat][lab]["den"] = h_den - - set_style(g_eff, style["color"][i], style["marker"][i], - get_x_axis(dependence), "Efficiency", "") - eff[cat][lab] = {} - eff[cat][lab]["eff"] = g_eff - i += 1 - - return eff, hist - - -def find_max(gr, gr_type, label): - m = -999999.0 - for lab in label: - if (gr[lab][gr_type].GetYaxis().GetXmax() > m): - m = gr[lab][gr_type].GetYaxis().GetXmax() - - return m - - -def find_min(gr, gr_type, label): - m = 999999.0 - for lab in label: - if (gr[lab][gr_type].GetYaxis().GetXmin() < m): - m = gr[lab][gr_type].GetYaxis().GetXmin() - return m - - -def plot(gr, - gr_type, - prefix, - dependence, - categories, - label, - legend=None, - hist=None, - dist=False, - labelpos=(0.75, 0.78, 0.9, 0.9)): - - for cat in categories: - can = TCanvas( - 'canvas_{depen}_{prefix}_{gr_type}_{cat}'.format( - depen=dependence, prefix=prefix, gr_type=gr_type, cat=cat), - "cR", 1200, 800) - can.SetBottomMargin(0.15) - can.SetLeftMargin(0.12) - can.SetTopMargin(0.15) - if dist: - can.SetTopMargin(0.20) - can.SetRightMargin(0.05) - can.cd() - - maximum = find_max(gr[cat], gr_type, label) - minimum = find_min(gr[cat], gr_type, label) - if (abs(maximum) > abs(minimum) and minimum < 0): - minimum = -maximum - - gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser( - minimum * 1.1, maximum * 1.1) - if (gr_type == "eff"): - gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser(0.0, 1.1) - if (gr_type == "sigma"): - gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser( - 0.0, maximum * 1.1) - gr[cat][label[0]][gr_type].Draw("AP") - - for lab in label: - gr[cat][lab][gr_type].Draw("SAME P") - - if dist: - histmax_den = 1.1 * hist[cat][label[0]]["den"].GetMaximum() - scale = gPad.GetUymax() / histmax_den - hist[cat][label[0]]["den"].Scale(scale * 0.75) - hist[cat][label[0]]["den"].Draw("hist SAME") - - for lab in label: - histmax_nom = 1.1 * hist[cat][lab]["nom"].GetMaximum() - #scale = gPad.GetUymax() / histmax_nom - hist[cat][lab]["nom"].Scale(scale * 0.75) - hist[cat][lab]["nom"].Draw("ep SAME") - - gr[cat][lab][gr_type].Draw("SAME P") - - if legend: - legend.Draw("SAME") - pavetext = TPaveText(labelpos[0], labelpos[1], labelpos[2], - labelpos[3], "NBNDC") - pavetext.AddText("LHCb simulation") - pavetext.SetFillColor(0) - pavetext.SetFillStyle(3000) - pavetext.SetTextSize(0.06) - pavetext.SetTextFont(132) - pavetext.Draw() - - saveName = '{prefix}_{dependence}_{cat}.pdf'.format( - prefix=prefix, dependence=dependence, cat=cat) - can.SaveAs(saveName) - - -def get_global(hist, trees, dependence, x_axis, y_axis, style, ranges, - categories, label, offset): - - dep = transfer_variable(dependence) - - for cat in categories: - hist[cat] = {} - i = offset - for lab in label: - var = '{dependence}>>hist_{dep}_{cat}_{i}({bins},{mins},{maxs})'.format( - dependence=dep, - dep=dependence, - cat=cat, - lab=lab, - bins=ranges[dependence]["bins"], - mins=ranges[dependence]["min"], - maxs=ranges[dependence]["max"], - i=i) - - cut = 'nrectrmc>=4 && dz < 2.0 && reco == 1 {cuts}'.format( - cuts=categories[cat]["cut"]) - - trees[lab].Draw(var, cut) - h = gDirectory.Get('hist_{dep}_{cat}_{i}'.format( - dep=dependence, cat=cat, lab=lab, i=i)) - if i == 0: - col = style["color"][i] - 10 - else: - col = style["color"][i] - set_style(h, col, style["marker"][i], x_axis, y_axis, "") - - hist[cat][lab] = h - i += 1 - - return hist - - -def set_text(text, color, x, y, lab, mean, mean_err, rms, rms_err, scale, - units): - s = 1.0 - if scale: - s = 1000.0 - - ur = "" - um = "#times 10^{-3}" - if units: - ur = "[#mu m]" - um = "[#mu m]" - - text.SetNDC() - text.SetTextFont(132) - text.SetTextColor(color) - text.DrawLatex(x, y * 1.0, lab) - - text.DrawLatex( - x, y * 0.95, "#mu = ({0:0.2f} #pm {1:0.2f}) {unit}".format( - mean * 1000.0, mean_err * 1000.0, unit=um)) - text.DrawLatex( - x, y * 0.90, "#sigma = ({0:0.2f} #pm {1:0.2f}) {unit}".format( - rms * s, rms_err * s, unit=ur)) - return text - - -def plot_comparison(hist, prefix, dependence, categories, label, style, norm, - offset): - - for cat in categories: - can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence, cat=cat), - "cR", 1200, 800) - can.SetBottomMargin(0.15) - can.SetLeftMargin(0.15) - can.SetTopMargin(0.20) - can.SetRightMargin(0.05) - - can.cd() - cor = get_text_cor() - - hist[cat][label[0]].GetYaxis().SetRangeUser( - 0.0, hist[cat][label[0]].GetMaximum() * 1.1) - scale = True - units = True - if "pull" in dependence: - scale = False - units = False - if norm: - hist[cat][label[0]].DrawNormalized("hist") - hist_max = hist[cat][label[0]].GetMaximum() - i = offset - for lab in label: - hist[cat][lab].DrawNormalized("SAME PE") - text = TLatex() - text = set_text(text, style["color"][i], cor["x"][i], - cor["y"][i], lab, hist[cat][lab].GetMean(), - hist[cat][lab].GetMeanError(), - hist[cat][lab].GetRMS(), - hist[cat][lab].GetRMSError(), scale, units) - i += 1 - - else: - hist[cat][label[0]].Draw("hist") - for lab in label: - hist[cat][lab].Draw("SAME PE") - pavetext = TPaveText(0.72, 0.77 - gStyle.GetPadTopMargin(), 0.87, - 0.89 - gStyle.GetPadTopMargin(), "NBNDC") - pavetext.AddText("LHCb simulation") - pavetext.SetFillColor(0) - pavetext.SetTextSize(0.06) - pavetext.SetTextFont(132) - pavetext.Draw() - - can.Update() - saveName = '{prefix}_{dependence}_{cat}.pdf'.format( - prefix=prefix, dependence=dependence, cat=cat) - can.SaveAs(saveName) - - -def get_robust_sigma(hist, resol): - - y = array('d', [0.] * 3) - x = array('d', [0.] * 3) - x[0] = 0.25 - x[1] = 0.50 - x[2] = 0.75 - - hist.GetQuantiles(3, y, x) - - _median = y[1] - _approxstdev = (y[2] - y[0]) / 1.34898 - #factor gives correspondence between IQR and stdev for a Gaussian - mult = 4.0 - - histclone = hist.Clone() - nb = histclone.GetNbinsX() - - for i in range(1, nb + 1): - if ((histclone.GetBinCenter(i) < (_median - _approxstdev * mult)) - or (histclone.GetBinCenter(i) > - (_median + _approxstdev * mult))): - histclone.SetBinContent(i, 0) - - if resol: - robustsigma = { - "sigma": { - "var": histclone.GetRMS() * 1000.0, - "err": histclone.GetRMSError() * 1000.0 - }, - "mean": { - "var": histclone.GetMean() * 1000.0, - "err": histclone.GetMeanError() * 1000.0 - } - } - - else: - robustsigma = { - "sigma": { - "var": histclone.GetRMS() * 1.0, - "err": histclone.GetRMSError() * 1.0 - }, - "mean": { - "var": histclone.GetMean(), - "err": histclone.GetMeanError() - } - } - - return robustsigma - - -def get_dependence(graph, trees, variable, dependence, ranges, style, - categories, label, offset): - - var = transfer_variable(variable) - bin_width = (ranges[dependence]["max"] - - ranges[dependence]["min"]) / ranges[dependence]["bins"] - - resol = True - mean = "Mean [#mu m]" - if "pull" in variable: - resol = False - mean = "Mean" - - for cat in categories: - graph[cat] = {} - i = offset - for lab in label: - graph[cat][lab] = {} - graph_rms = TGraphAsymmErrors(ranges[dependence]["bins"]) - graph_mean = TGraphAsymmErrors(ranges[dependence]["bins"]) - - bin_min = ranges[dependence]["min"] - for b in range(0, ranges[dependence]["bins"]): - - cut_bin = '{variable1}>={mins} && {variable2}<{maxs}'.format( - variable1=dependence, - mins=bin_min, - variable2=dependence, - maxs=bin_min + bin_width) - - hist_string = '{dependence}>>hist_{dep}_{cat}_{i}_{number}'.format( - dependence=var, - dep=variable, - cat=cat, - i=i, - number=int(b), - ) - - cut = '{basic} && reco == 1 && {bin_cut} {cuts}'.format( - basic=basic_cut(), - bin_cut=cut_bin, - cuts=categories[cat]["cut"]) - - a = trees[lab].Draw(hist_string, cut) - - bin_min += bin_width - - h = gDirectory.Get('hist_{dep}_{cat}_{i}_{number}'.format( - dep=variable, cat=cat, i=i, number=int(b))) - - robust_sigma = get_robust_sigma(h, resol) - - graph_mean.SetPoint(b, bin_min + bin_width / 2.0, - robust_sigma["mean"]["var"]) - graph_mean.SetPointError(b, bin_width / 2.0, bin_width / 2.0, - robust_sigma["mean"]["err"], - robust_sigma["mean"]["err"]) - - graph_rms.SetPoint(b, bin_min + bin_width / 2.0, - robust_sigma["sigma"]["var"]) - graph_rms.SetPointError(b, bin_width / 2.0, bin_width / 2.0, - robust_sigma["sigma"]["err"], - robust_sigma["sigma"]["err"]) - - set_style(graph_rms, style["color"][i], style["marker"][i], - get_x_axis(dependence), get_y_axis(variable), "") - set_style(graph_mean, style["color"][i], style["marker"][i], - get_x_axis(dependence), mean, "") - - graph[cat][lab]["sigma"] = graph_rms - graph[cat][lab]["mean"] = graph_mean - i += 1 - - return graph -- GitLab From 71b5ce36a0e6caddd3a7fc6a933b7732bc8a94c6 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Fri, 22 May 2020 10:15:29 +0000 Subject: [PATCH 163/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/8481974 --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 834a5af0829..18ab6d31efa 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -23,8 +23,7 @@ from PyConf.Algorithms import ( VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, PrTrackAssociator, PrLHCbID2MCParticleVPUTFTMU, PrTrackChecker, PrUTHitChecker, TrackListRefiner, TrackResChecker, TrackIPResolutionCheckerNT, - DataPacking__Unpack_LHCb__MCVPHitPacker_, - PrTrackerDumper, PVDumper) + DataPacking__Unpack_LHCb__MCVPHitPacker_, PrTrackerDumper, PVDumper) from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as FromVectorLHCbRecVertex from PyConf.Tools import LoKi__Hybrid__MCTool from PyConf.Tools import LoKi__Hybrid__TrackSelector as LoKiTrackSelector @@ -262,6 +261,7 @@ def get_best_tracks_checkers( efficiency_checkers.append(checker) return efficiency_checkers + def make_track_filter(InputTracks, code): selector = LoKiTrackSelector(Code=code, StatPrint=True) filtered_tracks = TrackListRefiner( -- GitLab From 4ae8d9b9fbe60f36a76fc308f8550b4660ac4ab8 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Sat, 23 May 2020 17:06:15 +0200 Subject: [PATCH 164/171] set default input and conds hlt1 back to default --- Hlt/Moore/tests/options/default_input_and_conds_hlt1.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py index 8c93e39c3e2..2bf391d876c 100644 --- a/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py +++ b/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py @@ -12,8 +12,6 @@ import os from Moore import options options.set_input_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_DIGI') -#options.set_input_from_testfiledb("Upgrade_BsPhiPhi_MD_FTv4_DIGI") - -options.evt_max = 10 +options.evt_max = 1000 execfile(os.path.expandvars('$MOOREROOT/tests/options/default_conds.py')) -- GitLab From 3b1162de7cb42a26e7cc6144a0aaed34dbae0364 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Mon, 25 May 2020 18:20:37 +0200 Subject: [PATCH 165/171] remove histograms that were added for comparison document --- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 35 +++++----------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index bff198c719b..816fc5c8c58 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -70,25 +70,20 @@ def getCuts(): basedict["Velo"] = [ "01_velo", "02_long", "03_long_P>5GeV", "04_long_strange", - "05_long_strange_P>5GeV", "06_long_fromB", "06_long_fromD", - "07_long_fromB_P>5GeV", "11_long_fromB_P>3GeV_Pt>0.5GeV", - "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "05_long_strange_P>5GeV", "06_long_fromB", "07_long_fromB_P>5GeV", + "11_long_fromB_P>3GeV_Pt>0.5GeV", "12_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Upstream"] = [ "01_velo", "02_velo+UT", "03_velo+UT_P>5GeV", "07_long", - "08_long_P>5GeV", "09_long_fromB", "09_long_fromD", - "10_long_fromB_P>5GeV", "14_long_fromB_P>3GeV_Pt>0.5GeV", - "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" + "08_long_P>5GeV", "09_long_fromB", "10_long_fromB_P>5GeV", + "14_long_fromB_P>3GeV_Pt>0.5GeV", "15_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] basedict["Forward"] = [ "01_long", "02_long_P>5GeV", "03_long_strange", - "04_long_strange_P>5GeV", "05_long_fromB", "05_long_fromD", - "06_long_fromB_P>5GeV", "10_long_fromB_P>3GeV_Pt>0.5GeV", - "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" - ] - basedict["MuonMatch"] = [ - "01_long", "02_long_muon", "03_long_muon_from_strange", "04_long_pion" + "04_long_strange_P>5GeV", "05_long_fromB", "06_long_fromB_P>5GeV", + "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] + basedict["MuonMatch"] = ["01_long", "02_long_muon"] return basedict @@ -100,16 +95,6 @@ def categoriesDict(): "title"] = "Long, forward track, 2 <#eta< 5" basedict["MuonMatch"]["02_long_muon"][ "title"] = "Long, #mu, forward track, 2 <#eta< 5" - basedict["MuonMatch"]["02_long_muon_P>3GeV_Pt>0.5GeV"][ - "title"] = "Long, #mu, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" - basedict["MuonMatch"]["03_long_muon_from_strange"][ - "title"] = "Long, #mu from strange, forward track, 2 <#eta< 5" - basedict["MuonMatch"]["03_long_muon_from_strange_P>3GeV_Pt>0.5GeV"][ - "title"] = "Long, #mu from strange, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" - basedict["MuonMatch"]["04_long_pion"][ - "title"] = "Long, #pi, forward track, 2 <#eta< 5" - basedict["MuonMatch"]["04_long_pion_P>3GeV_Pt>0.5GeV"][ - "title"] = "Long, #pi, forward track, p>3GeV, pt>0.5GeV, 2 <#eta< 5" basedict["Velo"]["01_velo"]["title"] = "Velo, 2 <#eta< 5" basedict["Velo"]["02_long"]["title"] = "Long, 2 <#eta< 5" @@ -119,7 +104,6 @@ def categoriesDict(): basedict["Velo"]["05_long_strange_P>5GeV"][ "title"] = "Long, from Strange, p>5GeV, 2 <#eta < 5" basedict["Velo"]["06_long_fromB"]["title"] = "Long from B, 2<#eta<5" - basedict["Velo"]["06_long_fromD"]["title"] = "Long from D, 2<#eta<5" basedict["Velo"]["07_long_fromB_P>5GeV"][ "title"] = "Long from B, p>5GeV, 2<#eta<5" basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -134,7 +118,6 @@ def categoriesDict(): basedict["Velo"]["04_long_strange"]["plotElectrons"] = False basedict["Velo"]["05_long_strange_P>5GeV"]["plotElectrons"] = False basedict["Velo"]["06_long_fromB"]["plotElectrons"] = True - basedict["Velo"]["06_long_fromD"]["plotElectrons"] = False basedict["Velo"]["07_long_fromB_P>5GeV"]["plotElectrons"] = True basedict["Velo"]["11_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False basedict["Velo"]["11_long_strange_P>3GeV_Pt>0.5GeV"][ @@ -157,7 +140,6 @@ def categoriesDict(): basedict["Upstream"]["08_long_P>5GeV"][ "title"] = "Long, p>5GeV, 2 <#eta < 5" basedict["Upstream"]["09_long_fromB"]["title"] = "Long from B, 2 <#eta < 5" - basedict["Upstream"]["09_long_fromD"]["title"] = "Long from D, 2 <#eta < 5" basedict["Upstream"]["10_long_fromB_P>5GeV"][ "title"] = "Long from B, p>5GeV, 2 <#eta < 5" basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -173,7 +155,6 @@ def categoriesDict(): basedict["Upstream"]["07_long"]["plotElectrons"] = True basedict["Upstream"]["08_long_P>5GeV"]["plotElectrons"] = False basedict["Upstream"]["09_long_fromB"]["plotElectrons"] = True - basedict["Upstream"]["09_long_fromD"]["plotElectrons"] = False basedict["Upstream"]["10_long_fromB_P>5GeV"]["plotElectrons"] = True basedict["Upstream"]["14_long_fromB_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False @@ -201,7 +182,6 @@ def categoriesDict(): "title"] = "Long from B, p>5GeV 2 <#eta < 5" basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from B, p>3GeV, pt>0.5GeV, 2 <#eta < 5" - basedict["Forward"]["05_long_fromD"]["title"] = "Long from D, 2 <#eta < 5" basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ "title"] = "Long from strange, p>3GeV, pt>0.5GeV, 2 <#eta < 5" basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ @@ -215,7 +195,6 @@ def categoriesDict(): basedict["Forward"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True basedict["Forward"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False - basedict["Forward"]["05_long_fromD"]["plotElectrons"] = False basedict["Forward"]["10_long_strange_P>3GeV_Pt>0.5GeV"][ "plotElectrons"] = False basedict["Forward"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][ -- GitLab From 71bafd94c35f7ad89fc08bee2551f3d1c4fafba2 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Mon, 8 Jun 2020 18:22:51 +0200 Subject: [PATCH 166/171] plug in comments from MR --- .gitignore | 5 -- CMakeLists.txt | 3 +- Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py | 1 - .../tests/options/test_allen_decreports.py | 2 +- Hlt/Moore/python/Moore/config.py | 51 ++++++++++--------- .../dump_binary_input_for_standalone_Allen.py | 9 +++- Hlt/RecoConf/python/RecoConf/mc_checking.py | 2 +- Hlt/RecoConf/python/RecoConf/standalone.py | 5 +- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index b9f41309ca2..c06d4e5abab 100644 --- a/.gitignore +++ b/.gitignore @@ -58,8 +58,3 @@ i686-winxp-vc9-dbg/ # Sphinx by-products doc/_build doc/graphviz - -# physics performance output files -*.root -*.stdout -*.txt \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index c85c75e26e4..a764b9b3369 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,8 @@ endif() # Declare project name and version gaudi_project(Moore v51r0 - USE Phys v31r0 Allen v0r7 + USE Phys v31r0 + Allen v0r9 DATA AppConfig VERSION v3r* FieldMap VERSION v5r* PRConfig VERSION v1r* diff --git a/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py index 13ab4148750..808c5ff9891 100644 --- a/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py +++ b/Hlt/Hlt1Conf/options/allen_hlt1_pp_default.py @@ -13,5 +13,4 @@ import os, json from Moore import options, run_allen from Hlt1Conf.settings import allen_lines -options.scheduler_legacy_mode = False run_allen(options, allen_lines) diff --git a/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py index 431e910d371..a91ceb0bb69 100644 --- a/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py +++ b/Hlt/Hlt1Conf/tests/options/test_allen_decreports.py @@ -11,7 +11,7 @@ """Compare decisions from a log file to those stored in a MDF. Takes three outputs from a previously-ran job: the options dump, the log -file, and the MDF. The decisions printed by the control flow manager are +file, and the MDF. The decisions printed in the form of counters of the RunAllen algorithm are compared to those taken from the DecReports found in the MDF. Any difference between the two is considered a failure. The options dump is used to configure the HltANNSvc for the job ran by this script. diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 125ab066141..1ba9cb3e970 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -8,9 +8,14 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -import re +import re, os, json, logging, inspect from collections import namedtuple -from Configurables import LumiCounterMerger +from Configurables import (LumiCounterMerger, ApplicationMgr, + DumpUTGeometry, DumpFTGeometry, + DumpMuonTable, DumpMuonGeometry, + DumpVPGeometry, DumpMagneticField, + DumpBeamline, DumpUTLookupTables, + AllenUpdater) from PyConf import configurable from PyConf.Algorithms import (bankKiller, DeterministicPrescaler, ExecutionReportsWriter, HltDecReportsWriter, @@ -29,18 +34,20 @@ from PyConf.application import configure_input, configure from .selreports import make_selreports from .persistency import clone_candidates +from RecoConf.hlt1_allen import make_allen_dec_reports + +log = logging.getLogger(__name__) # FIXME _enabled is a workaround for using ConfigurableUser #: Global ApplicationOptions instance holding the options for Moore options = ApplicationOptions(_enabled=False) - def _format_location(l): """Return the TES location `l` formatted for an output writer. Arguments: l (str or DataHandle) - """ + """ # Accept `l` as a str or a DataHandle if isinstance(l, DataHandle): l = "{}#1".format(l.location) @@ -200,6 +207,7 @@ def report_writers_node(lines, ) algs.extend([erw, drw]) locations_to_persist.append(drw.OutputRawEventLocation) + hlt_ann_svc = setup_component( "HltANNSvc", # Zero is an invalid DecReport ID, so start from 1 @@ -331,11 +339,6 @@ def setup_allen_non_event_data_service(dump_binaries=False): An ExtSvc is added to the ApplicationMgr to provide the Allen non-event data (geometries etc.) """ - from Configurables import ApplicationMgr - from Configurables import DumpUTGeometry, DumpFTGeometry, DumpMuonTable - from Configurables import DumpMuonGeometry, DumpVPGeometry - from Configurables import DumpMagneticField, DumpBeamline, DumpUTLookupTables - from Configurables import AllenUpdater producers = [ p(DumpToFile=dump_binaries) for p in (DumpVPGeometry, DumpUTGeometry, DumpFTGeometry, @@ -351,17 +354,18 @@ def get_allen_hlt1_lines(): """Read Allen HLT1 lines from json configuration file """ - import os, json Hlt1SelectionIDs = {} - with open( - os.path.expandvars( - "$ALLEN_INSTALL_DIR/constants/Sequence.json")) as config_file: - config = (json.load(config_file)) - index = 1 - for line in config["configured_lines"]: - line_name = "Hlt1" + str(line) + "Decision" - Hlt1SelectionIDs[line_name] = index - index += 1 + config_file_path = "$ALLEN_INSTALL_DIR/constants/Sequence.json" + try: + with open(os.path.expandvars(config_file_path)) as config_file: + config = (json.load(config_file)) + except: + log.fatal("Could not find Allen sequence file %s; make sure you have built Allen", config_file_path) + index = 1 + for line in config["configured_lines"]: + line_name = "Hlt1" + str(line) + "Decision" + Hlt1SelectionIDs[line_name] = index + index += 1 return Hlt1SelectionIDs @@ -374,8 +378,6 @@ def setup_allen_Hlt1ANN(): hlt_ann_svc = setup_component( "HltANNSvc", Hlt1SelectionID=Hlt1SelectionIDs) - print Hlt1SelectionIDs - return Hlt1SelectionIDs @@ -395,7 +397,7 @@ def run_allen(options, make_lines): setup_allen_non_event_data_service() # Write DecReports raw banks - from RecoConf.hlt1_allen import make_allen_dec_reports + allen_dec_reports = make_allen_dec_reports() # We will write the reports to raw banks at these locations @@ -455,7 +457,7 @@ def run_allen(options, make_lines): def run_allen_reconstruction(options, make_reconstruction, - dumpBinaries=False, + dump_binaries=False, public_tools=[]): """Configure the Allen reconstruction data flow @@ -468,7 +470,7 @@ def run_allen_reconstruction(options, """ - setup_allen_non_event_data_service(dump_binaries=dumpBinaries) + setup_allen_non_event_data_service(dump_binaries=dump_binaries) return run_reconstruction( options, make_reconstruction, public_tools=public_tools) @@ -511,7 +513,6 @@ def _get_arg_default(function, name): Raises TypeError if ``function`` has no default keyword argument called ``name``. """ - import inspect spec = inspect.getargspec(function) try: i = spec.args.index(name) # ValueError if not found diff --git a/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py index 7182200855a..12f448a5299 100644 --- a/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py +++ b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py @@ -15,9 +15,16 @@ from RecoConf.mc_checking import tracker_dumper, pv_dumper outputDir = "dump/" - + def dump_allen_binary_input(): + """Dump input required for Allen standalone running into binary files + The following input is dumped: + - Raw bank content of the Velo, UT, SciFi, Muon, ODIN banks + - MC info from the TrackerDumper required for the Allen standalone checker + - Non-event data such as geometry information + """ + data = [] data.append( make_dumped_raw_banks( diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 500044128f5..ea36dbeb4f0 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -112,7 +112,7 @@ def monitor_tracking_efficiency( LinksToLHCbIDs, MCCategories, HitTypesToCheck, - WriteHistos=2, + WriteHistos=1, ): """ Setup tracking efficiency checker diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index c1222a6090d..14be61152ea 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -25,9 +25,7 @@ from .calorimeter_mc_checking import ( monitor_calo_photon_resolution, monitor_calo_pi0_resolution) from PyConf.Algorithms import CaloFutureDigit2MCLinks2Table from PyConf.Algorithms import CaloClusterMCTruth -from .mc_checking import get_track_checkers, get_best_tracks_checkers, tracker_dumper, pv_dumper -from .hlt1_allen import (make_allen_tracks, make_allen_pvs, - make_allen_dec_reports, make_dumped_raw_banks) +from .mc_checking import get_track_checkers, get_best_tracks_checkers from .reco_objects_from_file import reconstruction from .rich_reconstruction import make_rich_pids, make_rich_pixels, default_rich_reco_options from .rich_data_monitoring import (make_rich_pixel_monitors, @@ -36,7 +34,6 @@ from .rich_data_monitoring import (make_rich_pixel_monitors, from .rich_mc_checking import make_rich_checkers, default_rich_checking_options from .calo_data_monitoring import monitor_calo_clusters from PyConf.Algorithms import Rich__Future__Rec__TrackFilter as TrackFilter -from PyConf.Algorithms import HltDecReportsDecoder from GaudiKernel.SystemOfUnits import MeV, mm from Moore.config import Reconstruction -- GitLab From a2275a74211f669ee6c74b855d43cd6407ae4db3 Mon Sep 17 00:00:00 2001 From: Dorothea Vom Bruch Date: Mon, 8 Jun 2020 16:27:06 +0000 Subject: [PATCH 167/171] Apply suggestion to Hlt/RecoConf/python/RecoConf/mc_checking.py --- Hlt/RecoConf/python/RecoConf/mc_checking.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index ea36dbeb4f0..25a09f00002 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -16,9 +16,11 @@ from PyConf.tonic import (configurable) from PyConf.dataflow import DataHandle from PyConf.components import Tool -from PyConf.application import default_raw_event, make_odin -from PyConf.application import make_data_with_FetchDataFromFile -from PyConf.application import default_raw_event, make_data_with_FetchDataFromFile +from PyConf.application import ( + default_raw_event, + make_data_with_FetchDataFromFile, + make_odin, +) from PyConf.Algorithms import ( VPFullCluster2MCParticleLinker, PrLHCbID2MCParticle, -- GitLab From ecad7405fb0311a1941d6d1e934cb8395cec0a62 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Mon, 8 Jun 2020 16:27:50 +0000 Subject: [PATCH 168/171] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/8711440 --- Hlt/Moore/python/Moore/config.py | 21 ++++++++++--------- .../dump_binary_input_for_standalone_Allen.py | 6 +++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 1ba9cb3e970..531f5496d61 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -10,12 +10,10 @@ ############################################################################### import re, os, json, logging, inspect from collections import namedtuple -from Configurables import (LumiCounterMerger, ApplicationMgr, - DumpUTGeometry, DumpFTGeometry, - DumpMuonTable, DumpMuonGeometry, - DumpVPGeometry, DumpMagneticField, - DumpBeamline, DumpUTLookupTables, - AllenUpdater) +from Configurables import (LumiCounterMerger, ApplicationMgr, DumpUTGeometry, + DumpFTGeometry, DumpMuonTable, DumpMuonGeometry, + DumpVPGeometry, DumpMagneticField, DumpBeamline, + DumpUTLookupTables, AllenUpdater) from PyConf import configurable from PyConf.Algorithms import (bankKiller, DeterministicPrescaler, ExecutionReportsWriter, HltDecReportsWriter, @@ -34,7 +32,7 @@ from PyConf.application import configure_input, configure from .selreports import make_selreports from .persistency import clone_candidates -from RecoConf.hlt1_allen import make_allen_dec_reports +from RecoConf.hlt1_allen import make_allen_dec_reports log = logging.getLogger(__name__) @@ -42,12 +40,13 @@ log = logging.getLogger(__name__) #: Global ApplicationOptions instance holding the options for Moore options = ApplicationOptions(_enabled=False) + def _format_location(l): """Return the TES location `l` formatted for an output writer. Arguments: l (str or DataHandle) - """ + """ # Accept `l` as a str or a DataHandle if isinstance(l, DataHandle): l = "{}#1".format(l.location) @@ -357,10 +356,12 @@ def get_allen_hlt1_lines(): Hlt1SelectionIDs = {} config_file_path = "$ALLEN_INSTALL_DIR/constants/Sequence.json" try: - with open(os.path.expandvars(config_file_path)) as config_file: + with open(os.path.expandvars(config_file_path)) as config_file: config = (json.load(config_file)) except: - log.fatal("Could not find Allen sequence file %s; make sure you have built Allen", config_file_path) + log.fatal( + "Could not find Allen sequence file %s; make sure you have built Allen", + config_file_path) index = 1 for line in config["configured_lines"]: line_name = "Hlt1" + str(line) + "Decision" diff --git a/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py index 12f448a5299..5b35101f15b 100644 --- a/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py +++ b/Hlt/RecoConf/options/dump_binary_input_for_standalone_Allen.py @@ -15,7 +15,7 @@ from RecoConf.mc_checking import tracker_dumper, pv_dumper outputDir = "dump/" - + def dump_allen_binary_input(): """Dump input required for Allen standalone running into binary files @@ -23,8 +23,8 @@ def dump_allen_binary_input(): - Raw bank content of the Velo, UT, SciFi, Muon, ODIN banks - MC info from the TrackerDumper required for the Allen standalone checker - Non-event data such as geometry information - """ - + """ + data = [] data.append( make_dumped_raw_banks( -- GitLab From b955c714b6f8d75e6bdeb86b2644026e6f853e88 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 25 Jun 2020 12:17:40 +0200 Subject: [PATCH 169/171] add LHCb simulation label to momentum resolution plot --- Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py | 2 +- Hlt/RecoConf/scripts/PrCheckerTrackResolution.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index fe7505bb961..08549dbff3b 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -35,7 +35,7 @@ gROOT.SetBatch(True) def getEfficiencyHistoNames(): - return ["eta", "p", "pt", "phi", "nPV", "docaz"] + return ["eta", "p", "pt", "phi", "nPV"] #, "docaz"] def getTrackers(): diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index d2801945169..eee008dbef6 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -80,6 +80,10 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): from Legend import place_legend setLHCbStyle() + latex = TLatex() + latex.SetNDC() + latex.SetTextSize(0.05) + markers = get_markers() colors = get_colors() styles = get_fillstyles() @@ -132,10 +136,12 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): "+-" + format(hres_p[lab].GetBinError(i), '.2f') + ")%") print("-----------------------------------------------------") + canvas1.PlaceLegend() for lab in label: hres_p[lab].Draw("E1 p1 same") canvas1.SetRightMargin(0.05) + latex.DrawLatex(0.7, 0.85, "LHCb simulation") canvas1.Write() if savepdf: canvas1.SaveAs("trackres_p.pdf") @@ -181,11 +187,12 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): format(hres_eta[lab].GetBinContent(i), '.2f') + "+-" + format(hres_eta[lab].GetBinError(i), '.2f') + ")%") print("-----------------------------------------------------") - + canvas2.PlaceLegend() for lab in label: hres_eta[lab].Draw("E1 p1 same") canvas2.SetRightMargin(0.05) + latex.DrawLatex(0.7, 0.85, "LHCb simulation") canvas2.Write() if savepdf: canvas2.SaveAs("trackres_eta.pdf") -- GitLab From 533a70a19595c9428f1194265d75920eddac0e81 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Mon, 29 Jun 2020 12:03:28 +0200 Subject: [PATCH 170/171] add scripts for PV plots --- .../options/hlt1_reco_allen_pvchecker.py | 37 ++ Hlt/RecoConf/python/RecoConf/mc_checking.py | 30 +- .../scripts/PrimaryVertexCheckerEfficiency.py | 154 ++++++ .../scripts/PrimaryVertexCheckerPull.py | 294 ++++++++++++ .../scripts/PrimaryVertexCheckerResolution.py | 289 ++++++++++++ Hlt/RecoConf/scripts/utils/pvconfig.py | 188 ++++++++ Hlt/RecoConf/scripts/utils/pvutils.py | 442 ++++++++++++++++++ 7 files changed, 1433 insertions(+), 1 deletion(-) create mode 100644 Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py create mode 100644 Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py create mode 100644 Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py create mode 100644 Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py create mode 100644 Hlt/RecoConf/scripts/utils/pvconfig.py create mode 100644 Hlt/RecoConf/scripts/utils/pvutils.py diff --git a/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py new file mode 100644 index 00000000000..a5fd51f1955 --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_reco_allen_pvchecker.py @@ -0,0 +1,37 @@ +############################################################################### +# (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 Moore import options, run_allen_reconstruction +from Moore.config import Reconstruction +from RecoConf.hlt1_tracking import require_gec +from RecoConf.mc_checking import get_pv_checkers, get_track_checkers +from Configurables import ApplicationMgr +from Configurables import NTupleSvc +from RecoConf.hlt1_allen import make_allen_tracks, make_allen_pvs + + +def hlt1_reco_pvchecker(): + + allen_tracks = make_allen_tracks() + pvs = make_allen_pvs() + + data = [pvs] + data += get_pv_checkers(pvs, allen_tracks["Velo"], produce_ntuple=True) + + return Reconstruction('PVperformance', data, [require_gec()]) + + +run_allen_reconstruction(options, hlt1_reco_pvchecker) + +NTupleSvc().Output += [ + "FILE1 DATAFILE='Hlt1_PVperformance_Allen.root' TYPE='ROOT' OPT='NEW'" +] +ApplicationMgr().ExtSvc += [NTupleSvc()] +ApplicationMgr().HistogramPersistency = "ROOT" diff --git a/Hlt/RecoConf/python/RecoConf/mc_checking.py b/Hlt/RecoConf/python/RecoConf/mc_checking.py index 25a09f00002..3633424d8be 100644 --- a/Hlt/RecoConf/python/RecoConf/mc_checking.py +++ b/Hlt/RecoConf/python/RecoConf/mc_checking.py @@ -29,7 +29,7 @@ from PyConf.Algorithms import ( TrackIPResolutionCheckerNT, DataPacking__Unpack_LHCb__MCVPHitPacker_, MCParticle2MCHitAlg, PrTrackerDumper, PVDumper, LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as - FromVectorLHCbRecVertex) + FromVectorLHCbRecVertex, PrimaryVertexChecker) from PyConf.Tools import (IdealStateCreator, LoKi__Hybrid__MCTool, VisPrimVertTool, LoKi__Hybrid__TrackSelector as @@ -267,6 +267,34 @@ def get_best_tracks_checkers( efficiency_checkers.append(checker) return efficiency_checkers +@configurable +def get_pv_checkers( + pvs, + tracks, + produce_ntuple=False, + make_links_lhcbids_mcparticles=make_links_lhcbids_mcparticles_tracking_system +): + + assert isinstance( + pvs, DataHandle), "Please provide reconstructed primary verticies" + + links_to_lhcbids = make_links_lhcbids_mcparticles() + links_to_tracks = make_links_tracks_mcparticles( + InputTracks=tracks, LinksToLHCbIDs=links_to_lhcbids) + pv_checkers = [] + + pvchecker = PrimaryVertexChecker( + produceNtuple=produce_ntuple, + inputVerticesName=pvs, + inputTracksName=tracks["v1"], + MCVertexInput=mc_unpackers()["MCVertices"], + MCParticleInput=mc_unpackers()["MCParticles"], + MCHeaderLocation=make_data_with_FetchDataFromFile("/Event/MC/Header"), + MCPropertyInput=make_data_with_FetchDataFromFile( + "/Event/MC/TrackInfo")) + + pv_checkers.append(pvchecker) + return pv_checkers def make_track_filter(InputTracks, code): selector = LoKiTrackSelector(Code=code, StatPrint=True) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py new file mode 100644 index 00000000000..bfc3151734f --- /dev/null +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py @@ -0,0 +1,154 @@ +############################################################################### +# (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. # +############################################################################### +#!/usr/bin/python + +# The script for plotting PV efficinecy as the function +# of various distributions: nTracks, z, r. +# As input the NTuple created by hlt1_reco_pvchecker.py +# is needed. +# +# The efficency is calculated usig TGraphAsymmErrors +# and Bayesian error bars +# +# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) +# date: 02/2020 +# +# Example of usage: +# ../../../run python PrimaryVertexCheckerEfficiency.py +# --file file1.root file2.root --label name1 name2 --dist +# + +import os, sys +import argparse +import ROOT + +from ROOT import TFile, TTree +from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray +from ROOT import gROOT, TLegend + +parser = argparse.ArgumentParser() +parser.add_argument( + '--file', dest='fileName', default="", nargs='+', help='filename to plot') +parser.add_argument( + '--label', dest='label', default="", nargs='+', help='labels for files') +parser.add_argument( + '--tree', + dest='treeName', + default="", + nargs='+', + help='tree name to plot', +) +parser.add_argument( + '--smog', + dest='smog', + default=False, + action='store_true', + help='set true for SMOG') +parser.add_argument( + '--multi', + dest='multi', + default=False, + action='store_true', + help='add multiplicity plots') +parser.add_argument( + '--dist', + dest='dist', + default=False, + action='store_true', + help='plot distributions in the canvas') +parser.add_argument( + '--prefix', + dest='prefix', + default="pv_eff", + help='prefix for the plot name', +) +parser.add_argument( + '--dir', + dest='directory', + default=os.getcwd(), + help='tree name to plot', +) + +parser.add_argument( + '--offset', + dest='offset', + default=0, + help='offset for plot colors', +) + + +def get_labels(number_of_files): + label = [] + for i in range(0, number_of_files): + label.append("PV Checker {number}".format(number=str(i + 1))) + return label + + +if __name__ == '__main__': + args = parser.parse_args() + path = args.directory + "/utils/" + sys.path.append(os.path.abspath(path)) + offset = int(args.offset) + + gROOT.SetBatch() + + from pvutils import get_default_tree_name + from pvutils import get_files, get_trees, get_eff, plot + + from pvconfig import get_variable_ranges + from pvconfig import get_style, get_categories + from pvconfig import set_legend + + ranges = get_variable_ranges(args.smog) + style = get_style() + + label = args.label + if args.label == "": + label = get_labels(len(args.fileName)) + + tr = {} + tf = {} + tf = get_files(tf, label, args.fileName) + tr = get_trees(tf, tr, label, args.treeName, True) + + eff = {} + eff["tracks"] = {} + eff["z"] = {} + eff["r"] = {} + + hist = {} + hist["tracks"] = {} + hist["z"] = {} + hist["r"] = {} + + cat = get_categories(args.multi, args.smog) + + eff["tracks"], hist["tracks"] = get_eff(eff["tracks"], hist["tracks"], tr, + "nrectrmc", style, ranges, cat, + label, offset) + eff["z"], hist["z"] = get_eff(eff["z"], hist["z"], tr, "zMC", style, + ranges, cat, label, offset) + eff["r"], hist["r"] = get_eff(eff["r"], hist["r"], tr, "rMC", style, + ranges, cat, label, offset) + + if args.dist: + legend = TLegend(0.15, 0.82, 0.88, 0.98) + else: + legend = TLegend(0.15, 0.86, 0.88, 0.98) + legend = set_legend(legend, label, eff["tracks"], "eff", hist["z"], + args.dist) + + plot(eff["tracks"], "eff", args.prefix, "ntracks", cat, label, legend, + hist["tracks"], args.dist) + plot(eff["z"], "eff", args.prefix, "z", cat, label, legend, hist["z"], + args.dist) + plot(eff["r"], "eff", args.prefix, "r", cat, label, legend, hist["r"], + args.dist) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py new file mode 100644 index 00000000000..cf30de6cca3 --- /dev/null +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py @@ -0,0 +1,294 @@ +############################################################################### +# (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. # +############################################################################### +#!/usr/bin/python + +# The script for plotting PV efficinecy as the function +# of various distributions: nTracks, z, r. +# As input the NTuple created by hlt1_reco_pvchecker.py +# is needed. +# +# The efficency is calculated usig TGraphAsymmErrors +# and Bayesian error bars +# +# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) +# date: 02/2020 +# +# Example of usage: +# ../../../run python PrimaryVertexCheckerPull.py +# --file file1.root file2.root --label name1 name2 +# + +import os, sys +import argparse +import ROOT + +from ROOT import TFile, TTree +from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow +from ROOT import gROOT, TLegend + +parser = argparse.ArgumentParser() +parser.add_argument( + '--file', dest='fileName', default="", nargs='+', help='filename to plot') +parser.add_argument( + '--label', dest='label', default="", nargs='+', help='labels for files') +parser.add_argument( + '--tree', + dest='treeName', + default="", + nargs='+', + help='tree name to plot', +) +parser.add_argument( + '--smog', + dest='smog', + default=False, + action='store_true', + help='set true for SMOG') +parser.add_argument( + '--multi', + dest='multi', + default=False, + action='store_true', + help='add multiplicity plots') +parser.add_argument( + '--dist', + dest='dist', + default=False, + action='store_true', + help='plot distributions in the canvas') +parser.add_argument( + '--prefix', + dest='prefix', + default="pv_pull", + help='prefix for the plot name', +) +parser.add_argument( + '--dir', + dest='directory', + default=os.getcwd(), + help='tree name to plot', +) + +parser.add_argument( + '--offset', + dest='offset', + default=0, + help='offset for plot colors', +) + + +def get_labels(number_of_files): + label = [] + for i in range(0, number_of_files): + label.append("PV Checker {number}".format(number=str(i + 1))) + return label + + +if __name__ == '__main__': + args = parser.parse_args() + path = args.directory + "/utils/" + sys.path.append(os.path.abspath(path)) + offset = int(args.offset) + gROOT.SetBatch() + + from pvutils import get_default_tree_name + from pvutils import get_files, get_trees + from pvutils import set_legend, get_global, plot_comparison + from pvutils import get_dependence + from pvutils import plot + + from pvconfig import get_variable_ranges + from pvconfig import get_style, get_categories + from pvconfig import get_y_axis + + ranges = get_variable_ranges(args.smog) + style = get_style() + + cat = get_categories(args.multi, args.smog) + label = args.label + if args.label == "": + label = get_labels(len(args.fileName)) + + tr = {} + tf = {} + tf = get_files(tf, label, args.fileName) + tr = get_trees(tf, tr, label, args.treeName, True) + + hist_x = {} + hist_y = {} + hist_z = {} + norm = True #to-do + hist_x = get_global(hist_x, tr, "pullx", "#Delta x / #sigma_{x}", + "Candidates Normalized", style, ranges, cat, label, + offset) + hist_y = get_global(hist_y, tr, "pully", "#Delta y / #sigma_{y}", + "Candidates Normalized", style, ranges, cat, label, + offset) + hist_z = get_global(hist_z, tr, "pullz", "#Delta z / #sigma_{z}", + "Candidates Normalized", style, ranges, cat, label, + offset) + + plot_comparison(hist_x, args.prefix, "pullx", cat, label, style, norm, + offset) + plot_comparison(hist_y, args.prefix, "pully", cat, label, style, norm, + offset) + plot_comparison(hist_z, args.prefix, "pullz", cat, label, style, norm, + offset) + + from ROOT import gEnv + gEnv.SetValue("Hist.Binning.1D.x", "100") + + graph = {} + graph["tracks"] = {} + graph["tracks"]["pullx"] = {} + graph["tracks"]["pully"] = {} + graph["tracks"]["pullz"] = {} + graph["tracks"]["pullx"] = get_dependence(graph["tracks"]["pullx"], tr, + "pullx", "nrectrmc", ranges, + style, cat, label, offset) + graph["tracks"]["pully"] = get_dependence(graph["tracks"]["pully"], tr, + "pully", "nrectrmc", ranges, + style, cat, label, offset) + graph["tracks"]["pullz"] = get_dependence(graph["tracks"]["pullz"], tr, + "pullz", "nrectrmc", ranges, + style, cat, label, offset) + + legend = TLegend(0.15, 0.86, 0.88, 0.98) + legend = set_legend(legend, label, graph["tracks"]["pullz"], "sigma") + + labelpos = (0.75, 0.75, 0.9, 0.87) + plot( + graph["tracks"]["pullx"], + "mean", + args.prefix + "_ntracks_mean", + "pullx", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["pullx"], + "sigma", + args.prefix + "_ntracks_sigma", + "pullx", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["tracks"]["pully"], + "mean", + args.prefix + "_ntracks_mean", + "pully", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["pully"], + "sigma", + args.prefix + "_ntracks_sigma", + "pully", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["tracks"]["pullz"], + "mean", + args.prefix + "_ntracks_mean", + "pullz", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["pullz"], + "sigma", + args.prefix + "_ntracks_sigma", + "pullz", + cat, + label, + legend, + labelpos=labelpos) + + graph["z"] = {} + graph["z"]["pullx"] = {} + graph["z"]["pully"] = {} + graph["z"]["pullz"] = {} + graph["z"]["pullx"] = get_dependence(graph["z"]["pullx"], tr, "pullx", + "zMC", ranges, style, cat, label, + offset) + graph["z"]["pully"] = get_dependence(graph["z"]["pully"], tr, "pully", + "zMC", ranges, style, cat, label, + offset) + graph["z"]["pullz"] = get_dependence(graph["z"]["pullz"], tr, "pullz", + "zMC", ranges, style, cat, label, + offset) + + plot( + graph["z"]["pullx"], + "mean", + args.prefix + "_z_mean", + "pullx", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["pullx"], + "sigma", + args.prefix + "_z_sigma", + "pullx", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["z"]["pully"], + "mean", + args.prefix + "_z_mean", + "pully", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["pully"], + "sigma", + args.prefix + "_z_sigma", + "pully", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["z"]["pullz"], + "mean", + args.prefix + "_z_mean", + "pullz", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["pullz"], + "sigma", + args.prefix + "_z_sigma", + "pullz", + cat, + label, + legend, + labelpos=labelpos) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py new file mode 100644 index 00000000000..e1bdce35d1c --- /dev/null +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py @@ -0,0 +1,289 @@ +############################################################################### +# (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. # +############################################################################### +#!/usr/bin/python + +# The script for plotting PV efficinecy as the function +# of various distributions: nTracks, z, r. +# As input the NTuple created by hlt1_reco_pvchecker.py +# is needed. +# +# The efficency is calculated usig TGraphAsymmErrors +# and Bayesian error bars +# +# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) +# date: 02/2020 +# +# Example of usage: +# ../../../run python PrimaryVertexCheckerResolution.py +# --file file1.root file2.root --label name1 name2 +# + +import os, sys +import argparse +import ROOT + +from ROOT import TFile, TTree +from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow +from ROOT import gROOT, TLegend + +parser = argparse.ArgumentParser() +parser.add_argument( + '--file', dest='fileName', default="", nargs='+', help='filename to plot') +parser.add_argument( + '--label', dest='label', default="", nargs='+', help='labels for files') +parser.add_argument( + '--tree', + dest='treeName', + default="", + nargs='+', + help='tree name to plot', +) +parser.add_argument( + '--smog', + dest='smog', + default=False, + action='store_true', + help='set true for SMOG') +parser.add_argument( + '--multi', + dest='multi', + default=False, + action='store_true', + help='add multiplicity plots') +parser.add_argument( + '--dist', + dest='dist', + default=False, + action='store_true', + help='plot distributions in the canvas') +parser.add_argument( + '--prefix', + dest='prefix', + default="pv_resol", + help='prefix for the plot name', +) +parser.add_argument( + '--dir', + dest='directory', + default=os.getcwd(), + help='tree name to plot', +) + +parser.add_argument( + '--offset', + dest='offset', + default=0, + help='offset for plot colors', +) + + +def get_labels(number_of_files): + label = [] + for i in range(0, number_of_files): + label.append("PVChecker{number}".format(number=str(i + 1))) + return label + + +if __name__ == '__main__': + args = parser.parse_args() + path = args.directory + "/utils/" + sys.path.append(os.path.abspath(path)) + offset = int(args.offset) + + gROOT.SetBatch() + + from pvutils import get_default_tree_name + from pvutils import get_files, get_trees + from pvutils import set_legend, get_global, plot_comparison + from pvutils import get_dependence + from pvutils import plot + + from pvconfig import get_variable_ranges + from pvconfig import get_style, get_categories + + ranges = get_variable_ranges(args.smog) + style = get_style() + + cat = get_categories(args.multi, args.smog) + label = args.label + if args.label == "": + label = get_labels(len(args.fileName)) + + tr = {} + tf = {} + tf = get_files(tf, label, args.fileName) + tr = get_trees(tf, tr, label, args.treeName, True) + + hist_x = {} + hist_y = {} + hist_z = {} + norm = True + + hist_x = get_global(hist_x, tr, "dx", "#Delta x [mm]", + "Candidates Normalized", style, ranges, cat, label, + offset) + hist_y = get_global(hist_y, tr, "dy", "#Delta y [mm]", + "Candidates Normalized", style, ranges, cat, label, + offset) + hist_z = get_global(hist_z, tr, "dz", "#Delta z [mm]", + "Candidates Normalized", style, ranges, cat, label, + offset) + + plot_comparison(hist_x, args.prefix, "dx", cat, label, style, norm, offset) + plot_comparison(hist_y, args.prefix, "dy", cat, label, style, norm, offset) + plot_comparison(hist_z, args.prefix, "dz", cat, label, style, norm, offset) + + from ROOT import gEnv + gEnv.SetValue("Hist.Binning.1D.x", "100") + + graph = {} + graph["tracks"] = {} + graph["tracks"]["dx"] = {} + graph["tracks"]["dy"] = {} + graph["tracks"]["dz"] = {} + graph["tracks"]["dx"] = get_dependence(graph["tracks"]["dx"], tr, "dx", + "nrectrmc", ranges, style, cat, + label, offset) + graph["tracks"]["dy"] = get_dependence(graph["tracks"]["dy"], tr, "dy", + "nrectrmc", ranges, style, cat, + label, offset) + graph["tracks"]["dz"] = get_dependence(graph["tracks"]["dz"], tr, "dz", + "nrectrmc", ranges, style, cat, + label, offset) + + legend = TLegend(0.15, 0.86, 0.88, 0.98) + legend = set_legend(legend, label, graph["tracks"]["dz"], "sigma") + + labelpos = (0.73, 0.75, 0.88, 0.87) + plot( + graph["tracks"]["dx"], + "mean", + args.prefix + "_ntracks_mean", + "dx", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["dx"], + "sigma", + args.prefix + "_ntracks_sigma", + "dx", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["tracks"]["dy"], + "mean", + args.prefix + "_ntracks_mean", + "dy", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["dy"], + "sigma", + args.prefix + "_ntracks_sigma", + "dy", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["tracks"]["dz"], + "mean", + args.prefix + "_ntracks_mean", + "dz", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["tracks"]["dz"], + "sigma", + args.prefix + "_ntracks_sigma", + "dz", + cat, + label, + legend, + labelpos=labelpos) + + graph["z"] = {} + graph["z"]["dx"] = {} + graph["z"]["dy"] = {} + graph["z"]["dz"] = {} + graph["z"]["dx"] = get_dependence(graph["z"]["dx"], tr, "dx", "zMC", + ranges, style, cat, label, offset) + graph["z"]["dy"] = get_dependence(graph["z"]["dy"], tr, "dy", "zMC", + ranges, style, cat, label, offset) + graph["z"]["dz"] = get_dependence(graph["z"]["dz"], tr, "dz", "zMC", + ranges, style, cat, label, offset) + + plot( + graph["z"]["dx"], + "mean", + args.prefix + "_z_mean", + "dx", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["dx"], + "sigma", + args.prefix + "_z_sigma", + "dx", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["z"]["dy"], + "mean", + args.prefix + "_z_mean", + "dy", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["dy"], + "sigma", + args.prefix + "_z_sigma", + "dy", + cat, + label, + legend, + labelpos=labelpos) + + plot( + graph["z"]["dz"], + "mean", + args.prefix + "_z_mean", + "dz", + cat, + label, + legend, + labelpos=labelpos) + plot( + graph["z"]["dz"], + "sigma", + args.prefix + "_z_sigma", + "dz", + cat, + label, + legend, + labelpos=labelpos) diff --git a/Hlt/RecoConf/scripts/utils/pvconfig.py b/Hlt/RecoConf/scripts/utils/pvconfig.py new file mode 100644 index 00000000000..09bccd2963f --- /dev/null +++ b/Hlt/RecoConf/scripts/utils/pvconfig.py @@ -0,0 +1,188 @@ +############################################################################### +# (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. # +############################################################################### +#!/usr/bin/python + +from ROOT import TH1F, TLegend +from ROOT import kRed, kBlue, kOrange, kMagenta, kGreen, kCyan, kGray, kYellow + + +def get_categories(multi, smog): + cut = {} + cut["all"] = {"cut": ""} + # cut["isolated"] = {"cut": "&&isol==1"} + # if not smog: + # cut["close"] = {"cut": "&&isol==0"} + if multi: + cut["1st"] = {"cut": "&&multimc==1"} + cut["2nd"] = {"cut": "&&multimc==2"} + cut["3rd"] = {"cut": "&&multimc==3"} + cut["4th"] = {"cut": "&&multimc==4"} + cut["5th"] = {"cut": "&&multimc==5"} + + return cut + + +def get_style(): + return { + "color": [kRed, kBlue, kOrange, kMagenta, kGreen, kCyan], + "marker": [21, 20, 22, 23, 24, 25] + } + + +def get_default_tree_name(is_checker): + if is_checker: + return "PrimaryVertexChecker/101" + else: + return "VertexCompare/102" + + +def transfer_variable(dep): + dictionary = { + "pullx": "dx/errx", + "pully": "dy/erry", + "pullz": "dz/errz", + "dx": "dx", + "dy": "dy", + "dz": "dz", + } + return dictionary[dep] + + +def get_variable_ranges(smog): + dictionary = { + "zMC": { + "bins": 50, + "min": -200, + "max": 200 + }, + "rMC": { + "bins": 50, + "min": 0.0, + "max": 0.2 + }, + "dx": { + "bins": 50, + "min": -0.10, + "max": 0.10 + }, + "dy": { + "bins": 50, + "min": -0.10, + "max": 0.10 + }, + "dz": { + "bins": 50, + "min": -0.40, + "max": 0.40 + }, + "pullx": { + "bins": 50, + "min": -3.50, + "max": 3.50 + }, + "pully": { + "bins": 50, + "min": -3.50, + "max": 3.50 + }, + "pullz": { + "bins": 50, + "min": -3.50, + "max": 3.50 + }, + "nrectrmc": { + "bins": 66, + "min": 4.0, + "max": 70.0 + } + } + if smog: + dictionary["zMC"] = {"bins": 100, "min": -500, "max": 200} + + return dictionary + + +def get_y_axis(dependence): + dictionary = { + "dx": "Resolution #Delta x [#mu m]", + "dy": "Resolution #Delta y [#mu m]", + "dz": "Resolution #Delta z [#mu m]", + "pullx": "Pull #Delta x/#sigma_{x}", + "pully": "Pull #Delta y/#sigma_{y}", + "pullz": "Pull #Delta z/#sigma_{z}" + } + return dictionary[dependence] + + +def get_x_axis(dependence): + dictionary = { + "zMC": "z [mm]", + "rMC": "radial distance [mm]", + "nrectrmc": "number of tracks in Primary Vertex" + } + return dictionary[dependence] + + +def set_style(graph, color, marker, xaxis, yaxis, title): + graph.SetTitle("") + graph.SetLineColor(color) + graph.SetMarkerColor(color) + graph.SetMarkerSize(1.3) + graph.SetMarkerStyle(marker) + graph.GetYaxis().SetTitleOffset(0.85) + if type(graph) == TH1F: + graph.SetFillColor(color) + graph.SetLineWidth(1) + graph.SetStats(False) + graph.GetYaxis().SetTitleOffset(1.1) + graph.GetYaxis().SetTitleSize(0.06) + graph.GetYaxis().SetLabelSize(0.06) + graph.GetXaxis().SetTitleSize(0.06) + graph.GetXaxis().SetLabelSize(0.06) + graph.GetXaxis().SetTitleFont(132) + graph.GetXaxis().SetLabelFont(132) + graph.GetYaxis().SetTitleFont(132) + graph.GetYaxis().SetLabelFont(132) + + if title != "": + graph.SetTitle(title) + if xaxis != "": + graph.GetXaxis().SetTitle(xaxis) + if yaxis != "": + graph.GetYaxis().SetTitle(yaxis) + + +def set_legend(legend, label, gr, gr_type, hist=None, dist=False): + legend.SetTextSize(0.04) + legend.SetTextFont(12) + legend.SetFillColor(4000) + legend.SetShadowColor(0) + legend.SetBorderSize(0) + legend.SetTextFont(132) + legend.SetNColumns(2) + for lab in label: + legend.AddEntry(gr["all"][lab][gr_type], "{lab}".format(lab=lab), + "lep") + if dist: + legend.AddEntry(hist["all"][label[0]]["den"], "Distribution MC", "f") + for lab in label: + legend.AddEntry(hist["all"][lab]["nom"], + "Distribution {lab}".format(lab=lab), "lep") + + return legend + + +def get_text_cor(): + return {"x": [0.17, 0.65, 0.17, 0.65], "y": [0.92, 0.92, 0.75, 0.75]} + + +def basic_cut(): + return "nrectrmc>=4 && dz < 2.0" diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py new file mode 100644 index 00000000000..16d61773c5a --- /dev/null +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -0,0 +1,442 @@ +############################################################################### +# (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. # +############################################################################### + +# The utils for processing output of the PrimaryVertexChecker output +# +# author: Agnieszka Dziurda (agnieszka.dziurda@cern.ch) +# date: 02/2020 +# + +from ROOT import TFile, TTree, TH1F, gDirectory, TGraphAsymmErrors, TPaveText, gStyle +from ROOT import TCanvas +from ROOT import TGraphErrors, TLegend +from ROOT import gPad, kGray, TLatex + +from pvconfig import get_default_tree_name +from pvconfig import transfer_variable +from pvconfig import get_x_axis, get_y_axis +from pvconfig import set_style +from pvconfig import set_legend +from pvconfig import get_text_cor +from pvconfig import basic_cut + +from array import array + + +def get_files(tf, label, files): + i = 0 + for f in files: + tf[label[i]] = TFile(f) + i += 1 + return tf + + +def get_trees(tf, tr, label, trees, is_checker): + i = 0 + for lab in label: + if len(tf) == len(trees): + tr[lab] = tf[lab].Get(trees[i]) + else: + tr[lab] = tf[lab].Get(get_default_tree_name(is_checker)) + i += 1 + return tr + + +def get_eff(eff, hist, trees, dependence, style, ranges, categories, label, + offset): + + for cat in categories: + eff[cat] = {} + hist[cat] = {} + i = offset + for lab in label: + var_den = '{dependence}>>hist{code}_{dep}_{cat}_denom{i}({bins},{mins},{maxs})'.format( + dependence=dependence, + code="den", + dep=dependence, + cat=cat, + lab=lab, + bins=ranges[dependence]["bins"], + mins=ranges[dependence]["min"], + maxs=ranges[dependence]["max"], + i=i) + var_nom = '{dependence}>>hist{code}_{dep}_{cat}_num{i}({bins},{mins},{maxs})'.format( + dependence=dependence, + code="nom", + dep=dependence, + cat=cat, + lab=lab, + bins=ranges[dependence]["bins"], + mins=ranges[dependence]["min"], + maxs=ranges[dependence]["max"], + i=i) + + cut_den = 'nrectrmc>=4 && dz < 2.0 {cuts}'.format( + cuts=categories[cat]["cut"]) + cut_nom = cut_den + ' && reco == 1' + + trees[lab].Draw(var_nom, cut_nom) + trees[lab].Draw(var_den, cut_den) + + h_nom = gDirectory.Get('hist{code}_{dep}_{cat}_num{i}'.format( + code="nom", dep=dependence, cat=cat, lab=lab, i=i)) + h_den = gDirectory.Get('hist{code}_{dep}_{cat}_denom{i}'.format( + code="den", dep=dependence, cat=cat, lab=lab, i=i)) + + g_eff = TGraphAsymmErrors() + g_eff.Divide(h_nom, h_den, "cl=0.683 b(1,1) mode") + + set_style(h_nom, style["color"][i] - 7, style["marker"][i] + 4, + get_x_axis(dependence), "Efficiency", "") + set_style(h_den, kGray, style["marker"][i], get_x_axis(dependence), + "Efficiency", "") + hist[cat][lab] = {} + hist[cat][lab]["nom"] = h_nom + hist[cat][lab]["den"] = h_den + + set_style(g_eff, style["color"][i], style["marker"][i], + get_x_axis(dependence), "Efficiency", "") + eff[cat][lab] = {} + eff[cat][lab]["eff"] = g_eff + i += 1 + + return eff, hist + + +def find_max(gr, gr_type, label): + m = -999999.0 + for lab in label: + if (gr[lab][gr_type].GetYaxis().GetXmax() > m): + m = gr[lab][gr_type].GetYaxis().GetXmax() + + return m + + +def find_min(gr, gr_type, label): + m = 999999.0 + for lab in label: + if (gr[lab][gr_type].GetYaxis().GetXmin() < m): + m = gr[lab][gr_type].GetYaxis().GetXmin() + return m + + +def plot(gr, + gr_type, + prefix, + dependence, + categories, + label, + legend=None, + hist=None, + dist=False, + labelpos=(0.75, 0.78, 0.9, 0.9)): + + for cat in categories: + can = TCanvas( + 'canvas_{depen}_{prefix}_{gr_type}_{cat}'.format( + depen=dependence, prefix=prefix, gr_type=gr_type, cat=cat), + "cR", 1200, 800) + can.SetBottomMargin(0.15) + can.SetLeftMargin(0.12) + can.SetTopMargin(0.15) + if dist: + can.SetTopMargin(0.20) + can.SetRightMargin(0.05) + can.cd() + + maximum = find_max(gr[cat], gr_type, label) + minimum = find_min(gr[cat], gr_type, label) + if (abs(maximum) > abs(minimum) and minimum < 0): + minimum = -maximum + + gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser( + minimum * 1.1, maximum * 1.1) + if (gr_type == "eff"): + gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser(0.0, 1.1) + if (gr_type == "sigma"): + gr[cat][label[0]][gr_type].GetYaxis().SetRangeUser( + 0.0, maximum * 1.1) + gr[cat][label[0]][gr_type].Draw("AP") + + for lab in label: + gr[cat][lab][gr_type].Draw("SAME P") + + if dist: + histmax_den = 1.1 * hist[cat][label[0]]["den"].GetMaximum() + scale = gPad.GetUymax() / histmax_den + hist[cat][label[0]]["den"].Scale(scale * 0.75) + hist[cat][label[0]]["den"].Draw("hist SAME") + + for lab in label: + histmax_nom = 1.1 * hist[cat][lab]["nom"].GetMaximum() + #scale = gPad.GetUymax() / histmax_nom + hist[cat][lab]["nom"].Scale(scale * 0.75) + hist[cat][lab]["nom"].Draw("ep SAME") + + gr[cat][lab][gr_type].Draw("SAME P") + + if legend: + legend.Draw("SAME") + pavetext = TPaveText(labelpos[0], labelpos[1], labelpos[2], + labelpos[3], "NBNDC") + pavetext.AddText("LHCb simulation") + pavetext.SetFillColor(0) + pavetext.SetFillStyle(3000) + pavetext.SetTextSize(0.06) + pavetext.SetTextFont(132) + pavetext.Draw() + + saveName = '{prefix}_{dependence}_{cat}.pdf'.format( + prefix=prefix, dependence=dependence, cat=cat) + can.SaveAs(saveName) + + +def get_global(hist, trees, dependence, x_axis, y_axis, style, ranges, + categories, label, offset): + + dep = transfer_variable(dependence) + + for cat in categories: + hist[cat] = {} + i = offset + for lab in label: + var = '{dependence}>>hist_{dep}_{cat}_{i}({bins},{mins},{maxs})'.format( + dependence=dep, + dep=dependence, + cat=cat, + lab=lab, + bins=ranges[dependence]["bins"], + mins=ranges[dependence]["min"], + maxs=ranges[dependence]["max"], + i=i) + + cut = 'nrectrmc>=4 && dz < 2.0 && reco == 1 {cuts}'.format( + cuts=categories[cat]["cut"]) + + trees[lab].Draw(var, cut) + h = gDirectory.Get('hist_{dep}_{cat}_{i}'.format( + dep=dependence, cat=cat, lab=lab, i=i)) + if i == 0: + col = style["color"][i] - 10 + else: + col = style["color"][i] + set_style(h, col, style["marker"][i], x_axis, y_axis, "") + + hist[cat][lab] = h + i += 1 + + return hist + + +def set_text(text, color, x, y, lab, mean, mean_err, rms, rms_err, scale, + units): + s = 1.0 + if scale: + s = 1000.0 + + ur = "" + um = "#times 10^{-3}" + if units: + ur = "[#mu m]" + um = "[#mu m]" + + text.SetNDC() + text.SetTextFont(132) + text.SetTextColor(color) + text.DrawLatex(x, y * 1.0, lab) + + text.DrawLatex( + x, y * 0.95, "#mu = ({0:0.2f} #pm {1:0.2f}) {unit}".format( + mean * 1000.0, mean_err * 1000.0, unit=um)) + text.DrawLatex( + x, y * 0.90, "#sigma = ({0:0.2f} #pm {1:0.2f}) {unit}".format( + rms * s, rms_err * s, unit=ur)) + return text + + +def plot_comparison(hist, prefix, dependence, categories, label, style, norm, + offset): + + for cat in categories: + can = TCanvas('canvas_{depen}_{cat}'.format(depen=dependence, cat=cat), + "cR", 1200, 800) + can.SetBottomMargin(0.15) + can.SetLeftMargin(0.15) + can.SetTopMargin(0.20) + can.SetRightMargin(0.05) + + can.cd() + cor = get_text_cor() + + hist[cat][label[0]].GetYaxis().SetRangeUser( + 0.0, hist[cat][label[0]].GetMaximum() * 1.1) + scale = True + units = True + if "pull" in dependence: + scale = False + units = False + if norm: + hist[cat][label[0]].DrawNormalized("hist") + hist_max = hist[cat][label[0]].GetMaximum() + i = offset + for lab in label: + hist[cat][lab].DrawNormalized("SAME PE") + text = TLatex() + text = set_text(text, style["color"][i], cor["x"][i], + cor["y"][i], lab, hist[cat][lab].GetMean(), + hist[cat][lab].GetMeanError(), + hist[cat][lab].GetRMS(), + hist[cat][lab].GetRMSError(), scale, units) + i += 1 + + else: + hist[cat][label[0]].Draw("hist") + for lab in label: + hist[cat][lab].Draw("SAME PE") + pavetext = TPaveText(0.72, 0.77 - gStyle.GetPadTopMargin(), 0.87, + 0.89 - gStyle.GetPadTopMargin(), "NBNDC") + pavetext.AddText("LHCb simulation") + pavetext.SetFillColor(0) + pavetext.SetTextSize(0.06) + pavetext.SetTextFont(132) + pavetext.Draw() + + can.Update() + saveName = '{prefix}_{dependence}_{cat}.pdf'.format( + prefix=prefix, dependence=dependence, cat=cat) + can.SaveAs(saveName) + + +def get_robust_sigma(hist, resol): + + y = array('d', [0.] * 3) + x = array('d', [0.] * 3) + x[0] = 0.25 + x[1] = 0.50 + x[2] = 0.75 + + hist.GetQuantiles(3, y, x) + + _median = y[1] + _approxstdev = (y[2] - y[0]) / 1.34898 + #factor gives correspondence between IQR and stdev for a Gaussian + mult = 4.0 + + histclone = hist.Clone() + nb = histclone.GetNbinsX() + + for i in range(1, nb + 1): + if ((histclone.GetBinCenter(i) < (_median - _approxstdev * mult)) + or (histclone.GetBinCenter(i) > + (_median + _approxstdev * mult))): + histclone.SetBinContent(i, 0) + + if resol: + robustsigma = { + "sigma": { + "var": histclone.GetRMS() * 1000.0, + "err": histclone.GetRMSError() * 1000.0 + }, + "mean": { + "var": histclone.GetMean() * 1000.0, + "err": histclone.GetMeanError() * 1000.0 + } + } + + else: + robustsigma = { + "sigma": { + "var": histclone.GetRMS() * 1.0, + "err": histclone.GetRMSError() * 1.0 + }, + "mean": { + "var": histclone.GetMean(), + "err": histclone.GetMeanError() + } + } + + return robustsigma + + +def get_dependence(graph, trees, variable, dependence, ranges, style, + categories, label, offset): + + var = transfer_variable(variable) + bin_width = (ranges[dependence]["max"] - + ranges[dependence]["min"]) / ranges[dependence]["bins"] + + resol = True + mean = "Mean [#mu m]" + if "pull" in variable: + resol = False + mean = "Mean" + + for cat in categories: + graph[cat] = {} + i = offset + for lab in label: + graph[cat][lab] = {} + graph_rms = TGraphAsymmErrors(ranges[dependence]["bins"]) + graph_mean = TGraphAsymmErrors(ranges[dependence]["bins"]) + + bin_min = ranges[dependence]["min"] + for b in range(0, ranges[dependence]["bins"]): + + cut_bin = '{variable1}>={mins} && {variable2}<{maxs}'.format( + variable1=dependence, + mins=bin_min, + variable2=dependence, + maxs=bin_min + bin_width) + + hist_string = '{dependence}>>hist_{dep}_{cat}_{i}_{number}'.format( + dependence=var, + dep=variable, + cat=cat, + i=i, + number=int(b), + ) + + cut = '{basic} && reco == 1 && {bin_cut} {cuts}'.format( + basic=basic_cut(), + bin_cut=cut_bin, + cuts=categories[cat]["cut"]) + + a = trees[lab].Draw(hist_string, cut) + + bin_min += bin_width + + h = gDirectory.Get('hist_{dep}_{cat}_{i}_{number}'.format( + dep=variable, cat=cat, i=i, number=int(b))) + + robust_sigma = get_robust_sigma(h, resol) + + graph_mean.SetPoint(b, bin_min + bin_width / 2.0, + robust_sigma["mean"]["var"]) + graph_mean.SetPointError(b, bin_width / 2.0, bin_width / 2.0, + robust_sigma["mean"]["err"], + robust_sigma["mean"]["err"]) + + graph_rms.SetPoint(b, bin_min + bin_width / 2.0, + robust_sigma["sigma"]["var"]) + graph_rms.SetPointError(b, bin_width / 2.0, bin_width / 2.0, + robust_sigma["sigma"]["err"], + robust_sigma["sigma"]["err"]) + + set_style(graph_rms, style["color"][i], style["marker"][i], + get_x_axis(dependence), get_y_axis(variable), "") + set_style(graph_mean, style["color"][i], style["marker"][i], + get_x_axis(dependence), mean, "") + + graph[cat][lab]["sigma"] = graph_rms + graph[cat][lab]["mean"] = graph_mean + i += 1 + + return graph -- GitLab From 31010358238c84e4619b0a8337a33785cd69c771 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Thu, 2 Jul 2020 12:25:57 +0200 Subject: [PATCH 171/171] plot ghost rate histogram for all trackers; update figure labels based on comments during approval --- .../scripts/PrCheckerEfficiency_HLT1.py | 100 +++++++++++------- Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py | 4 +- .../scripts/PrCheckerTrackResolution.py | 4 +- Hlt/RecoConf/scripts/utils/ConfigHistos.py | 6 +- 4 files changed, 69 insertions(+), 45 deletions(-) diff --git a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py index 08549dbff3b..3a387f42b00 100644 --- a/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py +++ b/Hlt/RecoConf/scripts/PrCheckerEfficiency_HLT1.py @@ -51,6 +51,14 @@ def getOriginFolders(): return basedict +def getTrackNames(): + basedict = {"Velo": {}, "Upstream": {}, "Forward": {}} + + basedict["Velo"] = "Velo" + basedict["Upstream"] = "VeloUT" + basedict["Forward"] = "Forward" + + return basedict def get_colors(): return [kBlack, kAzure, kGreen + 3, kMagenta + 2, kOrange, kCyan + 2] @@ -65,7 +73,11 @@ def get_fillstyles(): def getGhostHistoNames(): - return ["eta", "nPV", "pt", "p"] + basedict = {"Velo": {}, "Upstream": {}, "Forward": {}} + basedict["Velo"] = ["eta", "nPV"] + basedict["Upstream"] = ["eta", "nPV", "pt", "p"] + basedict["Forward"] = ["eta", "nPV", "pt", "p"] + return basedict def argument_parser(): @@ -126,7 +138,7 @@ def get_eff(eff, hist, tf, histoName, label, var): teff.SetStatisticOption(7) eff[lab] = teff.CreateGraph() eff[lab].SetName(lab) - eff[lab].SetTitle(lab + "not elec.") + eff[lab].SetTitle(lab + "not electron") if (histoName.find('strange') != -1): eff[lab].SetTitle(lab + " from stranges") if (histoName.find('electron') != -1): @@ -134,11 +146,11 @@ def get_eff(eff, hist, tf, histoName, label, var): hist[lab] = denominator.Clone() hist[lab].SetName("h_numerator_notElectrons") - hist[lab].SetTitle(var + " histo. not elec.") + hist[lab].SetTitle(var + " distribution, not electron") if (histoName.find('strange') != -1): - hist[lab].SetTitle(var + " histo. stranges") + hist[lab].SetTitle(var + " distribution, stranges") if (histoName.find('electron') != -1): - hist[lab].SetTitle(var + " histo. electron") + hist[lab].SetTitle(var + " distribution, electron") return eff, hist @@ -172,6 +184,7 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, cuts = getCuts() trackers = getTrackers() folders = getOriginFolders() + names = getTrackNames() for tracker in trackers: outputfile.cd() @@ -233,6 +246,8 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, eff[lab].Draw("P SAME") cutName = categories[tracker][cut]["title"] latex.DrawLatex(0.7, 0.85, "LHCb simulation") + track_name = names[tracker] + " tracks" + latex.DrawLatex(0.7, 0.75, track_name) latex.DrawLatex(0.35, 0.3, cutName) canvasName = tracker + "_" + cut + "_" + histo + ".pdf" if savepdf: @@ -286,6 +301,8 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, for lab in label: eff_elec[lab].Draw("P SAME") latex.DrawLatex(0.7, 0.85, "LHCb simulation") + track_name = names[tracker] + " tracks" + latex.DrawLatex(0.7, 0.75, track_name) latex.DrawLatex(0.35, 0.3, cutName) canvasName_elec = tracker + "_" + cut + "_" + histo + "_elec.pdf" if savepdf: @@ -334,45 +351,50 @@ def PrCheckerEfficiency(filename, outfile, label, plotstyle, dist, plotelec, eff[lab].Draw("P SAME") eff_elec[lab].Draw("P SAME") latex.DrawLatex(0.7, 0.85, "LHCb simulation") + track_name = names[tracker] + " tracks" + latex.DrawLatex(0.7, 0.75, track_name) latex.DrawLatex(0.35, 0.3, cutName) canvas_com.SetRightMargin(0.05) canvas_com.Write() # calculate ghost rate - if tracker == "Forward": - histoBaseName = "Track/" + folder + tracker + "/" - for histo in ghostHistos: - trackerDir.cd() - title = "ghost rate vs " + histo - canvas = TCanvas(title, title) - gPad.SetTicks() - numeratorName = histoBaseName + ghostHistoDict[histo][ - "variable"] + "_Ghosts" - denominatorName = histoBaseName + ghostHistoDict[histo][ - "variable"] + "_Total" - print("ghost histo: " + histoBaseName + " " + numeratorName + - " " + denominatorName) - ghost = {} - mg = TMultiGraph() - for i, lab in enumerate(label): - numerator = tf[lab].Get(numeratorName) - denominator = tf[lab].Get(denominatorName) - - teff = TEfficiency(numerator, denominator) - teff.SetStatisticOption(7) - ghost[lab] = teff.CreateGraph() - ghost[lab].SetName(lab) - set_style(ghost[lab], colors[i], markers[i], styles[i]) - mg.Add(ghost[lab]) - - xtitle = ghostHistoDict[histo]["xTitle"] - mg.GetXaxis().SetTitle(xtitle) - mg.GetYaxis().SetTitle("ghost rate") - mg.Draw("ap") - canvas.PlaceLegend() - if savepdf: - canvas.SaveAs("ghost_rate_" + histo + ".pdf") - canvas.Write() + histoBaseName = "Track/" + folder + tracker + "/" + for histo in ghostHistos[tracker]: + trackerDir.cd() + title = "ghost rate vs " + histo + canvas = TCanvas(title, title) + gPad.SetTicks() + numeratorName = histoBaseName + ghostHistoDict[histo][ + "variable"] + "_Ghosts" + denominatorName = histoBaseName + ghostHistoDict[histo][ + "variable"] + "_Total" + print("ghost histo: " + histoBaseName + " " + numeratorName + + " " + denominatorName) + ghost = {} + mg = TMultiGraph() + for i, lab in enumerate(label): + numerator = tf[lab].Get(numeratorName) + denominator = tf[lab].Get(denominatorName) + print("Numerator = " + numeratorName) + print("Denominator = " + denominatorName) + teff = TEfficiency(numerator, denominator) + teff.SetStatisticOption(7) + ghost[lab] = teff.CreateGraph() + ghost[lab].SetName(lab) + set_style(ghost[lab], colors[i], markers[i], styles[i]) + mg.Add(ghost[lab]) + + xtitle = ghostHistoDict[histo]["xTitle"] + mg.GetXaxis().SetTitle(xtitle) + mg.GetYaxis().SetTitle("ghost rate") + mg.Draw("ap") + latex.DrawLatex(0.7, 0.85, "LHCb simulation") + track_name = names[tracker] + " tracks" + latex.DrawLatex(0.7, 0.75, track_name) + #canvas.PlaceLegend() + if savepdf: + canvas.SaveAs("ghost_rate_" + histo + ".pdf") + canvas.Write() outputfile.Write() outputfile.Close() diff --git a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py index cece8847f38..f1251673498 100644 --- a/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py +++ b/Hlt/RecoConf/scripts/PrCheckerMuonIDEff.py @@ -112,14 +112,14 @@ def get_eff(eff, hist, tf, histoName, histoName_Den, label, var, printval): teff.SetStatisticOption(7) eff[lab] = teff.CreateGraph() eff[lab].SetName(lab) - eff[lab].SetTitle(lab + ", not elec.") + eff[lab].SetTitle(lab) if (histoName.find('strange') != -1): eff[lab].SetTitle(lab + " from stranges") if (histoName.find('electron') != -1): eff[lab].SetTitle(lab + " electron") hist[lab] = denominator.Clone() hist[lab].SetName("h_numerator_notElectrons") - hist[lab].SetTitle(var + " histo. not elec.") + hist[lab].SetTitle(var + " distribution") if (histoName.find('strange') != -1): hist[lab].SetTitle(var + " histo. stranges") if (histoName.find('electron') != -1): diff --git a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py index eee008dbef6..e4e7c26582a 100644 --- a/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py +++ b/Hlt/RecoConf/scripts/PrCheckerTrackResolution.py @@ -105,7 +105,7 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): "Track/TrackResChecker/ALL/vertex/dpoverp_vs_p") hdp_p[lab].SetName("dpoverp_p_" + lab) hmom[lab] = hdp_p[lab].ProjectionX() - hmom[lab].SetTitle("p histo. " + lab) + hmom[lab].SetTitle("p distribution " + lab) hdp_p[lab].FitSlicesY() hres_p[lab] = gDirectory.Get("dpoverp_p_" + lab + "_2") @@ -155,7 +155,7 @@ def PrCheckerTrackResolution(filename, label, outfile, savepdf, plotstyle): hdp_eta[lab].SetName("dpoverp_eta_" + lab) hdp_eta[lab].FitSlicesY() heta[lab] = hdp_eta[lab].ProjectionX() - heta[lab].SetTitle("#eta histo. " + lab) + heta[lab].SetTitle("#eta distribution " + lab) hres_eta[lab] = gDirectory.Get("dpoverp_eta_" + lab + "_2") hres_eta[lab].GetYaxis().SetTitle("dp/p [%]") diff --git a/Hlt/RecoConf/scripts/utils/ConfigHistos.py b/Hlt/RecoConf/scripts/utils/ConfigHistos.py index 816fc5c8c58..33cb61e2ccb 100644 --- a/Hlt/RecoConf/scripts/utils/ConfigHistos.py +++ b/Hlt/RecoConf/scripts/utils/ConfigHistos.py @@ -83,7 +83,7 @@ def getCuts(): "04_long_strange_P>5GeV", "05_long_fromB", "06_long_fromB_P>5GeV", "10_long_fromB_P>3GeV_Pt>0.5GeV", "11_UT_long_fromB_P>3GeV_Pt>0.5GeV" ] - basedict["MuonMatch"] = ["01_long", "02_long_muon"] + basedict["MuonMatch"] = ["01_long", "02_long_muon", "04_long_pion"] return basedict @@ -94,7 +94,9 @@ def categoriesDict(): basedict["MuonMatch"]["01_long"][ "title"] = "Long, forward track, 2 <#eta< 5" basedict["MuonMatch"]["02_long_muon"][ - "title"] = "Long, #mu, forward track, 2 <#eta< 5" + "title"] = "Long, #mu, forward track, 2 <#eta< 5" + basedict["MuonMatch"]["04_long_pion"][ + "title"] = "Long, #pi, forward track, 2 <#eta< 5" basedict["Velo"]["01_velo"]["title"] = "Velo, 2 <#eta< 5" basedict["Velo"]["02_long"]["title"] = "Long, 2 <#eta< 5" -- GitLab