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.

166 lines
5.5 KiB

  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. PrTrackAssociator,
  38. )
  39. from PyConf.Tools import PrMCDebugForwardTool, PrMCDebugMatchToolNN
  40. from PyConf.application import make_data_with_FetchDataFromFile
  41. from RecoConf.data_from_file import mc_unpackers
  42. import Functors as F
  43. import glob
  44. decay = "testJpsi"
  45. options.evt_max = -1
  46. # options.ntuple_file = f"/work/cetin/LHCb/reco_tuner/data_matching/NewParams/calo_data_{decay}_NewParams.root" # _dll_NegThree_mlp_NullSix.root"
  47. # options.ntuple_file = f"/work/cetin/LHCb/reco_tuner/efficiencies/electrons/calo_selected_effs_{decay}_VeloEcalSelection.root"
  48. options.ntuple_file = f"data/calo_selected_effs_{decay}.root"
  49. if decay == "B":
  50. options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi")
  51. elif decay == "BJpsi":
  52. options.input_files = glob.glob("/auto/data/guenther/Bd_JpsiKst_ee/*.xdigi")
  53. elif decay == "D":
  54. options.input_files = glob.glob("/auto/data/guenther/Dst_D0ee/*.xdigi")
  55. elif decay == "testJpsi":
  56. options.input_files = [
  57. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000009_1.xdigi",
  58. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000059_1.xdigi",
  59. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000020_1.xdigi",
  60. ]
  61. elif decay == "test":
  62. options.input_files = [
  63. "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000009_1.xdigi"
  64. ]
  65. options.input_type = "ROOT"
  66. options.dddb_tag = "dddb-20210617"
  67. options.conddb_tag = "sim-20210617-vc-md100"
  68. options.simulation = True
  69. def standalone_hlt2_fastest_reco():
  70. links_to_hits = make_links_lhcbids_mcparticles_tracking_system()
  71. hlt2_tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True)
  72. digisEcal = make_digits(calo_raw_bank=False)["digitsEcal"]
  73. tracks_v3, trackrels = convert_tracks_to_v3_from_v1(
  74. hlt2_tracks["Seed"]["v1"],
  75. track_types=["Ttrack"],
  76. )
  77. # track acceptances
  78. tracks_incalo = make_acceptance(tracks_v3)
  79. eshower = make_trackbased_eshower(tracks_incalo, digisEcal)
  80. matched_seeds = {}
  81. # should be best; shape of shower etc; E/p statt chi2; DLL even better? GET(1)
  82. # Cut=F.FILTER(F.ALL)).Output
  83. matched_seeds["v3"] = PrFilterTracks2ElectronShower(
  84. Relation=eshower["Ttrack"],
  85. # Cut=F.FILTER(((F.GET(1) @ F.WEIGHT) > -3)), # | ((F.GET(0) @ F.WEIGHT) > 0.7)),
  86. Cut=F.FILTER(((F.GET(0) @ F.WEIGHT) > 0.7) | ((F.GET(1) @ F.WEIGHT) > -2)),
  87. ).Output
  88. matched_seeds["v1"] = fromV3TrackV1Track(
  89. InputTracks=matched_seeds["v3"]
  90. ).OutputTracks
  91. links_to_velo_tracks = PrTrackAssociator(
  92. SingleContainer=hlt2_tracks["Velo"]["v1"],
  93. LinkerLocationID=links_to_hits,
  94. MCParticleLocation=mc_unpackers()["MCParticles"],
  95. MCVerticesInput=mc_unpackers()["MCVertices"],
  96. ).OutputLocation
  97. links_to_seed_tracks = PrTrackAssociator(
  98. SingleContainer=matched_seeds["v1"],
  99. LinkerLocationID=links_to_hits,
  100. MCParticleLocation=mc_unpackers()["MCParticles"],
  101. MCVerticesInput=mc_unpackers()["MCVertices"],
  102. ).OutputLocation
  103. matching_params = dict(
  104. MaxdDist=0.1,
  105. MinMatchNN=0.25,
  106. # PerfectTSelection=1.0,
  107. PerfectVeloSelection=1.0,
  108. MinZMag=5100,
  109. MaxZMag=5700,
  110. matchDebugOutput=0.0,
  111. )
  112. match_tracks = {}
  113. match_tracks["Pr"] = PrMatchNNv3(
  114. VeloInput=hlt2_tracks["Velo"]["Pr"],
  115. SeedInput=matched_seeds["v3"],
  116. MatchDebugToolName=PrMCDebugMatchToolNN(
  117. VeloTracks=hlt2_tracks["Velo"]["v1"],
  118. SeedTracks=matched_seeds["v1"],
  119. VeloTrackLinks=links_to_velo_tracks,
  120. SeedTrackLinks=links_to_seed_tracks,
  121. TrackInfo=make_data_with_FetchDataFromFile(
  122. "/Event/MC/TrackInfo", "LHCb::MCProperty"
  123. ),
  124. MCParticles=mc_unpackers()["MCParticles"],
  125. ),
  126. AddUTHitsToolName=get_global_ut_hits_tool(),
  127. **matching_params,
  128. ).MatchOutput
  129. match_tracks["v1"] = fromPrMatchTracksV1Tracks(
  130. InputTracksLocation=match_tracks["Pr"],
  131. VeloTracksLocation=hlt2_tracks["Velo"]["v1"],
  132. SeedTracksLocation=matched_seeds["v1"],
  133. ).OutputTracksLocation
  134. data = []
  135. types_and_locations_for_checkers = {
  136. "Forward": hlt2_tracks["Forward"],
  137. "Match": match_tracks,
  138. # "Seed": hlt2_tracks["Seed"],
  139. }
  140. data += get_track_checkers(types_and_locations_for_checkers)
  141. # data += get_fitted_tracks_checkers(best_tracks)
  142. return Reconstruction("hlt2_reco", data, [require_gec()])
  143. run_reconstruction(options, standalone_hlt2_fastest_reco)