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.

128 lines
4.9 KiB

10 months ago
  1. from Moore import options, run_reconstruction
  2. from Moore.config import Reconstruction
  3. from PRConfig.TestFileDB import test_file_db
  4. from PyConf.Algorithms import (
  5. PrForwardTrackingVelo,
  6. PrForwardTracking,
  7. PrTrackAssociator,
  8. PrMatchNN,
  9. )
  10. from PyConf.application import make_data_with_FetchDataFromFile
  11. from PyConf.Tools import PrMCDebugForwardTool, PrMCDebugMatchToolNN
  12. from RecoConf.data_from_file import mc_unpackers
  13. from RecoConf.hlt1_tracking import make_hlt1_tracks, make_PrStoreSciFiHits_hits
  14. from RecoConf.hlt2_tracking import get_global_ut_hits_tool, make_PrHybridSeeding_tracks
  15. from RecoConf.mc_checking import make_links_lhcbids_mcparticles_tracking_system
  16. options.evt_max = -1
  17. n_files_per_cat = 1
  18. polarity = "MU"
  19. options.ntuple_file = f"data/ghost_data_{polarity}.root"
  20. input_files = (
  21. (
  22. test_file_db["upgrade_DC19_01_Bs2JPsiPhi_MD"].filenames[:n_files_per_cat]
  23. if polarity == "MD"
  24. else test_file_db["upgrade_DC19_01_Bs2JpsiPhiMU"].filenames[:n_files_per_cat]
  25. )
  26. + test_file_db[f"upgrade_DC19_01_Bs2PhiPhi{polarity}"].filenames[:n_files_per_cat]
  27. + test_file_db[f"upgrade_DC19_01_Z2mumu{polarity}"].filenames[:n_files_per_cat]
  28. + test_file_db[f"upgrade_DC19_01_Bd2Dstmumu{polarity}"].filenames[:n_files_per_cat]
  29. + test_file_db[f"upgrade_DC19_01_Dst2D0pi{polarity}"].filenames[:n_files_per_cat]
  30. + test_file_db[f"upgrade_DC19_01_Bd2Kstee{polarity}"].filenames[:n_files_per_cat]
  31. + test_file_db[f"upgrade_DC19_01_Dp2KSPip_{polarity}"].filenames[:n_files_per_cat]
  32. )
  33. options.input_files = input_files
  34. options.input_type = "ROOT"
  35. options.set_conds_from_testfiledb(f"upgrade_DC19_01_Dst2D0pi{polarity}")
  36. def run_tracking_debug():
  37. links_to_hits = make_links_lhcbids_mcparticles_tracking_system()
  38. hlt1_tracks = make_hlt1_tracks()
  39. seed_tracks = make_PrHybridSeeding_tracks()
  40. # add MCLinking to the (fitted) V1 tracks
  41. links_to_velo_tracks = PrTrackAssociator(
  42. SingleContainer=hlt1_tracks["Velo"]["v1"],
  43. LinkerLocationID=links_to_hits,
  44. MCParticleLocation=mc_unpackers()["MCParticles"],
  45. MCVerticesInput=mc_unpackers()["MCVertices"],
  46. ).OutputLocation
  47. links_to_upstream_tracks = PrTrackAssociator(
  48. SingleContainer=hlt1_tracks["Upstream"]["v1"],
  49. LinkerLocationID=links_to_hits,
  50. MCParticleLocation=mc_unpackers()["MCParticles"],
  51. MCVerticesInput=mc_unpackers()["MCVertices"],
  52. ).OutputLocation
  53. links_to_seed_tracks = PrTrackAssociator(
  54. SingleContainer=seed_tracks["v1"],
  55. LinkerLocationID=links_to_hits,
  56. MCParticleLocation=mc_unpackers()["MCParticles"],
  57. MCVerticesInput=mc_unpackers()["MCVertices"],
  58. ).OutputLocation
  59. # be more robust against imperfect data
  60. loose_forward_params = dict(
  61. MaxChi2PerDoF=16,
  62. MaxChi2XProjection=30,
  63. MaxChi2PerDoFFinal=8,
  64. MaxChi2Stereo=8,
  65. MaxChi2StereoAdd=8,
  66. )
  67. forward_debug = PrForwardTrackingVelo(
  68. InputTracks=hlt1_tracks["Velo"]["Pr"],
  69. SciFiHits=make_PrStoreSciFiHits_hits(),
  70. AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
  71. DebugTool=PrMCDebugForwardTool(
  72. InputTracks=hlt1_tracks["Velo"]["v1"],
  73. InputTrackLinks=links_to_velo_tracks,
  74. MCParticles=mc_unpackers()["MCParticles"],
  75. SciFiHitLinks=links_to_hits,
  76. SciFiHits=make_PrStoreSciFiHits_hits(),
  77. TrackInfo=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"),
  78. ),
  79. **loose_forward_params,
  80. )
  81. forward_ut_debug = PrForwardTracking(
  82. SciFiHits=make_PrStoreSciFiHits_hits(),
  83. InputTracks=hlt1_tracks["Upstream"]["Pr"],
  84. AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
  85. DebugTool=PrMCDebugForwardTool(
  86. InputTracks=hlt1_tracks["Upstream"]["v1"],
  87. InputTrackLinks=links_to_upstream_tracks,
  88. MCParticles=mc_unpackers()["MCParticles"],
  89. SciFiHitLinks=links_to_hits,
  90. SciFiHits=make_PrStoreSciFiHits_hits(),
  91. TrackInfo=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"),
  92. ),
  93. **loose_forward_params,
  94. )
  95. loose_matching_params = dict(MaxMatchChi2=30.0, MaxDistX=500, MaxDistY=500)
  96. match_debug = PrMatchNN(
  97. VeloInput=hlt1_tracks["Velo"]["Pr"],
  98. SeedInput=seed_tracks["Pr"],
  99. MatchDebugToolName=PrMCDebugMatchToolNN(
  100. VeloTracks=hlt1_tracks["Velo"]["v1"],
  101. SeedTracks=seed_tracks["v1"],
  102. VeloTrackLinks=links_to_velo_tracks,
  103. SeedTrackLinks=links_to_seed_tracks,
  104. TrackInfo=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"),
  105. MCParticles=mc_unpackers()["MCParticles"],
  106. ),
  107. AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
  108. **loose_matching_params,
  109. ).MatchOutput
  110. data = [forward_debug, forward_ut_debug, match_debug]
  111. return Reconstruction("run_tracking_debug", data)
  112. run_reconstruction(options, run_tracking_debug)