running a bash code

Asked by Ilirjan Margjeka on 2018-09-28

Hi there,

I would like to write a .sh code to execute in an external machine, where the bash code should be executed.
If I put the timer to 1, it will not ask me any question when I launch the generation and this if fine. But, there is also the pythia card, the pythia-pgs card and the delphes card.
In the .sh file I write:

 ./../bin/generate_events > madgraph.log 2>&1

in order to send this job to the machine and to run bin/generate_event. How can say to the machine to run after the simple generation also to run also the others without making the question?

Cheers!
I.M.

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Olivier Mattelaer
Solved:
2018-09-29
Last query:
2018-09-29
Last reply:
2018-09-29

Olivier Mattelaer suggests this article as an answer to your question:
FAQ #2186: “How to script MG5 run?”.

Note that if you just want to keep all the cards as in a previous run then you can also do
./bin/generate_events -f

Cheers,

Olivier

Ilirjan Margjeka (ilir92) said : #3

Hi Olivier,

If I understand right, you mean:

1) cd MG directory/ work_area and here build the .sh script
2)in the .sh script should stay first ./../bin/mg5_aMC and write exactly the list of commands to run;
3) and at the end pf the .sh scrit should be ./bin/madevent
 so more or less something like this?

#!/bin/bash

cd /afs/cern.ch/work/m/mmelodea/private/CMSSW_8_0_2/src/MG5_aMC_v2_6_1/work_area/

eval `scramv1 runtime -sh`

./../bin/mg5_aMC

import model BSM_gg_hh
generate p p > h h
output RECAS_stuff
launch RECAS_stuff
shower=Pythia6
detector=PGS
analysis=ExRoot
madspin=OFF
reweight=OFF

cd /afs/cern.ch/work/m/mmelodea/private/CMSSW_8_0_2/src/MG5_aMC_v2_6_1/work_area/PP_HH_bbZZ_bb4l/Events/

eval `scramv2 runtime -sh`

./../bin/madevent > madgraph_1.log

Because I am not getting it really.
What should I do better?

Hi,

No you should do:
echo "import model BSM_gg_hh" > mycmd
echo "generate p p > h h" >> mycmd
#(I let you continue all those line like that)
./../bin/mg5_aMC mycmd > madgraph_1.log

Cheers,

Olivier

> On 28 Sep 2018, at 18:22, Ilirjan Margjeka <email address hidden> wrote:
>
> Question #674480 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/674480
>
> Ilirjan Margjeka posted a new comment:
> Hi Olivier,
>
> If I understand right, you mean:
>
> 1) cd MG directory/ work_area and here build the .sh script
> 2)in the .sh script should stay first ./../bin/mg5_aMC and write exactly the list of commands to run;
> 3) and at the end pf the .sh scrit should be ./bin/madevent
> so more or less something like this?
>
>
> #!/bin/bash
>
> cd
> /afs/cern.ch/work/m/mmelodea/private/CMSSW_8_0_2/src/MG5_aMC_v2_6_1/work_area/
>
> eval `scramv1 runtime -sh`
>
> ./../bin/mg5_aMC
>
> import model BSM_gg_hh
> generate p p > h h
> output RECAS_stuff
> launch RECAS_stuff
> shower=Pythia6
> detector=PGS
> analysis=ExRoot
> madspin=OFF
> reweight=OFF
>
> cd
> /afs/cern.ch/work/m/mmelodea/private/CMSSW_8_0_2/src/MG5_aMC_v2_6_1/work_area/PP_HH_bbZZ_bb4l/Events/
>
> eval `scramv2 runtime -sh`
>
> ./../bin/madevent > madgraph_1.log
>
> Because I am not getting it really.
> What should I do better?
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Ilirjan Margjeka (ilir92) said : #5

Hi Olivier,
I tried as you told me over there doing:

#!/bin/bash

echo "import model BSM_gg_hh" >mycmd

echo "generate p p > h h" >mycmd

echo "output RECAS_stuff" >mycmd

echo "launch RECAS_stuff" >mycmd

echo "shower=Pythia6 " >mycmd

echo "detector=PGS" >mycmd

echo "analysis=ExRoot" >mycmd

cd /MG5_aMC_v2_6_1/work_area/

eval `scramv1 runtime -sh`

./../bin/mg5_aMC mycmd > py_pgs_del.log

but as error I get:

load MG5 configuration from ../input/mg5_configuration.txt
None does not seem to correspond to a valid fastjet-config executable (v3+). We will use fjcore instead.
 Please set the 'fastjet'variable to the full (absolute) /PATH/TO/fastjet-config (including fastjet-config).
 MG5_aMC> set fastjet /PATH/TO/fastjet-config

