1
$\begingroup$

Consider the following file:

<LesHouchesEvents version="3.0">
<header>
<!--
#*********************************************************************
#                                                                    *
#                        MadGraph5_aMC@NLO                           *
#                                                                    *
#                           Going Beyond                             *
#                                                                    *
#                   http://madgraph.hep.uiuc.edu                     *
#                   http://madgraph.phys.ucl.ac.be                   *
#                   http://amcatnlo.cern.ch                          *
#                                                                    *
#                     The MadGraph5_aMC@NLO team                     *
#                                                                    *
#....................................................................*
#                                                                    *
# This file contains all the information necessary to reproduce      *
# the events generated:                                              *
#                                                                    *
# 1. software version                                                *
# 2. proc_card          : code generation info including model       *
# 3. param_card         : model primary parameters in the LH format  *
# 4. run_card           : running parameters (collider and cuts)     *
# 5. pythia_card        : present only if pythia has been run        *
# 6. pgs_card           : present only if pgs has been run           *
# 7. delphes_cards      : present only if delphes has been run       *
#                                                                    *
#                                                                    *
#*********************************************************************
-->
<MGVersion>
3.4.0
</MGVersion>
<MG5ProcCard>
<![CDATA[
#************************************************************
#*                     MadGraph5_aMC@NLO                    *
#*                                                          *
#*                *                       *                 *
#*                  *        * *        *                   *
#*                    * * * * 5 * * * *                     *
#*                  *        * *        *                   *
#*                *                       *                 *
#*                                                          *
#*                                                          *
#*         VERSION 3.4.0                 2022-05-06         *
#*                                                          *
#*    The MadGraph5_aMC@NLO Development Team - Find us at   *
#*    https://server06.fynu.ucl.ac.be/projects/madgraph     *
#*                                                          *
#************************************************************
#*                                                          *
#*               Command File for MadGraph5_aMC@NLO         *
#*                                                          *
#*     run as ./bin/mg5_aMC  filename                       *
#*                                                          *
#************************************************************
set group_subprocesses Auto
set ignore_six_quark_processes False
set low_mem_multicore_nlo_generation False
set complex_mass_scheme False
set include_lepton_initiated_processes False
set gauge unitary
set loop_optimized_output True
set loop_color_flows False
set max_npoint_for_channel 0
set default_unset_couplings 99
set max_t_for_channel 99
set zerowidth_tchannel True
set nlo_mixed_expansion True
import model sm
define p = g u c d s u~ c~ d~ s~
define j = g u c d s u~ c~ d~ s~
define l+ = e+ mu+
define l- = e- mu-
define vl = ve vm vt
define vl~ = ve~ vm~ vt~
import model Neutrinophilic-simple_UFO
import model Neutrinophilic-simple_UFO
import model Neutrinophilic-simple_UFO
import model Neutrinophilic-simple_UFO
import model Neutrinophilic-simple_UFO
import model Neutrinophilic-simple_UFO
import model Neutrinophilic-simple_UFO
generate vm~ p > mu+ phi j
output Neutrinophilic-DIS-3-GeV
]]>
</MG5ProcCard>
<MGProcCard>
#*********************************************************************
#                        MadGraph/MadEvent                           *
#                   http://madgraph.hep.uiuc.edu                     *
#                                                                    *
#                          proc_card.dat                             *
#*********************************************************************
#                                                                    *
#            This Files is generated by MADGRAPH 5                   *
#                                                                    *
# WARNING: This Files is generated for MADEVENT (compatibility issue)*
#          This files is NOT a valid MG4 proc_card.dat               *
#          Running this in MG4 will NEVER reproduce the result of MG5*
#                                                                    *
#*********************************************************************
#*********************************************************************
# Process(es) requested : mg2 input                                  *
#*********************************************************************
# Begin PROCESS # This is TAG. Do not modify this line
vm~ p > mu+ phi j           #Process
# Be carefull the coupling are here in MG5 convention
          
