HPS-MC
ap_gen_to_slic_job.py
Go to the documentation of this file.
1 """!
2 @file ap_gen_to_slic_job.py
3 
4 Job script to generate A-prime events, convert to StdHep, apply transformations,
5 and resulting simulate signal events using SLIC.
6 
7 There are options to generate prompt and displaced events.
8 You can use them by adjusting the StdHepConverter options as seen below.
9 """
10 
11 from hpsmc.generators import MG4, StdHepConverter
12 from hpsmc.tools import DisplaceUni, Unzip, BeamCoords, AddMotherFullTruth, SLIC
13 
14 job.description = 'ap from generation to slic'
15 
16 
17 inputs = list(job.input_files.values())
18 
19 if 'nevents' in job.params:
20  nevents = job.params['nevents']
21 else:
22  nevents = 10000
23 
24 # if 'ap_decay_dist' in job.params:
25 # ap_decay_dist = job.params['ap_decay_dist']
26 # else:
27 # ap_decay_dist = "lhe_uniform"
28 
29 
30 mg = MG4(name='ap', event_types=['unweighted'])
31 
32 if 'ap_decay_dist' in job.params:
33  ap_decay_dist = job.params['ap_decay_dist']
34 else:
35  ap_decay_dist = "lhe_uniform"
36 
37 
38 unzip = Unzip(inputs=["ap_unweighted_events.lhe.gz"], outputs=["ap_unweighted_events.lhe"])
39 
40 if ap_decay_dist == "lhe_uniform":
41 
42  cnv = StdHepConverter(name="lhe_uniform", inputs=["ap_unweighted_events.lhe"])
43 elif ap_decay_dist == "lhe_prompt":
44 
45  cnv = StdHepConverter(name="lhe_prompt", inputs=["ap_unweighted_events.lhe"])
46 elif ap_decay_dist == "displace_time":
47  if 'ctau' in job.params:
48 
49  cnv = DisplaceUni(inputs=["ap_unweighted_events.lhe"])
50  else:
51  logger.error("Missing parameter ctau")
52 else:
53  logger.error("Invalid ap decay distribution: ap_decay_dist = %s" % ap_decay_dist)
54 
55 
56 mom = AddMotherFullTruth(inputs=["ap_unweighted_events.stdhep", unzip.output_files()[0]], outputs=["ap_mom.stdhep"])
57 
58 
59 rot = BeamCoords(inputs=mom.output_files(), outputs=["ap_rot.stdhep"])
60 
61 
62 slic = SLIC(nevents=nevents + 1, inputs=rot.output_files(), outputs=["ap.slcio"])
63 
64 
65 job.add([mg, unzip, cnv, mom, rot, slic])
Run the MadGraph 4 event generator.
Definition: generators.py:329
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