Belle II Software development
ToFlat Class Reference
Inheritance diagram for ToFlat:
Transform ProTool

Public Member Functions

def __init__ (self, *args)
 
def get_flat_bins (self)
 
def get_x (self, x_flat)
 

Public Attributes

 cdf
 Transformation with the CDF.
 

Protected Member Functions

def _fit (self, x, y=None)
 
def _transform (self, x)
 

Detailed Description

This transformation uses the CDF to transform input data to a
flat transformation.

Attributes
----------
cdf : Transform.CDF
    Transformation with the CDF

Definition at line 235 of file transform.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
args 
)
 Init function

:param args: None

Reimplemented from Transform.

Definition at line 248 of file transform.py.

248 def __init__(self, *args):
249 """ Init function
250
251 :param args: None
252 """
253 Transform.__init__(self, "Flat", *args)
254
255
256 self.cdf = CDF(*args)
257

Member Function Documentation

◆ _fit()

def _fit (   self,
  x,
  y = None 
)
protected
Fit function calculates the cumulative distribution with numpy percentile.

:param x:   Inout distribution
:param y:   Will not be used in this transformation

Reimplemented from Transform.

Definition at line 258 of file transform.py.

258 def _fit(self, x, y=None):
259 """
260 Fit function calculates the cumulative distribution with numpy percentile.
261
262 :param x: Inout distribution
263 :param y: Will not be used in this transformation
264 """
265 self.io.debug("Fitting Flat")
266 self.cdf.fit(x)
267

◆ _transform()

def _transform (   self,
  x 
)
protected
Transforms the input data according to the cdf.
:param x:   Input data
:return:    Transformed data

Reimplemented from Transform.

Definition at line 268 of file transform.py.

268 def _transform(self, x):
269 """
270 Transforms the input data according to the cdf.
271 :param x: Input data
272 :return: Transformed data
273 """
274 if not self.is_processed:
275 self.fit(x)
276 return self.cdf.transform(x)
277

◆ get_flat_bins()

def get_flat_bins (   self)
Returns the binning of the CDF
:return: Binning for a flat distribution

Definition at line 278 of file transform.py.

278 def get_flat_bins(self):
279 """
280 Returns the binning of the CDF
281 :return: Binning for a flat distribution
282 """
283 return self.cdf.x
284

◆ get_x()

def get_x (   self,
  x_flat 
)
Dirty version for getting the original x value out of a flat x value.
:param x_flat:  x value in the flat distribution
:return:        x value on the original axis (approx)

Definition at line 285 of file transform.py.

285 def get_x(self, x_flat):
286 """
287 Dirty version for getting the original x value out of a flat x value.
288 :param x_flat: x value in the flat distribution
289 :return: x value on the original axis (approx)
290 """
291 x_cumul = np.linspace(self.min, self.max, self.n_bins * 50)
292 for xx in x_cumul:
293 if self.cdf.spline(xx) > x_flat:
294 return xx

Member Data Documentation

◆ cdf

cdf

Transformation with the CDF.

Definition at line 256 of file transform.py.


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