diff --git a/Hlt/Moore/python/Moore/config.py b/Hlt/Moore/python/Moore/config.py index 95bd9fe3983c3e7ddaefe5cd8e51247bbeb21ebe..087b3731e27827a234b2a81a5b109eb0f49b8fe2 100644 --- a/Hlt/Moore/python/Moore/config.py +++ b/Hlt/Moore/python/Moore/config.py @@ -56,7 +56,9 @@ from .streams import Stream, make_default_streams log = logging.getLogger(__name__) -def moore_control_flow(options, streams, process, analytics=False): +def moore_control_flow( + options, streams, process, use_allen_reconstruction=False, analytics=False +): """Return the Moore application control flow node. Combines the lines with `NONLAZY_OR` logic in a global decision @@ -68,6 +70,7 @@ def moore_control_flow(options, streams, process, analytics=False): options (ApplicationOptions): holder of application options streams (list of stream objects): control flow nodes of lines process (str): "hlt1", "hlt2", "spruce" or "pass". + use_allen_reconstruction (bool): whether to use Hlt1 reconstruction. Defaults to False. analytics (bool, optional): For use only in rate/event size analysis. Defaults to False. Returns: @@ -274,10 +277,22 @@ def moore_control_flow(options, streams, process, analytics=False): else: stream_writers_nodes = [] + children = [] + + if use_allen_reconstruction: + # If Hlt1 reconstruction is used, we need to add the non-event data service + # to the control flow to ensure that the Hlt1 reconstruction can access the + # necessary non-event data. + from Allen.config import setup_allen_non_event_data_service + + non_event_data_node = setup_allen_non_event_data_service() + children += [non_event_data_node] + children += [lines_node] + [rw_nodes] + stream_writers_nodes + return CompositeNode( "moore", combine_logic=NodeLogic.LAZY_AND, - children=([lines_node] + [rw_nodes] + stream_writers_nodes), + children=(children), force_order=True, ) @@ -287,6 +302,7 @@ def run_moore( make_streams=None, public_tools=[], analytics=False, + use_allen_reconstruction=False, exclude_incompatible=True, add_required_tools_automatically=True, ): @@ -308,6 +324,7 @@ def run_moore( make_streams: function returning dict of {stream : `DecisionLine` objects}) OR a list of `DecisionLine` objects public_tools (list): list of public `Tool` instances to configure analytics (bool, optional): For use only in rate/event size analysis. Defaults to False. + use_allen_reconstruction (bool, optional): Whether to use Hlt1 reconstruction. Defaults to False. exclude_incompatible (bool, optional): Exclude the lines that are incompatible with multithreaded mode. Defaults to True. add_required_tools_automatically (bool, optional): Attach required tools to the public_tools automatically. Defaults to True. """ @@ -381,7 +398,9 @@ def run_moore( process = "pass" # Combine all lines and output in a global control flow. - moore_control_node = moore_control_flow(options, streams, process, analytics) + moore_control_node = moore_control_flow( + options, streams, process, use_allen_reconstruction, analytics + ) # Filter to return true if physics bit 95 is "on" for this event rb_bank = default_raw_banks("HltRoutingBits") diff --git a/Hlt/Moore/python/Moore/production.py b/Hlt/Moore/python/Moore/production.py index cb87f440ae1f522ceb3ad2ac4a21c9fb90ea0120..66b2fe41c5991625911ea57dc66bcd95052d7d24 100644 --- a/Hlt/Moore/python/Moore/production.py +++ b/Hlt/Moore/python/Moore/production.py @@ -512,7 +512,10 @@ def _spruce( ] moore_control_node = moore_control_flow( - options, _my_line_maker(), process="spruce" + options, + _my_line_maker(), + process="spruce", + use_allen_reconstruction=False, ) ## Add this filter before `moore_control_node` using `LAZY_AND` logic IF flagging diff --git a/Hlt/RecoConf/options/allen_gaudi_pv_with_prvelotracks.py b/Hlt/RecoConf/options/allen_gaudi_pv_with_prvelotracks.py new file mode 100644 index 0000000000000000000000000000000000000000..1bc635227d1557302726fb88337cedb578724428 --- /dev/null +++ b/Hlt/RecoConf/options/allen_gaudi_pv_with_prvelotracks.py @@ -0,0 +1,59 @@ +############################################################################### +# (c) Copyright 2021 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 Allen.config import run_allen_reconstruction +from PyConf.Algorithms import ( + GaudiAllenPVsToPrimaryVertexContainer, + GaudiAllenVeloToV3Tracks, + TrackContainersMerger, + fromV3TrackV1Track, +) +from RecoConf.config import Reconstruction +from RecoConf.core_algorithms import make_unique_id_generator +from RecoConf.decoders import default_VeloCluster_source +from RecoConf.gaudi_allen_tracking import allen_velo_tracks +from RecoConf.legacy_rec_hlt1_tracking import all_velo_track_types +from RecoConf.mc_checking import get_pv_checkers +from RecoConf.options import options + + +def make_reconstruction(): + """ + PV checker for the Allen PV finding algorithm using converted Moore VELO tracks as input + """ + from AllenConf.primary_vertex_reconstruction import make_pvs + + # get all velo tracks + rec_tracks = all_velo_track_types() + # convert PrVelo tracks to Gaudi Allen VELO tracks + converted_velo_tracks = allen_velo_tracks(input_tracks=rec_tracks) + + # reconstruct Allen PVs + pvs = make_pvs(converted_velo_tracks, use_converted_tracks=True) + + # convert Allen PVs to PrimaryVertexContainer object + pv_container = GaudiAllenPVsToPrimaryVertexContainer( + number_of_multivertex=pvs["dev_number_of_multi_final_vertices"], + reconstructed_multi_pvs=pvs["dev_multi_final_vertices"], + ).OutputPVs + + # call PV checker + pv_checker = get_pv_checkers( + pv_container, + rec_tracks, + produce_ntuple=True, + nTracksToBeRecble=pvs["pp_minNumTracksPerVertex"], + ) + + return Reconstruction("pv_checker", pv_checker) + + +with default_VeloCluster_source.bind(bank_type="VPRetinaCluster"): + run_allen_reconstruction(options, make_reconstruction) diff --git a/Hlt/RecoConf/options/hlt1_convertedtracks_hlt2_pvs_vertex_compare.py b/Hlt/RecoConf/options/hlt1_convertedtracks_hlt2_pvs_vertex_compare.py new file mode 100644 index 0000000000000000000000000000000000000000..e844896bf16a6093206d16259e528bebc23db8d3 --- /dev/null +++ b/Hlt/RecoConf/options/hlt1_convertedtracks_hlt2_pvs_vertex_compare.py @@ -0,0 +1,84 @@ +############################################################################### +# (c) Copyright 2025 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 Allen.config import run_allen_reconstruction +from AllenConf.velo_reconstruction import decode_velo, make_velo_tracks +from PyConf.Algorithms import GaudiAllenPVsToPrimaryVertexContainer, VertexCompare +from PyConf.packing import persistable_location +from RecoConf.config import Reconstruction +from RecoConf.gaudi_allen_tracking import allen_velo_tracks +from RecoConf.legacy_rec_hlt1_tracking import ( + all_velo_track_types, + make_TrackBeamLineVertexFinderSoA_pvs, +) +from RecoConf.options import options + + +def run_VertexCompare(): + """ + Compares between: + - Allen PV finding algorithm using as input Moore VELO tracks converted vs the nominal Moore PV finding algorithm (with Moore VELO tracks) + - Allen PV finding algorithm using as input Moore VELO tracks converted vs the nominal Allen PV finding algorithm (with Allen VELO tracks) + """ + from AllenConf.primary_vertex_reconstruction import make_pvs + + # reconstruct Moore VELO tracks + hlt2_velo_tracks = all_velo_track_types() + # Convert to Allen VELO tracks + converted_velo_tracks = allen_velo_tracks(input_tracks=hlt2_velo_tracks) + + # reconstruct Allen PVs + pvs_converted_tracks = make_pvs( + converted_velo_tracks, pv_name="converted_tracks", use_converted_tracks=True + ) + + # reconstruct Allen VELO tracks + decoded_velo = decode_velo() + hlt1_velo_tracks = make_velo_tracks(decoded_velo) + + # reconstruct Allen PVs + hlt1_pvs = make_pvs(hlt1_velo_tracks, pv_name="nominal") + + # convert Allen PVs to PrimaryVertexContainer object + pv_container_hlt1 = GaudiAllenPVsToPrimaryVertexContainer( + number_of_multivertex=hlt1_pvs["dev_number_of_multi_final_vertices"], + reconstructed_multi_pvs=hlt1_pvs["dev_multi_final_vertices"], + ).OutputPVs + + pv_container_converted_tracks = GaudiAllenPVsToPrimaryVertexContainer( + number_of_multivertex=pvs_converted_tracks[ + "dev_number_of_multi_final_vertices" + ], + reconstructed_multi_pvs=pvs_converted_tracks["dev_multi_final_vertices"], + ).OutputPVs + + # reconstruct Moore PVs + hlt2_pvs = make_TrackBeamLineVertexFinderSoA_pvs( + hlt2_velo_tracks, location=persistable_location("PVs") + ) + + with VertexCompare.bind(produceNtuple=True): + vertex_compare = [ + VertexCompare( + inputVerticesName1=pv_container_converted_tracks, + inputVerticesName2=hlt2_pvs["v3"], + ), + VertexCompare( + inputVerticesName1=pv_container_converted_tracks, + inputVerticesName2=pv_container_hlt1, + ), + ] + return Reconstruction("vertex_compare", vertex_compare) + + +options.ntuple_file = "hlt2_pvs_vertex_compare.root" + + +run_allen_reconstruction(options, run_VertexCompare) diff --git a/Hlt/RecoConf/python/RecoConf/gaudi_allen_tracking.py b/Hlt/RecoConf/python/RecoConf/gaudi_allen_tracking.py new file mode 100644 index 0000000000000000000000000000000000000000..e8aea5092094a2a73e12a9e545a6451e2e9d626e --- /dev/null +++ b/Hlt/RecoConf/python/RecoConf/gaudi_allen_tracking.py @@ -0,0 +1,97 @@ +############################################################################### +# (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 ConfigurationError, configurable +from PyConf.Algorithms import ( + GaudiAllenPVsToPrimaryVertexContainer, + PrVeloToGaudiAllenVeloTracks, +) + + +@configurable +def allen_velo_tracks(input_tracks): + """Helper function to get velo tracks converted to Allen type. + + Args: + input_tracks (DataHandle): Input tracks to be converted. + + Returns: + DataHandle: Allen velo tracks + """ + allen_velo_tracks_alg = PrVeloToGaudiAllenVeloTracks( + PrVeloTracksForward=input_tracks["Pr"], + PrVeloTracksBackward=input_tracks["Pr::backward"], + ) + + return { + "v1": input_tracks["v1"], + "Pr": input_tracks["Pr"], + "Pr::backward": input_tracks["Pr::backward"], + "dev_velo_tracks_view": allen_velo_tracks_alg.AllenVeloTracksView, + "dev_velo_kalman_beamline_states_view": allen_velo_tracks_alg.AllenBeamlineStatesView, + "host_number_of_reconstructed_velo_tracks": allen_velo_tracks_alg.NumberOfReconstructedVeloTracks, + } + + +@configurable +def make_allen_pvs(hlt2_tracks, location=None): + """Makes PVs from velo tracks using HLT1 PV finding algorithm + + Args: + hlt2_tracks (DataHandle): HLT2 tracks to be converted for PV finding + location (str, optional): Location to store the output PVs. Defaults to None. + Returns: + DataHandle: Converted HLT1 reconstructed PVs + """ + from AllenConf.primary_vertex_reconstruction import make_pvs + + velo_tracks = { + "v1": hlt2_tracks["Velo"]["v1"], + "Pr": hlt2_tracks["Velo"]["Pr"], + "Pr::backward": hlt2_tracks["Velo"]["Pr::backward"], + } + converted_velo_tracks = allen_velo_tracks(input_tracks=velo_tracks) + hlt1_pvs = make_pvs( + converted_velo_tracks, pv_name="converted_tracks", use_converted_tracks=True + ) + + pvs = { + "v3": GaudiAllenPVsToPrimaryVertexContainer( + number_of_multivertex=hlt1_pvs["dev_number_of_multi_final_vertices"], + reconstructed_multi_pvs=hlt1_pvs["dev_multi_final_vertices"], + ).OutputPVs + } + + if "v1" in converted_velo_tracks: + if (location is not None) and ( + "SharedObjectsContainer" in converted_velo_tracks["v1"].type + ): + raise ConfigurationError( + "For use in PVs (and linking to tracks), Velo v1 tracks (persistable) relies on being a direct copy of Pr Velo tracks." + "Is that still the case with a Track::Selection? Should use the original KeyedContainer (probably)" + ) + from PyConf.Algorithms import PVToRecConverterV1 + + pvs["v1"] = PVToRecConverterV1( + InputVertices=pvs["v3"], + InputTracks=converted_velo_tracks["v1"], + outputs={"OutputVertices": location}, + ).OutputVertices + + else: + from PyConf.Algorithms import PVToRecConverterV1WithoutTracks + + pvs["v1"] = PVToRecConverterV1WithoutTracks( + InputVertices=pvs["v3"], + AddTrackWeights=False, + outputs={"OutputVertices": location}, + ).OutputVertices + + return pvs diff --git a/Hlt/RecoConf/python/RecoConf/hlt2_global_reco.py b/Hlt/RecoConf/python/RecoConf/hlt2_global_reco.py index 0779940edfe983761f4eb9ee3a46888881a0b9ed..5dad9ebb1e31263a26ddec168f1d98c925a5a9bb 100644 --- a/Hlt/RecoConf/python/RecoConf/hlt2_global_reco.py +++ b/Hlt/RecoConf/python/RecoConf/hlt2_global_reco.py @@ -69,6 +69,7 @@ def make_reconstruction( skipCalo=False, skipMuon=False, fastReco=False, + useAllenPVs=False, ): """Return reconstruction objects of the legacy, fastest or the light reconstruction, with possibility to skip the UT""" rich_and_charged_proto_track_types = ( @@ -85,14 +86,21 @@ def make_reconstruction( tracks_v3, tracks_rels = convert_tracks_to_v3_from_v1(persisted_tracks) # PVs - pvs = make_reco_pvs( - { - "Pr": hlt2_tracks["Velo"]["Pr"], - "Pr::backward": hlt2_tracks["Velo"]["Pr::backward"], - "v1": persisted_tracks["Velo"], - }, - persistable_location("PVs"), - ) + if useAllenPVs: + from .gaudi_allen_tracking import make_allen_pvs + + pvs = make_allen_pvs( + hlt2_tracks=hlt2_tracks, location=persistable_location("PVs") + ) + else: + pvs = make_reco_pvs( + { + "Pr": hlt2_tracks["Velo"]["Pr"], + "Pr::backward": hlt2_tracks["Velo"]["Pr::backward"], + "v1": persisted_tracks["Velo"], + }, + persistable_location("PVs"), + ) # calorimeter calo_pids = ( diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerBasic.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerBasic.py index b165e0bef10dbf10e7f10df4816bcc9168b533d6..c7f024f9ab752f92ea268ccef715a7fc07568bd5 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerBasic.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerBasic.py @@ -80,7 +80,7 @@ parser.add_argument( "--dir", dest="directory", default=os.getcwd(), - help="tree name to plot", + help="directory to save plots", ) parser.add_argument( @@ -100,7 +100,7 @@ def get_labels(number_of_files): if __name__ == "__main__": args = parser.parse_args() - path = args.directory + "/utils/" + path = os.getcwd() + "/utils/" sys.path.append(os.path.abspath(path)) offset = int(args.offset) gROOT.SetBatch() @@ -227,6 +227,7 @@ if __name__ == "__main__": offset, True, legend, + dir=args.directory, ) plot_comparison( hist_visMCPVs, @@ -239,16 +240,47 @@ if __name__ == "__main__": offset, True, legend, + dir=args.directory, ) plot_comparison( - hist_zMC, args.prefix, "zMC", cat, label, style, norm, offset, True, legend + hist_zMC, + args.prefix, + "zMC", + cat, + label, + style, + norm, + offset, + True, + legend, + dir=args.directory, ) plot_comparison( - hist_xMC, args.prefix, "xMC", cat, label, style, norm, offset, True, legend + hist_xMC, + args.prefix, + "xMC", + cat, + label, + style, + norm, + offset, + True, + legend, + dir=args.directory, ) plot_comparison( - hist_yMC, args.prefix, "yMC", cat, label, style, norm, offset, True, legend + hist_yMC, + args.prefix, + "yMC", + cat, + label, + style, + norm, + offset, + True, + legend, + dir=args.directory, ) plot_comparison( @@ -262,4 +294,5 @@ if __name__ == "__main__": offset, True, legend, + dir=args.directory, ) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py index 39f27e385c67560952d1a156e60601940d276f4c..af366ae9bcb24ea57cefae6ffbfa2332f807f59f 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerEfficiency.py @@ -80,7 +80,7 @@ parser.add_argument( "--dir", dest="directory", default=os.getcwd(), - help="tree name to plot", + help="directory to save plots", ) parser.add_argument( @@ -100,7 +100,7 @@ def get_labels(number_of_files): if __name__ == "__main__": args = parser.parse_args() - path = args.directory + "/utils/" + path = os.getcwd() + "/utils/" sys.path.append(os.path.abspath(path)) offset = int(args.offset) @@ -156,6 +156,7 @@ if __name__ == "__main__": "ntracks", cat, label, + args.directory, legend, hist["tracks"], args.dist, @@ -168,6 +169,7 @@ if __name__ == "__main__": "z", cat, label, + args.directory, legend, hist["z"], args.dist, @@ -180,6 +182,7 @@ if __name__ == "__main__": "r", cat, label, + args.directory, legend, hist["r"], args.dist, diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py index 4fd4cb19b07199490dc734d3336995e101d86ffa..f07fa6b1b01a5f0de32402dbda5a2d19bf0d2309 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerPull.py @@ -80,7 +80,7 @@ parser.add_argument( "--dir", dest="directory", default=os.getcwd(), - help="tree name to plot", + help="directory to save plots", ) parser.add_argument( @@ -100,7 +100,7 @@ def get_labels(number_of_files): if __name__ == "__main__": args = parser.parse_args() - path = args.directory + "/utils/" + path = os.getcwd() + "/utils/" sys.path.append(os.path.abspath(path)) offset = int(args.offset) gROOT.SetBatch() @@ -169,9 +169,39 @@ if __name__ == "__main__": 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, + dir=args.directory, + ) + plot_comparison( + hist_y, + args.prefix, + "pully", + cat, + label, + style, + norm, + offset, + dir=args.directory, + ) + plot_comparison( + hist_z, + args.prefix, + "pullz", + cat, + label, + style, + norm, + offset, + dir=args.directory, + ) from ROOT import gEnv @@ -228,6 +258,7 @@ if __name__ == "__main__": "pullx", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -238,6 +269,7 @@ if __name__ == "__main__": "pullx", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextposdown, ) @@ -249,6 +281,7 @@ if __name__ == "__main__": "pully", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -259,6 +292,7 @@ if __name__ == "__main__": "pully", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextposdown, ) @@ -270,6 +304,7 @@ if __name__ == "__main__": "pullz", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -280,6 +315,7 @@ if __name__ == "__main__": "pullz", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextposdown, ) @@ -305,6 +341,7 @@ if __name__ == "__main__": "pullx", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -315,6 +352,7 @@ if __name__ == "__main__": "pullx", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextposdown, ) @@ -326,6 +364,7 @@ if __name__ == "__main__": "pully", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -336,6 +375,7 @@ if __name__ == "__main__": "pully", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextposdown, ) @@ -347,6 +387,7 @@ if __name__ == "__main__": "pullz", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -357,6 +398,7 @@ if __name__ == "__main__": "pullz", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextposdown, ) diff --git a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py index a13f75921a7c60ec786a1e0cc8cf5d8539b29db8..b67248b0463aeb518ed7cc07a9df7e07001a71c7 100644 --- a/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py +++ b/Hlt/RecoConf/scripts/PrimaryVertexCheckerResolution.py @@ -80,7 +80,7 @@ parser.add_argument( "--dir", dest="directory", default=os.getcwd(), - help="tree name to plot", + help="directory to save plots", ) parser.add_argument( @@ -100,7 +100,7 @@ def get_labels(number_of_files): if __name__ == "__main__": args = parser.parse_args() - path = args.directory + "/utils/" + path = os.getcwd() + "/utils/" sys.path.append(os.path.abspath(path)) offset = int(args.offset) @@ -171,9 +171,15 @@ if __name__ == "__main__": 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) + plot_comparison( + hist_x, args.prefix, "dx", cat, label, style, norm, offset, dir=args.directory + ) + plot_comparison( + hist_y, args.prefix, "dy", cat, label, style, norm, offset, dir=args.directory + ) + plot_comparison( + hist_z, args.prefix, "dz", cat, label, style, norm, offset, dir=args.directory + ) from ROOT import gEnv @@ -205,6 +211,7 @@ if __name__ == "__main__": "dx", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -215,6 +222,7 @@ if __name__ == "__main__": "dx", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -226,6 +234,7 @@ if __name__ == "__main__": "dy", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -236,6 +245,7 @@ if __name__ == "__main__": "dy", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -247,6 +257,7 @@ if __name__ == "__main__": "dz", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -257,6 +268,7 @@ if __name__ == "__main__": "dz", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -282,6 +294,7 @@ if __name__ == "__main__": "dx", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -292,6 +305,7 @@ if __name__ == "__main__": "dx", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -303,6 +317,7 @@ if __name__ == "__main__": "dy", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -313,6 +328,7 @@ if __name__ == "__main__": "dy", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -324,6 +340,7 @@ if __name__ == "__main__": "dz", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) @@ -334,6 +351,7 @@ if __name__ == "__main__": "dz", cat, label, + args.directory, legend, lhcbtextpos=lhcbtextpos, ) diff --git a/Hlt/RecoConf/scripts/utils/pvutils.py b/Hlt/RecoConf/scripts/utils/pvutils.py index a644b226d3f36e23622e46b61b602081be1584ed..1bcce8c09e276247dfe322772679ee0a570a3922 100644 --- a/Hlt/RecoConf/scripts/utils/pvutils.py +++ b/Hlt/RecoConf/scripts/utils/pvutils.py @@ -15,6 +15,7 @@ # date: 02/2020 # +import os from array import array from pvconfig import ( @@ -168,6 +169,7 @@ def plot( dependence, categories, label, + dir, legend=None, hist=None, dist=False, @@ -228,8 +230,11 @@ def plot( lhcbtext.DrawTextNDC(lhcbtextpos[0], lhcbtextpos[1], "LHCb simulation") - saveName = "{prefix}_{dependence}_{cat}.pdf".format( - prefix=prefix, dependence=dependence, cat=cat + # ensure that dir exists + if not os.path.exists(dir): + os.makedirs(dir) + saveName = "{dir}/{prefix}_{dependence}_{cat}.pdf".format( + dir=dir, prefix=prefix, dependence=dependence, cat=cat ) can.SaveAs(saveName) @@ -331,6 +336,7 @@ def plot_comparison( style, norm, offset, + dir, simple=False, legend=None, ): @@ -400,8 +406,11 @@ def plot_comparison( pavetext.Draw() can.Update() - saveName = "{prefix}_{dependence}_{cat}.pdf".format( - prefix=prefix, dependence=dependence, cat=cat + # ensure that dir exists + if not os.path.exists(dir): + os.makedirs(dir) + saveName = "{dir}/{prefix}_{dependence}_{cat}.pdf".format( + dir=dir, prefix=prefix, dependence=dependence, cat=cat ) can.SaveAs(saveName) diff --git a/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking.qmt b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking.qmt index d446b1b54f5e334b2c2b2aab520d9fc4b5fa20bf..4f3a7aecab3ec21550db9fa3cda827b27ef53064 100644 --- a/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking.qmt +++ b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking.qmt @@ -10,8 +10,7 @@ or submit itself to any jurisdiction. --> gaudirun.py diff --git a/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking_SMOG.qmt b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking_SMOG.qmt index 862ab39c51447587a971fbf0375d767036706b4a..1af418a108fb00d215b7cec456f44d2998055d26 100644 --- a/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking_SMOG.qmt +++ b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking_SMOG.qmt @@ -10,8 +10,7 @@ or submit itself to any jurisdiction. --> gaudirun.py diff --git a/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking_beamshift.qmt b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking_beamshift.qmt index e555e2a6c0fe68607de2a8073c91d0ef8b961a93..d4b57899a42e0f472d578aba40e58c70e477ef6b 100644 --- a/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking_beamshift.qmt +++ b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_mcchecking_beamshift.qmt @@ -10,8 +10,7 @@ or submit itself to any jurisdiction. --> gaudirun.py diff --git a/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_prvelotracks_with_mcchecking.qmt b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_prvelotracks_with_mcchecking.qmt new file mode 100644 index 0000000000000000000000000000000000000000..c661dd9623479934c3471433b2efd305181ac950 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_prvelotracks_with_mcchecking.qmt @@ -0,0 +1,39 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $RECOCONFROOT/options/allen_gaudi_pv_with_prvelotracks.py + +true +../refs/allen_gaudi_pv_with_prvelotracks_with_mcchecking.ref +../refs/empty.ref + + +from Moore.qmtest.exclusions import ref_preprocessor +validateWithReference(preproc = ref_preprocessor) + +from Allen.qmtest.validators import check_PV_efficiency + +efficiency, fake_pv = check_PV_efficiency("$RECOCONFROOT/tests/refs/allen_gaudi_pv_with_prvelotracks_with_mcchecking_beamshift.ref", causes, "all") + +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/allen_gaudi_pv_with_prvelotracks_with_mcchecking_beamshift.qmt b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_prvelotracks_with_mcchecking_beamshift.qmt new file mode 100644 index 0000000000000000000000000000000000000000..2058840fcd5307ea37e7cd72957fa876d4dc1684 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/allen_gaudi_pv_with_prvelotracks_with_mcchecking_beamshift.qmt @@ -0,0 +1,39 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/mdf_input_and_conds_nominal_beamline_mc_expected_2024.py + $RECOCONFROOT/options/allen_gaudi_pv_with_prvelotracks.py + +true +../refs/allen_gaudi_pv_with_prvelotracks_with_mcchecking_beamshift.ref +../refs/empty.ref + + +from Moore.qmtest.exclusions import ref_preprocessor +validateWithReference(preproc = ref_preprocessor) + +from Allen.qmtest.validators import check_PV_efficiency + +efficiency, fake_pv = check_PV_efficiency("$RECOCONFROOT/tests/refs/allen_gaudi_pv_with_prvelotracks_with_mcchecking_beamshift.ref", causes, "all") + +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_convertedtracks_hlt2_pvs_vertex_compare.qmt b/Hlt/RecoConf/tests/qmtest/hlt1_convertedtracks_hlt2_pvs_vertex_compare.qmt new file mode 100644 index 0000000000000000000000000000000000000000..c2aea44b21857195fa2ed43be57321eb5f4eab55 --- /dev/null +++ b/Hlt/RecoConf/tests/qmtest/hlt1_convertedtracks_hlt2_pvs_vertex_compare.qmt @@ -0,0 +1,35 @@ + + + + +gaudirun.py + + $MOOREROOT/tests/options/default_input_and_conds_hlt1.py + $RECOCONFROOT/options/hlt1_convertedtracks_hlt2_pvs_vertex_compare.py + +true +../refs/hlt1_convertedtracks_hlt2_pvs_vertex_compare.ref +../refs/empty.ref + + +from Moore.qmtest.exclusions import ref_preprocessor +validateWithReference(preproc = ref_preprocessor) + +from Moore.qmtest.exclusions import remove_known_warnings +countErrorLines({"FATAL": 0, "ERROR": 0, "WARNING": 0}, + stdout=remove_known_warnings(stdout)) + + +