Belle II Software development
MCSideTrackingValidationModule Class Reference
Inheritance diagram for MCSideTrackingValidationModule:

Public Member Functions

def __init__ (self, name, contact, output_file_name=None, reco_tracks_name='RecoTracks', mc_reco_tracks_name='MCRecoTracks', expert_level=None)
 
def initialize (self)
 
def prepare (self)
 
def pick (self, mc_reco_track)
 
def peel (self, mc_reco_track)
 
def peel_mc_to_pr_match_info (self, mc_reco_track)
 
def peel_hit_efficiencies_in_all_pr_tracks (self, mc_reco_track)
 

Public Attributes

 reco_tracks_name
 Name of the StoreArray of the tracks from pattern recognition.
 
 mc_reco_tracks_name
 Name of the StoreArray of the ideal mc tracks.
 
 track_match_look_up
 Reference to the track match lookup object reading the relation information constructed by the MCMatcherTracksModule.
 
 found_det_hit_ids
 Set of all detector and hits ids contained in any pr track.
 
 matched_det_hit_ids
 Set of all detector and hits ids contained in matched pr tracks.
 
 clone_det_hit_ids
 Set of all detector and hits ids contained in clone pr tracks.
 
 fake_det_hit_ids
 Set of all detector and hits ids contained in background and ghost pr tracks.
 

Static Public Attributes

int default_expert_level = 10
 the threshold value for the expert level
 
refiners save_tree
 Save a tree of all collected variables in a sub folder.
 
refiners save_tree_basic
 Save a basic tree.
 
refiners save_overview_figures_of_merit
 Generate the average finding efficiencies and hit efficiencies.
 
refiners save_hit_efficiency_histogram
 Save a histogram of the hit efficiency.
 
dict renaming_select_for_finding_efficiency_profiles
 Rename the efficiency-profile quantities so that they display nicely in ROOT TLatex.
 
refiners save_finding_efficiency_profiles
 Make profile of finding efficiency.
 
refiners save_finding_efficiency_by_tan_lamba_profiles
 Make profile of finding efficiency versus tan(lambda)
 
refiners save_finding_efficiency_by_tan_lamba_in_pt_groups_profiles
 Make profiles of finding efficiency versus tan(lambda) grouped by transverse momentum.
 
dict renaming_select_for_hit_efficiency_profiles
 Rename the hit-profile quantities so that they display nicely in ROOT TLatex.
 
refiners save_hit_efficiency_profiles
 Make profile of hit efficiency.
 
refiners save_hit_efficiency_by_tan_lambda_profiles
 Make profile of finding efficiency versus tan(lambda)
 
refiners save_finding_efficiency_by_pt_profiles_groupbyCharge
 Charge dependent histograms Make profile of finding efficiency versus pt, tan(lambda)
 
refiners save_finding_efficiency_by_tan_lambda_profiles_groupbyCharge
 Charge dependent histograms Make profile of finding efficiency versus pt, tan(lambda)
 
refiners save_hit_efficiency_by_pt_profiles_groupbyCharge
 Charge dependent histograms Make profile of finding efficiency versus pt, tan(lambda)
 
refiners save_hit_efficiency_by_tan_lambda_profiles_groupbyCharge
 Charge dependent histograms Make profile of finding efficiency versus pt, tan(lambda)
 
refiners save_hit_efficiency_in_all_found_hist
 This creates a histogram for all MC track displaying the ratio of hits contained in any PR track Hence this is distinctly larger than the hit efficiency to the matched PR track Usefulness under discussion.
 
refiners save_missing_mc_tracks_hit_efficiency_in_all_found_hist
 This creates a histogram for each missing MC track displaying the ratio of hits contained in any PR tracks High values in this hit efficiencies means that the MC track is consumed by other PR tracks but no proper match could be established.
 

Detailed Description

Module to collect matching information about the found particles and to generate
   validation plots and figures of merit on the performance of track finding.
 Expert level behavior:
    expert_level = default_expert_level: all figures and plots from this module except tree entries
    expert_level > default_expert_level: everything including tree entries
    expert_level <= default_expert_level//2: only basic figures
    default_expert_level//2 < expert_level < default_expert_level: basic figures and basic tree entries

