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.

229 lines
7.7 KiB

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