Skip to content

Commit

Permalink
Merge branch 'dev' into temp
Browse files Browse the repository at this point in the history
  • Loading branch information
chunshen1987 committed Apr 16, 2024
2 parents c9fc4f3 + 294a234 commit 3b1f8b7
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 87 deletions.
64 changes: 23 additions & 41 deletions src/FSSW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "Stopwatch.h"

using iSS_data::AMOUNT_OF_OUTPUT;
using iSS_data::Vec4;
using iSS_data::VecD4;
using std::cout;
using std::endl;
using std::string;
Expand Down Expand Up @@ -469,17 +469,17 @@ void FSSW::combine_samples_to_OSCAR() {
oscar << setw(10) << ipart + 1 << " "
<< setw(10) << (*(*Hadron_list)[iev])[ipart].pid
<< " ";
sprintf(line_buffer,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e",
(*(*Hadron_list)[iev])[ipart].px,
(*(*Hadron_list)[iev])[ipart].py,
(*(*Hadron_list)[iev])[ipart].pz,
(*(*Hadron_list)[iev])[ipart].E,
(*(*Hadron_list)[iev])[ipart].mass,
(*(*Hadron_list)[iev])[ipart].x,
(*(*Hadron_list)[iev])[ipart].y,
(*(*Hadron_list)[iev])[ipart].z,
(*(*Hadron_list)[iev])[ipart].t);
snprintf(line_buffer, 500,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e",
(*(*Hadron_list)[iev])[ipart].px,
(*(*Hadron_list)[iev])[ipart].py,
(*(*Hadron_list)[iev])[ipart].pz,
(*(*Hadron_list)[iev])[ipart].E,
(*(*Hadron_list)[iev])[ipart].mass,
(*(*Hadron_list)[iev])[ipart].x,
(*(*Hadron_list)[iev])[ipart].y,
(*(*Hadron_list)[iev])[ipart].z,
(*(*Hadron_list)[iev])[ipart].t);
oscar << line_buffer << endl;
}
}
Expand Down Expand Up @@ -1945,39 +1945,21 @@ int FSSW::sample_momemtum_from_a_fluid_cell(
if (ran_gen_ptr->rand_uniform() < accept_prob) {
// accept the sample
// now we need to boost the momentum to the lab frame
Vec4 pLRF = {static_cast<float>(p0), static_cast<float>(px),
static_cast<float>(py), static_cast<float>(pz)};
Vec4 umu = {surf->u_tz[0], surf->u_tz[1],
surf->u_tz[2], surf->u_tz[3]};
Vec4 pLab = {0., 0., 0., 0.};
VecD4 pLRF = {p0, px, py, pz};
VecD4 umu = {surf->u_tz[0], surf->u_tz[1],
surf->u_tz[2], surf->u_tz[3]};
VecD4 pLab = {0., 0., 0., 0.};
boost_vector_back_to_lab_frame(pLRF, pLab, umu);

// assigned to the return variables
pT = sqrt(pLab[1]*pLab[1] + pLab[2]*pLab[2]);
phi = atan2(pLab[2], pLab[1]);
// if E and p^z are too close, resample one
double y = 0.5*log((pLab[0] + pLab[3])/(pLab[0] - pLab[3]));
if (std::isnan(y) || std::isinf(y)) {
// pLab[0] and pLab[3] are too close
// recompute pLab[3] with E, pT, and mass
pLab[3] = sqrt(pLab[0]*pLab[0] - pT*pT - mass*mass);
y = 0.5*log((pLab[0] + pLab[3])/(pLab[0] - pLab[3]));
if (std::isnan(y) || std::isinf(y)) {
std::cout << "[Error]: sampled y is " << y << "!"
<< std::endl;
std::cout << "umu = "
<< umu[0] << ", " << umu[1] << ", " << umu[2]
<< ", " << umu[3] << std::endl;
std::cout << "pLRF = "
<< pLRF[0] << ", " << pLRF[1] << ", "
<< pLRF[2] << ", " << pLRF[3] << std::endl;
std::cout << "pLab = "
<< pLab[0] << ", " << pLab[1] << ", "
<< pLab[2] << ", " << pLab[3] << std::endl;
exit(1);
}
if (!std::isnan(y) && !std::isinf(y)) {
pT = sqrt(pLab[1]*pLab[1] + pLab[2]*pLab[2]);
phi = atan2(pLab[2], pLab[1]);
y_minus_eta_s = y - surf->eta;
return(1);
}
y_minus_eta_s = y - surf->eta;
return(1);
}
tries++;
}
Expand Down Expand Up @@ -2018,7 +2000,7 @@ void FSSW::add_one_sampled_particle(
// this function boost a 4-vector from the fluid local rest frame to
// the lab frame. The fluid velocity is u^\mu.
void FSSW::boost_vector_back_to_lab_frame(
Vec4 &p_LRF, Vec4 &p_lab, Vec4 &umu) const {
VecD4 &p_LRF, VecD4 &p_lab, VecD4 &umu) const {
double p_dot_u = 0.;
for (int i = 1; i < 4; i++)
p_dot_u += p_LRF[i]*umu[i];
Expand Down
6 changes: 3 additions & 3 deletions src/FSSW.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ class FSSW {
const int particle_monval, const double mass,
const double pT, const double phi,
const double y_minus_eta_s, const double eta_s);
void boost_vector_back_to_lab_frame(iSS_data::Vec4 &p_LRF,
iSS_data::Vec4 &p_lab,
iSS_data::Vec4 &umu) const;
void boost_vector_back_to_lab_frame(iSS_data::VecD4 &p_LRF,
iSS_data::VecD4 &p_lab,
iSS_data::VecD4 &umu) const;
double bilinearInterp(std::vector<std::vector<double>>&mat,
int idx_e1, int idx_e2, int idx_nB1, int idx_nB2,
double x_fraction, double y_fraction);
Expand Down
2 changes: 1 addition & 1 deletion src/MomentumSamplerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MomentumSamplerBase {
std::vector<double> CDF_2_;

MomentumSamplerBase();
~MomentumSamplerBase() {};
virtual ~MomentumSamplerBase() {};

virtual double CDF_0(const double Etilde) const {return(0.0*Etilde);}
virtual double CDF_1(const double Etilde) const {return(0.0*Etilde);}
Expand Down
1 change: 1 addition & 0 deletions src/data_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace iSS_data {
const double hbarC=0.197327053; //GeV*fm

typedef std::array<float, 4> Vec4;
typedef std::array<double, 4> VecD4;
typedef std::array<double, 10> ViscousVec;

const int NUMBER_OF_LINES_TO_WRITE = 100000;
Expand Down
84 changes: 42 additions & 42 deletions src/emissionfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ void EmissionFunctionArray::sample_using_dN_dxtdetady_smooth_pT_phi() {
long number_to_sample = determine_number_to_sample(
dN, sampling_model, sampling_para1);
// write to control file
sprintf(line_buffer, "%lu\n", number_to_sample);
snprintf(line_buffer, 500, "%lu\n", number_to_sample);
control_str_buffer << line_buffer;
control_writing_signal++;
if (control_writing_signal == iSS_data::NUMBER_OF_LINES_TO_WRITE) {
Expand Down Expand Up @@ -1539,18 +1539,18 @@ void EmissionFunctionArray::sample_using_dN_dxtdetady_smooth_pT_phi() {
// write to sample file
if (!USE_OSCAR_FORMAT)
{
sprintf(line_buffer,
"%lu %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
FO_idx, surf->tau, surf->xpt, surf->ypt, y_minus_eta_s,
pT, phi, surf->da0, surf->da1, surf->da2, vx, vy, y,
eta_s, E, p_z, t, z);
snprintf(line_buffer, 500,
"%lu %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
FO_idx, surf->tau, surf->xpt, surf->ypt, y_minus_eta_s,
pT, phi, surf->da0, surf->da1, surf->da2, vx, vy, y,
eta_s, E, p_z, t, z);
}
// To be combined to OSCAR
if (USE_OSCAR_FORMAT)
{
sprintf(line_buffer,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e\n",
px, py, p_z, E, mass, surf->xpt, surf->ypt, z, t);
snprintf(line_buffer, 500,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e\n",
px, py, p_z, E, mass, surf->xpt, surf->ypt, z, t);
}
sample_str_buffer << line_buffer;
sample_writing_signal++;
Expand Down Expand Up @@ -1787,7 +1787,7 @@ void EmissionFunctionArray::sample_using_dN_pTdpTdphidy() {
long number_to_sample = determine_number_to_sample(
dN, sampling_model, sampling_para1);
// write to control file
sprintf(line_buffer, "%lu\n", number_to_sample);
snprintf(line_buffer, 500, "%lu\n", number_to_sample);
control_str_buffer << line_buffer;
control_writing_signal++;
if (control_writing_signal == iSS_data::NUMBER_OF_LINES_TO_WRITE) {
Expand Down Expand Up @@ -2050,17 +2050,17 @@ void EmissionFunctionArray::sample_using_dN_pTdpTdphidy() {

// write to sample file
if (!USE_OSCAR_FORMAT) {
sprintf(line_buffer,
"%lu %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
FO_idx, surf->tau, surf->xpt, surf->ypt, y_minus_eta_s,
pT, phi, surf->da0, surf->da1, surf->da2,
surf->u1/surf->u0, surf->u2/surf->u0, y, eta_s, E,
p_z, t, z);
snprintf(line_buffer, 500,
"%lu %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
FO_idx, surf->tau, surf->xpt, surf->ypt, y_minus_eta_s,
pT, phi, surf->da0, surf->da1, surf->da2,
surf->u1/surf->u0, surf->u2/surf->u0, y, eta_s, E,
p_z, t, z);
} else {
// To be combined to OSCAR
sprintf(line_buffer,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e\n",
px, py, p_z, E, mass, surf->xpt, surf->ypt, z, t);
snprintf(line_buffer, 500,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e\n",
px, py, p_z, E, mass, surf->xpt, surf->ypt, z, t);
}
sample_str_buffer << line_buffer;
sample_writing_signal++;
Expand Down Expand Up @@ -2699,17 +2699,17 @@ void EmissionFunctionArray::combine_samples_to_OSCAR() {
oscar << setw(10) << ipart + 1 << " "
<< setw(10) << (*(*Hadron_list)[iev])[ipart].pid
<< " ";
sprintf(line_buffer,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e",
(*(*Hadron_list)[iev])[ipart].px,
(*(*Hadron_list)[iev])[ipart].py,
(*(*Hadron_list)[iev])[ipart].pz,
(*(*Hadron_list)[iev])[ipart].E,
(*(*Hadron_list)[iev])[ipart].mass,
(*(*Hadron_list)[iev])[ipart].x,
(*(*Hadron_list)[iev])[ipart].y,
(*(*Hadron_list)[iev])[ipart].z,
(*(*Hadron_list)[iev])[ipart].t);
snprintf(line_buffer, 500,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e",
(*(*Hadron_list)[iev])[ipart].px,
(*(*Hadron_list)[iev])[ipart].py,
(*(*Hadron_list)[iev])[ipart].pz,
(*(*Hadron_list)[iev])[ipart].E,
(*(*Hadron_list)[iev])[ipart].mass,
(*(*Hadron_list)[iev])[ipart].x,
(*(*Hadron_list)[iev])[ipart].y,
(*(*Hadron_list)[iev])[ipart].z,
(*(*Hadron_list)[iev])[ipart].t);
oscar << line_buffer << endl;
}
}
Expand Down Expand Up @@ -3442,7 +3442,7 @@ void EmissionFunctionArray::sample_using_dN_dxtdy_4all_particles_conventional()
control_writing_signal++;
if (flag_output_samples_into_files == 1) {
// write to control file
sprintf(line_buffer, "%lu\n", number_to_sample);
snprintf(line_buffer, 500, "%lu\n", number_to_sample);
control_str_buffer << line_buffer;
if (control_writing_signal
== iSS_data::NUMBER_OF_LINES_TO_WRITE) {
Expand Down Expand Up @@ -4440,19 +4440,19 @@ std::string EmissionFunctionArray::add_one_sampled_particle(

// write to sample file
if (!USE_OSCAR_FORMAT) {
sprintf(line_buffer,
"%lu %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
FO_idx, surf->tau, surf->xpt, surf->ypt,
y_minus_eta_s, pT, phi, surf->da0, surf->da1,
surf->da2, surf->u1/surf->u0,
surf->u2/surf->u0, rapidity_y, eta_s, E, p_z,
t, z);
snprintf(line_buffer, 500,
"%lu %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
FO_idx, surf->tau, surf->xpt, surf->ypt,
y_minus_eta_s, pT, phi, surf->da0, surf->da1,
surf->da2, surf->u1/surf->u0,
surf->u2/surf->u0, rapidity_y, eta_s, E, p_z,
t, z);
} else {
// To be combined to OSCAR
sprintf(line_buffer,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e\n",
px, py, p_z, E, mass, surf->xpt,
surf->ypt, z, t);
snprintf(line_buffer, 500,
"%24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e\n",
px, py, p_z, E, mass, surf->xpt,
surf->ypt, z, t);
}
text_string = line_buffer;

Expand Down

0 comments on commit 3b1f8b7

Please sign in to comment.