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.

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