5 from AthenaConfiguration.AccumulatorCache
import AccumulatorCache
6 from AthenaCommon
import Logging
7 rhlog = Logging.logging.getLogger(
'RHadronConfig')
14 if(mcChannelNumber == 449497 ):
15 mcChannelNumber = 421442
16 rhlog.info(
'MC channel number changed from 449497 to ',
str(mcChannelNumber))
18 cvmfs_mc16 =
'/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/'
20 JO = glob(cvmfs_mc16+
str(
int(mcChannelNumber/1000))+
'xxx/'+
str(mcChannelNumber)+
'/mc.'+
'*.py')
22 JO_path = cvmfs_mc16+
str(
int(mcChannelNumber/1000))+
'xxx/'+
str(mcChannelNumber)
24 os.environ[
"JOBOPTSEARCHPATH"] = JO_path +
":"+os.environ[
"JOBOPTSEARCHPATH"]
25 os.environ[
"DATAPATH"] = JO_path +
":"+os.environ[
"DATAPATH"]
30 JO = glob(
str(mcChannelNumber)+
'/mc.'+
'*.py')
35 JO = glob(
'*/mc.'+
str(mcChannelNumber)+
'*.py')
36 if len(JO)>0: JO=JO[0]
39 JO = glob(
'mc.'+
'*.py')
44 for adir
in os.environ[
'DATAPATH'].
split(
":"):
45 JO = glob(adir+
'/mc.'+
'*.py')
50 raise RuntimeError(
'Could not locate job options for DSID '+
str(mcChannelNumber))
56 cwd_path = os.getcwd()
58 cwd_sub = glob(cwd_path +
"/PROC*/Cards")
59 cwd_sub_str =
' '.
join(
str(e)+
":" for e
in cwd_sub)
60 os.environ[
"DATAPATH"] = cwd_sub_str +
":"+os.environ[
"DATAPATH"]
64 """Create a list of particles for custom particle creation"""
66 from RHadrons.RHadronMasses
import update_particle_table
69 if not os.path.isfile(
'particles.txt'):
70 raise RuntimeError(
'Failed to create particles.txt file - will abort')
74 """Add lines to the PDG table"""
76 from ExtraParticles.PDGHelpers
import getPDGTABLE
79 from RHadrons.RHadronMasses
import update_PDG_table
84 """Add lines to the physics configuration"""
86 os.system(
'touch PhysicsConfiguration.txt')
87 newphysconfig =
"{key} = {value}".
format(key=KEY, value=VALUE)
88 os.system(
'echo "%s" >> PhysicsConfiguration.txt' % newphysconfig)
93 """ Load all the files needed for a given scenario"""
95 if not os.path.isfile(input_param_card):
96 raise RuntimeError(
'input_param_card file is missing - will abort')
101 from RHadrons.RHadronMasses
import get_interaction_list
102 get_interaction_list(input_param_card, interaction_file=
'ProcessList.txt', mass_spectrum=spectrum)
104 if os.path.isfile(
'PhysicsConfiguration.txt'):
105 rhlog.warning(
"load_files_for_rhadrons_scenario() Found pre-existing PhysicsConfiguration.txt file - deleting.")
106 os.remove(
'PhysicsConfiguration.txt')
111 runArgs = RunArguments()
114 runArgs.jobConfig = [JO.split(
'/')[-2]
if '/' in JO
else JO]
115 runArgs.runNumber = flags.Input.MCChannelNumber
116 runArgs.ecmEnergy = 13000.
117 runArgs.randomSeed = 1234
118 runArgs.generatorJobNumber = 0
128 MadGraph_param_blocks = {}
129 decoupled_mass =
'4.5E9'
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
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',
153 MadGraph_syst_mod =
None
156 MadGraph_param_card =
None
159 MadGraph_run_settings = {
'event_norm':
'average',
167 MadGraph_writeGridpack =
False
172 keepMadGraphOutput =
False
175 fixEventWeightsForBridgeMode=
False
178 MadGraph_add_lifetimes_lhe =
True
181 MadGraph_usePMGSettings =
True
184 customMadGraphPlugin =
None
194 force_nobmass_5FS =
True
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
203 from MadGraphControl.MadGraphUtilsHelpers
import 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',
'.') )
211 masses[
'1000006'] =
float(infoStrings[4])
212 masses[
'1000005'] = 3.00000000E+05
213 masses[
'1000022'] = 100000.
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 )
227 if len(infoStrings)>7:
228 gluinoBallProbabilityString =
str(infoStrings[7])
230 gluinoBallProbabilityString =
"gball10"
232 gluinoBallProbability =
float(gluinoBallProbabilityString.replace(
"gball",
""))/100.
233 rhlog.info(
" gluino-ball probability: %f ", gluinoBallProbability )
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
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
254 rhlog.info(
'Registered generation of stop pair production to b+mu; grid point '+
str(runArgs.generatorJobNumber))
256 MadGraph_run_settings.update({
'time_of_flight':
'1E-2',
'event_norm':
'sum'})
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')
264 nevts = flags.Exec.MaxEvents * 2.
266 MadGraph_run_settings.update({
'nevents':
int(nevts)})
269 if ktdurham
is not None:
270 MadGraph_run_settings.update({
'ktdurham':ktdurham})
272 if flavourScheme
not in [4,5]:
273 raise RuntimeError(
'flavourScheme must be 4 or 5.')
275 if flavourScheme == 4:
276 MadGraph_run_settings.update({
277 'pdgs_for_merging_cut':
'1, 2, 3, 4, 21'
279 _nQuarksMerge = 5
if finalStateB
else 4
281 MadGraph_run_settings.update({
282 'pdgs_for_merging_cut':
'1, 2, 3, 4, 5, 21',
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
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')
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]
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
323 MadGraph_param_blocks[
'DECAY'] = decays
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,
340 rhlog.info(
"Calling SUSY_Generation")
349 modify_param_card(param_card_input=
'param_card.dat', params={
'MASS': masses,
'DECAY':decays}, output_location=
'SLHA_INPUT.DAT')
351 return ktdurham, MadGraph_process, _nQuarksMerge, gluinoBallProbability
357 Pythia8CommandList = [
360 "23:mWidth = 2.4952",
363 "StandardModel:sin2thetaW = 0.23113",
364 "StandardModel:sin2thetaWbar = 0.23146",
365 "ParticleDecays:limitTau0 = on",
366 "ParticleDecays:tau0Max = 10.0"]
368 Pythia8CommandList += [
371 "SpaceShower:rapidityOrder = on",
372 "SigmaProcess:alphaSvalue = 0.140",
373 "SpaceShower:pT0Ref = 1.56",
374 "SpaceShower:pTmaxFudge = 0.91",
375 "SpaceShower:pTdampFudge = 1.05",
376 "SpaceShower:alphaSvalue = 0.127",
377 "TimeShower:alphaSvalue = 0.127",
378 "BeamRemnants:primordialKThard = 1.88",
379 "MultipartonInteractions:pT0Ref = 2.09",
380 "MultipartonInteractions:alphaSvalue = 0.126",
381 "PDF:pSet=LHAPDF6:NNPDF23_lo_as_0130_qed",
382 "ColourReconnection:range = 1.71"
389 addRapidityOrderMPI =
True
390 rapidityOrderMPICommand = []
391 for cmd
in Pythia8CommandList:
392 if "SpaceShower:rapidityOrderMPI = " in cmd:
393 addRapidityOrderMPI =
False
394 if "SpaceShower:rapidityOrder" in cmd
and "SpaceShower:rapidityOrderMPI" not in cmd
and addRapidityOrderMPI:
395 val = cmd.split(
"=")[-1]
396 rapidityOrderMPICommand = [
"SpaceShower:rapidityOrderMPI = " + val]
397 if addRapidityOrderMPI
and len(rapidityOrderMPICommand) != 0:
398 Pythia8CommandList += rapidityOrderMPICommand
405 njets =
max([l.count(
'j')
for l
in MadGraph_process.split(
'\n')])
406 njets_min =
min([l.count(
'j')
for l
in MadGraph_process.split(
'\n')
if 'generate ' in l
or 'add process' in l])
407 if njets > 0
and njets != njets_min:
408 Pythia8CommandList += [
"Merging:mayRemoveDecayProducts = on",
409 "Merging:nJetMax = "+
str(njets),
410 "Merging:doKTMerging = on",
411 "Merging:TMS = "+
str(ktdurham),
412 "Merging:ktType = 1",
413 "Merging:Dparameter = 0.4",
414 "Merging:nQuarksMerge = {0:d}".
format(_nQuarksMerge)]
417 Pythia8CommandList += [
"Init:showChangedSettings = on"]
418 Pythia8CommandList += [
"Rhadrons:allow = on"]
419 Pythia8CommandList += [
"RHadrons:allowDecay = off"]
421 Pythia8CommandList += [
"RHadrons:probGluinoball = %f"%gluinoBallProbability]
422 Pythia8CommandList += [
"Next:showScaleAndVertex = on"]
423 Pythia8CommandList += [
"Check:nErrList = 2"]
427 Pythia8CommandList += [
"Merging:Process = pp>{t1,1000006}{t1~,-1000006}"]
429 simdict = flags.Input.SpecialConfiguration
431 spectrum = 1
if 'SPECTRUM' not in simdict
else simdict[
'SPECTRUM']
438 lifetime =
float(simdict[
'LIFETIME'])
if "LIFETIME" in simdict
else -1.
448 from RHadrons.RHadronMasses
import get_Pythia8_commands
450 f =
open(
'PYTHIA8_COMMANDS.TXT',
'w')
451 f.write(
'\n'.
join(Pythia8CommandList))