Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InitialState.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file InitialState.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 "InitialState.h"
17 #include "JetScapeWriter.h"
18 #include <iostream>
19 
20 namespace Jetscape {
21 
23 
26 
27  JSINFO << "Initialize InitialState ... " << GetId() << " ...";
28 
29  grid_max_x_ = GetXMLElementDouble({"IS", "grid_max_x"});
30  grid_max_y_ = GetXMLElementDouble({"IS", "grid_max_y"});
31  grid_max_z_ = GetXMLElementDouble({"IS", "grid_max_z"});
32  grid_step_x_ = GetXMLElementDouble({"IS", "grid_step_x"});
33  grid_step_y_ = GetXMLElementDouble({"IS", "grid_step_y"});
34  grid_step_z_ = GetXMLElementDouble({"IS", "grid_step_z"});
35  JSINFO << "x range for bulk evolution = [" << -grid_max_x_ << ", "
36  << grid_max_x_ << "]";
37 
38  InitTask();
39 
41 }
42 
44  // Do whatever is needed to figure out the internal temp...
45 }
46 
48 
49 void InitialState::Write(weak_ptr<JetScapeWriter> w) {
50  //Write out the original vertex so the writer can keep track of it...
51  // auto f = w.lock();
52  // if ( f ) f->Write(make_shared<Vertex>(initialVtx));
53 }
54 
55 void InitialState::CollectHeader(weak_ptr<JetScapeWriter> w) {
56  auto f = w.lock();
57  if (f) {
58  auto &header = f->GetHeader();
59  header.SetNpart(GetNpart());
60  header.SetNcoll(GetNcoll());
61  header.SetTotalEntropy(GetTotalEntropy());
62  }
63 }
64 
65 std::tuple<double, double, double> InitialState::CoordFromIdx(int idx) {
66  int nx = GetXSize();
67  int ny = GetYSize();
68  int nz = GetZSize();
69 
70  int page = idx / (nx * ny);
71  int row = (idx - page * nx * ny) / nx;
72  int col = idx - page * nx * ny - row * nx;
73 
75  -grid_max_y_ + row * grid_step_y_,
76  -grid_max_z_ + page * grid_step_z_);
77 }
78 
79 
81  if (num_of_binary_collisions_.size() == 0) {
82  JSWARN << "num_of_binary_collisions is empty, setting the starting "
83  "location to 0. Make sure to add e.g. trento before PythiaGun.";
84  } else {
85  std::discrete_distribution<> dist(
87  end(num_of_binary_collisions_)); // Create the distribution
88  // Now generate values
89  auto idx = dist(*GetMt19937Generator());
90  auto coord = CoordFromIdx(idx);
91  x = std::get<0>(coord);
92  y = std::get<1>(coord);
93  }
94 }
95 
96 } // end namespace Jetscape