Skip to content

Commit 69951ca

Browse files
committed
External Pythia8+Powheg generator
1 parent f503c23 commit 69951ca

23 files changed

+954
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
R__ADD_INCLUDE_PATH($O2DPG_MC_CONFIG_ROOT)
2+
///#include "FairGenerator.h"
3+
//#include "Generators/GeneratorPythia8.h"
4+
#include "Pythia8/Pythia.h"
5+
#include "Generators/GeneratorPythia8Param.h"
6+
// Pythia8 generator with POWHEG
7+
//
8+
// Author: Marco Giacalone (marco.giacalone@cern.ch)
9+
10+
// o2-sim-dpl-eventgen --nEvents 10 --generator external\
11+
--configKeyValues "GeneratorExternal.fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGGAJE/external/\
12+
generator/generator_pythia8_powheg.C;GeneratorExternal.funcName=\
13+
getGeneratorJEPythia8POWHEG(\"powheg.input\",\"${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGGAJE/pythia8/generator/pythia8_powheg.cfg\")"
14+
// or with iniFile
15+
// o2-sim -g external --noGeant -n 2 -j 8 --configFile $O2DPG_MC_CONFIG_ROOT/MC/config/PWGGAJE/ini/GeneratorPythia8POWHEG.ini
16+
17+
namespace o2
18+
{
19+
namespace eventgen
20+
{
21+
22+
using namespace Pythia8;
23+
24+
class GeneratorJEPythia8POWHEG : public o2::eventgen::GeneratorPythia8
25+
{
26+
public:
27+
/// default constructor
28+
GeneratorJEPythia8POWHEG(std::string confpath = "pwgpath")
29+
{
30+
// Check if file exist and is not empty
31+
if (std::filesystem::exists(confpath) && std::filesystem::file_size(confpath) > 0) {
32+
// Copy the file to the current directory
33+
ifstream src(confpath);
34+
ofstream dst("powheg.input");
35+
gRandom->SetSeed(0);
36+
int seed = gRandom->Integer(900000000);
37+
bool isseed = false;
38+
bool isnumevts = false;
39+
std::string line;
40+
while (std::getline(src, line)) {
41+
if (line.find("iseed") != std::string::npos)
42+
{
43+
// Set the seed to the random number
44+
line = "iseed " + std::to_string(seed);
45+
isseed = true;
46+
}
47+
if (line.find("numevts") != std::string::npos)
48+
{
49+
// Set the number of events to the number of events defined in the configuration
50+
line = "numevts " + std::to_string(mSimConfig.getNEvents());
51+
// replace it in the file
52+
isnumevts = true;
53+
}
54+
dst << line << std::endl;
55+
}
56+
if (!isseed) {
57+
dst << "iseed " << seed << std::endl;
58+
}
59+
if (!isnumevts) {
60+
dst << "numevts " << mSimConfig.getNEvents() << std::endl;
61+
}
62+
src.close();
63+
dst.close();
64+
} else {
65+
LOG(fatal) << "POWHEG configuration file not found or empty" << std::endl;
66+
exit(1);
67+
}
68+
// Generate the POWHEG events
69+
std::string cmd = "pwhg_main_hvq";
70+
system(cmd.c_str());
71+
};
72+
73+
private:
74+
o2::conf::SimConfig mSimConfig = o2::conf::SimConfig::Instance(); // local sim config object
75+
};
76+
77+
} // namespace eventgen
78+
} // namespace o2
79+
80+
/** generator instance and settings **/
81+
82+
FairGenerator *getGeneratorJEPythia8POWHEG(std::string powhegconf = "pwgpath", std::string pythia8conf = "")
83+
{
84+
using namespace o2::eventgen;
85+
// Check if the conf path contains the O2DPG configuration environment variable
86+
if (powhegconf.find("${O2DPG_MC_CONFIG_ROOT}") != std::string::npos) {
87+
powhegconf.replace(powhegconf.find("${O2DPG_MC_CONFIG_ROOT}"), 23, std::getenv("O2DPG_MC_CONFIG_ROOT"));
88+
}
89+
auto myGen = new GeneratorJEPythia8POWHEG(powhegconf);
90+
if(GeneratorPythia8Param::Instance().config.empty() && pythia8conf.empty()) {
91+
LOG(fatal) << "No configuration provided for Pythia8";
92+
}
93+
else if (!pythia8conf.empty())
94+
{
95+
// Force the configuration for Pythia8 in case it is provided.
96+
// Useful for setting up the generator in the hybrid configuration
97+
// making it more versatile and not relying entirely on the parameters provided
98+
// by ini file or static parameters
99+
myGen->setConfig(pythia8conf);
100+
}
101+
return myGen;
102+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
!randomseed 352345 ! uncomment to set the random seed to a value of your choice.
2+
! It generates the call RM48IN(352345,0,0) (see the RM48 manual).
3+
! THIS MAY ONLY AFFECTS THE GENERATION OF POWHEG EVENTS!
4+
! If POWHEG is interfaced to a shower MC, refer to the shower MC
5+
! documentation to set its seed.
6+
7+
!Heavy flavour production parameters
8+
9+
ih1 1 ! hadron 1
10+
ih2 1 ! hadron 2
11+
#ndns1 131 ! pdf for hadron 1 (hvqpdf numbering)
12+
#ndns2 131 ! pdf for hadron 2
13+
!lhans1 11000 ! pdf set for hadron 1 (LHA numbering)
14+
!lhans2 11000 ! pdf set for hadron 2 (LHA numbering)
15+
!ebeam1 3500 ! energy of beam 1
16+
!ebeam2 3500 ! energy of beam 2
17+
!qmass 1.5 ! mass of heavy quark in GeV
18+
!facscfact 1 ! factorization scale factor: mufact=muref*facscfact
19+
!renscfact 1 ! renormalization scale factor: muren=muref*renscfact
20+
#fixedscale 1 ! use ref. scale=qmass (default 0, use running scale)
21+
22+
! Parameters to allow-disallow use of stored data
23+
use-old-grid 1 ! if 1 use old grid if file pwggrids.dat is present (# 1: regenerate)
24+
use-old-ubound 1 ! if 1 use norm of upper bounding function stored in pwgubound.dat, if present; # 1: regenerate
25+
26+
!ncall1 50000 ! number of calls for initializing the integration grid
27+
!itmx1 5 ! number of iterations for initializing the integration grid
28+
!ncall2 100000 ! number of calls for computing the integral and finding upper bound
29+
!itmx2 5 ! number of iterations for computing the integral and finding upper bound
30+
foldcsi 5 ! number of folds on x integration
31+
foldy 5 ! number of folds on y integration
32+
foldphi 1 ! number of folds on phi integration
33+
nubound 500000 ! number of bbarra calls to setup norm of upper bounding function
34+
iymax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
35+
!ixmax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
36+
xupbound 2 ! increase upper bound for radiation generation
37+
qmass 1.5
38+
ncall1 50000
39+
itmx1 5
40+
ncall2 100000
41+
itmx2 5
42+
facscfact 1
43+
renscfact 1
44+
bornktmin 0
45+
bornsuppfact 0
46+
storemintupb 0
47+
lhans1 11000
48+
lhans2 11000
49+
ebeam1 6800
50+
ebeam2 6800
51+
iseed 389759591
52+
numevts 4
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
! Random number generator initializing parameters
2+
iseed 0 ! initialize random number sequence
3+
4+
! Heavy flavour production parameters
5+
numevts 100000 ! number of events to be generated
6+
ih1 1 ! hadron 1 type (1: proton; -1: antiproton)
7+
ih2 1 ! hadron 2 type (1: proton; -1: antiproton)
8+
!ndns1 131 ! pdf for hadron 1 (when using the hvqpdf package, hvqpdf numbering)
9+
!ndns2 131 ! pdf for hadron 2 (when using the hvqpdf package, hvqpdf numbering)
10+
lhans1 11000 ! pdf set for hadron 1 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
11+
lhans2 11000 ! pdf set for hadron 2 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
12+
ebeam1 6800 ! energy of beam 1 in GeV
13+
ebeam2 6800 ! energy of beam 2 in GeV
14+
qmass 4.75 ! mass of heavy quark in GeV
15+
facscfact 0.5 ! factorization scale factor: mufact=muref*facscfact
16+
renscfact 1 ! renormalization scale factor: muren=muref*renscfact
17+
!fixedscale 1 ! use ref. scale=qmass (default 0, use running scale)
18+
19+
! Parameters to allow or not the use of stored data
20+
use-old-grid 1 ! if 1 use old grid if file pwggrids.dat is present (# 1: regenerate)
21+
use-old-ubound 1 ! if 1 use norm of upper bounding function stored in pwgubound.dat, if present; # 1: regenerate
22+
23+
! Parameters that control the grid for Born variables generation
24+
ncall1 10000 ! number of calls for initializing the integration grid
25+
itmx1 5 ! number of iterations for initializing the integration grid
26+
ncall2 100000 ! number of calls for computing the integral and finding upper bound
27+
itmx2 5 ! number of iterations for computing the integral and finding upper bound
28+
foldcsi 5 ! number of folds on x integration
29+
foldy 5 ! number of folds on y integration
30+
foldphi 1 ! number of folds on phi integration
31+
nubound 500000 ! number of bbarra calls to setup norm of upper bounding function
32+
iymax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
33+
ixmax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
34+
xupbound 2 ! increase upper bound for radiation generation
35+
bornktmin 0 ! (default 0d0) Generation cut: minimum kt in underlying Born
36+
bornsuppfact 0 ! (default 0d0) Mass parameter for Born suppression factor. If < 0 suppfact = 1
37+
storemintupb 0 ! store function calls in binary file for more precise generation
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
! Random number generator initializing parameters
2+
iseed 0 ! initialize random number sequence
3+
4+
! Heavy flavour production parameters
5+
numevts 100000 ! number of events to be generated
6+
ih1 1 ! hadron 1 type (1: proton; -1: antiproton)
7+
ih2 1 ! hadron 2 type (1: proton; -1: antiproton)
8+
!ndns1 131 ! pdf for hadron 1 (when using the hvqpdf package, hvqpdf numbering)
9+
!ndns2 131 ! pdf for hadron 2 (when using the hvqpdf package, hvqpdf numbering)
10+
lhans1 11000 ! pdf set for hadron 1 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
11+
lhans2 11000 ! pdf set for hadron 2 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
12+
ebeam1 6800 ! energy of beam 1 in GeV
13+
ebeam2 6800 ! energy of beam 2 in GeV
14+
qmass 4.75 ! mass of heavy quark in GeV
15+
facscfact 0.5 ! factorization scale factor: mufact=muref*facscfact
16+
renscfact 0.5 ! renormalization scale factor: muren=muref*renscfact
17+
!fixedscale 1 ! use ref. scale=qmass (default 0, use running scale)
18+
19+
! Parameters to allow or not the use of stored data
20+
use-old-grid 1 ! if 1 use old grid if file pwggrids.dat is present (# 1: regenerate)
21+
use-old-ubound 1 ! if 1 use norm of upper bounding function stored in pwgubound.dat, if present; # 1: regenerate
22+
23+
! Parameters that control the grid for Born variables generation
24+
ncall1 10000 ! number of calls for initializing the integration grid
25+
itmx1 5 ! number of iterations for initializing the integration grid
26+
ncall2 100000 ! number of calls for computing the integral and finding upper bound
27+
itmx2 5 ! number of iterations for computing the integral and finding upper bound
28+
foldcsi 5 ! number of folds on x integration
29+
foldy 5 ! number of folds on y integration
30+
foldphi 1 ! number of folds on phi integration
31+
nubound 500000 ! number of bbarra calls to setup norm of upper bounding function
32+
iymax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
33+
ixmax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
34+
xupbound 2 ! increase upper bound for radiation generation
35+
bornktmin 0 ! (default 0d0) Generation cut: minimum kt in underlying Born
36+
bornsuppfact 0 ! (default 0d0) Mass parameter for Born suppression factor. If < 0 suppfact = 1
37+
storemintupb 0 ! store function calls in binary file for more precise generation
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
! Random number generator initializing parameters
2+
iseed 0 ! initialize random number sequence
3+
4+
! Heavy flavour production parameters
5+
numevts 100000 ! number of events to be generated
6+
ih1 1 ! hadron 1 type (1: proton; -1: antiproton)
7+
ih2 1 ! hadron 2 type (1: proton; -1: antiproton)
8+
!ndns1 131 ! pdf for hadron 1 (when using the hvqpdf package, hvqpdf numbering)
9+
!ndns2 131 ! pdf for hadron 2 (when using the hvqpdf package, hvqpdf numbering)
10+
lhans1 11000 ! pdf set for hadron 1 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
11+
lhans2 11000 ! pdf set for hadron 2 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
12+
ebeam1 6800 ! energy of beam 1 in GeV
13+
ebeam2 6800 ! energy of beam 2 in GeV
14+
qmass 4.75 ! mass of heavy quark in GeV
15+
facscfact 2 ! factorization scale factor: mufact=muref*facscfact
16+
renscfact 1 ! renormalization scale factor: muren=muref*renscfact
17+
!fixedscale 1 ! use ref. scale=qmass (default 0, use running scale)
18+
19+
! Parameters to allow or not the use of stored data
20+
use-old-grid 1 ! if 1 use old grid if file pwggrids.dat is present (# 1: regenerate)
21+
use-old-ubound 1 ! if 1 use norm of upper bounding function stored in pwgubound.dat, if present; # 1: regenerate
22+
23+
! Parameters that control the grid for Born variables generation
24+
ncall1 10000 ! number of calls for initializing the integration grid
25+
itmx1 5 ! number of iterations for initializing the integration grid
26+
ncall2 100000 ! number of calls for computing the integral and finding upper bound
27+
itmx2 5 ! number of iterations for computing the integral and finding upper bound
28+
foldcsi 5 ! number of folds on x integration
29+
foldy 5 ! number of folds on y integration
30+
foldphi 1 ! number of folds on phi integration
31+
nubound 500000 ! number of bbarra calls to setup norm of upper bounding function
32+
iymax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
33+
ixmax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
34+
xupbound 2 ! increase upper bound for radiation generation
35+
bornktmin 0 ! (default 0d0) Generation cut: minimum kt in underlying Born
36+
bornsuppfact 0 ! (default 0d0) Mass parameter for Born suppression factor. If < 0 suppfact = 1
37+
storemintupb 0 ! store function calls in binary file for more precise generation
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
! Random number generator initializing parameters
2+
iseed 0 ! initialize random number sequence
3+
4+
! Heavy flavour production parameters
5+
numevts 100000 ! number of events to be generated
6+
ih1 1 ! hadron 1 type (1: proton; -1: antiproton)
7+
ih2 1 ! hadron 2 type (1: proton; -1: antiproton)
8+
!ndns1 131 ! pdf for hadron 1 (when using the hvqpdf package, hvqpdf numbering)
9+
!ndns2 131 ! pdf for hadron 2 (when using the hvqpdf package, hvqpdf numbering)
10+
lhans1 11000 ! pdf set for hadron 1 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
11+
lhans2 11000 ! pdf set for hadron 2 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
12+
ebeam1 6800 ! energy of beam 1 in GeV
13+
ebeam2 6800 ! energy of beam 2 in GeV
14+
qmass 4.75 ! mass of heavy quark in GeV
15+
facscfact 2 ! factorization scale factor: mufact=muref*facscfact
16+
renscfact 2 ! renormalization scale factor: muren=muref*renscfact
17+
!fixedscale 1 ! use ref. scale=qmass (default 0, use running scale)
18+
19+
! Parameters to allow or not the use of stored data
20+
use-old-grid 1 ! if 1 use old grid if file pwggrids.dat is present (# 1: regenerate)
21+
use-old-ubound 1 ! if 1 use norm of upper bounding function stored in pwgubound.dat, if present; # 1: regenerate
22+
23+
! Parameters that control the grid for Born variables generation
24+
ncall1 10000 ! number of calls for initializing the integration grid
25+
itmx1 5 ! number of iterations for initializing the integration grid
26+
ncall2 100000 ! number of calls for computing the integral and finding upper bound
27+
itmx2 5 ! number of iterations for computing the integral and finding upper bound
28+
foldcsi 5 ! number of folds on x integration
29+
foldy 5 ! number of folds on y integration
30+
foldphi 1 ! number of folds on phi integration
31+
nubound 500000 ! number of bbarra calls to setup norm of upper bounding function
32+
iymax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
33+
ixmax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
34+
xupbound 2 ! increase upper bound for radiation generation
35+
bornktmin 0 ! (default 0d0) Generation cut: minimum kt in underlying Born
36+
bornsuppfact 0 ! (default 0d0) Mass parameter for Born suppression factor. If < 0 suppfact = 1
37+
storemintupb 0 ! store function calls in binary file for more precise generation
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
! Random number generator initializing parameters
2+
iseed 0 ! initialize random number sequence
3+
4+
! Heavy flavour production parameters
5+
numevts 100000 ! number of events to be generated
6+
ih1 1 ! hadron 1 type (1: proton; -1: antiproton)
7+
ih2 1 ! hadron 2 type (1: proton; -1: antiproton)
8+
!ndns1 131 ! pdf for hadron 1 (when using the hvqpdf package, hvqpdf numbering)
9+
!ndns2 131 ! pdf for hadron 2 (when using the hvqpdf package, hvqpdf numbering)
10+
lhans1 11000 ! pdf set for hadron 1 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
11+
lhans2 11000 ! pdf set for hadron 2 (LHAGLUE number) (11000 = CT10NLO, 10550 = CTEQ66)
12+
ebeam1 6800 ! energy of beam 1 in GeV
13+
ebeam2 6800 ! energy of beam 2 in GeV
14+
qmass 5.00 ! mass of heavy quark in GeV
15+
facscfact 1 ! factorization scale factor: mufact=muref*facscfact
16+
renscfact 1 ! renormalization scale factor: muren=muref*renscfact
17+
!fixedscale 1 ! use ref. scale=qmass (default 0, use running scale)
18+
19+
! Parameters to allow or not the use of stored data
20+
use-old-grid 1 ! if 1 use old grid if file pwggrids.dat is present (# 1: regenerate)
21+
use-old-ubound 1 ! if 1 use norm of upper bounding function stored in pwgubound.dat, if present; # 1: regenerate
22+
23+
! Parameters that control the grid for Born variables generation
24+
ncall1 10000 ! number of calls for initializing the integration grid
25+
itmx1 5 ! number of iterations for initializing the integration grid
26+
ncall2 100000 ! number of calls for computing the integral and finding upper bound
27+
itmx2 5 ! number of iterations for computing the integral and finding upper bound
28+
foldcsi 5 ! number of folds on x integration
29+
foldy 5 ! number of folds on y integration
30+
foldphi 1 ! number of folds on phi integration
31+
nubound 500000 ! number of bbarra calls to setup norm of upper bounding function
32+
iymax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
33+
ixmax 1 ! <= 10, normalization of upper bounding function in iunorm X iunorm square in y, log(m2qq)
34+
xupbound 2 ! increase upper bound for radiation generation
35+
bornktmin 0 ! (default 0d0) Generation cut: minimum kt in underlying Born
36+
bornsuppfact 0 ! (default 0d0) Mass parameter for Born suppression factor. If < 0 suppfact = 1
37+
storemintupb 0 ! store function calls in binary file for more precise generation

0 commit comments

Comments
 (0)