Merge lp:~maddevelopers/mg5amcnlo/2.7.3_rwgtnlo2lo into lp:~maddevelopers/mg5amcnlo/3.4.0

Proposed by Olivier Mattelaer
Status: Rejected
Rejected by: Olivier Mattelaer
Proposed branch: lp:~maddevelopers/mg5amcnlo/2.7.3_rwgtnlo2lo
Merge into: lp:~maddevelopers/mg5amcnlo/3.4.0
Diff against target: 178 lines (+58/-18) (has conflicts)
3 files modified
madgraph/interface/amcatnlo_run_interface.py (+13/-2)
madgraph/interface/reweight_interface.py (+36/-16)
madgraph/various/misc.py (+9/-0)
Text conflict in madgraph/various/misc.py
To merge this branch: bzr merge lp:~maddevelopers/mg5amcnlo/2.7.3_rwgtnlo2lo
Reviewer Review Type Date Requested Status
Olivier Mattelaer Disapprove
Review via email: mp+413579@code.launchpad.net

Commit message

another branch that can be usefull to (partly?) include. To investigate

To post a comment you must log in.
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote :

I guess the interest here is quite weak.

The implementation is not perfect (no test for example) and some part of the code shuld be refactorised.
So I will reject this. If the request is done again, it should be possible to re-implement this quite quickly anyway.

review: Disapprove

Unmerged revisions

326. By olivier-mattelaer

