Back to home page

sPhenix code displayed by LXR

 
 

    


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

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 "Hadronization.h"
0017 #include "JetScapeLogger.h"
0018 #include <string>
0019 #include <vector>
0020 #include <iostream>
0021 #include "JetScapeSignalManager.h"
0022 #include "JetScapeWriterStream.h"
0023 
0024 using namespace std;
0025 
0026 namespace Jetscape {
0027 
0028 Hadronization::Hadronization() {
0029     SetId("Hadronization");
0030     TransformPartonsConnected = false;
0031     HydroHyperSurfaceConnected_ = false;
0032     GetHydroCellSignalConnected_ = false;
0033 }
0034 
0035 Hadronization::~Hadronization() {}
0036 
0037 void Hadronization::Clear() {
0038   VERBOSESHOWER(8);
0039   outHadrons.clear();
0040 }
0041 
0042 void Hadronization::Init() {
0043   JetScapeModuleBase::Init();
0044 
0045   // May need to read some configuration info from XML file here
0046 
0047   if (GetNumberOfTasks() < 1) {
0048     JSWARN << " : No valid Hadronization modules found ...";
0049     exit(-1);
0050   }
0051 
0052   JSINFO << "Found " << GetNumberOfTasks()
0053          << " Hadronization Tasks/Modules Initialize them ... ";
0054   JetScapeTask::InitTasks();
0055 }
0056 
0057 void Hadronization::DoHadronize() {
0058   VERBOSE(2) << "Get Recombination Partons...";
0059 
0060   if (inPartons.size() > 0) {
0061     VERBOSE(2) << "There are Partons ready for Recombination...";
0062     TransformPartons(inPartons, outHadrons, outPartons);
0063   } else {
0064     VERBOSE(2) << "There is no Parton ready for Recombination...";
0065   }
0066 }
0067 
0068 void Hadronization::Exec() {
0069   VERBOSE(2) << "Run Hadronization Exec...";
0070   VERBOSE(2) << "Found " << GetNumberOfTasks()
0071              << " Hadronization Tasks/Modules Execute them ... ";
0072 
0073   //this->outHadrons = make_shared<vector<shared_ptr<Hadron>>>();
0074   //this->outPartons = make_shared<vector<shared_ptr<Parton>>>();
0075 
0076   DoHadronize();
0077 }
0078 
0079 void Hadronization::WriteTask(weak_ptr<JetScapeWriter> w) {
0080   VERBOSE(4) << "In Hadronization::WriteTask";
0081   auto f = w.lock();
0082   if (!f)
0083     return;
0084 
0085   f->WriteComment("Hadronization module: " + GetId());
0086 
0087   if (GetHadrons().size() > 0) {
0088     f->WriteComment("Final State Hadrons");
0089     int i = 0;
0090     for (auto &h : GetHadrons()) {
0091       f->WriteWhiteSpace("[" + to_string(i) + "] H");
0092       f->Write(h);
0093       ++i;
0094     }
0095   } else {
0096     f->WriteComment("There are no Hadrons");
0097   }
0098 }
0099 
0100 void Hadronization::DeleteHadrons() {
0101   outHadrons.clear();
0102 }
0103 
0104 void Hadronization::DeleteRealHadrons() {
0105   outHadrons.erase(
0106     std::remove_if(
0107       outHadrons.begin(),
0108       outHadrons.end(),
0109       [](const std::shared_ptr<Hadron>& hadron) {
0110           return hadron->pstat() > 0;
0111       }
0112     ),
0113     outHadrons.end()
0114   );
0115 }
0116 
0117 } // namespace Jetscape