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.

164 lines
5.3 KiB

8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
8 months ago
8 months ago
7 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
8 months ago
7 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 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 = "testJpsi"
  41. options.evt_max = -1
  42. options.ntuple_file = f"/work/cetin/LHCb/reco_tuner/data_matching/sample4_data/calo_data_{decay}_filter_shower_dll_NegFive_mlp_NullFive.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 == "testJpsi":
  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(0) @ F.WEIGHT) > 0.7)
  96. Relation=eshower["Ttrack"],
  97. Cut=F.FILTER(((F.GET(1) @ F.WEIGHT) > -5)), # & ((F.GET(0) @ F.WEIGHT) > 0.5)),
  98. ).Output
  99. matched_seeds = {}
  100. matched_seeds["v3"] = shower_matched_seeds
  101. matched_seeds["v1"] = fromV3TrackV1Track(
  102. InputTracks=matched_seeds["v3"]
  103. ).OutputTracks
  104. matching_params = dict(
  105. MinMatchNN=0.5, # NN response cut value
  106. )
  107. calo_long = PrMatchNNv3(
  108. VeloInput=hlt2_tracks["Velo"]["Pr"],
  109. SeedInput=matched_seeds["v3"],
  110. AddUTHitsToolName=get_global_ut_hits_tool(),
  111. **matching_params,
  112. ).MatchOutput
  113. match_tracks = {}
  114. match_tracks["Pr"] = calo_long
  115. match_tracks["v1"] = fromPrMatchTracksV1Tracks(
  116. InputTracksLocation=match_tracks["Pr"],
  117. VeloTracksLocation=hlt2_tracks["Velo"]["v1"],
  118. SeedTracksLocation=matched_seeds["v1"],
  119. ).OutputTracksLocation
  120. out_track_types = get_default_out_track_types_for_light_reco()
  121. best_tracks = {
  122. track_type: hlt2_tracks[track_type] for track_type in out_track_types["Best"]
  123. }
  124. data = [
  125. calo_long,
  126. calo_matched_seeds,
  127. electron_matched_seeds,
  128. shower_matched_seeds,
  129. ]
  130. # data = [shower_matched_seeds]
  131. types_and_locations_for_checkers = {
  132. "Forward": hlt2_tracks["Forward"],
  133. "Seed": hlt2_tracks["Seed"],
  134. "Match": match_tracks, # hlt2_tracks["Match"],
  135. }
  136. data += get_track_checkers(types_and_locations_for_checkers)
  137. # data += get_fitted_tracks_checkers(best_tracks)
  138. return Reconstruction("hlt2_reco", data, [require_gec()])
  139. run_reconstruction(options, standalone_hlt2_fastest_reco)