6 from ROOT
import Belle2
7 from math
import pi, tan
9 from subprocess
import call
17 lib_source =
'/home/belle2/tasheng/tsim/'
18 rdi_path =
'/home/belle2/tasheng/Vivado_2017.2/lib/lnx64.o'
20 lib_source =
'/home/trgadmin/tsim/'
21 rdi_path =
'/home/trgadmin/Xilinx/Vivado/2017.2/lib/lnx64.o'
27 if rdi_path
not in os.environ[
'LD_LIBRARY_PATH']:
28 print(
'please set environment variable first! do either')
29 print(
'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:' + rdi_path)
31 print(
'setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:' + rdi_path)
35 for link
in [
'xsim.dir',
'innerLRLUT.mif',
'outerLRLUT.mif']:
36 if link
not in os.listdir(os.getcwd()):
37 call([
'ln',
'-s', lib_source + link])
40 generate tracks with particle gun, simulate CDC and CDC trigger, save the output.
51 particlegun_params = {
52 'pdgCodes': [-13, 13],
54 'momentumGeneration':
'inversePt',
56 'momentumParams': [3., 10.],
57 'thetaGeneration':
'uniform',
59 'thetaParams': [80, 100],
60 'phiGeneration':
'uniform',
61 'phiParams': [46, 135],
62 'vertexGeneration':
'uniform',
63 'xVertexParams': [0, 0.0],
64 'yVertexParams': [0, 0.0],
66 'zVertexParams': [-10., 10.]}
73 basf2.set_random_seed(seed)
77 main = basf2.create_path()
79 empty_path = basf2.create_path()
82 z_SL0 = [-31 - 1.5 / tan(30 / 180. * pi), 57 + 1.5 / tan(17 / 180. * pi)]
89 Reject tracks with bad combination of z0 and theta
94 Initialize self.mc with MCParticles StoreArray
101 Reject tracks with bad combination of z0 and theta
104 z0 = self.
mc[0].getVertex().Z()
105 vec = self.
mc[0].getMomentum()
107 if z_SL0[0] < z0 + r_SL0 / vec.Pt() * vec.Z() < z_SL0[1]:
111 main.add_module(
'Progress')
114 inputName =
'tsfout.root'
116 main.add_module(
'RootInput', inputFileName=inputName)
119 main.add_module(
'EventInfoSetter', evtNumList=evtnum)
120 main.add_module(
'Gearbox')
121 main.add_module(
'Geometry', components=[
'BeamPipe',
123 'MagneticFieldConstant4LimitedRCDC'])
124 particlegun = basf2.register_module(
'ParticleGun')
125 particlegun.param(particlegun_params)
126 main.add_module(particlegun)
130 main.add_module(skim)
131 skim.if_false(empty_path)
133 main.add_module(
'FullSim')
134 main.add_module(
'CDCDigitizer')
145 firmtsf = register_module(
'CDCTriggerTSFFirmware')
149 main.add_module(firmtsf)
155 firm2d = register_module(
'CDCTrigger2DFinderFirmware')
156 firm2d.logging.log_level = basf2.LogLevel.DEBUG
157 firm2d.logging.debug_level = 20
158 firm2d.logging.set_info(basf2.LogLevel.DEBUG, basf2.LogInfo.LEVEL | basf2.LogInfo.MESSAGE)
159 firm2d.param(
'nClocks', 32)
160 main.add_module(firm2d)
163 main.add_module(
'RootOutput', outputFileName=
'tsfout.root')
169 print(basf2.statistics)