Merge lp:~maddevelopers/mg5amcnlo/2.7.3_rwgt into lp:~mg5core1/mg5amcnlo/2.7.3
- 2.7.3_rwgt
- Merge into 2.7.3
Proposed by
Olivier Mattelaer
Status: | Merged |
---|---|
Merged at revision: | 341 |
Proposed branch: | lp:~maddevelopers/mg5amcnlo/2.7.3_rwgt |
Merge into: | lp:~mg5core1/mg5amcnlo/2.7.3 |
Diff against target: |
289 lines (+105/-36) 4 files modified
madgraph/interface/common_run_interface.py (+17/-6) madgraph/interface/reweight_interface.py (+38/-19) madgraph/iolibs/export_v4.py (+13/-10) madgraph/loop/loop_exporters.py (+37/-1) |
To merge this branch: | bzr merge lp:~maddevelopers/mg5amcnlo/2.7.3_rwgt |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Olivier Mattelaer | Pending | ||
Review via email: mp+385816@code.launchpad.net |
Commit message
new strategy for getting the benchmark point.
Do not use file but pass the information from python to f2py via a new API function.
This allows to have multiple thread running in parallel without a race condition on the file.
(independently this should fasten the run on slow IO like some nfs filesystem)
Description of the change
To post a comment you must log in.
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'madgraph/interface/common_run_interface.py' | |||
2 | --- madgraph/interface/common_run_interface.py 2020-06-16 12:49:37 +0000 | |||
3 | +++ madgraph/interface/common_run_interface.py 2020-06-16 13:14:54 +0000 | |||
4 | @@ -1036,7 +1036,11 @@ | |||
5 | 1036 | out = ask(question, '0', possible_answer, timeout=int(1.5*timeout), | 1036 | out = ask(question, '0', possible_answer, timeout=int(1.5*timeout), |
6 | 1037 | path_msg='enter path', ask_class = AskforEditCard, | 1037 | path_msg='enter path', ask_class = AskforEditCard, |
7 | 1038 | cards=cards, mode=mode, **opt) | 1038 | cards=cards, mode=mode, **opt) |
9 | 1039 | 1039 | if 'return_instance' in opt and opt['return_instance']: | |
10 | 1040 | out, cmd = out | ||
11 | 1041 | if 'return_instance' in opt and opt['return_instance']: | ||
12 | 1042 | return (out, cmd) | ||
13 | 1043 | return out | ||
14 | 1040 | 1044 | ||
15 | 1041 | @staticmethod | 1045 | @staticmethod |
16 | 1042 | def detect_card_type(path): | 1046 | def detect_card_type(path): |
17 | @@ -4507,7 +4511,12 @@ | |||
18 | 4507 | self.modified_card = set() #set of cards not in sync with filesystem | 4511 | self.modified_card = set() #set of cards not in sync with filesystem |
19 | 4508 | # need to sync them before editing/leaving | 4512 | # need to sync them before editing/leaving |
20 | 4509 | self.init_from_banner(from_banner, banner) | 4513 | self.init_from_banner(from_banner, banner) |
22 | 4510 | 4514 | self.writting_card = True | |
23 | 4515 | if 'write_file' in opt: | ||
24 | 4516 | if not opt['write_file']: | ||
25 | 4517 | self.writting_card = False | ||
26 | 4518 | self.param_consistency = False | ||
27 | 4519 | |||
28 | 4511 | #update default path by custom one if specify in cards | 4520 | #update default path by custom one if specify in cards |
29 | 4512 | for card in cards: | 4521 | for card in cards: |
30 | 4513 | if os.path.exists(card) and os.path.sep in cards: | 4522 | if os.path.exists(card) and os.path.sep in cards: |
31 | @@ -5255,7 +5264,7 @@ | |||
32 | 5255 | def do_set(self, line): | 5264 | def do_set(self, line): |
33 | 5256 | """ edit the value of one parameter in the card""" | 5265 | """ edit the value of one parameter in the card""" |
34 | 5257 | 5266 | ||
36 | 5258 | 5267 | ||
37 | 5259 | args = self.split_arg(line) | 5268 | args = self.split_arg(line) |
38 | 5260 | 5269 | ||
39 | 5261 | 5270 | ||
40 | @@ -5979,8 +5988,9 @@ | |||
41 | 5979 | self.do_set('shower_card extrapaths None ') | 5988 | self.do_set('shower_card extrapaths None ') |
42 | 5980 | 5989 | ||
43 | 5981 | # ensure that all cards are in sync | 5990 | # ensure that all cards are in sync |
46 | 5982 | for key in list(self.modified_card): | 5991 | if self.writting_card: |
47 | 5983 | self.write_card(key) | 5992 | for key in list(self.modified_card): |
48 | 5993 | self.write_card(key) | ||
49 | 5984 | 5994 | ||
50 | 5985 | 5995 | ||
51 | 5986 | def reask(self, *args, **opt): | 5996 | def reask(self, *args, **opt): |
52 | @@ -6106,7 +6116,8 @@ | |||
53 | 6106 | self.run_card.write(self.paths['run'], self.paths['run_default']) | 6116 | self.run_card.write(self.paths['run'], self.paths['run_default']) |
54 | 6107 | 6117 | ||
55 | 6108 | def write_card_param(self): | 6118 | def write_card_param(self): |
57 | 6109 | """ write the param_card """ | 6119 | """ write the param_card """ |
58 | 6120 | |||
59 | 6110 | self.param_card.write(self.paths['param']) | 6121 | self.param_card.write(self.paths['param']) |
60 | 6111 | 6122 | ||
61 | 6112 | @staticmethod | 6123 | @staticmethod |
62 | 6113 | 6124 | ||
63 | === modified file 'madgraph/interface/reweight_interface.py' | |||
64 | --- madgraph/interface/reweight_interface.py 2020-05-26 19:31:47 +0000 | |||
65 | +++ madgraph/interface/reweight_interface.py 2020-06-16 13:14:54 +0000 | |||
66 | @@ -688,7 +688,8 @@ | |||
67 | 688 | for i,card in enumerate(param_card_iterator): | 688 | for i,card in enumerate(param_card_iterator): |
68 | 689 | if self.options['rwgt_name']: | 689 | if self.options['rwgt_name']: |
69 | 690 | self.options['rwgt_name'] = '%s_%s' % (self.options['rwgt_name'].rsplit('_',1)[0], i+1) | 690 | self.options['rwgt_name'] = '%s_%s' % (self.options['rwgt_name'].rsplit('_',1)[0], i+1) |
71 | 691 | card.write(pjoin(rw_dir, 'Cards', 'param_card.dat')) | 691 | self.new_param_card = card |
72 | 692 | #card.write(pjoin(rw_dir, 'Cards', 'param_card.dat')) | ||
73 | 692 | self.exec_cmd("launch --keep_card", printcmd=False, precmd=True) | 693 | self.exec_cmd("launch --keep_card", printcmd=False, precmd=True) |
74 | 693 | 694 | ||
75 | 694 | self.options['rwgt_name'] = None | 695 | self.options['rwgt_name'] = None |
76 | @@ -708,24 +709,23 @@ | |||
77 | 708 | 709 | ||
78 | 709 | 710 | ||
79 | 710 | if not '--keep_card' in args: | 711 | if not '--keep_card' in args: |
80 | 711 | ff = open(pjoin(rw_dir,'Cards', 'param_card.dat'), 'w') | ||
81 | 712 | ff.write(self.banner['slha']) | ||
82 | 713 | ff.close() | ||
83 | 714 | if self.has_nlo and self.rwgt_mode != "LO": | 712 | if self.has_nlo and self.rwgt_mode != "LO": |
84 | 715 | rwdir_virt = rw_dir.replace('rw_me', 'rw_mevirt') | 713 | rwdir_virt = rw_dir.replace('rw_me', 'rw_mevirt') |
93 | 716 | files.ln(ff.name, starting_dir=pjoin(rwdir_virt, 'Cards')) | 714 | |
94 | 717 | ff = open(pjoin(path_me, 'rw_me','Cards', 'param_card_orig.dat'), 'w') | 715 | out, cmd = common_run_interface.CommonRunCmd.ask_edit_card_static(cards=['param_card.dat'], |
95 | 718 | ff.write(self.banner['slha']) | 716 | ask=self.ask, pwd=rw_dir, first_cmd=self.stored_line, |
96 | 719 | ff.close() | 717 | write_file=False, return_instance=True |
97 | 720 | if self.has_nlo and self.rwgt_mode != "LO": | 718 | ) |
90 | 721 | files.ln(ff.name, starting_dir=pjoin(path_me, 'rw_mevirt', 'Cards')) | ||
91 | 722 | cmd = common_run_interface.CommonRunCmd.ask_edit_card_static(cards=['param_card.dat'], | ||
92 | 723 | ask=self.ask, pwd=rw_dir, first_cmd=self.stored_line) | ||
98 | 724 | self.stored_line = None | 719 | self.stored_line = None |
100 | 725 | 720 | card = cmd.param_card | |
101 | 721 | new_card = card.write() | ||
102 | 722 | elif self.new_param_card: | ||
103 | 723 | new_card = self.new_param_card.write() | ||
104 | 724 | else: | ||
105 | 725 | new_card = open(pjoin(rw_dir, 'Cards', 'param_card.dat')).read() | ||
106 | 726 | |||
107 | 726 | # check for potential scan in the new card | 727 | # check for potential scan in the new card |
110 | 727 | new_card = open(pjoin(rw_dir, 'Cards', 'param_card.dat')).read() | 728 | pattern_scan = re.compile(r'''^(decay)?[\s\d]*scan''', re.I+re.M) |
109 | 728 | pattern_scan = re.compile(r'''^[\s\d]*scan''', re.I+re.M) | ||
111 | 729 | param_card_iterator = [] | 729 | param_card_iterator = [] |
112 | 730 | if pattern_scan.search(new_card): | 730 | if pattern_scan.search(new_card): |
113 | 731 | try: | 731 | try: |
114 | @@ -744,11 +744,19 @@ | |||
115 | 744 | param_card_iterator = main_card | 744 | param_card_iterator = main_card |
116 | 745 | first_card = param_card_iterator.next(autostart=True) | 745 | first_card = param_card_iterator.next(autostart=True) |
117 | 746 | new_card = first_card.write() | 746 | new_card = first_card.write() |
120 | 747 | first_card.write(pjoin(rw_dir, 'Cards', 'param_card.dat')) | 747 | self.new_param_card = first_card |
121 | 748 | 748 | #first_card.write(pjoin(rw_dir, 'Cards', 'param_card.dat')) | |
122 | 749 | |||
123 | 749 | # check if "Auto" is present for a width parameter) | 750 | # check if "Auto" is present for a width parameter) |
124 | 750 | tmp_card = new_card.lower().split('block',1)[1] | 751 | tmp_card = new_card.lower().split('block',1)[1] |
125 | 751 | if "auto" in tmp_card: | 752 | if "auto" in tmp_card: |
126 | 753 | if param_card_iterator: | ||
127 | 754 | first_card.write(pjoin(rw_dir, 'Cards', 'param_card.dat')) | ||
128 | 755 | else: | ||
129 | 756 | ff = open(pjoin(rw_dir, 'Cards', 'param_card.dat'),'w') | ||
130 | 757 | ff.write(new_card) | ||
131 | 758 | ff.close() | ||
132 | 759 | |||
133 | 752 | self.mother.check_param_card(pjoin(rw_dir, 'Cards', 'param_card.dat')) | 760 | self.mother.check_param_card(pjoin(rw_dir, 'Cards', 'param_card.dat')) |
134 | 753 | new_card = open(pjoin(rw_dir, 'Cards', 'param_card.dat')).read() | 761 | new_card = open(pjoin(rw_dir, 'Cards', 'param_card.dat')).read() |
135 | 754 | 762 | ||
136 | @@ -795,6 +803,7 @@ | |||
137 | 795 | # add the reweighting in the banner information: | 803 | # add the reweighting in the banner information: |
138 | 796 | #starts by computing the difference in the cards. | 804 | #starts by computing the difference in the cards. |
139 | 797 | s_orig = self.banner['slha'] | 805 | s_orig = self.banner['slha'] |
140 | 806 | self.orig_param_card_text = s_orig | ||
141 | 798 | s_new = new_card | 807 | s_new = new_card |
142 | 799 | self.new_param_card = check_param_card.ParamCard(s_new.splitlines()) | 808 | self.new_param_card = check_param_card.ParamCard(s_new.splitlines()) |
143 | 800 | 809 | ||
144 | @@ -866,15 +875,25 @@ | |||
145 | 866 | else: | 875 | else: |
146 | 867 | tag_name = 'rwgt_%s' % rewgtid | 876 | tag_name = 'rwgt_%s' % rewgtid |
147 | 868 | 877 | ||
148 | 878 | |||
149 | 869 | #initialise module. | 879 | #initialise module. |
150 | 870 | for (path,tag), module in self.f2pylib.items(): | 880 | for (path,tag), module in self.f2pylib.items(): |
151 | 871 | with misc.chdir(pjoin(os.path.dirname(rw_dir), path)): | 881 | with misc.chdir(pjoin(os.path.dirname(rw_dir), path)): |
152 | 872 | with misc.stdchannel_redirected(sys.stdout, os.devnull): | 882 | with misc.stdchannel_redirected(sys.stdout, os.devnull): |
153 | 873 | if 'second' in path or tag == 3: | 883 | if 'second' in path or tag == 3: |
155 | 874 | module.initialise(pjoin(rw_dir, 'Cards', 'param_card.dat')) | 884 | param_card = self.new_param_card |
156 | 875 | else: | 885 | else: |
158 | 876 | module.initialise(pjoin(path_me, 'rw_me', 'Cards', 'param_card_orig.dat')) | 886 | param_card = check_param_card.ParamCard(self.orig_param_card_text) |
159 | 887 | |||
160 | 888 | for block in param_card: | ||
161 | 877 | 889 | ||
162 | 890 | for param in param_card[block]: | ||
163 | 891 | lhacode = param.lhacode | ||
164 | 892 | value = param.value | ||
165 | 893 | name = '%s_%s' % (block.upper(), '_'.join([str(i) for i in lhacode])) | ||
166 | 894 | module.change_para(name, value) | ||
167 | 895 | module.update_all_coup() | ||
168 | 896 | |||
169 | 878 | return param_card_iterator, tag_name | 897 | return param_card_iterator, tag_name |
170 | 879 | 898 | ||
171 | 880 | 899 | ||
172 | 881 | 900 | ||
173 | === modified file 'madgraph/iolibs/export_v4.py' | |||
174 | --- madgraph/iolibs/export_v4.py 2020-06-11 16:04:47 +0000 | |||
175 | +++ madgraph/iolibs/export_v4.py 2020-06-16 13:14:54 +0000 | |||
176 | @@ -12,7 +12,6 @@ | |||
177 | 12 | # For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch | 12 | # For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch |
178 | 13 | # | 13 | # |
179 | 14 | ################################################################################ | 14 | ################################################################################ |
180 | 15 | from madgraph.iolibs.helas_call_writers import HelasCallWriter | ||
181 | 16 | """Methods and classes to export matrix elements to v4 format.""" | 15 | """Methods and classes to export matrix elements to v4 format.""" |
182 | 17 | 16 | ||
183 | 18 | import copy | 17 | import copy |
184 | @@ -2117,7 +2116,7 @@ | |||
185 | 2117 | SELECT CASE (name) | 2116 | SELECT CASE (name) |
186 | 2118 | %(parameter_setup)s | 2117 | %(parameter_setup)s |
187 | 2119 | CASE DEFAULT | 2118 | CASE DEFAULT |
189 | 2120 | stop 1 | 2119 | write(*,*) 'no parameter matching' |
190 | 2121 | END SELECT | 2120 | END SELECT |
191 | 2122 | 2121 | ||
192 | 2123 | return | 2122 | return |
193 | @@ -2185,13 +2184,9 @@ | |||
194 | 2185 | 2184 | ||
195 | 2186 | params = self.get_model_parameter(self.model) | 2185 | params = self.get_model_parameter(self.model) |
196 | 2187 | parameter_setup =[] | 2186 | parameter_setup =[] |
202 | 2188 | for p in params: | 2187 | for key, var in params.items(): |
198 | 2189 | if p.startswith('mdl_'): | ||
199 | 2190 | short_p = p[4:] | ||
200 | 2191 | else: | ||
201 | 2192 | short_p = p | ||
203 | 2193 | parameter_setup.append(' CASE ("%s")\n %s = value' | 2188 | parameter_setup.append(' CASE ("%s")\n %s = value' |
205 | 2194 | % (short_p, p)) | 2189 | % (key, var)) |
206 | 2195 | 2190 | ||
207 | 2196 | formatting = {'python_information':'\n'.join(info), | 2191 | formatting = {'python_information':'\n'.join(info), |
208 | 2197 | 'smatrixhel': '\n'.join(text), | 2192 | 'smatrixhel': '\n'.join(text), |
209 | @@ -2211,9 +2206,17 @@ | |||
210 | 2211 | def get_model_parameter(self, model): | 2206 | def get_model_parameter(self, model): |
211 | 2212 | """ returns all the model parameter | 2207 | """ returns all the model parameter |
212 | 2213 | """ | 2208 | """ |
213 | 2209 | params = {} | ||
214 | 2210 | for p in model.get('parameters')[('external',)]: | ||
215 | 2211 | name = p.name | ||
216 | 2212 | nopref = name[4:] if name.startswith('mdl_') else name | ||
217 | 2213 | params[nopref] = name | ||
218 | 2214 | |||
219 | 2215 | block = p.lhablock | ||
220 | 2216 | lha = '_'.join([str(i) for i in p.lhacode]) | ||
221 | 2217 | params['%s_%s' % (block, lha)] = name | ||
222 | 2214 | 2218 | ||
225 | 2215 | params = [p.name for p in model.get('parameters')[('external',)]] | 2219 | return params |
224 | 2216 | return params | ||
226 | 2217 | 2220 | ||
227 | 2218 | 2221 | ||
228 | 2219 | 2222 | ||
229 | 2220 | 2223 | ||
230 | === modified file 'madgraph/loop/loop_exporters.py' | |||
231 | --- madgraph/loop/loop_exporters.py 2019-06-05 11:03:48 +0000 | |||
232 | +++ madgraph/loop/loop_exporters.py 2020-06-16 13:14:54 +0000 | |||
233 | @@ -297,6 +297,33 @@ | |||
234 | 297 | RETURN | 297 | RETURN |
235 | 298 | END | 298 | END |
236 | 299 | 299 | ||
237 | 300 | subroutine CHANGE_PARA(name, value) | ||
238 | 301 | implicit none | ||
239 | 302 | CF2PY intent(in) :: name | ||
240 | 303 | CF2PY intent(in) :: value | ||
241 | 304 | |||
242 | 305 | character*512 name | ||
243 | 306 | double precision value | ||
244 | 307 | |||
245 | 308 | include '../Source/MODEL/input.inc' | ||
246 | 309 | include '../Source/MODEL/coupl.inc' | ||
247 | 310 | |||
248 | 311 | SELECT CASE (name) | ||
249 | 312 | %(parameter_setup)s | ||
250 | 313 | CASE DEFAULT | ||
251 | 314 | write(*,*) 'no parameter matching' | ||
252 | 315 | END SELECT | ||
253 | 316 | |||
254 | 317 | return | ||
255 | 318 | end | ||
256 | 319 | |||
257 | 320 | subroutine update_all_coup() | ||
258 | 321 | implicit none | ||
259 | 322 | call coup() | ||
260 | 323 | return | ||
261 | 324 | end | ||
262 | 325 | |||
263 | 326 | |||
264 | 300 | SUBROUTINE SET_MADLOOP_PATH(PATH) | 327 | SUBROUTINE SET_MADLOOP_PATH(PATH) |
265 | 301 | C Routine to set the path of the folder 'MadLoop5_resources' to MadLoop | 328 | C Routine to set the path of the folder 'MadLoop5_resources' to MadLoop |
266 | 302 | CHARACTER(512) PATH | 329 | CHARACTER(512) PATH |
267 | @@ -377,6 +404,14 @@ | |||
268 | 377 | #close the function | 404 | #close the function |
269 | 378 | if min_nexternal != max_nexternal: | 405 | if min_nexternal != max_nexternal: |
270 | 379 | text.append('endif') | 406 | text.append('endif') |
271 | 407 | |||
272 | 408 | params = self.get_model_parameter(self.model) | ||
273 | 409 | parameter_setup =[] | ||
274 | 410 | for key, var in params.items(): | ||
275 | 411 | parameter_setup.append(' CASE ("%s")\n %s = value' | ||
276 | 412 | % (key, var)) | ||
277 | 413 | |||
278 | 414 | |||
279 | 380 | 415 | ||
280 | 381 | formatting = {'python_information':'\n'.join(info), | 416 | formatting = {'python_information':'\n'.join(info), |
281 | 382 | 'smatrixhel': '\n'.join(text), | 417 | 'smatrixhel': '\n'.join(text), |
282 | @@ -385,7 +420,8 @@ | |||
283 | 385 | 'pdgs': ','.join([str(pdg[i]) if i<len(pdg) else '0' | 420 | 'pdgs': ','.join([str(pdg[i]) if i<len(pdg) else '0' |
284 | 386 | for i in range(max_nexternal) \ | 421 | for i in range(max_nexternal) \ |
285 | 387 | for pdg in allids]), | 422 | for pdg in allids]), |
287 | 388 | 'prefix':'\',\''.join(allprefix) | 423 | 'prefix':'\',\''.join(allprefix), |
288 | 424 | 'parameter_setup': '\n'.join(parameter_setup), | ||
289 | 389 | } | 425 | } |
290 | 390 | 426 | ||
291 | 391 | 427 |
This sounds good to go.
Was validated by CMS for LO reweighting and Gauthier did also some validation.
(in top of mine)
I might wait a bit for formal approval of Gauthier but I already approve