Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IPGlasmaWrapper.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file IPGlasmaWrapper.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 <string>
17 #include <fstream>
18 #include "IPGlasmaWrapper.h"
19 
20 // Register the module with the base class
22 
23 
25  SetId("IPGlasma");
26  event_id_ = 0;
27 }
28 
29 
31 
32 
34  IPGlasma_ptr_ = std::unique_ptr<IPGlasma>(
35  new IPGlasma(0, 1, 1, "ipglasma.input"));
36  int grid_nx = IPGlasma_ptr_->getGridSizeX();
37  double grid_spacing_x = IPGlasma_ptr_->getGridSpacingX();
38  double grid_size_x = grid_nx*grid_spacing_x/2.;
39  SetRanges(grid_size_x, grid_size_x, 0.);
40  SetSteps(grid_spacing_x, grid_spacing_x, 0.);
41 }
42 
43 
45  Clear();
46  Jetscape::JSINFO << "Run IPGlasma ...";
47  try {
48  IPGlasma_ptr_->generateAnEvent(event_id_);
49  event_id_++;
50  } catch (std::exception &err) {
51  Jetscape::JSWARN << err.what();
52  std::exit(-1);
53  }
54  ReadNbcList("NcollList0.dat");
55 }
56 
57 
59  Jetscape::JSINFO << "clear initial condition vectors";
60 }
61 
62 
64  Jetscape::JSINFO << "Read in binary collision list from "
65  << filename << "...";
66  std::ifstream infile(filename.c_str());
67  if (!infile.good()) {
68  Jetscape::JSWARN << "Can not open " << filename;
69  exit(1);
70  }
71 
72  double x, y;
73  infile >> x >> y;
74  while (!infile.eof()) {
75  binary_collision_x_.push_back(x);
76  binary_collision_y_.push_back(y);
77  infile >> x >> y;
78  }
79  infile.close();
80  ncoll_ = binary_collision_x_.size();
81  rand_int_ptr_ = (
82  std::make_shared<std::uniform_int_distribution<int>>(0, ncoll_-1));
83  Jetscape::JSINFO << "Ncoll = " << ncoll_;
84 }
85 
86 
88  int rand_idx = (*rand_int_ptr_)(*GetMt19937Generator());
89  x = binary_collision_x_[rand_idx];
90  y = binary_collision_y_[rand_idx];
91 }
92 
93 
94 void IPGlasmaWrapper::Write(weak_ptr<JetScapeWriter> w) {}