end_coup           # End the couplings input

done               # this tells MG there are no more procs
# End PROCESS  # This is TAG. Do not modify this line
#*********************************************************************
# Model information                                                  *
#*********************************************************************
# Begin MODEL  # This is TAG. Do not modify this line
Neutrinophilic-simple_UFO
# End   MODEL  # This is TAG. Do not modify this line
#*********************************************************************
# Start multiparticle definitions                                    *
#*********************************************************************
# Begin MULTIPARTICLES # This is TAG. Do not modify this line

# End  MULTIPARTICLES # This is TAG. Do not modify this line
</MGProcCard>
<MGRunCard>
<![CDATA[
#*********************************************************************
#                       MadGraph5_aMC@NLO                            *
#                                                                    *
#                     run_card.dat MadEvent                          *
#                                                                    *
#  This file is used to set the parameters of the run.               *
#                                                                    *
#  Some notation/conventions:                                        *
#                                                                    *
#   Lines starting with a '# ' are info or comments                  *
#                                                                    *
#   mind the format:   value    = variable     ! comment             *
#                                                                    *
#   To display more options, you can type the command:               *
#      update to_full                                                *
#*********************************************************************
#                                                                    
#*********************************************************************
# Tag name for the run (one word)                                    *
#*********************************************************************
  tag_1 = run_tag ! name of the run 
#*********************************************************************
# Number of events and rnd seed                                      *
# Warning: Do not generate more than 1M events in a single run       *
#*********************************************************************
  10000 = nevents ! Number of unweighted events requested 
 27 = iseed ! rnd seed (0=assigned automatically=default))
#*********************************************************************
# Collider type and energy                                           *
# lpp: 0=No PDF, 1=proton, -1=antiproton, 2=elastic photon of proton,*
#             +/-3=PDF of electron/positron beam                     *
#             +/-4=PDF of muon/antimuon beam                         *
#*********************************************************************
  0 = lpp1 ! beam 1 type 
  1 = lpp2 ! beam 2 type
  12.0  = ebeam1 ! beam 1 total energy in GeV
  0.938 = ebeam2 ! beam 2 total energy in GeV
#*********************************************************************
# Beam polarization from -100 (left-handed) to 100 (right-handed)    *
#*********************************************************************
  -100.0    = polbeam1 ! beam polarization for beam 1
  0.0   = polbeam2 ! beam polarization for beam 2


#*********************************************************************
# PDF CHOICE: this automatically fixes alpha_s and its evol.         *
# pdlabel: lhapdf=LHAPDF (installation needed) [1412.7420]           *
#          iww=Improved Weizsaecker-Williams Approx.[hep-ph/9310350] *
#          eva=Effective W/Z/A Approx.       [21yy.zzzzz]            *
#          none=No PDF, same as lhapdf with lppx=0                   *
#*********************************************************************
  none  = pdlabel1 ! PDF type for beam #1
  nn23lo1   = pdlabel2 ! PDF type for beam #2
  230000    = lhaid ! if pdlabel=lhapdf, this is the lhapdf number
# To see heavy ion options: type "update ion_pdf"
#*********************************************************************
# Renormalization and factorization scales                           *
#*********************************************************************
  True  = fixed_ren_scale ! if .true. use fixed ren scale
  True  = fixed_fac_scale1 ! if .true. use fixed fac scale for beam 1
  True  = fixed_fac_scale2 ! if .true. use fixed fac scale for beam 2
  91.188    = scale ! fixed ren scale
  91.188    = dsqrt_q2fact1 ! fixed fact scale for pdf1
  91.188    = dsqrt_q2fact2 ! fixed fact scale for pdf2
  -1    = dynamical_scale_choice ! Choose one of the preselected dynamical choices
  1.0   = scalefact ! scale factor for event-by-event scales

  0 = ievo_eva ! scale evolution for EW pdfs (eva):
                         ! 0 for evo by q^2; 1 for evo by pT^2

#*********************************************************************
# Type and output format
#*********************************************************************
  False = gridpack !True = setting up the grid pack
  -1.0  = time_of_flight ! threshold (in mm) below which the invariant livetime is not written (-1 means not written)
  average   = event_norm ! average/sum. Normalization of the weight in the LHEF
# To see MLM/CKKW  merging options: type "update MLM" or "update CKKW"

#*********************************************************************
#
#*********************************************************************
# Phase-Space Optimization strategy (basic options)
#*********************************************************************
  0 = nhel ! using helicities importance sampling or not.
                             ! 0: sum over helicity, 1: importance sampling
  2 = sde_strategy ! default integration strategy (hep-ph/2021.00773)
                             ! 1 is old strategy (using amp square)
                 ! 2 is new strategy (using only the denominator)
# To see advanced option for Phase-Space optimization: type "update psoptim"                 
#*********************************************************************
# Generation bias, check the wiki page below for more information:   *
#  'cp3.irmp.ucl.ac.be/projects/madgraph/wiki/LOEventGenerationBias' *
#*********************************************************************
  None  = bias_module ! Bias type of bias, [None, ptj_bias, -custom_folder-]
  {}    = bias_parameters ! Specifies the parameters of the module.
#
#*******************************                                                 
# Parton level cuts definition *
#*******************************
  0.0   = dsqrt_shat ! minimal shat for full process
#                                                                    
#
#*********************************************************************
# BW cutoff (M+/-bwcutoff*Gamma) ! Define on/off-shell for "$" and decay  
#*********************************************************************
  15.0  = bwcutoff ! (M+/-bwcutoff*Gamma)
#*********************************************************************
# Standard Cuts                                                      *
#*********************************************************************
# Minimum and maximum pt's (for max, -1 means no cut)                *
#*********************************************************************
  0.0   = ptj ! minimum pt for the jets 
  0.0   = ptl ! minimum pt for the charged leptons 
  -1.0  = ptjmax ! maximum pt for the jets
  -1.0  = ptlmax ! maximum pt for the charged leptons
  {'88288': 0.5}    = pt_min_pdg ! pt cut for other particles (use pdg code). Applied on particle and anti-particle
  {}    = pt_max_pdg ! pt cut for other particles (syntax e.g. {6: 100, 25: 50}) 
#
# For display option for energy cut in the partonic center of mass frame type 'update ecut'
#
#*********************************************************************
# Maximum and minimum absolute rapidity (for max, -1 means no cut)   *
#*********************************************************************
  -1.0  = etaj ! max rap for the jets 
  -1.0  = etal ! max rap for the charged leptons 
  0.0   = etalmin ! main rap for the charged leptons
  {}    = eta_min_pdg ! rap cut for other particles (use pdg code). Applied on particle and anti-particle
  {}    = eta_max_pdg ! rap cut for other particles (syntax e.g. {6: 2.5, 23: 5})
#*********************************************************************
# Minimum and maximum DeltaR distance                                *
#*********************************************************************
  0.0   = drjl ! min distance between jet and lepton 
  -1.0  = drjlmax ! max distance between jet and lepton
#*********************************************************************
# Minimum and maximum invariant mass for pairs                       *
#*********************************************************************
  {}    = mxx_min_pdg ! min invariant mass of a pair of particles X/X~ (e.g. {6:250})
  {'default': False}    = mxx_only_part_antipart ! if True the invariant mass is applied only 
                       ! to pairs of particle/antiparticle and not to pairs of the same pdg codes.  
#*********************************************************************
# Inclusive cuts                                                     *
#*********************************************************************
#*********************************************************************
# maximal pdg code for quark to be considered as a light jet         *
# (otherwise b cuts are applied)                                     *
#*********************************************************************
  4 = maxjetflavor ! Maximum jet pdg code
#*********************************************************************
#
#*********************************************************************
# Store info for systematics studies                                 *
# WARNING: Do not use for interference type of computation           *
#*********************************************************************
  True  = use_syst ! Enable systematics studies
#
  systematics   = systematics_program ! none, systematics [python], SysCalc [depreceted, C++]
  ['--mur=0.5,1,2', '--muf=0.5,1,2', '--pdf=errorset']  = systematics_arguments ! see: https://cp3.irmp.ucl.ac.be/projects/madgraph/wiki/Systematics#Systematicspythonmodule
]]>
</MGRunCard>
<slha>
######################################################################
## PARAM_CARD AUTOMATICALY GENERATED BY MG5                       ####
######################################################################
###################################
## INFORMATION FOR FRBLOCK
###################################
BLOCK FRBLOCK # 
      1 1.000000e+00 # gphi
      2 2.327350e-01 # gpnw
      3 2.327350e-01 # gnumumw
