12from ROOT
import Belle2
18 """Gather the MC VXD-CDC-merger results into ROOT file"""
24 output_file_name (str): name of the output ROOT file
26 HarvestingModule.__init__(self, foreach="MCParticles", output_file_name=output_file_name)
33 def pick(self, mc_particle):
34 """Return true if the MCParticle has a related MCRecoTrack"""
37 mc_track = mc_particle.getRelatedFrom(
"MCRecoTracks")
43 def peel(self, mc_particle):
44 """Collect information related to the MCParticle into a dictionary"""
45 mc_track = mc_particle.getRelatedFrom(
"MCRecoTracks")
49 result = peelers.peel_mc_particle(mc_particle)
50 result.update(peelers.peel_reco_track_hit_content(mc_track))
51 result.update(peelers.peel_event_info(event_info))
53 result[
"mc_store_array_number"] = mc_track.getArrayIndex()
58 result.update(peelers.peel_reco_track_hit_content(this_best_track_cdc, key=
"cdc_{part_name}"))
59 result.update(peelers.peel_reco_track_seed(this_best_track_cdc, key=
"cdc_{part_name}"))
60 if this_best_track_cdc:
61 result[
"cdc_store_array_number"] = this_best_track_cdc.getArrayIndex()
62 result[
"cdc_was_fitted"] = this_best_track_cdc.wasFitSuccessful()
64 result[
"cdc_store_array_number"] = -1
65 result[
"cdc_was_fitted"] = -1
67 result.update(peelers.peel_reco_track_hit_content(this_best_track_vxd, key=
"vxd_{part_name}"))
68 result.update(peelers.peel_reco_track_seed(this_best_track_vxd, key=
"vxd_{part_name}"))
69 if this_best_track_vxd:
70 result[
"vxd_store_array_number"] = this_best_track_vxd.getArrayIndex()
71 result[
"vxd_was_fitted"] = this_best_track_vxd.wasFitSuccessful()
73 result[
"vxd_store_array_number"] = -1
74 result[
"vxd_was_fitted"] = -1
76 if this_best_track_cdc:
77 merged_vxd_track = this_best_track_cdc.getRelated(
"SVDRecoTracks")
79 merged_vxd_track =
None
80 if this_best_track_vxd:
81 merged_cdc_track = this_best_track_vxd.getRelated(
"CDCRecoTracks")
83 merged_cdc_track =
None
85 flag_incorrect_not_merged =
False
86 flag_correct_merged =
False
87 flag_not_found =
False
88 flag_correct_not_merged_cdcmissing =
False
89 flag_incorrect_merged_cdcwrong_although_not_there =
False
90 flag_correct_not_merged_vxdmissing =
False
91 flag_incorrect_merged_vxdwrong_although_not_there =
False
93 flag_incorrect_merged =
False
98 if not this_best_track_cdc
and not this_best_track_vxd:
100 flag_not_found =
True
103 elif not this_best_track_cdc:
105 if not merged_cdc_track:
107 flag_correct_not_merged_cdcmissing =
True
111 flag_incorrect_merged_cdcwrong_although_not_there =
True
114 elif not this_best_track_vxd:
116 if not merged_vxd_track:
118 flag_correct_not_merged_vxdmissing =
True
122 flag_incorrect_merged_vxdwrong_although_not_there =
True
125 elif not merged_vxd_track
and not merged_cdc_track:
127 flag_incorrect_not_merged =
True
130 elif this_best_track_cdc == merged_cdc_track
and this_best_track_vxd == merged_vxd_track:
132 flag_correct_merged =
True
137 if merged_cdc_track != this_best_track_cdc:
138 flag_incorrect_merged =
True
144 "flag_correct_not_merged_cdcmissing": flag_correct_not_merged_cdcmissing,
145 "flag_correct_not_merged_vxdmissing": flag_correct_not_merged_vxdmissing,
146 "flag_correct_merged": flag_correct_merged,
147 "flag_incorrect_not_merged": flag_incorrect_not_merged,
148 "flag_incorrect_merged": flag_incorrect_merged,
149 "flag_incorrect_merged_cdcwrong_although_not_there": flag_incorrect_merged_cdcwrong_although_not_there,
150 "flag_incorrect_merged_vxdwrong_although_not_there": flag_incorrect_merged_vxdwrong_although_not_there,
151 "flag_not_found": flag_not_found,
157 save_tree = refiners.SaveTreeRefiner()
161def peel_matching_information(pr_track_and_mc_track_matcher, key="{part_name}"):
162 pr_track, mc_track_matcher = pr_track_and_mc_track_matcher
164 is_matched = mc_track_matcher.isAnyChargeMatchedPRRecoTrack(pr_track)
165 is_clone = mc_track_matcher.isAnyChargeClonePRRecoTrack(pr_track)
166 is_background = mc_track_matcher.isBackgroundPRRecoTrack(pr_track)
167 is_ghost = mc_track_matcher.isGhostPRRecoTrack(pr_track)
170 is_matched=is_matched,
172 is_background=is_background,
174 is_clone_or_match=(is_matched
or is_clone),
175 is_fake=
not (is_matched
or is_clone),
176 hit_purity=mc_track_matcher.getRelatedPurity(pr_track),
185 is_clone_or_match=nan,
192 """Gather the reconstructed VXD-CDC-merger results into ROOT file"""
194 def __init__(self, foreach, others, output_file_name):
198 others (str): name of other-tracks collection related to the reconstructed tracks
199 output_file_name (str): name of the output ROOT file
201 super().__init__(foreach, output_file_name)
212 """Collect information related to the reconstructed track into a dictionary"""
215 result = peelers.peel_reco_track_hit_content(pr_track)
216 result.update(peelers.peel_reco_track_seed(pr_track))
217 result.update(peelers.peel_event_info(event_info))
219 result[
"store_array_number"] = pr_track.getArrayIndex()
224 result[
"mc_store_array_number"] = mc_track.getArrayIndex()
226 result[
"mc_store_array_number"] = -1
230 matched_track = pr_track.getRelated(self.
others)
232 result.update(peel_matching_information((matched_track, self.
mc_track_matcher_other), key=
"other_{part_name}"))
235 result[
"matched_store_array_number"] = matched_track.getArrayIndex()
237 result[
"matched_store_array_number"] = -1
239 result[
"number_of_matches"] = pr_track.getRelationsWith(self.
others).size()
244 save_tree = refiners.SaveTreeRefiner()
a (simplified) python wrapper for StoreObjPtr.
Class to provide convenient methods to look up matching information between pattern recognition and M...
mc_track_matcher_vxd
matcher used for the MCTracks from the VXD
mc_track_matcher_cdc
matcher used for the MCTracks from the CDC
def pick(self, mc_particle)
def peel(self, mc_particle)
def __init__(self, output_file_name)
mc_track_matcher_other
function to find the MCRecoTrack related to an other-tracks entry
def __init__(self, foreach, others, output_file_name)
others
cached copy of the 'others' argument
mc_track_matcher
function to find the MCRecoTrack related to a reconstructed track