Belle II Software development
RecoTrackQEEvaluationTask Class Reference
Inheritance diagram for RecoTrackQEEvaluationTask:
TrackQEEvaluationBaseTask

Public Member Functions

 requires (self)
 
TrackQETeacherBaseTask teacher_task (self)
 Teacher task to require to provide a quality estimator weightfile for add_tracking_with_quality_estimation
 
Basf2PathTask data_collection_task (self)
 
 task_acronym (self)
 
 output (self)
 
 run (self)
 

Public Attributes

 teacher_task = None
 Task that is required by the evaluation base class to create the MVA weightfile that needs to be evaluated.
 

Static Public Attributes

 cdc_training_target = b2luigi.Parameter()
 Feature/variable to use as truth label for the CDC track quality estimator.
 
 git_hash
 Use git hash / release of basf2 version as additional luigi parameter.
 
 n_events_testing = b2luigi.IntParameter()
 Number of events to generate for the test data set.
 
 n_events_training = b2luigi.IntParameter()
 Number of events to generate for the training data set.
 
 experiment_number = b2luigi.IntParameter()
 Experiment number of the conditions database, e.g.
 
 process_type
 Define which kind of process shall be used.
 
 training_target
 Feature/variable to use as truth label in the quality estimator MVA classifier.
 
 exclude_variables
 List of collected variables to not use in the training of the QE MVA classifier.
 
 fast_bdt_option
 Hyperparameter options for the FastBDT algorithm.
 

Detailed Description

Run ``basf2_mva_evaluate.py`` for the final, combined quality estimator on
separate test data

Definition at line 2113 of file combined_quality_estimator_teacher.py.

Member Function Documentation

◆ data_collection_task()

Basf2PathTask data_collection_task ( self)
inherited
Property defining the specific ``DataCollectionTask`` to require.  Must
implemented by the inheriting specific teacher task class.

Definition at line 1941 of file combined_quality_estimator_teacher.py.

1941 def data_collection_task(self) -> Basf2PathTask:
1942 """
1943 Property defining the specific ``DataCollectionTask`` to require. Must
1944 implemented by the inheriting specific teacher task class.
1945 """
1946 raise NotImplementedError(
1947 "Evaluation Tasks must define a data collection task to require "
1948 )
1949

◆ output()

output ( self)
inherited
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 2002 of file combined_quality_estimator_teacher.py.

2002 def output(self):
2003 """
2004 Generate list of output files that the task should produce.
2005 The task is considered finished if and only if the outputs all exist.
2006 """
2007 weightfile_details = create_fbdt_option_string(self.fast_bdt_option)
2008 evaluation_pdf_output = self.teacher_task.weightfile_identifier_basename + weightfile_details + ".zip"
2009 yield self.add_to_output(evaluation_pdf_output)
2010

◆ requires()

requires ( self)
Generate list of luigi Tasks that this Task depends on.

Reimplemented from TrackQEEvaluationBaseTask.

Definition at line 2130 of file combined_quality_estimator_teacher.py.

2130 def requires(self):
2131 """
2132 Generate list of luigi Tasks that this Task depends on.
2133 """
2134 yield self.teacher_task(
2135 n_events_training=self.n_events_training,
2136 experiment_number=self.experiment_number,
2137 process_type=self.process_type,
2138 training_target=self.training_target,
2139 exclude_variables=self.exclude_variables,
2140 cdc_training_target=self.cdc_training_target,
2141 fast_bdt_option=self.fast_bdt_option,
2142 )
2143 if 'USEREC' in self.process_type:
2144 if 'USERECBB' in self.process_type:
2145 process = 'BBBAR'
2146 elif 'USERECEE' in self.process_type:
2147 process = 'BHABHA'
2148 yield CheckExistingFile(
2149 filename='datafiles/qe_records_N' + str(self.n_events_testing) + '_' + process + '_test_' +
2150 self.task_acronym + '.root'
2151 )
2152 else:
2153 yield self.data_collection_task(
2154 num_processes=MasterTask.num_processes,
2155 n_events=self.n_events_testing,
2156 experiment_number=self.experiment_number,
2157 random_seed=self.process_type + "_test",
2158 cdc_training_target=self.cdc_training_target,
2159 )
2160
2161

◆ run()

run ( self)
inherited
Run ``basf2_mva_evaluate.py`` subprocess to evaluate QE MVA.

The MVA weight file created from training on the training data set is
evaluated on separate test data.

Definition at line 2011 of file combined_quality_estimator_teacher.py.

