EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
testJetScape.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file testJetScape.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 // JetScape Framework Test Program
17 // (use either shared library (need to add paths; see setup.csh)
18 // (or create static library and link in)
19 // -------------------------------------------------------------
20 
21 #include <iostream>
22 #include <string>
23 #include <thread>
24 
25 #include "JetScape.h"
26 #include "JetEnergyLoss.h"
27 #include "JetEnergyLossManager.h"
28 #include "JetScapeSignalManager.h"
29 #include "FluidDynamics.h"
30 #include "JetScapeLogger.h"
31 #include "JetScapeXML.h"
32 #include "Matter.h"
33 #include "Martini.h"
34 #include "JetScapeWriterStream.h"
35 #ifdef USE_HEPMC
36 #include "JetScapeWriterHepMC.h"
37 #endif
38 
39 
40 #include "sigslot.h"
41 
42 // for test case ...
43 #include "Brick.h"
44 #include "GubserHydro.h"
45 
46 using namespace std;
47 using namespace sigslot;
48 
49 using namespace Jetscape;
50 
51 void Show();
52 
53 // -------------------------------------
54 
55 int main(int argc, char** argv)
56 {
57  cout<<endl;
58 
59  // DEBUG=true by default and REMARK=false
60  // can be also set via XML file
61  JetScapeLogger::Instance()->SetDebug(true);
62  //JetScapeLogger::Instance()->SetRemark(true);
63  JetScapeLogger::Instance()->SetVerboseLevel(9);
64 
65  Show();
66 
67  //JetScapeSignalManager::Instance();
68 
69  //Test verbose ...
70  // Verbose Level 10 should be the highest ... (not check though in class)
71  //JetScapeLogger::Instance()->Verbose(4)<<"Test Verbose ...";
72  //VERBOSE(4)<<" Test Verbose ...";
73 
74  //With definitions above/in logger class as a shortcut
75  //JSDEBUG<<" Test";
76 
77  //JetScapeXML::Instance()->SetXMLFileName("./jetscape_init.xml");
78  //JetScapeXML::Instance()->OpenXMLFile();
79  //JetScapeXML::Instance()->OpenXMLFile("./jetscape_init.xml");
80 
81  //shared_ptr<JetScape> jetscape = make_shared<JetScape> ();
82  // or shorter ...
83  //auto jetscape = make_shared<JetScape> ();
84  //jetscape->SetXMLFileName("./jetscape_init.xml");
85 
86  // JetScape Clas acts as TaskManager (should be generalized at some point)
87  // Make it truly recursive (not yet really implemented that way)
88  // Think harder and maybe in general/decide on shared vs. unique vs. raw pointer usage ...
89  // Current: Just use make_shared always (propably not the most efficient solution ...)
90 
91  //auto jetscape = make_shared<JetScape>("/Users/putschke/JetScape/framework_xcode/jetscape_init.xml",3);
92  auto jetscape = make_shared<JetScape>("./jetscape_init.xml",3);
93  // if << overloaded for classes then for example (see commented out in JetScape.h)
94  //cout<<*jetscape<<endl;
95  // try to automatically create in Add()!? and to handle things behind the scene ...
96  auto jlossmanager = make_shared<JetEnergyLossManager> ();
97  auto jloss = make_shared<JetEnergyLoss> ();
98  //auto hydro = make_shared<FluidDynamics> ();
99  //auto hydro = make_shared<Brick> ();
100  auto hydro = make_shared<GubserHydro> ();
101 
102  auto matter = make_shared<Matter> ();
103  auto martini = make_shared<Martini> ();
104 
105  //auto writer= make_shared<JetScapeWriterAsciiGZ> ("test_out.dat.gz");
106  auto writer= make_shared<JetScapeWriterAscii> ("test_out.dat");
107 #ifdef USE_HEPMC
108  //auto writer= make_shared<JetScapeWriterHepMC> ("test_out.dat");
109 #endif
110  writer->SetActive(false);
111 
112  jetscape->Add(hydro);
113 
114  jloss->Add(matter);
115  jloss->Add(martini);
116 
117  //jetscape->Add(jloss);
118 
119  jlossmanager->Add(jloss);
120  jetscape->Add(jlossmanager);
121 
122  //jetscape->Add(writer);
123 
124  // can add before or after jetscape (order does not matter)
125 
126  //INFO<<"Number of JetScape Tasks = "<<jetscape->GetNumberOfTasks();
127  //INFO<<"Number of Eloss Tasks = "<<jloss->GetNumberOfTasks();
128 
129  jetscape->Init();
130 
131  // maybe smarter to deal with multiple eloss instances (think of di-jet) in seperate task Manager !??
132  //auto jloss2=make_shared<JetEnergyLoss> (*jloss);
133  //jetscape->Add(jloss2);
134 
135  REMARK<<"Module testing for now on Module Base class!";
136  REMARK<<"jetscape->Init(); Calls all Init()'s of jetscape modules tasks, ";
137  REMARK<<"since list/vector is sortable, can be used to ensure correct order or via xml file";
138 
139  // --------------------------
140  /*
141  //cout<<((JetEnergyLoss*) (jloss.get()))->GetQhat()<<endl;
142  auto jloss2=make_shared<JetEnergyLoss> (*jloss); //default copy works with STL vector list but no deep copy!!? See below
143  // to be implemented in class ...
144 
145  cout<<jloss->GetNumberOfTasks()<<" "<<jloss2->GetNumberOfTasks()<<endl;
146 
147  cout<<jloss.get()<<" "<<jloss2.get()<<endl;
148  cout<<jloss->GetTaskAt(0).get()<<" "<<jloss2->GetTaskAt(0).get() <<endl;
149 
150  cout<<((Matter*) (jloss->GetTaskAt(0).get()))->GetQhat()<<endl; //check with shared ...
151  cout<<((Matter*) (jloss2->GetTaskAt(0).get()))->GetQhat()<<endl;
152  ((Matter*) (jloss2->GetTaskAt(0).get()))->SetQhat(12);
153  cout<<((Matter*) (jloss->GetTaskAt(0).get()))->GetQhat()<<endl; //check with shared ...
154  cout<<((Matter*) (jloss2->GetTaskAt(0).get()))->GetQhat()<<endl;
155  */
156 
157  /*
158  //cout<<((Martini*) (jloss->GetTaskAt(1).get()))->GetQhat()<<endl;
159  //cout<<((Martini*) (jloss2->GetTaskAt(1).get()))->GetQhat()<<endl;
160  */
161 
162  /*
163  auto matter2 = make_shared<Matter> (*matter);
164  matter2->SetQhat(15);
165  cout<<matter2->GetQhat()<<endl;
166  cout<<matter->GetQhat()<<endl;
167  */
168  // --------------------------
169 
170  //
171  // Simple signal/slot creation
172  //
173  //hydro.get() --> old C++ style pointer needd for sigslot code ...
174  //Maybe switch to boost signal2 for more modern implementation ...
175  //jloss->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
176 
177  //Signal itself defined in JetEnergyLoss class
178  //Signal not allowed virtual ... (think about inheritence and user interface ...!?)
179  //matter->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
180  //matter2->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
181  //martini->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
182 
183  //JSDEBUG<<"Connect Signal/Slot : jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);";
184  //REMARK<<"Can be handelded in own connection class ...";
185 
186  //matter2->jetSignal(1,2);
187 
188  // ------------------
189  //some quick and dirty debug ...
190  //cout<<jetscape.use_count()<<endl;
191  //cout<<jloss.use_count()<<endl;
192 
193  //VERBOSE(9)<<" : Martini use count = "<< martini.use_count() ;
194 
195  /*
196  //martini = NULL;
197  //martini.reset();
198  //delete martini.get();
199  JetScapeLogger::Instance()->Verbose(9)<<" Martini after nullptr ... "<< martini.use_count() ;
200 
201  cout<<jetscape.use_count()<<endl;
202  cout<<jloss.use_count()<<endl;
203  */
204  // ------------------
205 
206  jetscape->Exec();
207 
208  //jetscape->Finish();
209 
210  //REMARK<<"Overload Exec for Hydro ...";
211 
212  // Others like finish and write (and in general data structure handling to be added/implmented accordingly)
213 
214  // If not handeled via task class can be called individually or put in jetscape main class ...
215  //jloss->Init();
216  //hydro->Init();
217 
218  //this_thread::sleep_for(std::chrono::milliseconds(1000000));
219 
220 
221  INFO_NICE<<"Finished!";
222  cout<<endl;
223 
224  /*
225  Parameter parameter_list;
226  parameter_list.hydro_input_filename = *(argv+1);
227 
228  Brick *brick_ptr = new Brick();
229  brick_ptr->InitializeHydro(parameter_list);
230  brick_ptr->EvolveHydro();
231  for (int i=1;i<20;i++)
232  {
233  FluidCellInfo* check_fluid_info_ptr = new FluidCellInfo;
234  brick_ptr->GetHydroInfo(i, 1.0, 1.0, 0.0, check_fluid_info_ptr);
235  //brick_ptr->PrintFluidCellInformation(check_fluid_info_ptr);
236  cout<<i<<" "<<check_fluid_info_ptr->energy_density<<" "<<check_fluid_info_ptr->temperature<<endl;
237  cout<<i<<" "<<brick_ptr->GetTemperature(i, 1.0, 1.0, 0.0)<<endl;
238  delete check_fluid_info_ptr;
239  }
240  */
241 
242  return 0;
243 }
244 
245 // -------------------------------------
246 
247 void Show()
248 {
249  INFO_NICE<<"-------------------------------";
250  INFO_NICE<<"| Test JetScape Framework ... |";
251  INFO_NICE<<"-------------------------------";
252 }