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)
2081
2082