9from beamparameters
import add_beamparameters
12from background
import add_output
14d = datetime.datetime.today()
15print(d.strftime(
'job start: %Y-%m-%d %H:%M:%S\n'))
18 print(
"Usage: requires 5 arguments")
19 print(
"Argument 1: (bbbrem | bhwide | bhwide_largeangle | aafh | koralw)")
20 print(
"Argument 2: seed number")
21 print(
"Argument 3: (study | usual | ECL | PXD)")
22 print(
"Argument 4: phase ( 2 | 3)")
23 print(
"Argument 5: ROOT output directory path")
24 print(
"Argument 6: digitization (true | false)")
30generator = sys.argv[1].lower()
32sampleType = sys.argv[3]
35digitization = sys.argv[6]
40outputfilename = output_dir +
'/output_phase_' + argvs[4] +
'_' + generator +
'_' + num +
'.root'
43seed = str(1234567 + int(num))
44b2.set_random_seed(seed)
46kill = b2.create_path()
47main = b2.create_path()
56def add_cut(name, minParticles, maxParticles, minTheta, maxTheta=None):
57 """Add a generator level cut and kill the event if the cut is not passed. In
58 this case the cut is on the min/max charged particles which have a
59 center-of-mass theta angle between minTheta
and maxTheta. If maxTheta
is not
60 given assume it to be 180-minTheta
for a symmetric window
"""
64 maxTheta = 180 - minTheta
65 selection = main.add_module(
"GeneratorPreselection", applyInCMS=
True, nChargedMin=minParticles, nChargedMax=maxParticles,
66 MinChargedTheta=minTheta, MaxChargedTheta=maxTheta, MinChargedP=0., MinChargedPt=0.)
67 selection.if_value(
"!=11", kill)
68 selection.set_name(
"generator cut: " + name)
72beamparameters = add_beamparameters(main,
"Y4S")
73beamparameters.param(
"smearVertex",
True)
74beamparameters.param(
"generateCMS",
False)
76if generator ==
"bbbrem":
80 main.add_module(
"EventInfoSetter", expList=1, runList=1, evtNumList=evtnum)
81 main.add_module(
"BBBremInput", MinPhotonEnergyFraction=0.000001, Unweighted=
True, MaxWeight=1.57001e+07)
83 add_cut(
"at least one track below 0.5 degree", 0, 1, 0.5)
84elif generator ==
"bhwide":
88 main.add_module(
"EventInfoSetter", expList=1, runList=1, evtNumList=evtnum)
89 main.add_module(
"BHWideInput", ScatteringAngleRangeElectron=[0.5, 179.5], ScatteringAngleRangePositron=[0.5, 179.5])
90 add_cut(
"both tracks at least 0.5 degree", 2, 2, 0.5)
93 add_cut(
"max one track in 1-170", 0, 1, 1, 170)
94 add_cut(
"max one track in 10-179", 0, 1, 10, 179)
95elif generator ==
"bhwide_largeangle":
96 bgType =
'BHWideLargeAngle'
99 main.add_module(
"EventInfoSetter", expList=1, runList=1, evtNumList=evtnum)
100 main.add_module(
"BHWideInput", ScatteringAngleRangeElectron=[0.5, 179.5], ScatteringAngleRangePositron=[0.5, 179.5])
101 add_cut(
"both tracks at least 1 degree", 2, 2, 1)
102 add_cut(
"at least one 10 degree", 1, 2, 10)
103elif generator ==
"koralw":
107 main.add_module(
"EventInfoSetter", expList=1, runList=1, evtNumList=evtnum)
108 koralw = b2.register_module(
'KoralWInput')
109 koralw.param(
'RandomSeed', int(seed))
110 koralw.param(
'DataPath',
'./data/')
111 koralw.param(
'UserDataFile',
'KoralW_ee_mod.data')
113 main.add_module(koralw)
114elif generator ==
"aafh":
118 main.add_module(
"EventInfoSetter", expList=1, runList=1, evtNumList=evtnum)
119 aafh = b2.register_module(
'AafhInput')
147 'suppressionLimits': [1e100] * 4,
171 'maxFinalWeight': 2.5,
172 'maxSubgeneratorWeight': 1.0,
173 'subgeneratorWeights': [1.000e+00, 2.216e+01, 3.301e+03, 6.606e+03, 1.000e+00, 1.675e+00, 5.948e+00, 6.513e+00],
177 main.add_module(aafh)
179 print(
"unknown generation setting: {}".format(generator))
181print(
'generator ', generator)
182print(
'bgtype', bgType)
183print(
'reaTime', realTime)
185gearbox = b2.register_module(
'Gearbox')
186if sampleType ==
'study' and phase == 3:
187 gearbox.param(
'override', [
188 (
'/Global/length',
'40.0',
'm'),
189 (
"/DetectorComponent[@name='PXD']//ActiveChips",
'true',
''),
190 (
"/DetectorComponent[@name='PXD']//SeeNeutrons",
'true',
''),
191 (
"/DetectorComponent[@name='SVD']//ActiveChips",
'true',
''),
192 (
"/DetectorComponent[@name='SVD']//SeeNeutrons",
'true',
''),
193 (
"/DetectorComponent[@name='TOP']//BeamBackgroundStudy",
'1',
''),
194 (
"/DetectorComponent[@name='ARICH']//BeamBackgroundStudy",
'1',
''),
195 (
"/DetectorComponent[@name='ECL']//BeamBackgroundStudy",
'1',
''),
196 (
"/DetectorComponent[@name='BKLM']//BeamBackgroundStudy",
'1',
''),
197 (
"/DetectorComponent[@name='BeamPipe']//LimitStepLength",
'1',
''),
198 (
"/DetectorComponent[@name='Cryostat']//LimitStepLength",
'1',
''),
199 (
"/DetectorComponent[@name='FarBeamLine']//LimitStepLength",
'1',
''),
202 gearbox.param(
'override', [(
'/Global/length',
'40.0',
'm')])
204 gearbox.param(
'fileName',
'/geometry/Beast2_phase2.xml')
205main.add_module(gearbox)
207geometry = b2.register_module(
'Geometry')
209 "excludedComponents": [
"MagneticField"],
210 "additionalComponents": [
"MagneticField3dQuadBeamline"],
213main.add_module(geometry)
220fullsim = b2.register_module(
'FullSim')
221fullsim.param(
'PhysicsList',
'FTFP_BERT_HP')
222fullsim.param(
'UICommandsAtIdle', [
'/process/inactivate nKiller'])
223fullsim.param(
'StoreAllSecondaries',
True)
224fullsim.param(
'SecondariesEnergyCut', 0.0)
225main.add_module(fullsim)
227main.add_module(
"Progress")
229if phase == 2
and digitization ==
'true':
230 rootoutput = b2.register_module(
'RootOutput')
231 rootoutput.param(
'outputFileName', outputfilename)
232 rootoutput.param(
'updateFileCatalog',
False)
233 rootoutput.param(
'branchNames', [
"SVDSimHits",
"SVDTrueHits",
"SVDTrueHitsToSVDSimHits",
234 "PXDSimHits",
"MCParticleToPXDSimHits",
235 "CLAWSSimHits",
"ClawsHits",
236 "FANGSSimHits",
"FANGSHits",
238 "BeamabortSimHits",
"BeamabortHits",
239 "PindiodeSimHits",
"PindiodeHits",
240 "QcsmonitorSimHits",
"QcsmonitorHits",
241 "He3tubeSimHits",
"He3tubeHits",
242 "MicrotpcSimHits",
"MicrotpcHits",
244 MIP_to_PE = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]
245 he3digi = b2.register_module(
'He3Digitizer')
246 he3digi.param(
'conversionFactor', 0.303132019)
247 he3digi.param(
'useMCParticles',
False)
248 main.add_module(he3digi)
249 diadigi = b2.register_module(
'BeamDigitizer')
250 diadigi.param(
'WorkFunction', 13.25)
251 diadigi.param(
'FanoFactor', 0.382)
252 main.add_module(diadigi)
253 pindigi = b2.register_module(
'PinDigitizer')
254 pindigi.param(
'WorkFunction', 3.64)
255 pindigi.param(
'FanoFactor', 0.13)
256 main.add_module(pindigi)
257 clawsdigi = b2.register_module(
'ClawsDigitizer')
258 clawsdigi.param(
'ScintCell', 16)
259 clawsdigi.param(
'C_keV_to_MIP', 457.114)
260 clawsdigi.param(
'C_MIP_to_PE', MIP_to_PE)
261 clawsdigi.param(
'PEthres', 1.0)
262 main.add_module(clawsdigi)
263 qcssdigi = b2.register_module(
'QcsmonitorDigitizer')
264 qcssdigi.param(
'ScintCell', 40)
265 qcssdigi.param(
'C_keV_to_MIP', 1629.827)
266 qcssdigi.param(
'C_MIP_to_PE', 15.0)
267 qcssdigi.param(
'MIPthres', 0.5)
268 main.add_module(qcssdigi)
269 fangsdigi = b2.register_module(
'FANGSDigitizer')
270 main.add_module(fangsdigi)
271 tpcdigi = b2.register_module(
'TpcDigitizer')
272 main.add_module(tpcdigi)
273 main.add_module(rootoutput)
275 add_output(main, bgType, realTime, sampleType, phase, outputfilename)
280print(
'Event Statistics:')
283d = datetime.datetime.today()
284print(d.strftime(
'job finish: %Y-%m-%d %H:%M:%S\n'))