File indexing completed on 2026-04-06 08:10:18
0001 #include <iostream>
0002 #include <cstdlib>
0003 #include "Pythia8/Pythia.h"
0004
0005 #ifndef HEPMC2
0006 #include "Pythia8Plugins/HepMC3.h"
0007 #else
0008 #include "Pythia8Plugins/HepMC2.h"
0009 #endif
0010
0011 using namespace Pythia8;
0012
0013
0014
0015 int main(int argc, char* argv[]) {
0016
0017
0018 std::string outputFile = "main131.hepmc";
0019 int nEvents = 500000;
0020 int seed = 0;
0021
0022
0023 if (argc > 1) {
0024 outputFile = argv[1];
0025 }
0026 if (argc > 2) {
0027 nEvents = std::atoi(argv[2]);
0028 if (nEvents <= 0) {
0029 std::cerr << "Error: number of events must be positive\n";
0030 return 1;
0031 }
0032 }
0033 if (argc > 3) {
0034 seed = std::atoi(argv[3]);
0035 if (seed < 0) {
0036 std::cerr << "Error: seed must be >= 0\n";
0037 return 1;
0038 }
0039 }
0040 if (argc > 4) {
0041 std::cerr << "Usage: " << argv[0]
0042 << " [output.hepmc] [nEvents] [seed]\n";
0043 return 1;
0044 }
0045
0046 std::cout << "Writing HepMC output to: " << outputFile << "\n";
0047 std::cout << "Number of events: " << nEvents << "\n";
0048 std::cout << "Random seed: " << seed << "\n";
0049
0050
0051 Pythia8ToHepMC toHepMC(outputFile);
0052
0053
0054 Pythia pythia;
0055
0056 pythia.readString("Random:setSeed = on");
0057 pythia.readString("Random:seed = " + std::to_string(seed));
0058
0059
0060 pythia.readFile("/sphenix/user/hjheng/sPHENIXRepo/analysis/LightFlavorRatios/macros/simulation/steeringCards/phpythia8_minBias_Detroit.cfg");
0061
0062
0063 if (!pythia.init()) return 1;
0064
0065
0066 for (int iEvent = 0; iEvent < nEvents; ++iEvent) {
0067 if (!pythia.next()) continue;
0068 toHepMC.writeNextEvent(pythia);
0069 }
0070
0071
0072 pythia.stat();
0073
0074 return 0;
0075 }