10from ROOT
import Belle2
18ROOT.gSystem.Load(
"libtracking")
22 """Module to perform event-by-event tracking validation."""
24 """ Expert level behavior:
25 expert_level <= default_expert_level: all figures and plots
from this module
except tree entries
26 expert_level > default_expert_level: everything including tree entries
30 default_expert_level = 10
35 output_file_name=None,
36 reco_tracks_name='RecoTracks',
37 mc_reco_tracks_name='MCRecoTracks',
41 output_file_name = output_file_name or name +
'TrackingValidation.root'
43 super().
__init__(foreach=
"EventMetaData",
45 output_file_name=output_file_name,
47 expert_level=expert_level)
57 """Initialization signal at the start of the event processing"""
63 def pick(self, event_meta_data=None):
67 def peel(self, event_meta_data=None):
68 """Peel information from the event"""
79 n_mc_particles = mc_particles.getEntries()
84 n_mc_reco_tracks = mc_reco_tracks.getEntries()
88 n_reco_tracks = reco_tracks.getEntries()
91 all_mc_tracks_det_hit_ids = set()
92 n_matched_mc_reco_tracks = 0
93 n_matched_correct_charge_mc_reco_tracks = 0
94 n_matched_wrong_charge_mc_reco_tracks = 0
95 n_merged_mc_reco_tracks = 0
96 n_merged_correct_charge_mc_reco_tracks = 0
97 n_merged_wrong_charge_mc_reco_tracks = 0
98 n_missing_mc_reco_tracks = 0
99 for mc_reco_track
in mc_reco_tracks:
100 mc_reco_track_det_hit_ids = utilities.get_det_hit_ids(mc_reco_track)
101 all_mc_tracks_det_hit_ids.update(mc_reco_track_det_hit_ids)
103 is_matched = track_match_look_up.isAnyChargeMatchedMCRecoTrack(mc_reco_track)
104 is_matched_correct_charge = track_match_look_up.isCorrectChargeMatchedMCRecoTrack(mc_reco_track)
105 is_matched_wrong_charge = track_match_look_up.isWrongChargeMatchedMCRecoTrack(mc_reco_track)
106 is_merged = track_match_look_up.isAnyChargeMergedMCRecoTrack(mc_reco_track)
107 is_merged_correct_charge = track_match_look_up.isCorrectChargeMergedMCRecoTrack(mc_reco_track)
108 is_merged_wrong_charge = track_match_look_up.isWrongChargeMergedMCRecoTrack(mc_reco_track)
109 is_missing = track_match_look_up.isMissingMCRecoTrack(mc_reco_track)
112 n_matched_mc_reco_tracks += 1
113 if is_matched_correct_charge:
114 n_matched_correct_charge_mc_reco_tracks += 1
115 elif is_matched_wrong_charge:
116 n_matched_wrong_charge_mc_reco_tracks += 1
118 n_merged_mc_reco_tracks += 1
119 if is_merged_correct_charge:
120 n_merged_correct_charge_mc_reco_tracks += 1
121 elif is_merged_wrong_charge:
122 n_merged_wrong_charge_mc_reco_tracks += 1
124 n_missing_mc_reco_tracks += 1
127 n_matched_reco_tracks = 0
128 n_matched_correct_charge_reco_tracks = 0
129 n_matched_wrong_charge_reco_tracks = 0
130 n_clone_reco_tracks = 0
131 n_clone_correct_charge_reco_tracks = 0
132 n_clone_wrong_charge_reco_tracks = 0
133 n_background_reco_tracks = 0
134 n_ghost_reco_tracks = 0
136 all_tracks_det_hit_ids = set()
138 for reco_track
in reco_tracks:
139 is_matched = track_match_look_up.isAnyChargeMatchedPRRecoTrack(reco_track)
140 is_matched_correct_charge = track_match_look_up.isCorrectChargeMatchedPRRecoTrack(reco_track)
141 is_matched_wrong_charge = track_match_look_up.isWrongChargeMatchedPRRecoTrack(reco_track)
142 is_clone = track_match_look_up.isAnyChargeClonePRRecoTrack(reco_track)
143 is_clone_correct_charge = track_match_look_up.isCorrectChargeClonePRRecoTrack(reco_track)
144 is_clone_wrong_charge = track_match_look_up.isWrongChargeClonePRRecoTrack(reco_track)
145 is_background = track_match_look_up.isBackgroundPRRecoTrack(reco_track)
146 is_ghost = track_match_look_up.isGhostPRRecoTrack(reco_track)
149 n_matched_reco_tracks += 1
150 if is_matched_correct_charge:
151 n_matched_correct_charge_reco_tracks += 1
152 elif is_matched_wrong_charge:
153 n_matched_wrong_charge_reco_tracks += 1
155 n_clone_reco_tracks += 1
156 if is_clone_correct_charge:
157 n_clone_correct_charge_reco_tracks += 1
158 elif is_clone_wrong_charge:
159 n_clone_wrong_charge_reco_tracks += 1
161 n_background_reco_tracks += 1
163 n_ghost_reco_tracks += 1
165 reco_track_det_hit_ids = utilities.get_det_hit_ids(reco_track)
167 all_tracks_det_hit_ids.update(reco_track_det_hit_ids)
168 if is_matched
or is_clone:
171 mc_reco_track_det_hit_ids = utilities.get_det_hit_ids(mc_reco_track)
172 n_matched_hits += len(reco_track_det_hit_ids & mc_reco_track_det_hit_ids)
175 n_mc_particles=n_mc_particles,
176 n_mc_reco_tracks=n_mc_reco_tracks,
177 n_reco_tracks=n_reco_tracks,
179 n_matched_mc_reco_tracks=n_matched_mc_reco_tracks,
180 n_matched_correct_charge_mc_reco_tracks=n_matched_correct_charge_mc_reco_tracks,
181 n_matched_wrong_charge_mc_reco_tracks=n_matched_wrong_charge_mc_reco_tracks,
183 n_merged_mc_reco_tracks=n_merged_mc_reco_tracks,
184 n_merged_correct_charge_mc_reco_tracks=n_merged_correct_charge_mc_reco_tracks,
185 n_merged_wrong_charge_mc_reco_tracks=n_merged_wrong_charge_mc_reco_tracks,
187 n_missing_mc_reco_tracks=n_missing_mc_reco_tracks,
190 n_matched_reco_tracks=n_matched_reco_tracks,
191 n_matched_correct_charge_reco_tracks=n_matched_correct_charge_reco_tracks,
192 n_matched_wrong_charge_reco_tracks=n_matched_wrong_charge_reco_tracks,
193 n_clone_reco_tracks=n_clone_reco_tracks,
194 n_clone_correct_charge_reco_tracks=n_clone_correct_charge_reco_tracks,
195 n_clone_wrong_charge_reco_tracks=n_clone_wrong_charge_reco_tracks,
197 n_background_reco_tracks=n_background_reco_tracks,
198 n_ghost_reco_tracks=n_ghost_reco_tracks,
200 n_cdc_hits=cdc_hits.getEntries(),
201 n_all_mc_track_hits=len(all_mc_tracks_det_hit_ids),
202 n_all_track_hits=len(all_tracks_det_hit_ids),
203 n_found_hits=len(all_mc_tracks_det_hit_ids & all_tracks_det_hit_ids),
204 n_matched_hits=n_matched_hits
211 save_tree = refiners.save_tree(
214 folder_name=
"event_tree",
216 above_expert_level=default_expert_level
221 save_clone_rate = refiners.save_fom(
224 name=
"{module.id}_hit_figures_of_merit",
225 title=
"Hit sums in {module.title}",
229 "n_all_mc_track_hits",
A (simplified) python wrapper for StoreArray.
Class to provide convenient methods to look up matching information between pattern recognition and M...
cdc_hits_name
cached value of the CDCHits collection name
track_match_look_up
Reference to the track-match object that examines relation information from MCMatcherTracksModule.
def pick(self, event_meta_data=None)
mc_reco_tracks_name
cached value of the MCRecoTracks collection name
def peel(self, event_meta_data=None)
def __init__(self, name, contact, output_file_name=None, reco_tracks_name='RecoTracks', mc_reco_tracks_name='MCRecoTracks', expert_level=None)
reco_tracks_name
cached value of the RecoTracks collection name