raise Exception("Missing '%s' input file." % tri_input) # get run params run_params = RunParameters(key=params.run_params) # calculate mu for tri sampling mu = func.mu(tri_input, run_params) # convert tri events to stdhep stdhep_tri = StdHepConverter(run_params=run_params, inputs=[tri_input], outputs=["tri.stdhep"]) # rotate tri events into beam coords rot_tri = StdHepTool(name="beam_coords", inputs=["tri.stdhep"], outputs=["tri_rot.stdhep"], args=["-z", str(params.z)]) # sample tris using poisson distribution sample_tri = StdHepTool(name="merge_poisson", inputs=["tri_rot.stdhep"], outputs=["tri_sampled"], args=["-m", str(mu), "-N", "1", "-n", "500000"]) # calculate mu for wab sampling mu = func.mu(wab_input, run_params) # convert wab events to stdhep stdhep_wab = StdHepConverter(run_params=run_params, inputs=[wab_input], outputs=["wab.stdhep"])
job = Job(name="beam job") job.set_default_params(def_params) job.initialize() # get params params = job.params # create component to rotate into beam coords for each input rotated_files = [] for i in job.input_files.keys(): fname = os.path.splitext(i)[0] + "_rot.stdhep" rotated_files.append(fname) rot = StdHepTool(name="beam_coords", inputs=[i], outputs=[fname]) # add beam parameters which may come from JSON or defaults rot.args.extend(["-x", str(params['beam_sigma_x']), "-y", str(params['beam_sigma_y']), "-z", str(params['target_z'])]) # need to check for this as it has no reasonable default if "beam_skew" in params: rot.args.extend(["-q", str(params.beam_skew)]) job.components.append(rot) # create component to sample each input to new output sampled_files = []
params={ "map": params.map, "mpid": params.mpid, "mrhod": params.mrhod }, outputs=[procname], nevents=params.nevents) # convert LHE output to stdhep stdhep_cnv = StdHepConverter(run_params=RunParameters(key=params.run_params), inputs=[procname + "_unweighted_events.lhe.gz"], outputs=[procname + ".stdhep"]) # rotate events into beam coords rot = StdHepTool(name="beam_coords", inputs=[procname + ".stdhep"], outputs=[procname + "_rot.stdhep"]) # print out rotated simp events dump = StdHepTool(name="print_stdhep", inputs=[procname + "_rot.stdhep"]) # generate events in slic slic = SLIC(detector=params.detector, inputs=[procname + "_rot.stdhep"], outputs=[procname + ".slcio"], nevents=params.nevents, ignore_returncode=True) # insert empty bunches expected by pile-up simulation filter_bunches = FilterMCBunches(java_args=["-DdisableSvtAlignmentConstants"], inputs=[procname + ".slcio"],
# base file name filename = "aprime" # generate A-prime events using Madgraph 4 ap = MG4(name="ap", run_card="run_card_" + params['run_params'] + ".dat", params={"APMASS": params['apmass']}, outputs=[filename], nevents=params['nevents']) # unzip the LHE events to local file unzip = Unzip(inputs=[filename + "_events.lhe.gz"]) # displace the time of decay using ctau param displ = StdHepTool(name="lhe_tridents_displacetime", inputs=[filename + "_events.lhe"], outputs=[filename + ".stdhep"], args=["-l", str(params['ctau'])]) # rotate events into beam coordinates and move vertex by 5 mm rot = StdHepTool(name="beam_coords", inputs=[filename + ".stdhep"], outputs=[filename + "_rot.stdhep"], args=["-z", str(params['z'])]) # print rotated AP events dump = StdHepTool(name="print_stdhep", inputs=[filename + "_rot.stdhep"]) # define job components job.components = [ap, unzip, displ, rot, dump] # move final StdHep file to user-defined output file name if output_files is set in JSON params
wab_input) # get run params run_params = RunParameters(key=params['run_params']) # calculate mu for wab sampling mu = func.mu(wab_input, run_params) # convert wab events to stdhep stdhep_cnv = StdHepConverter(run_params=run_params, inputs=[wab_input], outputs=["wab.stdhep"]) # rotate wab events into beam coords rot_wab = StdHepTool(name="beam_coords", inputs=["wab.stdhep"], outputs=["wab_rot.stdhep"], args=["-z", str(params['z'])]) # sample wabs using poisson distribution sample_wab = StdHepTool( name="merge_poisson", inputs=["wab_rot.stdhep"], outputs=["wab_sampled"], args=["-m", str(mu), "-N", "1", "-n", str(params['nevents'])]) # rotate beam background events into beam coordinates rot_beam = StdHepTool(name="beam_coords", inputs=["beam.stdhep"], outputs=["beam_rot.stdhep"], args=["-z", str(params['z'])])
procname = "tritrig" # generate tritrig in MG5 mg = MG5(name=procname, run_card="run_card_" + params.run_params + ".dat", outputs=[procname], nevents=params.nevents) # convert LHE output to stdhep stdhep_cnv = StdHepConverter(run_params=RunParameters(key=params.run_params), inputs=[procname + "_events.lhe.gz"], outputs=[procname + ".stdhep"]) # add mother particle to tag trident particles mom = StdHepTool(name="add_mother", inputs=[procname + ".stdhep"], outputs=[procname + "_mom.stdhep"]) # rotate events into beam coords rot = StdHepTool(name="beam_coords", inputs=[procname + "_mom.stdhep"], outputs=[procname + "_rot.stdhep"]) # generate events in slic slic = SLIC(detector=params.detector, inputs=[procname + "_rot.stdhep"], outputs=[procname + ".slcio"], nevents=params.nevents, ignore_returncode=True) # insert empty bunches expected by pile-up simulation
from hpsmc.generators import MG4, StdHepConverter from hpsmc.job import Job from hpsmc.run_params import RunParameters from hpsmc.tools import Unzip, StdHepTool ap = MG4(description="Generate A-prime events with APMASS param", name="ap", run_card="run_card_1pt05.dat", params={"APMASS": 40.0}, outputs=["ap"], rand_seed=1, nevents=500) unzip = Unzip(inputs=["ap_events.lhe.gz"]) rand_seed = 1 z = 1.0 displ = StdHepTool(name="lhe_tridents_displacetime", inputs=["ap_events.lhe"], outputs=["ap.stdhep"], args=["-s", str(rand_seed), "-l", str(z)]) dump = StdHepTool(name="print_stdhep", inputs=["ap.stdhep"]) job = Job(name="AP test", components=[ap, unzip, displ, dump]) job.params = {} job.run()