File indexing completed on 2025-08-03 08:19:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <iostream>
0017 #include <fstream>
0018 #include <memory>
0019 #include <chrono>
0020 #include <thread>
0021
0022 #include "gzstream.h"
0023 #include "PartonShower.h"
0024 #include "JetScapeLogger.h"
0025 #include "JetScapeReader.h"
0026 #include "JetScapeBanner.h"
0027 #include "fjcore.hh"
0028
0029 #include <GTL/dfs.h>
0030
0031 using namespace std;
0032 using namespace fjcore;
0033
0034 using namespace Jetscape;
0035
0036
0037
0038
0039
0040
0041
0042 int main(int argc, char** argv)
0043 {
0044
0045
0046 JetScapeLogger::Instance()->SetDebug(false);
0047 JetScapeLogger::Instance()->SetRemark(false);
0048
0049
0050 JetScapeLogger::Instance()->SetVerboseLevel(0);
0051
0052
0053
0054
0055 bool writeHeaderV2 = false;
0056 if (argc > 3) {
0057 writeHeaderV2 = static_cast<bool>(argv[3]);
0058 std::cout << "NOTE: Writing header v2, and final cross section and error at EOF.\n";
0059 }
0060
0061
0062 std::string particleSeperator = " ";
0063 if (!writeHeaderV2) {
0064 particleSeperator = "\t";
0065 }
0066
0067 auto reader=make_shared<JetScapeReaderAscii>(argv[1]);
0068 std::ofstream dist_output (argv[2]);
0069 int SN=0, TotalPartons=0;
0070 while (!reader->Finished())
0071 {
0072 reader->Next();
0073
0074
0075 auto mShowers=reader->GetPartonShowers();
0076
0077 TotalPartons = 0;
0078 for (int i=0; i < mShowers.size(); i++)
0079 {
0080 TotalPartons = TotalPartons + mShowers[i]->GetFinalPartons().size();
0081 }
0082
0083 if(TotalPartons > 0)
0084 {
0085 ++SN;
0086 if (writeHeaderV2) {
0087
0088 dist_output << "#"
0089 << "\t" << "Event\t" << SN
0090 << "\t" << "weight\t" << reader->GetEventWeight()
0091 << "\t" << "EPangle\t" << reader->GetEventPlaneAngle()
0092 << "\t" << "N_partons\t" << TotalPartons
0093 << "\t" << "|"
0094 << "\t" << "N"
0095 << "\t" << "pid"
0096 << "\t" << "status"
0097 << "\t" << "E"
0098 << "\t" << "Px"
0099 << "\t" << "Py"
0100 << "\t" << "Pz"
0101 << "\n";
0102 }
0103 else {
0104 dist_output << "#" << "\t"
0105 << reader->GetEventPlaneAngle() << "\t"
0106 << "Event"
0107 << SN << "ID\t"
0108 << TotalPartons << "\t"
0109 << "pstat-EPx" << "\t"
0110 << "Py" << "\t"
0111 << "Pz" << "\t"
0112 << "Eta" << "\t"<< "Phi" << "\n";
0113 }
0114
0115 for (int i=0; i < mShowers.size(); i++)
0116 {
0117
0118
0119 for (int ipart = 0; ipart < mShowers[i]->GetFinalPartons().size(); ++ipart)
0120 {
0121 Parton p = *mShowers[i]->GetFinalPartons().at(ipart);
0122
0123
0124 dist_output << ipart
0125 << particleSeperator << p.pid()
0126 << particleSeperator << p.pstat()
0127 << particleSeperator << p.e()
0128 << particleSeperator << p.px()
0129 << particleSeperator << p.py()
0130 << particleSeperator << p.pz();
0131
0132
0133 if (!writeHeaderV2) {
0134 dist_output << particleSeperator << p.eta()
0135 << particleSeperator << p.phi();
0136 }
0137
0138
0139 dist_output << "\n";
0140 }
0141 }
0142 }
0143 }
0144
0145 if (writeHeaderV2) {
0146
0147 dist_output << "#"
0148 << "\t" << "sigmaGen\t" << reader->GetSigmaGen()
0149 << "\t" << "sigmaErr\t" << reader->GetSigmaErr()
0150 << "\n";
0151 }
0152 reader->Close();
0153 }