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

Public Member Functions

def __init__ (self, output_file_name)
 
def initialize (self)
 
def prepare (self)
 
def pick (self, segment_pair_relation)
 
def peel (self, segment_pair_relation)
 
def peel_target (self, segment_pair_relation)
 
def peel_mc (self, segment_pair_relation)
 
def peel_fit (self, segment_pair_relation)
 
def peel_fitless (self, segment_pair_relation)
 
def fit (self, segment_pair_relation)
 
def select_fitless (self, fitless_crops)
 
def select (self, crops)
 
def print_signal_number (self, crops, tdirectory, **kwds)
 

Public Attributes

 mc_segment_lookup
 defer reference to CDCMCSegment2dLookUp singleton until after it is constructed
 
 mc_segment_pair_filter
 defer reference to MCSegmentPairFilter until after it is constructed
 
 segment_pair_fusion
 defer reference to CDCAxialStereoFusion until after it is constructed
 

Static Public Attributes

float delta_phi_cut_value = 1.0
 default selection for the delta-phi of the segment pair
 
float is_after_cut_value = 1.0
 default selection for the ordering of the segment pair
 
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_fitless_selection_variables_histograms
 Save a tree of track-segment-without-fit variables in a sub folder.
 
refiners save_view_is_after_cut_histograms
 Save a tree of mal-ordered track-segment-pair variables in a sub folder.
 
refiners save_view_delta_phi_cut_histograms
 Save a tree of delta-phi-cut track-segment-pair variables in a sub folder.
 
refiners save_selection_variables_after_fitless_selection_histograms
 Save a tree of track-segment-pair selection variables in a sub folder.
 
refiners save_p_value_over_curvature_profile
 Save a tree of track-segment-pair p-value and curvature variables in a sub folder.
 

Detailed Description

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

Definition at line 85 of file segmentPairCreationValidation.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  output_file_name 
)
Constructor

Definition at line 89 of file segmentPairCreationValidation.py.

89 def __init__(self, output_file_name):
90 """Constructor"""
91 super().__init__(foreach="CDCSegmentPairVector",
92 output_file_name=output_file_name)
93
94 self.mc_segment_lookup = None
95
96 self.mc_segment_pair_filter = None
97
98 self.segment_pair_fusion = None
99

Member Function Documentation

◆ fit()

def fit (   self,
  segment_pair_relation 
)
Fit the segment pair

Definition at line 252 of file segmentPairCreationValidation.py.

252 def fit(self, segment_pair_relation):
253 """Fit the segment pair"""
254 self.segment_pair_fusion.reconstructFuseTrajectories(segment_pair_relation, True)
255

◆ initialize()

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

Definition at line 100 of file segmentPairCreationValidation.py.

100 def initialize(self):
101 """Receive signal at the start of event processing"""
102 super().initialize()
104 self.mc_segment_pair_filter = Belle2.TrackFindingCDC.MCSegmentPairFilter()
105 self.segment_pair_fusion = Belle2.TrackFindingCDC.CDCAxialStereoFusion
106
Utility class implementing the Kalmanesk combination of to two dimensional trajectories to one three ...
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Filter for the construction of axial to stereo segment pairs based on MC information.

◆ peel()

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

Definition at line 122 of file segmentPairCreationValidation.py.

122 def peel(self, segment_pair_relation):
123 """Aggregate the track and MC information for track segment-pair analysis"""
124 crops = self.peel_target(segment_pair_relation)
125 crops.update(self.peel_mc(segment_pair_relation))
126 crops.update(self.peel_fit(segment_pair_relation))
127 return crops
128

◆ peel_fit()

def peel_fit (   self,
  segment_pair_relation 
)
Create a dictionary of track-segment-fit information

Definition at line 154 of file segmentPairCreationValidation.py.

