Belle II Software development
SampleGenerator Class Reference

Public Member Functions

def __init__ (self, t0_bounds, tau_bounds, amplitude_bounds, sigma_bounds, tau_sigma, bin_size, wf=betaprime_wave)
 
def get_t0_bounds (self)
 
def get_amp_bounds (self)
 
def get_tau_bounds (self)
 
def set_tau_bounds (self, tau_min, tau_max)
 
def set_tau_sigma (self, tau_sigma)
 
def get_tau_sigma (self)
 
def get_sigma_bounds (self)
 
def generate (self, sample_size)
 
def get_t0_array (self)
 
def get_t0_bins (self)
 

Public Attributes

 t0_max
 t0 bounds
 
 tau_max
 tau bounds
 
 amp_max
 amplitude bounds
 
 sigma_max
 sigma bounds
 
 tau_coder
 tau encored
 
 tau_sigma
 tau sigma
 
 bin_size
 bin size
 
 wf
 wf ?
 
 tau_min
 tau min
 
 n_samples
 sample size
 
 stockdata
 stock data
 
 t0_bins
 undocumented variable
 
 t0_bin_times
 undocumented variable
 

Detailed Description

This class generates a Pandas dataframe with a random sample of SVD strip signals with specified size and parameters.
NB:
1. We generate time bins from quantiles, do we want a regular grid?
2. Have to think of possible irregular grid.

Definition at line 201 of file SVDSimBase.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  t0_bounds,
  tau_bounds,
  amplitude_bounds,
  sigma_bounds,
  tau_sigma,
  bin_size,
  wf = betaprime_wave 
)
The constructor takes the following parameters:
t0_bounds is a tuple, (t0_min, t0_max)
tau_bounds is a tuple (tau_min, tau_max)
amplitude_bounds is a tuple (amp_min, amp_max)
sigma_bounds is a tuple (sigma_min, sigma_max)
bin_size is the % fraction of t0_min, t0_max interval corresponding to a single output t0 bin.

Definition at line 209 of file SVDSimBase.py.

209 def __init__(self, t0_bounds, tau_bounds, amplitude_bounds, sigma_bounds, tau_sigma, bin_size, wf=betaprime_wave):
210 """
211 The constructor takes the following parameters:
212 t0_bounds is a tuple, (t0_min, t0_max)
213 tau_bounds is a tuple (tau_min, tau_max)
214 amplitude_bounds is a tuple (amp_min, amp_max)
215 sigma_bounds is a tuple (sigma_min, sigma_max)
216 bin_size is the % fraction of t0_min, t0_max interval corresponding to a single output t0 bin.
217 """
218
219
220 self.t0_min, self.t0_max = t0_bounds
221
222 self.tau_min, self.tau_max = tau_bounds
223
224 self.amp_min, self.amp_max = amplitude_bounds
225
226 self.sigma_min, self.sigma_max = sigma_bounds
227
228 self.tau_coder = tau_encoder(amplitude_bounds, tau_bounds)
229
230 self.tau_sigma = tau_sigma
231
232 self.bin_size = bin_size
233
234 self.wf = wf
235

Member Function Documentation

◆ generate()

def generate (   self,
  sample_size 
)
Generate sample_size samples.

Definition at line 280 of file SVDSimBase.py.

280 def generate(self, sample_size):
281 '''
282 Generate sample_size samples.
283 '''
284
285 self.n_samples = sample_size
286
287 self.stockdata = pd.DataFrame({
288 'test': np.random.uniform(size=self.n_samples),
289 't0': np.random.uniform(self.t0_min, self.t0_max, size=self.n_samples),
290 'tau': np.random.uniform(self.tau_min, self.tau_max, size=self.n_samples),
291 'sigma': np.random.uniform(self.sigma_min, self.sigma_max, size=self.n_samples),
292 'amplitude': np.random.uniform(self.amp_min, self.amp_max, size=self.n_samples),
293 's1': np.zeros(self.n_samples),
294 's2': np.zeros(self.n_samples),
295 's3': np.zeros(self.n_samples),
296 's4': np.zeros(self.n_samples),
297 's5': np.zeros(self.n_samples),
298 's6': np.zeros(self.n_samples)
299 })
300 self.stockdata['normed_tau'] = self.stockdata.apply(lambda row: self.tau_coder.encode(row.tau), axis=1)
301 orderedcols = ['test', 'amplitude', 't0', 'tau', 'sigma', 's1', 's2', 's3', 's4', 's5', 's6', 'normed_tau']
302 self.stockdata = self.stockdata[orderedcols]
303 # This is where the data are generated
304 self.stockdata[['s' + str(i) for i in range(1, 7)]] = self.stockdata.apply(lambda row: pd.Series(
305 gen_signal(row.amplitude, row.t0, row.tau, row.sigma, tau_sigma=self.tau_sigma, w=self.wf)), axis=1)
306
307 self.t0_bins = np.percentile(self.stockdata.t0, np.arange(0, 101, self.bin_size))
308 self.t0_bins[0] = self.t0_bins[0] - 0.1
309 self.t0_bins[-1] = self.t0_bins[-1] + 0.1
310 self.stockdata['t0_bin'] = np.digitize(self.stockdata.t0, self.t0_bins)
311
312 self.t0_bin_times = self.stockdata['t0'].groupby(self.stockdata.t0_bin).aggregate(np.mean)
313 abins = np.arange(self.amp_min, self.amp_max + 1, 1)
314 self.stockdata['abin'] = np.digitize(self.stockdata.amplitude, abins)
315 return self.stockdata
316

