Questions about SysCalc on CMSSW

Asked by Matheus Pereira Macedo de Sousa

Dear colleagues,
I'm getting an error when I try to run use_syst True

combination of events done in 0.06291699409484863 s
   === Results Summary for run: run_01 tag: tag_1 ===

      Cross-section: 49.96 +- 0.4766 bp
      Number of events: 50

fail
Failed to access python version of LHAPDF: If the python interface to LHAPDF is available on your system, try adding its location to the PYTHONPATH environment variable and the LHAPDF library location to LD_LIBRARY_PATH (linux) or DYLD_LIBRARY_PATH (mac os x).The required LD_LIBRARY_PATH is /afs/cern.ch/user/m/matheus/CMSSW_10_6_22/src/MG5_aMC_v2_9_16/HEPTools/lhapdf6_py3//lib
INFO: can not run systematics since can not link python to lhapdf

presents this error. But when you use it as False, you don't have this problem.

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Olivier Mattelaer
Solved:
Last query:
Last reply:
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#1

Hi,

Syscalc was a external C++ package that is not supported anymore (and that you are not using)
given your log, you are using his replacement which is fortran library that we shipped with MG5aMC.

For that library to run, you indeed need to have the python command "import lhapdf"
to work, which requires
1) lhapdf to be installed
2) PYTHONPATH (and LD_LIBRARY_PATH) to be set correctly.

Looks like this is not the case.

If you set use_syst=False, the library will not be used and therefore we will at minimum not need the python interface of lhapdf (lhapdf trough fortran might be needed depending of your run_card)

Cheers,

Olivier

> On 14 Mar 2024, at 18:05, Matheus Pereira Macedo de Sousa <email address hidden> wrote:
>
> New question #709574 on MadGraph5_aMC@NLO:
> https://answers.launchpad.net/mg5amcnlo/+question/709574
>
> Dear colleagues,
> I'm getting an error when I try to run use_syst True
>
> combination of events done in 0.06291699409484863 s
> === Results Summary for run: run_01 tag: tag_1 ===
>
> Cross-section: 49.96 +- 0.4766 bp
> Number of events: 50
>
> fail
> Failed to access python version of LHAPDF: If the python interface to LHAPDF is available on your system, try adding its location to the PYTHONPATH environment variable and the LHAPDF library location to LD_LIBRARY_PATH (linux) or DYLD_LIBRARY_PATH (mac os x).The required LD_LIBRARY_PATH is /afs/cern.ch/user/m/matheus/CMSSW_10_6_22/src/MG5_aMC_v2_9_16/HEPTools/lhapdf6_py3//lib
> INFO: can not run systematics since can not link python to lhapdf
>
> presents this error. But when you use it as False, you don't have this problem.
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Revision history for this message
Matheus Pereira Macedo de Sousa (mpmacedo) said :
#2

Hi Oliver, thanks for the response. I tried following your tips and here is the return of the environments I configured:
[matheus@lxplus963 MG5_aMC_v2_9_16]$ echo $PYTHONPATH
/afs/cern.ch/user/m/matheus/CMSSW_10_6_22/src/MG5_aMC_v2_9_16/HEPTools/lhapdf6_py3/lib/python3.9/site-packages:/afs/cern.ch/user/m/matheus/CMSSW_10_6_22/src/ MG5_aMC_v2_9_16/HEPTools/lhapdf6_py3/lib/python3.9/site-packages:
[matheus@lxplus963 MG5_aMC_v2_9_16]$ echo $LD_LIBRARY_PATH
/afs/cern.ch/user/m/matheus/CMSSW_10_6_22/src/MG5_aMC_v2_9_16/HEPTools/lhapdf6_py3/lib:/afs/cern.ch/user/m/matheus/CMSSW_10_6_22/src/MG5_aMC_v2_9_16/HEPTools/lhapdf6_py3/lib:

The problem is that I'm still having the same error
fail
Failed to access python version of LHAPDF: If the python interface to LHAPDF is available on your system, try adding its location to the PYTHONPATH environment variable and the LHAPDF library location to LD_LIBRARY_PATH (linux) or DYLD_LIBRARY_PATH (mac os x).The required LD_LIBRARY_PATH is /afs/cern.ch/user/m/matheus/CMSSW_10_6_22/src/MG5_aMC_v2_9_16/HEPTools/lhapdf6_py3//lib
INFO: can not run systematics since can not link python to lhapdf

Is there any other way I can perform or calculate the systematic uncertainty of my PDF?

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

