forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythia8HepMC3.C
More file actions
44 lines (37 loc) · 1.25 KB
/
Pythia8HepMC3.C
File metadata and controls
44 lines (37 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/// \author Marco Giacalone - March 2025
// A simple wrapper and demonstrator around Pythia8 for extracting HepMC3 files.
#include "Pythia8/Pythia.h"
#include "Pythia8Plugins/HepMC3.h"
using namespace o2::eventgen;
class HepMC3_Pythia8Wrapper : public GeneratorPythia8
{
public:
HepMC3_Pythia8Wrapper(std::string filename = "pythia8.hepmc") : GeneratorPythia8(), mFileName(filename)
{
// HepMC conversion object.
mToHepMC = std::make_unique<Pythia8::Pythia8ToHepMC>();
mToHepMC->setNewFile((filename == "" ? "pythia.hepmc" : filename));
};
~HepMC3_Pythia8Wrapper() = default;
bool importParticles() override
{
// events are written after the importParticles step
// since some filtering is happening there
auto ret = GeneratorPythia8::importParticles();
if (ret) {
LOG(info) << "Writing event to HepMC3 format";
mToHepMC->writeNextEvent(mPythia);
}
return ret;
};
private:
std::string mFileName = "pythia8.hepmc";
std::unique_ptr<Pythia8::Pythia8ToHepMC> mToHepMC;
};
FairGenerator*
hepmc_pythia8(std::string filename = "pythia8.hepmc")
{
std::cout << "HepMC3_Pythia8Wrapper initialising with filename: " << filename << std::endl;
auto py8 = new HepMC3_Pythia8Wrapper(filename);
return py8;
}