running a bash code

Asked by Ilirjan Margjeka

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:
Last query:
Last reply:
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#1

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

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

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

Revision history for this message
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?

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

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.

Revision history for this message
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.

Revision history for this message
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.

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

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

Revision history for this message
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.

Revision history for this message
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!

Revision history for this message
Ilirjan Margjeka (ilir92) said :
#10

Thanks Olivier Mattelaer, that solved my question.

Revision history for this message
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.

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

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.

Revision history for this message
Ilirjan Margjeka (ilir92) said :
#13

Thank you Olivier! you are the best!

Revision history for this message
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.

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

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.