14from background
import add_output
16d = datetime.datetime.today()
17print(d.strftime(
'job start: %Y-%m-%d %H:%M:%S\n'))
19print(
"Make a link to the input SAD files before running this steering script:")
20print(
"ln -s ~nakayama/[FIXME -> ask for the latest campaing] input")
22print(
"Produce first the input SAD files before running this steering script:")
23print(
"Make a link to the input SAD files before running this steering script:")
24print(
"ln -s ~login_name/[FIXME -> ask your-self where did I put it] input")
27 print(
"Usage: requires 8 arguments")
28 print(
"Argument 1: SAD input directory path")
29 print(
"Argument 2: (Touschek | Coulomb | Brens)_(HER | LER)(,_far)")
30 print(
"Argument 3: file number")
31 print(
"Argument 4: (study | usual | ECL | PXD)")
32 print(
"Argument 5: time-eqv in ns")
33 print(
"Argument 6: phase 1 | 2 |3")
34 print(
"Argument 7: ROOT output directory path")
35 print(
"Argument 8: digitization (true | false)")
46sampleTime = int(argvs[5])
49digitization = argvs[8]
51print(
'Input dir: ', input_dir)
53print(
'File number: ', num)
54print(
'Sample type: ', sampleType)
55print(
'Sample time: ', sampleTime,
'ns')
56print(
'Phase: ', phase)
57print(
'Output dir', output_dir)
60if name.find(
'LER') != -1:
62elif name.find(
'HER') != -1:
65 print(
'Name should include either of HER or LER')
68if name.find(
'far') != -1:
74fname =
'phase_' + str(argvs[6]) +
'_' + name +
'_' + sampleType +
'_' + num
75outputfilename = output_dir +
'/output_' + fname +
'.root'
82seed = str(1234567 + int(num))
83nummod = str(int(num) % 5000)
85if phase == 2
or phase == 3:
88 inputfilename =
'input/EvtbyEvt/' + name +
'_EvtbyEvt_' + nummod +
'.root'
89 if name ==
'Touschek_LER':
91 elif name ==
'Touschek_HER':
93 elif name ==
'Coulomb_LER':
95 elif name ==
'Coulomb_HER':
97 elif name ==
'Touschek_LER_far':
102 elif name ==
'Touschek_HER_far':
107 elif name ==
'Brems_HER':
109 elif name ==
'Brems_LER':
113 print(
'Unknown name! (' + name +
')')
117 readouttime = sampleTime
118 inputfilename =
'input/' + name +
'_' + nummod +
'.root'
120 print(
'Unknown name! (' + name +
')')
123if sampleType ==
'study':
125elif sampleType ==
'usual':
127elif sampleType ==
'ECL':
129elif sampleType ==
'PXD':
132 print(
'Unknown sample type! (' + sampleType +
')')
135print(
'accring: ', accring,
'(0:LER, 1:HER)')
136print(
'input: ', inputfilename)
137print(
'output: ', outputfilename)
138print(
'range: ', range)
139print(
'nevent: ', nevent)
140print(
'readmode: ', readmode)
141print(
'readouttime:', readouttime)
142print(
'bgType: ', bgType)
143print(
'sampleType: ', sampleType)
144print(
'realTime: ', realTime,
'ns')
147b2.set_log_level(b2.LogLevel.WARNING)
148b2.set_random_seed(int(seed))
150main = b2.create_path()
152eventinfosetter = b2.register_module(
'EventInfoSetter')
153eventinfosetter.param({
'evtNumList': [nevent],
'runList': [1],
'expList': [1]})
154main.add_module(eventinfosetter)
156gearbox = b2.register_module(
'Gearbox')
157if sampleType ==
'study' and phase == 3:
158 gearbox.param(
'override', [
159 (
'/Global/length',
'40.0',
'm'),
160 (
"/DetectorComponent[@name='PXD']//ActiveChips",
'true',
''),
161 (
"/DetectorComponent[@name='PXD']//SeeNeutrons",
'true',
''),
162 (
"/DetectorComponent[@name='SVD']//ActiveChips",
'true',
''),
163 (
"/DetectorComponent[@name='SVD']//SeeNeutrons",
'true',
''),
164 (
"/DetectorComponent[@name='TOP']//BeamBackgroundStudy",
'1',
''),
165 (
"/DetectorComponent[@name='ARICH']//BeamBackgroundStudy",
'1',
''),
166 (
"/DetectorComponent[@name='ECL']//BeamBackgroundStudy",
'1',
''),
167 (
"/DetectorComponent[@name='BKLM']//BeamBackgroundStudy",
'1',
''),
168 (
"/DetectorComponent[@name='BeamPipe']//LimitStepLength",
'1',
''),
169 (
"/DetectorComponent[@name='Cryostat']//LimitStepLength",
'1',
''),
170 (
"/DetectorComponent[@name='FarBeamLine']//LimitStepLength",
'1',
''),
173 gearbox.param(
'override', [(
'/Global/length',
'40.0',
'm')])
175 gearbox.param(
'fileName',
'/geometry/Beast2_phase2.xml')
177 gearbox.param(
'fileName',
'/geometry/Beast2_phase1.xml')
178main.add_module(gearbox)
180geometry = b2.register_module(
'Geometry')
181if phase == 2
or phase == 3:
183 "excludedComponents": [
"MagneticField"],
184 "additionalComponents": [
"MagneticField3dQuadBeamline"],
186main.add_module(geometry)
188sadinput = b2.register_module(
'SADInput')
189sadinput.param(
'Filename', inputfilename)
190sadinput.param(
'ReadMode', readmode)
191sadinput.param(
'AccRing', accring)
192sadinput.param(
'ReadoutTime', readouttime)
193sadinput.param(
'Range', range)
194main.add_module(sadinput)
196fullsim = b2.register_module(
'FullSim')
197fullsim.param(
'PhysicsList',
'FTFP_BERT_HP')
198fullsim.param(
'UICommandsAtIdle', [
'/process/inactivate nKiller'])
199fullsim.param(
'StoreAllSecondaries',
True)
200fullsim.param(
'SecondariesEnergyCut', 0.0)
201main.add_module(fullsim)
203progress = b2.register_module(
'Progress')
204main.add_module(progress)
205if phase == 1
and digitization ==
'true':
206 rootoutput = b2.register_module(
'RootOutput')
207 rootoutput.param(
'outputFileName', outputfilename)
208 rootoutput.param(
'updateFileCatalog',
False)
209 rootoutput.param(
'branchNames', [
"ClawSimHits",
"ClawsHits",
210 "BeamabortSimHits",
"BeamabortHits",
211 "PindiodeSimHits",
"PindiodeHits",
212 "BgoSimHits",
"BgobortHits",
213 "CsiSimHits",
"CsiHit_v2s",
214 "QcsmonitorSimHits",
"QcsmonitorHits",
215 "He3tubeSimHits",
"He3tubeHits",
216 "MicrotpcSimHits",
"MicrotpcHits",
218 bgodigi = b2.register_module(
'BgoDigitizer')
219 main.add_module(bgodigi)
222 csidigi = b2.register_module(
'CsiDigitizer_v2')
223 main.add_module(csidigi)
224 he3digi = b2.register_module(
'He3Digitizer')
225 he3digi.param(
'conversionFactor', 0.303132019)
226 he3digi.param(
'useMCParticles',
False)
227 main.add_module(he3digi)
228 diadigi = b2.register_module(
'BeamDigitizer')
229 diadigi.param(
'WorkFunction', 13.25)
230 diadigi.param(
'FanoFactor', 0.382)
231 main.add_module(diadigi)
232 pindigi = b2.register_module(
'PinDigitizer')
233 pindigi.param(
'WorkFunction', 3.64)
234 pindigi.param(
'FanoFactor', 0.13)
235 main.add_module(pindigi)
236 tpcdigi = b2.register_module(
'TpcDigitizer')
237 main.add_module(tpcdigi)
238 MIP_to_PE1 = [12.97, 12.46, 14.86, 15.71, 13.63, 14.56, 14.53, 15.31]
239 MIP_to_PE2 = [15.21, 12.46, 14.86, 15.71, 16.02, 15.83, 14.53, 15.31]
240 clawsdigi = b2.register_module(
'ClawDigitizer')
241 clawsdigi.param(
'ScintCell', 8)
242 clawsdigi.param(
'C_keV_to_MIP', 457.114)
243 clawsdigi.param(
'C_MIP_to_PE', MIP_to_PE2)
244 clawsdigi.param(
'PEthres', 1.0)
245 main.add_module(clawsdigi)
246 qcssdigi = b2.register_module(
'QcsmonitorDigitizer')
247 qcssdigi.param(
'ScintCell', 2)
248 qcssdigi.param(
'C_keV_to_MIP', 1629.827)
249 qcssdigi.param(
'C_MIP_to_PE', 15.0)
250 qcssdigi.param(
'MIPthres', 0.5)
251 main.add_module(qcssdigi)
252 main.add_module(rootoutput)
253elif phase == 2
and digitization ==
'true':
254 rootoutput = b2.register_module(
'RootOutput')
255 rootoutput.param(
'outputFileName', outputfilename)
256 rootoutput.param(
'updateFileCatalog',
False)
257 rootoutput.param(
'branchNames', [
"SVDSimHits",
"SVDTrueHits",
"SVDTrueHitsToSVDSimHits",
258 "PXDSimHits",
"MCParticleToPXDSimHits",
259 "CLAWSSimHits",
"ClawsHits",
260 "FANGSSimHits",
"FANGSHits",
262 "BeamabortSimHits",
"BeamabortHits",
263 "PindiodeSimHits",
"PindiodeHits",
264 "QcsmonitorSimHits",
"QcsmonitorHits",
265 "He3tubeSimHits",
"He3tubeHits",
266 "MicrotpcSimHits",
"MicrotpcHits",
268 MIP_to_PE = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]
269 he3digi = b2.register_module(
'He3Digitizer')
270 he3digi.param(
'conversionFactor', 0.303132019)
271 he3digi.param(
'useMCParticles',
False)
272 main.add_module(he3digi)
273 diadigi = b2.register_module(
'BeamDigitizer')
274 diadigi.param(
'WorkFunction', 13.25)
275 diadigi.param(
'FanoFactor', 0.382)
276 main.add_module(diadigi)
277 pindigi = b2.register_module(
'PinDigitizer')
278 pindigi.param(
'WorkFunction', 3.64)
279 pindigi.param(
'FanoFactor', 0.13)
280 main.add_module(pindigi)
281 clawsdigi = b2.register_module(
'ClawsDigitizer')
282 clawsdigi.param(
'ScintCell', 16)
283 clawsdigi.param(
'C_keV_to_MIP', 457.114)
284 clawsdigi.param(
'C_MIP_to_PE', MIP_to_PE)
285 clawsdigi.param(
'PEthres', 1.0)
286 main.add_module(clawsdigi)
287 qcssdigi = b2.register_module(
'QcsmonitorDigitizer')
288 qcssdigi.param(
'ScintCell', 40)
289 qcssdigi.param(
'C_keV_to_MIP', 1629.827)
290 qcssdigi.param(
'C_MIP_to_PE', 15.0)
291 qcssdigi.param(
'MIPthres', 0.5)
292 main.add_module(qcssdigi)
293 fangsdigi = b2.register_module(
'FANGSDigitizer')
294 main.add_module(fangsdigi)
295 tpcdigi = b2.register_module(
'TpcDigitizer')
296 main.add_module(tpcdigi)
297 main.add_module(rootoutput)
299 add_output(main, bgType, realTime, sampleType, phase, outputfilename)
303print(
'Event Statistics:')
306d = datetime.datetime.today()
307print(d.strftime(
'job finish: %Y-%m-%d %H:%M:%S\n'))