ATLAS Offline Software
Functions | Variables
setupEFT Namespace Reference

Functions

def parse_SMEFT_JO (physics_short, processes)
 
def setup_SMEFT_from_JOname (processes)
 
def setup_SMEFT (process, model_nick, param_name, reweight_name, eft_params)
 

Variables

string mgmodels = '/cvmfs/atlas.cern.ch/repo/sw/Generators/madgraph/models/latest/'
 

Function Documentation

◆ parse_SMEFT_JO()

def setupEFT.parse_SMEFT_JO (   physics_short,
  processes 
)

Definition at line 6 of file setupEFT.py.

6 def parse_SMEFT_JO(physics_short,processes):
7 
8  # check if reweighting required
9  reweight_name=None
10  for s in physics_short.split('_'):
11  if 'rwgt' in s:
12  reweight_name=s.replace('rwgt','')
13  physics_short=physics_short.replace('_'+s,'')
14  break
15 
16  # check if custom param card needed
17  param_name=None
18  for s in physics_short.split('_'):
19  if 'param' in s:
20  param_name=s.replace('param','')
21  physics_short=physics_short.replace('_'+s,'')
22  break
23 
24  if reweight_name!=None and param_name!=None:
25  raise RuntimeError("Can only do either reweighting or use a specific param card")
26 
27  # find list of non-zero parameters (if not doing reweighting or getting parameters from param card)
28  eft_params=None
29  if reweight_name==None and param_name==None:
30  params_re=r"_(?P<param>[A-Za-z0-9]+)_(?P<value>[-+]?\d+p?\d*)"
31  eft_params_list=re.findall(params_re,physics_short)
32  eft_params={}
33  for e in eft_params_list:
34  eft_params[e[0]]=e[1].replace('p','.')
35  physics_short=re.sub(params_re,"",physics_short)
36 
37  # the last three blocks in name, except for reweight and eft parameters
38  # TODO: update to be more robust and allow e.g. for filters in the name
39  jobconfig_tokens=physics_short.split('_')
40  print jobconfig_tokens
41  model_token=jobconfig_tokens[-3]
42  process_token=jobconfig_tokens[-2]
43  eft_order_token=jobconfig_tokens[-1]
44 
45  # determine process (and EFT order)
46  eft_order=eft_order_token.replace('SQ','^2').replace('lq','<=').replace('eq','==')
47  # add space between number and letter
48  for x in re.findall(r"\d[A-Za-z]",eft_order):
49  eft_order.replace(x,x[0]+' '+x[1])
50 
51  if not process_token in processes:
52  raise RuntimeError("Unkown process "+process_token)
53  elif not "EFTORDER" in processes[process_token]:
54  raise RuntimeError("No EFTORDER in process")
55  else:
56  process=processes[process_token].replace("EFTORDER",eft_order)
57 
58  return model_token,process,param_name,reweight_name,eft_params
59 
60 # build proc, param, and reweight card from 4 last blocks of job config name and 'processes' dict

◆ setup_SMEFT()

def setupEFT.setup_SMEFT (   process,
  model_nick,
  param_name,
  reweight_name,
  eft_params 
)

Definition at line 66 of file setupEFT.py.

