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

Public Member Functions

def __init__ (self, output_file_name)
 
def initialize (self)
 
def prepare (self)
 
def pick (self, segment)
 
def peel (self, segment)
 

Public Attributes

 mc_segment_lookup
 by default, there is no method to find matching MC track segments
 
 mc_hit_lookup
 Method to find matching MC hits.
 

Static Public Attributes

refiners save_histograms = refiners.save_histograms(outlier_z_score=5.0, allow_discrete=True)
 Save histograms in a sub folder.
 
refiners save_tree = refiners.save_tree()
 Save a tree of all collected variables in a sub folder.
 
refiners save_curvature_pull
 Save curvature-pull information in a sub folder.
 
refiners save_curvature_pull_rl_pure
 Save right-left curvature-pull information in a sub folder.
 
refiners save_absolute_curvature_pull
 Save absolute curvature-pull information in a sub folder.
 
refiners save_fit_quality_histograms
 Save fit-quality histograms in a sub folder.
 

Detailed Description

Module to collect information about the generated segments and
compose validation plots on terminate.

Definition at line 221 of file record.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  output_file_name 
)
Constructor

Definition at line 226 of file record.py.

226 def __init__(self, output_file_name):
227 """Constructor"""
228 super().__init__(foreach='CDCSegment2DVector',
229 output_file_name=output_file_name)
230
231
232 self.mc_segment_lookup = None
233

Member Function Documentation

◆ initialize()

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

Definition at line 234 of file record.py.

234 def initialize(self):
235 """Receive signal at the start of event processing"""
236 super().initialize()
237
238
240
242
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.

◆ peel()

def peel (   self,
  segment 
)
Aggregate the track and MC information for track-segment analysis

Definition at line 255 of file record.py.

255 def peel(self, segment):
256 """Aggregate the track and MC information for track-segment analysis"""
257
258 mc_segment_lookup = self.mc_segment_lookup
259 mc_hit_lookup = self.mc_hit_lookup
260
261 segment_crops = cdc_peelers.peel_segment2d(segment)
262
263 mc_particle = mc_segment_lookup.getMCParticle(segment)
264 mc_particle_crops = peelers.peel_mc_particle(mc_particle)
265
266 fit3d_truth = mc_segment_lookup.getTrajectory3D(segment)
267 curvature_truth = fit3d_truth.getCurvatureXY()
268
269 reconstructed_backward = mc_segment_lookup.isForwardOrBackwardToMCTrack(segment)
270 is_fake = mc_segment_lookup.getMCTrackId(segment) < 0
271
272 if reconstructed_backward != 1:
273 curvature_truth = -curvature_truth
274
275 truth_crops = dict(
276 tan_lambda_truth=fit3d_truth.getTanLambda(),
277 curvature_truth=curvature_truth,
278 abs_curvature_truth=abs(curvature_truth),
279 curvature_residual=segment_crops["curvature_estimate"] - curvature_truth,
280 curvature_pull=(segment_crops["curvature_estimate"] - curvature_truth) / segment_crops["curvature_variance"],
281 reconstructed_backward=reconstructed_backward,
282 is_fake=is_fake
283 )
284
285 rl_sum = 0
286 n_correct = 0
287 n_total = segment.size()
288 first_i_incorrect = float("nan")
289 last_i_incorrect = float("nan")
290 first_l_incorrect = 0
291 last_l_incorrect = 0
292
293 n_rl_switch = 0
294 last_rl_info = 0
295 for i, reco_hit2d in enumerate(segment):
296 rl_info = reco_hit2d.getRLInfo()
297 hit = reco_hit2d.getWireHit().getHit()
298 true_rl_info = mc_hit_lookup.getRLInfo(hit)
299
300 if rl_info != last_rl_info:
301 n_rl_switch += 1
302 last_rl_info = rl_info
303
304 if true_rl_info == rl_info:
305 n_correct += 1
306 else:
307 if first_i_incorrect != first_i_incorrect:
308 first_i_incorrect = i
309 first_l_incorrect = reco_hit2d.getRefDriftLength()
310 last_i_incorrect = i
311 last_l_incorrect = reco_hit2d.getRefDriftLength()
312 if rl_info == 1:
313 rl_sum += 1
314 elif rl_info == -1 or rl_info == 65535: # <- The root interface mistakes the signed enum value for an unsigned value
315 rl_sum -= 1
316
317 alias_score = segment.getAliasScore()
318
319 rl_crops = dict(
320 n_total=n_total,
321 n_correct=n_correct,
322 n_incorrect=n_total - n_correct,
323 rl_purity=n_correct / n_total,
324 first_incorrect_location=first_i_incorrect / (n_total - 1),
325 first_l_incorrect=first_l_incorrect,
326 last_incorrect_location=last_i_incorrect / (n_total - 1),
327 last_l_incorrect=last_l_incorrect,
328 n_rl_switch=n_rl_switch,
329 n_rl_asymmetry=rl_sum / n_total,
330 n_abs_rl_asymmetry=abs(rl_sum) / n_total,
331 may_alias=alias_score == 0,
332 alias_score=alias_score
333 )
334
335 segment_crops.update(truth_crops)
336 segment_crops.update(mc_particle_crops)
337 segment_crops.update(rl_crops)
338 return segment_crops
339
def peel_segment2d(segment, key="{part_name}")
Definition: cdc_peelers.py:14

