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

Public Member Functions

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

Public Attributes

 recotrack_option
 RecoTrack option, use string that is additive: deleteCDCQI0XY (= deletes CDCTracks with CDC-QI below 0.XY), useCDC (= uses trained CDC stored in datafiles/), useVXD (uses trained VXD stored in datafiles/), noVXD (= doesn't use the VXD MVA at all)
 

Static Public Attributes

str object_name = 'VXDQualityEstimatorMVA'
 DBObject name.
 
 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 option of the FastBDT algorithm.
 

Detailed Description

Task to run basf2 mva teacher on collected data for VXDTF2 track quality estimator

Definition at line 1372 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 1293 of file combined_quality_estimator_teacher.py.

1293 def data_collection_task(self) -> Basf2PathTask:
1294 """
1295 Property defining the specific ``DataCollectionTask`` to require. Must
1296 implemented by the inheriting specific teacher task class.
1297 """
1298 raise NotImplementedError(
1299 "Teacher Task must define a data collection task to require "
1300 )
1301

◆ get_weightfile_identifier()

get_weightfile_identifier ( self,
fast_bdt_option = None,
recotrack_option = None )
inherited
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 1251 of file combined_quality_estimator_teacher.py.

1251 def get_weightfile_identifier(self, fast_bdt_option=None, recotrack_option=None):
1252 """
1253 Name of the xml weightfile that is created by the teacher task.
1254 It is subsequently used as a local weightfile in the following validation tasks.
1255 """
1256 if fast_bdt_option is None:
1257 fast_bdt_option = self.fast_bdt_option
1258 if recotrack_option is None and hasattr(self, 'recotrack_option'):
1259
1262 if isinstance(self.recotrack_option, str):
1263 recotrack_option = self.recotrack_option
1264 else:
1265 recotrack_option = self.recotrack_option._default
1266 else:
1267 recotrack_option = ''
1268 weightfile_details = create_fbdt_option_string(fast_bdt_option)
1269 weightfile_name = self.weightfile_identifier_basename + weightfile_details
1270 if recotrack_option != '':
1271 weightfile_name = weightfile_name + '_' + recotrack_option
1272 return weightfile_name + "_weights"
1273

◆ make_db()

make_db ( self)
Creates the local VXD payload from weightfiles.

Definition at line 1389 of file combined_quality_estimator_teacher.py.

1389 def make_db(self):
1390 """
1391 Creates the local VXD payload from weightfiles.
1392 """
1393 vxd_identifier = self.get_output_file_name(self.get_weightfile_identifier() + '.xml')
1394 with open(vxd_identifier, "r") as f:
1395 weight_file_content = f.read()
1396 vxd_name = write_mva_weightfile_content_to_db(
1397 dbobj_name=self.object_name,
1398 content=weight_file_content,
1399 iovList=(0, 0, 0, -1)
1400 )
1401 return vxd_name
1402
1403

◆ 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 1322 of file combined_quality_estimator_teacher.py.

1322 def output(self):
1323 """
1324 Generate list of output files that the task should produce.
1325 The task is considered finished if and only if the outputs all exist.
1326 """
1327 yield self.add_to_output(self.get_weightfile_identifier() + '.xml')
1328

◆ process()

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

1329 def process(self):
1330 """
1331 Use basf2_mva teacher to create MVA weightfile from collected training
1332 data variables.
1333
1334 This is the main process that is dispatched by the ``run`` method that
1335 is inherited from ``Basf2Task``.
1336 """
1337 if 'USEREC' in self.process_type:
1338 if 'USERECBB' in self.process_type:
1339 process = 'BBBAR'
1340 elif 'USERECEE' in self.process_type:
1341 process = 'BHABHA'
1342 records_files = ['datafiles/qe_records_N' + str(self.n_events_training) +
1343 '_' + process + '_' + self.random_seed + '.root']
1344 else:
1345 if hasattr(self, 'recotrack_option') and isinstance(self, RecoTrackQETeacherTask):
1346 records_files = self.get_input_file_names(
1347 self.data_collection_task.get_records_file_name(
1348 self.data_collection_task,
1349 n_events=self.n_events_training,
1350 random_seed=self.process_type + '_' + self.random_seed,
1351 recotrack_option=self.recotrack_option))
1352 else:
1353 records_files = self.get_input_file_names(
1354 self.data_collection_task.get_records_file_name(
1355 self.data_collection_task,
1356 n_events=self.n_events_training,
1357 random_seed=self.process_type + '_' + self.random_seed))
1358
1359 weightfile_identifier = self.get_output_file_name(self.get_weightfile_identifier() + '.xml')
1360 print('The weightfile used is:', weightfile_identifier)
1361 my_basf2_mva_teacher(
1362 records_files=records_files,
1363 tree_name=self.tree_name,
1364 weightfile_identifier=weightfile_identifier,
1365 target_variable=self.training_target,
1366 exclude_variables=self.exclude_variables,
1367 fast_bdt_option=self.fast_bdt_option,
1368 )
1369 _ = self.make_db()
1370
1371

◆ random_seed()

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

1284 def random_seed(self):
1285 """
1286 Property defining random seed to be used by the ``GenerateSimTask``.
1287 Should differ from the random seed in the test data samples. Must
1288 implemented by the inheriting specific teacher task class.
1289 """
1290 raise NotImplementedError("Teacher Task must define a static random seed")
1291

◆ requires()

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

Reimplemented in RecoTrackQETeacherTask.

Definition at line 1302 of file combined_quality_estimator_teacher.py.

1302 def requires(self):
1303 """
1304 Generate list of luigi Tasks that this Task depends on.
1305 """
1306 if 'USEREC' in self.process_type:
1307 if 'USERECBB' in self.process_type:
1308 process = 'BBBAR'
1309 elif 'USERECEE' in self.process_type:
1310 process = 'BHABHA'
1311 yield CheckExistingFile(
1312 filename='datafiles/qe_records_N' + str(self.n_events_training) + '_' + process + '_' + self.random_seed + '.root',
1313 )
1314 else:
1315 yield self.data_collection_task(
1316 num_processes=MasterTask.num_processes,
1317 n_events=self.n_events_training,
1318 experiment_number=self.experiment_number,
1319 random_seed=self.process_type + '_' + self.random_seed,
1320 )
1321

◆ tree_name()

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

1275 def tree_name(self):
1276 """
1277 Property defining the name of the tree in the ROOT file from the
1278 ``data_collection_task`` that contains the recorded training data. Must
1279 implemented by the inheriting specific teacher task class.
1280 """
1281 raise NotImplementedError("Teacher Task must define a static tree_name")
1282

◆ weightfile_identifier_basename()

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

1242 def weightfile_identifier_basename(self):
1243 """
1244 Property defining the basename for the .xml and .root weightfiles that are created.
1245 Has to be implemented by the inheriting teacher task class.
1246 """
1247 raise NotImplementedError(
1248 "Teacher Task must define a static weightfile_identifier"
1249 )
1250

Member Data Documentation

◆ 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 1229 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 1212 of file combined_quality_estimator_teacher.py.

◆ fast_bdt_option

fast_bdt_option
staticinherited
Initial value:
= b2luigi.ListParameter(
)

Hyperparameter option of the FastBDT algorithm.

default are the FastBDT default values.

Definition at line 1235 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 1210 of file combined_quality_estimator_teacher.py.

◆ object_name

str object_name = 'VXDQualityEstimatorMVA'
static

DBObject name.

Definition at line 1387 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 1216 of file combined_quality_estimator_teacher.py.

◆ recotrack_option

recotrack_option
inherited

RecoTrack option, use string that is additive: deleteCDCQI0XY (= deletes CDCTracks with CDC-QI below 0.XY), useCDC (= uses trained CDC stored in datafiles/), useVXD (uses trained VXD stored in datafiles/), noVXD (= doesn't use the VXD MVA at all)

Definition at line 1262 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 1222 of file combined_quality_estimator_teacher.py.


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