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.

211 lines
6.1 KiB

8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
  1. # flake8: noqa
  2. from Moore import options, run_reconstruction
  3. from Moore.config import Reconstruction
  4. from PyConf.Algorithms import PrKalmanFilter, PrMatchNN, fromPrMatchTracksV1Tracks
  5. from PyConf.Tools import TrackMasterExtrapolator, PrMCDebugMatchToolNN
  6. from PyConf.application import make_data_with_FetchDataFromFile
  7. from RecoConf.data_from_file import mc_unpackers
  8. import glob
  9. from RecoConf.mc_checking import (
  10. check_track_resolution,
  11. check_tracking_efficiency,
  12. get_mc_categories,
  13. get_hit_type_mask,
  14. make_links_lhcbids_mcparticles_tracking_system,
  15. make_links_tracks_mcparticles,
  16. get_track_checkers,
  17. )
  18. from RecoConf.core_algorithms import make_unique_id_generator
  19. from RecoConf.hlt2_tracking import make_hlt2_tracks, get_global_ut_hits_tool
  20. from RecoConf.hlt1_tracking import (
  21. make_VeloClusterTrackingSIMD_hits,
  22. make_PrStorePrUTHits_hits,
  23. make_PrStoreSciFiHits_hits,
  24. get_global_materiallocator,
  25. )
  26. """
  27. This set of options is used for reconstruction development purposes,
  28. and assumes that the input contains MCHits (i.e. is of `Exended`
  29. DST/digi type).
  30. author: Furkan Cetin
  31. date: 10/2023
  32. Moore/run gaudirun.py /work/cetin/LHCb/reco_tuner/moore_options/get_resolution_and_eff_data.py
  33. """
  34. decay = "test"
  35. options.evt_max = -1
  36. options.ntuple_file = f"data/resolutions_and_effs_{decay}_preselect_ttracks.root"
  37. options.input_type = "ROOT"
  38. if decay == "B":
  39. options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi")
  40. elif decay == "BJpsi":
  41. options.input_files = glob.glob("/auto/data/guenther/Bd_JpsiKst_ee/*.xdigi")
  42. elif decay == "D":
  43. options.input_files = glob.glob("/auto/data/guenther/Dst_D0ee/*.xdigi")
  44. elif decay == "test2":
  45. options.input_files = [
  46. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000009_1.xdigi"
  47. ]
  48. elif decay == "test":
  49. options.input_files = ["/auto/data/guenther/Bd_Kstee/00151673_00000002_1.xdigi"]
  50. options.dddb_tag = "dddb-20210617"
  51. options.conddb_tag = "sim-20210617-vc-md100"
  52. options.simulation = True
  53. options.output_level = 3
  54. def run_tracking_resolution():
  55. tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True)
  56. fitted_forward_tracks = PrKalmanFilter(
  57. Input=tracks["Forward"]["Pr"],
  58. MaxChi2=2.8,
  59. MaxChi2PreOutlierRemoval=20,
  60. HitsVP=make_VeloClusterTrackingSIMD_hits(),
  61. HitsUT=make_PrStorePrUTHits_hits(),
  62. HitsFT=make_PrStoreSciFiHits_hits(),
  63. ReferenceExtrapolator=TrackMasterExtrapolator(
  64. MaterialLocator=get_global_materiallocator(),
  65. ),
  66. InputUniqueIDGenerator=make_unique_id_generator(),
  67. ).OutputTracks
  68. links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system()
  69. links_to_best = make_links_tracks_mcparticles(
  70. InputTracks=tracks["BestLong"],
  71. LinksToLHCbIDs=links_to_lhcbids,
  72. )
  73. links_to_forward = make_links_tracks_mcparticles(
  74. InputTracks=tracks["Forward"],
  75. LinksToLHCbIDs=links_to_lhcbids,
  76. )
  77. links_to_velo = make_links_tracks_mcparticles(
  78. InputTracks=tracks["Velo"],
  79. LinksToLHCbIDs=links_to_lhcbids,
  80. )
  81. links_to_seed = make_links_tracks_mcparticles(
  82. InputTracks=tracks["Seed"],
  83. LinksToLHCbIDs=links_to_lhcbids,
  84. )
  85. match_debug = PrMatchNN(
  86. VeloInput=tracks["Velo"]["Pr"],
  87. SeedInput=tracks["Seed"]["Pr"],
  88. MatchDebugToolName=PrMCDebugMatchToolNN(
  89. VeloTracks=tracks["Velo"]["v1"],
  90. SeedTracks=tracks["Seed"]["v1"],
  91. VeloTrackLinks=links_to_velo,
  92. SeedTrackLinks=links_to_seed,
  93. TrackInfo=make_data_with_FetchDataFromFile(
  94. "/Event/MC/TrackInfo", "LHCb::MCProperty"
  95. ),
  96. MCParticles=mc_unpackers()["MCParticles"],
  97. ),
  98. AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
  99. ).MatchOutput
  100. match_tracks = {}
  101. match_tracks["Pr"] = match_debug
  102. match_tracks["v1"] = fromPrMatchTracksV1Tracks(
  103. InputTracksLocation=match_debug,
  104. VeloTracksLocation=tracks["Velo"]["v1"],
  105. SeedTracksLocation=tracks["Seed"]["v1"],
  106. ).OutputTracksLocation
  107. links_to_match = make_links_tracks_mcparticles(
  108. InputTracks=match_tracks,
  109. LinksToLHCbIDs=links_to_lhcbids,
  110. )
  111. res_checker_forward = check_track_resolution(
  112. tracks["Forward"],
  113. suffix="Forward",
  114. )
  115. res_checker_best_long = check_track_resolution(
  116. tracks["BestLong"],
  117. suffix="BestLong",
  118. )
  119. res_checker_best_forward = check_track_resolution(
  120. dict(v1=fitted_forward_tracks),
  121. suffix="BestForward",
  122. )
  123. res_checker_seed = check_track_resolution(
  124. tracks["Seed"],
  125. suffix="Seed",
  126. )
  127. eff_checker_forward = check_tracking_efficiency(
  128. "Forward",
  129. tracks["Forward"],
  130. links_to_forward,
  131. links_to_lhcbids,
  132. get_mc_categories("Forward"),
  133. get_hit_type_mask("Forward"),
  134. )
  135. eff_checker_match = check_tracking_efficiency(
  136. "Match",
  137. match_tracks,
  138. links_to_match,
  139. links_to_lhcbids,
  140. get_mc_categories("Match"),
  141. get_hit_type_mask("Match"),
  142. )
  143. eff_checker_best_long = check_tracking_efficiency(
  144. "BestLong",
  145. tracks["BestLong"],
  146. links_to_best,
  147. links_to_lhcbids,
  148. get_mc_categories("BestLong"),
  149. get_hit_type_mask("BestLong"),
  150. )
  151. eff_checker_seed = check_tracking_efficiency(
  152. "Seed",
  153. tracks["Seed"],
  154. links_to_seed,
  155. links_to_lhcbids,
  156. get_mc_categories("Seed"),
  157. get_hit_type_mask("Seed"),
  158. )
  159. types_and_locations_for_checkers = {
  160. "Forward": tracks["Forward"],
  161. "Seed": tracks["Seed"],
  162. "Match": match_tracks,
  163. }
  164. data = []
  165. data += get_track_checkers(types_and_locations_for_checkers)
  166. # data = [
  167. # res_checker_forward,
  168. # res_checker_best_long,
  169. # res_checker_best_forward,
  170. # res_checker_seed,
  171. # eff_checker_forward,
  172. # eff_checker_match,
  173. # eff_checker_best_long,
  174. # eff_checker_seed,
  175. # ]
  176. return Reconstruction("run_tracking_debug", data)
  177. run_reconstruction(options, run_tracking_resolution)