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

Public Member Functions

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

Public Attributes

 mc_track_lookup
 by default, there is no method to find matching MC tracks
 
 track_fitter
 Use the CDCReimannFitter with a constrained origin for track fitting.
 
 lower_curv_bounds
 cached copy of lower bounds
 
 upper_curv_bounds
 cached copy of upper bounds
 
 mc_hit_lookup
 Method to find matching MC hits.
 

Static Public Attributes

refiners save_tree = refiners.save_tree()
 Save a tree of all collected variables in a sub folder.
 
refiners save_histograms = refiners.save_histograms(outlier_z_score=5.0, allow_discrete=True)
 Save histograms in a sub folder.
 
refiners save_profiles
 Save profile histograms in a sub folder.
 
refiners save_cross_curv_profile
 Save cross-curvature profile histograms in a sub folder.
 
refiners save_scatter = refiners.save_scatters(x=['curvature_estimate'], y='n_hits')
 Save scatterplots in a sub folder.
 

Detailed Description

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

Definition at line 82 of file record.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  output_file_name 
)
Constructor

Definition at line 87 of file record.py.

87 def __init__(self, output_file_name):
88 """Constructor"""
89 super().__init__(foreach='CDCTrackVector',
90 output_file_name=output_file_name)
91
92
93 self.mc_track_lookup = None
94
95 origin_track_fitter = TFCDC.CDCRiemannFitter()
96 origin_track_fitter.setOriginConstrained()
97
98 self.track_fitter = origin_track_fitter
99
100 curv_bounds = []
101 with open('fine_curv_bounds.txt') as curv_bounds_file:
102 for curv_bound_line in curv_bounds_file:
103 curv_bounds.append(float(curv_bound_line))
104
105 bin_bounds = list(zip(curv_bounds[0::2], curv_bounds[1::2]))
106 bin_bounds = sorted(bin_bounds)
107
108
109 self.lower_curv_bounds = np.array([bin[0] for bin in bin_bounds])
110
111 self.upper_curv_bounds = np.array([bin[1] for bin in bin_bounds])
112
113 assert(len(self.lower_curv_bounds) == len(self.upper_curv_bounds))
114

Member Function Documentation

◆ initialize()

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

Definition at line 115 of file record.py.

115 def initialize(self):
116 """Receive signal at the start of event processing"""
117 super().initialize()
118
119 self.mc_track_lookup = TFCDC.CDCMCTrackLookUp.getInstance()
120
121 self.mc_hit_lookup = TFCDC.CDCMCHitLookUp.getInstance()
122

◆ peel()

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

Definition at line 135 of file record.py.

