From 57e0e87cb54e9b1008e5bd1b37fd260e213d331c Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Thu, 6 Feb 2025 16:19:27 -0700 Subject: [PATCH] Add MadGraph5_aMC@NLO * Add MadGraph5_aMC@NLO v3.5.7. - c.f. https://github.com/mg5amcnlo/mg5amcnlo - Add tutorial example (tutorial.mg5) for a simple test. * Integration with Pythia8 via MG5aMC_PY8_interface is not yet supported. - c.f. https://github.com/mg5amcnlo/MG5aMC_PY8_interface * Detection of existing libraries (ninja, collier) for NLO calculations is not supported yet either given bugs. --- .../allow-for-shared-libraries.patch | 28 +++ recipes/mg5amcnlo/meta.yaml | 159 ++++++++++++ recipes/mg5amcnlo/mg5_configuration.txt | 237 ++++++++++++++++++ recipes/mg5amcnlo/tutorial.mg5 | 10 + 4 files changed, 434 insertions(+) create mode 100644 recipes/mg5amcnlo/allow-for-shared-libraries.patch create mode 100644 recipes/mg5amcnlo/meta.yaml create mode 100644 recipes/mg5amcnlo/mg5_configuration.txt create mode 100644 recipes/mg5amcnlo/tutorial.mg5 diff --git a/recipes/mg5amcnlo/allow-for-shared-libraries.patch b/recipes/mg5amcnlo/allow-for-shared-libraries.patch new file mode 100644 index 0000000000000..efd7d57b43a6e --- /dev/null +++ b/recipes/mg5amcnlo/allow-for-shared-libraries.patch @@ -0,0 +1,28 @@ +From 5d0031339ab287ea14966e00239c3c756a9c3ee6 Mon Sep 17 00:00:00 2001 +From: Matthew Feickert +Date: Thu, 6 Feb 2025 15:33:17 -0700 +Subject: [PATCH] fix: Allow for ninja and collier to be shared libraries + +* It is valid for external instances of ninja and collier to be shared libraries, + and so accept them if they are found when a static libray version is not. +--- + madgraph/interface/madgraph_interface.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/madgraph/interface/madgraph_interface.py b/madgraph/interface/madgraph_interface.py +index ebc9572..1e545d6 100755 +--- a/madgraph/interface/madgraph_interface.py ++++ b/madgraph/interface/madgraph_interface.py +@@ -7996,6 +7996,9 @@ in the MG5aMC option 'samurai' (instead of leaving it to its default 'auto').""" + self.options[args[0]] = None + else: + program = misc.which_lib(os.path.join(args[1],'lib%s.a'%args[0])) ++ # Check for shared library ++ if program is None: ++ program = misc.which_lib(os.path.join(args[1],'lib%s.so'%args[0])) + if program!=None: + res = 0 + logger.info('set %s to %s' % (args[0],args[1])) +-- +2.47.1 + diff --git a/recipes/mg5amcnlo/meta.yaml b/recipes/mg5amcnlo/meta.yaml new file mode 100644 index 0000000000000..3ad69f79a4196 --- /dev/null +++ b/recipes/mg5amcnlo/meta.yaml @@ -0,0 +1,159 @@ +{% set name = "mg5amcnlo" %} +{% set version = "3.5.7" %} + +package: + name: {{ name }} + version: {{ version }} + +source: + - url: https://github.com/hep-packaging-coordination/mg5amcnlo-release-mirror/releases/download/{{ version }}/MG5_aMC_v{{ version }}.tar.gz + sha256: ca3e027f078438318bd4143a102aebc2d51358f537b5d52bbc574fe49a6a901e + folder: source + patches: + # FIXME: mg5amcnlo assumes that ninja and collier are only static libraries + - allow-for-shared-libraries.patch + +build: + # FIXME: mg5amcnlo doesn't support Python 3.12 yet + skip: true # [py<37 or py>311 or win] + number: 0 + script: + # Remove unnecessary files + - rm -r source/.github + - rm -r source/tests + - rm -r source/vendor/CutTools + - rm source/.bzrignore + - rm source/.gitignore + - rm source/code-notes + - rm source/README + - rm source/UpdateNotes.txt + # FIXME: Remove prebuilt binary added in tarball + - rm source/vendor/DiscreteSampler/check + + # Fix bugs + # FIXME: Use user space perl instead of system perl + - find source -type f -exec grep -Il '#!/usr/bin/perl -w' {} + | xargs sed -i 's|#!/usr/bin/perl -w|#!/usr/bin/env perl -w|g' + + # Need to use -a to preserve symlinks + - cp -a source $PREFIX/MG5_aMC + + # TODO: Add MG5aMC_PY8_interface + # https://github.com/mg5amcnlo/MG5aMC_PY8_interface + + # Build configuration file be replacing placeholder values with PREFIX + - cp $RECIPE_DIR/mg5_configuration.txt . + - sed -i "s|REPLACE_WITH_PREFIX|$PREFIX|g" mg5_configuration.txt + - sed -i "s|REPLACE_WITH_BASENAME_FC|$(basename $FC)|g" mg5_configuration.txt + - sed -i "s|REPLACE_WITH_BASENAME_GXX|$(basename $GXX)|g" mg5_configuration.txt + - mv mg5_configuration.txt $PREFIX/MG5_aMC/input/mg5_configuration.txt + + # Setup links + - mkdir -p $PREFIX/bin + - ln -s $PREFIX/MG5_aMC/bin/mg5_aMC $PREFIX/bin/mg5_aMC + - mkdir -p $PREFIX/share/mg5_aMC + - ln -s $PREFIX/MG5_aMC/proc_card.dat $PREFIX/share/mg5_aMC/proc_card.dat + + # Generate initial files + # conda-build intentionally compiles .pyc files, so keep those. + # c.f. https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#skip-compiling-some-py-files-into-pyc-files + - echo "exit" | mg5_aMC + - rm py.py + +requirements: + build: + - {{ stdlib('c') }} + # Compilers needed to set names in mg5_configuration.txt and will be + # used in the future along with make when bugs with Pythia8 are fixed + - {{ compiler('cxx') }} + - {{ compiler('fortran') }} + # - make + - sed + - grep + host: + - python + - six + - ply + - fastjet-cxx + - emela + - lhapdf + run: + # mg5amcnlo is a code generator and so requires a build system at runtime + - {{ compiler('cxx') }} + - {{ compiler('fortran') }} + - make + - tar + - perl + - python + - six + - numpy + - fastjet-contrib + - emela + - lhapdf + - pythia8 + - ply + - oneloop + # ninja-hep-ph uses libquadmath and so does not support macOS + - ninja-hep-ph # [linux] + - collier + - ghostscript + +test: + files: + - $RECIPE_DIR/tutorial.mg5 + commands: + - test -d $PREFIX/MG5_aMC + - test -d $PREFIX/MG5_aMC/aloha + - test -d $PREFIX/MG5_aMC/bin + - test -d $PREFIX/MG5_aMC/HELAS + - test -d $PREFIX/MG5_aMC/input + - test -d $PREFIX/MG5_aMC/madgraph + - test -d $PREFIX/MG5_aMC/MadSpin + - test -d $PREFIX/MG5_aMC/mg5decay + - test -d $PREFIX/MG5_aMC/models + - test -d $PREFIX/MG5_aMC/PLUGIN + - test -d $PREFIX/MG5_aMC/Template + - test -d $PREFIX/MG5_aMC/vendor + + - test -f $PREFIX/MG5_aMC/proc_card.dat + - test -f $PREFIX/MG5_aMC/VERSION + - test -f $PREFIX/bin/mg5_aMC + - test -f $PREFIX/MG5_aMC/input/mg5_configuration.txt + - test -f $PREFIX/MG5_aMC/madgraph/LICENSE + + - echo -e "\n# Checking mg5_configuration.txt" + - cat $PREFIX/MG5_aMC/input/mg5_configuration.txt + + - mg5_aMC --help + + - echo "exit" | mg5_aMC + + - mg5_aMC $RECIPE_DIR/tutorial.mg5 + +about: + home: https://github.com/mg5amcnlo/mg5amcnlo + summary: 'MadGraph5_aMC@NLO' + description: | + MadGraph5_aMC@NLO is a framework that aims at providing all the elements + necessary for SM and BSM phenomenology, such as the computations of cross + sections, the generation of hard events and their matching with event + generators, and the use of a variety of tools relevant to event manipulation + and analysis. + Processes can be simulated to LO accuracy for any user-defined Lagrangian, + and the NLO accuracy in the case of models that support this kind of calculations + — prominent among these are QCD and EW corrections to SM processes. + Matrix elements at the tree- and one-loop-level can also be obtained. + + MadGraph5_aMC@NLO is the new version of both MadGraph5 and aMC@NLO that unifies + the LO and NLO lines of development of automated tools within the MadGraph family. + As such, the code allows one to simulate processes in virtually all configurations + of interest, in particular for hadronic and e+e- colliders; starting from version + 3.2.0, the latter include Initial State Radiation and beamstrahlung effects. + # modified University of Illinois/NCSA license + license: LicenseRef-NCSA + license_family: OTHER + license_file: source/LICENSE + dev_url: https://github.com/mg5amcnlo/mg5amcnlo + +extra: + recipe-maintainers: + - matthewfeickert diff --git a/recipes/mg5amcnlo/mg5_configuration.txt b/recipes/mg5amcnlo/mg5_configuration.txt new file mode 100644 index 0000000000000..d11639bfef7d1 --- /dev/null +++ b/recipes/mg5amcnlo/mg5_configuration.txt @@ -0,0 +1,237 @@ +################################################################################ +# +# Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors +# +# This file is a part of the MadGraph5_aMC@NLO project, an application which +# automatically generates Feynman diagrams and matrix elements for arbitrary +# high-energy processes in the Standard Model and beyond. +# +# It is subject to the MadGraph5_aMC@NLO license which should accompany this +# distribution. +# +# For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch +# +################################################################################ +# +# This File contains some configuration variable for MadGraph/MadEvent +# +# Line starting by #! are comment and should remain commented +# Line starting with # should be uncommented if you want to modify the default +# value. +# Current value for all options can seen by typing "display options" +# after either ./bin/mg5_aMC or ./bin/madevent +# +# You can place this files in ~/.mg5/mg5_configuration.txt if you have more than +# one version of MG5. +# +################################################################################ + +#! Allow/Refuse syntax that changed meaning in version 3.1 of the code +#! (Compare to 3.0, 3.1 is back to the meaning of 2.x branch) +#! +# acknowledged_v3.1_syntax = False + + +#! Prefered Fortran Compiler +#! If None: try to find g77 or gfortran on the system +#! +fortran_compiler = REPLACE_WITH_PREFIX/bin/REPLACE_WITH_BASENAME_FC +# f2py_compiler_py2 = None +f2py_compiler_py3 = REPLACE_WITH_PREFIX/bin/f2py + + +#! Prefered C++ Compiler +#! If None: try to find g++ or clang on the system +#! +cpp_compiler = REPLACE_WITH_PREFIX/bin/REPLACE_WITH_BASENAME_GXX + +#! Prefered Text Editor +#! Default: use the shell default Editor +#! or try to find one available on the system +#! Be careful: Only shell based editor are allowed +# text_editor = None + +#! Prefered WebBrower +#! If None: try to find one available on the system +# web_browser = None + +#! Prefered PS viewer +#! If None: try to find one available on the system +eps_viewer = REPLACE_WITH_PREFIX/bin/gs + +#! Time allowed to answer question (if no answer takes default value) +#! 0: No time limit +# timeout = 60 + +#! Pythia8 path. +#! Defines the path to the pythia8 installation directory (i.e. the +#! on containing the lib, bin and include directories) . +#! If using a relative path, that starts from the mg5 directory +# pythia8_path = REPLACE_WITH_PREFIX + +#! MG5aMC_PY8_interface path +#! Defines the path of the C++ driver file that is used by MG5_aMC to +#! steer the Pythia8 shower. +#! Can be installed directly from within MG5_aMC with the following command: +#! MG5_aMC> install mg5amc_py8_interface +# mg5amc_py8_interface_path = ./HEPTools/MG5aMC_PY8_interface + +#! Herwig++/Herwig7 paths +#! specify here the paths also to HepMC ant ThePEG +#! define the path to the herwig++, thepeg and hepmc directories. +#! paths can be absolute or relative from mg5 directory +#! WARNING: if Herwig7 has been installed with the bootstrap script, +#! then please set thepeg_path and hepmc_path to the same value as +#! hwpp_path +# hwpp_path = +# thepeg_path = +# hepmc_path = + +#! Control when MG5 checks if he is up-to-date. +#! Enter the number of day between two check (0 means never) +#! A question is always asked before any update +# auto_update = 7 + +################################################################################ +# INFO FOR MADEVENT / aMC@NLO +################################################################################ +# If this file is in a MADEVENT Template. 'main directory' is the directory +# containing the SubProcesses directory. Otherwise this is the MadGraph5_aMC@NLO main +# directory (containing the directories madgraph and Template) + +#! Allow/Forbid the automatic opening of the web browser (on the status page) +#! when launching MadEvent [True/False] +# automatic_html_opening = True +#! allow notification of finished job in the notification center (Mac Only) +# notification_center = True + + +#! Default Running mode +#! 0: single machine/ 1: cluster / 2: multicore +# run_mode = 2 + +#! Cluster Type [pbs|sge|condor|lsf|ge|slurm|htcaas|htcaas2] Use for cluster run only +#! And cluster queue (or partition for slurm) +#! And size of the cluster (some part of the code can adapt splitting accordingly) +# cluster_type = condor +# cluster_queue = madgraph +# cluster_size = 150 +# cluster_walltime = # time in minute for slurm and second for condor (not supported for other scheduller) + +#! Path to a node directory to avoid direct writing on the central disk +#! Note that condor clusters avoid direct writing by default (therefore this +#! options does not affect condor clusters) +# cluster_temp_path = None + +#! path to a node directory where local file can be found (typically pdf) +#! to avoid to send them to the node (if cluster_temp_path is on True or condor) +# cluster_local_path = None # example: /cvmfs/cp3.uclouvain.be/madgraph/ + +#! Cluster waiting time for status update +#! First number is when the number of waiting job is higher than the number +#! of running one (time in second). The second number is in the second case. +# cluster_status_update = 600 30 + +#! How to deal with failed submission (can occurs on cluster mode) +#! 0: crash, -1: print error, hangs the program up to manual instructions, N(>0) retry up to N times. +# cluster_nb_retry = 1 + +#! How much time to wait for the output file before resubmission/crash (filesystem can be very slow) +# cluster_retry_wait = 300 + +#! Nb_core to use (None = all) This is use only for multicore run +#! This correspond also to the number core used for code compilation for cluster mode +# nb_core = None + +#! Pythia-PGS Package +#! relative path start from main directory +# pythia-pgs_path = ./pythia-pgs + +#! Delphes Package +#! relative path start from main directory +# delphes_path = ./Delphes + +#! MadAnalysis4 fortran-based package [for basic analysis] +#! relative path start from main directory +# madanalysis_path = ./MadAnalysis + +#! MadAnalysis5 python-based Package [For advanced analysis] +#! relative path start from main directory +# madanalysis5_path = ./HEPTools/madanalysis5/madanalysis5 + +#! ExRootAnalysis Package +#! relative path start from main directory +# exrootanalysis_path = ./ExRootAnalysis + +#! TOPDRAWER PATH +#! Path to the directory containing td executables +#! relative path start from main directory +# td_path = ./td + +#! lhapdf-config --can be specify differently depending of your python version +#! If None: try to find one available on the system +# lhapdf_py2 = lhapdf-config +lhapdf_py3 = REPLACE_WITH_PREFIX/bin/lhapdf-config + +#! fastjet-config +#! If None: try to find one available on the system +fastjet = REPLACE_WITH_PREFIX/bin/fastjet-config + +#! eMELA-config +#! If None: try to find one available on the system +eMELA = REPLACE_WITH_PREFIX/bin/eMELA-config + +#! MCatNLO-utilities +#! relative path starting from main directory +# MCatNLO-utilities_path = ./MCatNLO-utilities + +#! Set what OLP to use for the loop ME generation +# OLP = MadLoop + +#! Set the PJFRy++ directory containing pjfry's library +#! if auto: try to find it automatically on the system (default) +#! if '' or None: disabling pjfry +#! if pjfry=/PATH/TO/pjfry/lib: use that specific installation path for PJFry++ +# pjfry = auto + +#! Set the Golem95 directory containing golem's library +#! It only supports version higher than 1.3.0 +#! if auto: try to find it automatically on the system (default) +#! if '' or None: disabling Golem95 +#! if golem=/PATH/TO/golem/lib: use that speficif installation path for Golem95 +# golem = auto + +#! Set the samurai directory containing samurai's library +#! It only supports version higher than 2.0.0 +#! if auto: try to find it automatically on the system (default) +#! if '' or None: disabling samurai +#! if samurai=/PATH/TO/samurai/lib: use that specific installation path for samurai +# samurai = None + +#! Set the Ninja directory containing ninja's library +#! if '' or None: disabling ninja +#! if ninja=/PATH/TO/ninja/lib: use that specific installation path for ninja +ninja = REPLACE_WITH_PREFIX/lib + +#! Set the COLLIER directory containing COLLIER's library +#! if '' or None: disabling COLLIER +#! if ninja=/PATH/TO/ninja/lib: use that specific installation path for COLLIER +# Note that it is necessary that you have generated a static library for COLLIER +collier = REPLACE_WITH_PREFIX/lib + +#! Set how MadLoop dependencies (such as CutTools) should be handled +#! > external : ML5 places a link to the MG5_aMC-wide libraries +#! > internal : ML5 copies all dependencies in the output so that it is independent +#! > environment_paths : ML5 searches for the dependencies in your environment path +# output_dependencies = external + +#! SysCalc PATH +#! Path to the directory containing syscalc executables +#! relative path start from main directory +# syscalc_path = ./SysCalc + +#! Absolute paths to the config script in the bin directory of PineAPPL +#! (to generate PDF-independent fast-interpolation grids). +# pineappl = pineappl + + diff --git a/recipes/mg5amcnlo/tutorial.mg5 b/recipes/mg5amcnlo/tutorial.mg5 new file mode 100644 index 0000000000000..23bd0e7495b77 --- /dev/null +++ b/recipes/mg5amcnlo/tutorial.mg5 @@ -0,0 +1,10 @@ +generate p p > t t~ + +display particles +display multiparticles + +add process p p > W+ j, W+ > l+ vl @2 + +output MY_FIRST_MG5_RUN + +launch MY_FIRST_MG5_RUN