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