Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:25

0001 /*******************************************************************************
0002  * Copyright (c) The JETSCAPE Collaboration, 2018
0003  *
0004  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
0005  * 
0006  * For the list of contributors see AUTHORS.
0007  *
0008  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
0009  *
0010  * or via email to bugs.jetscape@gmail.com
0011  *
0012  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
0013  * See COPYING for details.
0014  ******************************************************************************/
0015 
0016 #include <string>
0017 #include <fstream>
0018 #include "IPGlasmaWrapper.h"
0019 
0020 // Register the module with the base class
0021 RegisterJetScapeModule<IPGlasmaWrapper> IPGlasmaWrapper::reg("IPGlasma");
0022 
0023 
0024 IPGlasmaWrapper::IPGlasmaWrapper() {
0025     SetId("IPGlasma");
0026     event_id_ = 0;
0027 }
0028 
0029 
0030 IPGlasmaWrapper::~IPGlasmaWrapper() {}
0031 
0032 
0033 void IPGlasmaWrapper::InitTask() {
0034     IPGlasma_ptr_ = std::unique_ptr<IPGlasma>(
0035                                 new IPGlasma(0, 1, 1, "ipglasma.input"));
0036     int grid_nx = IPGlasma_ptr_->getGridSizeX();
0037     double grid_spacing_x = IPGlasma_ptr_->getGridSpacingX();
0038     double grid_size_x = grid_nx*grid_spacing_x/2.;
0039     SetRanges(grid_size_x, grid_size_x, 0.);
0040     SetSteps(grid_spacing_x, grid_spacing_x, 0.);
0041 }
0042 
0043 
0044 void IPGlasmaWrapper::Exec() {
0045     Clear();
0046     Jetscape::JSINFO << "Run IPGlasma ...";
0047     try {
0048         IPGlasma_ptr_->generateAnEvent(event_id_);
0049         event_id_++;
0050     } catch (std::exception &err) {
0051         Jetscape::JSWARN << err.what();
0052         std::exit(-1);
0053     }
0054     ReadNbcList("NcollList0.dat");
0055 }
0056 
0057 
0058 void IPGlasmaWrapper::Clear() {
0059     Jetscape::JSINFO << "clear initial condition vectors";
0060 }
0061 
0062 
0063 void IPGlasmaWrapper::ReadNbcList(std::string filename) {
0064     Jetscape::JSINFO << "Read in binary collision list from "
0065                      << filename << "...";
0066     std::ifstream infile(filename.c_str());
0067     if (!infile.good()) {
0068         Jetscape::JSWARN << "Can not open " << filename;
0069         exit(1);
0070     }
0071 
0072     double x, y;
0073     infile >> x >> y;
0074     while (!infile.eof()) {
0075         binary_collision_x_.push_back(x);
0076         binary_collision_y_.push_back(y);
0077         infile >> x >> y;
0078     }
0079     infile.close();
0080     ncoll_ = binary_collision_x_.size();
0081     rand_int_ptr_ = (
0082         std::make_shared<std::uniform_int_distribution<int>>(0, ncoll_-1));
0083     Jetscape::JSINFO << "Ncoll = " << ncoll_;
0084 }
0085 
0086 
0087 void IPGlasmaWrapper::SampleABinaryCollisionPoint(double &x, double &y) {
0088     int rand_idx = (*rand_int_ptr_)(*GetMt19937Generator());
0089     x = binary_collision_x_[rand_idx];
0090     y = binary_collision_y_[rand_idx];
0091 }
0092 
0093 
0094 void IPGlasmaWrapper::Write(weak_ptr<JetScapeWriter> w) {}