Reweighing with allmatrix2py

Asked by Emil Gorm Nielsen

Hi,
I am trying to use allmatrix to calculate matrix elements for 10 different configurations of EWdim6 couplings. How ever, when I run it I get

Param card 1 of 10: 000.dat
 Warning: parameter mdl_CWWWL2 not found
          setting it to default value 0.99999990000000005
 Warning: parameter mdl_CWL2 not found
          setting it to default value 9.9999990000000007
 Warning: parameter mdl_CBL2 not found
          setting it to default value 99.999989999999997
 Warning: parameter mdl_CPWWWL2 not found
          setting it to default value 999.99990000000003
 Warning: parameter mdl_CPWL2 not found
          setting it to default value 9999.9989999999998
 Warning: parameter mdl_MP not found
          setting it to default value 125.01200000000000
 Warning: parameter mdl_WTau not found
          setting it to default value 2.2699999999999998E-012
 Warning: parameter mdl_WH1 not found
          setting it to default value 6.3823389999999999E-003

for all 10 parameter cards, and the matrix elements are identical for the 10 cards as if the cards are not loaded correctly.
Here is the code I use:

#!/usr/bin/env python
from __future__ import division

import sys
import math
import ROOT
sys.path.append("../SubProcesses")
import allmatrix2py

def invert_momenta(p):
        """ fortran/C-python do not order table in the same order"""
        new_p = []
        for i in range(len(p[0])): new_p.append([0]*len(p))
        for i, onep in enumerate(p):
            for j, x in enumerate(onep):
                new_p[j][i] = x
        return new_p

if len(sys.argv) < 3:
    print("Usage: add_weights.py input_file out_file")
    sys.exit(2)

ROOT.gSystem.Load("libExRootAnalysis")
try:
    ROOT.gInterpreter.Declare('#include "ExRootAnalysis/ExRootClasses.h"')
except:
    print("Include failed. Exiting")
    sys.exit(1)

inname = sys.argv[1]
outname = sys.argv[2]

fin = ROOT.TFile(inname)
t = fin.Get("LHEF")
nentries = t.GetEntries()

param_files = ["000.dat", "100.dat", "010.dat", "001.dat", "-100.dat", "0-10.dat", "00-1.dat", "1-10.dat", "01-1.dat", "-101.dat"]

import numpy
all_weights = numpy.zeros((nentries,len(param_files)))

print("%d entries in tree" % nentries)
print("-"*15)
print("Computing MEs")
print('-'*15)

for j, card in enumerate(param_files):
print("Param card %d of %d: %s" % (j+1,len(param_files),card))
    allmatrix2py.initialise("Cards/" +card)
    for i in range(nentries):
        # Load selected branches with data from specified event
        t.GetEntry(i)
        flavours = [par.PID for par in t.Particle if abs(par.PID) < 25]
        p = [[par.E, par.Px, par.Py, par.Pz] for par in t.Particle if abs(par.PID) < 25]
        all_weights[i,j] = allmatrix2py.smatrixhel(flavours,invert_momenta(p),0.13,0,-1)
    print('\n')

fout = ROOT.TFile(outname, "RECREATE")
tout = t.CloneTree(0)#ROOT.TTree("LHEF", "Weighted events")

weights = ROOT.std.vector('double')(len(param_files), 0.)
tout.Branch("weights_true", weights)

print("-"*15)
print("Writing MEs to new tree")
print('-'*15)

for i in range(nentries):
    for j in range(len(param_files)):
        weights[j] = all_weights[i,j]
        if i == 0 : print weights[j]
    tout.Fill()

tout.Write()
fout.Close()

Any idea as to why this is not working properly?

Emil

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Emil Gorm Nielsen
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#1

Well, I do not know.
It seems that they are a problem with your param_card.
which either does not have the information, or that the reader has some issue with the line formatting.

Without the param_card, I can not comment.

Cheers,

Olivier

