Merge lp:~maddevelopers/mg5amcnlo/eft_width_expansion into lp:~maddevelopers/mg5amcnlo/3.4.0

Proposed by Olivier Mattelaer
Status: Rejected
Rejected by: Olivier Mattelaer
Proposed branch: lp:~maddevelopers/mg5amcnlo/eft_width_expansion
Merge into: lp:~maddevelopers/mg5amcnlo/3.4.0
Diff against target: 203 lines (+143/-0)
3 files modified
madgraph/interface/madgraph_interface.py (+133/-0)
madgraph/interface/master_interface.py (+3/-0)
models/usermod.py (+7/-0)
To merge this branch: bzr merge lp:~maddevelopers/mg5amcnlo/eft_width_expansion
Reviewer Review Type Date Requested Status
Olivier Mattelaer Disapprove
Review via email: mp+413578@code.launchpad.net

Commit message

Some change here could be insteresting to include (mainly/only usermod.py ?))

to be investigated

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

I have include the change of usermod.py in 3.4.0.
The rest should not be include (but the idea devellop here could be use for the handling of the 5D case)

review: Disapprove

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'madgraph/interface/madgraph_interface.py'
2--- madgraph/interface/madgraph_interface.py 2021-12-03 15:40:10 +0000
3+++ madgraph/interface/madgraph_interface.py 2022-01-04 09:56:33 +0000
4@@ -2895,6 +2895,7 @@
5 'modellist']
6 _add_opts = ['process', 'model']
7 _save_opts = ['model', 'processes', 'options']
8+ _edit_model_opts = ['eftwdith']
9 _tutorial_opts = ['aMCatNLO', 'stop', 'MadLoop', 'MadGraph5']
10 _switch_opts = ['mg5','aMC@NLO','ML5']
11 _check_opts = ['full', 'timing', 'stability', 'profile', 'permutation',
12@@ -3111,6 +3112,138 @@
13
14 return value
15
16+
17+ def do_editmodel(self, line):
18+ """ Method allowing to create a new UFO_MODEL.
19+ For special cases
20+ """
21+
22+ args = self.split_arg(line)
23+
24+ if args[0] not in ['eftwidth']:
25+ raise Exception, 'invalid mode: %s not in valid options: %s' % (args[0],','.join(self._editmodel_opts))
26+
27+ new_model_path = args[1]
28+ to_duplicate = args[2:]
29+
30+ #Need to do the work!!!
31+ import models.usermod as usermod
32+ new_model = usermod.UFOModel(self._curr_model.get('modelpath'))
33+ #model = self._curr_model
34+
35+ #Define custom propagators:
36+ propa_spin0 = copy.deepcopy(new_model.propagators[0])
37+ propa_spin0.name = 'SEFT'
38+ propa_spin0.numerator = 'Mass(id)'
39+ propa_spin0.denominator = "(P('mu', id) * P('mu', id) - Mass(id) * Mass(id) + complex(0,1) * Mass(id) * Width(id))**2"
40+ propa_spin12 = copy.deepcopy(new_model.propagators[0])
41+ propa_spin12.name = 'FEFT'
42+ propa_spin12.numerator = "Mass(id)*(Gamma('mu', 1, 2) * P('mu', id) + Mass(id) * Identity(1, 2))"
43+ propa_spin12.denominator = "(P('mu', id) * P('mu', id) - Mass(id) * Mass(id) + complex(0,1) * Mass(id) * Width(id))**2"
44+ propa_spin1 = copy.deepcopy(new_model.propagators[0])
45+ propa_spin1.name = 'VEFT'
46+ propa_spin1.numerator = "(-1 * Metric(1, 2) + Metric(1,'mu')* P('mu', id) * P(2, id) / Mass(id)"
47+ propa_spin1.denominator = "(P('mu', id) * P('mu', id) - Mass(id) * Mass(id) + complex(0,1) * Mass(id) * Width(id))**2"
48+
49+ # adding them
50+ new_model.propagators.append(propa_spin0)
51+ new_model.propagators.append(propa_spin12)
52+ new_model.propagators.append(propa_spin1)
53+
54+ #make a local copy of all vertices to avoid to add double modify interactions
55+ all_interactions = copy.copy(new_model.vertices)
56+
57+ decay = new_model.model.decays.all_decays
58+
59+
60+ for name in to_duplicate:
61+ misc.sprint(name)
62+ ufoparticle = new_model.get_particle(name)
63+
64+ new_particle = copy.copy(ufoparticle)
65+ new_particle.name += '__fake__'
66+ new_particle.antiname += '__fake__'
67+ if new_particle.pdg_code >0:
68+ new_particle.pdg_code += 111000
69+ else:
70+ new_particle.pdg_code -= 111000
71+
72+ # add new parameter for the width (as external) -> set it as new width
73+ #new_width = copy.copy(new_particle.width)
74+ #new_width.lhacode[0] += 111000
75+ #new_model.add_parameter(new_width)
76+ #new_particle.width = new_width
77+ # set the propagator
78+ if new_particle.spin == 1:
79+ new_particle.propagator = propa_spin0
80+ elif new_particle.spin == 2:
81+ new_particle.propagator = propa_spin12
82+ elif new_particle.spin == 3:
83+ new_particle.propagator = propa_spin1
84+ else:
85+ raise Exception, "spin not yet supported"
86+ #new_particle.propagating = False
87+
88+ new_param = copy.deepcopy(new_model.parameters[0])
89+ new_param.name = 'C%s' % abs(ufoparticle.pdg_code)
90+ new_param.nature = 'internal'
91+ this_decay = None
92+ for dec in decay:
93+ misc.sprint(ufoparticle.pdg_code, dec.particle.pdg_code)
94+ if abs(dec.particle.pdg_code) == abs(ufoparticle.pdg_code):
95+ this_decay=dec
96+ break
97+ assert this_decay
98+ import aloha.aloha_parsers as aloha_parsers
99+ expr = []
100+
101+ for k,v in this_decay.partial_widths.items():
102+ if 'a3phidQL' in v:
103+ expr.append('(%s)-(%s)' % (v.replace('a3phidQL**2','0'),v.replace('a3phidQL**2','0').replace('a3phidQL','0')))
104+
105+ if expr:
106+ new_param.value = 'cmath.sqrt(%s)' % ' + '.join(expr)
107+ else:
108+ new_param.value = '0.'
109+ misc.sprint(new_param.value)
110+ new_param.type = 'real'
111+ if new_particle.pdg_code >0:
112+ new_model.add_parameter(new_param)
113+
114+ # add the particle to the model
115+ new_model.add_particle(new_particle)
116+
117+ for vert in all_interactions:
118+ if not ufoparticle in vert.particles:
119+ continue
120+ new_vert = copy.copy(vert)
121+ new_vert.particles = list(vert.particles)
122+ new_vert.couplings = dict(new_vert.couplings)
123+ index = new_vert.particles.index(ufoparticle)
124+ new_vert.particles[index] = new_particle
125+ new_vert.name += '_%s' % str(new_particle.pdg_code).replace('-','_')
126+
127+ for key, coup in new_vert.couplings.items():
128+ if 'NP' in coup.order:
129+ del new_vert.couplings[key]
130+ continue
131+ new_coup = copy.deepcopy(coup)
132+ new_coup.order['NP'] = 1
133+ new_coup.value = '%s * (%s)' % (new_param.name, new_coup.value)
134+ new_coup.name += '_%s' % str(new_particle.pdg_code).replace('-','_')
135+ new_model.couplings.append(new_coup)
136+ #new_model.add_coupling(new_coup)
137+ new_vert.couplings[key] = new_coup
138+
139+ if new_vert.couplings:
140+ new_model.vertices.append(new_vert)
141+ misc.sprint(new_vert, new_vert.couplings)
142+
143+ new_model.write(new_model_path)
144+
145+
146+
147+
148 # Add a process to the existing multiprocess definition
149 # Generate a new amplitude
150 def do_add(self, line):
151
152=== modified file 'madgraph/interface/master_interface.py'
153--- madgraph/interface/master_interface.py 2021-03-09 15:04:20 +0000
154+++ madgraph/interface/master_interface.py 2022-01-04 09:56:33 +0000
155@@ -466,6 +466,9 @@
156 def do_display(self, *args, **opts):
157 return self.cmd.do_display(self, *args, **opts)
158
159+ def do_editmodel(self, *args, **opts):
160+ return self.cmd.do_editmodel(self, *args, **opts)
161+
162 def do_exit(self, *args, **opts):
163 return self.cmd.do_exit(self, *args, **opts)
164
165
166=== modified file 'models/usermod.py'
167--- models/usermod.py 2021-07-27 09:18:15 +0000
168+++ models/usermod.py 2022-01-04 09:56:33 +0000
169@@ -56,6 +56,7 @@
170 as empty."""
171 self.modelpath = modelpath
172 model = ufomodels.load_model(modelpath)
173+ self.model = model
174 # Check the validity of the model. Too old UFO (before UFO 1.0)
175 if not hasattr(model, 'all_orders'):
176 raise USRMODERROR('Base Model doesn\'t follows UFO convention (no couplings_order information)\n' +\
177@@ -239,6 +240,8 @@
178 return 'L.%s' % repr(param)
179 elif param.__class__.__name__ == 'Particle':
180 return 'P.%s' % repr(param)
181+ elif param.__class__.__name__ == 'Propagator':
182+ return 'Propa.%s' % repr(param)
183 elif param is None:
184 return 'None'
185 else:
186@@ -338,6 +341,9 @@
187 import parameters as Param
188
189 """
190+ if self.propagators:
191+ text += "import propagators as Propa\n"
192+
193 text += self.create_file_content(self.particles)
194 ff = open(os.path.join(outputdir, 'particles.py'), 'w')
195 ff.writelines(text)
196@@ -767,6 +773,7 @@
197 old_coupling = next((p for p in self.couplings if p.value==coupling.value), None)
198
199 if old_coupling:
200+ misc.sprint('duplicate name', coupling)
201 coupling.replace = old_coupling #tag for replacement
202 else:
203 self.couplings.append(coupling)

Subscribers

People subscribed via source and target branches

to all changes: