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.6 KiB

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
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
  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"/work/cetin/LHCb/reco_tuner/data_matching/NewParams/calo_data_{decay}_NewParams.root" # _dll_NegThree_mlp_NullSix.root"
  43. options.ntuple_file = f"/work/cetin/LHCb/reco_tuner/efficiencies/electrons/calo_effs_{decay}_EcalSelection.root"
  44. # options.ntuple_file = f"data/calo_effs_{decay}.root"
  45. if decay == "B":
  46. options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi")
  47. elif decay == "BJpsi":
  48. options.input_files = glob.glob("/auto/data/guenther/Bd_JpsiKst_ee/*.xdigi")
  49. elif decay == "D":
  50. options.input_files = glob.glob("/auto/data/guenther/Dst_D0ee/*.xdigi")
  51. elif decay == "testJpsi":
  52. options.input_files = [
  53. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000009_1.xdigi",
  54. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000059_1.xdigi",
  55. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000020_1.xdigi",
  56. ]
  57. elif decay == "test":
  58. options.input_files = ["/auto/data/guenther/Bd_Kstee/00151673_00000002_1.xdigi"]
  59. options.input_type = "ROOT"
  60. options.dddb_tag = "dddb-20210617"
  61. options.conddb_tag = "sim-20210617-vc-md100"
  62. options.simulation = True
  63. def standalone_hlt2_fastest_reco():
  64. hlt2_tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True)
  65. digisEcal = make_digits(calo_raw_bank=False)["digitsEcal"]
  66. ecalClusters = make_clusters(digisEcal)
  67. tracks_v3, trackrels = convert_tracks_to_v3_from_v1(
  68. hlt2_tracks["Seed"]["v1"],
  69. track_types=["Ttrack"],
  70. )
  71. # track acceptances
  72. tracks_incalo = make_acceptance(tracks_v3)
  73. tcmatches = make_track_cluster_matching(ecalClusters, tracks_incalo)
  74. PhElOutput = make_photons_and_electrons(
  75. ecalClusters, tcmatches["combined"], make_all_pvs()["v3"]
  76. )
  77. photons = PhElOutput["photons"]
  78. electrons = PhElOutput["electrons"]
  79. eshower = make_trackbased_eshower(tracks_incalo, digisEcal)
  80. tcmatches_e = make_track_electron_and_brem_matching(
  81. tracks_incalo, tcmatches, digisEcal, electrons, photons
  82. )
  83. # filter with calo clusters
  84. calo_matched_seeds = PrFilterTracks2CaloClusters(
  85. Relation=tcmatches["Ttrack"],
  86. Cut=F.FILTER((F.MIN_ELEMENT_NOTZERO @ F.FORWARDARG0 @ F.WEIGHT) < 20),
  87. ).Output
  88. # corrections on track (bit better for elec?)
  89. # Cut=F.FILTER(F.ALL) ).Output
  90. electron_matched_seeds = PrFilterTracks2ElectronMatch(
  91. Relation=tcmatches_e["Ttrack"]["ElectronMatch"],
  92. Cut=F.FILTER(F.MIN_ELEMENT_NOTZERO @ F.FORWARDARG0 @ F.WEIGHT < 20),
  93. ).Output
  94. # should be best; shape of shower etc; E/p statt chi2; DLL even better? GET(1)
  95. # Cut=F.FILTER(F.ALL)).Output
  96. shower_matched_seeds = PrFilterTracks2ElectronShower(
  97. # Relation=eshower["Ttrack"], Cut=F.FILTER((F.GET(0) @ F.WEIGHT) > 0.7)
  98. Relation=eshower["Ttrack"],
  99. Cut=F.FILTER(
  100. ((F.GET(0) @ F.WEIGHT) > 0.7) | ((F.GET(1) @ F.WEIGHT) > -2)
  101. ), # | ((F.GET(0) @ F.WEIGHT) > 0.7)),
  102. ).Output
  103. matched_seeds = {}
  104. matched_seeds["v3"] = shower_matched_seeds
  105. matched_seeds["v1"] = fromV3TrackV1Track(
  106. InputTracks=matched_seeds["v3"]
  107. ).OutputTracks
  108. matching_params = dict(
  109. MaxdDist=0.1,
  110. MinMatchNN=0.25, # NN response cut value
  111. MinZMag=5100,
  112. MaxZMag=5700,
  113. )
  114. calo_long = PrMatchNNv3(
  115. VeloInput=hlt2_tracks["Velo"]["Pr"],
  116. SeedInput=matched_seeds["v3"],
  117. AddUTHitsToolName=get_global_ut_hits_tool(),
  118. **matching_params,
  119. ).MatchOutput
  120. match_tracks = {}
  121. match_tracks["Pr"] = calo_long
  122. match_tracks["v1"] = fromPrMatchTracksV1Tracks(
  123. InputTracksLocation=match_tracks["Pr"],
  124. VeloTracksLocation=hlt2_tracks["Velo"]["v1"],
  125. SeedTracksLocation=matched_seeds["v1"],
  126. ).OutputTracksLocation
  127. out_track_types = get_default_out_track_types_for_light_reco()
  128. best_tracks = {
  129. track_type: hlt2_tracks[track_type] for track_type in out_track_types["Best"]
  130. }
  131. # data = [
  132. # calo_long,
  133. # calo_matched_seeds,
  134. # electron_matched_seeds,
  135. # shower_matched_seeds,
  136. # ]
  137. data = []
  138. types_and_locations_for_checkers = {
  139. "Forward": hlt2_tracks["Forward"],
  140. "Match": match_tracks, # hlt2_tracks["Match"],
  141. "Seed": hlt2_tracks["Seed"],
  142. }
  143. data += get_track_checkers(types_and_locations_for_checkers)
  144. # data += get_fitted_tracks_checkers(best_tracks)
  145. return Reconstruction("hlt2_reco", data, [require_gec()])
  146. run_reconstruction(options, standalone_hlt2_fastest_reco)