Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LiquefierBase.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LiquefierBase.cc
1 /*******************************************************************************
2  * Copyright (c) The JETSCAPE Collaboration, 2018
3  *
4  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
5  *
6  * For the list of contributors see AUTHORS.
7  *
8  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
9  *
10  * or via email to bugs.jetscape@gmail.com
11  *
12  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
13  * See COPYING for details.
14  ******************************************************************************/
15 #include "LiquefierBase.h"
16 #include <math.h>
17 
18 namespace Jetscape {
19 
21  : hydro_source_abs_err(1e-10), drop_stat(-11), miss_stat(-13),
22  neg_stat(-17) {
24 }
25 
28  std::array<Jetscape::real, 4> &jmu) const {
29  jmu = {0.0, 0.0, 0.0, 0.0};
30  for (const auto &drop_i : dropletlist) {
31 
32  const auto x_drop = drop_i.get_xmu();
33  double ds2 = tau * tau + x_drop[0] * x_drop[0] -
34  2.0 * tau * x_drop[0] * cosh(eta - x_drop[3]) -
35  (x - x_drop[1]) * (x - x_drop[1]) -
36  (y - x_drop[2]) * (y - x_drop[2]);
37 
38  if (tau >= x_drop[0] && ds2 >= 0.0) {
39  std::array<Jetscape::real, 4> jmu_i = {0.0, 0.0, 0.0, 0.0};
40  smearing_kernel(tau, x, y, eta, drop_i, jmu_i);
41  for (int i = 0; i < 4; i++)
42  jmu[i] += jmu_i[i];
43  }
44  }
45 }
46 
51  const std::vector<Parton> &pIn, std::vector<Parton> &pOut) {
52  FourVector p_init(0., 0., 0., 0.);
53  for (const auto &iparton : pIn) {
54  auto temp = iparton.p_in();
55  if (iparton.pstat() == -1) {
56  p_init -= temp;
57  } else {
58  p_init += temp;
59  }
60  }
61 
62  FourVector p_final(0., 0., 0., 0.);
63  FourVector x_final(0., 0., 0., 0.);
64  for (const auto &iparton : pOut) {
65  auto temp = iparton.p_in();
66  if (iparton.pstat() == -1) {
67  p_final -= temp;
68  } else {
69  p_final += temp;
70  }
71  x_final = iparton.x_in();
72  }
73 
74  FourVector p_missing = p_init;
75  p_missing -= p_final;
76  if (std::abs(p_missing.t()) > hydro_source_abs_err ||
77  std::abs(p_missing.x()) > hydro_source_abs_err ||
78  std::abs(p_missing.y()) > hydro_source_abs_err ||
79  std::abs(p_missing.z()) > hydro_source_abs_err) {
80  JSWARN << "A vertex does not conserve energy momentum!";
81  JSWARN << "E = " << p_missing.t() << " GeV, px = " << p_missing.x()
82  << " GeV, py = " << p_missing.y() << " GeV, pz = " << p_missing.z()
83  << " GeV.";
84  Parton parton_miss(0, 21, miss_stat, p_missing, x_final);
85  pOut.push_back(parton_miss);
86  }
87 }
88 
89 void LiquefierBase::filter_partons(std::vector<Parton> &pOut) {
90  // if e_threshold > 0, use e_threshold, else, use |e_threshold|*T
91  // this should be put into xml later.
92  auto e_threshold = 2.0; // GeV
93 
94  for (auto &iparton : pOut) {
95  if (iparton.pstat() == miss_stat)
96  continue;
97 
98  // ignore photons
99  if (iparton.isPhoton(iparton.pid()))
100  continue;
101 
102  // ignore heavy quarks
103  if (std::abs(iparton.pid()) == 4 || std::abs(iparton.pid()) == 5)
104  continue;
105 
106  if (iparton.pstat() == -1) {
107  // remove negative particles from parton list
108  //iparton.set_stat(drop_stat);
109  iparton.set_stat(neg_stat);
110  continue;
111  }
112 
113  // for positive particles, including jet partons and recoil partons
114  auto tLoc = iparton.x_in().t();
115  auto xLoc = iparton.x_in().x();
116  auto yLoc = iparton.x_in().y();
117  auto zLoc = iparton.x_in().z();
118  std::unique_ptr<FluidCellInfo> check_fluid_info_ptr;
119  GetHydroCellSignal(tLoc, xLoc, yLoc, zLoc, check_fluid_info_ptr);
120  auto vxLoc = check_fluid_info_ptr->vx;
121  auto vyLoc = check_fluid_info_ptr->vy;
122  auto vzLoc = check_fluid_info_ptr->vz;
123  auto beta2 = vxLoc * vxLoc + vyLoc * vyLoc + vzLoc * vzLoc;
124  auto gamma = 1.0 / sqrt(1.0 - beta2);
125  auto E_boosted = gamma * (iparton.e() - iparton.p(1) * vxLoc -
126  iparton.p(2) * vyLoc - iparton.p(3) * vzLoc);
127  if (e_threshold > 0.) {
128  // drop partons with energy smaller than e_threshold
129  // (in the local rest frame) from parton list
130  if (E_boosted < e_threshold) {
131  iparton.set_stat(drop_stat);
132  continue;
133  }
134  } else {
135  // drop partons with energy smaller than |e_threshold|*T
136  // (in the local rest frame) from parton list
137  auto tempLoc = check_fluid_info_ptr->temperature;
138  if (E_boosted < std::abs(e_threshold) * tempLoc) {
139  iparton.set_stat(drop_stat);
140  continue;
141  }
142  }
143  }
144 }
145 
146 void LiquefierBase::add_hydro_sources(std::vector<Parton> &pIn,
147  std::vector<Parton> &pOut) {
148  if (pOut.size() == 0) {
149  // the process is freestreaming, ignore
150  filter_partons(pIn);
151  return;
152  }
154  filter_partons(pOut);
155 
156  FourVector p_final;
157  FourVector p_init;
158  FourVector x_final;
159  FourVector x_init;
160  //cout << "debug, mid ......." << pOut.size() << endl;
161  // use energy conservation to deterime the source term
162  const auto weight_init = 1.0;
163  for (const auto &iparton : pIn) {
164  auto temp = iparton.p_in();
165  p_init += temp;
166  x_init = iparton.x_in();
167  }
168 
169  auto weight_final = 0.0;
170  for (const auto &iparton : pOut) {
171  if (iparton.pstat() == drop_stat)
172  continue;
173  if (iparton.pstat() == miss_stat)
174  continue;
175  if (iparton.pstat() == neg_stat)
176  continue;
177  auto temp = iparton.p_in();
178  p_final += temp;
179  x_final = iparton.x_in();
180  weight_final = 1.0;
181  }
182 
183  if (std::abs(p_init.t() - p_final.t()) / p_init.t() > hydro_source_abs_err ||
184  std::abs(p_init.x() - p_final.x()) / p_init.t() > hydro_source_abs_err ||
185  std::abs(p_init.y() - p_final.y()) / p_init.t() > hydro_source_abs_err ||
186  std::abs(p_init.z() - p_final.z()) / p_init.t() > hydro_source_abs_err) {
187  auto droplet_t = ((x_final.t() * weight_final + x_init.t() * weight_init) /
188  (weight_final + weight_init));
189  auto droplet_x = ((x_final.x() * weight_final + x_init.x() * weight_init) /
190  (weight_final + weight_init));
191  auto droplet_y = ((x_final.y() * weight_final + x_init.y() * weight_init) /
192  (weight_final + weight_init));
193  auto droplet_z = ((x_final.z() * weight_final + x_init.z() * weight_init) /
194  (weight_final + weight_init));
195 
196  auto droplet_tau = sqrt(droplet_t * droplet_t - droplet_z * droplet_z);
197  auto droplet_eta =
198  (0.5 * log((droplet_t + droplet_z) / (droplet_t - droplet_z)));
199  auto droplet_E = p_init.t() - p_final.t();
200  auto droplet_px = p_init.x() - p_final.x();
201  auto droplet_py = p_init.y() - p_final.y();
202  auto droplet_pz = p_init.z() - p_final.z();
203 
204  std::array<Jetscape::real, 4> droplet_xmu = {
205  static_cast<Jetscape::real>(droplet_tau),
206  static_cast<Jetscape::real>(droplet_x),
207  static_cast<Jetscape::real>(droplet_y),
208  static_cast<Jetscape::real>(droplet_eta)};
209  std::array<Jetscape::real, 4> droplet_pmu = {
210  static_cast<Jetscape::real>(droplet_E),
211  static_cast<Jetscape::real>(droplet_px),
212  static_cast<Jetscape::real>(droplet_py),
213  static_cast<Jetscape::real>(droplet_pz)};
214  Droplet drop_i(droplet_xmu, droplet_pmu);
215  add_a_droplet(drop_i);
216  }
217 }
218 
220 
222  Jetscape::real total_E = 0.0;
223  for (const auto &drop_i : dropletlist) {
224  total_E += drop_i.get_pmu()[0];
225  }
226  return (total_E);
227 }
228 
229 }; // namespace Jetscape