PS: Why not utilizing the official "reweighting module"? (is this because of the input/output format?)

Revision history for this message
Emil Gorm Nielsen (gorm123) said :
#2

Thanks for the answer, the parameter cards looks like this (with different couplings)

######################################################################
## PARAM_CARD AUTOMATICALY GENERATED BY MG5 FOLLOWING UFO MODEL ####
######################################################################
## ##
## Width set on Auto will be computed following the information ##
## present in the decay.py files of the model. ##
## See arXiv:1402.1178 for more details. ##
## ##
######################################################################

###################################
## INFORMATION FOR DIM6
###################################
Block Dim6
    1 0.000000e+00 # CWWWL2
    2 0.000000e+00 # CWL2
    3 0.000000e+01 # CBL2
    4 0.000000e+02 # CPWWWL2
    5 0.000000e+03 # CPWL2

###################################
## INFORMATION FOR MASS
###################################
Block mass
    5 4.700000e+00 # MB
    6 1.720000e+02 # MT
   15 1.777000e+00 # MTA
   23 9.118760e+01 # MZ
   25 1.250000e+02 # MH
  9000006 1.250120e+02 # MP
## Dependent parameters, given by model restrictions.
## Those values should be edited following the
## analytical expression. MG5 ignores those values
## but they are important for interfacing the output of MG5
## to external program such as Pythia.
  1 0.000000 # d : 0.0
  2 0.000000 # u : 0.0
  3 0.000000 # s : 0.0
  4 0.000000 # c : 0.0
  11 0.000000 # e- : 0.0
  12 0.000000 # ve : 0.0
  13 0.000000 # mu- : 0.0
  14 0.000000 # vm : 0.0
  16 0.000000 # vt : 0.0
  21 0.000000 # g : 0.0
  22 0.000000 # a : 0.0
  24 79.824360 # w+ : cmath.sqrt(MZ__exp__2/2. + cmath.sqrt(MZ__exp__4/4. - (aEW*cmath.pi*MZ__exp__2)/(Gf*sqrt__2)))

Revision history for this message
Emil Gorm Nielsen (gorm123) said :
#3

Accidentally hit enter, this is the full param card

######################################################################
## PARAM_CARD AUTOMATICALY GENERATED BY MG5 FOLLOWING UFO MODEL ####
######################################################################
## ##
## Width set on Auto will be computed following the information ##
## present in the decay.py files of the model. ##
## See arXiv:1402.1178 for more details. ##
## ##
######################################################################

###################################
## INFORMATION FOR DIM6
###################################
Block Dim6
    1 0.000000e+00 # CWWWL2
    2 0.000000e+00 # CWL2
    3 0.000000e+01 # CBL2
    4 0.000000e+02 # CPWWWL2
    5 0.000000e+03 # CPWL2

###################################
## INFORMATION FOR MASS
###################################
Block mass
    5 4.700000e+00 # MB
    6 1.720000e+02 # MT
   15 1.777000e+00 # MTA
   23 9.118760e+01 # MZ
   25 1.250000e+02 # MH
  9000006 1.250120e+02 # MP
## Dependent parameters, given by model restrictions.
## Those values should be edited following the
## analytical expression. MG5 ignores those values
## but they are important for interfacing the output of MG5
## to external program such as Pythia.
  1 0.000000 # d : 0.0
  2 0.000000 # u : 0.0
  3 0.000000 # s : 0.0
  4 0.000000 # c : 0.0
  11 0.000000 # e- : 0.0
  12 0.000000 # ve : 0.0
  13 0.000000 # mu- : 0.0
  14 0.000000 # vm : 0.0
  16 0.000000 # vt : 0.0
  21 0.000000 # g : 0.0
  22 0.000000 # a : 0.0
  24 79.824360 # w+ : cmath.sqrt(MZ__exp__2/2. + cmath.sqrt(MZ__exp__4/4. - (aEW*cmath.pi*MZ__exp__2)/(Gf*sqrt__2)))
