File indexing completed on 2026-08-22 09:16:31
0001
0002
0003
0004
0005
0006 #ifndef PYTHIA_PARALLEL_H
0007 #define PYTHIA_PARALLEL_H
0008
0009 #include "Pythia8/Pythia.h"
0010 #include "Pythia8/PythiaStdlib.h"
0011
0012 namespace Pythia8 {
0013
0014
0015
0016
0017
0018 class PythiaParallel {
0019
0020 public:
0021
0022
0023 PythiaParallel(string xmlDir = "../share/Pythia8/xmldoc",
0024 bool printBanner = true);
0025
0026
0027 bool readString(string setting, bool warn = true) {
0028 return pythiaHelper.readString(setting, warn); }
0029
0030
0031 bool readFile(string fileName, bool warn = true,
0032 int subrun = SUBRUNDEFAULT);
0033 bool readFile(string fileName, int subrun) {
0034 return readFile(fileName, true, subrun); }
0035 bool readFile(istream& is = cin, bool warn = true,
0036 int subrun = SUBRUNDEFAULT);
0037 bool readFile(istream& is, int subrun) {
0038 return readFile(is, true, subrun);}
0039
0040
0041 bool init();
0042 bool init(function<bool(Pythia*)> additionalSetup);
0043
0044
0045 void foreach(function<void(Pythia*)> action);
0046
0047
0048 void foreachAsync(function<void(Pythia*)> action);
0049
0050
0051
0052
0053
0054 void stat(bool combine = true);
0055
0056
0057 vector<long> run(long nEvents, function<void(Pythia*)> callback);
0058 vector<long> run(function<void(Pythia*)> callback) {
0059 return run(settings.mode("Main:numberOfEvents"), callback); }
0060
0061
0062 Pythia pythiaHelper;
0063
0064
0065 double sigmaGen() const { return sigmaGenSave; }
0066
0067
0068 double weightSum() const { return weightSumSave; }
0069
0070
0071 Settings& settings;
0072
0073
0074 ParticleData& particleData;
0075
0076 private:
0077
0078
0079 Logger& logger;
0080
0081
0082 bool isInit = false;
0083
0084
0085 double weightSumSave, sigmaGenSave;
0086
0087
0088 int numThreads;
0089 bool processAsync;
0090 bool balanceLoad;
0091 bool doNext;
0092
0093
0094 vector<unique_ptr<Pythia> > pythiaObjects;
0095
0096
0097 mutex mainMutex;
0098
0099 };
0100
0101
0102
0103 }
0104
0105 #endif