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