Belle II Software development
TrackQETeacherBaseTask Class Reference
Inheritance diagram for TrackQETeacherBaseTask:
CDCQETeacherTask RecoTrackQETeacherTask VXDQETeacherTask

Public Member Functions

def weightfile_identifier_basename (self)
 
def get_weightfile_xml_identifier (self, fast_bdt_option=None, recotrack_option=None)
 
def tree_name (self)
 
def random_seed (self)
 
Basf2PathTask data_collection_task (self)
 
def requires (self)
 
def output (self)
 
def process (self)
 

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 training_target
 Feature/variable to use as truth label in the quality estimator MVA classifier.
 
b2luigi exclude_variables
 List of collected variables to not use in the training of the QE MVA classifier.
 
b2luigi fast_bdt_option
 Hyperparameter option of the FastBDT algorithm.
 

Detailed Description

A teacher task runs the basf2 mva teacher on the training data provided by a
data collection task.

Since teacher tasks are needed for all quality estimators covered by this
steering file and the only thing that changes is the required data
collection task and some training parameters, I decided to use inheritance
and have the basic functionality in this base class/interface and have the
specific teacher tasks inherit from it.

Definition at line 1163 of file combined_quality_estimator_teacher.py.

Member Function Documentation

◆ data_collection_task()

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

Definition at line 1252 of file combined_quality_estimator_teacher.py.

1252 def data_collection_task(self) -> Basf2PathTask:
1253 """
1254 Property defining the specific ``DataCollectionTask`` to require. Must
1255 implemented by the inheriting specific teacher task class.
1256 """
1257 raise NotImplementedError(
1258 "Teacher Task must define a data collection task to require "
1259 )
1260

◆ get_weightfile_xml_identifier()

def get_weightfile_xml_identifier (   self,
  fast_bdt_option = None,
  recotrack_option = None 
)
Name of the xml weightfile that is created by the teacher task.
It is subsequently used as a local weightfile in the following validation tasks.

Definition at line 1216 of file combined_quality_estimator_teacher.py.

1216 def get_weightfile_xml_identifier(self, fast_bdt_option=None, recotrack_option=None):
1217 """
1218 Name of the xml weightfile that is created by the teacher task.
1219 It is subsequently used as a local weightfile in the following validation tasks.
1220 """
1221 if fast_bdt_option is None:
1222 fast_bdt_option = self.fast_bdt_option
1223 if recotrack_option is None and hasattr(self, 'recotrack_option'):
1224 recotrack_option = self.recotrack_option
1225 else:
1226 recotrack_option = ''
1227 weightfile_details = create_fbdt_option_string(fast_bdt_option)
1228 weightfile_name = self.weightfile_identifier_basename + weightfile_details
1229 if recotrack_option != '':
1230 weightfile_name = weightfile_name + '_' + recotrack_option
1231 return weightfile_name + ".weights.xml"
1232

◆ output()

def 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 1281 of file combined_quality_estimator_teacher.py.

1281 def output(self):
1282 """
1283 Generate list of output files that the task should produce.
1284 The task is considered finished if and only if the outputs all exist.
1285 """
1286 yield self.add_to_output(self.get_weightfile_xml_identifier())
1287

◆ process()

def process (   self)
Use basf2_mva teacher to create MVA weightfile from collected training
data variables.

This is the main process that is dispatched by the ``run`` method that
is inherited from ``Basf2Task``.

Definition at line 1288 of file combined_quality_estimator_teacher.py.