###################################
## 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
      88188 9.380000e-01 # mp
      88189 9.390000e-01 # mn
      88190 0.000000e+00 # mnumu
      88288 2.000000e-01 # mphi
      1 0.000000e+00 # d : 0.0
      2 0.000000e+00 # u : 0.0
      3 0.000000e+00 # s : 0.0
      4 0.000000e+00 # c : 0.0
      11 0.000000e+00 # e- : 0.0
      12 0.000000e+00 # ve : 0.0
      13 0.000000e+00 # mu- : 0.0
      14 0.000000e+00 # vm : 0.0
      16 0.000000e+00 # vt : 0.0
      21 0.000000e+00 # g : 0.0
      22 0.000000e+00 # a : 0.0
      24 7.982436e+01 # 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.300000e-01 # as (note that parameter not used if you use a pdf set)
###################################
## 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 23 2.495200e+00 # wz
DECAY 24 2.085000e+00 # ww
DECAY 25 4.070000e-03 # wh
DECAY 88188 0.000000e+00 # wnp
DECAY 88189 0.000000e+00 # wnn
DECAY 1 0.000000e+00 # d : 0.0
DECAY 2 0.000000e+00 # u : 0.0
DECAY 3 0.000000e+00 # s : 0.0
DECAY 4 0.000000e+00 # c : 0.0
DECAY 5 0.000000e+00 # b : 0.0
DECAY 11 0.000000e+00 # e- : 0.0
DECAY 12 0.000000e+00 # ve : 0.0
DECAY 13 0.000000e+00 # mu- : 0.0
DECAY 14 0.000000e+00 # vm : 0.0
DECAY 15 0.000000e+00 # ta- : 0.0
DECAY 16 0.000000e+00 # vt : 0.0
DECAY 21 0.000000e+00 # g : 0.0
DECAY 22 0.000000e+00 # a : 0.0
DECAY 88190 0.000000e+00 # numu : 0.0
DECAY 88288 0.000000e+00 # phi : 0.0
###################################
## INFORMATION FOR QNUMBERS 88188
###################################
BLOCK QNUMBERS 88188 #  np
      1 3 # 3 times electric charge
      2 2 # number of spin states (2s+1)
      3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
      4 1 # particle/antiparticle distinction (0=own anti)
