30 JetEnergyLossManager::JetEnergyLossManager() {
31 SetId(
"JLossManager");
32 GetHardPartonListConnected =
false;
36 JetEnergyLossManager::~JetEnergyLossManager() {
41 if (GetNumberOfTasks() > 0)
46 JSDEBUG <<
"Hard Parton List ...";
50 int n = GetNumberOfTasks();
51 for (
int i = 1;
i <
n;
i++)
55 JetScapeSignalManager::Instance()->CleanUp();
56 JetScapeTask::ClearTasks();
62 JSINFO <<
"Initialize JetEnergyLoss Manager ...";
64 if (GetNumberOfTasks() < 1) {
65 JSWARN <<
" : No valid Energy Loss Manager modules found ...";
69 JSINFO <<
"Found " << GetNumberOfTasks()
70 <<
" Eloss Manager Tasks/Modules Initialize them ... ";
71 JetScapeTask::InitTasks();
73 JSINFO <<
"Connect JetEnergyLossManager Signal to Hard Process ...";
74 JetScapeSignalManager::Instance()->ConnectGetHardPartonListSignal(
78 for (
auto it : GetTaskList()) {
79 if (dynamic_pointer_cast<JetEnergyLoss>(
it))
81 JetScapeSignalManager::Instance()->SetEnergyLossPointer(
82 dynamic_pointer_cast<JetEnergyLoss>(
it));
86 void JetEnergyLossManager::WriteTask(weak_ptr<JetScapeWriter> w) {
88 JetScapeTask::WriteTasks(w);
91 void JetEnergyLossManager::Exec() {
92 VERBOSE(1) <<
"Run JetEnergyLoss Manager ...";
93 JSDEBUG <<
"Task Id = " << this_thread::get_id();
95 if (GetNumberOfTasks() < 1) {
96 JSWARN <<
" : No valid Energy Loss Manager modules found ...";
103 if (GetGetHardPartonListConnected()) {
104 GetHardPartonList(hp);
105 VERBOSE(3) <<
" Number of Hard Partons = " << hp.size();
106 for (
int i = 1;
i < hp.size();
i++) {
108 <<
" th copy because number of intital hard partons = "
112 auto jloss_copy = make_shared<JetEnergyLoss>(*jloss_org);
124 VERBOSE(3) <<
" Found " << GetNumberOfTasks()
125 <<
" Eloss Manager Tasks/Modules Execute them ... ";
126 JSDEBUG <<
"Check and Create Signal/Slots via JetScapeSignalManager instance "
134 if (GetGetHardPartonListConnected() && hp.size() > 0) {
136 for (
auto it : GetTaskList()) {
145 bool multiTask =
false;
158 int nTasks = GetNumberOfTasks();
159 int nCPUs = thread::hardware_concurrency();
161 vector<thread> threads;
163 int nMaxThreads = nCPUs * 2;
166 VERBOSE(3) <<
" Use multi-threading: (max) # of threads = # of CPU's "
167 << nCPUs <<
" (found) * 2";
169 for (
auto it : GetTaskList()) {
170 if (
it->GetActive()) {
171 threads.push_back(thread(&JetEnergyLoss::Exec,
172 dynamic_pointer_cast<JetEnergyLoss>(
it)));
175 if (n == nMaxThreads) {
177 for (
auto &th : threads)
187 if (nTasks < nMaxThreads) {
188 for (
auto &th : threads)
196 JetScapeTask::ExecuteTasks();
199 VERBOSE(3) <<
" " << GetNumberOfTasks()
200 <<
" Eloss Manager Tasks/Modules finished.";
203 void JetEnergyLossManager::CreateSignalSlots() {
204 for (
auto it : GetTaskList()) {
205 for (
auto it2 :
it->GetTaskList()) {
206 if (!dynamic_pointer_cast<JetEnergyLoss>(it2)->GetJetSignalConnected()) {
207 JetScapeSignalManager::Instance()->ConnectJetSignal(
208 dynamic_pointer_cast<JetEnergyLoss>(it2));
210 if (!dynamic_pointer_cast<JetEnergyLoss>(it2)
211 ->GetEdensitySignalConnected()) {
212 JetScapeSignalManager::Instance()->ConnectEdensitySignal(
213 dynamic_pointer_cast<JetEnergyLoss>(it2));
215 if (!dynamic_pointer_cast<JetEnergyLoss>(it2)
216 ->GetGetHydroCellSignalConnected()) {
217 JetScapeSignalManager::Instance()->ConnectGetHydroCellSignal(
218 dynamic_pointer_cast<JetEnergyLoss>(it2));
220 if (!dynamic_pointer_cast<JetEnergyLoss>(it2)
221 ->GetGetHydroTau0SignalConnected()) {
222 JetScapeSignalManager::Instance()->ConnectGetHydroTau0Signal(
223 dynamic_pointer_cast<JetEnergyLoss>(it2));
228 if (!dynamic_pointer_cast<JetEnergyLoss>(it2)
229 ->GetSentInPartonsConnected()) {
230 JetScapeSignalManager::Instance()->ConnectSentInPartonsSignal(
231 dynamic_pointer_cast<JetEnergyLoss>(
it),
232 dynamic_pointer_cast<JetEnergyLoss>(it2));
237 !liq_pt.lock()->get_GetHydroCellSignalConnected()) {
238 JetScapeSignalManager::Instance()->ConnectGetHydroCellSignal(
243 JetScapeSignalManager::Instance()->PrintGetHydroCellSignalMap();
245 JetScapeSignalManager::Instance()->PrintSentInPartonsSignalMap();