1288 def process(self):
1289 """
1290 Use basf2_mva teacher to create MVA weightfile from collected training
1291 data variables.
1292
1293 This is the main process that is dispatched by the ``run`` method that
1294 is inherited from ``Basf2Task``.
1295 """
1296 if 'USEREC' in self.process_type:
1297 if 'USERECBB' in self.process_type:
1298 process = 'BBBAR'
1299 elif 'USERECEE' in self.process_type:
1300 process = 'BHABHA'
1301 records_files = ['datafiles/qe_records_N' + str(self.n_events_training) +
1302 '_' + process + '_' + self.random_seed + '.root']
1303 else:
1304 if hasattr(self, 'recotrack_option'):
1305 records_files = self.get_input_file_names(
1306 self.data_collection_task.get_records_file_name(
1307 self.data_collection_task,
1308 n_events=self.n_events_training,
1309 random_seed=self.process_type + '_' + self.random_seed,
1310 recotrack_option=self.recotrack_option))
1311 else:
1312 records_files = self.get_input_file_names(
1313 self.data_collection_task.get_records_file_name(
1314 self.data_collection_task,
1315 n_events=self.n_events_training,
1316 random_seed=self.process_type + '_' + self.random_seed))
1317
1318 my_basf2_mva_teacher(
1319 records_files=records_files,
1320 tree_name=self.tree_name,
1321 weightfile_identifier=self.get_output_file_name(self.get_weightfile_xml_identifier()),
1322 target_variable=self.training_target,
1323 exclude_variables=self.exclude_variables,
1324 fast_bdt_option=self.fast_bdt_option,
1325 )
1326
1327

◆ random_seed()

def random_seed (   self)
Property defining random seed to be used by the ``GenerateSimTask``.
Should differ from the random seed in the test data samples.  Must
implemented by the inheriting specific teacher task class.

Definition at line 1243 of file combined_quality_estimator_teacher.py.

1243 def random_seed(self):
1244 """
1245 Property defining random seed to be used by the ``GenerateSimTask``.
1246 Should differ from the random seed in the test data samples. Must
1247 implemented by the inheriting specific teacher task class.
1248 """
1249 raise NotImplementedError("Teacher Task must define a static random seed")
1250

◆ requires()

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

Reimplemented in RecoTrackQETeacherTask.

Definition at line 1261 of file combined_quality_estimator_teacher.py.

1261 def requires(self):
1262 """
1263 Generate list of luigi Tasks that this Task depends on.
1264 """
1265 if 'USEREC' in self.process_type:
1266 if 'USERECBB' in self.process_type:
1267 process = 'BBBAR'
1268 elif 'USERECEE' in self.process_type:
1269 process = 'BHABHA'
1270 yield CheckExistingFile(
1271 filename='datafiles/qe_records_N' + str(self.n_events_training) + '_' + process + '_' + self.random_seed + '.root',
1272 )
1273 else:
1274 yield self.data_collection_task(
1275 num_processes=MasterTask.num_processes,
1276 n_events=self.n_events_training,
1277 experiment_number=self.experiment_number,
1278 random_seed=self.process_type + '_' + self.random_seed,
1279 )
1280

◆ tree_name()

def tree_name (   self)
Property defining the name of the tree in the ROOT file from the
``data_collection_task`` that contains the recorded training data.  Must
implemented by the inheriting specific teacher task class.

Definition at line 1234 of file combined_quality_estimator_teacher.py.

1234 def tree_name(self):
1235 """
1236 Property defining the name of the tree in the ROOT file from the
1237 ``data_collection_task`` that contains the recorded training data. Must
1238 implemented by the inheriting specific teacher task class.
1239 """
1240 raise NotImplementedError("Teacher Task must define a static tree_name")
1241

◆ weightfile_identifier_basename()

def weightfile_identifier_basename (   self)
Property defining the basename for the .xml and .root weightfiles that are created.
Has to be implemented by the inheriting teacher task class.

Definition at line 1207 of file combined_quality_estimator_teacher.py.

1207 def weightfile_identifier_basename(self):
1208 """
1209 Property defining the basename for the .xml and .root weightfiles that are created.
1210 Has to be implemented by the inheriting teacher task class.
1211 """
1212 raise NotImplementedError(
1213 "Teacher Task must define a static weightfile_identifier"
1214 )
1215

Member Data Documentation

◆ exclude_variables

b2luigi exclude_variables
static
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 1194 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 1177 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 1200 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 1175 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 1181 of file combined_quality_estimator_teacher.py.

◆ training_target

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

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

Definition at line 1187 of file combined_quality_estimator_teacher.py.


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