11from basf2
import create_path, set_log_level, B2ERROR, B2INFO, LogLevel, process, statistics
13from svd
import add_svd_simulation
32 if argvs[1] ==
'phase2':
35 elif argvs[1] ==
'phase3':
38 elif argvs[1] ==
'phase31':
42 B2ERROR(
'The argument can be either phase2, phase3 or phase31')
45 B2ERROR(
'No argument given specifying the running phase')
46 print(
'Usage: basf2 ' + argvs[0] +
' phase2/phase3/phase31 [scaleFactor=1 ' +
47 'PXDmode=ungated/gated]')
53 scaleFactor = float(argvs[2])
57if len(argvs) > 3
and argvs[3] ==
'gated':
62if 'BELLE2_BACKGROUND_MIXING_DIR' not in os.environ:
63 B2ERROR(
'BELLE2_BACKGROUND_MIXING_DIR variable is not set - it must contain the path to BG samples')
64 B2INFO(
'on KEKCC: /sw/belle2/bkg.mixing')
67bg = glob.glob(os.environ[
'BELLE2_BACKGROUND_MIXING_DIR'] +
'/*.root')
70 B2ERROR(
'No root files found in folder ' + os.environ[
'BELLE2_BACKGROUND_MIXING_DIR'])
74if 'BELLE2_BACKGROUND_MIXING_EXTRA_DIRS' not in os.environ:
75 B2ERROR(
'BELLE2_BACKGROUND_MIXING_EXTRA_DIRS variable is not set - it must contain the path to extra samples')
76 B2INFO(
'on KEKCC: /sw/belle2/bkg.mixing_extra')
79SVDOverlayDir = os.environ[
'BELLE2_BACKGROUND_MIXING_EXTRA_DIRS'] +
'/SVD'
80SVDOverlayFiles = glob.glob(SVDOverlayDir +
'/*_overlay.root')
82if len(SVDOverlayFiles) == 0:
83 B2ERROR(
'No root files found in folder ' + SVDOverlayDir)
86B2INFO(
'Making BG overlay sample for ' + argvs[1] +
' with ECL compression = ' +
87 str(compression) +
' and PXD in ' + mode +
' mode')
88B2INFO(
'Using background samples from folder ' + os.environ[
'BELLE2_BACKGROUND_MIXING_DIR'])
89B2INFO(
'With scaling factor: ' + str(scaleFactor))
90B2INFO(
'With SVD xTalk&Noise files from folder ' + str(SVDOverlayDir))
92set_log_level(LogLevel.WARNING)
98main.add_module(
'EventInfoSetter', evtNumList=[100], expList=[expNo])
101main.add_module(
'Gearbox')
104main.add_module(
'Geometry')
107main.add_module(
'SimulateEventLevelTriggerTimeInfo')
111 main.add_module(
'BeamBkgMixer', backgroundFiles=bg, overallScaleFactor=scaleFactor,
112 minTimePXD=-20000.0, maxTimePXD=20000.0)
115 main.add_module(
'PXDInjectionVetoEmulator')
118 main.add_module(
'PXDDigitizer')
121 main.add_module(
'BeamBkgMixer', backgroundFiles=bg, overallScaleFactor=scaleFactor)
124 main.add_module(
'PXDDigitizer', IntegrationWindow=
False)
127add_svd_simulation(main)
129main.add_module(
'BGOverlayInput', skipExperimentCheck=
True, bkgInfoName=
'BackgroundInfoSVDOverlay', inputFileNames=SVDOverlayFiles)
130main.add_module(
'BGOverlayExecutor', bkgInfoName=
'BackgroundInfoSVDOverlay')
131main.add_module(
'SVDShaperDigitSorter')
134main.add_module(
'CDCDigitizer')
137main.add_module(
'TOPDigitizer')
140main.add_module(
'ARICHDigitizer')
143main.add_module(
'ECLDigitizer', WaveformMaker=
True, CompressionAlgorithm=compression)
146main.add_module(
'KLMDigitizer')
149main.add_module(
'TRGECLBGTCHit')
152branches = [
'EventLevelTriggerTimeInfo',
'PXDDigits',
'SVDShaperDigits',
'CDCHits',
'TOPDigits',
153 'ARICHDigits',
'ECLWaveforms',
'KLMDigits',
'TRGECLBGTCHits']
155 branches += [
'PXDInjectionBGTiming']
156main.add_module(
'RootOutput', outputFileName=
'BGforOverlay.root', branchNames=branches)
159main.add_module(
'Progress')