22 #define MAGENTA "\033[35m"
33 JSDEBUG <<
"Initialize PythiaGun";
37 readString(
"Init:showProcesses = off");
38 readString(
"Init:showChangedSettings = off");
39 readString(
"Init:showMultipartonInteractions = off");
40 readString(
"Init:showChangedParticleData = off");
41 if (JetScapeLogger::Instance()->GetInfo()) {
42 readString(
"Init:showProcesses = on");
43 readString(
"Init:showChangedSettings = on");
44 readString(
"Init:showMultipartonInteractions = on");
45 readString(
"Init:showChangedParticleData = on");
49 readString(
"Next:numberShowInfo = 0");
50 readString(
"Next:numberShowProcess = 0");
51 readString(
"Next:numberShowEvent = 0");
55 numbf.setf(ios::fixed, ios::floatfield);
56 numbf.setf(ios::showpoint);
60 std::string s = GetXMLElementText({
"Hard",
"PythiaGun",
"name"});
65 readString(
"HadronLevel:Decay = off");
66 readString(
"HadronLevel:all = off");
67 readString(
"PartonLevel:ISR = on");
68 readString(
"PartonLevel:MPI = on");
70 readString(
"PromptPhoton:all=on");
71 readString(
"WeakSingleBoson:all=off");
72 readString(
"WeakDoubleBoson:all=off");
74 pTHatMin = GetXMLElementDouble({
"Hard",
"PythiaGun",
"pTHatMin"});
75 pTHatMax = GetXMLElementDouble({
"Hard",
"PythiaGun",
"pTHatMax"});
79 readString(
"HardQCD:all = off");
80 readString(
"SoftQCD:nonDiffractive = on");
84 readString(
"HardQCD:all = on");
87 numbf.str(
"PhaseSpace:pTHatMin = "); numbf << pTHatMin; readString(numbf.str());
88 numbf.str(
"PhaseSpace:pTHatMax = "); numbf << pTHatMax; readString(numbf.str());
93 FSR_on = GetXMLElementInt({
"Hard",
"PythiaGun",
"FSR_on"});
95 readString(
"PartonLevel:FSR = on");
97 readString(
"PartonLevel:FSR = off");
100 JSINFO <<
MAGENTA <<
"Pythia Gun with " << pTHatMin <<
" < pTHat < " << pTHatMax;
105 readString(
"Random:setSeed = on");
106 numbi.str(
"Random:seed = ");
107 unsigned int seed = 0;
108 if (RandomXmlDescription) {
112 throw std::runtime_error(
"Cannot parse xml");
115 JSWARN <<
"No <Random> element found in xml, seeding to 0";
119 readString(numbi.str());
122 readString(
"Beams:idA = 2212");
123 readString(
"Beams:idB = 2212");
126 eCM = GetXMLElementDouble({
"Hard",
"PythiaGun",
"eCM"});
127 numbf.str(
"Beams:eCM = ");
129 readString(numbf.str());
132 vir_factor = GetXMLElementDouble({
"Eloss",
"Matter",
"vir_factor"});
133 softMomentumCutoff = GetXMLElementDouble({
"Hard",
"PythiaGun",
"softMomentumCutoff"});
135 std::stringstream
lines;
136 lines << GetXMLElementText({
"Hard",
"PythiaGun",
"LinesToRead"},
false);
138 while (std::getline(lines, s,
'\n')) {
139 if (s.find_first_not_of(
" \t\v\f\r") == s.npos)
141 VERBOSE(7) <<
"Also reading in: " <<
s;
147 throw std::runtime_error(
"Pythia init() failed.");
150 std::ofstream sigma_printer;
151 sigma_printer.open(printer, std::ios::trunc);
157 VERBOSE(1) <<
"Run Hard Process : " << GetId() <<
" ...";
158 VERBOSE(8) <<
"Current Event #" << GetCurrentEvent();
161 vector<Pythia8::Particle> p62;
164 struct greater_than_pt {
165 inline bool operator()(
const Pythia8::Particle &p1,
166 const Pythia8::Particle &p2) {
167 return (p1.pT() > p2.pT());
174 if (!printer.empty()){
175 std::ofstream sigma_printer;
178 sigma_printer <<
"sigma = " << GetSigmaGen() <<
" Err = " << GetSigmaErr() << endl ;
187 for (
int parid = 0; parid <
event.size(); parid++) {
190 Pythia8::Particle &
particle =
event[parid];
196 if( (std::abs(particle.id()) > 1100) && (std::abs(particle.id()) < 6000) && ((std::abs(particle.id())/10)%10 == 0) ){
197 if(particle.id() > 0){particle.id( -1*particle.id()/1000 );}
198 else{particle.id( particle.id()/1000 );}
203 if (particle.status() != 62)
207 if (fabs(particle.id()) > 5 &&
208 (particle.id() != 21 && particle.id() != 22))
213 if (vir_factor > 0. && (particle.pT() < softMomentumCutoff)) {
216 }
else if(vir_factor < 0. && (particle.pAbs() < softMomentumCutoff)) {
219 JSWARN <<
"vir_factor should not be zero.";
226 if (!particle.isFinal())
230 if (fabs(particle.id()) > 5 &&
231 (particle.id() != 21 && particle.id() != 22))
234 p62.push_back(particle);
244 std::sort(p62.begin(), p62.end(), greater_than_pt());
249 if(softQCD && (info.pTHat() >= pTHatMax)){
continue;}
255 double p[4], xLoc[4];
258 for (
int i = 0;
i <= 3;
i++) {
268 VERBOSE(1) <<
"No initial state module, setting the starting location to "
269 "0. Make sure to add e.g. trento before PythiaGun.";
272 ini->SampleABinaryCollisionPoint(x, y);
285 for (
int np = 0; np < p62.size(); ++np) {
286 Pythia8::Particle &
particle = p62.at(np);
288 VERBOSE(7) <<
"Adding particle with pid = " << particle.id()
289 <<
" at x=" << xLoc[1] <<
", y=" << xLoc[2] <<
", z=" << xLoc[3];
291 VERBOSE(7) <<
"Adding particle with pid = " << particle.id()
292 <<
", pT = " << particle.pT() <<
", eta = " << particle.eta()
293 <<
", phi = " << particle.phi() <<
", e = " << particle.e();
295 VERBOSE(7) <<
" at x=" << xLoc[1] <<
", y=" << xLoc[2] <<
", z=" << xLoc[3];
297 auto ptn = make_shared<Parton>(0, particle.id(), 0, particle.pT(), particle.eta(),particle.phi(), particle.e(), xLoc);
298 ptn->set_color(particle.col());
299 ptn->set_anti_color(particle.acol());
300 ptn->set_max_color(1000 * (np + 1));
304 VERBOSE(8) << GetNHardPartons();