21 using namespace Jetscape;
39 std::string s = GetXMLElementText({
"JetHadronization",
"name"});
40 JSDEBUG << s <<
" to be initializied ...";
43 GetXMLElementDouble({
"JetHadronization",
"eCMforHadronization"});
49 VERBOSE(2) <<
"Start Hadronizing using the PYTHIA module...";
52 pythia.readString(
"Init:showProcesses = off");
53 pythia.readString(
"Init:showChangedSettings = off");
54 pythia.readString(
"Init:showMultipartonInteractions = off");
55 pythia.readString(
"Init:showChangedParticleData = off");
58 pythia.readString(
"Init:showProcesses = on");
59 pythia.readString(
"Init:showChangedSettings = on");
60 pythia.readString(
"Init:showMultipartonInteractions = on");
61 pythia.readString(
"Init:showChangedParticleData = on");
65 pythia.readString(
"Next:numberShowInfo = 0");
66 pythia.readString(
"Next:numberShowProcess = 0");
67 pythia.readString(
"Next:numberShowEvent = 0");
70 pythia.readString(
"Next:numberShowInfo = 1");
71 pythia.readString(
"Next:numberShowProcess = 1");
72 pythia.readString(
"Next:numberShowEvent = 1");
75 pythia.readString(
"ProcessLevel:all = off");
76 pythia.readString(
"PartonLevel:FSR=off");
79 std::string pythia_decays = GetXMLElementText({
"JetHadronization",
"pythia_decays"});
80 double tau0Max = 10.0;
81 double tau0Max_xml = GetXMLElementDouble({
"JetHadronization",
"tau0Max"});
82 if(tau0Max_xml >= 0){tau0Max = tau0Max_xml;}
83 else{
JSWARN <<
"tau0Max should be larger than 0. Set it to 10.";}
84 if(pythia_decays ==
"on"){
85 JSINFO <<
"Pythia decays are turned on for tau0Max < " << tau0Max;
86 pythia.readString(
"HadronLevel:Decay = on");
87 pythia.readString(
"ParticleDecays:limitTau0 = on");
88 pythia.readString(
"ParticleDecays:tau0Max = " +
std::to_string(tau0Max));
90 JSINFO <<
"Pythia decays are turned off";
91 pythia.readString(
"HadronLevel:Decay = off");
97 GetXMLElementText({
"JetHadronization",
"weak_decays"});
98 if (weak_decays ==
"off") {
99 JSINFO <<
"Hadron decays are turned off.";
100 JSWARN <<
"This parameter will be depracted at some point. Use 'pythia_decays' instead.\nOverwriting 'pythia_decays'.";
101 pythia.readString(
"HadronLevel:Decay = off");
102 }
else if(weak_decays ==
"on") {
103 JSINFO <<
"Hadron decays inside a range of 10 mm/c are turned on.";
104 JSWARN <<
"This parameter will be depracted at some point. Use 'pythia_decays' and 'tau0Max' for more control on decays.\nOverwriting 'pythia_decays' and fix 'tau0Max' to 10.";
105 pythia.readString(
"HadronLevel:Decay = on");
106 pythia.readString(
"ParticleDecays:limitTau0 = on");
107 pythia.readString(
"ParticleDecays:tau0Max = 10.0");
110 std::stringstream
lines;
111 lines << GetXMLElementText({
"JetHadronization",
"LinesToRead"},
false);
112 while (std::getline(lines, s,
'\n')) {
113 if (s.find_first_not_of(
" \t\v\f\r") == s.npos)
115 JSINFO <<
"Also reading in: " <<
s;
116 pythia.readString(s);
127 f->WriteComment(
"Hadronization Module : " + GetId());
128 f->WriteComment(
"Hadronization to be implemented accordingly ...");
135 Event &
event = pythia.event;
139 JSDEBUG <<
"&&&&&&&&&&&&&&&&&&& the number of showers are: " <<
shower.size();
140 for (
unsigned int ishower = 0; ishower <
shower.size(); ++ishower) {
141 JSDEBUG <<
"&&&&&&&&&&&&&&&&&&& there are " <<
shower.at(ishower).size()
142 <<
" partons in the shower number " << ishower;
143 for (
unsigned int ipart = 0; ipart <
shower.at(ishower).size(); ++ipart) {
144 double onshellE = pow(pow(
shower.at(ishower).at(ipart)->px(), 2) +
145 pow(
shower.at(ishower).at(ipart)->py(), 2) +
146 pow(
shower.at(ishower).at(ipart)->pz(), 2),
149 if (
shower.at(ishower).at(ipart)->pid() == 22) {
152 <<
" photon found in colored hadronization with ";
154 <<
"px = " <<
shower.at(ishower).at(ipart)->px();
157 event.append(
shower.at(ishower).at(ipart)->pid(), 23,
158 shower.at(ishower).at(ipart)->color(),
159 shower.at(ishower).at(ipart)->anti_color(),
160 shower.at(ishower).at(ipart)->px(),
161 shower.at(ishower).at(ipart)->py(),
162 shower.at(ishower).at(ipart)->pz(), onshellE);
166 std::vector<int> cols;
167 std::vector<int> acols;
168 for (
unsigned int ipart = 0; ipart <
shower.at(ishower).size(); ++ipart) {
169 if (
shower.at(ishower).at(ipart)->pid() == 22) {
172 if (
shower.at(ishower).at(ipart)->color() != 0) {
173 cols.push_back(
shower.at(ishower).at(ipart)->color());
175 if (
shower.at(ishower).at(ipart)->anti_color() != 0) {
176 acols.push_back(
shower.at(ishower).at(ipart)->anti_color());
182 while (icol < cols.size()) {
183 bool foundpair =
false;
184 for (
int iacol = 0; iacol < acols.size(); ++iacol) {
185 if (cols[icol] == acols[iacol]) {
186 cols.erase(cols.begin() + icol);
187 acols.erase(acols.begin() + iacol);
200 if ((cols.size() > 0) && (acols.size() > 0)) {
203 anti_color = acols[0];
204 }
else if ((cols.size() > 0) && (acols.size() == 0)) {
208 }
else if ((cols.size() == 0) && (acols.size() > 0)) {
211 anti_color = acols[0];
216 event.append(pid, 23, anti_color, color, 0.2, 0.2, pz,
217 sqrt(pz * pz + 0.08));
220 VERBOSE(2) <<
"There are " << hOut.size() <<
" Hadrons and " << pOut.size()
221 <<
" partons after Hadronization";
227 std::vector<std::vector<int>> col_instances;
228 for (
unsigned int i = 0;
i <
event.size(); ++
i) {
231 for (
int icols = 0; icols < col_instances.size(); ++icols) {
232 if (
event[
i].
col() == col_instances[icols][0]) {
233 ++col_instances[icols][1];
236 if (
event[
i].acol() == col_instances[icols][0]) {
237 ++col_instances[icols][1];
242 std::vector<int> tmpcol;
245 col_instances.push_back(tmpcol);
247 if (newacol && (
event[
i].acol() != 0)) {
248 std::vector<int> tmpcol;
249 tmpcol.push_back(
event[
i].acol());
251 col_instances.push_back(tmpcol);
255 std::remove_if(col_instances.begin(), col_instances.end(),
256 [](
const std::vector<int> &val) {
return val[1] <= 2; }),
257 col_instances.end());
259 while (col_instances.size() > 0) {
261 for (
int i =
event.size() - 1;
i >= 0; --
i) {
262 if (col_instances[0][0] ==
event[
i].
col()) {
263 event[
i].col(updcol);
266 if (col_instances[0][0] ==
event[
i].acol()) {
267 event[
i].acol(updcol);
275 col_instances[0][1] -= 2;
277 std::remove_if(col_instances.begin(), col_instances.end(),
278 [](
const std::vector<int> &val) {
return val[1] <= 2; }),
279 col_instances.end());
285 unsigned int ip = hOut.size();
286 for (
unsigned int i = 0;
i <
event.size(); ++
i) {
293 double x[4] = {0, 0, 0, 0};