###################################
## INFORMATION FOR QNUMBERS 88189
###################################
BLOCK QNUMBERS 88189 #  nn
      1 0 # 3 times electric charge
      2 2 # number of spin states (2s+1)
      3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
      4 1 # particle/antiparticle distinction (0=own anti)
###################################
## INFORMATION FOR QNUMBERS 88190
###################################
BLOCK QNUMBERS 88190 #  numu
      1 0 # 3 times electric charge
      2 2 # number of spin states (2s+1)
      3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
      4 0 # particle/antiparticle distinction (0=own anti)
###################################
## INFORMATION FOR QNUMBERS 88288
###################################
BLOCK QNUMBERS 88288 #  phi
      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)
</slha>
<MGPythiaCard>
<![CDATA[
!
! It is possible to run this card manually with:
!    LD_LIBRARY_PATH=/home/name/Downloads/mg5/HEPTools/lib:$LD_LIBRARY_PATH /home/name/Downloads/mg5/HEPTools/MG5aMC_PY8_interface/MG5aMC_PY8_interface tag_1_pythia8.cmd
!
!
! Pythia8 cmd card automatically generated by MadGraph5_aMC@NLO
! For more information on the use of the MG5aMC / Pythia8 interface, visit
!    https://cp3.irmp.ucl.ac.be/projects/madgraph/wiki/LOPY8Merging
!
! ==================
! General parameters 
! ==================
!
Main:numberOfEvents      = -1
!
! -------------------------------------------------------------------
! Specify the HEPMC output of the Pythia8 shower. You can set it to:
!   hepmc       : MG5aMC will automatically place it the run_<i> directory
!   hepmc.gz    : Same as 'hepmc', but also will compress the output file.
!   hepmcremove : MG5aMC will automatically remove the file at the end of the run.
!                 (usefull when running with Delphes)
!   hepmc@<hepmc_path> :
!                 User defined path where the HEPMC file must written. It will
!                 therefore not be placed in the run_<i> directory. The
!                 specified path, if not absolute, will be relative to
!                 the Event/run_<i> directory of the process output.
!   /dev/null : to turn off the HEPMC output.
!   fifo      : to have MG5aMC setup the piping of the PY8 output to 
!               analysis tools such as MadAnalysis5.  
!   fifo@<fifo_path> :
!               Same as 'fifo', but selecting a custom path to create the
!               fifo pipe. (useful to select a mounted drive that supports 
!               fifo). Note that the fifo file extension *must* be '.hepmc.fifo'.
! -------------------------------------------------------------------
!
HEPMCoutput:file         = tag_1_pythia8_events.hepmc
!
! --------------------------------------------------------------------
! Parameters relevant only when performing MLM merging, which can be
! turned on by setting ickkw to '1' in the run_card and chosing a 
! positive value for the parameter xqcut.
! For details, see section 'Jet Matching' on the left-hand menu of 
!    http://home.thep.lu.se/~torbjorn/pythia81html/Welcome.html
! --------------------------------------------------------------------
! If equal to -1.0, MadGraph5_aMC@NLO will set it automatically based 
! on the parameter 'xqcut' of the run_card.dat 
! The following parameter was forced to be commented out by MG5aMC.
! JetMatching:qCut         = -1.0
! Use default kt-MLM to match parton level jets to those produced by the
! shower. But the other Shower-kt scheme is available too with this option.
! The following parameter was forced to be commented out by MG5aMC.
! JetMatching:doShowerKt   = off
! A value of -1 means that it is automatically guessed by MadGraph.
! It is however always safer to explicitly set it.
! The following parameter was forced to be commented out by MG5aMC.
! JetMatching:nJetMax      = -1
!
! --------------------------------------------------------------------
! Parameters relevant only when performing CKKW-L merging, which can
! be turned on by setting the parameter 'ptlund' *or* 'ktdurham' to
! a positive value. 
! For details, see section 'CKKW-L Merging' on the left-hand menu of 
!    http://home.thep.lu.se/~torbjorn/pythia81html/Welcome.html
! --------------------------------------------------------------------
! Central merging scale values you want to be used.
! If equal to -1.0, then MadGraph5_aMC@NLO will set this automatically
! based on the parameter 'ktdurham' of the run_card.dat
! The following parameter was forced to be commented out by MG5aMC.
! Merging:TMS              = -1.0
! This must be set manually, according to Pythia8 directives.
! An example of possible value is 'pp>LEPTONS,NEUTRINOS'
! Alternatively, from Pythia v8.223 onwards, the value 'guess' can be 
! used to instruct Pythia to guess the hard process. The guess would mean 
! that all particles apart from light partons will be considered as a part 
! of the hard process. This guess is prone to errors if the desired hard 
! process is complicated (i.e. contains light partons). The user should
! then be wary of suspicious error messages in the Pythia log file. 
! The following parameter was forced to be commented out by MG5aMC.
! Merging:Process          = <set_by_user>
! A value of -1 means that it is automatically guessed by MadGraph.
! It is however always safer to explicitly set it.
! The following parameter was forced to be commented out by MG5aMC.
! Merging:nJetMax        = -1
!
! For all merging schemes, decide whehter you want the merging scale
! variation computed for only the central weights or all other 
! PDF and scale variation weights as well
SysCalc:fullCutVariation = off
!
! ==========================
! User customized parameters 
! ==========================
!
! By default, Pythia8 generates multi-parton interaction events. This is
! often irrelevant for phenomenology and very slow. You can turn this 
! feature off by uncommenting the line below if so desired.
!partonlevel:mpi = off
!
! Additional technical parameters set by MG5_aMC.
!
! Tell Pythia8 that an LHEF input is used.
Beams:frameType=4
! 1.0 corresponds to HEPMC weight given in [mb]. We choose here the [pb] normalization.
HEPMCoutput:scaling=1.0000000000e+09
! Be more forgiving with momentum mismatches.
Check:epTolErr=1.0000000000e-02
JetMatching:etaJetMax=1.0000000000e+03
! Specify one must read inputs from the MadGraph banner.
JetMatching:setMad=off
! 
!     ====================
!     Subrun definitions
!     ====================
!     
LHEFInputs:nSubruns=1
Main:subrun=0
!
!  Definition of subrun 0
!
Beams:LHEF=unweighted_events.lhe.gz
]]>
</MGPythiaCard>
<MGGenerationInfo>
#  Number of Events        :       10000
#  Integrated weight (pb)  :       9.2277e-06
</MGGenerationInfo>
</header>
<init>
-14 2212 1.200000e+01 9.380000e-01 0 0 247000 247000 -4 1
9.227700e-06 3.975200e-08 9.227700e-06 1
<generator name='MadGraph5_aMC@NLO' version='3.4.0'>please cite 1405.0301 </generator>
</init>
</LesHouchesEvents>