set lhapdf to /lustrehome/imargjek/CMSSW_8_0_2/src/MG5_aMC_v2_6_1/HEPTools/lhapdf6/bin/lhapdf-config
Using default text editor "vi". Set another one in ./input/mg5_configuration.txt
Using default eps viewer "gv". Set another one in ./input/mg5_configuration.txt
No valid web browser found. Please set in ./input/mg5_configuration.txt
import /lustrehome/imargjek/CMSSW_8_0_2/src/MG5_aMC_v2_6_1/work_area/mycmd
The import format was not given, so we guess it as command
analysis=ExRoot
^[[1;34mCommand "analysis=ExRoot" not recognized, please try again^[[0m
quit

what should I do?

Cheers
I.M.

Ilirjan Margjeka (ilir92) said : #6

and when I do only

./../bin/mg5_aMC > py_pgs_del.log

so without mycmd here, I do get from py_pgs_del.log:

load MG5 configuration from ../input/mg5_configuration.txt
None does not seem to correspond to a valid fastjet-config executable (v3+). We will use fjcore instead.
 Please set the 'fastjet'variable to the full (absolute) /PATH/TO/fastjet-config (including fastjet-config).
 MG5_aMC> set fastjet /PATH/TO/fastjet-config

set lhapdf to /lustrehome/imargjek/CMSSW_8_0_2/src/MG5_aMC_v2_6_1/HEPTools/lhapdf6/bin/lhapdf-config
Using default text editor "vi". Set another one in ./input/mg5_configuration.txt
Using default eps viewer "gv". Set another one in ./input/mg5_configuration.txt
No valid web browser found. Please set in ./input/mg5_configuration.txt
Loading default model: sm
INFO: Restrict model sm with file ../models/sm/restrict_default.dat .
INFO: Run "set stdout_level DEBUG" before import for more information.
INFO: Change particles name to pass to MG5 convention
Defined multiparticle p = g u c d s u~ c~ d~ s~
Defined multiparticle j = g u c d s u~ c~ d~ s~
Defined multiparticle l+ = e+ mu+
Defined multiparticle l- = e- mu-
Defined multiparticle vl = ve vm vt
Defined multiparticle vl~ = ve~ vm~ vt~
Defined multiparticle all = g u c d s u~ c~ d~ s~ a ve vm vt e- mu- ve~ vm~ vt~ e+ mu+ t b t~ b~ z w+ h w- ta- ta+
MG5_aMC>

and nothing else.

It seams that my mash system here doesn't read those commands in that way written over here.
What do you suggest me ?

Cheers
I.M.

HI,

You only put one ">" instead of two ">>".
If you only put one, you remove any previous entry in the file.
Consequently you only have a single line in your mycmd file.
To check that your .sh script works as expected, you can check the content of the mycmd file
which should contain the line that you want.
i.e. that file should contains the lines:

import model BSM_gg_hh
generate p p > h h
output RECAS_stuff
launch RECAS_stuff
shower=Pythia6
detector=PGS
analysis=ExRoot
madspin=OFF
reweight=OFF

Ilirjan Margjeka (ilir92) said : #8

Hi Olivier,

yes indeed now the mycmd file has those lines, but the script doesnt make the work:

#!/bin/bash

echo "import model BSM_gg_hh">> mycmd

echo "generate p p > h h">> mycmd

echo "output RECAS_stuff">> mycmd

echo "launch RECAS_stuff">> mycmd

echo "shower=Pythia6">> mycmd

echo "detector=PGS">> mycmd

echo "analysis=ExRoot">> mycmd

echo "madspin=OFF">> mycmd

echo "reweight=OFF">> mycmd

cd /lustrehome/imargjek/CMSSW_8_0_2/src/MG5_aMC_v2_6_1/work_area/

eval `scramv1 runtime -sh`

./..bin/mg5_aMC mycmd > py_pgs_del.log

but the py_pgs_del.log is totally empty. the job doesn't start.

Ilirjan Margjeka (ilir92) said : #9

Anyway, Olivier: I have found the mistake now and it is working!

I used wrong thhose commands where they should be in different place to let the .sh file work, more:

#!/bin/bash

cd /MG5_aMC_v2_6_1/work_area/

echo "import model BSM_gg_hh"> mycmd

echo "generate p p > h h">> mycmd

echo "output RECAS_stuff">> mycmd

echo "launch RECAS_stuff">> mycmd

echo "shower=Pythia6">> mycmd

echo "detector=PGS">> mycmd

echo "analysis=ExRoot">> mycmd

echo "madspin=OFF">> mycmd

echo "reweight=OFF">> mycmd

eval `scramv1 runtime -sh`

./../bin/mg5_aMC mycmd > py_pgs_del.log 2>&1

now it working perfectly!!

Thank you Olivier!

Ilirjan Margjeka (ilir92) said : #10

Thanks Olivier Mattelaer, that solved my question.

Ilirjan Margjeka (ilir92) said : #11

Olivier, one more question:

So, in the .sh file to change for example in the par_card.dat from the .sh script how should I do that?

Just like this:

echo "set mt=120" >>mycmd?

or how?

Cheers
I.M.

yes

> On 29 Sep 2018, at 22:17, Ilirjan Margjeka <email address hidden> wrote:
>
> Question #674480 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/674480
>
> Ilirjan Margjeka posted a new comment:
> Olivier, one more question:
>
> So, in the .sh file to change for example in the par_card.dat from the
> .sh script how should I do that?
>
> Just like this:
>
> echo "set mt=120" >>mycmd?
>
> or how?
>
> Cheers
> I.M.
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Ilirjan Margjeka (ilir92) said : #13

Thank you Olivier! you are the best!

Ilirjan Margjeka (ilir92) said : #14

How can I send 2 and more jobbs at the same time using the same:

echo "import model BSM_gg_hh" >mycmd
echo "generate p p > h h" >mycmd

but for different outputs with respective different conditions from the par_car.dat?

Cheers
I.M.

Not sure what you want here and they are probably plenty of ways of doing it.

For example, can do something like (in your mycmd file)
generate p p > t t~
output DIR1
generate p p > h h [QCD]
output DIR2
launch DIR1
set mt 150
launch DIR2
set mt180

You can also do the same via two mycmd file (which is probably better for the above example)

Cheers,

Olivier

> On 30 Sep 2018, at 13:27, Ilirjan Margjeka <email address hidden> wrote:
>
> Question #674480 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/674480
>
> Ilirjan Margjeka posted a new comment:
> How can I send 2 and more jobbs at the same time using the same:
>
> echo "import model BSM_gg_hh" >mycmd
> echo "generate p p > h h" >mycmd
>
> but for different outputs with respective different conditions from the
> par_car.dat?
>
> Cheers
> I.M.
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.