Belle II Software development
background_bhabha_generation.py
1
8
9import sys
10import basf2
11
12if len(sys.argv) != 2:
13 print("Usage: {} [bbbrem|bhwide|bhwide_largeangle]".format(sys.argv[0]), file=sys.stderr)
14 sys.exit(1)
15
16generator = sys.argv[1].lower()
17
18kill = basf2.create_path()
19main = basf2.create_path()
20main.add_module("EventInfoSetter", expList=0, runList=1, evtNumList=1000000)
21main.add_module("EventInfoPrinter")
22
23basf2.set_log_level(basf2.LogLevel.DEBUG)
24basf2.set_debug_level(250)
25basf2.logging.package("framework").log_level = basf2.LogLevel.WARNING
26
27
28def add_cut(name, minParticles, maxParticles, minTheta, maxTheta=None):
29 """Add a generator level cut and kill the event if the cut is not passed. In
30 this case the cut is on the min/max charged particles which have a
31 center-of-mass theta angle between minTheta and maxTheta. If maxTheta is not
32 given assume it to be 180-minTheta for a symmetric window"""
33
34 # if only one angle make it symmetric
35 if maxTheta is None:
36 maxTheta = 180 - minTheta
37 selection = main.add_module("GeneratorPreselection", applyInCMS=True, nChargedMin=minParticles, nChargedMax=maxParticles,
38 MinChargedTheta=minTheta, MaxChargedTheta=maxTheta, MinChargedP=0., MinChargedPt=0.)
39 selection.if_value("!=11", kill)
40 selection.set_name("generator cut: " + name)
41
42
43if generator == "bbbrem":
44 main.add_module("BBBremInput", MinPhotonEnergyFraction=0.000001, Unweighted=True, MaxWeight=1.57001e+07)
45 # at least one track below 0.5 degree means maximum one particle in 0.5-179.5
46 add_cut("at least one track below 0.5 degree", 0, 1, 0.5)
47elif generator == "bhwide":
48 main.add_module("BHWideInput", ScatteringAngleRangeElectron=[0.5, 179.5], ScatteringAngleRangePositron=[0.5, 179.5])
49 add_cut("both tracks at least 0.5 degree", 2, 2, 0.5)
50 # but if one is above 1 and the other above 10 degree so we in 1-170 and
51 # 10-179
52 add_cut("max one track in 1-170", 0, 1, 1, 170)
53 add_cut("max one track in 10-179", 0, 1, 10, 179)
54elif generator == "bhwide_largeangle":
55 main.add_module("BHWideInput", ScatteringAngleRangeElectron=[0.5, 179.5], ScatteringAngleRangePositron=[0.5, 179.5])
56 add_cut("both tracks at least 1 degree", 2, 2, 1)
57 add_cut("at least one 10 degree", 1, 2, 10)
58else:
59 print("unknown generation setting: {}".format(generator))
60
61main.add_module("Progress")
62main.add_module("RootOutput", outputFileName="%s.root" % generator)
63basf2.process(main)
64print(basf2.statistics)