Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Hadronization.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Hadronization.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 "Hadronization.h"
17 #include "JetScapeLogger.h"
18 #include <string>
19 #include <vector>
20 #include <iostream>
21 #include "JetScapeSignalManager.h"
22 #include "JetScapeWriterStream.h"
23 
24 using namespace std;
25 
26 namespace Jetscape {
27 
28 Hadronization::Hadronization() {
29  SetId("Hadronization");
30  TransformPartonsConnected = false;
31  HydroHyperSurfaceConnected_ = false;
32  GetHydroCellSignalConnected_ = false;
33 }
34 
35 Hadronization::~Hadronization() {}
36 
38  VERBOSESHOWER(8);
39  outHadrons.clear();
40 }
41 
44 
45  // May need to read some configuration info from XML file here
46 
47  if (GetNumberOfTasks() < 1) {
48  JSWARN << " : No valid Hadronization modules found ...";
49  exit(-1);
50  }
51 
52  JSINFO << "Found " << GetNumberOfTasks()
53  << " Hadronization Tasks/Modules Initialize them ... ";
54  JetScapeTask::InitTasks();
55 }
56 
57 void Hadronization::DoHadronize() {
58  VERBOSE(2) << "Get Recombination Partons...";
59 
60  if (inPartons.size() > 0) {
61  VERBOSE(2) << "There are Partons ready for Recombination...";
62  TransformPartons(inPartons, outHadrons, outPartons);
63  } else {
64  VERBOSE(2) << "There is no Parton ready for Recombination...";
65  }
66 }
67 
68 void Hadronization::Exec() {
69  VERBOSE(2) << "Run Hadronization Exec...";
70  VERBOSE(2) << "Found " << GetNumberOfTasks()
71  << " Hadronization Tasks/Modules Execute them ... ";
72 
73  //this->outHadrons = make_shared<vector<shared_ptr<Hadron>>>();
74  //this->outPartons = make_shared<vector<shared_ptr<Parton>>>();
75 
76  DoHadronize();
77 }
78 
79 void Hadronization::WriteTask(weak_ptr<JetScapeWriter> w) {
80  VERBOSE(4) << "In Hadronization::WriteTask";
81  auto f = w.lock();
82  if (!f)
83  return;
84 
85  f->WriteComment("Hadronization module: " + GetId());
86 
87  if (GetHadrons().size() > 0) {
88  f->WriteComment("Final State Hadrons");
89  int i = 0;
90  for (auto &h : GetHadrons()) {
91  f->WriteWhiteSpace("[" + to_string(i) + "] H");
92  f->Write(h);
93  ++i;
94  }
95  } else {
96  f->WriteComment("There are no Hadrons");
97  }
98 }
99 
100 void Hadronization::DeleteHadrons() {
101  outHadrons.clear();
102 }
103 
104 void Hadronization::DeleteRealHadrons() {
105  outHadrons.erase(
106  std::remove_if(
107  outHadrons.begin(),
108  outHadrons.end(),
109  [](const std::shared_ptr<Hadron>& hadron) {
110  return hadron->pstat() > 0;
111  }
112  ),
113  outHadrons.end()
114  );
115 }
116 
117 } // namespace Jetscape