◆ pick()

def pick (   self,
  segment 
)
Select segments with 4 or more hits and a matching primary MC particle

Definition at line 247 of file record.py.

247 def pick(self, segment):
248 """Select segments with 4 or more hits and a matching primary MC particle"""
249 mc_segment_lookup = self.mc_segment_lookup
250 mc_particle = mc_segment_lookup.getMCParticle(segment)
251
252 # Check that mc_particle is not a nullptr
253 return mc_particle and is_primary(mc_particle) and segment.size() > 3
254

◆ prepare()

def prepare (   self)
Initialize the MC-hit lookup method

Definition at line 243 of file record.py.

243 def prepare(self):
244 """Initialize the MC-hit lookup method"""
246

Member Data Documentation

◆ mc_hit_lookup

mc_hit_lookup

Method to find matching MC hits.

Definition at line 241 of file record.py.

◆ mc_segment_lookup

mc_segment_lookup

by default, there is no method to find matching MC track segments

Method to find matching MC track segments.

Definition at line 232 of file record.py.

◆ save_absolute_curvature_pull

refiners save_absolute_curvature_pull
static
Initial value:
= refiners.save_pull_analysis(
part_name="curvature",
unit="1/cm",
absolute=True,
aux_names=["tan_lambda_truth", "abs_curvature_truth"],
groupby=[
"stereo_kind",
"superlayer_id"
],
outlier_z_score=4.0,
title_postfix="")

Save absolute curvature-pull information in a sub folder.

Definition at line 377 of file record.py.

◆ save_curvature_pull

refiners save_curvature_pull
static
Initial value:
= refiners.save_pull_analysis(
part_name="curvature",
unit="1/cm",
absolute=False,
aux_names=["tan_lambda_truth", "abs_curvature_truth"],
groupby=[
"stereo_kind",
"superlayer_id"
],
outlier_z_score=4.0,
title_postfix="")

Save curvature-pull information in a sub folder.

Definition at line 347 of file record.py.

◆ save_curvature_pull_rl_pure

refiners save_curvature_pull_rl_pure
static
Initial value:
= refiners.save_pull_analysis(
part_name="curvature",
unit="1/cm",
absolute=True,
filter_on="rl_purity",
filter=lambda rl_purity: rl_purity > 0.5,
aux_names=["tan_lambda_truth", "abs_curvature_truth"],
groupby=[
"stereo_kind",
"superlayer_id"
],
outlier_z_score=4.0,
title_postfix="",
folder_name="rl_pure/{groupby_addition}"
)

Save right-left curvature-pull information in a sub folder.

Definition at line 360 of file record.py.

◆ save_fit_quality_histograms

refiners save_fit_quality_histograms
static
Initial value:
= refiners.save_histograms(
outlier_z_score=5.0,
select={
"ndf": "ndf",
"chi2": "#chi2",
"p_value": "p-value",
"tan_lambda_truth": "true tan #lambda",
},
groupby=[None, "stereo_kind", "superlayer_id"],
title="Histogram of {part_name}{stacked_by_indication}{stackby}",
description="Distribution of {part_name} in the segment fits",
)

Save fit-quality histograms in a sub folder.

Definition at line 390 of file record.py.

◆ save_histograms

refiners save_histograms = refiners.save_histograms(outlier_z_score=5.0, allow_discrete=True)
static

Save histograms in a sub folder.

Definition at line 342 of file record.py.

◆ save_tree

refiners save_tree = refiners.save_tree()
static

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

Definition at line 344 of file record.py.


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