2011 def run(self):
2012 """
2013 Run ``basf2_mva_evaluate.py`` subprocess to evaluate QE MVA.
2014
2015 The MVA weight file created from training on the training data set is
2016 evaluated on separate test data.
2017 """
2018 weightfile_details = create_fbdt_option_string(self.fast_bdt_option)
2019 evaluation_pdf_output_basename = self.teacher_task.weightfile_identifier_basename + weightfile_details + ".zip"
2020 evaluation_pdf_output_path = self.get_output_file_name(evaluation_pdf_output_basename)
2021
2022 if 'USEREC' in self.process_type:
2023 if 'USERECBB' in self.process_type:
2024 process = 'BBBAR'
2025 elif 'USERECEE' in self.process_type:
2026 process = 'BHABHA'
2027 datafiles = 'datafiles/qe_records_N' + str(self.n_events_testing) + '_' + \
2028 process + '_test_' + self.task_acronym + '.root'
2029 else:
2030 datafiles = self.get_input_file_names(
2031 self.data_collection_task.get_records_file_name(
2032 self.data_collection_task,
2033 n_events=self.n_events_testing,
2034 random_seed=self.process_type + '_test_' +
2035 self.task_acronym))[0]
2036 teacher_task = None
2037 for req in b2luigi.task.flatten(self.requires()):
2038 if isinstance(req, self.teacher_task):
2039 teacher_task = req
2040 break
2041 if hasattr(teacher_task, 'recotrack_option') and isinstance(self, RecoTrackQEEvaluationTask):
2042 records_files = teacher_task.get_input_file_names(
2043 self.data_collection_task.get_records_file_name(
2044 self.data_collection_task,
2045 n_events=self.n_events_training,
2046 random_seed=self.process_type + '_' + teacher_task.random_seed,
2047 recotrack_option=teacher_task.recotrack_option))
2048 else:
2049 records_files = teacher_task.get_input_file_names(
2050 self.data_collection_task.get_records_file_name(
2051 self.data_collection_task,
2052 n_events=self.n_events_training,
2053 random_seed=self.process_type + '_' + teacher_task.random_seed))
2054 cmd = [
2055 "basf2_mva_evaluate.py",
2056 "--identifiers",
2057 self.get_input_file_names(
2058 self.teacher_task.get_weightfile_identifier(
2059 self.teacher_task,
2060 fast_bdt_option=self.fast_bdt_option) + '.xml')[0],
2061 "--train_datafiles",
2062 records_files[0],
2063 "--datafiles",
2064 datafiles,
2065 "--treename",
2066 self.teacher_task.tree_name,
2067 "--outputfile",
2068 evaluation_pdf_output_path
2069 ]
2070 print(
2071 'The weightfile for QE Evaluate is:',
2072 self.get_input_file_names(
2073 self.teacher_task.get_weightfile_identifier(
2074
2076 self.teacher_task,
2077 fast_bdt_option=self.fast_bdt_option) +
2078 '.xml')[0])
2079
2080 subprocess.run(cmd, check=True) # code to actually run the basf2_mva_evaluate.py process
2081
2082

◆ task_acronym()

task_acronym ( self)
inherited
Acronym to distinguish between cdc, vxd and rec(o) MVA

Definition at line 1951 of file combined_quality_estimator_teacher.py.

1951 def task_acronym(self):
1952 """
1953 Acronym to distinguish between cdc, vxd and rec(o) MVA
1954 """
1955 raise NotImplementedError(
1956 "Evaluation Tasks must define a task acronym."
1957 )
1958

◆ teacher_task()

TrackQETeacherBaseTask teacher_task ( self)
inherited

Teacher task to require to provide a quality estimator weightfile for add_tracking_with_quality_estimation

Property defining specific teacher task to require.

Definition at line 1932 of file combined_quality_estimator_teacher.py.

1932 def teacher_task(self) -> TrackQETeacherBaseTask:
1933 """
1934 Property defining specific teacher task to require.
1935 """
1936 raise NotImplementedError(
1937 "Evaluation Tasks must define a teacher task to require "
1938 )
1939

Member Data Documentation

◆ cdc_training_target

cdc_training_target = b2luigi.Parameter()
static

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

Definition at line 2128 of file combined_quality_estimator_teacher.py.

◆ exclude_variables

exclude_variables
staticinherited
Initial value:
= b2luigi.ListParameter(
)

List of collected variables to not use in the training of the QE MVA classifier.

In addition to variables containing the "truth" substring, which are excluded by default.

Definition at line 1918 of file combined_quality_estimator_teacher.py.

◆ experiment_number

experiment_number = b2luigi.IntParameter()
staticinherited

Experiment number of the conditions database, e.g.

defines simulation geometry

Definition at line 1901 of file combined_quality_estimator_teacher.py.

◆ fast_bdt_option

fast_bdt_option
staticinherited
Initial value:
= b2luigi.ListParameter(
)

Hyperparameter options for the FastBDT algorithm.

Definition at line 1924 of file combined_quality_estimator_teacher.py.

◆ git_hash

git_hash
staticinherited
Initial value:
= b2luigi.Parameter(
)

Use git hash / release of basf2 version as additional luigi parameter.

This parameter is already set in all other tasks that inherit from Basf2Task. For this task, I decided against inheriting from Basf2Task because it already calls a subprocess and therefore does not need a dispatchable process method.

Definition at line 1891 of file combined_quality_estimator_teacher.py.

◆ n_events_testing

n_events_testing = b2luigi.IntParameter()
staticinherited

Number of events to generate for the test data set.

Definition at line 1897 of file combined_quality_estimator_teacher.py.

◆ n_events_training

n_events_training = b2luigi.IntParameter()
staticinherited

Number of events to generate for the training data set.

Definition at line 1899 of file combined_quality_estimator_teacher.py.

◆ process_type

process_type
staticinherited
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 1905 of file combined_quality_estimator_teacher.py.

◆ teacher_task

teacher_task = None
inherited

Task that is required by the evaluation base class to create the MVA weightfile that needs to be evaluated.

Definition at line 2038 of file combined_quality_estimator_teacher.py.

◆ training_target

training_target
staticinherited
Initial value:
= b2luigi.Parameter(
)

Feature/variable to use as truth label in the quality estimator MVA classifier.

Definition at line 1911 of file combined_quality_estimator_teacher.py.


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