8 variablesCombinerLevel=None, categoriesCombinationCode=None,
9 TMVAfbdt=False, FANNmlp=False, downloadFlag=False,
10 useOnlyLocalFlag=False, signal_fraction=-2,
11 filesDirectory="./FlavorTagging/TrainedMethods", path=None):
13 Samples the input data or tests the combiner according to the selected categories.
18 from basf2
import B2INFO, B2FATAL
22 B2INFO(
'COMBINER LEVEL')
24 B2INFO(
"Flavor Tagger: Required Combiner for Categories:")
25 for category
in categories:
28 B2INFO(f
"Flavor Tagger: which corresponds to a weight file with categories\
29 combination code {categoriesCombinationCode}")
32 if variablesCombinerLevel
is None:
33 variablesCombinerLevel = []
34 exp_type = get_Belle_or_Belle2()
36 combiner_method_prefix = f
"FlavorTagger_{exp_type}_{weightFiles}Combiner{categoriesCombinationCode}"
40 identifierFBDT = f
"{combiner_method_prefix}FBDT"
41 if downloadFlag
or useOnlyLocalFlag:
42 identifierFBDT = f
"{filesDirectory}/{combiner_method_prefix}FBDT_1.root"
45 if not os.path.isfile(identifierFBDT):
46 basf2_mva.download(f
"{combiner_method_prefix}FBDT", identifierFBDT)
47 if not os.path.isfile(identifierFBDT):
48 B2FATAL(f
"Flavor Tagger: Weight file {identifierFBDT} was\
49 not downloaded from Database. Please check the\
50 buildOrRevision name. Stopped")
53 if not os.path.isfile(identifierFBDT):
54 B2FATAL(f
"flavorTagger: Combinerlevel FastBDT was not trained\
55 with this combination of categories. Weight file\
56 {identifierFBDT} not found. Stopped")
58 B2INFO(f
"flavorTagger: Ready to be used with weightFile\
59 {combiner_method_prefix}FBDT_1.root")
62 identifierFANN = f
"{combiner_method_prefix}FANN"
63 if downloadFlag
or useOnlyLocalFlag:
64 identifierFANN = f
"{filesDirectory}/{combiner_method_prefix}FANN_1.root"
67 if not os.path.isfile(identifierFANN):
68 basf2_mva.download(f
"{combiner_method_prefix}FANN", identifierFANN)
69 if not os.path.isfile(identifierFANN):
70 B2FATAL(f
"Flavor Tagger: Weight file {identifierFANN} was\
71 not downloaded from Database. Please check the\
72 build or revision name name. Stopped")
74 if not os.path.isfile(identifierFANN):
75 B2FATAL(f
"flavorTagger: Combinerlevel FANNMLP was not trained\
76 with this combination of categories. Weight file\
77 {identifierFANN} not found. Stopped")
79 B2INFO(f
"flavorTagger: Ready to be used with weightFile {combiner_method_prefix}FANN_1.root")
83 if TMVAfbdt
and not FANNmlp:
84 B2INFO(f
"flavorTagger: Apply FBDTMethod {combiner_method_prefix}FBDT")
88 extraInfoName=
'qrCombinedFBDT',
89 signalFraction=signal_fraction,
90 identifier=identifierFBDT
93 if FANNmlp
and not TMVAfbdt:
94 B2INFO(
'flavorTagger: Apply FANNMethod on combiner level')
98 extraInfoName=
'qrCombinedFANN',
99 signalFraction=signal_fraction,
100 entifier=identifierFANN
103 if FANNmlp
and TMVAfbdt:
104 B2INFO(
'flavorTagger: Apply FANNMethod and FBDTMethod on combiner level')
105 mvaMultipleExperts = basf2.register_module(
'MVAMultipleExperts')
106 mvaMultipleExperts.set_name(
'MVAMultipleExperts_Combiners')
107 mvaMultipleExperts.param(
'listNames', [])
108 mvaMultipleExperts.param(
'extraInfoNames', [
'qrCombinedFBDT',
'qrCombinedFANN'])
109 mvaMultipleExperts.param(
'signalFraction', signal_fraction)
110 mvaMultipleExperts.param(
'identifiers', [identifierFBDT, identifierFANN])
111 path.add_module(mvaMultipleExperts)