154 def peel_fit(self, segment_pair_relation):
155 """Create a dictionary of track-segment-fit information"""
156 fitless_crops = self.peel_fitless(segment_pair_relation)
157
158 select_fitless = fitless_crops["select_fitless"]
159 if select_fitless:
160 # Now fit
161 self.fit(segment_pair_relation)
162 fit3d = segment_pair_relation.getTrajectory3D()
163
164 i_curv = 0
165 i_tan_lambda = 3
166
167 chi2 = fit3d.getChi2()
168 ndf = fit3d.getNDF()
169
170 curvature_estimate = fit3d.getCurvatureXY()
171 curvature_variance = fit3d.getLocalVariance(i_curv)
172
173 tan_lambda_estimate = fit3d.getTanLambda()
174 tan_lambda_variance = fit3d.getLocalVariance(i_tan_lambda)
175
176 chi2 = chi2
177 ndf = ndf
178 p_value = prob(chi2, ndf)
179 # select = True
180
181 else:
182 nan = float('nan')
183 curvature_estimate = nan
184 curvature_variance = nan
185
186 tan_lambda_estimate = nan
187 tan_lambda_variance = nan
188
189 chi2 = nan
190 ndf = nan
191 p_value = nan
192
193 crops = dict(
194 curvature_estimate=curvature_estimate,
195 curvature_variance=curvature_variance,
196
197 tan_lambda_estimate=tan_lambda_estimate,
198 tan_lambda_variance=tan_lambda_variance,
199
200 chi2=chi2,
201 ndf=ndf,
202 p_value=p_value,
203 )
204
205 if select_fitless:
206 crops["select"] = self.select(crops)
207 else:
208 crops["select"] = False
209
210 crops.update(fitless_crops)
211
212 return crops
213

◆ peel_fitless()

def peel_fitless (   self,
  segment_pair_relation 
)
Create a dictionary of track-segments-without-fit information

Definition at line 214 of file segmentPairCreationValidation.py.

214 def peel_fitless(self, segment_pair_relation):
215 """Create a dictionary of track-segments-without-fit information"""
216 # Try to make some judgements without executing the common fit.
217
218 start_segment = segment_pair_relation.getStartSegment()
219 end_segment = segment_pair_relation.getEndSegment()
220
221 start_fit2d = start_segment.getTrajectory2D()
222 end_fit2d = end_segment.getTrajectory2D()
223
224 start_superlayer_id = start_segment.getISuperLayer()
225 end_superlayer_id = end_segment.getISuperLayer()
226
227 sorted_superlayer_ids = sorted([start_superlayer_id, end_superlayer_id])
228
229 superlayer_id_pair = 10.0 * sorted_superlayer_ids[1] + sorted_superlayer_ids[0]
230
231 fitless_crops = dict(
232 start_superlayer_id=start_superlayer_id,
233 end_superlayer_id=end_superlayer_id,
234 superlayer_id_pair=superlayer_id_pair,
235
236 start_size=start_segment.size(),
237 end_size=end_segment.size(),
238
239 start_curvature_estimate=start_fit2d.getCurvature(),
240 end_curvature_estimate=end_fit2d.getCurvature(),
241
242 delta_phi=segment_pair_relation.computeDeltaPhiAtSuperLayerBound(),
243 is_coaligned=segment_pair_relation.computeIsCoaligned(),
244
245 start_is_before_end=segment_pair_relation.computeStartIsBeforeEnd(),
246 end_is_after_start=segment_pair_relation.computeEndIsAfterStart(),
247 )
248
249 fitless_crops["select_fitless"] = self.select_fitless(fitless_crops)
250 return fitless_crops
251

◆ peel_mc()

def peel_mc (   self,
  segment_pair_relation 
)
Create a dictionary of MC-truth (curvature,tanlambda) pairs

Definition at line 139 of file segmentPairCreationValidation.py.

