27 def choose_input_features(use_vertex_features=True, use_charge_and_ROE_features=False, use_continuum_features=1):
29 Function to return all names of input features.
30 :param use_vertex_features: If Vertex info should be included.
31 :param use_charge_and_ROE_features: If charge and ROE should be included as extra features(information already
32 included in group structure). This option is only nevessary when using Relation Layers.
33 :param use_continuum_features: Use old Continuum Features (0: No, 1: Yes, 2: Use only the old features)
34 :return: Array of feature names
44 'KSFWVariables(hso00)',
45 'KSFWVariables(hso02)',
46 'KSFWVariables(hso04)',
47 'KSFWVariables(hso10)',
48 'KSFWVariables(hso12)',
49 'KSFWVariables(hso14)',
50 'KSFWVariables(hso20)',
51 'KSFWVariables(hso22)',
52 'KSFWVariables(hso24)',
53 'KSFWVariables(hoo0)',
54 'KSFWVariables(hoo1)',
55 'KSFWVariables(hoo2)',
56 'KSFWVariables(hoo3)',
57 'KSFWVariables(hoo4)',
68 if use_continuum_features == 2:
71 basic_variables = [
'p',
'phi',
'cosTheta',
'pErr',
'phiErr',
'cosThetaErr']
72 vertex_variables = [
'distance',
'dphi',
'dcosTheta']
74 cluster_specific_variables = [
'clusterNHits',
'clusterTiming',
'clusterE9E25',
'clusterReg']
75 track_specific_variables = [
'kaonID',
'electronID',
'muonID',
'protonID',
'pValue',
'nCDCHits']
77 if use_charge_and_ROE_features:
78 cluster_specific_variables += [
'isInRestOfEvent']
79 track_specific_variables += [
'isInRestOfEvent',
'charge']
81 cluster_specific_variables += [
'thrustsig' + var
for var
in basic_variables]
82 track_specific_variables += [
'thrustsig' + var
for var
in basic_variables]
84 if use_vertex_features:
85 track_specific_variables += [
'thrustsig' + var
for var
in vertex_variables]
87 cluster_lists = [
'Csig',
'Croe']
88 track_lists = [
'TPsig',
'TMsig',
'TProe',
'TMroe']
91 for plist
in track_lists:
93 for var
in track_specific_variables:
94 variables.append(
'{}_{}{}'.format(var, plist, rank))
96 for plist
in cluster_lists:
97 for rank
in range(10):
98 for var
in cluster_specific_variables:
99 variables.append(
'{}_{}{}'.format(var, plist, rank))
101 if use_continuum_features:
107 if __name__ ==
"__main__":
110 path =
'/group/belle2/tutorial/release_01-00-00/inputForDCSTutorial/'
112 train_data = path +
'train.root'
113 test_data = path +
'test.root'
115 general_options = basf2_mva.GeneralOptions()
116 general_options.m_datafiles = basf2_mva.vector(train_data)
117 general_options.m_treename =
"tree"
118 general_options.m_identifier =
"Deep_Feed_Forward.xml"
119 general_options.m_variables = basf2_mva.vector(*choose_input_features(
True,
False, 1))
120 general_options.m_spectators = basf2_mva.vector(
'Mbc',
'DeltaZ')
121 general_options.m_target_variable =
"isNotContinuumEvent"
123 specific_options = basf2_mva.PythonOptions()
124 specific_options.m_framework =
"contrib_keras"
125 specific_options.m_steering_file =
'analysis/examples/tutorials/B2A714-DeepContinuumSuppression_MVAModel.py'
126 specific_options.m_training_fraction = 0.9
133 'use_relation_layers':
False,
138 'adversary_steps': 5}
139 specific_options.m_config = json.dumps(keras_dic)
142 basf2_mva.teacher(general_options, specific_options)
145 subprocess.call(
'basf2_mva_evaluate.py '
146 ' -train ' + train_data +
147 ' -data ' + test_data +
148 ' -id ' +
'Deep_Feed_Forward.xml' +
149 ' --output qqbarSuppressionEvaluation.pdf',