Skip to content

Commit 7d84d35

Browse files
jackal1-66sawenzel
authored andcommitted
External Pythia8+Powheg generator
1 parent f6f881b commit 7d84d35

22 files changed

+905
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
#include "CommonUtils/FileSystemUtils.h"
7+
// Pythia8 generator with POWHEG
8+
//
9+
// Author: Marco Giacalone (marco.giacalone@cern.ch)
10+
11+
// o2-sim-dpl-eventgen --nEvents 10 --generator external\
12+
--configKeyValues "GeneratorExternal.fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGGAJE/external/\
13+
generator/generator_pythia8_powheg.C;GeneratorExternal.funcName=\
14+
getGeneratorJEPythia8POWHEG(\"powheg.input\",\"${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGGAJE/pythia8/generator/pythia8_powheg.cfg\")"
15+
// or with iniFile
16+
// o2-sim -g external --noGeant -n 2 -j 8 --configFile $O2DPG_MC_CONFIG_ROOT/MC/config/PWGGAJE/ini/GeneratorPythia8POWHEG.ini
17+
18+
namespace o2
19+
{
20+
namespace eventgen
21+
{
22+
23+
using namespace Pythia8;
24+
25+
// Pythia8 generator using POWHEG data that are generated during the initialization
26+
// of the external generator. The POWHEG configuration file is copied to the current
27+
// directory with the right name and the POWHEG events are generated using the pwhg_main_hvq executable.
28+
class GeneratorJEPythia8POWHEG : public o2::eventgen::GeneratorPythia8
29+
{
30+
public:
31+
/// default constructor
32+
GeneratorJEPythia8POWHEG(std::string confpath = "pwgpath")
33+
{
34+
// Check if file exist and is not empty
35+
if (std::filesystem::exists(confpath) && std::filesystem::file_size(confpath) > 0) {
36+
// Copy the file to the current directory
37+
ifstream src(confpath);
38+
ofstream dst("powheg.input");
39+
gRandom->SetSeed(0);
40+
int seed = gRandom->Integer(900000000);
41+
bool isseed = false;
42+
bool isnumevts = false;
43+
std::string line;
44+
while (std::getline(src, line)) {
45+
if (line.find("iseed") != std::string::npos)
46+
{
47+
// Set the seed to the random number
48+
line = "iseed " + std::to_string(seed);
49+
isseed = true;
50+
}
51+
if (line.find("numevts") != std::string::npos)
52+
{
53+
// Set the number of events to the number of events defined in the configuration
54+
line = "numevts " + std::to_string(mSimConfig.getNEvents());
55+
// replace it in the file
56+
isnumevts = true;
57+
}
58+
dst << line << std::endl;
59+
}
60+
if (!isseed) {
61+
dst << "iseed " << seed << std::endl;
62+
}
63+
if (!isnumevts) {
64+
dst << "numevts " << mSimConfig.getNEvents() << std::endl;
65+
}
66+
src.close();
67+
dst.close();
68+
} else {
69+
LOG(fatal) << "POWHEG configuration file not found or empty" << std::endl;
70+
exit(1);
71+
}
72+
// Generate the POWHEG events
73+
std::string cmd = "pwhg_main_hvq";
74+
system(cmd.c_str());
75+
};
76+
77+
private:
78+
o2::conf::SimConfig mSimConfig = o2::conf::SimConfig::Instance(); // local sim config object
79+
};
80+
81+
} // namespace eventgen
82+
} // namespace o2
83+
84+
/** generator instance and settings **/
85+
86+
FairGenerator *getGeneratorJEPythia8POWHEG(std::string powhegconf = "pwgpath", std::string pythia8conf = "")
87+
{
88+
using namespace o2::eventgen;
89+
// Expand paths for the POWHEG configuration file
90+
powhegconf = o2::utils::expandShellVarsInFileName(powhegconf);
91+
LOG(info) << "Using POWHEG configuration file: " << powhegconf;
92+
auto myGen = new GeneratorJEPythia8POWHEG(powhegconf);
93+
if(GeneratorPythia8Param::Instance().config.empty() && pythia8conf.empty()) {
94+
LOG(fatal) << "No configuration provided for Pythia8";
95+
}
96+
else if (!pythia8conf.empty())
97+
{
98+
// Force the configuration for Pythia8 in case it is provided.
99+
// Useful for setting up the generator in the hybrid configuration
100+
// making it more versatile and not relying entirely on the parameters provided
101+
// by ini file or static parameters
102+
myGen->setConfig(pythia8conf);
103+
}
104+
return myGen;
105+
}
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
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.50 ! 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)