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.

173 lines
5.5 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. # flake8: noqa
  2. from Moore import options, run_reconstruction
  3. from RecoConf.hlt2_tracking import (
  4. make_hlt2_tracks,
  5. get_default_out_track_types_for_light_reco,
  6. convert_tracks_to_v3_from_v1,
  7. get_global_ut_hits_tool,
  8. )
  9. from RecoConf.hlt1_tracking import make_all_pvs
  10. from RecoConf.event_filters import require_gec
  11. from RecoConf.mc_checking import (
  12. get_track_checkers,
  13. get_fitted_tracks_checkers,
  14. check_tracking_efficiency,
  15. make_links_lhcbids_mcparticles_tracking_system,
  16. make_links_tracks_mcparticles,
  17. get_mc_categories,
  18. get_hit_type_mask,
  19. )
  20. from RecoConf.calorimeter_reconstruction import (
  21. make_photons_and_electrons,
  22. make_clusters,
  23. make_acceptance,
  24. make_track_cluster_matching,
  25. make_digits,
  26. make_track_electron_and_brem_matching,
  27. make_trackbased_eshower,
  28. )
  29. from Moore.config import Reconstruction
  30. from PyConf.Algorithms import (
  31. PrFilterTracks2CaloClusters,
  32. PrMatchNNv3,
  33. PrFilterTracks2ElectronMatch,
  34. PrFilterTracks2ElectronShower,
  35. fromPrMatchTracksV1Tracks,
  36. fromV3TrackV1Track,
  37. )
  38. import Functors as F
  39. import glob
  40. decay = "BJpsi"
  41. options.evt_max = -1
  42. options.ntuple_file = f"data/calo_data_{decay}_filter_shower_dll.root"
  43. if decay == "B":
  44. options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi")
  45. elif decay == "BJpsi":
  46. options.input_files = glob.glob("/auto/data/guenther/Bd_JpsiKst_ee/*.xdigi")
  47. elif decay == "D":
  48. options.input_files = glob.glob("/auto/data/guenther/Dst_D0ee/*.xdigi")
  49. elif decay == "test2":
  50. options.input_files = [
  51. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000009_1.xdigi",
  52. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000059_1.xdigi",
  53. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000020_1.xdigi",
  54. ]
  55. elif decay == "test":
  56. options.input_files = ["/auto/data/guenther/Bd_Kstee/00151673_00000002_1.xdigi"]
  57. options.input_type = "ROOT"
  58. options.dddb_tag = "dddb-20210617"
  59. options.conddb_tag = "sim-20210617-vc-md100"
  60. options.simulation = True
  61. def standalone_hlt2_fastest_reco():
  62. hlt2_tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True)
  63. digisEcal = make_digits(calo_raw_bank=False)["digitsEcal"]
  64. ecalClusters = make_clusters(digisEcal)
  65. tracks_v3, trackrels = convert_tracks_to_v3_from_v1(
  66. hlt2_tracks["Seed"]["v1"],
  67. track_types=["Ttrack"],
  68. )
  69. # track acceptances
  70. tracks_incalo = make_acceptance(tracks_v3)
  71. tcmatches = make_track_cluster_matching(ecalClusters, tracks_incalo)
  72. PhElOutput = make_photons_and_electrons(
  73. ecalClusters, tcmatches["combined"], make_all_pvs()["v3"]
  74. )
  75. photons = PhElOutput["photons"]
  76. electrons = PhElOutput["electrons"]
  77. eshower = make_trackbased_eshower(tracks_incalo, digisEcal)
  78. tcmatches_e = make_track_electron_and_brem_matching(
  79. tracks_incalo, tcmatches, digisEcal, electrons, photons
  80. )
  81. # filter with calo clusters
  82. calo_matched_seeds = PrFilterTracks2CaloClusters(
  83. Relation=tcmatches["Ttrack"],
  84. Cut=F.FILTER((F.MIN_ELEMENT_NOTZERO @ F.FORWARDARG0 @ F.WEIGHT) < 20),
  85. ).Output
  86. # corrections on track (bit better for elec?)
  87. # Cut=F.FILTER(F.ALL) ).Output
  88. electron_matched_seeds = PrFilterTracks2ElectronMatch(
  89. Relation=tcmatches_e["Ttrack"]["ElectronMatch"],
  90. Cut=F.FILTER(F.MIN_ELEMENT_NOTZERO @ F.FORWARDARG0 @ F.WEIGHT < 20),
  91. ).Output
  92. # should be best; shape of shower etc; E/p statt chi2; DLL even better? GET(1)
  93. # Cut=F.FILTER(F.ALL)).Output
  94. shower_matched_seeds = PrFilterTracks2ElectronShower(
  95. Relation=eshower["Ttrack"], Cut=F.FILTER((F.GET(1) @ F.WEIGHT) > 0.7)
  96. ).Output
  97. matched_seeds = {}
  98. matched_seeds["v3"] = shower_matched_seeds
  99. matched_seeds["v1"] = fromV3TrackV1Track(
  100. InputTracks=matched_seeds["v3"]
  101. ).OutputTracks
  102. calo_long = PrMatchNNv3(
  103. VeloInput=hlt2_tracks["Velo"]["Pr"],
  104. SeedInput=matched_seeds["v3"],
  105. AddUTHitsToolName=get_global_ut_hits_tool(),
  106. ).MatchOutput
  107. match_tracks = {}
  108. match_tracks["Pr"] = calo_long
  109. match_tracks["v1"] = fromPrMatchTracksV1Tracks(
  110. InputTracksLocation=match_tracks["Pr"],
  111. VeloTracksLocation=hlt2_tracks["Velo"]["v1"],
  112. SeedTracksLocation=matched_seeds["v1"],
  113. ).OutputTracksLocation
  114. out_track_types = get_default_out_track_types_for_light_reco()
  115. best_tracks = {
  116. track_type: hlt2_tracks[track_type] for track_type in out_track_types["Best"]
  117. }
  118. # links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system()
  119. # links_to_match = make_links_tracks_mcparticles(
  120. # InputTracks=match_tracks,
  121. # LinksToLHCbIDs=links_to_lhcbids,
  122. # )
  123. # eff_checker_match = check_tracking_efficiency(
  124. # "Match",
  125. # match_tracks,
  126. # links_to_match,
  127. # links_to_lhcbids,
  128. # get_mc_categories("Match"),
  129. # get_hit_type_mask("Match"),
  130. # )
  131. data = [
  132. calo_long,
  133. calo_matched_seeds,
  134. electron_matched_seeds,
  135. shower_matched_seeds,
  136. # eff_checker_match,
  137. ]
  138. # data = [shower_matched_seeds]
  139. types_and_locations_for_checkers = {
  140. "Forward": hlt2_tracks["Forward"],
  141. "Seed": hlt2_tracks["Seed"],
  142. "Match": match_tracks, # hlt2_tracks["Match"],
  143. }
  144. data += get_track_checkers(types_and_locations_for_checkers)
  145. # data += get_fitted_tracks_checkers(best_tracks)
  146. return Reconstruction("hlt2_reco", data, [require_gec()])
  147. run_reconstruction(options, standalone_hlt2_fastest_reco)