HPS-MC
ap_slic_job.py
Go to the documentation of this file.
1 """!
2 @file ap_slic_job.py
3 
4 Job script to convert A-prime events to StdHep, apply transformations,
5 and resulting simulate signal events using SLIC.
6 """
7 
8 import logging
9 from hpsmc.generators import StdHepConverter
10 from hpsmc.tools import DisplaceUni, Unzip, BeamCoords, AddMotherFullTruth, SLIC
11 
12 
13 logger = logging.getLogger('hpsmc.job')
14 
15 job.description = 'ap to slic'
16 
17 
18 inputs = list(job.input_files.values())
19 
20 if 'nevents' in job.params:
21  nevents = job.params['nevents']
22 else:
23  nevents = 10000
24 
25 if 'ap_decay_dist' in job.params:
26  ap_decay_dist = job.params['ap_decay_dist']
27 else:
28  ap_decay_dist = "lhe_uniform"
29 
30 
31 unzip = Unzip(inputs=["ap_unweighted_events.lhe.gz"], outputs=["ap_unweighted_events.lhe"])
32 
33 if ap_decay_dist == "lhe_uniform":
34 
35  cnv = StdHepConverter(name="lhe_uniform", inputs=["ap_unweighted_events.lhe"])
36  job.add([cnv])
37 elif ap_decay_dist == "lhe_prompt":
38 
39  cnv = StdHepConverter(name="lhe_prompt", inputs=["ap_unweighted_events.lhe"])
40  job.add([cnv])
41 elif ap_decay_dist == "displace_time":
42  if 'ctau' in job.params:
43 
44  cnv = DisplaceUni(inputs=["ap_unweighted_events.lhe"])
45  job.add([cnv])
46  else:
47  logger.error("Missing parameter ctau")
48 else:
49  logger.error("Invalid ap decay distribution: ap_decay_dist = %s" % ap_decay_dist)
50 
51 
52 mom = AddMotherFullTruth(inputs=["ap_displace.stdhep", unzip.output_files()[0]], outputs=["ap_mom.stdhep"])
53 
54 
55 rot = BeamCoords(inputs=mom.output_files(), outputs=["ap_rot.stdhep"])
56 
57 
58 slic = SLIC(nevents=nevents + 1, inputs=rot.output_files(), outputs=["ap.slcio"])
59 
60 
61 job.add([unzip, mom, rot, slic])
Convert LHE files to StdHep using EGS5.
Definition: generators.py:135
Add full truth mother particles for physics samples.
Definition: tools.py:742
Transform StdHep events into beam coordinates.
Definition: tools.py:516
Convert LHE files to StdHep, displacing the time by given ctau.
Definition: tools.py:695
Run the SLIC Geant4 simulation.
Definition: tools.py:15
Unzip the input files to outputs.
Definition: tools.py:1218
Tools that can be used in HPSMC jobs.
Definition: tools.py:1