11"""This script is used in the nightly build to check for memory issues with valgrind.
12It is run as a test to make sure the memcheck does not fail because of issues in the script."""
14from b2test_utils
import skip_test_if_light
17from basf2
import set_random_seed, set_log_level, LogLevel, create_path, Module, find_file, process, statistics, conditions
18from simulation
import add_simulation
19from reconstruction
import add_reconstruction
20from mdst
import add_mdst_output
21from ROOT
import Belle2
22from modularAnalysis
import reconstructDecay, rankByHighest, buildRestOfEvent, buildContinuumSuppression, matchMCTruth, \
23 variablesToNtuple, getAnalysisGlobaltag
24from stdCharged
import stdPi, stdMu
25from vertex
import treeFit, TagV
26from flavorTagger
import flavorTagger
27from rawdata
import add_packers, add_unpackers
36set_log_level(LogLevel.ERROR)
39conditions.prepend_globaltag(getAnalysisGlobaltag())
45main.add_module(
'EventInfoSetter')
49 """Module to stop the event processing in case the argument InitOnly is given"""
52 """Set the event meta data to end of data"""
55 eventMetaData.setEndOfData()
58if len(sys.argv) > 1
and sys.argv[1] ==
'InitOnly':
62evtmetainfo = main.add_module(
'EventInfoPrinter')
63evtmetainfo.set_log_level(LogLevel.INFO)
66main.add_module(
'EvtGenInput', userDECFile=find_file(
'decfiles/dec/1111440100.dec'))
70if 'BELLE2_BACKGROUND_DIR' in os.environ:
71 bg = glob.glob(os.environ[
'BELLE2_BACKGROUND_DIR'] +
'/*.root')
72add_simulation(main, bkgfiles=bg)
75add_reconstruction(main)
78add_mdst_output(main,
True)
81main.add_module(
'RootOutput', outputFileName=
'dst.root')
85stdPi(
'loose', path=main)
86stdMu(
'loose', path=main)
89reconstructDecay(
'K_S0:pipi -> pi+:loose pi-:loose', cut=
'0.4 < M < 0.6', path=main)
92reconstructDecay(
'J/psi:mumu -> mu+:loose mu-:loose', cut=
'3.0 < M < 3.2', path=main)
95reconstructDecay(
'B0:jpsiks -> J/psi:mumu K_S0:pipi', cut=
'5.2 < M < 5.4', path=main)
98treeFit(
'B0:jpsiks', 0.0, path=main)
101rankByHighest(
'B0:jpsiks',
'chiProb', path=main)
104buildRestOfEvent(
'B0:jpsiks', path=main)
107buildContinuumSuppression(
'B0:jpsiks',
'all', path=main)
110matchMCTruth(
'B0:jpsiks', path=main)
116TagV(
'B0:jpsiks',
'breco', path=main)
119fs_vars = [
'kaonID',
'muonID',
'dr',
'dz',
'pValue',
'isSignal',
'mcErrors',
'genMotherID']
120b_vars = [
'nTracks',
'Mbc',
'deltaE',
'p',
'E',
'useCMSFrame(p)',
'useCMSFrame(E)',
121 'isSignal',
'mcErrors',
'nROE_KLMClusters',
'qrOutput(FBDT)',
'TagVLBoost',
'TagVz',
'TagVzErr',
'mcDeltaT'] + \
122 [f
'daughter(0,daughter(0,{var}))' for var
in fs_vars]
125variablesToNtuple(
'B0:jpsiks', variables=b_vars, filename=
'ntuple.root', treename=
'B0tree', path=main)
130for module
in main.modules():
131 if module.type() ==
'SVDUnpacker':
132 module.param(
'silentlyAppend',
True)
135main.add_module(
'Profile', outputFileName=
'vmem_profile.png', rssOutputFileName=
'rss_profile.png').set_log_level(LogLevel.INFO)
142statistics.csv(
'memcheck.csv')
a (simplified) python wrapper for StoreObjPtr.