HPS-MC
tritrig_beam_slic_to_reco_job.py
Go to the documentation of this file.
1 """!
2 @file tritrig_beam_job.py
3 
4 Merge tritrig and beam events, simulate signal events, and detector readout.
5 """
6 import os
7 from hpsmc.tools import SLIC, JobManager, LCIOCount, LCIOMerge, ExtractEventsWithHitAtHodoEcal
8 
9 
10 inputs = list(job.input_files.values())
11 
12 job.description = 'tritrig beam slic to reco'
13 
14 if 'nevents' in job.params:
15  nevents = job.params['nevents']
16 else:
17  nevents = 10000
18 
19 
20 tritrig_file_name = 'tritrig_events.stdhep'
21 
22 
23 beam_file_names = []
24 beam_slic_file_names = []
25 for i in range(len(inputs)):
26  if inputs[i] != tritrig_file_name:
27  beam_file_names.append(inputs[i])
28  filename, file_extension = os.path.splitext(inputs[i])
29  beam_slic_file = filename + '.slcio'
30  beam_slic_file_names.append(beam_slic_file)
31 
32 
33 tritrig_name = 'tritrig'
34 
35 
36 beam_name = 'beam'
37 
38 
39 tritrig_beam_name = 'tritrig_beam'
40 
41 
42 slic = SLIC(inputs=[tritrig_file_name],
43  outputs=['%s.slcio' % tritrig_name])
44 
45 
46 filter_bunches = ExtractEventsWithHitAtHodoEcal(inputs=slic.output_files(),
47  outputs=['%s_filt.slcio' % tritrig_name],
48  event_interval=250, num_hodo_hits=0)
49 
50 
51 count_filter = LCIOCount(inputs=filter_bunches.output_files())
52 
53 
54 slic_beams = []
55 for i in range(len(beam_file_names)):
56  slic_beams.append(SLIC(inputs=[beam_file_names[i]],
57  outputs=[beam_slic_file_names[i]],
58  nevents=nevents * 250,
59  ignore_job_params=['nevents'])
60  )
61 
62 
63 slic_beam_cat = ExtractEventsWithHitAtHodoEcal(inputs=beam_slic_file_names,
64  outputs=['beam_cat.slcio'],
65  event_interval=0, num_hodo_hits=0)
66 
67 
68 merge = LCIOMerge(inputs=[filter_bunches.output_files()[0],
69  slic_beam_cat.outputs[0]],
70  outputs=['%s.slcio' % tritrig_beam_name],
71  ignore_job_params=['nevents'])
72 
73 
74 count_merge = LCIOCount(inputs=merge.output_files())
75 
76 
77 readout = JobManager(steering='readout',
78  inputs=merge.output_files(),
79  outputs=['%s_readout.slcio' % tritrig_beam_name])
80 
81 
82 count_readout = LCIOCount(inputs=readout.output_files())
83 
84 
85 recon = JobManager(steering='recon',
86  inputs=readout.output_files(),
87  outputs=['%s_recon.slcio' % tritrig_beam_name])
88 
89 
90 count_recon = LCIOCount(inputs=recon.output_files())
91 
92 comps = [slic, filter_bunches, count_filter]
93 for i in range(len(slic_beams)):
94  comps.append(slic_beams[i])
95 comps.extend([slic_beam_cat, merge, count_merge, readout, count_readout, recon, count_recon])
96 job.add(comps)
Apply hodo-hit filter and space MC events to process before readout.
Definition: tools.py:1160
Run the hps-java JobManager class.
Definition: tools.py:160
Count events in LCIO files.
Definition: tools.py:1487
Merge LCIO files.
Definition: tools.py:1530
Run the SLIC Geant4 simulation.
Definition: tools.py:15
Tools that can be used in HPSMC jobs.
Definition: tools.py:1