66 def setup_SMEFT(process,model_nick,param_name,reweight_name,eft_params):
67 
68  if model_nick=="EFTAaUm":
69  model="SMEFTsim_A_U35_alphaScheme_UFO"
70  eft_parameter_block='frblock'
71  restriction=None
72  sm_restriction='SMlimit'
73  elif model_nick=="EFTAWUm":
74  model="SMEFTsim_A_U35_MwScheme_UFO"
75  eft_parameter_block='frblock'
76  restriction=None
77  sm_restriction='SMlimit'
78  elif model_nick=="EFTBaUm":
79  model="SMEFT_alpha_FLU_UFO"
80  eft_parameter_block='NEWCOUP'
81  restriction=None
82  sm_restriction='SM'
83  elif model_nick=="EFTBWUm":
84  model="SMEFT_mW_FLU_UFO"
85  eft_parameter_block='NEWCOUP'
86  restriction=None
87  sm_restriction='SM'
88  elif model_nick=="EFTAaU":
89  model="SMEFTsim_A_U35_alphaScheme_UFO"
90  eft_parameter_block='frblock'
91  restriction='massless'
92  sm_restriction='SMlimit_massless'
93  elif model_nick=="EFTAWU":
94  model="SMEFTsim_A_U35_MwScheme_UFO"
95  eft_parameter_block='frblock'
96  restriction='massless'
97  sm_restriction='SMlimit_massless'
98 
99  else:
100  raise RuntimeError("Unkown model: "+model_nick)
101 
102  # get reweight card and param card for reweighting
103  reweight_card_loc=None
104  if reweight_name!=None:
105  param_card_loc='MadGraph_param_card_'+model_nick+'_reweight'+reweight_name+'.dat'
106  restrict_card_loc='MadGraph_restrict_card_'+model_nick+'_reweight'+reweight_name+'.dat'
107  reweight_card_loc='MadGraph_reweight_card_'+model_nick+'_'+reweight_name+'.dat'
108  get_param_file = subprocess.Popen(['get_files','-data', param_card_loc])
109  get_param_file.wait()
110  if not os.path.exists(param_card_loc):
111  raise RuntimeError("Cannot find "+param_card_loc)
112  get_restrict_file = subprocess.Popen(['get_files','-data', restrict_card_loc])
113  get_restrict_file.wait()
114  if not os.path.exists(restrict_card_loc):
115  print 'running without user defined restriction card'
116  restrict_card_loc=None
117  get_reweight_file = subprocess.Popen(['get_files','-data', reweight_card_loc])
118  get_reweight_file.wait()
119  if not os.path.exists(reweight_card_loc):
120  raise RuntimeError("Cannot find "+reweight_card_loc)
121  eft_params=None
122 
123  # get param card and set non-zero parameters
124  elif param_name!=None:
125  param_card_loc='MadGraph_param_card_'+model_nick+'_'+param_name+'.dat'
126  restrict_card_loc='MadGraph_restrict_card_'+model_nick+'_'+param_name+'.dat'
127  get_param_file = subprocess.Popen(['get_files','-data', param_card_loc])
128  get_param_file.wait()
129  if not os.path.exists(param_card_loc):
130  raise RuntimeError("Cannot find "+param_card_loc)
131  get_restrict_file = subprocess.Popen(['get_files','-data', restrict_card_loc])
132  get_restrict_file.wait()
133  if not os.path.exists(restrict_card_loc):
134  print 'running without user defined restriction card'
135  restrict_card_loc=None
136 
137  # set only one or a few parameter non-zero
138  # dynamically create restricted model that only contains the relevant operators
139  else:
140  param_card_default='MadGraph_param_card_'+model_nick+'.dat'
141  param_card_loc=param_card_default.replace('.dat','_updated.dat')
142  modify_param_card(param_card_default,output_location=param_card_loc,params={eft_parameter_block:eft_params})
143  if os.path.exists('mgmodels_local'):
144  shutil.rmtree('mgmodels_local')
145  os.mkdir('mgmodels_local')
146  restricted_model='mgmodels_local/'+model
147  shutil.copytree(mgmodels+model,restricted_model)
148  eft_params_to_keep=eft_params
149  for p in eft_params_to_keep:
150  eft_params_to_keep[p]='9.999999e-01'
151  if len(eft_params_to_keep)==0:
152  process=process.replace('NP==0','')
153  restriction='without_irrelevant_couplings'
154  if len(eft_params_to_keep)>0:
155  modify_param_card(param_card_default,output_location=restricted_model+'/'+'restrict_'+restriction+'.dat',params={eft_parameter_block:eft_params_to_keep})
156  else:
157  shutil.copy(param_card_default,restricted_model+'/'+'restrict_'+restriction+'.dat')
158  model='./'+restricted_model
159  restrict_card_loc=None
160 
161  if restrict_card_loc!=None and (reweight_name!=None or param_name!=None):
162  if os.path.exists('mgmodels_local'):
163  shutil.rmtree('mgmodels_local')
164  os.mkdir('mgmodels_local')
165  restricted_model='mgmodels_local/'+model
166  shutil.copytree(mgmodels+model,restricted_model)
167  restriction='without_irrelevant_couplings'
168  shutil.copy(restrict_card_loc,restricted_model+'/'+'restrict_'+restriction+'.dat')
169  model='./'+restricted_model
170 
171  # write process card
172  proc_card="import model "+model
173  if restriction!=None:
174  proc_card+='-'+restriction
175  proc_card+="\n"
176  proc_card+=process+"\noutput -f\n"
177  process_dir=new_process(proc_card)
178 
179  if param_card_loc!=None:
180  shutil.move(param_card_loc,process_dir+'/Cards/param_card.dat')
181  if reweight_card_loc!=None:
182  shutil.move(reweight_card_loc,process_dir+'/Cards/reweight_card.dat')
183 
184  return process_dir
185 
186 
187 

◆ setup_SMEFT_from_JOname()

def setupEFT.setup_SMEFT_from_JOname (   processes)

Definition at line 61 of file setupEFT.py.

61 def setup_SMEFT_from_JOname(processes):
62  physics_short=get_physics_short()
63  model_nick,process,param_name,reweight_name,eft_params=parse_SMEFT_JO(physics_short,processes)
64  return setup_SMEFT(process,model_nick,param_name,reweight_name,eft_params)
65 

Variable Documentation

◆ mgmodels

string setupEFT.mgmodels = '/cvmfs/atlas.cern.ch/repo/sw/Generators/madgraph/models/latest/'

Definition at line 4 of file setupEFT.py.

replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.MadGraphUtils.modify_param_card
def modify_param_card(param_card_input=None, param_card_backup=None, process_dir=MADGRAPH_GRIDPACK_LOCATION, params={}, output_location=None)
Definition: MadGraphUtils.py:1902
python.MadGraphUtils.new_process
def new_process(process='generate p p > t t~\noutput -f', plugin=None, keepJpegs=False, usePMGSettings=False)
Definition: MadGraphUtils.py:222
setupEFT.setup_SMEFT
def setup_SMEFT(process, model_nick, param_name, reweight_name, eft_params)
Definition: setupEFT.py:66
setupEFT.parse_SMEFT_JO
def parse_SMEFT_JO(physics_short, processes)
Definition: setupEFT.py:6
setupEFT.setup_SMEFT_from_JOname
def setup_SMEFT_from_JOname(processes)
Definition: setupEFT.py:61
python.JOsupport.get_physics_short
def get_physics_short()
Definition: JOsupport.py:12