139 def peel_mc(self, segment_pair_relation):
140 """Create a dictionary of MC-truth (curvature,tanlambda) pairs"""
141 mc_segment_lookup = self.mc_segment_lookup
142
143 end_segment = segment_pair_relation.getEndSegment()
144
145 # Take the fit best at the middle of the segment pair
146 # mc_particle = mc_segment_lookup.getMCParticle(end_segment)
147 fit3d_truth = mc_segment_lookup.getTrajectory3D(end_segment)
148
149 return dict(
150 curvature_truth=fit3d_truth.getCurvatureXY(),
151 tan_lambda_truth=fit3d_truth.getTanLambda(),
152 )
153

◆ peel_target()

def peel_target (   self,
  segment_pair_relation 
)
Create a dictionary of MC-truth (weight,decision) pairs

Definition at line 129 of file segmentPairCreationValidation.py.

129 def peel_target(self, segment_pair_relation):
130 """Create a dictionary of MC-truth (weight,decision) pairs"""
131 mc_weight = self.mc_segment_pair_filter(segment_pair_relation)
132 mc_decision = np.isfinite(mc_weight) # Filters for nan
133
134 return dict(
135 mc_weight=mc_weight,
136 mc_decision=mc_decision,
137 )
138

◆ pick()

def pick (   self,
  segment_pair_relation 
)
Select segment pairs with 4 or more hit in each segments and a matching primary MC particle

Definition at line 111 of file segmentPairCreationValidation.py.

111 def pick(self, segment_pair_relation):
112 """Select segment pairs with 4 or more hit in each segments and a matching primary MC particle"""
113 mc_segment_lookup = self.mc_segment_lookup
114 start_segment = segment_pair_relation.getStartSegment()
115 end_segment = segment_pair_relation.getEndSegment()
116 mc_particle = mc_segment_lookup.getMCParticle(start_segment)
117 return (mc_particle and
118 is_primary(mc_particle) and
119 start_segment.size() > 3 and
120 end_segment.size() > 3)
121

◆ prepare()

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

Definition at line 107 of file segmentPairCreationValidation.py.

107 def prepare(self):
108 """Initialize the MC-hit lookup method"""
110
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.

◆ print_signal_number()

def print_signal_number (   self,
  crops,
  tdirectory,
**  kwds 
)
Print diagnostic information about the track-segment-pair selection

Definition at line 331 of file segmentPairCreationValidation.py.

331 def print_signal_number(self, crops, tdirectory, **kwds):
332 """Print diagnostic information about the track-segment-pair selection"""
333 info = get_logger().info
334
335 # start_superlayer_ids = crops["start_superlayer_id"]
336 # end_superlayer_ids = crops["end_superlayer_id"]
337
338 superlayer_id_pair = crops["superlayer_id_pair"]
339 info("Number of pairs in superlayers %s : %s", np.unique(superlayer_id_pair), len(superlayer_id_pair))
340
341 mc_decisions = crops["mc_decision"]
342 n = len(mc_decisions)
343 n_signal = np.sum(mc_decisions)
344 n_background = n - n_signal
345 info("#Signal : %s", n_signal)
346 info("#Background : %s", n_background)
347
348 fitless_selections = np.nonzero(crops["select_fitless"])
349 info("#Signal after precut : %s", np.sum(mc_decisions[fitless_selections]))
350 info("#Background after precut : %s", np.sum(1 - mc_decisions[fitless_selections]))
351
352

◆ select()

def select (   self,
  crops 
)
Select every track-segment-pair

Definition at line 269 of file segmentPairCreationValidation.py.

269 def select(self, crops):
270 """Select every track-segment-pair"""
271 return True
272

◆ select_fitless()

def select_fitless (   self,
  fitless_crops 
)
Selection of track-segments-without-fit

Definition at line 261 of file segmentPairCreationValidation.py.

261 def select_fitless(self, fitless_crops):
262 """Selection of track-segments-without-fit"""
263 delta_phi = fitless_crops["delta_phi"]
264 start_is_before_end = fitless_crops["start_is_before_end"]
265 end_is_after_start = fitless_crops["end_is_after_start"]
266 is_after_select = (abs(start_is_before_end) < self.is_after_cut_value) & (abs(end_is_after_start) < self.is_after_cut_value)
267 return (abs(delta_phi) < self.delta_phi_cut_value) & is_after_select
268

