7from MadGraphControl.MadGraphUtils import (generate, generate_from_gridpack,my_MGC_instance, add_lifetimes, arrange_output, MADGRAPH_GRIDPACK_LOCATION,is_gen_from_gridpack, new_process )
54def get_SUSY_variations( process: str, masses: dict[str, str | float], syst_mod: str |
None =
None, ktdurham: str |
None =
None ) -> float:
56 Provides varied matching scales for SUSY event generation based on inputs
58 process: the process to be generated (e.g. p p > go go). Used to figure
59 out which particles are relevant for the matching scale
60 masses: the dictionary of PDGID to mass mapping, used to figure out the
62 syst_mod: the requested systematic variation (if any); can be msup,
64 ktdurham: the matching scale in case the user provides it by hand
71 if process
is not None:
72 id_map = {
'go':
'1000021',
'dl':
'1000001',
'ul':
'1000002',
'sl':
'1000003',
'cl':
'1000004',
'b1':
'1000005',
't1':
'1000006',
73 'dr':
'2000001',
'ur':
'2000002',
'sr':
'2000003',
'cr':
'2000004',
'b2':
'2000005',
't2':
'2000006',
74 'n1':
'1000022',
'n2':
'1000023',
'x1':
'1000024',
'x2':
'1000037',
'n3':
'1000025',
'n4':
'1000035',
75 'el':
'1000011',
'mul':
'1000013',
'ta1':
'1000015',
'sve':
'1000012',
'svm':
'1000014',
'svt':
'1000016',
76 'er':
'2000011',
'mur':
'2000013',
'ta2':
'2000015'}
78 if 'generate' in l
or 'add process' in l:
80 for particle
in clean_proc.split():
81 if particle
not in id_map:
82 susylog.info(f
'Particle {particle} not found in PDG ID map - skipping')
84 prod_particles += id_map[particle]
88 if len(prod_particles)>0:
89 for x
in prod_particles:
91 my_mass =
min(my_mass,abs(float(masses[x])))
93 susylog.info(f
'Seem to ask for production of PDG ID {x}, but {x} not in mass dictionary?')
95 strong_ids = [
'1000001',
'1000002',
'1000003',
'1000004',
'1000005',
'1000006',
'2000001',
'2000002',
'2000003',
'2000004',
'2000005',
'2000006',
'1000021']
96 weak_ids = [
'1000023',
'1000024',
'1000025',
'1000011',
'1000013',
'1000015',
'2000011',
'2000013',
'2000015',
'1000012',
'1000014',
'1000016']
98 my_mass =
min([abs(float(masses[x]))
for x
in strong_ids
if x
in masses])
102 my_mass =
max([abs(float(masses[x]))
for x
in weak_ids
if x
in masses
and float(masses[x])<10000.])
104 if my_mass>10000.
and '1000022' in masses:
105 my_mass = masses[
'1000022']
107 raise RuntimeError(
'Could not understand which mass to use for matching cut in '+str(masses))
110 ktdurham =
min(my_mass*0.25,500)
112 ktdurham =
max(ktdurham,15)
113 if syst_mod ==
'msup':
114 susylog.info(
'Applying upward variation (by 2x) of matching scale')
115 ktdurham = ktdurham*2.
116 elif syst_mod ==
'msdw':
117 susylog.info(
'Applying downward variation (by 2x) of matching scale')
118 ktdurham = ktdurham*0.5
120 susylog.info(
'For matching, will use ktdurham of '+str(ktdurham))
161def SUSY_Generation(runArgs: RunArguments |
None =
None, process: str |
None =
None, plugin: str |
None =
None,\
162 syst_mod: str |
None =
None, keepOutput: bool =
False, param_card: str |
None =
None,\
163 writeGridpack: bool =
False, madspin_card: str |
None =
None, run_settings: dict = {},
164 params: dict = {}, fixEventWeightsForBridgeMode: bool =
False,\
165 add_lifetimes_lhe: bool =
False, usePMGSettings: bool =
True) -> float:
168 Helper function for SUSY event generation, used in simplified model setups. Attempts to
169 simplify and harmonize a bunch of the things that normally have to be done by hand.
171 runArgs: passed from the job transform, includes random number seed, ecm energy, and setting for output files
172 process: simplified process definition for event generation
173 plugin: in case a MG5_aMC plugin is requested for event generation
174 syst_mod: requested systematic variation of parameter settings
175 keepOutput: retains the process directory created by MG5_aMC. Should always be false in production
176 param_card: In case an explicit parameter card is needed (e.g. for pMSSM), can be set this way
177 writeGridpack: used to construct gridpacks
178 madspin_card: used for MadSpin definitions
179 run_settings: any additional run card settings required (e.g. cuts on particle momenta). Dictionary to be
180 passed into modify_run_card(...)
181 params: any additional param card settings. Dictionary to be passed into modify_param_card(...)
182 fixEventWeightsForBridgeMode: In case Bridge mode is being used, this applies a fix to the event weights
183 add_lifetimes_lhe: if fundamental particles written to the LHE have a lifetime (e.g. sleptons or charginos), this
184 allows the inclusion of their time of flight lifetime in the LHE file directly
185 usePMGSettings (bool): See :py:func:`new_process`. Will set SM parameters to the appropriate values. Default: True.
187 the setting of the matching scale to be provided to Pythia8
190 global my_MGC_instance
191 ktdurham = run_settings[
'ktdurham']
if 'ktdurham' in run_settings
else None
194 process_dir = MADGRAPH_GRIDPACK_LOCATION
195 if not is_gen_from_gridpack():
197 process_dir = new_process(full_proc, plugin=plugin, usePMGSettings=usePMGSettings)
198 susylog.info(
'Using process directory '+str(process_dir))
201 my_MGC_instance.paramCard.modify_paramCardDict(params=params)
204 settings = {
'ktdurham':ktdurham}
205 settings.update(run_settings)
208 my_MGC_instance.runCardDict.update(settings)
211 if madspin_card
is not None:
212 if not os.access(madspin_card,os.R_OK):
213 raise RuntimeError(
'Could not locate madspin card at '+str(madspin_card))
214 shutil.copy(madspin_card,process_dir+
'/Cards/madspin_card.dat')
217 if is_gen_from_gridpack():
218 generate_from_gridpack(runArgs=runArgs)
221 generate(runArgs=runArgs,process_dir=process_dir,grid_pack=writeGridpack)
224 if add_lifetimes_lhe :
225 susylog.info(
'Requested addition of lifetimes to LHE files: doing so now.')
226 if is_gen_from_gridpack():
229 add_lifetimes(process_dir=process_dir)
232 arrange_output(process_dir=process_dir,saveProcDir=keepOutput,runArgs=runArgs,fixEventWeightsForBridgeMode=fixEventWeightsForBridgeMode)
234 susylog.info(
'All done generating events!!')
235 return settings[
'ktdurham']
float SUSY_Generation(RunArguments|None runArgs=None, str|None process=None, str|None plugin=None, str|None syst_mod=None, bool keepOutput=False, str|None param_card=None, bool writeGridpack=False, str|None madspin_card=None, dict run_settings={}, dict params={}, bool fixEventWeightsForBridgeMode=False, bool add_lifetimes_lhe=False, bool usePMGSettings=True)