Definition at line 22 of file mc_side_module.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  name,
  contact,
  output_file_name = None,
  reco_tracks_name = 'RecoTracks',
  mc_reco_tracks_name = 'MCRecoTracks',
  expert_level = None 
)
Constructor

Definition at line 35 of file mc_side_module.py.

42 expert_level=None):
43 """Constructor"""
44
45 output_file_name = output_file_name or name + 'TrackingValidation.root'
46
47 super().__init__(foreach=mc_reco_tracks_name,
48 name=name,
49 output_file_name=output_file_name,
50 contact=contact,
51 expert_level=expert_level)
52
53
54 self.reco_tracks_name = reco_tracks_name
55
56
57 self.mc_reco_tracks_name = mc_reco_tracks_name
58
59
60 self.track_match_look_up = None
61
62 if self.expert_level >= self.default_expert_level:
63
64 self.found_det_hit_ids = set()
65
66
67 self.matched_det_hit_ids = set()
68
69
70 self.clone_det_hit_ids = set()
71
72
73 self.fake_det_hit_ids = set()
74

Member Function Documentation

◆ initialize()

def initialize (   self)
Initialization signal at the start of the event processing

Definition at line 75 of file mc_side_module.py.

75 def initialize(self):
76 """Initialization signal at the start of the event processing"""
77 super().initialize()
78 self.track_match_look_up = Belle2.TrackMatchLookUp(self.mc_reco_tracks_name, self.reco_tracks_name)
79
Class to provide convenient methods to look up matching information between pattern recognition and M...

◆ peel()

def peel (   self,
  mc_reco_track 
)
Looks at the individual Monte Carlo tracks and store information about them

Definition at line 119 of file mc_side_module.py.

119 def peel(self, mc_reco_track):
120 """Looks at the individual Monte Carlo tracks and store information about them"""
121 track_match_look_up = self.track_match_look_up
122
123 # Analyse from the Monte Carlo reference side
124 mc_reco_tracks = Belle2.PyStoreArray(self.foreach)
125 multiplicity = mc_reco_tracks.getEntries()
126
127 mc_particle = track_match_look_up.getRelatedMCParticle(mc_reco_track)
128 is_primary = bool(mc_particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle))
129 mc_to_pr_match_info_crops = self.peel_mc_to_pr_match_info(mc_reco_track)
130 mc_store_array_crops = peelers.peel_store_array_info(mc_reco_track, key="mc_{part_name}")
131
132 crops = dict(is_primary=is_primary,
133 multiplicity=multiplicity,
134 **mc_to_pr_match_info_crops,
135 **mc_store_array_crops
136 )
137
138 if self.expert_level >= self.default_expert_level:
139 reco_track = track_match_look_up.getRelatedPRRecoTrack(mc_reco_track)
140 mc_particle_crops = peelers.peel_mc_particle(mc_particle)
141 hit_content_crops = peelers.peel_reco_track_hit_content(mc_reco_track)
142
143 # Custom peel function to get single detector hit purities
144 subdetector_hit_efficiency_crops = peelers.peel_subdetector_hit_efficiency(mc_reco_track, reco_track)
145
146 mc_hit_efficiencies_in_all_pr_tracks_crops = self.peel_hit_efficiencies_in_all_pr_tracks(mc_reco_track)
147
148 # Event Info
149 event_meta_data = Belle2.PyStoreObj("EventMetaData")
150 event_crops = peelers.peel_event_info(event_meta_data)
151
152 # Store Array for easier joining
153 store_array_crops = peelers.peel_store_array_info(reco_track, key="pr_{part_name}")
154
155 # Information on PR reco track
156 pr_purity_information = {
157 "pr_hit_purity": track_match_look_up.getRelatedPurity(reco_track) if reco_track else float("nan"),
158 **peelers.peel_subdetector_hit_purity(reco_track=reco_track, mc_reco_track=mc_reco_track,
159 key="pr_{part_name}")
160 }
161
162 # Information on TrackFinders
163 trackfinder_crops = peelers.peel_trackfinder(reco_track)
164
165 # Basic peel function to get Quality Indicators
166 qualityindicator_crops = peelers.peel_quality_indicators(reco_track)
167
168 crops.update(dict(**hit_content_crops,
169 **mc_particle_crops,
170 **subdetector_hit_efficiency_crops,
171 **mc_hit_efficiencies_in_all_pr_tracks_crops,
172 **event_crops,
173 **store_array_crops,
174 **pr_purity_information,
175 **trackfinder_crops,
176 **qualityindicator_crops
177 ))
178
179 return crops
180
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67

