122def configureAndRunMadGraph(flags):
123
124 runArgs = buildRunArgs(flags)
125
126
127
128 MadGraph_param_blocks = {}
129 decoupled_mass = '4.5E9'
130 masses = {}
131 for p in ['1000001','1000002','1000003','1000004','1000005','1000006','2000001','2000002','2000003','2000004','2000005','2000006','1000021',\
132 '1000023','1000024','1000025','1000011','1000013','1000015','2000011','2000013','2000015','1000012','1000014','1000016','1000022',\
133 '1000035','1000037','35','36','37']:
134 masses[p]=decoupled_mass
135 decays = {}
136
137
138 squarks = []
139 squarksl = []
140 for anum in [1,2,3,4]:
141 squarks += [str(1000000+anum),str(-1000000-anum),str(2000000+anum),str(-2000000-anum)]
142 squarksl += [str(1000000+anum),str(-1000000-anum)]
143 dict_index_syst = {0:'scalefactup',
144 1:'scalefactdown',
145 2:'alpsfactup',
146 3:'alpsfactdown',
147 4:'moreFSR',
148 5:'lessFSR',
149 6:'qup',
150 7:'qdown'}
151
152
153 MadGraph_syst_mod = None
154 ktdurham = None
155 madspin_card = None
156 MadGraph_param_card = None
157
158
159 MadGraph_run_settings = {'event_norm':'average',
160 'drjj':0.0,
161 'lhe_version':'3.0',
162 'cut_decays':'F',
163 'ickkw':0,
164 'xqcut':0}
165
166
167 MadGraph_writeGridpack = False
168
169
170
171
172 keepMadGraphOutput = False
173
174
175 fixEventWeightsForBridgeMode=False
176
177
178 MadGraph_add_lifetimes_lhe = True
179
180
181 MadGraph_usePMGSettings = True
182
183
184 customMadGraphPlugin = None
185
186
187
188
189
190
191
192 flavourScheme = 5
193 define_pj_5FS = True
194 force_nobmass_5FS = True
195 finalStateB = False
196
197 """
198 This JO is long-lived stop RHadrons decaying to b+mu
199 Migrated from r19 JO: https://gitlab.cern.ch/atlas-physics/pmg/infrastructure/mc15joboptions/-/blob/master/common/MadGraph/MadGraphControl_SimplifiedModel_TT_RPVdirectBL_LongLived_RHadron.py
200 JIRA: https://its.cern.ch/jira/browse/ATLMCPROD-5979
201 """
202
203 from MCJobOptionUtils.JOsupport import get_physics_short
204 phys_short = get_physics_short()
205 infoStrings = phys_short.split("_")
206 rhlog.info( " jobConfig: %s ", phys_short[0] )
207 rhlog.info( " stop mass: %s ", infoStrings[4] )
208 rhlog.info(
" stop ctau: %s ", infoStrings[6].
replace(
'p',
'.') )
209
210
211 masses['1000006'] = float(infoStrings[4])
212 masses['1000005'] = 3.00000000E+05
213 masses['1000022'] = 100000.
214
215
216 lifetimeString = str(infoStrings[6])
217 stopLifetime = lifetimeString.replace(
"ns",
"").
replace(
".py",
"").
replace(
"p",
".")
218 hbar = 6.582119514e-16
219 stopWidth = hbar/float(stopLifetime)
220 rhlog.info( " stop lifetime, width: %f, %f ", float(stopLifetime), stopWidth )
221
222
223 flavourScheme = 4
224
225
226
227 if len(infoStrings)>7:
228 gluinoBallProbabilityString = str(infoStrings[7])
229 else:
230 gluinoBallProbabilityString = "gball10"
231
232 gluinoBallProbability = float(gluinoBallProbabilityString.replace("gball",""))/100.
233 rhlog.info( " gluino-ball probability: %f ", gluinoBallProbability )
234
235
236 decays['1000006'] = """DECAY 1000006 %s # stop1 decays
237 # BR NDA ID1 ID2 ID3 ID4
238 1.00000000000 2 -13 5 # stop1 to b mu
239 """%(stopWidth)
240
241
242
243 MadGraph_process = '''
244 import model MSSM_SLHA2-full
245 define susylq = ul ur dl dr cl cr sl sr
246 define susylq~ = ul~ ur~ dl~ dr~ cl~ cr~ sl~ sr~
247 generate p p > t1 t1~ $ go susylq susylq~ b2 t1 t2 b2~ t1~ t2~ @1
248 add process p p > t1 t1~ j $ go susylq susylq~ b2 t1 t2 b2~ t1~ t2~ @2
249 add process p p > t1 t1~ j j $ go susylq susylq~ b2 t1 t2 b2~ t1~ t2~ @3
250 output -f
251 '''
252
253
254 rhlog.info('Registered generation of stop pair production to b+mu; grid point '+str(runArgs.generatorJobNumber))
255
256 MadGraph_run_settings.update({'time_of_flight':'1E-2', 'event_norm':'sum'})
257
258
259 if 'rpv' in phys_short.lower() and 'import ' not in MadGraph_process:
260 raise RuntimeError('Please import a model when using an RPV decay; these are not handled by the standard MSSM model in MadGraph')
261
262
263
264 nevts = flags.Exec.MaxEvents * 2.
265
266 MadGraph_run_settings.update({'nevents':int(nevts)})
267
268
269 if ktdurham is not None:
270 MadGraph_run_settings.update({'ktdurham':ktdurham})
271
272 if flavourScheme not in [4,5]:
273 raise RuntimeError('flavourScheme must be 4 or 5.')
274
275 if flavourScheme == 4:
276 MadGraph_run_settings.update({
277 'pdgs_for_merging_cut': '1, 2, 3, 4, 21'
278 })
279 _nQuarksMerge = 5 if finalStateB else 4
280 else:
281 MadGraph_run_settings.update({
282 'pdgs_for_merging_cut': '1, 2, 3, 4, 5, 21',
283 'asrwgtflavor': 5,
284 'maxjetflavor': 5
285 })
286 _nQuarksMerge = 5
287 if define_pj_5FS:
288
289 MadGraph_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" + MadGraph_process
290
291 for l in MadGraph_process.split('\n'):
292 l_nocomment = l.split('#')[0]
293 if ("define p" in l_nocomment or "define j" in l_nocomment) and l_nocomment.count("=") == 1:
294 l_equals = (l_nocomment.split(
"=")[-1]).
split(
" ")
295 if not set([
'g',
'u',
'c',
'd',
's',
'b',
'u~',
'c~',
'd~',
's~',
'b~']) <=
set(l_equals):
296 raise RuntimeError('Invalid definition found for p or j in MadGraph_process string while using 5FS')
297 if force_nobmass_5FS:
298 if masses.get('5',0.0) != 0.0:
299 raise RuntimeError('Non-zero mass found for b while using 5FS')
300 masses['5'] = 0.0
301
302
303 if 'scup' in phys_short:
304 MadGraph_syst_mod=dict_index_syst[0]
305 elif 'scdw' in phys_short:
306 MadGraph_syst_mod=dict_index_syst[1]
307 elif 'alup' in phys_short:
308 MadGraph_syst_mod=dict_index_syst[2]
309 elif 'aldw' in phys_short:
310 MadGraph_syst_mod=dict_index_syst[3]
311 elif 'qcup' in phys_short:
312 MadGraph_syst_mod=dict_index_syst[6]
313 elif 'qcdw' in phys_short:
314 MadGraph_syst_mod=dict_index_syst[7]
315
316
317 if 'mass' in [x.lower() for x in MadGraph_param_blocks]:
318 raise RuntimeError('Do not provide masses in MadGraph_param_blocks; use the masses variable instead')
319 MadGraph_param_blocks['MASS'] = masses
320
321
322 if len(decays)>0:
323 MadGraph_param_blocks['DECAY'] = decays
324
325 argdict = {'runArgs' : runArgs,
326 'process' : MadGraph_process,
327 'params' : MadGraph_param_blocks,
328 'fixEventWeightsForBridgeMode': fixEventWeightsForBridgeMode,
329 'madspin_card' : madspin_card,
330 'keepOutput' : keepMadGraphOutput,
331 'run_settings' : MadGraph_run_settings,
332 'writeGridpack' : MadGraph_writeGridpack,
333 'syst_mod' : MadGraph_syst_mod,
334 'param_card' : MadGraph_param_card,
335 'add_lifetimes_lhe' : MadGraph_add_lifetimes_lhe,
336 'usePMGSettings' : MadGraph_usePMGSettings,
337 'plugin' : customMadGraphPlugin,
338 }
339
340 rhlog.info("Calling SUSY_Generation")
341
342 from MadGraphControl.SUSY_Helpers import SUSY_Generation
343 ktdurham = SUSY_Generation(**argdict)
344
345 addProcessCardsToDATAPATH()
346
347
349 modify_param_card(param_card_input='param_card.dat', params={'MASS': masses,'DECAY':decays}, output_location='SLHA_INPUT.DAT')
350
351 return ktdurham, MadGraph_process, _nQuarksMerge, gluinoBallProbability
352
353
std::string replace(std::string s, const std::string &s2, const std::string &s3)
std::vector< std::string > split(const std::string &s, const std::string &t=":")