◆ get_amp_bounds()

def get_amp_bounds (   self)
Get amplitude bounds of sampling space

Definition at line 242 of file SVDSimBase.py.

242 def get_amp_bounds(self):
243 '''
244 Get amplitude bounds of sampling space
245 '''
246 return (self.amp_min, self.amp_max)
247

◆ get_sigma_bounds()

def get_sigma_bounds (   self)
Get sigma bounds

Definition at line 274 of file SVDSimBase.py.

274 def get_sigma_bounds(self):
275 '''
276 Get sigma bounds
277 '''
278 return (self.sigma_min, self.sigma_max)
279

◆ get_t0_array()

def get_t0_array (   self)
Get array of mean t0's for classifier bins

Definition at line 317 of file SVDSimBase.py.

317 def get_t0_array(self):
318 '''
319 Get array of mean t0's for classifier bins
320 '''
321 return self.t0_bin_times
322

◆ get_t0_bins()

def get_t0_bins (   self)
Get array of mean t0's for classifier bins

Definition at line 323 of file SVDSimBase.py.

323 def get_t0_bins(self):
324 '''
325 Get array of mean t0's for classifier bins
326 '''
327 return pd.Series(self.t0_bins)
328
329
330# ==============================================================================
331# Tau (scale) conversion and encoding
332# ------------------------------------------------------------------------------
333'''
334Empirical ranges of raw waveform width values from February 2017 testbeam data.
335These values are only used for scaling and not critical.
336'''

◆ get_t0_bounds()

def get_t0_bounds (   self)
Get t0 bounds of sampling space

Definition at line 236 of file SVDSimBase.py.

236 def get_t0_bounds(self):
237 '''
238 Get t0 bounds of sampling space
239 '''
240 return (self.t0_min, self.t0_max)
241

◆ get_tau_bounds()

def get_tau_bounds (   self)
Get tau bounds of sampling space

Definition at line 248 of file SVDSimBase.py.

248 def get_tau_bounds(self):
249 '''
250 Get tau bounds of sampling space
251 '''
252 return (self.tau_min, self.tau_max)
253

◆ get_tau_sigma()

def get_tau_sigma (   self)
Get width jitter for the simulation.

Definition at line 268 of file SVDSimBase.py.

268 def get_tau_sigma(self):
269 '''
270 Get width jitter for the simulation.
271 '''
272 return self.tau_sigma
273

◆ set_tau_bounds()

def set_tau_bounds (   self,
  tau_min,
  tau_max 
)
Set width limits for the simulation.

Definition at line 254 of file SVDSimBase.py.

254 def set_tau_bounds(self, tau_min, tau_max):
255 '''
256 Set width limits for the simulation.
257 '''
258
259 self.tau_min = tau_min
260 self.tau_max = tau_max
261

◆ set_tau_sigma()

def set_tau_sigma (   self,
  tau_sigma 
)
Set width jitter for the simulation.

Definition at line 262 of file SVDSimBase.py.

262 def set_tau_sigma(self, tau_sigma):
263 '''
264 Set width jitter for the simulation.
265 '''
266 self.tau_sigma = tau_sigma
267

Member Data Documentation

◆ amp_max

amp_max

amplitude bounds

Definition at line 224 of file SVDSimBase.py.

◆ bin_size

bin_size

bin size

Definition at line 232 of file SVDSimBase.py.

◆ n_samples

n_samples

sample size

Definition at line 285 of file SVDSimBase.py.

◆ sigma_max

sigma_max

sigma bounds

Definition at line 226 of file SVDSimBase.py.

◆ stockdata

stockdata

stock data

Definition at line 287 of file SVDSimBase.py.

◆ t0_bin_times

t0_bin_times

undocumented variable

Definition at line 312 of file SVDSimBase.py.

◆ t0_bins

t0_bins

undocumented variable

Definition at line 307 of file SVDSimBase.py.

◆ t0_max

t0_max

t0 bounds

Definition at line 220 of file SVDSimBase.py.

◆ tau_coder

tau_coder

tau encored

Definition at line 228 of file SVDSimBase.py.

◆ tau_max

tau_max

tau bounds

Definition at line 222 of file SVDSimBase.py.

◆ tau_min

tau_min

tau min

Definition at line 259 of file SVDSimBase.py.

◆ tau_sigma

tau_sigma

tau sigma

Definition at line 230 of file SVDSimBase.py.

◆ wf

wf

wf ?

Definition at line 234 of file SVDSimBase.py.


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