Belle II Software development
SplitNMergeSimTask Class Reference
Inheritance diagram for SplitNMergeSimTask:
LSFTask

Public Member Functions

 output_file_name (self, n_events=None, random_seed=None)
 Name of the ROOT output file with generated and simulated events.
 
 output (self)
 
 requires (self)
 
 process (self)
 
 on_success (self)
 
 remove_output (self)
 

Public Attributes

 job_name = self.task_id
 set the job name (inherited variable)
 

Static Public Attributes

 experiment_number = b2luigi.IntParameter()
 Experiment number of the conditions database, e.g.
 
 random_seed = b2luigi.Parameter()
 Random basf2 seed.
 
 n_events = b2luigi.IntParameter()
 Number of events to generate.
 
 bkgfiles_dir
 Directory with overlay background root files.
 
str batch_system = 'lsf'
 batch system
 
str queue = 's'
 queue
 

Detailed Description

Generate simulated Monte Carlo with background overlay.

Make sure to use different ``random_seed`` parameters for the training data
format the classifier trainings and for the test data for the respective
evaluation/validation tasks.

Definition at line 289 of file combined_to_pxd_ckf_mva_training.py.

Member Function Documentation

◆ on_success()

on_success ( self)
On success method.

Definition at line 371 of file combined_to_pxd_ckf_mva_training.py.

371 def on_success(self):
372 """
373 On success method.
374 """
375 print("Finished merging. Now remove the input files to save space.")
376 file_list = [f for f in self.get_all_input_file_names()]
377 for input_file in file_list:
378 try:
379 os.remove(input_file)
380 except FileNotFoundError:
381 pass
382

◆ output()

output ( self)
Generate list of output files that the task should produce.
The task is considered finished if and only if the outputs all exist.

Definition at line 327 of file combined_to_pxd_ckf_mva_training.py.

327 def output(self):
328 """
329 Generate list of output files that the task should produce.
330 The task is considered finished if and only if the outputs all exist.
331 """
332 yield self.add_to_output(self.output_file_name())
333

◆ output_file_name()

output_file_name ( self,
n_events = None,
random_seed = None )

Name of the ROOT output file with generated and simulated events.

Create output file name depending on number of events and production
mode that is specified in the random_seed string.

:param n_events: Number of events to simulate.
:param random_seed: Random seed to use for the simulation to create independent samples.

Definition at line 313 of file combined_to_pxd_ckf_mva_training.py.

313 def output_file_name(self, n_events=None, random_seed=None):
314 """
315 Create output file name depending on number of events and production
316 mode that is specified in the random_seed string.
317
318 :param n_events: Number of events to simulate.
319 :param random_seed: Random seed to use for the simulation to create independent samples.
320 """
321 if n_events is None:
322 n_events = self.n_events
323 if random_seed is None:
324 random_seed = self.random_seed
325 return "generated_mc_N" + str(n_events) + "_" + random_seed + ".root"
326

◆ process()

process ( self)
When all GenerateSimTasks finished, merge the output.

Definition at line 358 of file combined_to_pxd_ckf_mva_training.py.

358 def process(self):
359 """
360 When all GenerateSimTasks finished, merge the output.
361 """
362 create_output_dirs(self)
363
364 file_list = [f for f in self.get_all_input_file_names()]
365 print("Merge the following files:")
366 print(file_list)
367 cmd = ["b2file-merge", "-f"]
368 args = cmd + [self.get_output_file_name(self.output_file_name())] + file_list
369 subprocess.check_call(args)
370

◆ remove_output()

remove_output ( self)
Default function from base b2luigi.Task class.

Definition at line 383 of file combined_to_pxd_ckf_mva_training.py.

383 def remove_output(self):
384 """
385 Default function from base b2luigi.Task class.
386 """
387 self._remove_output()
388
389

◆ requires()

requires ( self)
This task requires several GenerateSimTask to be finished so that he required number of events is created.

Definition at line 334 of file combined_to_pxd_ckf_mva_training.py.

334 def requires(self):
335 """
336 This task requires several GenerateSimTask to be finished so that he required number of events is created.
337 """
338 n_events_per_task = SummaryTask.n_events_per_task
339 quotient, remainder = divmod(self.n_events, n_events_per_task)
340 for i in range(quotient):
341 yield GenerateSimTask(
342 bkgfiles_dir=self.bkgfiles_dir,
343 num_processes=SummaryTask.num_processes,
344 random_seed=self.random_seed + '_' + str(i).zfill(3),
345 n_events=n_events_per_task,
346 experiment_number=self.experiment_number,
347 )
348 if remainder > 0:
349 yield GenerateSimTask(
350 bkgfiles_dir=self.bkgfiles_dir,
351 num_processes=SummaryTask.num_processes,
352 random_seed=self.random_seed + '_' + str(quotient).zfill(3),
353 n_events=remainder,
354 experiment_number=self.experiment_number,
355 )
356

Member Data Documentation

◆ batch_system

str batch_system = 'lsf'
staticinherited

batch system

Definition at line 189 of file combined_to_pxd_ckf_mva_training.py.

◆ bkgfiles_dir

bkgfiles_dir
static
Initial value:
= b2luigi.Parameter(
)

Directory with overlay background root files.

Definition at line 306 of file combined_to_pxd_ckf_mva_training.py.

◆ experiment_number

experiment_number = b2luigi.IntParameter()
static

Experiment number of the conditions database, e.g.

defines simulation geometry

Definition at line 299 of file combined_to_pxd_ckf_mva_training.py.

◆ job_name

job_name = self.task_id
inherited

set the job name (inherited variable)

Definition at line 197 of file combined_to_pxd_ckf_mva_training.py.

◆ n_events

n_events = b2luigi.IntParameter()
static

Number of events to generate.

Definition at line 304 of file combined_to_pxd_ckf_mva_training.py.

◆ queue

str queue = 's'
staticinherited

queue

Definition at line 191 of file combined_to_pxd_ckf_mva_training.py.

◆ random_seed

random_seed = b2luigi.Parameter()
static

Random basf2 seed.

It is further used to read of the production process to preserve clearness in the b2luigi output.

Definition at line 302 of file combined_to_pxd_ckf_mva_training.py.


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