Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JetScapeSignalManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JetScapeSignalManager.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 "JetScapeSignalManager.h"
17 #include "JetScapeLogger.h"
18 #include <stdlib.h>
19 
20 using namespace std;
21 
22 namespace Jetscape {
23 
24 JetScapeSignalManager *JetScapeSignalManager::m_pInstance = NULL;
25 
26 JetScapeSignalManager *JetScapeSignalManager::Instance() {
27  if (!m_pInstance) {
28  JSINFO << "Created JetScapeSignalManager Instance";
29  m_pInstance = new JetScapeSignalManager();
30  }
31 
32  return m_pInstance;
33 }
34 
35 void JetScapeSignalManager::ConnectGetHardPartonListSignal(
36  shared_ptr<JetEnergyLossManager> jm) {
37  if (!jm->GetGetHardPartonListConnected()) {
38  auto hpp = GetHardProcessPointer().lock();
39  if (hpp) {
40  jm->GetHardPartonList.connect(hpp.get(), &HardProcess::GetHardPartonList);
41  jm->SetGetHardPartonListConnected(true);
42  }
43  }
44 }
45 
46 void JetScapeSignalManager::ConnectGetFinalPartonListSignal(
47  shared_ptr<HadronizationManager> hm) {
48  if (!hm->GetGetFinalPartonListConnected()) {
49 
50  auto elp = GetEnergyLossPointer().lock();
51  if (elp) {
52  hm->GetFinalPartonList.connect(elp.get(),
53  &JetEnergyLoss::SendFinalStatePartons);
54  hm->SetGetFinalPartonListConnected(true);
55  }
56  }
57 
58  if (!hm->GetGetHadronListConnected()) {
59  auto hpp = GetHardProcessPointer().lock();
60  if (hpp) {
61  hm->GetHadronList.connect(hpp.get(), &HardProcess::GetHadronList);
62  hm->SetGetHadronListConnected(true);
63  }
64  }
65 }
66 
67 void JetScapeSignalManager::ConnectJetSignal(shared_ptr<JetEnergyLoss> j) {
68  if (!j->GetJetSignalConnected()) {
69  auto hp = GetHydroPointer().lock();
70  if (hp) {
71  j->jetSignal.connect(hp.get(), &FluidDynamics::UpdateEnergyDeposit);
72  j->SetJetSignalConnected(true);
73  jet_signal_map.emplace(num_jet_signals, (weak_ptr<JetEnergyLoss>)j);
74  num_jet_signals++;
75  }
76  }
77 }
78 
79 void JetScapeSignalManager::ConnectEdensitySignal(shared_ptr<JetEnergyLoss> j) {
80  if (!j->GetEdensitySignalConnected()) {
81  auto hp = GetHydroPointer().lock();
82  if (hp) {
83  j->edensitySignal.connect(hp.get(), &FluidDynamics::GetEnergyDensity);
84  j->SetEdensitySignalConnected(true);
85  edensity_signal_map.emplace(num_edensity_signals,
86  (weak_ptr<JetEnergyLoss>)j);
87  num_edensity_signals++;
88  }
89  }
90 }
91 
92 void JetScapeSignalManager::ConnectGetHydroTau0Signal(
93  shared_ptr<JetEnergyLoss> j) {
94  if (!j->GetGetHydroTau0SignalConnected()) {
95  auto hp = GetHydroPointer().lock();
96  if (hp) {
97  j->GetHydroTau0Signal.connect(hp.get(), &FluidDynamics::GetHydroStartTime);
98  j->SetGetHydroTau0SignalConnected(true);
99  }
100  }
101 }
102 
103 void JetScapeSignalManager::ConnectGetHydroCellSignal(
104  shared_ptr<JetEnergyLoss> j) {
105  if (!j->GetGetHydroCellSignalConnected()) {
106  auto hp = GetHydroPointer().lock();
107  if (hp) {
108  j->GetHydroCellSignal.connect(hp.get(), &FluidDynamics::GetHydroCell);
109  j->SetGetHydroCellSignalConnected(true);
110  GetHydroCellSignal_map.emplace(num_GetHydroCellSignals,
111  (weak_ptr<JetEnergyLoss>)j);
112  num_GetHydroCellSignals++;
113  }
114  }
115 }
116 
117 void JetScapeSignalManager::ConnectGetHydroCellSignal(
118  shared_ptr<LiquefierBase> l) {
119  if (!l->get_GetHydroCellSignalConnected()) {
120  auto hp = GetHydroPointer().lock();
121  if (hp) {
122  l->GetHydroCellSignal.connect(hp.get(), &FluidDynamics::GetHydroCell);
123  l->set_GetHydroCellSignalConnected(true);
124  }
125  }
126 }
127 
128 void JetScapeSignalManager::ConnectGetHydroCellSignal(
129  shared_ptr<Hadronization> h) {
130  if (!h->GetGetHydroCellSignalConnected()) {
131  auto hp = GetHydroPointer().lock();
132  if (hp) {
133  h->GetHydroCellSignal.connect(hp.get(), &FluidDynamics::GetHydroCell);
134  h->SetGetHydroCellSignalConnected(true);
135  }
136  }
137 }
138 
139 void JetScapeSignalManager::ConnectSentInPartonsSignal(
140  shared_ptr<JetEnergyLoss> j, shared_ptr<JetEnergyLoss> j2) {
141  if (!j2->GetSentInPartonsConnected()) {
142  j->SentInPartons.connect(j2.get(), &JetEnergyLoss::DoEnergyLoss);
143  j2->SetSentInPartonsConnected(true);
144  SentInPartons_map.emplace(num_SentInPartons, (weak_ptr<JetEnergyLoss>)j2);
145 
146  num_SentInPartons++;
147  }
148 }
149 
150 void JetScapeSignalManager::ConnectTransformPartonsSignal(
151  shared_ptr<Hadronization> h, shared_ptr<Hadronization> h2) {
152  if (!h2->GetTransformPartonsConnected()) {
153  h->TransformPartons.connect(h2.get(), &Hadronization::DoHadronization);
154  h2->SetTransformPartonsConnected(true);
155  TransformPartons_map.emplace(num_TransformPartons,
156  (weak_ptr<Hadronization>)h2);
157 
158  num_TransformPartons++;
159  }
160 }
161 
162 
163 void JetScapeSignalManager::ConnectGetFinalHadronListSignal(
164  shared_ptr<HadronPrinter> h){
165  auto hadroMgrShared = GetHadronizationManagerPointer().lock();
166  //hadronPrinter->GetFinalHadronList.connect(hadro.get(), &Hadronization::GetHadrons);
167  h->GetFinalHadronList.connect(hadroMgrShared.get(),
168  &HadronizationManager::GetHadrons);
169 }
170 
171 
172 void JetScapeSignalManager::ConnectGetHydroHyperSurfaceSignal(
173  shared_ptr<Hadronization> h) {
174  if (!h->GetGetHydroHyperSurfaceConnected()) {
175  auto hp = GetHydroPointer().lock();
176  if (hp) {
177  h->GetHydroHyperSurface.connect(
178  hp.get(), &FluidDynamics::FindAConstantTemperatureSurface);
179  h->SetGetHydroHyperSurfaceConnected(true);
180  }
181  }
182 }
183 
185  VERBOSE(8);
186 
187  // hmmm wrong caintainer .. should have used vectore with struct instead of map!!!!
188 
189  auto loss = jloss.lock();
190  if (loss) {
191  int nEnd = SentInPartons_map.size();
192  int nStart = loss->GetTaskAt(0)->GetNumberOfTasks();
193 
194  for (int i = nStart; i < nEnd; i++) {
195  jet_signal_map.erase(i);
196  num_jet_signals--;
197 
198  edensity_signal_map.erase(i);
199  num_edensity_signals--;
200 
201  GetHydroCellSignal_map.erase(i);
202  num_GetHydroCellSignals--;
203 
204  SentInPartons_map.erase(i);
205  num_SentInPartons--;
206 
207  TransformPartons_map.erase(i);
208  num_TransformPartons--;
209  }
210  } else {
211  jet_signal_map.clear();
212  edensity_signal_map.clear();
213  GetHydroCellSignal_map.clear(), SentInPartons_map.clear();
214  TransformPartons_map.clear();
215  // think better here how to handle the clean of when the instance goes out of scope ...!???
216  }
217 
218  PrintGetHydroCellSignalMap();
219  PrintSentInPartonsSignalMap();
220  PrintTransformPartonsSignalMap();
221 
222  VERBOSE(8) << "Done ...";
223 }
224 
225 void JetScapeSignalManager::PrintJetSignalMap() {
226  for (auto &x : jet_signal_map) {
227  auto xs = x.second.lock();
228  if (xs) {
229  VERBOSE(8) << "[" << x.first << ':' << xs.get() << ']' << " "
230  << xs->GetId();
231  }
232  }
233 }
234 
235 void JetScapeSignalManager::PrintEdensitySignalMap() {
236  for (auto &x : edensity_signal_map) {
237  auto xs = x.second.lock();
238  if (xs) {
239  VERBOSE(8) << "[" << x.first << ':' << xs.get() << ']' << " "
240  << xs->GetId();
241  }
242  }
243 }
244 
245 void JetScapeSignalManager::PrintGetHydroCellSignalMap() {
246  for (auto &x : GetHydroCellSignal_map) {
247  auto xs = x.second.lock();
248  if (xs) {
249  VERBOSE(8) << "[" << x.first << ':' << xs.get() << ']' << " "
250  << xs->GetId();
251  }
252  }
253 }
254 
255 void JetScapeSignalManager::PrintSentInPartonsSignalMap() {
256  for (auto &x : SentInPartons_map) {
257  auto xs = x.second.lock();
258  if (xs) {
259  VERBOSE(8) << "[" << x.first << ':' << xs.get() << ']' << " "
260  << xs->GetId();
261  }
262  }
263 }
264 
265 void JetScapeSignalManager::PrintTransformPartonsSignalMap() {
266  for (auto &x : TransformPartons_map) {
267  auto xs = x.second.lock();
268  if (xs) {
269  VERBOSE(8) << "[" << x.first << ':' << xs.get() << ']' << " "
270  << xs->GetId();
271  }
272  }
273 }
274 
275 /*
276 void JetScapeSignalManager::Clear()
277 {
278  // if use of shared pointers ...
279  //hydro=nullptr;
280  //jloss=nullptr;
281  // ...
282 }
283 */
284 
285 } // end namespace Jetscape