5 print(
"Usage: {} [bbbrem|bhwide|bhwide_largeangle]".format(sys.argv[0]), file=sys.stderr)
8 generator = sys.argv[1].lower()
10 kill = basf2.create_path()
11 main = basf2.create_path()
12 main.add_module(
"EventInfoSetter", expList=0, runList=1, evtNumList=1000000)
13 main.add_module(
"EventInfoPrinter")
15 basf2.set_log_level(basf2.LogLevel.DEBUG)
16 basf2.set_debug_level(250)
17 basf2.logging.package(
"framework").log_level = basf2.LogLevel.WARNING
20 def add_cut(name, minParticles, maxParticles, minTheta, maxTheta=None):
21 """Add a generator level cut and kill the event if the cut is not passed. In
22 this case the cut is on the min/max charged particles which have a
23 center-of-mass theta angle between minTheta and maxTheta. If maxTheta is not
24 given assume it to be 180-minTheta for a symmetric window"""
28 maxTheta = 180 - minTheta
29 selection = main.add_module(
"GeneratorPreselection", applyInCMS=
True, nChargedMin=minParticles, nChargedMax=maxParticles,
30 MinChargedTheta=minTheta, MaxChargedTheta=maxTheta, MinChargedP=0., MinChargedPt=0.)
31 selection.if_value(
"!=11", kill)
32 selection.set_name(
"generator cut: " + name)
35 if generator ==
"bbbrem":
36 main.add_module(
"BBBremInput", MinPhotonEnergyFraction=0.000001, Unweighted=
True, MaxWeight=1.57001e+07)
38 add_cut(
"at least one track below 0.5 degree", 0, 1, 0.5)
39 elif generator ==
"bhwide":
40 main.add_module(
"BHWideInput", ScatteringAngleRangeElectron=[0.5, 179.5], ScatteringAngleRangePositron=[0.5, 179.5])
41 add_cut(
"both tracks at least 0.5 degree", 2, 2, 0.5)
44 add_cut(
"max one track in 1-170", 0, 1, 1, 170)
45 add_cut(
"max one track in 10-179", 0, 1, 10, 179)
46 elif generator ==
"bhwide_largeangle":
47 main.add_module(
"BHWideInput", ScatteringAngleRangeElectron=[0.5, 179.5], ScatteringAngleRangePositron=[0.5, 179.5])
48 add_cut(
"both tracks at least 1 degree", 2, 2, 1)
49 add_cut(
"at least one 10 degree", 1, 2, 10)
51 print(
"unknown generation setting: {}".format(generator))
53 main.add_module(
"Progress")
54 main.add_module(
"RootOutput", outputFileName=
"%s.root" % generator)
56 print(basf2.statistics)