◆ peel_hit_efficiencies_in_all_pr_tracks()

def peel_hit_efficiencies_in_all_pr_tracks (   self,
  mc_reco_track 
)
Extracts hit efficiencies

Definition at line 195 of file mc_side_module.py.

195 def peel_hit_efficiencies_in_all_pr_tracks(self, mc_reco_track):
196 """Extracts hit efficiencies"""
197 mc_det_hit_ids = utilities.get_det_hit_ids(mc_reco_track)
198
199 hit_efficiency_in_all_found = utilities.calc_hit_efficiency(self.found_det_hit_ids,
200 mc_det_hit_ids)
201
202 unfound_hit_efficiency = 1.0 - hit_efficiency_in_all_found
203
204 hit_efficiency_in_all_matched = utilities.calc_hit_efficiency(self.matched_det_hit_ids,
205 mc_det_hit_ids)
206
207 hit_efficiency_in_all_fake = utilities.calc_hit_efficiency(self.fake_det_hit_ids,
208 mc_det_hit_ids)
209
210 hit_efficiency_crops = dict(
211 hit_efficiency_in_all_found=hit_efficiency_in_all_found,
212 unfound_hit_efficiency=unfound_hit_efficiency,
213 hit_efficiency_in_all_matched=hit_efficiency_in_all_matched,
214 hit_efficiency_in_all_fake=hit_efficiency_in_all_fake,
215 )
216 return hit_efficiency_crops
217

◆ peel_mc_to_pr_match_info()

def peel_mc_to_pr_match_info (   self,
  mc_reco_track 
)
Extracts track-match information from the MCMatcherTracksModule results

Definition at line 181 of file mc_side_module.py.

181 def peel_mc_to_pr_match_info(self, mc_reco_track):
182 """Extracts track-match information from the MCMatcherTracksModule results"""
183 track_match_look_up = self.track_match_look_up
184 return dict(
185 is_matched=track_match_look_up.isAnyChargeMatchedMCRecoTrack(mc_reco_track),
186 is_matched_correct_charge=track_match_look_up.isCorrectChargeMatchedMCRecoTrack(mc_reco_track),
187 is_matched_wrong_charge=track_match_look_up.isWrongChargeMatchedMCRecoTrack(mc_reco_track),
188 is_merged=track_match_look_up.isAnyChargeMergedMCRecoTrack(mc_reco_track),
189 is_merged_correct_charge=track_match_look_up.isCorrectChargeMergedMCRecoTrack(mc_reco_track),
190 is_merged_wrong_charge=track_match_look_up.isWrongChargeMergedMCRecoTrack(mc_reco_track),
191 is_missing=track_match_look_up.isMissingMCRecoTrack(mc_reco_track),
192 hit_efficiency=track_match_look_up.getRelatedEfficiency(mc_reco_track),
193 )
194

◆ pick()

def pick (   self,
  mc_reco_track 
)
Pick every MCRecoTrack

Definition at line 115 of file mc_side_module.py.

115 def pick(self, mc_reco_track):
116 """Pick every MCRecoTrack"""
117 return True
118

◆ prepare()

def prepare (   self)
Collect some statistics about the pattern recognition tracks used for comparison to the MC tracks

Executed once at the start of each event.

Definition at line 80 of file mc_side_module.py.

