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.

234 lines
7.8 KiB

10 months ago
10 months ago
7 months ago
10 months ago
10 months ago
9 months ago
10 months ago
7 months ago
10 months ago
10 months ago
9 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
  1. # flake8: noqa
  2. # ruff: noqa
  3. """
  4. Moore/run gaudirun.py /work/cetin/LHCb/reco_tuner/moore_options/get_ghost_data.py
  5. """
  6. from Moore import options, run_reconstruction
  7. from Moore.config import Reconstruction
  8. from PyConf.Algorithms import (
  9. PrForwardTrackingVelo,
  10. PrForwardTracking,
  11. PrTrackAssociator,
  12. PrMatchNN,
  13. PrResidualVeloTracks,
  14. PrResidualSeedingLong,
  15. fromPrMatchTracksV1Tracks,
  16. fromPrVeloTracksV1Tracks,
  17. fromPrSeedingTracksV1Tracks,
  18. )
  19. from PyConf.application import make_data_with_FetchDataFromFile
  20. from PyConf.Tools import PrMCDebugForwardTool, PrMCDebugMatchToolNN
  21. from RecoConf.data_from_file import mc_unpackers
  22. from RecoConf.hlt1_tracking import make_hlt1_tracks, make_PrStoreSciFiHits_hits
  23. from RecoConf.hlt2_tracking import (
  24. get_global_ut_hits_tool,
  25. make_PrHybridSeeding_tracks,
  26. make_PrMatchNN_tracks,
  27. get_fast_hlt2_tracks,
  28. )
  29. from RecoConf.event_filters import require_gec
  30. from RecoConf.mc_checking import make_links_lhcbids_mcparticles_tracking_system
  31. import glob
  32. options.evt_max = -1
  33. decay = "B" # D, B
  34. options.ntuple_file = (
  35. f"/work/cetin/LHCb/reco_tuner/data/ghost_data_{decay}_Default.root"
  36. )
  37. options.input_type = "ROOT"
  38. if decay == "B":
  39. options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi")
  40. elif decay == "BJpsi":
  41. options.input_files = glob.glob("/auto/data/guenther/Bd_JpsiKst_ee/*.xdigi")
  42. elif decay == "D":
  43. options.input_files = glob.glob("/auto/data/guenther/Dst_D0ee/*.xdigi")
  44. elif decay == "test":
  45. options.input_files = ["/auto/data/guenther/Bd_Kstee/00151673_00000002_1.xdigi"]
  46. elif decay == "both":
  47. options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi") + glob.glob(
  48. "/auto/data/guenther/Dst_D0ee/*.xdigi"
  49. )
  50. options.dddb_tag = "dddb-20210617"
  51. options.conddb_tag = "sim-20210617-vc-md100"
  52. options.simulation = True
  53. def run_tracking_debug():
  54. links_to_hits = make_links_lhcbids_mcparticles_tracking_system()
  55. hlt1_tracks = make_hlt1_tracks()
  56. seed_tracks = make_PrHybridSeeding_tracks()
  57. # add MCLinking to the (fitted) V1 tracks
  58. links_to_velo_tracks = PrTrackAssociator(
  59. SingleContainer=hlt1_tracks["Velo"]["v1"],
  60. LinkerLocationID=links_to_hits,
  61. MCParticleLocation=mc_unpackers()["MCParticles"],
  62. MCVerticesInput=mc_unpackers()["MCVertices"],
  63. ).OutputLocation
  64. links_to_upstream_tracks = PrTrackAssociator(
  65. SingleContainer=hlt1_tracks["Upstream"]["v1"],
  66. LinkerLocationID=links_to_hits,
  67. MCParticleLocation=mc_unpackers()["MCParticles"],
  68. MCVerticesInput=mc_unpackers()["MCVertices"],
  69. ).OutputLocation
  70. links_to_seed_tracks = PrTrackAssociator(
  71. SingleContainer=seed_tracks["v1"],
  72. LinkerLocationID=links_to_hits,
  73. MCParticleLocation=mc_unpackers()["MCParticles"],
  74. MCVerticesInput=mc_unpackers()["MCVertices"],
  75. ).OutputLocation
  76. # # be more robust against imperfect data
  77. # loose_forward_params = dict(
  78. # MaxChi2PerDoF=16,
  79. # MaxChi2XProjection=30,
  80. # MaxChi2PerDoFFinal=8,
  81. # MaxChi2Stereo=8,
  82. # MaxChi2StereoAdd=8,
  83. # )
  84. # forward_debug = PrForwardTrackingVelo(
  85. # InputTracks=hlt1_tracks["Velo"]["Pr"],
  86. # SciFiHits=make_PrStoreSciFiHits_hits(),
  87. # AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
  88. # DebugTool=PrMCDebugForwardTool(
  89. # InputTracks=hlt1_tracks["Velo"]["v1"],
  90. # InputTrackLinks=links_to_velo_tracks,
  91. # MCParticles=mc_unpackers()["MCParticles"],
  92. # SciFiHitLinks=links_to_hits,
  93. # SciFiHits=make_PrStoreSciFiHits_hits(),
  94. # TrackInfo=make_data_with_FetchDataFromFile(
  95. # "/Event/MC/TrackInfo", "LHCb::MCProperty"
  96. # ),
  97. # ),
  98. # **loose_forward_params,
  99. # )
  100. # forward_ut_debug = PrForwardTracking(
  101. # SciFiHits=make_PrStoreSciFiHits_hits(),
  102. # InputTracks=hlt1_tracks["Upstream"]["Pr"],
  103. # AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
  104. # DebugTool=PrMCDebugForwardTool(
  105. # InputTracks=hlt1_tracks["Upstream"]["v1"],
  106. # InputTrackLinks=links_to_upstream_tracks,
  107. # MCParticles=mc_unpackers()["MCParticles"],
  108. # SciFiHitLinks=links_to_hits,
  109. # SciFiHits=make_PrStoreSciFiHits_hits(),
  110. # TrackInfo=make_data_with_FetchDataFromFile(
  111. # "/Event/MC/TrackInfo", "LHCb::MCProperty"
  112. # ),
  113. # ),
  114. # **loose_forward_params,
  115. # )
  116. loose_matching_params = dict(
  117. MaxMatchChi2=30.0, # 30.0,
  118. MaxDistX=500, # 500,
  119. MaxDistY=500, # 500,
  120. MaxDSlope=3.0,
  121. MaxDSlopeY=0.3,
  122. MaxdDist=0.1,
  123. MinMatchNN=0.25, # NN response cut value
  124. )
  125. match_debug = PrMatchNN(
  126. VeloInput=hlt1_tracks["Velo"]["Pr"],
  127. SeedInput=seed_tracks["Pr"],
  128. MatchDebugToolName=PrMCDebugMatchToolNN(
  129. VeloTracks=hlt1_tracks["Velo"]["v1"],
  130. SeedTracks=seed_tracks["v1"],
  131. VeloTrackLinks=links_to_velo_tracks,
  132. SeedTrackLinks=links_to_seed_tracks,
  133. TrackInfo=make_data_with_FetchDataFromFile(
  134. "/Event/MC/TrackInfo", "LHCb::MCProperty"
  135. ),
  136. MCParticles=mc_unpackers()["MCParticles"],
  137. ),
  138. AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
  139. **loose_matching_params,
  140. ).MatchOutput
  141. """
  142. v1_match_tracks = fromPrMatchTracksV1Tracks(
  143. InputTracksLocation=match_debug,
  144. VeloTracksLocation=hlt1_tracks["Velo"]["v1"],
  145. SeedTracksLocation=seed_tracks["v1"],
  146. ).OutputTracksLocation
  147. # run Matching on residual velo and seed track segments
  148. pr_velo_residual = PrResidualVeloTracks(
  149. TracksLocation=match_debug,
  150. VeloTrackLocation=hlt1_tracks["Velo"]["Pr"],
  151. ).VeloTrackOutput
  152. v1_velo_residual = fromPrVeloTracksV1Tracks(
  153. InputTracksLocation=pr_velo_residual
  154. ).OutputTracksLocation
  155. pr_seed_residual = PrResidualSeedingLong(
  156. MatchTracksLocation=match_debug,
  157. SeedTracksLocation=seed_tracks["Pr"],
  158. ).SeedTracksOutput
  159. v1_seed_residual = fromPrSeedingTracksV1Tracks(
  160. InputTracksLocation=pr_seed_residual
  161. ).OutputTracksLocation
  162. # add MCLinking to the (fitted) residual V1 tracks
  163. links_to_res_velo_tracks = PrTrackAssociator(
  164. SingleContainer=v1_velo_residual,
  165. LinkerLocationID=links_to_hits,
  166. MCParticleLocation=mc_unpackers()["MCParticles"],
  167. MCVerticesInput=mc_unpackers()["MCVertices"],
  168. ).OutputLocation
  169. links_to_res_seed_tracks = PrTrackAssociator(
  170. SingleContainer=v1_seed_residual,
  171. LinkerLocationID=links_to_hits,
  172. MCParticleLocation=mc_unpackers()["MCParticles"],
  173. MCVerticesInput=mc_unpackers()["MCVertices"],
  174. ).OutputLocation
  175. loose_res_matching_params = dict(
  176. MaxMatchChi2=30.0, # 30.0,
  177. MaxDistX=500, # 500,
  178. MaxDistY=500, # 500,
  179. MaxDSlope=1.5,
  180. MinMatchNN=0.5, # NN response cut value
  181. FastYTol=2500.0,
  182. )
  183. match_residual = PrMatchNN(
  184. VeloInput=pr_velo_residual,
  185. SeedInput=pr_seed_residual,
  186. MatchDebugToolName=PrMCDebugMatchToolNN(
  187. VeloTracks=v1_velo_residual,
  188. SeedTracks=v1_seed_residual,
  189. VeloTrackLinks=links_to_res_velo_tracks,
  190. SeedTrackLinks=links_to_res_seed_tracks,
  191. TrackInfo=make_data_with_FetchDataFromFile("/Event/MC/TrackInfo"),
  192. MCParticles=mc_unpackers()["MCParticles"],
  193. ),
  194. AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
  195. **loose_res_matching_params,
  196. ).MatchOutput
  197. """
  198. # data = [forward_debug, forward_ut_debug, match_debug] # match_residual]
  199. data = [match_debug]
  200. return Reconstruction("run_tracking_debug", data, [require_gec()])
  201. run_reconstruction(options, run_tracking_debug)