26from background
import add_output
59 print(
' basf2', argvs[0],
'equivTime_us num [sampleType phase outdir]')
61 print(
' equivTime_us equivalent SuperKEKB running time in micro-seconds')
62 print(
' num output file number')
63 print(
' sampleType one of: study, usual, PXD, ECL (D = usual)')
64 print(
' phase 2, 31 (= early phase 3, ie Run 1), 32 (= Run 2) or 3 (D = 3)')
65 print(
' outdir output directory path (D = output)')
82 print(
'phase ', phase,
'not supported')
85realTime = float(equivTime) * 1000
86numEvents = int(crossect * lumi * realTime * 1e-9)
87fname = bgType +
'_' + sampleType +
'-phase' + str(phase) +
'-' + num
88outputFile = outdir +
'/' + fname +
'.root'
91 b2.B2ERROR(
'number of events is 0 -> increase equivTime_us')
96if not os.path.exists(outdir):
101b2.B2RESULT(
'Events to be generated: ' + str(numEvents) +
' - corresponds to ' + equivTime +
102 ' us of running at ' + str(lumi) +
' /nb/s (phase ' + str(phase) +
')')
103b2.B2RESULT(
'Output file: ' + outputFile)
106b2.set_log_level(b2.LogLevel.RESULT)
109main = b2.create_path()
112eventinfosetter = b2.register_module(
'EventInfoSetter')
113eventinfosetter.param(
'evtNumList', [numEvents])
114main.add_module(eventinfosetter)
117gearbox = b2.register_module(
'Gearbox')
119 gearbox.param(
'fileName',
'geometry/Beast2_phase2.xml')
121 gearbox.param(
'fileName',
'geometry/Belle2_earlyPhase3.xml')
123 gearbox.param(
'fileName',
'geometry/Belle2_Run2.xml')
124if sampleType ==
'study':
125 gearbox.param(
'override', [
126 (
"/DetectorComponent[@name='PXD']//ActiveChips",
'true',
''),
127 (
"/DetectorComponent[@name='PXD']//SeeNeutrons",
'true',
''),
128 (
"/DetectorComponent[@name='SVD']//ActiveChips",
'true',
''),
129 (
"/DetectorComponent[@name='SVD']//SeeNeutrons",
'true',
''),
130 (
"/DetectorComponent[@name='TOP']//BeamBackgroundStudy",
'1',
''),
131 (
"/DetectorComponent[@name='ARICH']//BeamBackgroundStudy",
'1',
''),
132 (
"/DetectorComponent[@name='ECL']//BeamBackgroundStudy",
'1',
''),
133 (
"/DetectorComponent[@name='KLM']//BKLM/BeamBackgroundStudy",
'1',
''),
134 (
"/DetectorComponent[@name='KLM']//EKLM/BeamBackgroundStudy",
'1',
''),
136main.add_module(gearbox)
139aafh = b2.register_module(
'AafhInput')
143 'suppressionLimits': [1e100] * 4,
145 'maxFinalWeight': 2.5,
146 'maxSubgeneratorWeight': 1.0,
147 'subgeneratorWeights': [1.000e+00, 2.216e+01, 3.301e+03, 6.606e+03, 1.000e+00,
148 1.675e+00, 5.948e+00, 6.513e+00],
153geometry = b2.register_module(
'Geometry')
154geometry.param(
'useDB',
False)
155addComp = [
"MagneticField3dQuadBeamline"]
157if sampleType ==
'study' and (phase == 31
or phase == 32):
158 addComp.extend([
"BEAMABORT",
"MICROTPC",
"CLAWS",
"HE3TUBE"])
160geometry.param({
"excludedComponents": [
"MagneticField"],
161 "additionalComponents": addComp})
162main.add_module(geometry)
165fullsim = b2.register_module(
'FullSim')
166if sampleType ==
'study':
167 fullsim.param(
'PhysicsList',
'FTFP_BERT_HP')
168 fullsim.param(
'UICommandsAtIdle', [
'/process/inactivate nKiller'])
169 fullsim.param(
'StoreAllSecondaries',
True)
170 fullsim.param(
'SecondariesEnergyCut', 0.000001)
171main.add_module(fullsim)
174progress = b2.register_module(
'Progress')
175main.add_module(progress)
178if phase == 31
or phase == 32:
180add_output(main, bgType, realTime, sampleType, phase, fileName=outputFile)