3 from MadGraphControl.MadGraphUtilsHelpers
import get_physics_short
7 if 'rpv' in phys_short.lower()
and not 'import ' in process:
8 raise RuntimeError(
'Please import a model when using an RPV decay; these are not handled by the standard MSSM model in MadGraph')
12 if runArgs.maxEvents>0:
13 nevts=runArgs.maxEvents*evt_multiplier
15 nevts=evgenConfig.nEventsPerJob*evt_multiplier
18 nevts=evgenConfig.nEventsPerJob*2.
19 run_settings.update({
'nevents':
int(nevts)})
22 if ktdurham
is not None:
23 run_settings.update({
'ktdurham':ktdurham})
25 if flavourScheme
not in [4,5]:
26 raise RuntimeError(
'flavourScheme must be 4 or 5.')
28 if flavourScheme == 4:
30 'pdgs_for_merging_cut':
'1, 2, 3, 4, 21'
32 _nQuarksMerge = 5
if finalStateB
else 4
35 'pdgs_for_merging_cut':
'1, 2, 3, 4, 5, 21',
42 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
44 for l
in process.split(
'\n'):
45 l_nocomment = l.split(
'#')[0]
46 if (
"define p" in l_nocomment
or "define j" in l_nocomment)
and l_nocomment.count(
"=") == 1:
47 l_equals = (l_nocomment.split(
"=")[-1]).
split(
" ")
48 if not set([
'g',
'u',
'c',
'd',
's',
'b',
'u~',
'c~',
'd~',
's~',
'b~']) <=
set(l_equals):
49 raise RuntimeError(
'Invalid definition found for p or j in process string while using 5FS')
51 if masses.get(
'5',0.0) != 0.0:
52 raise RuntimeError(
'Non-zero mass found for b while using 5FS')
56 if 'scup' in phys_short:
57 syst_mod=dict_index_syst[0]
58 elif 'scdw' in phys_short:
59 syst_mod=dict_index_syst[1]
60 elif 'alup' in phys_short:
61 syst_mod=dict_index_syst[2]
62 elif 'aldw' in phys_short:
63 syst_mod=dict_index_syst[3]
64 elif 'qcup' in phys_short:
65 syst_mod=dict_index_syst[6]
66 elif 'qcdw' in phys_short:
67 syst_mod=dict_index_syst[7]
70 if 'mass' in [x.lower()
for x
in param_blocks]:
71 raise RuntimeError(
'Do not provide masses in param_blocks; use the masses variable instead')
72 param_blocks[
'MASS']=masses
74 if len(decays)>0: param_blocks[
'DECAY']=decays
75 argdict = {
'runArgs' : runArgs,
77 'params' : param_blocks,
78 'fixEventWeightsForBridgeMode': fixEventWeightsForBridgeMode,
79 'madspin_card' : madspin_card,
80 'keepOutput' : keepOutput,
81 'run_settings' : run_settings,
82 'writeGridpack' : writeGridpack,
83 'syst_mod' : syst_mod,
84 'param_card' : param_card,
85 'add_lifetimes_lhe' : add_lifetimes_lhe,
86 'usePMGSettings' : usePMGSettings,
91 if not hasattr(runArgs,
'inputGeneratorFile')
or runArgs.inputGeneratorFile
is None:
100 param_card_old = process_dir+
'/Cards/param_card.dat'
103 if tarfile.is_tarfile(runArgs.inputGeneratorFile):
104 myTarball = tarfile.open(runArgs.inputGeneratorFile)
106 for afile
in myTarball.getnames():
107 if afile.endswith(
'.events'): myEvents = afile
109 raise RuntimeError(
'No input events file found!')
111 events_file = myTarball.extractfile( myEvents )
112 update_lhe_file(lhe_file_old=myEvents,param_card_old=param_card_old,masses=masses)
113 for aline
in events_file:
115 if b
'ktdurham' in aline
and b
'=' in aline:
116 ktdurham =
float(aline.split(b
'=')[0].strip())
121 update_lhe_file(lhe_file_old=runArgs.inputGeneratorFile,param_card_old=param_card_old,masses=masses)
122 with open(runArgs.inputGeneratorFile,
'r')
as events_file:
123 for aline
in events_file:
124 if 'ktdurham' in aline
and "=" in aline:
125 ktdurham =
float(aline.split(
'=')[0].strip())
128 if madspin_card
is not None:
131 arrange_output(process_dir=process_dir,saveProcDir=keepOutput,runArgs=runArgs,fixEventWeightsForBridgeMode=fixEventWeightsForBridgeMode)
137 njets=
max([l.count(
'j')
for l
in process.split(
'\n')])
138 njets_min=
min([l.count(
'j')
for l
in process.split(
'\n')
if 'generate ' in l
or 'add process' in l])
139 if njets>0
and njets!=njets_min
and hasattr(genSeq,
'Pythia8'):
140 genSeq.Pythia8.Commands += [
"Merging:mayRemoveDecayProducts = on",
141 "Merging:nJetMax = "+
str(njets),
142 "Merging:doKTMerging = on",
143 "Merging:TMS = "+
str(ktdurham),
144 "Merging:ktType = 1",
145 "Merging:Dparameter = 0.4",
146 "Merging:nQuarksMerge = {0:d}".
format(_nQuarksMerge)]
150 evgenConfig.keywords += [
"SUSY"]