Member Data Documentation

◆ delta_phi_cut_value

float delta_phi_cut_value = 1.0
static

default selection for the delta-phi of the segment pair

Definition at line 257 of file segmentPairCreationValidation.py.

◆ is_after_cut_value

float is_after_cut_value = 1.0
static

default selection for the ordering of the segment pair

Definition at line 259 of file segmentPairCreationValidation.py.

◆ mc_segment_lookup

mc_segment_lookup

defer reference to CDCMCSegment2dLookUp singleton until after it is constructed

Definition at line 94 of file segmentPairCreationValidation.py.

◆ mc_segment_pair_filter

mc_segment_pair_filter

defer reference to MCSegmentPairFilter until after it is constructed

Definition at line 96 of file segmentPairCreationValidation.py.

◆ save_fitless_selection_variables_histograms

refiners save_fitless_selection_variables_histograms
static
Initial value:
= refiners.save_histograms(
select=["mc_decision", "delta_phi", "start_is_before_end", "end_is_after_start", "is_coaligned"],
outlier_z_score=5.0,
allow_discrete=True,
stackby="mc_decision",
folder_name="fitless_selection_variables",
)

Save a tree of track-segment-without-fit variables in a sub folder.

Definition at line 281 of file segmentPairCreationValidation.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 275 of file segmentPairCreationValidation.py.

◆ save_p_value_over_curvature_profile

refiners save_p_value_over_curvature_profile
static
Initial value:
= refiners.save_profiles(
select={"p_value": "p-value", "curvature_truth": "true curvature"},
y="p-value",
folder_name="selection_variables_after_fitless_selection",
title=r"$p$-value versus true curvature after fitless selection",
filter_on="select_fitless",
)

Save a tree of track-segment-pair p-value and curvature variables in a sub folder.

Definition at line 320 of file segmentPairCreationValidation.py.

◆ save_selection_variables_after_fitless_selection_histograms

refiners save_selection_variables_after_fitless_selection_histograms
static
Initial value:
= refiners.save_histograms(
select=["mc_decision", "chi2", "ndf", "p_value"],
outlier_z_score=5.0,
allow_discrete=True,
stackby="mc_decision",
folder_name="selection_variables_after_fitless_selection",
filter_on="select_fitless",
)

Save a tree of track-segment-pair selection variables in a sub folder.

Definition at line 309 of file segmentPairCreationValidation.py.

◆ save_tree

refiners save_tree = refiners.save_tree()
static

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

Definition at line 277 of file segmentPairCreationValidation.py.

◆ save_view_delta_phi_cut_histograms

refiners save_view_delta_phi_cut_histograms
static
Initial value:
= refiners.save_histograms(
select=["mc_decision", "delta_phi"],
lower_bound=-delta_phi_cut_value,
upper_bound=delta_phi_cut_value,
stackby="mc_decision",
folder_name="view_fitless_cuts",
)

Save a tree of delta-phi-cut track-segment-pair variables in a sub folder.

Definition at line 299 of file segmentPairCreationValidation.py.

◆ save_view_is_after_cut_histograms

refiners save_view_is_after_cut_histograms
static
Initial value:
= refiners.save_histograms(
select=["mc_decision", "start_is_before_end", "end_is_after_start"],
lower_bound=-is_after_cut_value,
upper_bound=is_after_cut_value,
stackby="mc_decision",
folder_name="view_fitless_cuts",
)

Save a tree of mal-ordered track-segment-pair variables in a sub folder.

Definition at line 290 of file segmentPairCreationValidation.py.

◆ segment_pair_fusion

segment_pair_fusion

defer reference to CDCAxialStereoFusion until after it is constructed

Definition at line 98 of file segmentPairCreationValidation.py.


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