############################################################################### # (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 multiprocessing import os import glob from RecoConf.data_from_file import mc_unpackers mc_unpackers.global_bind(packed_data=True) # set to False for unpacked data from Configurables import LHCb__Det__LbDD4hep__DD4hepSvc as DD4hepSvc from Moore import options, run_reconstruction from Moore.config import Reconstruction from PyConf.Algorithms import TracksToSelection from RecoConf.upgrade2_reconstruction import ( get_upgrade2_hlt2_tracks, tracking_efficiency, ) from RecoConf.rich_data_monitoring import ( default_rich_monitoring_options, make_rich_pixel_monitors, make_rich_track_monitors, ) from RecoConf.rich_reconstruction import ( make_rich_clusters, make_rich_tracks, default_rich_reco_options, get_detector_bool_opts, make_rich_pids, ) from RecoConf.rich_mc_checking import ( track_to_MCP_rels, default_rich_checking_options, make_rich_checkers, make_track_links, ) from RecoConf.rich_reconstruction_mc_cheat import ( default_mc_reco_cheat_options, decoded_data_add_MC_time, emulated_raw_from_MC, make_photon_candidates_with_mc_info, make_rich_pixels_with_mc_positions, make_rich_track_segments_add_MC_time, make_rich_track_segments_from_MC, ) from RecoConf.mc_checking import make_links_tracks_mcparticles from PyConf.Algorithms import MergeFourLinks from RecoConf.upgrade2_fetch_from_file import get_mc_particles # Turn on/off 4D reco for the RICH enable4D = False def test_standalone_tracking_RICH(do_data_monitoring=True, do_mc_checking=True): # The list of algs to explicitly request to be run algs_to_run = [] # Default RICH reco options reco_opts = default_rich_reco_options() # Add default special options in case of MC cheated Reco reco_opts.update(default_mc_reco_cheat_options()) # This is never DetDesc MC for U2 reco_opts["IsDetDescMC"] = False # Enable slightly wider side bands in the RICH reco_opts["PhotonSelection"] == "Online" # Make U2 tracks hlt2_tracks = get_upgrade2_hlt2_tracks() # Get the "MatchMT" tracks tkType = "Long" tks = hlt2_tracks["MatchMT"] # The track type we use track_version = "v1" # Track selection tkSel = TracksToSelection(InputLocation=tks[track_version]) # save original unfilter track handle reco_opts["OriginalV1Tracks"] = tks[track_version] # tracks to pass to RICH tksToUse = tkSel.OutputLocation # Local lambda to get the LHCbID links for our U2 tracks def get_lhcbid_links_U2(unused_var=True): ### 'unsued_var' is becasue get_lhcbid_links has a useUT flag ### Eventually we need to remove all these 'useUT' options entirely. tv_links = hlt2_tracks["Velo"]["ClusterLinks"] ft_links = hlt2_tracks["FT"]["ClusterLinks"] mp_links = hlt2_tracks["MP"]["ClusterLinks"] up_links = hlt2_tracks["UP"]["ClusterLinks"] return MergeFourLinks( InLinks1=tv_links, InLinks2=ft_links, InLinks3=mp_links, InLinks4=up_links, MCParticleLocation=get_mc_particles(), ).Links # Enable 4D reco for the RICH if enable4D: reco_opts["Enable4DReco"] = (enable4D, enable4D) # Enable algorithms to add time to pixels and tracks make_track_links.global_bind(lhcbid_links=get_lhcbid_links_U2) make_rich_clusters.global_bind(decode=decoded_data_add_MC_time) make_rich_tracks.global_bind(segments=make_rich_track_segments_add_MC_time) # RICH photon reco conf = make_rich_pids(track_name=tkType, input_tracks=tksToUse, options=reco_opts) # Ensure if nothng else the RICH Reco sequence will run algs_to_run += [conf["RichPIDs"]] # Build U2 tracking links ourselves if "RichTrackMCPartLinks" not in conf.keys(): conf["RichTrackMCPartLinks"] = make_links_tracks_mcparticles( tks[track_version], LinksToLHCbIDs=get_lhcbid_links_U2() ) # CK Theta resolution range to use. # Extended if Online mode else use default. CKResHistoRange = ( (0.0055, 0.0035) if reco_opts["PhotonSelection"] == "Online" else None ) # list of configured monitors and checkers moni_check_algs = {} if do_data_monitoring: # Data monitoring options moni_opts = default_rich_monitoring_options() # Set the histogram set for the data monitoring moni_set = "Expert" # CK theta window in plots if CKResHistoRange: moni_opts["CKResHistoRange"] = CKResHistoRange # Make monitors moni_check_algs.update( make_rich_track_monitors( conf=conf, reco_opts=reco_opts, moni_opts=moni_opts, moni_set=moni_set, ) ) moni_check_algs.update( make_rich_pixel_monitors( conf=conf, reco_opts=reco_opts, moni_opts=moni_opts, moni_set=moni_set, ) ) if do_mc_checking: # Tracking # for det in ["TV","FT","MP","MT"] : for det in ["MT"] : moni_check_algs[det+"-EFF"] = tracking_efficiency(det, hlt2_tracks[det]) # RICH # MC Checking options check_opts = default_rich_monitoring_options() check_opts.update(default_rich_checking_options()) check_opts["IsDetDescMC"] = reco_opts["IsDetDescMC"] # CK theta window in plots if CKResHistoRange: check_opts["CKResHistoRange"] = CKResHistoRange # checking options check_opts["DetailedHistograms"] = False # Set the histogram set for MC checking moni_set = "Expert" # make the checkers moni_check_algs.update( make_rich_checkers( conf=conf, reco_opts=reco_opts, check_opts=check_opts, moni_set=moni_set, ) ) # finally extract the final algorithm instances from the dict and # add the the overall list passed to the scheduler to run. algs_to_run += [v for _, v in sorted(moni_check_algs.items())] # Return the final configuration return Reconstruction("U2_track_rich_reco", algs_to_run, []) # WP6 data options.input_type = "ROOT" options.evt_max = 1000 options.print_freq = 100 options.simulation = True #options.n_threads = multiprocessing.cpu_count() options.n_threads = 1 options.ntuple_file = "tuple_reco_baseline.root" DD4hepSvc().DetectorList = [ "/world", "TV", "UP", "FT", "MP", "Magnet", "Rich1", "Rich2", ] # WP6 data # options.conditions_version = "sim11/run5-ideal" # options.geometry_version = "run5/branch-baseline" # camPath = "/usera/jonesc/NFS/data/MC/UpgradeII" # eosPath = "root://eoslhcb.cern.ch//eos/lhcb/wg/rta" # usePath = camPath if os.path.exists(camPath) else eosPath # options.input_files = [ # usePath + "/WP6/UII/Beam7000GeV-md100-nu54-VerExtAngle/30000000/tv-baseline/boole/Boole_0.digi" # ] # Sajan Run5 RICH data options.conditions_version = "sim11/run5-ideal" options.geometry_version = "run5/Rich/v4/trunk" camPath = ( "/usera/jonesc/NFS/data/MC/UpgradeII/seaso/Run5-track/SeriesP-RichMapmt/DigiFiles/" ) eosPath = "/eos/lhcb/user/s/seaso/BooleOutput/Run5-track/SeriesP-RichMapmt/DigiFiles/" usePath = camPath if os.path.exists(camPath) else eosPath options.input_files = sorted(glob.glob(usePath + "*.digi")) options.histo_file = "Track-RICH-U2.histos.root" options.ntuple_file = "Track-RICH-U2.tuples.root" run_reconstruction(options, test_standalone_tracking_RICH)