Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LiquifierBase.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LiquifierBase.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 
16 #include "LiquefierBase.h"
17 #include "gtest/gtest.h"
18 
19 #include<vector>
20 
21 using namespace Jetscape;
22 
23 // check function to add a droplet and Clear
24 TEST(LiquefierBaseTest, TEST_add_a_droplet_and_Clear) {
25  LiquefierBase lqf;
27 
28  Droplet a_drop;
29  lqf.add_a_droplet(a_drop);
31 
32  lqf.Clear();
34 }
35 
36 
37 TEST(LiquefierBaseTest, TEST_filter_partons) {
38  LiquefierBase lqf;
39  FourVector p_test1(1.0, 0.0, 0.0, 1.0); // px, py, pz, E
40  FourVector x_test1(0.0, 0.0, 0.0, 1.0); // x, y, z, t
41  Parton test1(0, 21, 0, p_test1, x_test1); // 21 = gluon
42 
43  FourVector p_test2(3.0, 0.0, 0.0, 3.0);
44  FourVector x_test2(0.0, 0.0, 0.0, 1.0);
45  Parton test2(0, 21, 0, p_test2, x_test2);
46 
47  std::vector<Parton> pOut;
48 
49  pOut.push_back(test1);
50  pOut.push_back(test2);
51  lqf.filter_partons(pOut);
52  EXPECT_EQ(2, pOut.size());
53  EXPECT_EQ(lqf.get_drop_stat(), pOut[0].pstat());
54  EXPECT_EQ(0, pOut[1].pstat());
55  pOut.clear();
56 
57  // test a negative particle
58  FourVector p_test3(3.0, 0.0, 0.0, 3.0);
59  FourVector x_test3(0.0, 0.0, 0.0, 1.0);
60  Parton test3(0, 21, -1, p_test3, x_test3);
61  pOut.push_back(test3);
62  lqf.filter_partons(pOut);
63  EXPECT_EQ(1, pOut.size());
64  for(const auto &iparton : pOut)
65  EXPECT_EQ(lqf.get_drop_stat(), iparton.pstat());
66  pOut.clear();
67 
68  // test a negative particle and a soft particle
69  pOut.push_back(test1);
70  pOut.push_back(test3);
71  lqf.filter_partons(pOut);
72  EXPECT_EQ(2, pOut.size());
73  for(const auto &iparton : pOut)
74  EXPECT_EQ(lqf.get_drop_stat(), iparton.pstat());
75  pOut.clear();
76 
77  // test a negative particle and a hard particle
78  pOut.push_back(test2);
79  pOut.push_back(test3);
80  lqf.filter_partons(pOut);
81  EXPECT_EQ(2, pOut.size());
82  EXPECT_EQ(0, pOut[0].pstat());
83  EXPECT_EQ(lqf.get_drop_stat(), pOut[1].pstat());
84  pOut.clear();
85 }
86 
87 
88 TEST(LiquefierBaseTest, TEST_check_energy_momentum_conservation) {
89  LiquefierBase lqf;
90  FourVector p_test1(1.0, 0.0, 0.0, 1.0); // px, py, pz, E
91  FourVector x_test1(0.0, 0.0, 0.0, 1.0); // x, y, z, t
92  Parton test1(0, 21, 0, p_test1, x_test1); // 21 = gluon
93 
94  FourVector p_test2(3.0, 0.0, 0.0, 3.0);
95  FourVector x_test2(0.0, 0.0, 0.0, 1.0);
96  Parton test2(0, 21, 0, p_test2, x_test2);
97 
98  std::vector<Parton> pIn;
99  std::vector<Parton> pOut;
100 
101  pIn.push_back(test1);
102  pOut.push_back(test2);
103  lqf.check_energy_momentum_conservation(pIn, pOut);
104  EXPECT_EQ(1, pIn.size());
105  EXPECT_EQ(2, pOut.size());
106  EXPECT_DOUBLE_EQ(pIn[0].p(0), pOut[0].p(0) + pOut[1].p(0));
107  EXPECT_DOUBLE_EQ(pIn[0].p(1), pOut[0].p(1) + pOut[1].p(1));
108  EXPECT_DOUBLE_EQ(pIn[0].p(2), pOut[0].p(2) + pOut[1].p(2));
109  EXPECT_DOUBLE_EQ(pIn[0].p(3), pOut[0].p(3) + pOut[1].p(3));
110  pIn.clear();
111  pOut.clear();
112 }
113 
114 
115 // check function to add a hydro source term
116 TEST(LiquefierBaseTest, TEST_add_hydro_source) {
117  LiquefierBase lqf;
118 
119  FourVector p_test1(1.0, 0.0, 0.0, 1.0); // px, py, pz, E
120  FourVector x_test1(0.0, 0.0, 0.0, 1.0); // x, y, z, t
121  Parton test1(0, 21, 0, p_test1, x_test1); // 21 = gluon
122 
123  FourVector p_test2(3.0, 0.0, 0.0, 3.0);
124  FourVector x_test2(0.0, 0.0, 0.0, 1.0);
125  Parton test2(0, 21, 0, p_test2, x_test2);
126 
127  std::vector<Parton> pIn;
128  std::vector<Parton> pOut;
129  pIn.push_back(test1);
130  pIn.push_back(test2);
131 
132  // test when pOut.size() == 0
133  lqf.add_hydro_sources(pIn, pOut);
135  pIn.clear();
136  pOut.clear();
137  lqf.Clear();
138 
139  // test when pOut == pIn (hard parton)
140  pIn.push_back(test2);
141  pOut.push_back(test2);
142  lqf.add_hydro_sources(pIn, pOut);
144  EXPECT_EQ(1, pIn.size());
145  EXPECT_EQ(1, pOut.size());
146  pIn.clear();
147  pOut.clear();
148  lqf.Clear();
149 
150  // test when pOut == pIn (soft parton)
151  pIn.push_back(test1);
152  pOut.push_back(test1);
153  lqf.add_hydro_sources(pIn, pOut);
155  EXPECT_EQ(1, pIn.size());
156  EXPECT_EQ(1, pOut.size());
157  EXPECT_DOUBLE_EQ(p_test1.t(), (lqf.get_a_droplet(0).get_pmu())[0]);
158  EXPECT_DOUBLE_EQ(p_test1.x(), (lqf.get_a_droplet(0).get_pmu())[1]);
159  EXPECT_DOUBLE_EQ(x_test1.t(), (lqf.get_a_droplet(0).get_xmu())[0]);
160  pIn.clear();
161  pOut.clear();
162  lqf.Clear();
163 
164  // test a negative particle
165  FourVector p_test3(3.0, 0.0, 0.0, 3.0);
166  FourVector x_test3(0.0, 0.0, 0.0, 1.0);
167  Parton test3(0, 21, -1, p_test3, x_test3);
168  pIn.push_back(test2);
169  pOut.push_back(test3);
170  lqf.add_hydro_sources(pIn, pOut);
172  EXPECT_DOUBLE_EQ(p_test3.t(), (lqf.get_a_droplet(0).get_pmu())[0]);
173  EXPECT_DOUBLE_EQ(p_test3.x(), (lqf.get_a_droplet(0).get_pmu())[1]);
174  EXPECT_DOUBLE_EQ(x_test3.t(), (lqf.get_a_droplet(0).get_xmu())[0]);
175  EXPECT_EQ(1, pIn.size());
176  EXPECT_EQ(2, pOut.size());
177  pIn.clear();
178  pOut.clear();
179  lqf.Clear();
180 
181  // test a negative particle and a soft particle
182  pIn.push_back(test2);
183  pOut.push_back(test1);
184  pOut.push_back(test3);
185  lqf.add_hydro_sources(pIn, pOut);
187  EXPECT_DOUBLE_EQ(p_test2.t(), (lqf.get_a_droplet(0).get_pmu())[0]);
188  EXPECT_DOUBLE_EQ(p_test2.x(), (lqf.get_a_droplet(0).get_pmu())[1]);
189  EXPECT_DOUBLE_EQ(x_test2.t(), (lqf.get_a_droplet(0).get_xmu())[0]);
190  EXPECT_EQ(1, pIn.size());
191  EXPECT_EQ(3, pOut.size());
192  pIn.clear();
193  pOut.clear();
194  lqf.Clear();
195 
196  // test a negative particle and a hard particle
197  pIn.push_back(test1);
198  pOut.push_back(test2);
199  pOut.push_back(test3);
200  lqf.add_hydro_sources(pIn, pOut);
202  EXPECT_DOUBLE_EQ(p_test1.t() - p_test2.t(),
203  (lqf.get_a_droplet(0).get_pmu())[0]);
204  EXPECT_DOUBLE_EQ(p_test1.x() - p_test2.x(),
205  (lqf.get_a_droplet(0).get_pmu())[1]);
206  EXPECT_DOUBLE_EQ((x_test1.t() + x_test2.t())/2.,
207  (lqf.get_a_droplet(0).get_xmu())[0]);
208  EXPECT_EQ(1, pIn.size());
209  EXPECT_EQ(3, pOut.size());
210  pIn.clear();
211  pOut.clear();
212  lqf.Clear();
213 
214  // test a soft particle in pIn only
215  //pIn.push_back(test1);
216  //lqf.add_hydro_sources(pIn, pOut);
217  //EXPECT_EQ(1, lqf.get_dropletlist_size());
218  //EXPECT_DOUBLE_EQ(p_test1.t(), (lqf.get_a_droplet(0).get_pmu())[0]);
219  //EXPECT_DOUBLE_EQ(p_test1.x(), (lqf.get_a_droplet(0).get_pmu())[1]);
220  //EXPECT_DOUBLE_EQ(x_test1.t(), (lqf.get_a_droplet(0).get_xmu())[0]);
221  //EXPECT_EQ(0, pIn.size());
222  //EXPECT_EQ(0, pOut.size());
223  //pIn.clear();
224  //pOut.clear();
225  //lqf.Clear();
226 }