Belle II Software development
FunctionFittedGroupedDEDXEstimatorTrainer Class Reference
Inheritance diagram for FunctionFittedGroupedDEDXEstimatorTrainer:
FittedGroupedDEDXEstimatorTrainer GroupedDEDXEstimationTrainer DEDXEstimationTrainer GaussianEstimatorTrainer GaussianEstimatorTrainerSQRT LandauEstimatorTrainer LandauEstimatorTrainerSQRT

Public Member Functions

def __init__ (self, fit_function, dimension_of_fit_function, result_function, use_sigma_for_result_fitting)
 
def plot_grouped_result (self, data)
 

Public Attributes

 dimension_of_fit_function
 cached value of the degrees of freedom in the fit
 
 fit_function
 cached copy of the fitting function
 
 train_function
 this class's training function
 

Detailed Description

Train a neural network for dE/dx-based particle identification

Definition at line 193 of file train.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  fit_function,
  dimension_of_fit_function,
  result_function,
  use_sigma_for_result_fitting 
)
Constructor

Reimplemented from FittedGroupedDEDXEstimatorTrainer.

Reimplemented in GaussianEstimatorTrainer, LandauEstimatorTrainer, GaussianEstimatorTrainerSQRT, and LandauEstimatorTrainerSQRT.

Definition at line 196 of file train.py.

196 def __init__(self, fit_function, dimension_of_fit_function, result_function, use_sigma_for_result_fitting):
197 """Constructor"""
198
199
200 self.dimension_of_fit_function = dimension_of_fit_function
201
202 self.fit_function = fit_function
203
204 FittedGroupedDEDXEstimatorTrainer.__init__(self, result_function, use_sigma_for_result_fitting)
205
206 def train_function(fit_data):
207 """Train on the fit to curated-data highest values whose truth value is known"""
208 max_value = self.use_only_the_highest_values(fit_data, 1).p_bin_centers.values[0]
209
210 if self.dimension_of_fit_function == 3:
211 p0 = (1e3, max_value, 4e-2)
212 elif self.dimension_of_fit_function == 6:
213 p0 = (1e3, max_value, 4e-2, 1, 1, 1)
214
215 popt, pcov = curve_fit(self.fit_function, fit_data.p_bin_centers, fit_data.number_of_p_values, p0=p0)
216
217 return [np.sqrt(np.diag(pcov)[1]), popt]
218
219
220 self.train_function = train_function
221

Member Function Documentation

◆ plot_grouped_result()

def plot_grouped_result (   self,
  data 
)
Plot the fitted grouped results

Reimplemented from FittedGroupedDEDXEstimatorTrainer.

Definition at line 222 of file train.py.

222 def plot_grouped_result(self, data):
223 """Plot the fitted grouped results"""
224 FittedGroupedDEDXEstimatorTrainer.plot_grouped_result(self, data)
225
226 dedx_binned_data, dedx_bins = self.create_dedx_bins(data)
227
228 p_plot_data = np.linspace(data.p.min(), data.p.max(), 1000)
229
230 # List to prevent bug in pd.DataFrame.apply
231 already_plotted_list = []
232
233 def plot_fitted_results(dedx_bin):
234 dedx_bin_center = dedx_bin.mean().values[0]
235
236 if dedx_bin_center not in already_plotted_list:
237 fitted_results = self.result_parameters_for_each_dedx_bin[dedx_bin.mean()[self.dedx_column]]
238 already_plotted_list.append(dedx_bin_center)
239 unneeded, fit_options = fitted_results
240
241 dedx_plot_data = self.fit_function(p_plot_data, *fitted_results[1])
242 plt.plot(p_plot_data, dedx_plot_data)
243
244 return True
245
246 dedx_binned_data.apply(plot_fitted_results)
247
248

Member Data Documentation

◆ dimension_of_fit_function

dimension_of_fit_function

cached value of the degrees of freedom in the fit

Definition at line 200 of file train.py.

◆ fit_function

fit_function

cached copy of the fitting function

Definition at line 202 of file train.py.

◆ train_function

train_function

this class's training function

Definition at line 220 of file train.py.


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