###################################
## INFORMATION FOR SMINPUTS
###################################
Block sminputs
    1 1.279000e+02 # aEWM1
    2 1.166370e-05 # Gf
    3 1.184000e-01 # aS

###################################
## INFORMATION FOR YUKAWA
###################################
Block yukawa
    5 4.700000e+00 # ymb
    6 1.720000e+02 # ymt
   15 1.777000e+00 # ymtau

###################################
## INFORMATION FOR DECAY
###################################
DECAY 6 1.508336e+00 # WT
DECAY 15 2.270000e-12 # WTau
DECAY 23 2.495200e+00 # WZ
DECAY 24 2.085000e+00 # WW
DECAY 25 6.382339e-03 # WH
DECAY 9000006 6.382339e-03 # WH1
## Dependent parameters, given by model restrictions.
## Those values should be edited following the
## analytical expression. MG5 ignores those values
 ## but they are important for interfacing the output of MG5
## to external program such as Pythia.
DECAY 1 0.000000 # d : 0.0
DECAY 2 0.000000 # u : 0.0
DECAY 3 0.000000 # s : 0.0
DECAY 4 0.000000 # c : 0.0
DECAY 5 0.000000 # b : 0.0
DECAY 11 0.000000 # e- : 0.0
DECAY 12 0.000000 # ve : 0.0
DECAY 13 0.000000 # mu- : 0.0
DECAY 14 0.000000 # vm : 0.0
DECAY 16 0.000000 # vt : 0.0
DECAY 21 0.000000 # g : 0.0
DECAY 22 0.000000 # a : 0.0
#===========================================================
# QUANTUM NUMBERS OF NEW STATE(S) (NON SM PDG CODE)
#===========================================================

Block QNUMBERS 9000006 # h1
        1 0 # 3 times electric charge
        2 1 # number of spin states (2S+1)
        3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
        4 0 # Particle/Antiparticle distinction (0=own anti)
                                                                                                                                                                                       34,7 54%

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#4

I guess that this is EWDim6 model.
In that case, i do not reproduce your problem on my laptop.

I have obviously just run

import allmatrix2py
allmatrix2py.initialise('../Cards/param2.dat')

Since I do not have the ROOT package

Cheers,

Olivier

Revision history for this message
Emil Gorm Nielsen (gorm123) said :
#5

I get the same error, when running those lines alone in python, so it seems allmatrix2py is not working locally.
Could it be something is wrong with my environment?
I use madgraph 2.6.4, gfortran 7.3.0, gcc 7.3.0 and python 2.7.15.
Madgraph was installed following the instructions on your website.
Are there some additional python bindings necessary for allmatrix2py to work?

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#6

Hi,

> Are there some additional python bindings necessary for allmatrix2py to work?

It needs f2py (and therefore typically numpy) but you do have those.

Now the first question is, are you sure that it reads the correct param_card?
In your code, I see this
sys.path.append("../SubProcesses")
meaning that you run from the bin directory? (or Cards directory)
but then you use
allmatrix2py.initialise("Cards/" +card)

It might be correct obviously (I do not know your setup) but I would have expect
allmatrix2py.initialise("../Cards/" +card)

This being said, it might be related to the directory used,
Can you run that command from the SubProcesses directory?
since in the official rwgt module, I'm using the following command:
        #initialise module.
        for (path,tag), module in self.f2pylib.items():
            with misc.chdir(pjoin(os.path.dirname(rw_dir), path)):
                    if 'second' in path or tag == 3:
                        module.initialise(pjoin(rw_dir, 'Cards', 'param_card.dat'))
                    else:
                        module.initialise(pjoin(path_me, 'rw_me', 'Cards', 'param_card_orig.dat'))

Cheers,

Olivier

Revision history for this message
Emil Gorm Nielsen (gorm123) said :
#7

Thanks, I fixed it. Apparently the problem was the empty lines in the parameter cards, which the fortran code in lha.read.f couldn't read.