3from MadGraphControl.SUSY_Helpers
import SUSY_Generation
4from MCJobOptionUtils.JOsupport
import get_physics_short,check_reset_proc_number
6phys_short = get_physics_short()
8if 'rpv' in phys_short.lower()
and not 'import ' in process:
9 raise RuntimeError(
'Please import a model when using an RPV decay; these are not handled by the standard MSSM model in MadGraph')
13 if runArgs.maxEvents>0:
14 nevts=runArgs.maxEvents*evt_multiplier
16 nevts=evgenConfig.nEventsPerJob*evt_multiplier
19 nevts=evgenConfig.nEventsPerJob*2.
20run_settings.update({
'nevents':int(nevts)})
23if ktdurham
is not None:
24 run_settings.update({
'ktdurham':ktdurham})
26if flavourScheme
not in [4,5]:
27 raise RuntimeError(
'flavourScheme must be 4 or 5.')
34 'pdgs_for_merging_cut':
'1, 2, 3, 4, 21'
36 PYTHIA8_nQuarksMerge = 5
if finalStateB
else 4
39 'pdgs_for_merging_cut':
'1, 2, 3, 4, 5, 21',
43 PYTHIA8_nQuarksMerge = 5
46 process =
"define p = g u c d s b u~ c~ d~ s~ b~\ndefine j = g u c d s b u~ c~ d~ s~ b~\n" + process
48 for l
in process.split(
'\n'):
49 l_nocomment = l.split(
'#')[0]
50 if (
"define p" in l_nocomment
or "define j" in l_nocomment)
and l_nocomment.count(
"=") == 1:
51 l_equals = (l_nocomment.split(
"=")[-1]).
split(
" ")
52 if not set([
'g',
'u',
'c',
'd',
's',
'b',
'u~',
'c~',
'd~',
's~',
'b~']) <=
set(l_equals):
53 raise RuntimeError(
'Invalid definition found for p or j in process string while using 5FS')
55 if masses.get(
'5',0.0) != 0.0:
56 raise RuntimeError(
'Non-zero mass found for b while using 5FS')
60if '_msup' in phys_short:
62elif '_msdw' in phys_short:
64if syst_mod
not in [
'msup',
'msdw',
None]:
65 raise RuntimeError(f
'Systematic variation {syst_mod=} unknown; allowed values are "msup" or "msdw" for matching scale up/down variations')
68if 'mass' in [x.lower()
for x
in param_blocks]:
69 raise RuntimeError(
'Do not provide masses in param_blocks; use the masses variable instead')
70param_blocks[
'MASS']=masses
72if len(decays)>0: param_blocks[
'DECAY']=decays
73argdict = {
'runArgs' : runArgs,
75 'params' : param_blocks,
76 'fixEventWeightsForBridgeMode': fixEventWeightsForBridgeMode,
77 'madspin_card' : madspin_card,
78 'keepOutput' : keepOutput,
79 'run_settings' : run_settings,
80 'writeGridpack' : writeGridpack,
81 'syst_mod' : syst_mod,
82 'param_card' : param_card,
83 'add_lifetimes_lhe' : add_lifetimes_lhe,
84 'usePMGSettings' : usePMGSettings,
89if not hasattr(runArgs,
'inputGeneratorFile')
or runArgs.inputGeneratorFile
is None:
91 ktdurham = SUSY_Generation(**argdict)
96 from MadGraphControl.SUSY_Helpers
import SUSY_process
97 process_dir = new_process(SUSY_process(
'generate p p > go go'))
98 modify_param_card(process_dir=process_dir,params={
'MASS':masses,
'DECAY':decays})
99 param_card_old = process_dir+
'/Cards/param_card.dat'
102 if tarfile.is_tarfile(runArgs.inputGeneratorFile):
103 myTarball = tarfile.open(runArgs.inputGeneratorFile)
105 for afile
in myTarball.getnames():
106 if afile.endswith(
'.events'): myEvents = afile
108 raise RuntimeError(
'No input events file found!')
110 events_file = myTarball.extractfile( myEvents )
111 update_lhe_file(lhe_file_old=myEvents,param_card_old=param_card_old,masses=masses)
112 for aline
in events_file:
114 if b
'ktdurham' in aline
and b
'=' in aline:
115 ktdurham = float(aline.split(b
'=')[0].
strip())
120 update_lhe_file(lhe_file_old=runArgs.inputGeneratorFile,param_card_old=param_card_old,masses=masses)
121 with open(runArgs.inputGeneratorFile,
'r')
as events_file:
122 for aline
in events_file:
123 if 'ktdurham' in aline
and "=" in aline:
124 ktdurham = float(aline.split(
'=')[0].
strip())
127 if madspin_card
is not None:
129 add_madspin(madspin_card,process_dir=process_dir)
130 arrange_output(process_dir=process_dir,saveProcDir=keepOutput,runArgs=runArgs,fixEventWeightsForBridgeMode=fixEventWeightsForBridgeMode)
133check_reset_proc_number(opts)
136PYTHIA8_nJetMax=
max([l.count(
'j')
for l
in process.split(
'\n')])
137njets_min=
min([l.count(
'j')
for l
in process.split(
'\n')
if 'generate ' in l
or 'add process' in l])
138if PYTHIA8_nJetMax>0
and PYTHIA8_nJetMax!=njets_min
and hasattr(genSeq,
'Pythia8'):
140 PYTHIA8_TMS = ktdurham
141 PYTHIA8_Dparameter = 0.4
143 if 'PYTHIA8_Process' not in dir():
144 for acommand
in genSeq.Pythia8.Commands:
145 if acommand.startswith(
'Merging:Process'):
146 PYTHIA8_Process = acommand.split(
'=')[1].
strip()
150 PYTHIA8_Process =
'guess'
153 include(
'Pythia8_i/Pythia8_CKKWL_kTMerge.py')
155 genSeq.Pythia8.Commands += [
"Merging:mayRemoveDecayProducts = on"]
159evgenConfig.keywords += [
"SUSY"]
std::vector< std::string > split(const std::string &s, const std::string &t=":")