Belle II Software development
trggrl.py
1#!/usr/bin/env python3
2
3
10
11# ------------------------------------------------------------------------------------------------------
12# TSim-ecl example code.
13# ------------------------------------------------------------------------------------------------------
14# In order to test Tsim-ecl code, you need a root file which has ECLHit table.(after Gsim)
15# ex)
16# commend > basf2 TrgEcl_pgun.py [Name of output root file]
17# ------------------------------------------------------------------------------------------------------
18import os
19import basf2 as b2
20import random
21
22
23import sys # get argv
24argvs = sys.argv # get arg
25argc = len(argvs) # of arg
26if argc != 2:
27 sys.exit("ztsim02.py> # of arg is strange. Exit.")
28if argc == 2:
29
30 f_out_root = argvs[1]
31print()
32# print 'f_in_root = %s' % f_in_root
33print(f'f_out_root = {f_out_root}\n')
34
35
38
39# suppress messages and warnings during processing:
40# level: LogLevel.DEBUG/INFO/WARNING/ERROR/FATALls
41b2.set_log_level(b2.LogLevel.ERROR)
42# set_log_level(LogLevel.INFO)
43# set_log_level(LogLevel.DEBUG)
44
45b2.set_random_seed(0)
46basf2datadir = os.path.join(os.environ.get('BELLE2_LOCAL_DIR', None), 'data')
47
48# one event
49# eventinfosetter.param({'evtNumList': [1000], 'runList': [1]})
50
51# Register necessary modules
52eventinfosetter = b2.register_module('EventInfoSetter')
53eventinfoprinter = b2.register_module('EventInfoPrinter')
54
55gearbox = b2.register_module('Gearbox')
56
57# input
58# rootinput1 = register_module('RootInput')
59# rootinput1.param('inputFileName', f_in_root)
60
61# Geometry builder
62geometry = b2.register_module('Geometry')
63
64# Simulation
65g4sim = b2.register_module('FullSim')
66
67# register module for TRGCDC
68# evtmetagen = register_module('EventInfoSetter')
69evtmetainfo = b2.register_module('Progress')
70# paramloader = register_module('Gearbox')
71# geobuilder = register_module('Geometry')
72# particlegun = register_module('ParticleGun')
73# evtgeninput = register_module('EvtGenInput')
74# kkgeninput = register_module('KKGenInput')
75mcparticleprinter = b2.register_module('PrintMCParticles')
76# g4sim = register_module('FullSim')
77# bkgmixer = register_module('BeamBkgMixer')
78cdcdigitizer = b2.register_module('CDCDigitizer')
79cdctrg = b2.register_module("TRGCDC")
80# rootOut = register_module('RootOutput')
81# rootIn = register_module('RootInput')
82
83
84# one event
85eventinfosetter.param({'evtNumList': [100], 'runList': [1]})
86
87intseed = random.randint(1, 10000000)
88
89pGun = b2.register_module('ParticleGun')
90param_pGun = {
91 'pdgCodes': [11],
92 'nTracks': 1,
93 'momentumGeneration': 'uniform',
94 'momentumParams': [1.0, 2.0],
95 'thetaGeneration': 'uniform',
96 'thetaParams': [50., 130.],
97 'phiGeneration': 'uniform',
98 # 'phiParams': [0, 360],
99 'phiParams': [-45, 45],
100 'vertexGeneration': 'uniform',
101 'xVertexParams': [0.0, 0.0],
102 'yVertexParams': [0.0, 0.0],
103 'zVertexParams': [0.0, 0.0],
104}
105
106pGun.param(param_pGun)
107
108mcparticleprinter.param('maxLevel', -1)
109# need to check
110# g4sim.param('UICommandsAtIdle',['/control/execute ' +
111# os.path.join(os.environ.get('BELLE2_LOCAL_DIR', None),"trg/cdc/examples/physics.mac")])
112
113# ...CDCDigitizer...
114# set digitizer to no smearing
115param_cdcdigi = {'Fraction': 1,
116 'Resolution1': 0.,
117 'Resolution2': 0.,
118 'Threshold': -10.0}
119cdcdigitizer.param(param_cdcdigi)
120cdcdigitizer.param('AddInWirePropagationDelay', True)
121cdcdigitizer.param('AddTimeOfFlight', True)
122
123# ...CDC Trigger...
124# ---General settings---
125# cdctrg.param('ConfigFile', os.path.join(basf2datadir,"trg/cdc/TRGCDCConfig_0_20101111_1051.dat"))
126cdctrg.param('ConfigFile', os.path.join(basf2datadir, "trg/cdc/TRGCDCConfig_0_20101111_1051_2013beamtest.dat"))
127# cdctrg.param('DebugLevel', 1)
128cdctrg.param('CurlBackStop', 0)
129cdctrg.param('SimulationMode', 1) # 1:fast, 2:firm, 3:fast and firm
130cdctrg.param('FastSimulationMode', 0)
131# cdctrg.param('SimulationMode',0x11)
132# cdctrg.param('TRGCDCRootFile',1)
133# cdctrg.param('RootTRGCDCFile', 'TRGCDC.root')
134# ---TSF settings---
135# TSLUT (latest version @ 2014.07)
136cdctrg.param('InnerTSLUTFile', os.path.join(basf2datadir, "trg/cdc/innerLUT_v2.2.coe"))
137cdctrg.param('OuterTSLUTFile', os.path.join(basf2datadir, "trg/cdc/outerLUT_v2.2.coe"))
138# cdctrg.param('TSFLogicLUT', 1)
139# cdctrg.param('TSFRootFile',1)
140# ---2D finder settings---
141cdctrg.param('2DFinderPerfect', 0)
142cdctrg.param('HoughFinderMeshX', 160)
143cdctrg.param('HoughFinderMeshY', 26)
144# ---3D finder settings---
145cdctrg.param('Hough3DRootFile', 1)
146# 0: perfect finder, 1: Hough3DFinder, 2: (Default) GeoFinder, 3: VHDL GeoFinder
147# 0: (Default) Logic TSF, 1: LUT TSF
148# cdctrg.param('Finder3DMode',0)
149# ---3D fitter settings---
150cdctrg.param('Fitter3DRootFile', 1)
151cdctrg.param('RootFitter3DFile', 'Fitter3D.root')
152cdctrg.param('Fitter3DLRLUT', 0)
153
154
155# TRGECL
156trgeclfam = b2.register_module("TRGECLFAM")
157trgecl = b2.register_module("TRGECL")
158trgeclMC = b2.register_module("TRGECLMCMatching")
159# addParam("FAMFitMethod", _famMethod, "TRGECLFAM fit method", _famMethod);
160trgeclfam.param('FAMFitMethod', 1)
161
162grltrg = b2.register_module('TRGGRL')
163grltrg.param('DebugLevel', 0)
164grltrg.param('ConfigFile',
165 os.path.join(os.environ['BELLE2_LOCAL_DIR'],
166 "trg/gdl/data/ftd/0.01/ftd_0.01"))
167
168# output
169rootoutput = b2.register_module('RootOutput')
170rootoutput.param('outputFileName', f_out_root)
171
172# import random
173# progress = register_module('Progress')
174
175
176# Set parameters
177
178# Create paths
179main = b2.create_path()
180
181# main.add_module(rootinput1)
182# main.add_module(rootinput2)
183main.add_module(eventinfosetter)
184main.add_module(eventinfoprinter)
185main.add_module(evtmetainfo)
186# main.add_module(paramloader)
187main.add_module(gearbox)
188main.add_module(geometry)
189main.add_module(pGun)
190main.add_module(mcparticleprinter)
191main.add_module(g4sim)
192
193main.add_module(cdcdigitizer)
194main.add_module(cdctrg)
195main.add_module(trgeclfam)
196main.add_module(trgecl)
197main.add_module(grltrg)
198# main.add_module(trgeclMC)
199
200main.add_module(rootoutput)
201
202
203# main
204b2.process(main)
205
208print(b2.statistics)
209# ===<END>