80 def prepare(self):
81 """Collect some statistics about the pattern recognition tracks used for comparison to the MC tracks
82
83 Executed once at the start of each event.
84 """
85 super().prepare()
86 if self.expert_level >= self.default_expert_level:
87 reco_tracks = Belle2.PyStoreArray(self.reco_tracks_name)
88 track_match_look_up = self.track_match_look_up
89
90 found_det_hit_ids = set()
91 matched_det_hit_ids = set()
92 clone_det_hit_ids = set()
93 fake_det_hit_ids = set()
94
95 for reco_track in reco_tracks:
96 det_hit_ids = utilities.get_det_hit_ids(reco_track)
97
98 found_det_hit_ids |= det_hit_ids
99
100 if track_match_look_up.isAnyChargeMatchedPRRecoTrack(reco_track):
101 matched_det_hit_ids |= det_hit_ids
102
103 if track_match_look_up.isAnyChargeClonePRRecoTrack(reco_track):
104 clone_det_hit_ids |= det_hit_ids
105
106 if (track_match_look_up.isGhostPRRecoTrack(reco_track) or
107 track_match_look_up.isBackgroundPRRecoTrack(reco_track)):
108 fake_det_hit_ids |= det_hit_ids
109
110 self.found_det_hit_ids = found_det_hit_ids
111 self.matched_det_hit_ids = matched_det_hit_ids
112 self.clone_det_hit_ids = clone_det_hit_ids
113 self.fake_det_hit_ids = fake_det_hit_ids
114

Member Data Documentation

◆ clone_det_hit_ids

clone_det_hit_ids

Set of all detector and hits ids contained in clone pr tracks.

Updated each event.

Definition at line 70 of file mc_side_module.py.

◆ default_expert_level

int default_expert_level = 10
static

the threshold value for the expert level

Definition at line 33 of file mc_side_module.py.

◆ fake_det_hit_ids

fake_det_hit_ids

Set of all detector and hits ids contained in background and ghost pr tracks.

Updated each event.

Definition at line 73 of file mc_side_module.py.

◆ found_det_hit_ids

found_det_hit_ids

Set of all detector and hits ids contained in any pr track.

Updated each event.

Definition at line 64 of file mc_side_module.py.

◆ matched_det_hit_ids

matched_det_hit_ids

Set of all detector and hits ids contained in matched pr tracks.

Updated each event.

Definition at line 67 of file mc_side_module.py.

◆ mc_reco_tracks_name

mc_reco_tracks_name

Name of the StoreArray of the ideal mc tracks.

Definition at line 57 of file mc_side_module.py.

◆ reco_tracks_name

reco_tracks_name

Name of the StoreArray of the tracks from pattern recognition.

Definition at line 54 of file mc_side_module.py.

◆ renaming_select_for_finding_efficiency_profiles

dict renaming_select_for_finding_efficiency_profiles
static
Initial value:
= {
'is_matched': 'finding efficiency',
'd0_truth': 'd_{0}',
'pt_truth': 'p_{t}',
'multiplicity': 'multiplicity',
'phi0_truth': '#phi',
}

Rename the efficiency-profile quantities so that they display nicely in ROOT TLatex.

Definition at line 272 of file mc_side_module.py.

◆ renaming_select_for_hit_efficiency_profiles

dict renaming_select_for_hit_efficiency_profiles
static
Initial value:
= {
'hit_efficiency': 'hit efficiency',
'd0_truth': 'd_{0}',
'pt_truth': 'p_{t}',
'multiplicity': 'multiplicity',
'phi0_truth': '#phi',
}

Rename the hit-profile quantities so that they display nicely in ROOT TLatex.

Definition at line 330 of file mc_side_module.py.

◆ save_finding_efficiency_by_pt_profiles_groupbyCharge

refiners save_finding_efficiency_by_pt_profiles_groupbyCharge
static
Initial value:
= refiners.save_profiles(
)

Charge dependent histograms Make profile of finding efficiency versus pt, tan(lambda)

Definition at line 370 of file mc_side_module.py.

◆ save_finding_efficiency_by_tan_lamba_in_pt_groups_profiles

refiners save_finding_efficiency_by_tan_lamba_in_pt_groups_profiles
static
Initial value:
= refiners.save_profiles(
)

Make profiles of finding efficiency versus tan(lambda) grouped by transverse momentum.