It contains the following string:

  12.0  = ebeam1 ! beam 1 total energy in GeV

Could you please tell me how to scan over the file and extract the single number 12.0?

$\endgroup$
2
  • 1
    $\begingroup$ Is this materially different from this? mathematica.stackexchange.com/a/271686/84894 $\endgroup$
    – lericr
    Commented Aug 15, 2022 at 22:11
  • 2
    $\begingroup$ Please take a look at StringCases. There are probably several different ways, depending on how the structure of the file changes. One possibility is StringCases[text, d : (DigitCharacter | ".") .. ~~ " " .. ~~ "= ebeam1" :> d] $\endgroup$
    – Domen
    Commented Aug 15, 2022 at 22:14

1 Answer 1

5
$\begingroup$

If we import the file as a string, we may use "StringCases" to extract the number. To specify the searched for string "RegularExpression" can be used. E.g. "12.0 = ebeam1 ! beam" can be coded as:

(\d+. \d*) this means 1 or more digits followed by a period followed by zero or more digits. The brackets store the number for later use.

\s+ means one or more space

= ebeam1 ! beam this is understood literally

Finally we need to convert the string to a number:

str = Import["d:/tmp/test.txt"];
ToExpression[
  StringCases[str, 
   RegularExpression["(\\d+\.\\d*)\s+= ebeam1 ! beam"] :> "$1"]][[1]]

(* 12. *)
$\endgroup$
1
  • $\begingroup$ Thank you very much for the detailed explanation! $\endgroup$ Commented Aug 16, 2022 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.