Belle II Software  release-08-01-10
cdc_peelers.py
1 
8 
9 import tracking.harvest.peelers as peelers
10 from tracking.validation.utilities import prob
11 
12 
13 @peelers.format_crop_keys
14 def peel_segment2d(segment, key="{part_name}"):
15  superlayer_id = segment.getISuperLayer()
16  size = segment.size()
17  supercluster_id = segment.getISuperCluster()
18 
19  trajectory2d = segment.getTrajectory2D()
20  trajectory2d_crops = peel_trajectory2d(trajectory2d, key="{part_name}")
21 
22  crops = dict(
23  size=size,
24  superlayer_id=superlayer_id,
25  supercluster_id=supercluster_id,
26  stereo_kind=segment.getStereoKind(),
27  )
28 
29  crops.update(trajectory2d_crops)
30  return crops
31 
32 
33 @peelers.format_crop_keys
34 def peel_trajectory2d(trajectory2d, key="{part_name}"):
35  chi2 = trajectory2d.getChi2()
36  ndf = trajectory2d.getNDF()
37  is_fitted = trajectory2d.isFitted()
38 
39  i_curv = 0
40  curvature_estimate = trajectory2d.getCurvature()
41  curvature_variance = trajectory2d.getLocalVariance(i_curv)
42 
43  return dict(
44  chi2=chi2,
45  ndf=ndf,
46  is_fitted=is_fitted,
47  p_value=prob(chi2, ndf),
48  curvature_estimate=curvature_estimate,
49  curvature_variance=curvature_variance,
50  )
51 
52 
53 @peelers.format_crop_keys
54 def peel_trajectory3d(trajectory3d, key="{part_name}"):
55  i_curv = 0
56  i_tan_lambda = 3
57 
58  curvature_estimate = trajectory3d.getCurvatureXY()
59  curvature_variance = trajectory3d.getLocalVariance(i_curv)
60 
61  tan_lambda_estimate = trajectory3d.getTanLambda()
62  tan_lambda_variance = trajectory3d.getLocalVariance(i_tan_lambda)
63 
64  chi2 = trajectory3d.getChi2()
65  ndf = trajectory3d.getNDF()
66 
67  return dict(
68  chi2=chi2,
69  ndf=ndf,
70  p_value=prob(chi2, ndf),
71  curvature_estimate=curvature_estimate,
72  curvature_variance=curvature_variance,
73  tan_lambda_estimate=tan_lambda_estimate,
74  tan_lambda_variance=tan_lambda_variance,
75  )
76 
77 
78 @peelers.format_crop_keys
79 def peel_segment_pair(segment_pair, key="{part_name}"):
80  from_segment = segment_pair.getFromSegment()
81  to_segment = segment_pair.getToSegment()
82 
83  from_segment_crops = peel_segment2d(from_segment, key="from_{part_name}")
84  to_segment_crops = peel_segment2d(to_segment, key="to_{part_name}")
85 
86  sorted_superlayer_ids = sorted([from_segment_crops["from_superlayer_id"],
87  to_segment_crops["to_superlayer_id"]])
88 
89  superlayer_id_pair = 10.0 * sorted_superlayer_ids[1] + sorted_superlayer_ids[0]
90 
91  trajectory3d = segment_pair.getTrajectory3D()
92  trajectory3d_crops = peel_trajectory3d(trajectory3d, key="{part_name}")
93 
94  crops = dict(
95  superlayer_id_pair=superlayer_id_pair
96  )
97 
98  crops.update(from_segment_crops)
99  crops.update(to_segment_crops)
100  crops.update(trajectory3d_crops)
101 
102  return crops