Definition at line 311 of file mc_side_module.py.

◆ save_finding_efficiency_by_tan_lamba_profiles

refiners save_finding_efficiency_by_tan_lamba_profiles
static
Initial value:
= refiners.save_profiles(
)

Make profile of finding efficiency versus tan(lambda)

Definition at line 294 of file mc_side_module.py.

◆ save_finding_efficiency_by_tan_lambda_profiles_groupbyCharge

refiners save_finding_efficiency_by_tan_lambda_profiles_groupbyCharge
static
Initial value:
= refiners.save_profiles(
)

Charge dependent histograms Make profile of finding efficiency versus pt, tan(lambda)

Definition at line 388 of file mc_side_module.py.

◆ save_finding_efficiency_profiles

refiners save_finding_efficiency_profiles
static
Initial value:
= refiners.save_profiles(
)

Make profile of finding efficiency.

Definition at line 281 of file mc_side_module.py.

◆ save_hit_efficiency_by_pt_profiles_groupbyCharge

refiners save_hit_efficiency_by_pt_profiles_groupbyCharge
static
Initial value:
= refiners.save_profiles(
)

Charge dependent histograms Make profile of finding efficiency versus pt, tan(lambda)

Definition at line 407 of file mc_side_module.py.

◆ save_hit_efficiency_by_tan_lambda_profiles

refiners save_hit_efficiency_by_tan_lambda_profiles
static
Initial value:
= refiners.save_profiles(
)

Make profile of finding efficiency versus tan(lambda)

Definition at line 352 of file mc_side_module.py.

◆ save_hit_efficiency_by_tan_lambda_profiles_groupbyCharge

refiners save_hit_efficiency_by_tan_lambda_profiles_groupbyCharge
static
Initial value:
= refiners.save_profiles(
)

Charge dependent histograms Make profile of finding efficiency versus pt, tan(lambda)

Definition at line 425 of file mc_side_module.py.

◆ save_hit_efficiency_histogram

refiners save_hit_efficiency_histogram
static
Initial value:
= refiners.save_histograms(
)

Save a histogram of the hit efficiency.

Definition at line 262 of file mc_side_module.py.

◆ save_hit_efficiency_in_all_found_hist

refiners save_hit_efficiency_in_all_found_hist
static
Initial value:
= refiners.save_histograms(
)

This creates a histogram for all MC track displaying the ratio of hits contained in any PR track Hence this is distinctly larger than the hit efficiency to the matched PR track Usefulness under discussion.

Definition at line 445 of file mc_side_module.py.

◆ save_hit_efficiency_profiles

refiners save_hit_efficiency_profiles
static
Initial value:
= refiners.save_profiles(
)

Make profile of hit efficiency.

Definition at line 339 of file mc_side_module.py.

◆ save_missing_mc_tracks_hit_efficiency_in_all_found_hist

refiners save_missing_mc_tracks_hit_efficiency_in_all_found_hist
static
Initial value:
= refiners.save_histograms(
)

This creates a histogram for each missing MC track displaying the ratio of hits contained in any PR tracks High values in this hit efficiencies means that the MC track is consumed by other PR tracks but no proper match could be established.

Definition at line 456 of file mc_side_module.py.

◆ save_overview_figures_of_merit

refiners save_overview_figures_of_merit
static
Initial value:
= refiners.save_fom(
)

Generate the average finding efficiencies and hit efficiencies.

Definition at line 243 of file mc_side_module.py.

◆ save_tree

refiners save_tree
static
Initial value:
= refiners.save_tree(
# using cond to suppress false doxygen warnings
)

Save a tree of all collected variables in a sub folder.

Definition at line 222 of file mc_side_module.py.

◆ save_tree_basic

refiners save_tree_basic
static
Initial value:
= refiners.save_tree(
# using cond to suppress false doxygen warnings
)

Save a basic tree.

Definition at line 232 of file mc_side_module.py.

◆ track_match_look_up

track_match_look_up

Reference to the track match lookup object reading the relation information constructed by the MCMatcherTracksModule.

Definition at line 60 of file mc_side_module.py.


The documentation for this class was generated from the following file: