12 """This script is used in the nightly build to check for memory issues with valgrind. 
   13 It is run as a test to make sure the memcheck does not fail because of issues in the script.""" 
   15 from b2test_utils 
import skip_test_if_light
 
   18 from basf2 
import set_random_seed, set_log_level, LogLevel, create_path, Module, find_file, process, statistics, conditions
 
   19 from simulation 
import add_simulation
 
   20 from reconstruction 
import add_reconstruction
 
   21 from mdst 
import add_mdst_output
 
   22 from ROOT 
import Belle2
 
   23 from modularAnalysis 
import reconstructDecay, rankByHighest, buildRestOfEvent, buildContinuumSuppression, matchMCTruth, \
 
   24     variablesToNtuple, getAnalysisGlobaltag
 
   25 from stdCharged 
import stdPi, stdMu
 
   26 from vertex 
import treeFit, TagV
 
   27 from flavorTagger 
import flavorTagger
 
   28 from rawdata 
import add_packers, add_unpackers
 
   37 set_log_level(LogLevel.ERROR)
 
   40 conditions.prepend_globaltag(getAnalysisGlobaltag())
 
   46 main.add_module(
'EventInfoSetter')
 
   50     """Module to stop the event processing in case the argument InitOnly is given""" 
   53         """Set the event meta data to end of data""" 
   56         eventMetaData.setEndOfData()
 
   59 if len(sys.argv) > 1 
and sys.argv[1] == 
'InitOnly':
 
   63 evtmetainfo = main.add_module(
'EventInfoPrinter')
 
   64 evtmetainfo.set_log_level(LogLevel.INFO)
 
   67 main.add_module(
'EvtGenInput', userDECFile=find_file(
'decfiles/dec/1111440100.dec'))
 
   71 if 'BELLE2_BACKGROUND_DIR' in os.environ:
 
   72     bg = glob.glob(os.environ[
'BELLE2_BACKGROUND_DIR'] + 
'/*.root')
 
   73 add_simulation(main, bkgfiles=bg)
 
   76 add_reconstruction(main)
 
   79 add_mdst_output(main, 
True)
 
   82 main.add_module(
'RootOutput', outputFileName=
'dst.root')
 
   86 stdPi(
'loose', path=main)
 
   87 stdMu(
'loose', path=main)
 
   90 reconstructDecay(
'K_S0:pipi -> pi+:loose pi-:loose', cut=
'0.4 < M < 0.6', path=main)
 
   93 reconstructDecay(
'J/psi:mumu -> mu+:loose mu-:loose', cut=
'3.0 < M < 3.2', path=main)
 
   96 reconstructDecay(
'B0:jpsiks -> J/psi:mumu K_S0:pipi', cut=
'5.2 < M < 5.4', path=main)
 
   99 treeFit(
'B0:jpsiks', 0.0, path=main)
 
  102 rankByHighest(
'B0:jpsiks', 
'chiProb', path=main)
 
  105 buildRestOfEvent(
'B0:jpsiks', path=main)
 
  108 buildContinuumSuppression(
'B0:jpsiks', 
'all', path=main)
 
  111 matchMCTruth(
'B0:jpsiks', path=main)
 
  117 TagV(
'B0:jpsiks', 
'breco', path=main)
 
  120 fs_vars = [
'kaonID', 
'muonID', 
'dr', 
'dz', 
'pValue', 
'isSignal', 
'mcErrors', 
'genMotherID']
 
  121 b_vars = [
'nTracks', 
'Mbc', 
'deltaE', 
'p', 
'E', 
'useCMSFrame(p)', 
'useCMSFrame(E)',
 
  122           'isSignal', 
'mcErrors', 
'nROE_KLMClusters', 
'qrOutput(FBDT)', 
'TagVLBoost', 
'TagVz', 
'TagVzErr', 
'mcDeltaT'] + \
 
  123     [
'daughter(0,daughter(0,%s))' % var 
for var 
in fs_vars]
 
  126 variablesToNtuple(
'B0:jpsiks', variables=b_vars, filename=
'ntuple.root', treename=
'B0tree', path=main)
 
  131 for module 
in main.modules():
 
  132     if module.type() == 
'SVDUnpacker':
 
  133         module.param(
'silentlyAppend', 
True)
 
  136 main.add_module(
'Profile', outputFileName=
'vmem_profile.png', rssOutputFileName=
'rss_profile.png').set_log_level(LogLevel.INFO)
 
a (simplified) python wrapper for StoreObjPtr.