adding support for True_LO mode for NLO reweighting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'madgraph/interface/amcatnlo_run_interface.py'
2--- madgraph/interface/amcatnlo_run_interface.py 2021-12-03 15:50:41 +0000
3+++ madgraph/interface/amcatnlo_run_interface.py 2022-01-04 10:04:18 +0000
4@@ -1385,7 +1385,15 @@
5 else:
6 self.allowed_reweight = [ 'OFF', 'ON', 'NLO', 'NLO_TREE','LO']
7 return self.allowed_reweight
8-
9+
10+ def check_value_reweight(self, value):
11+
12+ if value in self.get_allowed('reweight'):
13+ return True
14+ elif value.upper() == 'TRUE_LO':
15+ return 'TRUE_LO'
16+
17+
18 def set_default_reweight(self):
19 """initialise the switch for reweight"""
20
21@@ -1409,7 +1417,10 @@
22 "set store_rwgt_info T"]
23 elif value == 'NLO_TREE':
24 return ["edit reweight_card --replace_line='change mode' --before_line='launch' change mode NLO_tree",
25- "set store_rwgt_info T"]
26+ "set store_rwgt_info T"]
27+ elif value == 'TRUE_LO':
28+ return ["edit reweight_card --replace_line='change mode' --before_line='launch' change mode True_LO",
29+ "set store_rwgt_info T"]
30 return []
31
32 #
33
34=== modified file 'madgraph/interface/reweight_interface.py'
35--- madgraph/interface/reweight_interface.py 2021-12-03 15:40:10 +0000
36+++ madgraph/interface/reweight_interface.py 2022-01-04 10:04:18 +0000
37@@ -112,7 +112,7 @@
38 self.seed = None
39 self.output_type = "default"
40 self.helicity_reweighting = True
41- self.rwgt_mode = '' # can be LO, NLO, NLO_tree, '' is default
42+ self.rwgt_mode = '' # can be LO, NLO, NLO_tree, True_LO, '' is default
43 self.has_nlo = False
44 self.rwgt_dir = None
45 self.exitted = False # Flag to know if do_quit was already called.
46@@ -462,7 +462,9 @@
47 elif self.rwgt_mode == 'LO+NLO':
48 return ['_lo', '_nlo']
49 elif self.rwgt_mode == 'NLO_tree':
50- return ['_tree']
51+ return ['_tree']
52+ elif self.rwgt_mode == 'True_LO':
53+ return ['_Tlo']
54 elif not self.rwgt_mode and self.has_nlo :
55 return ['_nlo']
56 else:
57@@ -1056,6 +1058,7 @@
58 bjx = []
59 wgt_tree = [] # reweight for loop-improved type
60 wgt_virt = [] #reweight b+v together
61+ wgt_tlo = [] # reweight at LO accuracy
62 base_wgt = []
63 gs=[]
64 qcdpower = []
65@@ -1068,6 +1071,7 @@
66 all_ctype = [w.type for w in cevent.wgts]
67 if '_nlo' in type_nlo and any(c in all_ctype for c in [2,14,15]):
68 need_V =True
69+
70
71 w_orig = self.calculate_matrix_element(cevent, 0)
72 w_new = self.calculate_matrix_element(cevent, 1)
73@@ -1111,6 +1115,12 @@
74 c_wgt.pwgt[2] * ratio_T]
75 wgt_tree.append(new_wgt)
76
77+ if '_Tlo' in type_nlo: #return real LO accuracy weight
78+ if c_wgt.type == 2:
79+ new_wgt = list(c_wgt.pwgt[:3])
80+ else:
81+ new_wgt = [0, 0, 0]
82+ wgt_tlo.append(new_wgt)
83 base_wgt.append(c_wgt.pwgt[:3])
84
85
86@@ -1150,6 +1160,11 @@
87 w_new = self.calculate_matrix_element(event, 1)
88 final_weight['_lo'] = w_new/w_orig*event.wgt
89
90+ if '_Tlo' in type_nlo:
91+ out, partial = self.combine_wgt_local(scales2, pdg, bjx, wgt_tlo, gs, qcdpower, self.pdf)
92+ avg = [1] * len(partial)
93+ final_weight['_Tlo'] = out/orig_wgt*event.wgt
94+
95
96 if self.output_type != 'default' and len(type_nlo)==1 and '_lo' not in type_nlo:
97 to_write = [partial[i]/ref_wgts[i]*partial_check[i]
98@@ -1160,10 +1175,14 @@
99 c_wgt.ref_wgt = to_write.pop(0)
100 if '_tree' in type_nlo:
101 c_wgt.pwgt = wgt_tree.pop(0)
102+ elif '_Tlo' in type_nlo:
103+ c_wgt.pwgt = wgt_tlo.pop(0)
104 else:
105 c_wgt.pwgt = wgt_virt.pop(0)
106 assert not to_write
107 assert not wgt_tree
108+ assert not wgt_tlo
109+ assert not wgt_virt
110 return final_weight
111
112
113@@ -1697,7 +1716,7 @@
114 # 5. create the virtual for NLO reweighting ---------------------------
115 if second and 'virtual_path' in self.dedicated_path:
116 files.ln(self.dedicated_path['virtual_path'], path_me, name=data['paths'][1])
117- elif has_nlo and 'NLO' in self.rwgt_mode:
118+ elif has_nlo and 'NLO' in self.rwgt_mode and self.rwgt_mode != 'NLO_tree':
119 self.create_standalone_virt_directory(data, second)
120
121 if False:#not second:
122@@ -1723,22 +1742,23 @@
123 except:
124 misc.compile(['OLP_static'], cwd=pjoin(path_me, data['paths'][1],'SubProcesses'),
125 nb_core=1)
126- elif has_nlo and not second and self.rwgt_mode == ['NLO_tree']:
127+ elif has_nlo and not second and self.rwgt_mode in ['NLO_tree','True_LO']:
128 # We do not have any virtual reweighting to do but we still have to
129 #combine the weights.
130 #Idea:create a fake directory.
131- start = time.time()
132- commandline='import model loop_sm;generate g g > e+ ve [virt=QCD]'
133- # deactivate golem since it creates troubles
134- old_options = dict(mgcmd.options)
135- mgcmd.options['golem'] = None
136- commandline = commandline.replace('add process', 'generate',1)
137- logger.info(commandline)
138- mgcmd.exec_cmd(commandline, precmd=True)
139- commandline = 'output standalone_rw %s --prefix=int -f' % pjoin(path_me, data['paths'][1])
140- mgcmd.exec_cmd(commandline, precmd=True)
141- #put back golem to original value
142- mgcmd.options['golem'] = old_options['golem']
143+ if False:
144+ start = time.time()
145+ commandline='import model loop_sm;generate g g > e+ ve [virt=QCD]'
146+ # deactivate golem since it creates troubles
147+ old_options = dict(mgcmd.options)
148+ mgcmd.options['golem'] = None
149+ commandline = commandline.replace('add process', 'generate',1)
150+ logger.info(commandline)
151+ mgcmd.exec_cmd(commandline, precmd=True)
152+ commandline = 'output standalone_rw %s --prefix=int -f' % pjoin(path_me, data['paths'][1])
153+ mgcmd.exec_cmd(commandline, precmd=True)
154+ #put back golem to original value
155+ mgcmd.options['golem'] = old_options['golem']
156 # update make_opts
157 if not mgcmd.options['lhapdf']:
158 raise Exception("NLO_tree reweighting requires LHAPDF to work correctly")
159
160=== modified file 'madgraph/various/misc.py'
161--- madgraph/various/misc.py 2021-12-03 15:40:10 +0000
162+++ madgraph/various/misc.py 2022-01-04 10:04:18 +0000
163@@ -2112,6 +2112,15 @@
164 use_lhapdf=False
165 return False
166 else:
167+<<<<<<< TREE
168+=======
169+ if sys.platform != "darwin":
170+ if os.environ.has_key('LD_LIBRARY_PATH'):
171+ os.environ['LD_LIBRARY_PATH'] = lhapdf_libdir
172+ else:
173+ os.environ['LD_LIBRARY_PATH'] = '%s:%s' %(lhapdf_libdir,os.environ['LD_LIBRARY_PATH'])
174+
175+>>>>>>> MERGE-SOURCE
176 try:
177 candidates=[dirname for dirname in os.listdir(lhapdf_libdir) \
178 if os.path.isdir(os.path.join(lhapdf_libdir,dirname))]

Subscribers

People subscribed via source and target branches

to all changes: