23 import modularAnalysis
as ma
28 if (
len(sys.argv) < 2
or sys.argv[1]
not in [
'signal',
'qqbar']):
29 sys.exit(
"usage:\n\tbasf2 B2A703-ContinuumSuppression_MVAExpert.py <signal,qqbar>")
32 if not os.getenv(
'BELLE2_EXAMPLES_DATA_DIR'):
33 b2.B2FATAL(
"You need the example data installed. Run `b2install-data example` in terminal for it.")
35 step = str(sys.argv[1])
37 path = os.getenv(
'BELLE2_EXAMPLES_DATA_DIR')+
'/mva/'
41 input_file = [path +
'Bd_KsPi0_expert/*']
43 input_file = [path +
'*bar_expert/*']
45 sys.exit(
'Step does not match any of the available samples: `signal` or `qqbar`')
47 outfile =
'MVAExpert_fullNTuple_' + step +
'.root'
51 main = b2.create_path()
53 ma.inputMdst(environmentType=
'default',
57 ma.fillParticleList(decayString=
'gamma:all',
59 ma.fillParticleList(decayString=
'pi+:good',
60 cut=
'chiProb > 0.001 and pionID > 0.5',
62 ma.fillParticleList(decayString=
'pi-:good',
63 cut=
'chiProb > 0.001 and pionID > 0.5',
66 ma.reconstructDecay(decayString=
'K_S0 -> pi+:good pi-:good',
67 cut=
'0.480<=M<=0.516',
70 ma.reconstructDecay(decayString=
'pi0 -> gamma:all gamma:all',
71 cut=
'0.115<=M<=0.152',
74 ma.reconstructDecay(decayString=
'B0 -> K_S0 pi0',
75 cut=
'5.2 < Mbc < 5.3 and -0.3 < deltaE < 0.2',
78 ma.matchMCTruth(list_name=
'B0', path=main)
79 ma.buildRestOfEvent(list_name=
'B0', path=main)
83 cleanMask = (
'cleanMask',
'nCDCHits > 0 and useCMSFrame(p)<=3.2',
'p >= 0.05 and useCMSFrame(p)<=3.2')
84 ma.appendROEMasks(list_name=
'B0',
85 mask_tuples=[cleanMask],
88 ma.buildContinuumSuppression(list_name=
'B0',
104 'KSFWVariables(mm2)',
105 'KSFWVariables(hso00)',
106 'KSFWVariables(hso02)',
107 'KSFWVariables(hso04)',
108 'KSFWVariables(hso10)',
109 'KSFWVariables(hso12)',
110 'KSFWVariables(hso14)',
111 'KSFWVariables(hso20)',
112 'KSFWVariables(hso22)',
113 'KSFWVariables(hso24)',
114 'KSFWVariables(hoo0)',
115 'KSFWVariables(hoo1)',
116 'KSFWVariables(hoo2)',
117 'KSFWVariables(hoo3)',
118 'KSFWVariables(hoo4)',
131 targetVar = [
'isNotContinuumEvent']
134 main.add_module(
'MVAExpert', listNames=[
'B0'], extraInfoName=
'FastBDT', identifier=
'MVAFastBDT.root')
137 expertVars = [
'extraInfo(FastBDT)',
'transformedNetworkOutput(FastBDT,0.1,1.0)']
140 ma.variablesToNtuple(decayString=
'B0',
141 variables=trainVars + targetVar + expertVars,