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

Public Member Functions

def requires (self)
 
def output (self)
 
def process (self)
 
def on_failure (self, exception)
 

Static Public Attributes

b2luigi n_events_training = b2luigi.IntParameter()
 Number of events to generate for the training data set.
 
b2luigi experiment_number = b2luigi.IntParameter()
 Experiment number of the conditions database, e.g.
 
b2luigi process_type
 Define which kind of process shall be used.
 
b2luigi cdc_training_target = b2luigi.Parameter()
 Feature/variable to use as truth label for the CDC track quality estimator.
 
b2luigi fast_bdt_option
 Hyperparameter option of the FastBDT algorithm.
 

Protected Member Functions

def _clean (self)
 

Detailed Description

Collect weightfile identifiers from different teacher tasks and merge them
into a local database for testing.

Definition at line 2372 of file combined_quality_estimator_teacher.py.

Member Function Documentation

◆ _clean()

def _clean (   self)
protected
Remove local database and tar archives in output directory

Definition at line 2469 of file combined_quality_estimator_teacher.py.

2469 def _clean(self):
2470 """
2471 Remove local database and tar archives in output directory
2472 """
2473 localdb_archive_path = Path(self.get_output_file_name("localdb.tar"))
2474 localdb_path = localdb_archive_path.parent / "localdb"
2475
2476 if localdb_path.exists():
2477 print(f"Deleting localdb\n{localdb_path}\nwith contents\n ",
2478 "\n ".join(f.name for f in localdb_path.iterdir()))
2479 shutil.rmtree(localdb_path, ignore_errors=False) # recursively delete localdb
2480
2481 if localdb_archive_path.is_file():
2482 print(f"Deleting {localdb_archive_path}")
2483 os.remove(localdb_archive_path)
2484

◆ on_failure()

def on_failure (   self,
  exception 
)
Cleanup: Remove local database to prevent existing outputs when task did not finish successfully

Definition at line 2485 of file combined_quality_estimator_teacher.py.

2485 def on_failure(self, exception):
2486 """
2487 Cleanup: Remove local database to prevent existing outputs when task did not finish successfully
2488 """
2489 self._clean()
2490 # Run existing on_failure from parent class
2491 super().on_failure(exception)
2492
2493

◆ output()

def output (   self)
Local database

Definition at line 2426 of file combined_quality_estimator_teacher.py.

2426 def output(self):
2427 """
2428 Local database
2429 """
2430 yield self.add_to_output("localdb.tar")
2431

◆ process()

def process (   self)
Create local database

Definition at line 2432 of file combined_quality_estimator_teacher.py.

2432 def process(self):
2433 """
2434 Create local database
2435 """
2436 current_path = Path.cwd()
2437 localdb_archive_path = Path(self.get_output_file_name("localdb.tar")).absolute()
2438 output_dir = localdb_archive_path.parent
2439
2440 # remove existing local databases in output directories
2441 self._clean()
2442 # "Upload" the weightfiles of all 3 teacher tasks into the same localdb
2443 for task in (VXDQETeacherTask, CDCQETeacherTask, RecoTrackQETeacherTask):
2444 # Extract xml identifier input file name before switching working directories, as it returns relative paths
2445 weightfile_xml_identifier_path = os.path.abspath(self.get_input_file_names(
2446 task.get_weightfile_xml_identifier(task, fast_bdt_option=self.fast_bdt_option))[0])
2447 # As localdb is created in working directory, chdir into desired output path
2448 try:
2449 os.chdir(output_dir)
2450 # Same as basf2_mva_upload on the command line, creates localdb directory in current working dir
2451 basf2_mva.upload(
2452 weightfile_xml_identifier_path,
2453 task.weightfile_identifier_basename,
2454 self.experiment_number, 0,
2455 self.experiment_number, -1,
2456 )
2457 finally: # Switch back to working directory of b2luigi, even if upload failed
2458 os.chdir(current_path)
2459
2460 # Pack localdb into tar archive, so that we can have on single output file instead
2461 shutil.make_archive(
2462 base_name=localdb_archive_path.as_posix().split('.')[0],
2463 format="tar",
2464 root_dir=output_dir,
2465 base_dir="localdb",
2466 verbose=True,
2467 )
2468

◆ requires()

def requires (   self)
Required teacher tasks

Definition at line 2398 of file combined_quality_estimator_teacher.py.

2398 def requires(self):
2399 """
2400 Required teacher tasks
2401 """
2402 yield VXDQETeacherTask(
2403 n_events_training=self.n_events_training,
2404 process_type=self.process_type,
2405 experiment_number=self.experiment_number,
2406 exclude_variables=MasterTask.exclude_variables_vxd,
2407 fast_bdt_option=self.fast_bdt_option,
2408 )
2409 yield CDCQETeacherTask(
2410 n_events_training=self.n_events_training,
2411 process_type=self.process_type,
2412 experiment_number=self.experiment_number,
2413 training_target=self.cdc_training_target,
2414 exclude_variables=MasterTask.exclude_variables_cdc,
2415 fast_bdt_option=self.fast_bdt_option,
2416 )
2417 yield RecoTrackQETeacherTask(
2418 n_events_training=self.n_events_training,
2419 process_type=self.process_type,
2420 experiment_number=self.experiment_number,
2421 cdc_training_target=self.cdc_training_target,
2422 exclude_variables=MasterTask.exclude_variables_rec,
2423 fast_bdt_option=self.fast_bdt_option,
2424 )
2425

Member Data Documentation

◆ cdc_training_target

b2luigi cdc_training_target = b2luigi.Parameter()
static

Feature/variable to use as truth label for the CDC track quality estimator.

Definition at line 2390 of file combined_quality_estimator_teacher.py.

◆ experiment_number

b2luigi experiment_number = b2luigi.IntParameter()
static

Experiment number of the conditions database, e.g.

defines simulation geometry

Definition at line 2380 of file combined_quality_estimator_teacher.py.

◆ fast_bdt_option

b2luigi fast_bdt_option
static
Initial value:
= b2luigi.ListParameter(
)

Hyperparameter option of the FastBDT algorithm.

default are the FastBDT default values.

Definition at line 2392 of file combined_quality_estimator_teacher.py.

◆ n_events_training

b2luigi n_events_training = b2luigi.IntParameter()
static

Number of events to generate for the training data set.

Definition at line 2378 of file combined_quality_estimator_teacher.py.

◆ process_type

b2luigi process_type
static
Initial value:
= b2luigi.Parameter(
)

Define which kind of process shall be used.

Decide between simulating BBBAR or BHABHA, MUMU, YY, DDBAR, UUBAR, SSBAR, CCBAR, reconstructing DATA or already simulated files (USESIMBB/EE) or running on existing reconstructed files (USERECBB/EE)

Definition at line 2384 of file combined_quality_estimator_teacher.py.


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