You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
4.7 KiB

10 months ago
  1. ###############################################################################
  2. # (c) Copyright 2023 CERN for the benefit of the LHCb Collaboration #
  3. # #
  4. # This software is distributed under the terms of the GNU General Public #
  5. # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
  6. # #
  7. # In applying this licence, CERN does not waive the privileges and immunities #
  8. # granted to it by virtue of its status as an Intergovernmental Organization #
  9. # or submit itself to any jurisdiction. #
  10. ###############################################################################
  11. # flake8: noqa
  12. from Moore import options, run_reconstruction
  13. from Moore.config import Reconstruction
  14. from RecoConf.data_from_file import mc_unpackers
  15. from RecoConf.hlt1_tracking import make_VeloClusterTrackingSIMD_hits
  16. from RecoConf.hlt2_tracking import (
  17. make_hlt2_tracks,
  18. make_PrKalmanFilter_tracks,
  19. make_PrStorePrUTHits_hits,
  20. make_PrStoreSciFiHits_hits,
  21. )
  22. from RecoConf.mc_checking import (
  23. make_links_lhcbids_mcparticles_tracking_system,
  24. make_links_tracks_mcparticles,
  25. make_default_IdealStateCreator,
  26. )
  27. from PyConf.Algorithms import PrTrackAssociator, PrDebugTrackingLosses
  28. from PyConf.application import make_data_with_FetchDataFromFile
  29. import glob
  30. decay = "B"
  31. if decay == "B":
  32. options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi")
  33. elif decay == "D":
  34. options.input_files = glob.glob("/auto/data/guenther/Dst_D0ee/*.xdigi")
  35. elif decay == "test":
  36. options.input_files = ["/auto/data/guenther/Bd_Kstee/00151673_00000002_1.xdigi"]
  37. options.conddb_tag = "sim-20210617-vc-md100"
  38. options.dddb_tag = "dddb-20210617"
  39. options.simulation = True
  40. options.input_type = "ROOT"
  41. options.ntuple_file = f"data/tracking_losses_ntuple_{decay}.root"
  42. options.evt_max = -1
  43. # run with
  44. # ./Moore/run gaudirun.py Moore/Hlt/RecoConf/options/tracking_developments/run_pr_tracking_losses.py
  45. # tested by mc_matching_example.py
  46. def run_tracking_losses():
  47. links_to_hits = make_links_lhcbids_mcparticles_tracking_system()
  48. hlt2_tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True)
  49. vp_hits = make_VeloClusterTrackingSIMD_hits()
  50. ut_hits = make_PrStorePrUTHits_hits()
  51. ft_hits = make_PrStoreSciFiHits_hits()
  52. fitted_match_tracks = make_PrKalmanFilter_tracks( # fitted_forward_tracks
  53. input_tracks=hlt2_tracks["Match"]["Pr"], # Forward
  54. hits_vp=vp_hits,
  55. hits_ut=ut_hits,
  56. hits_ft=ft_hits,
  57. )
  58. # add MCLinking to the (fitted) V1 tracks
  59. links_to_velo_tracks = PrTrackAssociator(
  60. SingleContainer=hlt2_tracks["Velo"]["v1"],
  61. LinkerLocationID=links_to_hits,
  62. MCParticleLocation=mc_unpackers()["MCParticles"],
  63. MCVerticesInput=mc_unpackers()["MCVertices"],
  64. ).OutputLocation
  65. links_to_long_tracks = PrTrackAssociator(
  66. SingleContainer=hlt2_tracks["Match"]["v1"], # Forward
  67. LinkerLocationID=links_to_hits,
  68. MCParticleLocation=mc_unpackers()["MCParticles"],
  69. MCVerticesInput=mc_unpackers()["MCVertices"],
  70. ).OutputLocation
  71. with PrTrackAssociator.bind(FractionOK=0.5):
  72. loose_links_to_long_tracks = PrTrackAssociator(
  73. SingleContainer=hlt2_tracks["Match"]["v1"], # Forward
  74. LinkerLocationID=links_to_hits,
  75. MCParticleLocation=mc_unpackers()["MCParticles"],
  76. MCVerticesInput=mc_unpackers()["MCVertices"],
  77. ).OutputLocation
  78. links_to_fitted_tracks = PrTrackAssociator(
  79. SingleContainer=fitted_match_tracks, # fitted_forward_tracks
  80. LinkerLocationID=links_to_hits,
  81. MCParticleLocation=mc_unpackers()["MCParticles"],
  82. MCVerticesInput=mc_unpackers()["MCVertices"],
  83. ).OutputLocation
  84. tracking_losses = PrDebugTrackingLosses(
  85. name="PrDebugTrackingLosses",
  86. TrackType="Long",
  87. StudyTracks=hlt2_tracks["Match"]["v1"], # Forward
  88. VeloTracks=hlt2_tracks["Velo"]["v1"],
  89. MCParticles=mc_unpackers()["MCParticles"],
  90. MCVPHits=mc_unpackers()["MCVPHits"],
  91. MCUTHits=mc_unpackers()["MCUTHits"],
  92. MCFTHits=mc_unpackers()["MCFTHits"],
  93. VeloTrackLinks=links_to_velo_tracks,
  94. TrackLinks=links_to_long_tracks,
  95. LooseTrackLinks=loose_links_to_long_tracks,
  96. FittedTrackLinks=links_to_fitted_tracks,
  97. # LHCbIDLinks=links_to_hits,
  98. IdealStateCreator=make_default_IdealStateCreator(),
  99. TrackInfo=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"),
  100. )
  101. data = [tracking_losses]
  102. return Reconstruction("run_tracking_losses", data)
  103. run_reconstruction(options, run_tracking_losses)