135 def peel(self, track):
136 """Aggregate the track and MC information for track-segment analysis"""
137 track_fitter = self.track_fitter
138
139 rl_drift_circle = 1
140 unit_variance = 0
141 observations2D = TFCDC.CDCObservations2D(rl_drift_circle, unit_variance)
142
143 for recoHit3D in track:
144 observations2D.append(recoHit3D)
145
146 trajectory2D = track_fitter.fit(observations2D)
147 trajectory2D.setLocalOrigin(TFCDC.Vector2D(0, 0))
148
149 n_hits = track.size()
150 pt = trajectory2D.getAbsMom2D()
151 curv = trajectory2D.getCurvature()
152 curl_curv = abs(self.lower_curv_bounds[0])
153 bin_curv = curv if abs(curv) < curl_curv else abs(curv)
154 curv_var = trajectory2D.getLocalVariance(0)
155 impact = trajectory2D.getGlobalImpact()
156 phi0 = trajectory2D.getLocalCircle().phi0()
157
158 circle = trajectory2D.getLocalCircle()
159 n12 = circle.n12()
160
161 cross_curvs = []
162 for recoHit3D in track:
163 wire_ref_pos = recoHit3D.getRefPos2D()
164 drift_length = recoHit3D.getSignedRecoDriftLength()
165 r = wire_ref_pos.norm()
166 cross_curv = -2 * (n12.dot(wire_ref_pos) - drift_length) / (r * r - drift_length * drift_length)
167 cross_curvs.append(cross_curv)
168
169 cross_curvs = np.array(cross_curvs)
170 cross_curv = np.median(cross_curvs)
171 cross_curv_var = np.median(np.abs(cross_curvs - cross_curv))
172
173 basic_curv_precision = TFCDC.PrecisionUtil.getBasicCurvPrecision(cross_curv)
174 origin_curv_precision = TFCDC.PrecisionUtil.getOriginCurvPrecision(cross_curv)
175 non_origin_curv_precision = TFCDC.PrecisionUtil.getNonOriginCurvPrecision(cross_curv)
176
177 bin_id = np.digitize([abs(cross_curv)], self.lower_curv_bounds)
178 if bin_id == 0:
179 max_curv_precision = 0.00007
180 else:
181 max_curv_precision = self.upper_curv_bounds[bin_id - 1] - self.lower_curv_bounds[bin_id - 1]
182
183 random_bin_id = random.randrange(len(self.upper_curv_bounds))
184 random_lower_curv_bound = self.lower_curv_bounds[random_bin_id]
185 random_upper_curv_bound = self.upper_curv_bounds[random_bin_id]
186 curv_dense = random.uniform(random_lower_curv_bound, random_upper_curv_bound)
187 curv_width = random_upper_curv_bound - random_lower_curv_bound
188
189 return dict(
190 n_hits=n_hits,
191 curvature_estimate=curv,
192 curvature_variance=curv_var,
193 abs_curvature_estimate=abs(curv),
194 inv_curv=1.0 / abs(curv),
195 cross_curv=cross_curv,
196 cross_curv_var=cross_curv_var,
197 basic_curv_precision=basic_curv_precision,
198 origin_curv_precision=origin_curv_precision,
199 non_origin_curv_precision=non_origin_curv_precision,
200 max_curv_precision=max_curv_precision,
201 pt=pt,
202 curv_bin=bin_curv,
203 curv_dense=curv_dense,
204 curv_width=curv_width,
205 impact_estimate=impact,
206 phi0=phi0,
207 )
208

◆ pick()

def pick (   self,
  track 
)
Select tracks with at least 4 segments and associated primary MC particle

Definition at line 127 of file record.py.

127 def pick(self, track):
128 """Select tracks with at least 4 segments and associated primary MC particle"""
129 mc_track_lookup = self.mc_track_lookup
130 mc_particle = mc_track_lookup.getMCParticle(track)
131
132 # Check that mc_particle is not a nullptr
133 return mc_particle and is_primary(mc_particle) and track.size() > 3
134

◆ prepare()

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

Definition at line 123 of file record.py.

123 def prepare(self):
124 """Initialize the MC-hit lookup method"""
125 TFCDC.CDCMCHitLookUp.getInstance().fill()
126

Member Data Documentation

◆ lower_curv_bounds

lower_curv_bounds

cached copy of lower bounds

Definition at line 109 of file record.py.

◆ mc_hit_lookup

mc_hit_lookup

Method to find matching MC hits.

Definition at line 121 of file record.py.

◆ mc_track_lookup

mc_track_lookup

by default, there is no method to find matching MC tracks

Method to find matching MC tracks.

Definition at line 93 of file record.py.

◆ save_cross_curv_profile

refiners save_cross_curv_profile
static
Initial value:
= refiners.save_profiles(x=['cross_curv'],
y=['cross_curv_var',
'curvature_estimate',
'basic_curv_precision',
'origin_curv_precision',
'non_origin_curv_precision',
'max_curv_precision',
],
outlier_z_score=5.0)

Save cross-curvature profile histograms in a sub folder.

Definition at line 221 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 213 of file record.py.

◆ save_profiles

refiners save_profiles
static
Initial value:
= refiners.save_profiles(x=['curvature_estimate', 'phi0'],
y='curvature_variance',
outlier_z_score=5.0)

Save profile histograms in a sub folder.

Definition at line 216 of file record.py.

◆ save_scatter

refiners save_scatter = refiners.save_scatters(x=['curvature_estimate'], y='n_hits')
static

Save scatterplots in a sub folder.

Definition at line 232 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 211 of file record.py.

◆ track_fitter

track_fitter

Use the CDCReimannFitter with a constrained origin for track fitting.

Definition at line 98 of file record.py.

◆ upper_curv_bounds

upper_curv_bounds

cached copy of upper bounds

Definition at line 111 of file record.py.


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