and if you run python3.9 can you run the command "import lhapdf"?
Next question are you sure that you are using python3.9 when running MG5aMC?

Cheers,

Olivier

Revision history for this message
Matheus Pereira Macedo de Sousa (mpmacedo) said :
#4

even if I do this, I got this error

[matheus@lxplus910 MG5_aMC_v2_9_16]$ python3
Python 3.9.18 (main, January 4, 2024, 00:00:00)
[GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] on Linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import lhapdf
Traceback (most recent last call):
    File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'lhapdf'

I don't really know why it doesn't regulate the package in python, when I run madgaph without python I can run lhapdf normally. However, is there any other way for me to calculate the systematic uncertainty of the PDF using or not sys_calc

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

So clearly that is your issue with lhapdf...
Nothing that I can do on my side to help you on that.

> owever, is
> there any other way for me to calculate the systematic uncertainty of
> the PDF using or not sys_calc

The old syscalc code might be the way to go. (if you suceed to install it)

The second option that you can try is to run with [LOonly=QCD]
(so for example
generate p p > t t~ [LOonly=QCD]
)
where you run LO computation within the NLO frameword where you can in principle do such computation at a pure fortran level.
(in that case you have all the constraint in term of syntax/cuts/... of the NLO code)

Cheers,

Olivier

> On 19 Mar 2024, at 12:35, Matheus Pereira Macedo de Sousa <email address hidden> wrote:
>
> Question #709574 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/709574
>
> Matheus Pereira Macedo de Sousa posted a new comment:
> even if I do this, I got this error
>
> [matheus@lxplus910 MG5_aMC_v2_9_16]$ python3
> Python 3.9.18 (main, January 4, 2024, 00:00:00)
> [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] on Linux
> Type “help”, “copyright”, “credits” or “license” for more information.
>>>> import lhapdf
> Traceback (most recent last call):
> File "<stdin>", line 1, in <module>
> ModuleNotFoundError: No module named 'lhapdf'
>
> I don't really know why it doesn't regulate the package in python, when
> I run madgaph without python I can run lhapdf normally. However, is
> there any other way for me to calculate the systematic uncertainty of
> the PDF using or not sys_calc
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Revision history for this message
Matheus Pereira Macedo de Sousa (mpmacedo) said :
#6

I'm in doubt about this second option because I work with magnetic monopoles following a model like this:
import model mono_spinhalf
generate a a > mm+ mm-

and I use this PDF 324900. In other words, regardless of the PDF, can I work with this second option?

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

So the version of the model "mono_spinhalf" that I do have is problematic for that feature.
But if you have a more recent version of the model (and that you hack it to claim that you can do QCD loop) then it should work.

To make it work (if you have the same old version as me):
1) edit the QCD coupling_order in coupling_order.py
and add the attribute perturbative_expansion = 1

2) edit the file object_library.py
and check the object CouplingOrder
it should contains the line (was missing for me)
self.perturbative_expansion = perturbative_expansion
check also that the definition does define "perturbative_expansion" (was the case for me)
 def __init__(self, name, expansion_order, hierarchy, perturbative_expansion = 0):

3) edit the file __init__.py
and add (if the object is not already defined obviously --was not for me--)
all_CTvertices = []

Then I run the above and got:

      Number of events generated: 10000
      Total cross section: 6.499e+01 +- 3.7e-01 pb
   --------------------------------------------------------------
      Scale variation (computed from LHE events):
          Dynamical_scale_choice -1 (envelope of 9 values):
              6.499e+01 pb +6.9% -6.6%
   --------------------------------------------------------------

Now that run is not with your PDF, since that one seems problematic on my system/install of lhapdf and crash (at fortran level) with the message:
 Info file not found for PDF set 'NNPDF31_nlo_as_0118_luxqed'

Cheers,

Olivier

Revision history for this message
Matheus Pereira Macedo de Sousa (mpmacedo) said :
#8

Dear Oliver, thank you for the great assistance. In fact, I made the changes you recommended and my PDF that I sent still has a problem when I run it. However, this is my doubt, when I make these changes that you suggested, do I need to continue with use_syst True or do I change it to False? Because if you leave True, the problem persists

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

The run_card does not have any use_syst parameter inside (since you are in the NLO mode and not in the LO mode).
On the other-hand, you might need to set the reweight_pdf parameter to True (parameter that does not exists for LO mode).

So you can not use the run_card that you were using before otherwise it will lead to issue.

Cheers,

Olivier

Revision history for this message
Matheus Pereira Macedo de Sousa (mpmacedo) said :
#10

Thanks Olivier Mattelaer, that solved my question.