Merge lp:~maddevelopers/mg5amcnlo/dim6_eft into lp:mg5amcnlo/lts
- dim6_eft
- Merge into series2.0
Proposed by
Olivier Mattelaer
Status: | Superseded |
---|---|
Proposed branch: | lp:~maddevelopers/mg5amcnlo/dim6_eft |
Merge into: | lp:mg5amcnlo/lts |
Diff against target: |
2266 lines (+721/-333) 35 files modified
Template/LO/Cards/run_card.dat (+1/-13) Template/LO/Source/PDF/pdg2pdf.f (+8/-5) Template/LO/Source/PDF/pdg2pdf_lhapdf.f (+1/-0) Template/LO/Source/PDF/pdg2pdf_lhapdf6.f (+8/-5) Template/LO/SubProcesses/dummy_fct.f (+10/-0) Template/LO/SubProcesses/genps.f (+8/-3) Template/LO/SubProcesses/reweight.f (+1/-1) Template/NLO/Source/PDF/pdg2pdf.f (+8/-5) Template/NLO/Source/PDF/pdg2pdf_lhapdf.f (+8/-5) Template/NLO/Source/PDF/pdg2pdf_lhapdf6.f (+8/-5) Template/NLO/SubProcesses/fks_singular.f (+6/-4) Template/loop_material/StandAlone/SubProcesses/makefile (+2/-2) madgraph/core/base_objects.py (+3/-1) madgraph/core/diagram_generation.py (+4/-3) madgraph/fks/fks_common.py (+18/-4) madgraph/interface/common_run_interface.py (+4/-4) madgraph/interface/extended_cmd.py (+3/-3) madgraph/interface/madevent_interface.py (+56/-75) madgraph/interface/madgraph_interface.py (+70/-12) madgraph/interface/master_interface.py (+5/-0) madgraph/interface/reweight_interface.py (+234/-50) madgraph/iolibs/export_v4.py (+60/-20) madgraph/iolibs/template_files/madevent_makefile_source (+4/-5) madgraph/iolibs/template_files/matrix_standalone_splitOrders_v4.inc (+11/-8) madgraph/iolibs/template_files/matrix_standalone_v4.inc (+9/-9) madgraph/iolibs/template_files/pythia8/pythia8_model_parameters_cc.inc (+47/-45) madgraph/iolibs/template_files/pythia8/pythia8_model_parameters_h.inc (+6/-4) madgraph/various/banner.py (+55/-21) madgraph/various/lhe_parser.py (+32/-11) madgraph/various/misc.py (+2/-2) madgraph/various/rambo.py (+7/-0) models/check_param_card.py (+3/-0) models/import_ufo.py (+14/-3) models/template_files/fortran/lha_read.f (+2/-2) models/template_files/fortran/lha_read_mp.f (+3/-3) |
To merge this branch: | bzr merge lp:~maddevelopers/mg5amcnlo/dim6_eft |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
MadTeam | Pending | ||
Review via email: mp+367511@code.launchpad.net |
Commit message
change in the reweighting for the EFT validation effort
Description of the change
To post a comment you must log in.
Unmerged revisions
- 299. By olivier-mattelaer
-
fix latest acceptance test
- 298. By olivier-mattelaer
-
some cleaning + adapting test for new allowed input in RAMBO
- 297. By olivier-mattelaer
-
merge with latest 2.6.6
- 296. By olivier-mattelaer
-
add reweight_card
- 295. By olivier-mattelaer
-
add more model information
- 294. By olivier-mattelaer
-
adding support for nincoming in standalone fortran as py lib
- 293. By olivier-mattelaer
-
merge with last 2.6.6
- 292. By olivier-mattelaer
-
avoid any issue with parameter with many input parameter in standalone mode
- 291. By olivier-mattelaer
-
fix issue with multiple launch in re=wgt outside of mg
- 290. By olivier-mattelaer
-
fix an issue related to NLO model for import process command
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Template/LO/Cards/run_card.dat' |
2 | --- Template/LO/Cards/run_card.dat 2018-05-29 13:11:53 +0000 |
3 | +++ Template/LO/Cards/run_card.dat 2019-05-16 09:35:25 +0000 |
4 | @@ -121,19 +121,7 @@ |
5 | %(missetmax)s = missetmax ! maximum missing Et (sum of neutrino's momenta) |
6 | %(pt_min_pdg)s = pt_min_pdg ! pt cut for other particles (use pdg code). Applied on particle and anti-particle |
7 | %(pt_max_pdg)s = pt_max_pdg ! pt cut for other particles (syntax e.g. {6: 100, 25: 50}) |
8 | -#********************************************************************* |
9 | -# Minimum and maximum E's (in the center of mass frame) * |
10 | -#********************************************************************* |
11 | - %(ej)s = ej ! minimum E for the jets |
12 | - %(eb)s = eb ! minimum E for the b |
13 | - %(ea)s = ea ! minimum E for the photons |
14 | - %(el)s = el ! minimum E for the charged leptons |
15 | - %(ejmax)s = ejmax ! maximum E for the jets |
16 | - %(ebmax)s = ebmax ! maximum E for the b |
17 | - %(eamax)s = eamax ! maximum E for the photons |
18 | - %(elmax)s = elmax ! maximum E for the charged leptons |
19 | - %(e_min_pdg)s = e_min_pdg ! E cut for other particles (use pdg code). Applied on particle and anti-particle |
20 | - %(e_max_pdg)s = e_max_pdg ! E cut for other particles (syntax e.g. {6: 100, 25: 50}) |
21 | +$ecut |
22 | #********************************************************************* |
23 | # Maximum and minimum absolute rapidity (for max, -1 means no cut) * |
24 | #********************************************************************* |
25 | |
26 | === modified file 'Template/LO/Source/PDF/pdg2pdf.f' |
27 | --- Template/LO/Source/PDF/pdg2pdf.f 2018-03-07 23:11:46 +0000 |
28 | +++ Template/LO/Source/PDF/pdg2pdf.f 2019-05-16 09:35:25 +0000 |
29 | @@ -58,12 +58,14 @@ |
30 | endif |
31 | |
32 | ipart=ipdg |
33 | - if(iabs(ipart).eq.21) ipart=0 |
34 | - if(iabs(ipart).eq.22) ipart=7 |
35 | - iporg=ipart |
36 | - |
37 | + if(iabs(ipart).eq.21) then |
38 | + ipart=0 |
39 | + else if(iabs(ipart).eq.22) then |
40 | + ipart=7 |
41 | + else if(iabs(ipart).eq.7) then |
42 | + ipart=7 |
43 | c This will be called for any PDG code, but we only support up to 7 |
44 | - if(iabs(ipart).gt.7)then |
45 | + else if(iabs(ipart).gt.7)then |
46 | write(*,*) 'PDF not supported for pdg ',ipdg |
47 | write(*,*) 'For lepton colliders, please set the lpp* '// |
48 | $ 'variables to 0 in the run_card' |
49 | @@ -72,6 +74,7 @@ |
50 | stop 1 |
51 | endif |
52 | |
53 | + iporg=ipart |
54 | ireuse = 0 |
55 | do i=1,2 |
56 | c Check if result can be reused since any of last two calls |
57 | |
58 | === modified file 'Template/LO/Source/PDF/pdg2pdf_lhapdf.f' |
59 | --- Template/LO/Source/PDF/pdg2pdf_lhapdf.f 2018-03-07 23:11:46 +0000 |
60 | +++ Template/LO/Source/PDF/pdg2pdf_lhapdf.f 2019-05-16 09:35:25 +0000 |
61 | @@ -57,6 +57,7 @@ |
62 | ipart=ipdg |
63 | if(ipart.eq.21) ipart=0 |
64 | if(iabs(ipart).eq.22) ipart=7 |
65 | + if(iabs(ipart).eq.7) ipart=7 |
66 | iporg=ipart |
67 | |
68 | c This will be called for any PDG code, but we only support up to 7 |
69 | |
70 | === modified file 'Template/LO/Source/PDF/pdg2pdf_lhapdf6.f' |
71 | --- Template/LO/Source/PDF/pdg2pdf_lhapdf6.f 2018-03-07 23:11:46 +0000 |
72 | +++ Template/LO/Source/PDF/pdg2pdf_lhapdf6.f 2019-05-16 09:35:25 +0000 |
73 | @@ -54,12 +54,14 @@ |
74 | endif |
75 | |
76 | ipart=ipdg |
77 | - if(iabs(ipart).eq.21) ipart=0 |
78 | - if(iabs(ipart).eq.22) ipart=7 |
79 | - iporg=ipart |
80 | - |
81 | + if(iabs(ipart).eq.21) then |
82 | + ipart=0 |
83 | + else if(iabs(ipart).eq.22) then |
84 | + ipart=7 |
85 | + else if (iabs(ipart).eq.7) then |
86 | + ipart=7 |
87 | c This will be called for any PDG code, but we only support up to 7 |
88 | - if(iabs(ipart).gt.7)then |
89 | + else if(iabs(ipart).gt.7)then |
90 | write(*,*) 'PDF not supported for pdg ',ipdg |
91 | write(*,*) 'For lepton colliders, please set the lpp* '// |
92 | $ 'variables to 0 in the run_card' |
93 | @@ -68,6 +70,7 @@ |
94 | stop 1 |
95 | endif |
96 | |
97 | + iporg=ipart |
98 | c Determine the iset used in lhapdf |
99 | call getnset(iset) |
100 | if (iset.ne.1) then |
101 | |
102 | === modified file 'Template/LO/SubProcesses/dummy_fct.f' |
103 | --- Template/LO/SubProcesses/dummy_fct.f 2018-01-11 16:16:25 +0000 |
104 | +++ Template/LO/SubProcesses/dummy_fct.f 2019-05-16 09:35:25 +0000 |
105 | @@ -86,3 +86,13 @@ |
106 | shat = x(1)*x(2)*ebeam(1)*ebeam(2) |
107 | return |
108 | end |
109 | + |
110 | + |
111 | + logical function dummy_boostframe() |
112 | + implicit none |
113 | +c |
114 | +c |
115 | + dummy_boostframe = .false. |
116 | + return |
117 | + end |
118 | + |
119 | |
120 | === modified file 'Template/LO/SubProcesses/genps.f' |
121 | --- Template/LO/SubProcesses/genps.f 2018-06-27 09:03:22 +0000 |
122 | +++ Template/LO/SubProcesses/genps.f 2019-05-16 09:35:25 +0000 |
123 | @@ -185,7 +185,8 @@ |
124 | c External function |
125 | double precision SumDot |
126 | external SumDot |
127 | - |
128 | + logical dummy_boostframe |
129 | + external dummy_boostframe |
130 | c |
131 | c data |
132 | c |
133 | @@ -304,8 +305,12 @@ |
134 | c First Generate Momentum for initial state particles |
135 | c |
136 | if (lpp(1).eq.9.or.lpp(2).eq.9)then |
137 | - p(:,1) = pi1(:) |
138 | - p(:,2) = pi2(:) |
139 | + if (dummy_boostframe())then |
140 | + call mom2cx(m(-nbranch),m(1),m(2),1d0,0d0,p(0,1),p(0,2)) |
141 | + else |
142 | + p(:,1) = pi1(:) |
143 | + p(:,2) = pi2(:) |
144 | + endif |
145 | else if(nincoming.eq.2) then |
146 | call mom2cx(m(-nbranch),m(1),m(2),1d0,0d0,p(0,1),p(0,2)) |
147 | else |
148 | |
149 | === modified file 'Template/LO/SubProcesses/reweight.f' |
150 | --- Template/LO/SubProcesses/reweight.f 2019-01-25 10:41:09 +0000 |
151 | +++ Template/LO/SubProcesses/reweight.f 2019-05-16 09:35:25 +0000 |
152 | @@ -399,7 +399,7 @@ |
153 | c exotic q > gluon q' |
154 | ipart(1,imo)=ipart(1,ida1) |
155 | ipart(2,imo)=0 |
156 | - else if (get_color(idmo).eq.1.or.get_color(idmo).eq.2) then |
157 | + else if (get_color(idmo).eq.1.or.get_color(idmo).eq.2.or.get_color(idda1).eq.2.or.get_color(idda2).eq.2) then |
158 | c Color singlet |
159 | ipart(1,imo)=ipart(1,ida1) |
160 | ipart(2,imo)=ipart(1,ida2) |
161 | |
162 | === modified file 'Template/NLO/Source/PDF/pdg2pdf.f' |
163 | --- Template/NLO/Source/PDF/pdg2pdf.f 2015-10-21 14:57:34 +0000 |
164 | +++ Template/NLO/Source/PDF/pdg2pdf.f 2019-05-16 09:35:25 +0000 |
165 | @@ -66,12 +66,14 @@ |
166 | endif |
167 | |
168 | ipart=ipdg |
169 | - if(iabs(ipart).eq.21) ipart=0 |
170 | - if(iabs(ipart).eq.22) ipart=7 |
171 | - iporg=ipart |
172 | - |
173 | + if(iabs(ipart).eq.21) then |
174 | + ipart=0 |
175 | + else if(iabs(ipart).eq.22) then |
176 | + ipart=7 |
177 | + else if(iabs(ipart).eq.7) then |
178 | + ipart=7 |
179 | + else if(iabs(ipart).gt.7)then |
180 | c This will be called for any PDG code, but we only support up to 7 |
181 | - if(iabs(ipart).gt.7)then |
182 | write(*,*) 'PDF not supported for pdg ',ipdg |
183 | write(*,*) 'For lepton colliders, please set the lpp* '// |
184 | $ 'variables to 0 in the run_card' |
185 | @@ -80,6 +82,7 @@ |
186 | stop 1 |
187 | endif |
188 | |
189 | + iporg=ipart |
190 | ireuse = 0 |
191 | ii=i_replace |
192 | do i=1,20 |
193 | |
194 | === modified file 'Template/NLO/Source/PDF/pdg2pdf_lhapdf.f' |
195 | --- Template/NLO/Source/PDF/pdg2pdf_lhapdf.f 2016-02-09 14:17:01 +0000 |
196 | +++ Template/NLO/Source/PDF/pdg2pdf_lhapdf.f 2019-05-16 09:35:25 +0000 |
197 | @@ -64,12 +64,14 @@ |
198 | endif |
199 | |
200 | ipart=ipdg |
201 | - if(iabs(ipart).eq.21) ipart=0 |
202 | - if(iabs(ipart).eq.22) ipart=7 |
203 | - iporg=ipart |
204 | - |
205 | + if(iabs(ipart).eq.21) then |
206 | + ipart=0 |
207 | + else if(iabs(ipart).eq.22) then |
208 | + ipart=7 |
209 | + else if(iabs(ipart).eq.7) then |
210 | + ipart=7 |
211 | + else if(iabs(ipart).gt.7)then |
212 | c This will be called for any PDG code, but we only support up to 7 |
213 | - if(iabs(ipart).gt.7)then |
214 | write(*,*) 'PDF not supported for pdg ',ipdg |
215 | write(*,*) 'For lepton colliders, please set the lpp* '// |
216 | $ 'variables to 0 in the run_card' |
217 | @@ -82,6 +84,7 @@ |
218 | c Determine the member of the set (function of lhapdf) |
219 | call getnmem(iset,imem) |
220 | |
221 | + iporg=ipart |
222 | ireuse = 0 |
223 | ii=i_replace |
224 | do i=1,20 |
225 | |
226 | === modified file 'Template/NLO/Source/PDF/pdg2pdf_lhapdf6.f' |
227 | --- Template/NLO/Source/PDF/pdg2pdf_lhapdf6.f 2016-02-11 19:09:10 +0000 |
228 | +++ Template/NLO/Source/PDF/pdg2pdf_lhapdf6.f 2019-05-16 09:35:25 +0000 |
229 | @@ -65,12 +65,14 @@ |
230 | endif |
231 | |
232 | ipart=ipdg |
233 | - if(iabs(ipart).eq.21) ipart=0 |
234 | - if(iabs(ipart).eq.22) ipart=7 |
235 | - iporg=ipart |
236 | - |
237 | + if(iabs(ipart).eq.21) then |
238 | + ipart=0 |
239 | + else if(iabs(ipart).eq.22) then |
240 | + ipart=7 |
241 | + else if(iabs(ipart).eq.7) then |
242 | + ipart=7 |
243 | + else if(iabs(ipart).gt.7)then |
244 | c This will be called for any PDG code, but we only support up to 7 |
245 | - if(iabs(ipart).gt.7)then |
246 | write(*,*) 'PDF not supported for pdg ',ipdg |
247 | write(*,*) 'For lepton colliders, please set the lpp* '// |
248 | $ 'variables to 0 in the run_card' |
249 | @@ -82,6 +84,7 @@ |
250 | c Determine the member of the set (function of lhapdf) |
251 | call getnmem(iset,imem) |
252 | |
253 | + iporg=ipart |
254 | ireuse = 0 |
255 | ii=i_replace |
256 | do i=1,20 |
257 | |
258 | === modified file 'Template/NLO/SubProcesses/fks_singular.f' |
259 | --- Template/NLO/SubProcesses/fks_singular.f 2018-03-12 07:20:30 +0000 |
260 | +++ Template/NLO/SubProcesses/fks_singular.f 2019-05-16 09:35:25 +0000 |
261 | @@ -2896,10 +2896,12 @@ |
262 | & pjet,njet,jet) |
263 | do i=1,NN |
264 | di(i)=sqrt(amcatnlo_fastjetdmergemax(i-1)) |
265 | - if (i.gt.1.and.di(i).gt.di(i-1))then |
266 | - write(*,*)'Error in set_shower_scale_noshape' |
267 | - write(*,*)NN,i,di(i),di(i-1) |
268 | - stop |
269 | + if (i.gt.1)then |
270 | + if(di(i).gt.di(i-1))then |
271 | + write(*,*)'Error in set_shower_scale_noshape' |
272 | + write(*,*)NN,i,di(i),di(i-1) |
273 | + stop |
274 | + endif |
275 | endif |
276 | enddo |
277 | if(iSH.eq.1)shower_S_scale(iFKS)=di(NN) |
278 | |
279 | === modified file 'Template/loop_material/StandAlone/SubProcesses/makefile' |
280 | --- Template/loop_material/StandAlone/SubProcesses/makefile 2017-09-01 09:45:48 +0000 |
281 | +++ Template/loop_material/StandAlone/SubProcesses/makefile 2019-05-16 09:35:25 +0000 |
282 | @@ -119,11 +119,11 @@ |
283 | endif |
284 | matrix$(MENUM)py.so: ../$(OLP)_static f2py_wrapper.f |
285 | touch __init__.py |
286 | - $(F2PY) $(MADLOOP_LIB) -m matrix$(MENUM)py -c f2py_wrapper.f --fcompiler=$(FC) -L../../lib/ -ldhelas -lmodel $(LINK_LOOP_LIBS) $(STDLIB) |
287 | + $(F2PY) $(MADLOOP_LIB) -m matrix$(MENUM)py -c f2py_wrapper.f --f77exec=$(FC) -L../../lib/ -ldhelas -lmodel $(LINK_LOOP_LIBS) $(STDLIB) |
288 | |
289 | allmatrix$(MENUM)py.so: $(OLP)_static all_matrix.f $(LIBS) $(WRAPPER) |
290 | touch __init__.py |
291 | - $(F2PY) $(MADLOOP_LIB) -m allmatrix$(MENUM)py -c all_matrix.f $(wildcard $(LOOP_PREFIX)*/f2py_wrapper.f) --fcompiler=$(FC) -L../lib/ -ldhelas -lmodel $(LINK_LOOP_LIBS) $(STDLIB) |
292 | + $(F2PY) $(MADLOOP_LIB) -m allmatrix$(MENUM)py -c all_matrix.f $(wildcard $(LOOP_PREFIX)*/f2py_wrapper.f) --f77exec=$(FC) -L../lib/ -ldhelas -lmodel $(LINK_LOOP_LIBS) $(STDLIB) |
293 | |
294 | clean: |
295 | @rm -f *.o *.so *.$(libext) *.$(dylibext) |
296 | |
297 | === modified file 'madgraph/core/base_objects.py' |
298 | --- madgraph/core/base_objects.py 2018-12-03 22:10:49 +0000 |
299 | +++ madgraph/core/base_objects.py 2019-05-16 09:35:25 +0000 |
300 | @@ -1043,6 +1043,8 @@ |
301 | self['expansion_order'] = None |
302 | self['version_tag'] = None # position of the directory (for security) |
303 | self['gauge'] = [0, 1] |
304 | + import collections |
305 | + self['model_info'] = collections.defaultdict(str) |
306 | self['case_sensitive'] = True |
307 | # attribute which might be define if needed |
308 | #self['name2pdg'] = {'name': pdg} |
309 | @@ -1184,7 +1186,7 @@ |
310 | |
311 | if (name == 'order_hierarchy') and not self[name]: |
312 | if self['interactions']: |
313 | - self['order_hierarchy'] = self.get_order_hierarchy() |
314 | + self['order_hierarchy'] = self.get_order_hierarchy() |
315 | |
316 | if (name == 'expansion_order') and self[name] == None: |
317 | if self['interactions']: |
318 | |
319 | === modified file 'madgraph/core/diagram_generation.py' |
320 | --- madgraph/core/diagram_generation.py 2018-12-03 22:10:49 +0000 |
321 | +++ madgraph/core/diagram_generation.py 2019-05-16 09:35:25 +0000 |
322 | @@ -1334,7 +1334,7 @@ |
323 | def __init__(self, argument = None, collect_mirror_procs = False, |
324 | ignore_six_quark_processes = False, loop_filter=None, diagram_filter=False): |
325 | """Allow initialization with Process and with ProcessDefinition""" |
326 | - |
327 | + |
328 | if isinstance(argument, base_objects.Process): |
329 | super(DecayChainAmplitude, self).__init__() |
330 | from madgraph.loop.loop_diagram_generation import LoopMultiProcess |
331 | @@ -1373,7 +1373,8 @@ |
332 | " incoming particle" |
333 | self['decay_chains'].append(\ |
334 | DecayChainAmplitude(process, collect_mirror_procs, |
335 | - ignore_six_quark_processes)) |
336 | + ignore_six_quark_processes, |
337 | + diagram_filter=diagram_filter)) |
338 | |
339 | # Flag decaying legs in the core diagrams by onshell = True |
340 | decay_ids = sum([[a.get('process').get('legs')[0].get('id') \ |
341 | @@ -1782,7 +1783,7 @@ |
342 | if not process.get('required_s_channels') and \ |
343 | not process.get('forbidden_onsh_s_channels') and \ |
344 | not process.get('forbidden_s_channels') and \ |
345 | - not process.get('is_decay_chain'): |
346 | + not process.get('is_decay_chain') and not diagram_filter: |
347 | try: |
348 | crossed_index = success_procs.index(sorted_legs) |
349 | # The relabeling of legs for loop amplitudes is cumbersome |
350 | |
351 | === modified file 'madgraph/fks/fks_common.py' |
352 | --- madgraph/fks/fks_common.py 2019-02-03 21:24:20 +0000 |
353 | +++ madgraph/fks/fks_common.py 2019-05-16 09:35:25 +0000 |
354 | @@ -454,12 +454,26 @@ |
355 | for i, ii in model.get('interaction_dict').items(): |
356 | # i want interections of pert_order: 1 (from LO to NLO), |
357 | # without any other orders |
358 | + # and of "base" type |
359 | + if ii.get('type') != 'base': continue |
360 | + |
361 | if ii.get('orders') == {pert_order:1} and len(ii['particles']) == 3 : |
362 | masslist = [p.get('mass').lower() for p in ii['particles']] |
363 | - # check that there is at least a massless particle, and that the |
364 | - # remaining ones have the same mass |
365 | - # (otherwise the real emission final state will not be degenerate |
366 | - # with the born one |
367 | + |
368 | + # require that at least one particle be soft and of even spin for the interaction to be IR singular |
369 | + found_soft_even_spin_particle = False |
370 | + for p in ii['particles']: |
371 | + if p.get('mass').lower()=='zero': |
372 | + if p.get('spin')%2==1: |
373 | + found_soft_even_spin_particle = True |
374 | + break |
375 | + if not found_soft_even_spin_particle: |
376 | + continue |
377 | + |
378 | + # check that there is at least a massless particle, and that the |
379 | + # remaining ones have the same mass |
380 | + # (otherwise the real emission final state will not be degenerate |
381 | + # with the born one |
382 | try: |
383 | masslist.remove('zero') |
384 | except ValueError: |
385 | |
386 | === modified file 'madgraph/interface/common_run_interface.py' |
387 | --- madgraph/interface/common_run_interface.py 2019-01-16 11:18:08 +0000 |
388 | +++ madgraph/interface/common_run_interface.py 2019-05-16 09:35:25 +0000 |
389 | @@ -3677,7 +3677,7 @@ |
390 | madspin_cmd.mg5cmd.options.update(self.options) |
391 | for key, value in self.options.items(): |
392 | if isinstance(value, str): |
393 | - madspin_cmd.mg5cmd.exec_cmd( 'set %s %s' %(key,value), errorhandling=False, printcmd=False, precmd=False, postcmd=True) |
394 | + madspin_cmd.mg5cmd.exec_cmd( 'set %s %s --no_save' %(key,value), errorhandling=False, printcmd=False, precmd=False, postcmd=True) |
395 | madspin_cmd.cluster = self.cluster |
396 | |
397 | madspin_cmd.update_status = lambda *x,**opt: self.update_status(*x, level='madspin',**opt) |
398 | @@ -4481,7 +4481,7 @@ |
399 | if from_banner is None: |
400 | self.from_banner = {} |
401 | return |
402 | - misc.sprint(from_banner) |
403 | + |
404 | self.from_banner = {} |
405 | for card in from_banner: |
406 | self.from_banner[card] = banner.charge_card(card) |
407 | @@ -5190,7 +5190,6 @@ |
408 | def do_set(self, line): |
409 | """ edit the value of one parameter in the card""" |
410 | |
411 | - |
412 | args = self.split_arg(line) |
413 | |
414 | |
415 | @@ -5413,7 +5412,7 @@ |
416 | val = ' '.join(args[start+1:]) |
417 | val = val.split('#')[0] |
418 | else: |
419 | - val = args[start+1] |
420 | + val = ' '.join(args[start+1:]) |
421 | self.setR(args[start], val) |
422 | self.modified_card.add('run') # delayed writing of the run_card |
423 | # special mode for set run_card nocut T (generated by set no_parton_cut |
424 | @@ -6665,6 +6664,7 @@ |
425 | |
426 | if card_name == 'unknown': |
427 | logger.warning('Fail to determine the type of the file. Not copied') |
428 | + return |
429 | if card_name != 'banner': |
430 | logger.info('copy %s as %s' % (pathname, card_name)) |
431 | files.cp(path, self.paths[card_name.rsplit('_',1)[0]]) |
432 | |
433 | === modified file 'madgraph/interface/extended_cmd.py' |
434 | --- madgraph/interface/extended_cmd.py 2018-11-28 22:12:28 +0000 |
435 | +++ madgraph/interface/extended_cmd.py 2019-05-16 09:35:25 +0000 |
436 | @@ -1652,7 +1652,6 @@ |
437 | # filepath can be overwritten during the run (leading to weird results) |
438 | # Note also that we need a generator and not a list. |
439 | for line in self.inputfile: |
440 | - |
441 | #remove pointless spaces and \n |
442 | line = line.replace('\n', '').strip() |
443 | # execute the line |
444 | @@ -2332,11 +2331,11 @@ |
445 | elif line and hasattr(self, 'do_%s' % line.split()[0]): |
446 | # go to retry |
447 | reprint_opt = True |
448 | - elif self.value == 'repeat': |
449 | + elif self.value in ['repeat', 'reask']: |
450 | reprint_opt = True |
451 | else: |
452 | raise Exception |
453 | - except Exception, error: |
454 | + except Exception, error: |
455 | print """not valid argument. Valid argument are file path or value in (%s).""" \ |
456 | % ','.join(self.allow_arg) |
457 | print 'please retry' |
458 | @@ -2421,6 +2420,7 @@ |
459 | allowed_args += ['%s=%s;' % (key,s) for s in self.get_allowed(key)] |
460 | # adding special mode |
461 | allowed_args += [key[4:]+';' for key in dir(self) if key.startswith('ans_')] |
462 | + allowed_args += [arg[:-1] for arg in allowed_args if arg[-1] == ';'] |
463 | if 'allow_arg' in opts: |
464 | allowed_args += opts['allow_arg'] |
465 | del opts['allow_arg'] |
466 | |
467 | === modified file 'madgraph/interface/madevent_interface.py' |
468 | --- madgraph/interface/madevent_interface.py 2019-01-24 13:43:19 +0000 |
469 | +++ madgraph/interface/madevent_interface.py 2019-05-16 09:35:25 +0000 |
470 | @@ -2557,7 +2557,11 @@ |
471 | |
472 | |
473 | self.create_plot('parton') |
474 | - self.exec_cmd('store_events', postcmd=False) |
475 | + self.exec_cmd('store_events', postcmd=False) |
476 | + if self.run_card['boost_event'].strip() and self.run_card['boost_event'] != 'False': |
477 | + self.boost_events() |
478 | + |
479 | + |
480 | self.exec_cmd('reweight -from_cards', postcmd=False) |
481 | self.exec_cmd('decay_events -from_cards', postcmd=False) |
482 | if self.run_card['time_of_flight']>=0: |
483 | @@ -2580,6 +2584,49 @@ |
484 | self.results.current['cross'], |
485 | self.results.current['error'])) |
486 | |
487 | + def boost_events(self): |
488 | + |
489 | + if not self.run_card['boost_event']: |
490 | + return |
491 | + |
492 | + if self.run_card['boost_event'].startswith('lambda'): |
493 | + if not isinstance(self, cmd.CmdShell): |
494 | + raise Exception, "boost not allowed online" |
495 | + filter = eval(self.run_card['boost_event']) |
496 | + else: |
497 | + raise Exception |
498 | + |
499 | + path = [pjoin(self.me_dir, 'Events', self.run_name, 'unweighted_events.lhe.gz'), |
500 | + pjoin(self.me_dir, 'Events', self.run_name, 'unweighted_events.lhe'), |
501 | + pjoin(self.me_dir, 'Events', self.run_name, 'events.lhe.gz'), |
502 | + pjoin(self.me_dir, 'Events', self.run_name, 'events.lhe')] |
503 | + |
504 | + for p in path: |
505 | + if os.path.exists(p): |
506 | + event_path = p |
507 | + break |
508 | + else: |
509 | + raise Exception, "fail to find event file for the boost" |
510 | + |
511 | + |
512 | + lhe = lhe_parser.EventFile(event_path) |
513 | + with misc.TMP_directory() as tmp_dir: |
514 | + output = lhe_parser.EventFile(pjoin(tmp_dir, os.path.basename(event_path)), 'w') |
515 | + #write the banner to the output file |
516 | + output.write(lhe.banner) |
517 | + # Loop over all events |
518 | + for event in lhe: |
519 | + event.boost(filter) |
520 | + #write this modify event |
521 | + output.write(str(event)) |
522 | + output.write('</LesHouchesEvent>\n') |
523 | + lhe.close() |
524 | + files.mv(pjoin(tmp_dir, os.path.basename(event_path)), event_path) |
525 | + |
526 | + |
527 | + |
528 | + |
529 | + |
530 | def do_initMadLoop(self,line): |
531 | """Compile and run MadLoop for a certain number of PS point so as to |
532 | initialize MadLoop (setup the zero helicity and loop filter.)""" |
533 | @@ -3516,11 +3563,9 @@ |
534 | args = self.split_arg(line) |
535 | # Check argument's validity |
536 | self.check_combine_events(args) |
537 | - |
538 | self.update_status('Combining Events', level='parton') |
539 | |
540 | |
541 | - |
542 | if self.run_card['gridpack'] and isinstance(self, GridPackCmd): |
543 | return GridPackCmd.do_combine_events(self, line) |
544 | |
545 | @@ -3546,7 +3591,9 @@ |
546 | |
547 | partials = 0 # if too many file make some partial unweighting |
548 | sum_xsec, sum_xerru, sum_axsec = 0,[],0 |
549 | - for Gdir in self.get_Gdir(): |
550 | + Gdirs = self.get_Gdir() |
551 | + Gdirs.sort() |
552 | + for Gdir in Gdirs: |
553 | if os.path.exists(pjoin(Gdir, 'events.lhe')): |
554 | result = sum_html.OneResult('') |
555 | result.read_results(pjoin(Gdir, 'results.dat')) |
556 | @@ -3555,7 +3602,6 @@ |
557 | result.get('xerru'), |
558 | result.get('axsec') |
559 | ) |
560 | - |
561 | sum_xsec += result.get('xsec') |
562 | sum_xerru.append(result.get('xerru')) |
563 | sum_axsec += result.get('axsec') |
564 | @@ -3580,7 +3626,6 @@ |
565 | get_wgt, trunc_error=1e-2, event_target=self.run_card['nevents'], |
566 | log_level=logging.DEBUG, normalization=self.run_card['event_norm'], |
567 | proc_charac=self.proc_characteristic) |
568 | - |
569 | if partials: |
570 | for i in range(partials): |
571 | try: |
572 | @@ -5587,7 +5632,6 @@ |
573 | elif self.run_card['python_seed'] >= 0: |
574 | import random |
575 | random.seed(self.run_card['python_seed']) |
576 | - |
577 | if self.run_card['ickkw'] == 2: |
578 | logger.info('Running with CKKW matching') |
579 | self.treat_ckkw_matching() |
580 | @@ -5603,7 +5647,7 @@ |
581 | logger.info("compile Source Directory") |
582 | |
583 | # Compile |
584 | - for name in [ 'all', '../bin/internal/combine_events']: |
585 | + for name in [ 'all']:#, '../bin/internal/combine_events']: |
586 | self.compile(arg=[name], cwd=os.path.join(self.me_dir, 'Source')) |
587 | |
588 | bias_name = os.path.basename(self.run_card['bias_module']) |
589 | @@ -6193,7 +6237,7 @@ |
590 | |
591 | if not banner: |
592 | banner = self.banner |
593 | - |
594 | + |
595 | if auto: |
596 | self.ask_edit_cards(cards, from_banner=['param', 'run'], |
597 | mode='auto', plot=(pythia_version==6), banner=banner |
598 | @@ -6570,7 +6614,9 @@ |
599 | |
600 | partials = 0 # if too many file make some partial unweighting |
601 | sum_xsec, sum_xerru, sum_axsec = 0,[],0 |
602 | - for Gdir in self.get_Gdir(): |
603 | + Gdirs = self.get_Gdir() |
604 | + Gdirs.sort() |
605 | + for Gdir in Gdirs: |
606 | #mfactor already taken into accoun in auto_dsig.f |
607 | if os.path.exists(pjoin(Gdir, 'events.lhe')): |
608 | result = sum_html.OneResult('') |
609 | @@ -6617,71 +6663,6 @@ |
610 | if self.run_card['bias_module'].lower() not in ['dummy', 'none']: |
611 | self.correct_bias() |
612 | |
613 | - def do_combine_events_v4(self, line): |
614 | - """Advanced commands: Launch combine events""" |
615 | - |
616 | - args = self.split_arg(line) |
617 | - |
618 | - # Check argument's validity |
619 | - self.check_combine_events(args) |
620 | - |
621 | - self.update_status('Combining Events', level='parton') |
622 | - |
623 | - try: |
624 | - os.remove(pjoin(self.me_dir,'SubProcesses', 'combine.log')) |
625 | - except Exception: |
626 | - pass |
627 | - |
628 | - if not self.readonly: |
629 | - run_dir = pjoin(self.me_dir,'SubProcesses') |
630 | - stdout_file = pjoin(self.me_dir,'SubProcesses', 'combine.log') |
631 | - else: |
632 | - run_dir = pjoin('SubProcesses') |
633 | - stdout_file = pjoin('SubProcesses', 'combine.log') |
634 | - |
635 | - cluster.onecore.launch_and_wait('../bin/internal/run_combine', |
636 | - args=[self.run_name], |
637 | - cwd=run_dir, |
638 | - stdout=stdout_file, |
639 | - required_output=[pjoin(self.me_dir,'SubProcesses', 'combine.log')]) |
640 | - |
641 | - output = misc.mult_try_open(stdout_file).read() |
642 | - # Store the number of unweighted events for the results object |
643 | - pat = re.compile(r'''\s*Unweighting\s*selected\s*(\d+)\s*events''') |
644 | - try: |
645 | - nb_event = pat.search(output).groups()[0] |
646 | - except AttributeError: |
647 | - time.sleep(10) |
648 | - output = misc.mult_try_open(pjoin(self.me_dir,'SubProcesses','combine.log')).read() |
649 | - try: |
650 | - nb_event = pat.search(output).groups()[0] |
651 | - except AttributeError: |
652 | - logger.warning('Fail to read the number of unweighted events in the combine.log file') |
653 | - nb_event = 0 |
654 | - self.results.add_detail('nb_event', nb_event) |
655 | - |
656 | - # Define The Banner |
657 | - tag = self.run_card['run_tag'] |
658 | - |
659 | - # Update the banner with the pythia card |
660 | - if not self.banner: |
661 | - self.banner = banner_mod.recover_banner(self.results, 'parton') |
662 | - self.banner.load_basic(self.me_dir) |
663 | - # Add cross-section/event information |
664 | - self.banner.add_generation_info(self.results.current['cross'], nb_event) |
665 | - if not hasattr(self, 'random_orig'): self.random_orig = 0 |
666 | - self.banner.change_seed(self.random_orig) |
667 | - if not os.path.exists(pjoin(self.me_dir, 'Events', self.run_name)): |
668 | - os.mkdir(pjoin(self.me_dir, 'Events', self.run_name)) |
669 | - self.banner.write(pjoin(self.me_dir, 'Events', self.run_name, |
670 | - '%s_%s_banner.txt' % (self.run_name, tag))) |
671 | - |
672 | - |
673 | - self.banner.add_to_file(pjoin(self.me_dir,'Events', 'events.lhe'), |
674 | - out=pjoin(self.me_dir,'Events', self.run_name, 'events.lhe')) |
675 | - self.banner.add_to_file(pjoin(self.me_dir,'Events', 'unweighted_events.lhe'), |
676 | - out=pjoin(self.me_dir,'Events', self.run_name, 'unweighted_events.lhe')) |
677 | - |
678 | |
679 | class MadLoopInitializer(object): |
680 | """ A container class for the various methods for initializing MadLoop. It is |
681 | |
682 | === modified file 'madgraph/interface/madgraph_interface.py' |
683 | --- madgraph/interface/madgraph_interface.py 2019-02-03 21:24:20 +0000 |
684 | +++ madgraph/interface/madgraph_interface.py 2019-05-16 09:35:25 +0000 |
685 | @@ -339,6 +339,9 @@ |
686 | logger.info("") |
687 | logger.info(" import banner PATH [--no_launch]:",'$MG:BOLD') |
688 | logger.info(" Rerun the exact same run define in the valid banner.") |
689 | + logger.info("") |
690 | + logger.info(" import process PATH", '$MG:BOLD') |
691 | + logger.info(" generate the list of processes defined in the file") |
692 | |
693 | def help_install(self): |
694 | logger.info("syntax: install " + "|".join(self._install_opts),'$MG:color:BLUE') |
695 | @@ -1211,9 +1214,12 @@ |
696 | if not( 0 <= int(options.cluster) <= 2): |
697 | return self.InvalidCmd, 'cluster mode should be between 0 and 2' |
698 | |
699 | + misc.sprint(args) |
700 | if not args: |
701 | if self._done_export: |
702 | + misc.sprint(self._done_export) |
703 | mode = self.find_output_type(self._done_export[0]) |
704 | + misc.sprint(mode) |
705 | if (self._done_export[1] == 'plugin' and mode in self._export_formats): |
706 | args.append(mode) |
707 | args.append(self._done_export[0]) |
708 | @@ -1447,12 +1453,18 @@ |
709 | if not args[1].isdigit(): |
710 | raise self.InvalidCmd('%s values should be a integer' % args[0]) |
711 | |
712 | + if args[0] in ['low_mem_multicore_nlo_generation']: |
713 | + if sys.version_info[0] == 2 and sys.version_info[1] == 6: |
714 | + raise self.InvalidCmd('python2.6 does not support such functionalities please use python2.7') |
715 | + |
716 | + |
717 | if args[0] in ['loop_optimized_output', 'loop_color_flows', 'low_mem_multicore_nlo_generation']: |
718 | try: |
719 | args[1] = banner_module.ConfigFile.format_variable(args[1], bool, args[0]) |
720 | except Exception: |
721 | raise self.InvalidCmd('%s needs argument True or False'%args[0]) |
722 | |
723 | + |
724 | if args[0] in ['gauge']: |
725 | if args[1] not in ['unitary','Feynman']: |
726 | raise self.InvalidCmd('gauge needs argument unitary or Feynman.') |
727 | @@ -2780,7 +2792,7 @@ |
728 | _switch_opts = ['mg5','aMC@NLO','ML5'] |
729 | _check_opts = ['full', 'timing', 'stability', 'profile', 'permutation', |
730 | 'gauge','lorentz', 'brs', 'cms'] |
731 | - _import_formats = ['model_v4', 'model', 'proc_v4', 'command', 'banner'] |
732 | + _import_formats = ['model_v4', 'model', 'proc_v4', 'command', 'banner', 'process'] |
733 | _install_opts = ['Delphes', 'MadAnalysis4', 'ExRootAnalysis', |
734 | 'update', 'Golem95', 'PJFry', 'QCDLoop', 'maddm', 'maddump', |
735 | 'looptools'] |
736 | @@ -3002,8 +3014,13 @@ |
737 | standalone_only = False |
738 | if '--standalone' in args: |
739 | standalone_only = True |
740 | - args.remove('--standalone') |
741 | - |
742 | + args.remove('--standalone') |
743 | + |
744 | + allow_no_diagram = False |
745 | + if '--no_warning=nodiagram' in args: |
746 | + allow_no_diagram = True |
747 | + args.remove('--no_warning=nodiagram') |
748 | + |
749 | # Check the validity of the arguments |
750 | self.check_add(args) |
751 | |
752 | @@ -3081,6 +3098,14 @@ |
753 | " can only be given on one type of coupling and either on"+\ |
754 | " squared orders or amplitude orders, not both.") |
755 | |
756 | + if myprocdef.get_ninitial() ==1 and myprocdef.get('squared_orders'): |
757 | + logger.warning('''Computation of interference term with decay is not 100% validated. |
758 | + Please check carefully your result. |
759 | + One suggestion is also to compare the generation of your process with and without |
760 | + set group_subprocesses True |
761 | + (to write Before the generate command) |
762 | + ''') |
763 | + |
764 | cpu_time1 = time.time() |
765 | |
766 | # Generate processes |
767 | @@ -3092,13 +3117,18 @@ |
768 | self.options['ignore_six_quark_processes'] if \ |
769 | "ignore_six_quark_processes" in self.options \ |
770 | else [] |
771 | - |
772 | - myproc = diagram_generation.MultiProcess(myprocdef, |
773 | + try: |
774 | + myproc = diagram_generation.MultiProcess(myprocdef, |
775 | collect_mirror_procs = collect_mirror_procs, |
776 | ignore_six_quark_processes = ignore_six_quark_processes, |
777 | optimize=optimize, diagram_filter=diagram_filter) |
778 | - |
779 | - |
780 | + except diagram_generation.NoDiagramException: |
781 | + if not allow_no_diagram: |
782 | + raise |
783 | + else: |
784 | + logger.warning('no diagram generated. No error raised due to flag') |
785 | + return |
786 | + |
787 | for amp in myproc.get('amplitudes'): |
788 | if amp not in self._curr_amps: |
789 | self._curr_amps.append(amp) |
790 | @@ -4718,9 +4748,10 @@ |
791 | split_orders=list(set(perturbation_couplings_list+squared_orders.keys())) |
792 | try: |
793 | split_orders.sort(key=lambda elem: 0 if elem=='WEIGHTED' else |
794 | - self._curr_model['order_hierarchy'] |
795 | + self._curr_model.get('order_hierarchy') |
796 | [elem if not elem.endswith('.sqrt') else elem[:-5]]) |
797 | except KeyError: |
798 | + misc.sprint(self._curr_model['order_hierarchy'], self._curr_model.get('modelpath')) |
799 | raise self.InvalidCmd, "The loaded model does not defined a "+\ |
800 | " coupling order hierarchy for these couplings: %s"%\ |
801 | str([so for so in split_orders if so!='WEIGHTED' and so not |
802 | @@ -5219,6 +5250,7 @@ |
803 | complex_mass_scheme=self.options['complex_mass_scheme']) |
804 | if os.path.sep in args[1] and "import" in self.history[-1]: |
805 | self.history[-1] = 'import model %s' % self._curr_model.get('modelpath+restriction') |
806 | + #self._curr_model.get('order_hierarchy') |
807 | |
808 | if self.options['gauge']=='unitary': |
809 | if not force and isinstance(self._curr_model,\ |
810 | @@ -5271,7 +5303,23 @@ |
811 | self.check_for_export_dir(args[1]) |
812 | # Execute the card |
813 | self.import_command_file(args[1]) |
814 | - |
815 | + elif args[0] == 'process': |
816 | + if not os.path.isfile(args[1]): |
817 | + raise self.InvalidCmd("Path %s is not a valid pathname" % args[1]) |
818 | + else: |
819 | + first = True |
820 | + for line in open(args[1]): |
821 | + line = line.split('#')[0].strip() |
822 | + if not line: |
823 | + continue |
824 | + if first: |
825 | + self.exec_cmd('generate %s' % line, precmd=True) |
826 | + first = False |
827 | + else: |
828 | + self.exec_cmd('add process %s' % line, precmd=True) |
829 | + |
830 | + |
831 | + |
832 | elif args[0] == 'banner': |
833 | type = madevent_interface.MadEventCmd.detect_card_type(args[1]) |
834 | if type != 'banner': |
835 | @@ -5825,8 +5873,8 @@ |
836 | 'MadAnalysis':['arXiv:1206.1599'], |
837 | 'collier':['arXiv:1604.06792'], |
838 | 'oneloop':['arXiv:1007.4716'], |
839 | - 'maddm':['arXiv:1505.04190'], |
840 | - 'maddump':['arXiv:1806.xxxxx']} |
841 | + 'maddm':['arXiv:1804.00444'], |
842 | + 'maddump':['arXiv:1812.06771']} |
843 | |
844 | install_server = ['http://madgraph.phys.ucl.ac.be/package_info.dat', |
845 | 'http://madgraph.physics.illinois.edu/package_info.dat'] |
846 | @@ -6841,11 +6889,12 @@ |
847 | |
848 | args = self.split_arg(line) |
849 | # check argument validity and normalise argument |
850 | + print _launch_parser.print_help() |
851 | (options, args) = _launch_parser.parse_args(args) |
852 | self.check_launch(args, options) |
853 | options = options.__dict__ |
854 | # args is now MODE PATH |
855 | - |
856 | + misc.sprint(args[0]) |
857 | if args[0].startswith('standalone'): |
858 | if os.path.isfile(os.path.join(os.getcwd(),args[1],'Cards',\ |
859 | 'MadLoopParams.dat')) and not os.path.isfile(os.path.join(\ |
860 | @@ -8161,6 +8210,15 @@ |
861 | logger_mg.info('More info in temporary files:\n %s/index.html' % (decay_dir)) |
862 | with misc.MuteLogger(['madgraph','ALOHA','cmdprint','madevent'], [40,40,40,40]): |
863 | self.exec_cmd('output %s -f' % decay_dir,child=False) |
864 | + |
865 | + #modify some parameter of the default run_card |
866 | + run_card = banner_module.RunCard(pjoin(decay_dir,'Cards','run_card.dat')) |
867 | + if run_card['ickkw']: |
868 | + run_card['ickkw'] = 0 |
869 | + run_card['xqcut'] = 0 |
870 | + run_card.remove_all_cut() |
871 | + run_card.write(pjoin(decay_dir,'Cards','run_card.dat')) |
872 | + |
873 | # Need to write the correct param_card in the correct place !!! |
874 | if os.path.exists(opts['output']): |
875 | files.cp(opts['output'], pjoin(decay_dir, 'Cards', 'param_card.dat')) |
876 | |
877 | === modified file 'madgraph/interface/master_interface.py' |
878 | --- madgraph/interface/master_interface.py 2018-04-02 14:02:36 +0000 |
879 | +++ madgraph/interface/master_interface.py 2019-05-16 09:35:25 +0000 |
880 | @@ -272,6 +272,10 @@ |
881 | |
882 | def do_import(self, *args, **opts): |
883 | self.cmd.do_import(self, *args, **opts) |
884 | + line = args[0] |
885 | + import_mode = args[0].split()[0] |
886 | + if import_mode in self._import_formats and not import_mode.startswith('model'): |
887 | + return |
888 | if self._curr_model: |
889 | if isinstance(self._curr_model, loop_base_objects.LoopModel) and \ |
890 | self._curr_model['perturbation_couplings']!=[] and \ |
891 | @@ -610,6 +614,7 @@ |
892 | |
893 | def change_principal_cmd(self, name): |
894 | |
895 | + |
896 | old_cmd=self.current_interface |
897 | if name in self.interface_names.keys(): |
898 | self.prompt= self.interface_names[name][0]+'>' |
899 | |
900 | === modified file 'madgraph/interface/reweight_interface.py' |
901 | --- madgraph/interface/reweight_interface.py 2018-09-19 12:07:16 +0000 |
902 | +++ madgraph/interface/reweight_interface.py 2019-05-16 09:35:25 +0000 |
903 | @@ -1,3 +1,4 @@ |
904 | +#! /usr/bin/env python |
905 | ################################################################################ |
906 | # |
907 | # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors |
908 | @@ -26,8 +27,11 @@ |
909 | import subprocess |
910 | from subprocess import Popen, PIPE, STDOUT |
911 | |
912 | - |
913 | pjoin = os.path.join |
914 | +if "__main__" == __name__: |
915 | + local_path = os.path.dirname(os.path.realpath( __file__ )) |
916 | + root_path = pjoin(local_path, '..','..') |
917 | + sys.path.insert(0, root_path) |
918 | |
919 | import madgraph.interface.extended_cmd as extended_cmd |
920 | import madgraph.interface.madgraph_interface as mg_interface |
921 | @@ -66,13 +70,12 @@ |
922 | |
923 | prompt = 'Reweight>' |
924 | debug_output = 'Reweight_debug' |
925 | - rwgt_dir_possibility = ['rw_me','rw_me_second','rw_mevirt','rw_mevirt_second'] |
926 | + #rwgt_dir_possibility = ['rw_me','rw_me_second','rw_mevirt','rw_mevirt_second'] |
927 | |
928 | @misc.mute_logger() |
929 | def __init__(self, event_path=None, allow_madspin=False, mother=None, *completekey, **stdin): |
930 | """initialize the interface with potentially an event_path""" |
931 | |
932 | - |
933 | self.me_dir = os.getcwd() |
934 | if not event_path: |
935 | cmd_logger.info('************************************************************') |
936 | @@ -95,6 +98,7 @@ |
937 | self.f2pylib = {} |
938 | self.second_model = None |
939 | self.second_process = None |
940 | + self.nb_library = 1 |
941 | self.dedicated_path = {} |
942 | self.soft_threshold = None |
943 | self.systematics = False # allow to run systematics in ouput2.0 mode |
944 | @@ -154,6 +158,7 @@ |
945 | if not self.lhe_input.banner: |
946 | value = self.ask("What is the path to banner", 0, [0], "please enter a path", timeout=0) |
947 | self.lhe_input.banner = open(value).read() |
948 | + |
949 | self.banner = self.lhe_input.get_banner() |
950 | |
951 | #get original cross-section/error |
952 | @@ -359,6 +364,7 @@ |
953 | if self.has_standalone_dir: |
954 | self.terminate_fortran_executables() |
955 | self.has_standalone_dir = False |
956 | + |
957 | if args[-1] == "--add": |
958 | self.second_process.append(" ".join(args[1:-1])) |
959 | else: |
960 | @@ -463,6 +469,16 @@ |
961 | self.options['rwgt_name'] = opts['rwgt_name'] |
962 | |
963 | model_line = self.banner.get('proc_card', 'full_model_line') |
964 | + if not self.mother and not hasattr(self, 'output'): |
965 | + name, ext = self.lhe_input.name.rsplit('.',1) |
966 | + target = '%s_out.%s' % (name, ext) |
967 | + |
968 | + if os.path.exists(target) and os.path.getmtime(target) > os.path.getmtime(self.lhe_input.name): |
969 | + nb_launch = len([1 for l in self.history if l.strip().startswith('launch')]) |
970 | + if nb_launch > 1: |
971 | + files.mv(target, self.lhe_input.name) |
972 | + self.exec_cmd('import %s' % self.lhe_input.name) |
973 | + |
974 | |
975 | if not self.has_standalone_dir: |
976 | if self.rwgt_dir and os.path.exists(pjoin(self.rwgt_dir,'rw_me','rwgt.pkl')): |
977 | @@ -504,7 +520,7 @@ |
978 | path_me = self.me_dir |
979 | |
980 | if self.second_model or self.second_process or self.dedicated_path: |
981 | - rw_dir = pjoin(path_me, 'rw_me_second') |
982 | + rw_dir = pjoin(path_me, 'rw_me_%s' % self.nb_library) |
983 | else: |
984 | rw_dir = pjoin(path_me, 'rw_me') |
985 | |
986 | @@ -564,7 +580,7 @@ |
987 | if self.output_type == "default": |
988 | for name in weight: |
989 | if 'orig' in name: |
990 | - continue |
991 | + continue |
992 | event.reweight_data['%s%s' % (tag_name,name)] = weight[name] |
993 | #write this event with weight |
994 | output.write(str(event)) |
995 | @@ -581,7 +597,7 @@ |
996 | output[(tag_name,name)].write(str(new_evt)) |
997 | |
998 | # check normalisation of the events: |
999 | - if 'event_norm' in self.run_card: |
1000 | + if self.run_card and 'event_norm' in self.run_card: |
1001 | if self.run_card['event_norm'] in ['average','bias']: |
1002 | for key, value in cross.items(): |
1003 | cross[key] = value / (event_nb+1) |
1004 | @@ -630,14 +646,16 @@ |
1005 | import madgraph.interface.madevent_interface as ME_interface |
1006 | |
1007 | self.lhe_input.close() |
1008 | - if not self.mother: |
1009 | + if hasattr(self, 'output_path'): |
1010 | + target = self.output_path |
1011 | + elif not self.mother: |
1012 | name, ext = self.lhe_input.name.rsplit('.',1) |
1013 | target = '%s_out.%s' % (name, ext) |
1014 | elif self.output_type != "default" : |
1015 | target = pjoin(self.mother.me_dir, 'Events', run_name, 'events.lhe') |
1016 | else: |
1017 | target = self.lhe_input.name |
1018 | - |
1019 | + |
1020 | if self.output_type == "default": |
1021 | files.mv(output.name, target) |
1022 | logger.info('Event %s have now the additional weight' % self.lhe_input.name) |
1023 | @@ -692,7 +710,7 @@ |
1024 | path_me = self.me_dir |
1025 | |
1026 | if self.second_model or self.second_process or self.dedicated_path: |
1027 | - rw_dir = pjoin(path_me, 'rw_me_second') |
1028 | + rw_dir = pjoin(path_me, 'rw_me_%s' % self.nb_library) |
1029 | else: |
1030 | rw_dir = pjoin(path_me, 'rw_me') |
1031 | |
1032 | @@ -711,6 +729,8 @@ |
1033 | files.ln(ff.name, starting_dir=pjoin(path_me, 'rw_mevirt', 'Cards')) |
1034 | cmd = common_run_interface.CommonRunCmd.ask_edit_card_static(cards=['param_card.dat'], |
1035 | ask=self.ask, pwd=rw_dir, first_cmd=self.stored_line) |
1036 | + |
1037 | + |
1038 | self.stored_line = None |
1039 | |
1040 | # check for potential scan in the new card |
1041 | @@ -747,12 +767,10 @@ |
1042 | if 'initrwgt' in self.banner and self.output_type == 'default': |
1043 | if 'name=\'mg_reweighting\'' in self.banner['initrwgt']: |
1044 | blockpat = re.compile(r'''<weightgroup name=\'mg_reweighting\'\s*weight_name_strategy=\'includeIdInWeightName\'>(?P<text>.*?)</weightgroup>''', re.I+re.M+re.S) |
1045 | - misc.sprint(blockpat, self.banner['initrwgt']) |
1046 | before, content, after = blockpat.split(self.banner['initrwgt']) |
1047 | header_rwgt_other = before + after |
1048 | - pattern = re.compile('<weight id=\'(?:rwgt_(?P<id>\d+)|(?P<id2>[_\w]+))(?P<rwgttype>\s*|_\w+)\'>(?P<info>.*?)</weight>', re.S+re.I+re.M) |
1049 | + pattern = re.compile('<weight id=\'(?:rwgt_(?P<id>\d+)|(?P<id2>[_\w\-]+))(?P<rwgttype>\s*|_\w+)\'>(?P<info>.*?)</weight>', re.S+re.I+re.M) |
1050 | mg_rwgt_info = pattern.findall(content) |
1051 | - |
1052 | maxid = 0 |
1053 | for k,(i, fulltag, nlotype, diff) in enumerate(mg_rwgt_info): |
1054 | if i: |
1055 | @@ -795,12 +813,19 @@ |
1056 | else: |
1057 | tag = str(rewgtid) |
1058 | |
1059 | + version = misc.get_pkg_info()['version'] |
1060 | + model_version = self.mg5cmd._curr_model['model_info']['version'] |
1061 | + |
1062 | + str_version = "<weight_generator>MG5aMC_v%s</weight_generator>\n<weight_model_version>%s</weight_model_version>" %\ |
1063 | + (version, model_version) |
1064 | + |
1065 | if not self.second_model and not self.dedicated_path: |
1066 | old_param = check_param_card.ParamCard(s_orig.splitlines()) |
1067 | new_param = self.new_param_card |
1068 | card_diff = old_param.create_diff(new_param) |
1069 | if card_diff == '' and not self.second_process: |
1070 | logger.warning(' REWEIGHTING: original card and new card are identical.') |
1071 | + card_diff = "%s\n<weight_slha>%s</weight_slha>" % (str_version,card_diff) |
1072 | try: |
1073 | if old_param['sminputs'].get(3)- new_param['sminputs'].get(3) > 1e-3 * new_param['sminputs'].get(3): |
1074 | logger.warning("We found different value of alpha_s. Note that the value of alpha_s used is the one associate with the event and not the one from the cards.") |
1075 | @@ -812,6 +837,7 @@ |
1076 | mg_rwgt_info.append((tag, name, card_diff)) |
1077 | else: |
1078 | str_proc = "\n change process ".join([""]+self.second_process) |
1079 | + str_proc = "\n<weight_card>\n%s\n</weight_card>\n" |
1080 | for name in type_rwgt: |
1081 | mg_rwgt_info.append((tag, name, str_proc + '\n'+ card_diff)) |
1082 | else: |
1083 | @@ -824,8 +850,8 @@ |
1084 | if self.dedicated_path: |
1085 | for k,v in self.dedicated_path.items(): |
1086 | str_info += "\n change %s %s" % (k,v) |
1087 | - card_diff = str_info |
1088 | - str_info += '\n' + s_new |
1089 | + card_diff = '<weight_slha>\n%s\n</weight_slha>' % str_info |
1090 | + str_info = '\n<weight_card>\n%s\n</weight_card>\n%s\n<weight_slha>\n%s</weight_slha>\n' % (str_info,str_version,s_new) |
1091 | for name in type_rwgt: |
1092 | mg_rwgt_info.append((tag, name, str_info)) |
1093 | # re-create the banner. |
1094 | @@ -845,8 +871,11 @@ |
1095 | self.banner['initrwgt'] = self.banner['initrwgt'].replace('\n\n', '\n') |
1096 | |
1097 | logger.info('starts to compute weight for events with the following modification to the param_card:') |
1098 | - logger.info(card_diff.replace('\n','\nKEEP:')) |
1099 | - self.run_card = banner.Banner(self.banner).charge_card('run_card') |
1100 | + #logger.info(card_diff.replace('\n','\nKEEP:')) |
1101 | + try: |
1102 | + self.run_card = banner.Banner(self.banner).charge_card('run_card') |
1103 | + except Exception: |
1104 | + self.run_card = None |
1105 | |
1106 | if self.options['rwgt_name']: |
1107 | tag_name = self.options['rwgt_name'] |
1108 | @@ -857,7 +886,7 @@ |
1109 | for (path,tag), module in self.f2pylib.items(): |
1110 | with misc.chdir(pjoin(os.path.dirname(rw_dir), path)): |
1111 | with misc.stdchannel_redirected(sys.stdout, os.devnull): |
1112 | - if 'second' in path or tag == 3: |
1113 | + if 'rw_me_' in path or tag == 3: |
1114 | module.initialise(pjoin(rw_dir, 'Cards', 'param_card.dat')) |
1115 | else: |
1116 | module.initialise(pjoin(path_me, 'rw_me', 'Cards', 'param_card_orig.dat')) |
1117 | @@ -985,6 +1014,7 @@ |
1118 | misc.sprint(nhel, Pdir, hel_dict) |
1119 | raise Exception, "Invalid matrix element for original computation (weight=0)" |
1120 | |
1121 | + |
1122 | return {'orig': orig_wgt, '': w_new/w_orig*orig_wgt*jac} |
1123 | |
1124 | def calculate_nlo_weight(self, event): |
1125 | @@ -1154,14 +1184,20 @@ |
1126 | if (not self.second_model and not self.second_process and not self.dedicated_path) or hypp_id==0: |
1127 | orig_order, Pdir, hel_dict = self.id_to_path[tag] |
1128 | else: |
1129 | - orig_order, Pdir, hel_dict = self.id_to_path_second[tag] |
1130 | + if tag in self.id_to_path_second: |
1131 | + orig_order, Pdir, hel_dict = self.id_to_path_second[tag] |
1132 | + else: |
1133 | + return 0.0 |
1134 | |
1135 | base = os.path.basename(os.path.dirname(Pdir)) |
1136 | - if '_second' in base: |
1137 | + if base == 'rw_me': |
1138 | + moduletag = (base, 2+hypp_id) |
1139 | + else: |
1140 | moduletag = (base, 2) |
1141 | - else: |
1142 | - moduletag = (base, 2+hypp_id) |
1143 | + |
1144 | + |
1145 | |
1146 | + |
1147 | module = self.f2pylib[moduletag] |
1148 | |
1149 | p = event.get_momenta(orig_order) |
1150 | @@ -1171,7 +1207,7 @@ |
1151 | if self.helicity_reweighting and 9 not in hel_order: |
1152 | nhel = hel_dict[tuple(hel_order)] |
1153 | else: |
1154 | - nhel = -1 |
1155 | + nhel = -2 |
1156 | |
1157 | # For 2>N pass in the center of mass frame |
1158 | # - required for helicity by helicity re-weighitng |
1159 | @@ -1187,10 +1223,29 @@ |
1160 | p = self.invert_momenta(p) |
1161 | pdg = list(orig_order[0])+list(orig_order[1]) |
1162 | |
1163 | + |
1164 | +# sa_text = """ |
1165 | +# import allmatrix2py |
1166 | +# allmatrix2py.initialise(\"%(path)s\") |
1167 | +# pdg = %(pdg)s |
1168 | +# p = %(p)s |
1169 | +# aqcd = %(as)s |
1170 | +# scale2 = %(scale2)s |
1171 | +# nhel = %(nhel)s |
1172 | +# allmatrix2py.smatrixhel(pdg,p, aqcd, scale2, nhel) |
1173 | +# """% {'path': pjoin(os.path.dirname(module.__file__),'..', 'Cards', 'param_card.dat'), |
1174 | +# 'pdg': str(pdg), |
1175 | +# 'p': str(p), |
1176 | +# 'as':event.aqcd, |
1177 | +# 'scale2':scale2, |
1178 | +# 'nhel':nhel} |
1179 | +# misc.sprint(sa_text) |
1180 | + |
1181 | + |
1182 | with misc.chdir(Pdir): |
1183 | with misc.stdchannel_redirected(sys.stdout, os.devnull): |
1184 | - me_value = module.smatrixhel(pdg,p, event.aqcd, scale2, nhel) |
1185 | - |
1186 | + me_value = module.smatrixhel(pdg, event.ievent, p, event.aqcd, scale2, nhel) |
1187 | + |
1188 | # for loop we have also the stability status code |
1189 | if isinstance(me_value, tuple): |
1190 | me_value, code = me_value |
1191 | @@ -1198,7 +1253,7 @@ |
1192 | hundred_value = (code % 1000) //100 |
1193 | if hundred_value in [4]: |
1194 | me_value = 0. |
1195 | - |
1196 | + |
1197 | return me_value |
1198 | |
1199 | def terminate_fortran_executables(self, new_card_only=False): |
1200 | @@ -1304,10 +1359,13 @@ |
1201 | nlo_order = nlo_order.replace('noborn', 'virt') |
1202 | commandline += "add process %s [%s] %s;" % (base,nlo_order,post) |
1203 | commandline = commandline.replace('add process', 'generate',1) |
1204 | - logger.info("RETRY with %s", commandline) |
1205 | - mgcmd.exec_cmd(commandline, precmd=True) |
1206 | - has_nlo = False |
1207 | + if commandline: |
1208 | + logger.info("RETRY with %s", commandline) |
1209 | + mgcmd.exec_cmd(commandline, precmd=True) |
1210 | + has_nlo = False |
1211 | except Exception, error: |
1212 | + misc.sprint(mgcmd._curr_model.get('modelpath')) |
1213 | + misc.sprint(type(error)) |
1214 | raise |
1215 | |
1216 | commandline = 'output standalone_rw %s --prefix=int' % pjoin(path_me,data['paths'][0]) |
1217 | @@ -1404,6 +1462,7 @@ |
1218 | else: |
1219 | proc = proc.replace('[', '[ virt=') |
1220 | commandline += "add process %s ;" % proc |
1221 | + commandline = re.sub('@\s*\d+', '', commandline) |
1222 | # deactivate golem since it creates troubles |
1223 | old_options = dict(mgcmd.options) |
1224 | if mgcmd.options['golem'] or mgcmd.options['pjfry']: |
1225 | @@ -1499,7 +1558,13 @@ |
1226 | #self.id_to_path = {} |
1227 | #data['id2path'] = self.id_to_path |
1228 | else: |
1229 | - data['paths'] = ['rw_me_second', 'rw_mevirt_second'] |
1230 | + for key in self.f2pylib.keys(): |
1231 | + if 'rw_me_%s' % self.nb_library in key[0]: |
1232 | + del self.f2pylib[key] |
1233 | + |
1234 | + |
1235 | + self.nb_library += 1 |
1236 | + data['paths'] = ['rw_me_%s' % self.nb_library, 'rw_mevirt_%s' % self.nb_library] |
1237 | # model |
1238 | if self.second_model: |
1239 | data['mg_names'] = True |
1240 | @@ -1531,14 +1596,19 @@ |
1241 | else: |
1242 | path_me = self.rwgt_dir |
1243 | data['path'] = path_me |
1244 | - try: |
1245 | - shutil.rmtree(pjoin(path_me,data['paths'][0])) |
1246 | - except Exception: |
1247 | - pass |
1248 | - try: |
1249 | - shutil.rmtree(pjoin(path_me, data['paths'][1])) |
1250 | - except Exception: |
1251 | - pass |
1252 | + for i in range(2): |
1253 | + pdir = pjoin(path_me,data['paths'][i]) |
1254 | + if os.path.exists(pdir): |
1255 | + try: |
1256 | + shutil.rmtree(pjoin(path_me,data['paths'][0])) |
1257 | + except Exception, error: |
1258 | + misc.sprint(error) |
1259 | + pass |
1260 | + |
1261 | + |
1262 | + |
1263 | + |
1264 | + |
1265 | |
1266 | # 1. prepare the interface---------------------------------------------- |
1267 | mgcmd = self.mg5cmd |
1268 | @@ -1686,12 +1756,16 @@ |
1269 | path_me = self.me_dir |
1270 | else: |
1271 | path_me = self.rwgt_dir |
1272 | - for onedir in self.rwgt_dir_possibility: |
1273 | + |
1274 | + rwgt_dir_possibility = ['rw_me','rw_me_%s' % self.nb_library,'rw_mevirt','rw_mevirt_%s' % self.nb_library] |
1275 | + for onedir in rwgt_dir_possibility: |
1276 | if not os.path.isdir(pjoin(path_me,onedir)): |
1277 | continue |
1278 | pdir = pjoin(path_me, onedir, 'SubProcesses') |
1279 | if self.mother: |
1280 | nb_core = self.mother.options['nb_core'] if self.mother.options['run_mode'] !=0 else 1 |
1281 | + elif hasattr(self, 'nb_core'): |
1282 | + nb_core = self.nb_core |
1283 | else: |
1284 | nb_core = 1 |
1285 | os.environ['MENUM'] = '2' |
1286 | @@ -1710,7 +1784,8 @@ |
1287 | |
1288 | self.id_to_path = {} |
1289 | self.id_to_path_second = {} |
1290 | - for onedir in self.rwgt_dir_possibility: |
1291 | + rwgt_dir_possibility = ['rw_me','rw_me_%s' % self.nb_library,'rw_mevirt','rw_mevirt_%s' % self.nb_library] |
1292 | + for onedir in rwgt_dir_possibility: |
1293 | if not os.path.exists(pjoin(path_me,onedir)): |
1294 | continue |
1295 | pdir = pjoin(path_me, onedir, 'SubProcesses') |
1296 | @@ -1719,14 +1794,18 @@ |
1297 | mod_name = '%s.SubProcesses.allmatrix%spy' % (onedir, tag) |
1298 | #mymod = __import__('%s.SubProcesses.allmatrix%spy' % (onedir, tag), globals(), locals(), [],-1) |
1299 | if mod_name in sys.modules.keys(): |
1300 | + if 'rw_me_' in mod_name: |
1301 | + raise Exception |
1302 | del sys.modules[mod_name] |
1303 | tmp_mod_name = mod_name |
1304 | while '.' in tmp_mod_name: |
1305 | tmp_mod_name = tmp_mod_name.rsplit('.',1)[0] |
1306 | del sys.modules[tmp_mod_name] |
1307 | - mymod = __import__(mod_name, globals(), locals(), [],-1) |
1308 | + mymod = __import__(mod_name, globals(), locals(), [],-1) |
1309 | + reload(mymod) |
1310 | else: |
1311 | mymod = __import__(mod_name, globals(), locals(), [],-1) |
1312 | + |
1313 | |
1314 | S = mymod.SubProcesses |
1315 | mymod = getattr(S, 'allmatrix%spy' % tag) |
1316 | @@ -1739,12 +1818,16 @@ |
1317 | break |
1318 | |
1319 | data = self.id_to_path |
1320 | - if '_second' in onedir: |
1321 | + if onedir != "rw_me": |
1322 | data = self.id_to_path_second |
1323 | |
1324 | + |
1325 | + |
1326 | # get all the information |
1327 | all_pdgs = mymod.get_pdg_order() |
1328 | - all_pdgs = [[pdg for pdg in pdgs if pdg!=0] for pdgs in mymod.get_pdg_order()] |
1329 | + allids, all_pids = mymod.get_pdg_order() |
1330 | + all_pdgs = [[pdg for pdg in pdgs if pdg!=0] for pdgs in allids] |
1331 | + #all_pids = [pid for (pdgs, pid) in allids] |
1332 | all_prefix = [''.join(j).strip().lower() for j in mymod.get_prefix()] |
1333 | prefix_set = set(all_prefix) |
1334 | |
1335 | @@ -1767,7 +1850,7 @@ |
1336 | misc.sprint(os.path.exists(pjoin(path_me,onedir,'SubProcesses','MadLoop5_resources', '%sHelConfigs.dat' % prefix.upper()))) |
1337 | continue |
1338 | |
1339 | - for i,pdg in enumerate(all_pdgs): |
1340 | + for i,(pdg,pid) in enumerate(zip(all_pdgs,all_pids)): |
1341 | if self.is_decay: |
1342 | incoming = [pdg[0]] |
1343 | outgoing = pdg[1:] |
1344 | @@ -1899,10 +1982,111 @@ |
1345 | |
1346 | |
1347 | |
1348 | - |
1349 | - |
1350 | - |
1351 | - |
1352 | - |
1353 | - |
1354 | - |
1355 | +if "__main__" == __name__: |
1356 | + # Check if optimize mode is (and should be) activated |
1357 | + import optparse |
1358 | + # Write out nice usage message if called with -h or --help |
1359 | + usage = "usage: %prog [options] [FILE] " |
1360 | + parser = optparse.OptionParser(usage=usage) |
1361 | + parser.add_option("-l", "--logging", default='INFO', |
1362 | + help="logging level (DEBUG|INFO|WARNING|ERROR|CRITICAL) [%default]") |
1363 | + parser.add_option("-f", "--file", default='', |
1364 | + help="Use script file FILE") |
1365 | + parser.add_option("-d", "--mgme_dir", default='', dest = 'mgme_dir', |
1366 | + help="Use MG_ME directory MGME_DIR") |
1367 | + parser.add_option("","--debug", action="store_true", default=False, dest='debug', \ |
1368 | + help='force to launch debug mode') |
1369 | + (options, args) = parser.parse_args() |
1370 | + if len(args) == 0: |
1371 | + args = '' |
1372 | + |
1373 | + if __debug__ and not options.debug and \ |
1374 | + (not os.path.exists(os.path.join(root_path, 'bin','create_release.py'))): |
1375 | + subprocess.call([sys.executable] + ['-O'] + sys.argv) |
1376 | + sys.exit() |
1377 | + |
1378 | + |
1379 | + import logging |
1380 | + import logging.config |
1381 | + import madgraph.interface.coloring_logging |
1382 | + |
1383 | + try: |
1384 | + import readline |
1385 | + except ImportError: |
1386 | + try: |
1387 | + import pyreadline as readline |
1388 | + except: |
1389 | + print "For tab completion and history, install module readline." |
1390 | + else: |
1391 | + import rlcompleter |
1392 | + |
1393 | + if 'r261:67515' in sys.version and 'GCC 4.2.1 (Apple Inc. build 5646)' in sys.version: |
1394 | + readline.parse_and_bind("bind ^I rl_complete") |
1395 | + readline.__doc__ = 'libedit' |
1396 | + |
1397 | + elif hasattr(readline, '__doc__'): |
1398 | + if 'libedit' not in readline.__doc__: |
1399 | + readline.parse_and_bind("tab: complete") |
1400 | + else: |
1401 | + readline.parse_and_bind("bind ^I rl_complete") |
1402 | + else: |
1403 | + readline.__doc__ = 'GNU' |
1404 | + readline.parse_and_bind("tab: complete") |
1405 | + |
1406 | + # charge history file |
1407 | + try: |
1408 | + history_file = os.path.join(os.environ['HOME'], '.mg5', 'rwgthistory') |
1409 | + readline.read_history_file(history_file) |
1410 | + except: |
1411 | + pass |
1412 | + |
1413 | + try: |
1414 | + import psyco |
1415 | + psyco.full() |
1416 | + except: |
1417 | + pass |
1418 | + |
1419 | + try: |
1420 | + if __debug__ and options.logging == 'INFO': |
1421 | + options.logging = 'DEBUG' |
1422 | + logging.config.fileConfig(os.path.join(root_path, 'madgraph', 'interface', '.mg5_logging.conf')) |
1423 | + logging.root.setLevel(eval('logging.' + options.logging)) |
1424 | + logging.getLogger('madgraph').setLevel(eval('logging.' + options.logging)) |
1425 | + logging.getLogger('madevent').setLevel(eval('logging.' + options.logging)) |
1426 | + except: |
1427 | + pass |
1428 | + |
1429 | + # Call the cmd interface main loop |
1430 | + try: |
1431 | + if options.file or args: |
1432 | + # They are an input file |
1433 | + if args: |
1434 | + input_file = os.path.realpath(args[0]) |
1435 | + else: |
1436 | + input_file = os.path.realpath(options.file) |
1437 | + print "using input+file", input_file |
1438 | + cmd_line = ReweightInterface() |
1439 | + cmd_line.use_rawinput = False |
1440 | + cmd_line.haspiping = False |
1441 | + cmd_line.import_command_file(input_file) |
1442 | + cmd_line.run_cmd('quit') |
1443 | + else: |
1444 | + # Interactive mode |
1445 | + try: |
1446 | + cmd_line = ReweightInterface() |
1447 | + cmd_line.use_rawinput = True |
1448 | + cmd_line.cmdloop() |
1449 | + except: |
1450 | + pass |
1451 | + try: |
1452 | + cmd_line.exec_cmd('quit all', printcmd=False) |
1453 | + readline.set_history_length(100) |
1454 | + if not os.path.exists(os.path.join(os.environ['HOME'], '.mg5')): |
1455 | + os.mkdir(os.path.join(os.environ['HOME'], '.mg5')) |
1456 | + readline.write_history_file(history_file) |
1457 | + except Exception, error: |
1458 | + pass |
1459 | + except KeyboardInterrupt: |
1460 | + print 'writting history and quit on KeyboardInterrupt' |
1461 | + pass |
1462 | + |
1463 | |
1464 | === modified file 'madgraph/iolibs/export_v4.py' |
1465 | --- madgraph/iolibs/export_v4.py 2018-12-22 20:33:20 +0000 |
1466 | +++ madgraph/iolibs/export_v4.py 2019-05-16 09:35:25 +0000 |
1467 | @@ -2066,17 +2066,18 @@ |
1468 | |
1469 | template = """ |
1470 | %(python_information)s |
1471 | - subroutine smatrixhel(pdgs, npdg, p, ALPHAS, SCALE2, nhel, ANS) |
1472 | + subroutine smatrixhel(pdgs, procid, npdg, p, ALPHAS, SCALE2, nhel, ANS) |
1473 | IMPLICIT NONE |
1474 | |
1475 | CF2PY double precision, intent(in), dimension(0:3,npdg) :: p |
1476 | CF2PY integer, intent(in), dimension(npdg) :: pdgs |
1477 | +CF2PY integer, intent(in):: procid |
1478 | CF2PY integer, intent(in) :: npdg |
1479 | CF2PY double precision, intent(out) :: ANS |
1480 | CF2PY double precision, intent(in) :: ALPHAS |
1481 | CF2PY double precision, intent(in) :: SCALE2 |
1482 | integer pdgs(*) |
1483 | - integer npdg, nhel |
1484 | + integer npdg, nhel, procid |
1485 | double precision p(*) |
1486 | double precision ANS, ALPHAS, PI,SCALE2 |
1487 | include 'coupl.inc' |
1488 | @@ -2100,12 +2101,31 @@ |
1489 | RETURN |
1490 | END |
1491 | |
1492 | - subroutine get_pdg_order(PDG) |
1493 | + subroutine get_nincoming(pdgs, procid, npdg, N) |
1494 | + IMPLICIT NONE |
1495 | +CF2PY integer, intent(in), dimension(npdg) :: pdgs |
1496 | +CF2PY integer, intent(in):: procid |
1497 | +CF2PY integer, intent(in) :: npdg |
1498 | +CF2PY INTEGER, intent(out) :: N |
1499 | + integer pdgs(*) |
1500 | + integer npdg, procid |
1501 | + INTEGER N |
1502 | + %(nincoming)s |
1503 | + return |
1504 | + end |
1505 | + |
1506 | + subroutine get_pdg_order(PDG, PID) |
1507 | IMPLICIT NONE |
1508 | CF2PY INTEGER, intent(out) :: PDG(%(nb_me)i,%(maxpart)i) |
1509 | - INTEGER PDG(%(nb_me)i,%(maxpart)i), PDGS(%(nb_me)i,%(maxpart)i) |
1510 | +CF2PY INTEGER, intent(out) :: PID(%(nb_me)i) |
1511 | + |
1512 | + INTEGER PDG(%(nb_me)i,%(maxpart)i), PDGS(%(nb_me)i,%(maxpart)i) |
1513 | + INTEGER PID(%(nb_me)i),PIDs(%(nb_me)i) |
1514 | DATA PDGS/ %(pdgs)s / |
1515 | + DATA PIDS/ %(pids)s / |
1516 | + |
1517 | PDG = PDGS |
1518 | + PID = PIDS |
1519 | RETURN |
1520 | END |
1521 | |
1522 | @@ -2123,43 +2143,56 @@ |
1523 | |
1524 | allids = self.prefix_info.keys() |
1525 | allprefix = [self.prefix_info[key][0] for key in allids] |
1526 | - min_nexternal = min([len(ids) for ids in allids]) |
1527 | - max_nexternal = max([len(ids) for ids in allids]) |
1528 | + min_nexternal = min([len(ids[0]) for ids in allids]) |
1529 | + max_nexternal = max([len(ids[0]) for ids in allids]) |
1530 | |
1531 | info = [] |
1532 | - for key, (prefix, tag) in self.prefix_info.items(): |
1533 | - info.append('#PY %s : %s # %s' % (tag, key, prefix)) |
1534 | - |
1535 | + for (key, pid), (prefix, tag) in self.prefix_info.items(): |
1536 | + info.append('#PY %s : %s # %s %s' % (tag, key, prefix, pid)) |
1537 | |
1538 | text = [] |
1539 | + text_incomming = [] |
1540 | for n_ext in range(min_nexternal, max_nexternal+1): |
1541 | - current = [ids for ids in allids if len(ids)==n_ext] |
1542 | - if not current: |
1543 | + current_id = [ids[0] for ids in allids if len(ids[0])==n_ext] |
1544 | + current_pid = [ids[1] for ids in allids if len(ids[0])==n_ext] |
1545 | + if not current_id: |
1546 | continue |
1547 | if min_nexternal != max_nexternal: |
1548 | if n_ext == min_nexternal: |
1549 | text.append(' if (npdg.eq.%i)then' % n_ext) |
1550 | + text_incomming.append(' if (npdg.eq.%i)then' % n_ext) |
1551 | else: |
1552 | text.append(' else if (npdg.eq.%i)then' % n_ext) |
1553 | - for ii,pdgs in enumerate(current): |
1554 | + text_incomming.append(' else if (npdg.eq.%i)then' % n_ext) |
1555 | + for ii,pdgs in enumerate(current_id): |
1556 | + pid = current_pid[ii] |
1557 | + #misc.sprint([(i,pdg) for i,pdg in pdgs]) |
1558 | condition = '.and.'.join(['%i.eq.pdgs(%i)' %(pdg, i+1) for i, pdg in enumerate(pdgs)]) |
1559 | if ii==0: |
1560 | - text.append( ' if(%s) then ! %i' % (condition, i)) |
1561 | + text.append( ' if(%s.and.(procid.le.0.or.procid.eq.%d)) then ! %i' % (condition, pid, i)) |
1562 | + text_incomming.append( ' if(%s.and.(procid.le.0.or.procid.eq.%d)) then ! %i' % (condition, pid, i)) |
1563 | else: |
1564 | - text.append( ' else if(%s) then ! %i' % (condition,i)) |
1565 | - text.append(' call %ssmatrixhel(p, nhel, ans)' % self.prefix_info[pdgs][0]) |
1566 | + text.append( ' else if(%s.and.(procid.le.0.or.procid.eq.%d)) then ! %i' % (condition,pid,i)) |
1567 | + text_incomming.append( ' else if(%s.and.(procid.le.0.or.procid.eq.%d)) then ! %i' % (condition,pid,i)) |
1568 | + text.append(' call %ssmatrixhel(p, nhel, ans)' % self.prefix_info[(pdgs,pid)][0]) |
1569 | + text_incomming.append(' N=%i' % len(tag[0])) |
1570 | + |
1571 | text.append(' endif') |
1572 | + text_incomming.append(' endif') |
1573 | #close the function |
1574 | if min_nexternal != max_nexternal: |
1575 | text.append('endif') |
1576 | + text_incomming.append(' endif') |
1577 | |
1578 | formatting = {'python_information':'\n'.join(info), |
1579 | 'smatrixhel': '\n'.join(text), |
1580 | 'maxpart': max_nexternal, |
1581 | 'nb_me': len(allids), |
1582 | 'pdgs': ','.join(str(pdg[i]) if i<len(pdg) else '0' |
1583 | - for i in range(max_nexternal) for pdg in allids), |
1584 | - 'prefix':'\',\''.join(allprefix) |
1585 | + for i in range(max_nexternal) for (pdg,pid) in allids), |
1586 | + 'prefix':'\',\''.join(allprefix), |
1587 | + 'pids': ','.join(str(pid) for (pdg,pid) in allids), |
1588 | + 'nincoming':'\n'.join(text_incomming) |
1589 | } |
1590 | formatting['lenprefix'] = len(formatting['prefix']) |
1591 | text = template % formatting |
1592 | @@ -2257,7 +2290,7 @@ |
1593 | raise Exception, '--prefix options supports only \'int\' and \'proc\'' |
1594 | for proc in matrix_element.get('processes'): |
1595 | ids = [l.get('id') for l in proc.get('legs_with_decays')] |
1596 | - self.prefix_info[tuple(ids)] = [proc_prefix, proc.get_tag()] |
1597 | + self.prefix_info[(tuple(ids), proc.get('id'))] = [proc_prefix, proc.get_tag()] |
1598 | |
1599 | calls = self.write_matrix_element_v4( |
1600 | writers.FortranWriter(filename), |
1601 | @@ -2509,6 +2542,7 @@ |
1602 | else: |
1603 | matrix_template = "matrix_standalone_splitOrders_v4.inc" |
1604 | |
1605 | + |
1606 | replace_dict['template_file'] = pjoin(_file_path, 'iolibs', 'template_files', matrix_template) |
1607 | replace_dict['template_file2'] = pjoin(_file_path, \ |
1608 | 'iolibs/template_files/split_orders_helping_functions.inc') |
1609 | @@ -5688,8 +5722,14 @@ |
1610 | else: |
1611 | load_card = '' |
1612 | lha_read_filename='lha_read.f' |
1613 | - cp( MG5DIR + '/models/template_files/fortran/' + lha_read_filename, \ |
1614 | - os.path.join(self.dir_path,'lha_read.f')) |
1615 | + |
1616 | + nb_para= len(self.params_dep + self.params_indep + self.params_ext) |
1617 | + template = pjoin(MG5DIR, 'models', 'template_files', 'fortran', lha_read_filename) |
1618 | + open(os.path.join(self.dir_path,'lha_read.f'),'w').write( |
1619 | + open(template).read() % {'maxpara':nb_para}) |
1620 | + |
1621 | + #cp( MG5DIR + '/models/template_files/fortran/' + lha_read_filename, \ |
1622 | + # os.path.join(self.dir_path,'lha_read.f')) |
1623 | |
1624 | file=file%{'includes':'\n '.join(includes), |
1625 | 'load_card':load_card} |
1626 | |
1627 | === modified file 'madgraph/iolibs/template_files/madevent_makefile_source' |
1628 | --- madgraph/iolibs/template_files/madevent_makefile_source 2017-08-14 08:21:48 +0000 |
1629 | +++ madgraph/iolibs/template_files/madevent_makefile_source 2019-05-16 09:35:25 +0000 |
1630 | @@ -26,8 +26,7 @@ |
1631 | |
1632 | # Binaries |
1633 | |
1634 | -BINARIES = $(BINDIR)gen_ximprove $(BINDIR)combine_events \ |
1635 | - $(BINDIR)gensudgrid $(BINDIR)combine_runs |
1636 | +BINARIES = $(BINDIR)gen_ximprove $(BINDIR)gensudgrid $(BINDIR)combine_runs |
1637 | |
1638 | # Compile commands |
1639 | |
1640 | @@ -54,8 +53,8 @@ |
1641 | |
1642 | $(BINDIR)gen_ximprove: gen_ximprove.o ranmar.o rw_routines.o open_file.o |
1643 | $(FC) $(LDFLAGS) -o $@ $^ |
1644 | -$(BINDIR)combine_events: $(COMBINE) $(LIBDIR)libmodel.$(libext) $(LIBDIR)libpdf.$(libext) run_card.inc $(LIBDIR)libbias.$(libext) |
1645 | - $(FC) -o $@ $(COMBINE) -L$(LIBDIR) -lmodel -lpdf $(llhapdf) $(LDFLAGS) -lbias |
1646 | +#$(BINDIR)combine_events: $(COMBINE) $(LIBDIR)libmodel.$(libext) $(LIBDIR)libpdf.$(libext) run_card.inc $(LIBDIR)libbias.$(libext) |
1647 | +# $(FC) -o $@ $(COMBINE) -L$(LIBDIR) -lmodel -lpdf $(llhapdf) $(LDFLAGS) -lbias |
1648 | $(BINDIR)gensudgrid: $(GENSUDGRID) $(LIBDIR)libpdf.$(libext) $(LIBDIR)libcernlib.$(libext) |
1649 | $(FC) -o $@ $(GENSUDGRID) -L$(LIBDIR) -lmodel -lpdf -lcernlib $(llhapdf) $(LDFLAGS) |
1650 | |
1651 | @@ -66,7 +65,7 @@ |
1652 | invarients.o: invarients.f genps.inc |
1653 | setrun.o: setrun.f nexternal.inc leshouche.inc genps.inc |
1654 | gen_ximprove.o: gen_ximprove.f run_config.inc run_card.inc |
1655 | -combine_events.o: combine_events.f run_config.inc run_card.inc |
1656 | +#combine_events.o: combine_events.f run_config.inc run_card.inc |
1657 | combine_runs.o: combine_runs.f run_config.inc run_card.inc |
1658 | select_events.o: select_events.f run_config.inc |
1659 | setrun.o: setrun.f nexternal.inc leshouche.inc run_card.inc run_config.inc |
1660 | |
1661 | === modified file 'madgraph/iolibs/template_files/matrix_standalone_splitOrders_v4.inc' |
1662 | --- madgraph/iolibs/template_files/matrix_standalone_splitOrders_v4.inc 2018-05-17 12:03:54 +0000 |
1663 | +++ madgraph/iolibs/template_files/matrix_standalone_splitOrders_v4.inc 2019-05-16 09:35:25 +0000 |
1664 | @@ -127,24 +127,27 @@ |
1665 | C ---------- |
1666 | C BEGIN CODE |
1667 | C ---------- |
1668 | - NTRY=NTRY+1 |
1669 | - DO IHEL=1,NEXTERNAL |
1670 | - JC(IHEL) = +1 |
1671 | - ENDDO |
1672 | - DO I=1,NSQAMPSO |
1673 | - ANS(I) = 0D0 |
1674 | - ENDDO |
1675 | C When spin-2 particles are involved, the Helicity filtering is dangerous for the 2->1 topology. |
1676 | C This is because depending on the MC setup the initial PS points have back-to-back initial states |
1677 | C for which some of the spin-2 helicity configurations are zero. But they are no longer zero |
1678 | C if the point is boosted on the z-axis. Remember that HELAS helicity amplitudes are no longer |
1679 | C lorentz invariant with expternal spin-2 particles (only the helicity sum is). |
1680 | C For this reason, we simply remove the filterin when there is only three external particles. |
1681 | - IF (NEXTERNAL.LE.3) THEN |
1682 | + IF(USERHEL.EQ.-2.OR.NEXTERNAL.LE.3) THEN |
1683 | DO IHEL=1,NCOMB |
1684 | GOODHEL(IHEL)=.TRUE. |
1685 | ENDDO |
1686 | + IF(USERHEL.EQ.-2) USERHEL = -1 |
1687 | ENDIF |
1688 | + |
1689 | + NTRY=NTRY+1 |
1690 | + DO IHEL=1,NEXTERNAL |
1691 | + JC(IHEL) = +1 |
1692 | + ENDDO |
1693 | + DO I=1,NSQAMPSO |
1694 | + ANS(I) = 0D0 |
1695 | + ENDDO |
1696 | + |
1697 | DO IHEL=1,NCOMB |
1698 | IF (USERHEL.EQ.-1.OR.USERHEL.EQ.IHEL) THEN |
1699 | IF (GOODHEL(IHEL) .OR. NTRY .LT. 2 .OR.USERHEL.NE.-1) THEN |
1700 | |
1701 | === modified file 'madgraph/iolibs/template_files/matrix_standalone_v4.inc' |
1702 | --- madgraph/iolibs/template_files/matrix_standalone_v4.inc 2018-05-17 12:03:54 +0000 |
1703 | +++ madgraph/iolibs/template_files/matrix_standalone_v4.inc 2019-05-16 09:35:25 +0000 |
1704 | @@ -78,7 +78,6 @@ |
1705 | LOGICAL GOODHEL(NCOMB) |
1706 | DATA NTRY/0/ |
1707 | DATA GOODHEL/NCOMB*.FALSE./ |
1708 | - |
1709 | C |
1710 | C GLOBAL VARIABLES |
1711 | C |
1712 | @@ -101,21 +100,22 @@ |
1713 | C ---------- |
1714 | C BEGIN CODE |
1715 | C ---------- |
1716 | - IF(USERHEL.EQ.-1) NTRY=NTRY+1 |
1717 | - DO IHEL=1,NEXTERNAL |
1718 | - JC(IHEL) = +1 |
1719 | - ENDDO |
1720 | C When spin-2 particles are involved, the Helicity filtering is dangerous for the 2->1 topology. |
1721 | C This is because depending on the MC setup the initial PS points have back-to-back initial states |
1722 | C for which some of the spin-2 helicity configurations are zero. But they are no longer zero |
1723 | C if the point is boosted on the z-axis. Remember that HELAS helicity amplitudes are no longer |
1724 | C lorentz invariant with expternal spin-2 particles (only the helicity sum is). |
1725 | C For this reason, we simply remove the filterin when there is only three external particles. |
1726 | - IF (NEXTERNAL.LE.3) THEN |
1727 | - DO IHEL=1,NCOMB |
1728 | - GOODHEL(IHEL)=.TRUE. |
1729 | - ENDDO |
1730 | + IF(USERHEL.EQ.-2.OR.NEXTERNAL.LE.3) THEN |
1731 | + DO IHEL=1,NCOMB |
1732 | + GOODHEL(IHEL)=.TRUE. |
1733 | + ENDDO |
1734 | + IF(USERHEL.EQ.-2) USERHEL=-1 |
1735 | ENDIF |
1736 | + IF(USERHEL.EQ.-1) NTRY=NTRY+1 |
1737 | + DO IHEL=1,NEXTERNAL |
1738 | + JC(IHEL) = +1 |
1739 | + ENDDO |
1740 | ANS = 0D0 |
1741 | DO IHEL=1,NCOMB |
1742 | IF (USERHEL.EQ.-1.OR.USERHEL.EQ.IHEL) THEN |
1743 | |
1744 | === modified file 'madgraph/iolibs/template_files/pythia8/pythia8_model_parameters_cc.inc' |
1745 | --- madgraph/iolibs/template_files/pythia8/pythia8_model_parameters_cc.inc 2015-09-14 15:08:12 +0000 |
1746 | +++ madgraph/iolibs/template_files/pythia8/pythia8_model_parameters_cc.inc 2019-05-16 09:35:25 +0000 |
1747 | @@ -7,48 +7,50 @@ |
1748 | #include "Parameters_%(model_name)s.h" |
1749 | #include "%(include_prefix)sPythiaStdlib.h" |
1750 | |
1751 | -namespace Pythia8 { |
1752 | - |
1753 | - // Initialize static instance |
1754 | - Parameters_%(model_name)s* Parameters_%(model_name)s::instance = 0; |
1755 | - |
1756 | - // Function to get static instance - only one instance per program |
1757 | - Parameters_%(model_name)s* Parameters_%(model_name)s::getInstance(){ |
1758 | - if (instance == 0) |
1759 | - instance = new Parameters_%(model_name)s(); |
1760 | - |
1761 | - return instance; |
1762 | - } |
1763 | - |
1764 | - void Parameters_%(model_name)s::setIndependentParameters(ParticleData*& pd, Couplings*& csm, SusyLesHouches*& slhaPtr){ |
1765 | - %(set_independent_parameters)s |
1766 | - } |
1767 | - void Parameters_%(model_name)s::setIndependentCouplings(){ |
1768 | - %(set_independent_couplings)s |
1769 | - } |
1770 | - void Parameters_%(model_name)s::setDependentParameters(ParticleData*& pd, Couplings*& csm, SusyLesHouches*& slhaPtr, double alpS){ |
1771 | - %(set_dependent_parameters)s |
1772 | - } |
1773 | - void Parameters_%(model_name)s::setDependentCouplings(){ |
1774 | - %(set_dependent_couplings)s |
1775 | - } |
1776 | - |
1777 | - // Routines for printing out parameters |
1778 | - void Parameters_%(model_name)s::printIndependentParameters(){ |
1779 | - cout << "%(model_name)s model parameters independent of event kinematics:" << endl; |
1780 | - %(print_independent_parameters)s |
1781 | - } |
1782 | - void Parameters_%(model_name)s::printIndependentCouplings(){ |
1783 | - cout << "%(model_name)s model couplings independent of event kinematics:" << endl; |
1784 | - %(print_independent_couplings)s |
1785 | - } |
1786 | - void Parameters_%(model_name)s::printDependentParameters(){ |
1787 | - cout << "%(model_name)s model parameters dependent on event kinematics:" << endl; |
1788 | - %(print_dependent_parameters)s |
1789 | - } |
1790 | - void Parameters_%(model_name)s::printDependentCouplings(){ |
1791 | - cout << "%(model_name)s model couplings dependent on event kinematics:" << endl; |
1792 | - %(print_dependent_couplings)s |
1793 | - } |
1794 | - |
1795 | -} // end namespace Pythia8 |
1796 | +using namespace Pythia8; |
1797 | + |
1798 | +// Initialize static instance |
1799 | +Parameters_%(model_name)s* Parameters_%(model_name)s::instance = 0; |
1800 | + |
1801 | +// Function to get static instance - only one instance per program |
1802 | +Parameters_%(model_name)s* Parameters_%(model_name)s::getInstance(){ |
1803 | +if (instance == 0) |
1804 | + instance = new Parameters_%(model_name)s(); |
1805 | + |
1806 | +return instance; |
1807 | +} |
1808 | + |
1809 | +void Parameters_%(model_name)s::setIndependentParameters(ParticleData*& pd, Couplings*& csm, SusyLesHouches*& slhaPtr){ |
1810 | +%(set_independent_parameters)s |
1811 | +} |
1812 | +void Parameters_%(model_name)s::setIndependentCouplings(){ |
1813 | +%(set_independent_couplings)s |
1814 | +} |
1815 | +/* |
1816 | +void Parameters_%(model_name)s::setDependentParameters(ParticleData*& pd, Couplings*& csm, SusyLesHouches*& slhaPtr, double alpS){ |
1817 | +%(set_dependent_parameters)s |
1818 | +} |
1819 | +*/ |
1820 | + |
1821 | +void Parameters_%(model_name)s::setDependentCouplings(){ |
1822 | +%(set_dependent_couplings)s |
1823 | +} |
1824 | + |
1825 | +// Routines for printing out parameters |
1826 | +void Parameters_%(model_name)s::printIndependentParameters(){ |
1827 | +cout << "%(model_name)s model parameters independent of event kinematics:" << endl; |
1828 | +%(print_independent_parameters)s |
1829 | +} |
1830 | +void Parameters_%(model_name)s::printIndependentCouplings(){ |
1831 | +cout << "%(model_name)s model couplings independent of event kinematics:" << endl; |
1832 | +%(print_independent_couplings)s |
1833 | +} |
1834 | +void Parameters_%(model_name)s::printDependentParameters(){ |
1835 | +cout << "%(model_name)s model parameters dependent on event kinematics:" << endl; |
1836 | +%(print_dependent_parameters)s |
1837 | +} |
1838 | +void Parameters_%(model_name)s::printDependentCouplings(){ |
1839 | +cout << "%(model_name)s model couplings dependent on event kinematics:" << endl; |
1840 | +%(print_dependent_couplings)s |
1841 | +} |
1842 | + |
1843 | |
1844 | === modified file 'madgraph/iolibs/template_files/pythia8/pythia8_model_parameters_h.inc' |
1845 | --- madgraph/iolibs/template_files/pythia8/pythia8_model_parameters_h.inc 2015-09-14 15:08:12 +0000 |
1846 | +++ madgraph/iolibs/template_files/pythia8/pythia8_model_parameters_h.inc 2019-05-16 09:35:25 +0000 |
1847 | @@ -14,7 +14,7 @@ |
1848 | |
1849 | using namespace std; |
1850 | |
1851 | -namespace Pythia8 { |
1852 | +using namespace Pythia8; |
1853 | |
1854 | class Parameters_%(model_name)s |
1855 | { |
1856 | @@ -32,7 +32,11 @@ |
1857 | // Set couplings that are unchanged during the run |
1858 | void setIndependentCouplings(); |
1859 | // Set parameters that are changed event by event |
1860 | -void setDependentParameters(ParticleData*& pd, Couplings*& csm, SusyLesHouches*& slhaPtr, double alpS); |
1861 | +//void setDependentParameters(ParticleData*& pd, Couplings*& csm, SusyLesHouches*& slhaPtr, double alpS); |
1862 | +// TMP: hardcoded bogus implementation with no arguments since this |
1863 | +// is being called from within the matrix elements. |
1864 | +void setDependentParameters() {}; |
1865 | + |
1866 | // Set couplings that are changed event by event |
1867 | void setDependentCouplings(); |
1868 | |
1869 | @@ -45,10 +49,8 @@ |
1870 | // Print couplings that are changed event by event |
1871 | void printDependentCouplings(); |
1872 | |
1873 | - |
1874 | private: |
1875 | static Parameters_%(model_name)s* instance; |
1876 | }; |
1877 | |
1878 | -} // end namespace Pythia8 |
1879 | #endif // Pythia8_parameters_%(model_name)s_H |
1880 | |
1881 | === modified file 'madgraph/various/banner.py' |
1882 | --- madgraph/various/banner.py 2018-12-18 20:16:08 +0000 |
1883 | +++ madgraph/various/banner.py 2019-05-16 09:35:25 +0000 |
1884 | @@ -384,9 +384,12 @@ |
1885 | header = open(pjoin(MG5DIR,'Template', 'LO', 'Source', 'banner_header.txt')).read() |
1886 | |
1887 | if not self.lhe_version: |
1888 | - self.lhe_version = self.get('run_card', 'lhe_version', default=1.0) |
1889 | - if float(self.lhe_version) < 3: |
1890 | - self.lhe_version = 1.0 |
1891 | + if 'mgruncard' in self: |
1892 | + self.lhe_version = self.get('run_card', 'lhe_version', default=1.0) |
1893 | + if float(self.lhe_version) < 3: |
1894 | + self.lhe_version = 1.0 |
1895 | + else: |
1896 | + self.lhe_version = 3.0 |
1897 | |
1898 | ff.write(header % { 'version':float(self.lhe_version)}) |
1899 | |
1900 | @@ -686,13 +689,20 @@ |
1901 | try: |
1902 | _tag = results_object[run].tags[-1] |
1903 | except Exception,error: |
1904 | - return Banner() |
1905 | + if os.path.exists( pjoin(results_object.path,'Events','%s_banner.txt' % (run))): |
1906 | + tag = None |
1907 | + else: |
1908 | + return Banner() |
1909 | else: |
1910 | _tag = tag |
1911 | - |
1912 | - path = results_object.path |
1913 | - banner_path = pjoin(path,'Events',run,'%s_%s_banner.txt' % (run, tag)) |
1914 | - |
1915 | + |
1916 | + if tag: |
1917 | + path = results_object.path |
1918 | + banner_path = pjoin(path,'Events',run,'%s_%s_banner.txt' % (run, tag)) |
1919 | + else: |
1920 | + banner_path = pjoin(results_object.path,'Events','%s_banner.txt' % (run)) |
1921 | + |
1922 | + |
1923 | if not os.path.exists(banner_path): |
1924 | if level != "parton" and tag != _tag: |
1925 | return recover_banner(results_object, level, _run, results_object[_run].tags[0]) |
1926 | @@ -712,6 +722,7 @@ |
1927 | |
1928 | # security if the banner was remove (or program canceled before created it) |
1929 | return Banner() |
1930 | + |
1931 | banner = Banner(banner_path) |
1932 | |
1933 | |
1934 | @@ -2744,8 +2755,26 @@ |
1935 | # |
1936 | """, |
1937 | template_off= '# Syscalc is deprecated but to see the associate options type\'update syscalc\''), |
1938 | - ] |
1939 | - |
1940 | + |
1941 | +# ECUT block (hidden it by default but for e+ e- collider) |
1942 | + runblock(name='ecut', fields=('ej','eb','ea','el','ejmax','ebmax','eamax','elmax','e_min_pdg','e_max_pdg'), |
1943 | + template_on=\ |
1944 | +"""#********************************************************************* |
1945 | +# Minimum and maximum E's (in the center of mass frame) * |
1946 | +#********************************************************************* |
1947 | + %(ej)s = ej ! minimum E for the jets |
1948 | + %(eb)s = eb ! minimum E for the b |
1949 | + %(ea)s = ea ! minimum E for the photons |
1950 | + %(el)s = el ! minimum E for the charged leptons |
1951 | + %(ejmax)s = ejmax ! maximum E for the jets |
1952 | + %(ebmax)s = ebmax ! maximum E for the b |
1953 | + %(eamax)s = eamax ! maximum E for the photons |
1954 | + %(elmax)s = elmax ! maximum E for the charged leptons |
1955 | + %(e_min_pdg)s = e_min_pdg ! E cut for other particles (use pdg code). Applied on particle and anti-particle |
1956 | + %(e_max_pdg)s = e_max_pdg ! E cut for other particles (syntax e.g. {6: 100, 25: 50}) |
1957 | +""", |
1958 | + template_off= '#\n# For display option for energy cut in the partonic center of mass frame type \'update ecut\'\n#'), |
1959 | + ] |
1960 | |
1961 | |
1962 | def default_setup(self): |
1963 | @@ -2807,6 +2836,7 @@ |
1964 | self.add_param("asrwgtflavor", 5, comment = 'highest quark flavor for a_s reweighting in MLM') |
1965 | self.add_param("clusinfo", True) |
1966 | self.add_param("lhe_version", 3.0) |
1967 | + self.add_param("boost_event", "False", hidden=True, include=False, comment="allow to boost the full event. The boost put at rest the sume of 4-momenta of the particle selected by the filter defined here. example going to the higgs rest frame: lambda p: p.pid==25") |
1968 | self.add_param("event_norm", "average", allowed=['sum','average', 'unity'], |
1969 | include=False, sys_default='sum') |
1970 | #cut |
1971 | @@ -2828,14 +2858,14 @@ |
1972 | self.add_param("ptlmax", -1.0, cut=True) |
1973 | self.add_param("missetmax", -1.0, cut=True) |
1974 | # E cut |
1975 | - self.add_param("ej", 0.0, cut=True) |
1976 | - self.add_param("eb", 0.0, cut=True) |
1977 | - self.add_param("ea", 0.0, cut=True) |
1978 | - self.add_param("el", 0.0, cut=True) |
1979 | - self.add_param("ejmax", -1.0, cut=True) |
1980 | - self.add_param("ebmax", -1.0, cut=True) |
1981 | - self.add_param("eamax", -1.0, cut=True) |
1982 | - self.add_param("elmax", -1.0, cut=True) |
1983 | + self.add_param("ej", 0.0, cut=True, hidden=True) |
1984 | + self.add_param("eb", 0.0, cut=True, hidden=True) |
1985 | + self.add_param("ea", 0.0, cut=True, hidden=True) |
1986 | + self.add_param("el", 0.0, cut=True, hidden=True) |
1987 | + self.add_param("ejmax", -1.0, cut=True, hidden=True) |
1988 | + self.add_param("ebmax", -1.0, cut=True, hidden=True) |
1989 | + self.add_param("eamax", -1.0, cut=True, hidden=True) |
1990 | + self.add_param("elmax", -1.0, cut=True, hidden=True) |
1991 | # Eta cut |
1992 | self.add_param("etaj", 5.0, cut=True) |
1993 | self.add_param("etab", -1.0, cut=True) |
1994 | @@ -2958,8 +2988,8 @@ |
1995 | # Special syntax are related to those. (can not be edit directly) |
1996 | self.add_param('pt_min_pdg',{'__type__':0.}, include=False) |
1997 | self.add_param('pt_max_pdg',{'__type__':0.}, include=False) |
1998 | - self.add_param('E_min_pdg',{'__type__':0.}, include=False) |
1999 | - self.add_param('E_max_pdg',{'__type__':0.}, include=False) |
2000 | + self.add_param('E_min_pdg',{'__type__':0.}, include=False, hidden=True) |
2001 | + self.add_param('E_max_pdg',{'__type__':0.}, include=False, hidden=True) |
2002 | self.add_param('eta_min_pdg',{'__type__':0.}, include=False) |
2003 | self.add_param('eta_max_pdg',{'__type__':0.}, include=False) |
2004 | self.add_param('mxx_min_pdg',{'__type__':0.}, include=False) |
2005 | @@ -2975,6 +3005,7 @@ |
2006 | self.add_param('mxxmin4pdg',[-1.], system=True) |
2007 | self.add_param('mxxpart_antipart', [False], system=True) |
2008 | |
2009 | + |
2010 | |
2011 | def check_validity(self): |
2012 | """ """ |
2013 | @@ -3155,10 +3186,13 @@ |
2014 | self['ebeam1'] = 500 |
2015 | self['ebeam2'] = 500 |
2016 | self['use_syst'] = False |
2017 | + self.display_block.append('beam_pol') |
2018 | + self.display_block.append('ecut') |
2019 | else: |
2020 | self['lpp1'] = 0 |
2021 | self['lpp2'] = 0 |
2022 | - self['use_syst'] = False |
2023 | + self['use_syst'] = False |
2024 | + self.display_block.append('beam_pol') |
2025 | |
2026 | # Check if need matching |
2027 | min_particle = 99 |
2028 | |
2029 | === modified file 'madgraph/various/lhe_parser.py' |
2030 | --- madgraph/various/lhe_parser.py 2018-10-23 20:08:08 +0000 |
2031 | +++ madgraph/various/lhe_parser.py 2019-05-16 09:35:25 +0000 |
2032 | @@ -976,13 +976,13 @@ |
2033 | self.seek(0) |
2034 | else: |
2035 | # check special case without PDF for one (or both) beam |
2036 | - if init_information["idbmup1"] == 0: |
2037 | + if init_information["idbmup1"] in [0,9]: |
2038 | event = self.next() |
2039 | init_information["idbmup1"]= event[0].pdg |
2040 | if init_information["idbmup2"] == 0: |
2041 | init_information["idbmup2"]= event[1].pdg |
2042 | self.seek(0) |
2043 | - if init_information["idbmup2"] == 0: |
2044 | + if init_information["idbmup2"] in [0,9]: |
2045 | event = self.next() |
2046 | init_information["idbmup2"] = event[1].pdg |
2047 | self.seek(0) |
2048 | @@ -1726,6 +1726,25 @@ |
2049 | |
2050 | return new_event |
2051 | |
2052 | + def boost(self, filter=None): |
2053 | + """modify the current event to boost it according to the current filter""" |
2054 | + if filter is None: |
2055 | + filter = lambda p: p.status==-1 |
2056 | + |
2057 | + pboost = FourMomentum() |
2058 | + for p in self: |
2059 | + if filter(p): |
2060 | + pboost += p |
2061 | + |
2062 | + # change sign of three-component due to helas convention |
2063 | + pboost.px *=-1 |
2064 | + pboost.py *=-1 |
2065 | + pboost.pz *=-1 |
2066 | + for p in self: |
2067 | + b= FourMomentum(p).boost(pboost) |
2068 | + p.E, p.px, p.py, p.pz = b.E, b.px, b.py, b.pz |
2069 | + |
2070 | + return self |
2071 | |
2072 | def check(self): |
2073 | """check various property of the events""" |
2074 | @@ -2493,18 +2512,20 @@ |
2075 | def boost(self, mom): |
2076 | """mom 4-momenta is suppose to be given in the rest frame of this 4-momenta. |
2077 | the output is the 4-momenta in the frame of this 4-momenta |
2078 | - function copied from HELAS routine.""" |
2079 | + function copied from HELAS routine. |
2080 | + if the current momenta is (E,\vec{p}), in order to go to the rest frame |
2081 | + of the current particle, mom should be (E, -\vec{p}) |
2082 | + """ |
2083 | |
2084 | - |
2085 | - pt = self.px**2 + self.py**2 + self.pz**2 |
2086 | - if pt: |
2087 | + pnorm = mom.px**2 + mom.py**2 + mom.pz**2 |
2088 | + if pnorm: |
2089 | s3product = self.px * mom.px + self.py * mom.py + self.pz * mom.pz |
2090 | - mass = self.mass |
2091 | - lf = (mom.E + (self.E - mass) * s3product / pt ) / mass |
2092 | + mass = mom.mass |
2093 | + lf = (self.E + (mom.E - mass) * s3product / pnorm ) / mass |
2094 | return FourMomentum(E=(self.E*mom.E+s3product)/mass, |
2095 | - px=mom.px + self.px * lf, |
2096 | - py=mom.py + self.py * lf, |
2097 | - pz=mom.pz + self.pz * lf) |
2098 | + px=self.px + mom.px * lf, |
2099 | + py=self.py + mom.py * lf, |
2100 | + pz=self.pz + mom.pz * lf) |
2101 | else: |
2102 | return FourMomentum(mom) |
2103 | |
2104 | |
2105 | === modified file 'madgraph/various/misc.py' |
2106 | --- madgraph/various/misc.py 2018-06-01 13:06:03 +0000 |
2107 | +++ madgraph/various/misc.py 2019-05-16 09:35:25 +0000 |
2108 | @@ -867,10 +867,10 @@ |
2109 | return f(arg, *args, **opt) |
2110 | except OSError, error: |
2111 | logger.debug('try to recover from %s' % error) |
2112 | - if isinstance(arg, list): |
2113 | + if isinstance(arg, (list,tuple)): |
2114 | prog = arg[0] |
2115 | else: |
2116 | - prog = arg[0] |
2117 | + prog = arg |
2118 | |
2119 | # Permission denied |
2120 | if error.errno == 13: |
2121 | |
2122 | === modified file 'madgraph/various/rambo.py' |
2123 | --- madgraph/various/rambo.py 2015-10-01 16:00:08 +0000 |
2124 | +++ madgraph/various/rambo.py 2019-05-16 09:35:25 +0000 |
2125 | @@ -1,6 +1,7 @@ |
2126 | from __future__ import division |
2127 | import math |
2128 | import random |
2129 | +import madgraph.various.misc as misc |
2130 | |
2131 | class FortranList(list): |
2132 | |
2133 | @@ -91,6 +92,12 @@ |
2134 | V= FortranList(N) |
2135 | IWARN = [0,0] |
2136 | # Check input object |
2137 | + if isinstance(XM, list) and not isinstance(XM, FortranList): |
2138 | + tmp = FortranList(1, N) |
2139 | + for i,val in enumerate(XM): |
2140 | + tmp[i+1] = val |
2141 | + XM = tmp |
2142 | + |
2143 | assert isinstance(XM, FortranList) |
2144 | assert XM.min == 1 |
2145 | assert XM.max == N+1 |
2146 | |
2147 | === modified file 'models/check_param_card.py' |
2148 | --- models/check_param_card.py 2018-10-19 08:27:34 +0000 |
2149 | +++ models/check_param_card.py 2019-05-16 09:35:25 +0000 |
2150 | @@ -93,6 +93,9 @@ |
2151 | data, self.comment = text.split('#',1) |
2152 | else: |
2153 | data, self.comment = text, "" |
2154 | + |
2155 | + if ']]>' in data: |
2156 | + data = data.split(']]>',1)[0] |
2157 | |
2158 | |
2159 | data = data.split() |
2160 | |
2161 | === modified file 'models/import_ufo.py' |
2162 | --- models/import_ufo.py 2019-01-30 19:32:17 +0000 |
2163 | +++ models/import_ufo.py 2019-05-16 09:35:25 +0000 |
2164 | @@ -585,7 +585,7 @@ |
2165 | else: |
2166 | pass |
2167 | else: |
2168 | - self.model.set('order_hierarchy', hierarchy) |
2169 | + self.model.set('order_hierarchy', hierarchy) |
2170 | |
2171 | # Also set expansion_order, i.e., maximum coupling order per process |
2172 | expansion_order={} |
2173 | @@ -602,11 +602,19 @@ |
2174 | pass |
2175 | else: |
2176 | self.model.set('expansion_order', expansion_order) |
2177 | - self.model.set('expansion_order', expansion_order) |
2178 | + |
2179 | |
2180 | #clean memory |
2181 | del self.checked_lor |
2182 | |
2183 | + for name in dir(self.ufomodel): |
2184 | + if name.startswith('__') and name.endswith('__'): |
2185 | + value = getattr(self.ufomodel, name) |
2186 | + if not isinstance(value, (str, int)): |
2187 | + continue |
2188 | + self.model['model_info'][name[2:-2]] = value |
2189 | + |
2190 | + |
2191 | return self.model |
2192 | |
2193 | def optimise_interaction(self, interaction): |
2194 | @@ -1940,6 +1948,7 @@ |
2195 | logger.debug('coupling with small value %s: %s treated as zero' % |
2196 | (name, value)) |
2197 | zero_coupling.append(name) |
2198 | + continue |
2199 | elif not strict_zero and abs(value) < 1e-10: |
2200 | return self.detect_identical_couplings(strict_zero=True) |
2201 | |
2202 | @@ -2234,8 +2243,10 @@ |
2203 | else: |
2204 | arg = 'width' |
2205 | change_name = [p.name for (p,f) in parameters[1:]] |
2206 | + factor_for_name = [f for (p,f) in parameters[1:]] |
2207 | [p.set(arg, new_name) for p in self['particle_dict'].values() |
2208 | - if p[arg] in change_name] |
2209 | + if p[arg] in change_name and |
2210 | + factor_for_name[change_name.index(p[arg])]==1] |
2211 | |
2212 | def remove_interactions(self, zero_couplings): |
2213 | """ remove the interactions and particle counterterms |
2214 | |
2215 | === modified file 'models/template_files/fortran/lha_read.f' |
2216 | --- models/template_files/fortran/lha_read.f 2016-10-27 15:40:27 +0000 |
2217 | +++ models/template_files/fortran/lha_read.f 2019-05-16 09:35:25 +0000 |
2218 | @@ -179,7 +179,7 @@ |
2219 | implicit none |
2220 | |
2221 | integer maxpara |
2222 | - parameter (maxpara=1000) |
2223 | + parameter (maxpara=%(maxpara)i) |
2224 | character*20 param(maxpara),value(maxpara),val,par |
2225 | character*20 blockname |
2226 | integer npara |
2227 | @@ -280,7 +280,7 @@ |
2228 | c parameters |
2229 | c |
2230 | integer maxpara |
2231 | - parameter (maxpara=1000) |
2232 | + parameter (maxpara=%(maxpara)i) |
2233 | c |
2234 | c arguments |
2235 | c |
2236 | |
2237 | === modified file 'models/template_files/fortran/lha_read_mp.f' |
2238 | --- models/template_files/fortran/lha_read_mp.f 2016-10-27 15:40:27 +0000 |
2239 | +++ models/template_files/fortran/lha_read_mp.f 2019-05-16 09:35:25 +0000 |
2240 | @@ -199,7 +199,7 @@ |
2241 | implicit none |
2242 | |
2243 | integer maxpara |
2244 | - parameter (maxpara=1000) |
2245 | + parameter (maxpara=%(maxpara)i) |
2246 | character*20 param(maxpara),value(maxpara),val,par |
2247 | character*20 blockname |
2248 | integer npara |
2249 | @@ -300,7 +300,7 @@ |
2250 | c parameters |
2251 | c |
2252 | integer maxpara |
2253 | - parameter (maxpara=1000) |
2254 | + parameter (maxpara=%(maxpara)i) |
2255 | c |
2256 | c arguments |
2257 | c |
2258 | @@ -356,7 +356,7 @@ |
2259 | c parameters |
2260 | c |
2261 | integer maxpara |
2262 | - parameter (maxpara=1000) |
2263 | + parameter (maxpara=%(maxpara)i) |
2264 | c |
2265 | c arguments |
2266 | c |