Analysis Software
Documentation for sPHENIX simulation 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>();
93  const char* mainXMLName = "../config/jetscape_main.xml";
94  const char* userXMLName = "../config/jetscape_user.xml";
95 
96  jetscape->SetXMLMainFileName(mainXMLName);
97  jetscape->SetXMLUserFileName(userXMLName);
98 
99  jetscape->SetNumberOfEvents(3);
100  // if << overloaded for classes then for example (see commented out in JetScape.h)
101  //cout<<*jetscape<<endl;
102  // try to automatically create in Add()!? and to handle things behind the scene ...
103  auto jlossmanager = make_shared<JetEnergyLossManager> ();
104  auto jloss = make_shared<JetEnergyLoss> ();
105  //auto hydro = make_shared<FluidDynamics> ();
106  //auto hydro = make_shared<Brick> ();
107  auto hydro = make_shared<GubserHydro> ();
108 
109  auto matter = make_shared<Matter> ();
110  auto martini = make_shared<Martini> ();
111 
112  //auto writer= make_shared<JetScapeWriterAsciiGZ> ("test_out.dat.gz");
113  auto writer= make_shared<JetScapeWriterAscii> ("test_out.dat");
114 #ifdef USE_HEPMC
115  //auto writer= make_shared<JetScapeWriterHepMC> ("test_out.dat");
116 #endif
117  writer->SetActive(false);
118 
119  jetscape->Add(hydro);
120 
121  jloss->Add(matter);
122  jloss->Add(martini);
123 
124  //jetscape->Add(jloss);
125 
126  jlossmanager->Add(jloss);
127  jetscape->Add(jlossmanager);
128 
129  //jetscape->Add(writer);
130 
131  // can add before or after jetscape (order does not matter)
132 
133  //JSINFO<<"Number of JetScape Tasks = "<<jetscape->GetNumberOfTasks();
134  //JSINFO<<"Number of Eloss Tasks = "<<jloss->GetNumberOfTasks();
135 
136  jetscape->Init();
137 
138  // maybe smarter to deal with multiple eloss instances (think of di-jet) in seperate task Manager !??
139  //auto jloss2=make_shared<JetEnergyLoss> (*jloss);
140  //jetscape->Add(jloss2);
141 
142  REMARK<<"Module testing for now on Module Base class!";
143  REMARK<<"jetscape->Init(); Calls all Init()'s of jetscape modules tasks, ";
144  REMARK<<"since list/vector is sortable, can be used to ensure correct order or via xml file";
145 
146  // --------------------------
147  /*
148  //cout<<((JetEnergyLoss*) (jloss.get()))->GetQhat()<<endl;
149  auto jloss2=make_shared<JetEnergyLoss> (*jloss); //default copy works with STL vector list but no deep copy!!? See below
150  // to be implemented in class ...
151 
152  cout<<jloss->GetNumberOfTasks()<<" "<<jloss2->GetNumberOfTasks()<<endl;
153 
154  cout<<jloss.get()<<" "<<jloss2.get()<<endl;
155  cout<<jloss->GetTaskAt(0).get()<<" "<<jloss2->GetTaskAt(0).get() <<endl;
156 
157  cout<<((Matter*) (jloss->GetTaskAt(0).get()))->GetQhat()<<endl; //check with shared ...
158  cout<<((Matter*) (jloss2->GetTaskAt(0).get()))->GetQhat()<<endl;
159  ((Matter*) (jloss2->GetTaskAt(0).get()))->SetQhat(12);
160  cout<<((Matter*) (jloss->GetTaskAt(0).get()))->GetQhat()<<endl; //check with shared ...
161  cout<<((Matter*) (jloss2->GetTaskAt(0).get()))->GetQhat()<<endl;
162  */
163 
164  /*
165  //cout<<((Martini*) (jloss->GetTaskAt(1).get()))->GetQhat()<<endl;
166  //cout<<((Martini*) (jloss2->GetTaskAt(1).get()))->GetQhat()<<endl;
167  */
168 
169  /*
170  auto matter2 = make_shared<Matter> (*matter);
171  matter2->SetQhat(15);
172  cout<<matter2->GetQhat()<<endl;
173  cout<<matter->GetQhat()<<endl;
174  */
175  // --------------------------
176 
177  //
178  // Simple signal/slot creation
179  //
180  //hydro.get() --> old C++ style pointer needd for sigslot code ...
181  //Maybe switch to boost signal2 for more modern implementation ...
182  //jloss->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
183 
184  //Signal itself defined in JetEnergyLoss class
185  //Signal not allowed virtual ... (think about inheritence and user interface ...!?)
186  //matter->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
187  //matter2->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
188  //martini->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
189 
190  //JSDEBUG<<"Connect Signal/Slot : jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);";
191  //REMARK<<"Can be handelded in own connection class ...";
192 
193  //matter2->jetSignal(1,2);
194 
195  // ------------------
196  //some quick and dirty debug ...
197  //cout<<jetscape.use_count()<<endl;
198  //cout<<jloss.use_count()<<endl;
199 
200  //VERBOSE(9)<<" : Martini use count = "<< martini.use_count() ;
201 
202  /*
203  //martini = NULL;
204  //martini.reset();
205  //delete martini.get();
206  JetScapeLogger::Instance()->Verbose(9)<<" Martini after nullptr ... "<< martini.use_count() ;
207 
208  cout<<jetscape.use_count()<<endl;
209  cout<<jloss.use_count()<<endl;
210  */
211  // ------------------
212 
213  jetscape->Exec();
214 
215  //jetscape->Finish();
216 
217  //REMARK<<"Overload Exec for Hydro ...";
218 
219  // Others like finish and write (and in general data structure handling to be added/implmented accordingly)
220 
221  // If not handeled via task class can be called individually or put in jetscape main class ...
222  //jloss->Init();
223  //hydro->Init();
224 
225  //this_thread::sleep_for(std::chrono::milliseconds(1000000));
226 
227 
228  INFO_NICE<<"Finished!";
229  cout<<endl;
230 
231  /*
232  Parameter parameter_list;
233  parameter_list.hydro_input_filename = *(argv+1);
234 
235  Brick *brick_ptr = new Brick();
236  brick_ptr->InitializeHydro(parameter_list);
237  brick_ptr->EvolveHydro();
238  for (int i=1;i<20;i++)
239  {
240  FluidCellInfo* check_fluid_info_ptr = new FluidCellInfo;
241  brick_ptr->GetHydroInfo(i, 1.0, 1.0, 0.0, check_fluid_info_ptr);
242  //brick_ptr->PrintFluidCellInformation(check_fluid_info_ptr);
243  cout<<i<<" "<<check_fluid_info_ptr->energy_density<<" "<<check_fluid_info_ptr->temperature<<endl;
244  cout<<i<<" "<<brick_ptr->GetTemperature(i, 1.0, 1.0, 0.0)<<endl;
245  delete check_fluid_info_ptr;
246  }
247  */
248 
249  return 0;
250 }
251 
252 // -------------------------------------
253 
254 void Show()
255 {
256  INFO_NICE<<"-------------------------------";
257  INFO_NICE<<"| Test JetScape Framework ... |";
258  INFO_NICE<<"-------------------------------";
259 }