Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:31

0001 /*******************************************************************************
0002  * Copyright (c) The JETSCAPE Collaboration, 2018
0003  *
0004  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
0005  * 
0006  * For the list of contributors see AUTHORS.
0007  *
0008  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
0009  *
0010  * or via email to bugs.jetscape@gmail.com
0011  *
0012  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
0013  * See COPYING for details.
0014  ******************************************************************************/
0015 // ------------------------------------------------------------
0016 // JetScape Framework Test Program
0017 // (use either shared library (need to add paths; see setup.csh)
0018 // (or create static library and link in)
0019 // -------------------------------------------------------------
0020 
0021 #include <iostream>
0022 #include <string>
0023 #include <thread>
0024 
0025 #include "JetScape.h"
0026 #include "JetEnergyLoss.h"
0027 #include "JetEnergyLossManager.h"
0028 #include "JetScapeSignalManager.h"
0029 #include "FluidDynamics.h"
0030 #include "JetScapeLogger.h"
0031 #include "JetScapeXML.h"
0032 #include "Matter.h"
0033 #include "Martini.h"
0034 #include "JetScapeWriterStream.h"
0035 #ifdef USE_HEPMC
0036 #include "JetScapeWriterHepMC.h"
0037 #endif
0038 
0039 
0040 #include "sigslot.h"
0041 
0042 // for test case ...
0043 #include "Brick.h"
0044 #include "GubserHydro.h"
0045 
0046 using namespace std;
0047 using namespace sigslot;
0048 
0049 using namespace Jetscape;
0050 
0051 void Show();
0052 
0053 // -------------------------------------
0054 
0055 int main(int argc, char** argv)
0056 {
0057   cout<<endl;
0058   
0059   // DEBUG=true by default and REMARK=false
0060   // can be also set via XML file
0061   JetScapeLogger::Instance()->SetDebug(true);
0062   //JetScapeLogger::Instance()->SetRemark(true);  
0063   JetScapeLogger::Instance()->SetVerboseLevel(9);
0064    
0065   Show();
0066 
0067   //JetScapeSignalManager::Instance();
0068   
0069   //Test verbose ...
0070   // Verbose Level 10 should be the highest ... (not check though in class) 
0071   //JetScapeLogger::Instance()->Verbose(4)<<"Test Verbose ...";
0072   //VERBOSE(4)<<" Test Verbose ...";
0073   
0074   //With definitions above/in logger class  as a shortcut
0075   //JSDEBUG<<" Test";
0076   
0077   //JetScapeXML::Instance()->SetXMLFileName("./jetscape_init.xml");
0078   //JetScapeXML::Instance()->OpenXMLFile();
0079   //JetScapeXML::Instance()->OpenXMLFile("./jetscape_init.xml");    
0080   
0081   //shared_ptr<JetScape> jetscape = make_shared<JetScape> ();
0082   // or shorter ...
0083   //auto jetscape = make_shared<JetScape> ();
0084   //jetscape->SetXMLFileName("./jetscape_init.xml");
0085 
0086   // JetScape Clas acts as TaskManager (should be generalized at some point)
0087   // Make it truly recursive (not yet really implemented that way)
0088   // Think harder and maybe in general/decide on shared vs. unique vs. raw pointer usage ...
0089   // Current: Just use make_shared always (propably not the most efficient solution ...)
0090   
0091   //auto jetscape = make_shared<JetScape>("/Users/putschke/JetScape/framework_xcode/jetscape_init.xml",3);
0092   auto jetscape = make_shared<JetScape>();
0093   const char* mainXMLName = "../config/jetscape_main.xml";
0094   const char* userXMLName = "../config/jetscape_user.xml";
0095 
0096   jetscape->SetXMLMainFileName(mainXMLName);
0097   jetscape->SetXMLUserFileName(userXMLName);
0098 
0099   jetscape->SetNumberOfEvents(3);
0100   // if << overloaded for classes then for example (see commented out in JetScape.h)
0101   //cout<<*jetscape<<endl; 
0102   // try to automatically create in Add()!? and to handle things behind the scene ...
0103   auto jlossmanager = make_shared<JetEnergyLossManager> ();
0104   auto jloss = make_shared<JetEnergyLoss> ();
0105   //auto hydro = make_shared<FluidDynamics> ();
0106   //auto hydro = make_shared<Brick> ();
0107   auto hydro = make_shared<GubserHydro> ();
0108   
0109   auto matter = make_shared<Matter> ();
0110   auto martini = make_shared<Martini> ();
0111 
0112   //auto writer= make_shared<JetScapeWriterAsciiGZ> ("test_out.dat.gz");
0113   auto writer= make_shared<JetScapeWriterAscii> ("test_out.dat");
0114 #ifdef USE_HEPMC
0115   //auto writer= make_shared<JetScapeWriterHepMC> ("test_out.dat");
0116 #endif
0117   writer->SetActive(false);
0118   
0119   jetscape->Add(hydro);
0120 
0121   jloss->Add(matter);
0122   jloss->Add(martini);
0123 
0124   //jetscape->Add(jloss);
0125   
0126   jlossmanager->Add(jloss);
0127   jetscape->Add(jlossmanager);
0128 
0129   //jetscape->Add(writer);
0130 
0131   // can add before or after jetscape (order does not matter)
0132   
0133   //JSINFO<<"Number of JetScape Tasks = "<<jetscape->GetNumberOfTasks();
0134   //JSINFO<<"Number of Eloss Tasks = "<<jloss->GetNumberOfTasks();
0135   
0136   jetscape->Init();
0137 
0138    // maybe smarter to deal with multiple eloss instances (think of di-jet) in seperate task Manager !??
0139   //auto jloss2=make_shared<JetEnergyLoss> (*jloss);
0140   //jetscape->Add(jloss2);
0141 
0142   REMARK<<"Module testing for now on Module Base class!";
0143   REMARK<<"jetscape->Init(); Calls all Init()'s of jetscape modules tasks, ";
0144   REMARK<<"since list/vector is sortable, can be used to ensure correct order or via xml file"; 
0145 
0146   // --------------------------
0147   /*
0148   //cout<<((JetEnergyLoss*) (jloss.get()))->GetQhat()<<endl;
0149   auto jloss2=make_shared<JetEnergyLoss> (*jloss); //default copy works with STL vector list but no deep copy!!? See below
0150   // to be implemented in class ...
0151   
0152   cout<<jloss->GetNumberOfTasks()<<" "<<jloss2->GetNumberOfTasks()<<endl;
0153   
0154   cout<<jloss.get()<<" "<<jloss2.get()<<endl;
0155   cout<<jloss->GetTaskAt(0).get()<<" "<<jloss2->GetTaskAt(0).get() <<endl;
0156   
0157   cout<<((Matter*) (jloss->GetTaskAt(0).get()))->GetQhat()<<endl; //check with shared ...
0158   cout<<((Matter*) (jloss2->GetTaskAt(0).get()))->GetQhat()<<endl;
0159   ((Matter*) (jloss2->GetTaskAt(0).get()))->SetQhat(12);
0160   cout<<((Matter*) (jloss->GetTaskAt(0).get()))->GetQhat()<<endl; //check with shared ...
0161   cout<<((Matter*) (jloss2->GetTaskAt(0).get()))->GetQhat()<<endl;
0162   */
0163   
0164   /*
0165   //cout<<((Martini*) (jloss->GetTaskAt(1).get()))->GetQhat()<<endl;
0166   //cout<<((Martini*) (jloss2->GetTaskAt(1).get()))->GetQhat()<<endl;
0167   */
0168 
0169   /*
0170   auto matter2 = make_shared<Matter> (*matter);
0171   matter2->SetQhat(15);
0172   cout<<matter2->GetQhat()<<endl;
0173   cout<<matter->GetQhat()<<endl;
0174   */
0175   // --------------------------
0176   
0177   //
0178   // Simple signal/slot creation
0179   //
0180   //hydro.get() --> old C++ style pointer needd for sigslot code ...
0181   //Maybe switch to boost signal2 for more modern implementation ... 
0182   //jloss->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
0183   
0184   //Signal itself defined in JetEnergyLoss class
0185   //Signal not allowed virtual ... (think about inheritence and user interface ...!?)
0186   //matter->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
0187   //matter2->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
0188   //martini->jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);
0189 
0190   //JSDEBUG<<"Connect Signal/Slot : jetSignal.connect(hydro.get(), &FluidDynamics::UpdateEnergyDeposit);";
0191   //REMARK<<"Can be handelded in own connection class ...";
0192 
0193   //matter2->jetSignal(1,2);
0194   
0195   // ------------------
0196   //some quick and dirty debug ...
0197   //cout<<jetscape.use_count()<<endl;
0198   //cout<<jloss.use_count()<<endl;
0199   
0200   //VERBOSE(9)<<" : Martini use count = "<<  martini.use_count() ;
0201 
0202   /*
0203   //martini = NULL;
0204   //martini.reset();
0205   //delete martini.get();
0206   JetScapeLogger::Instance()->Verbose(9)<<" Martini after nullptr ... "<<  martini.use_count() ; 
0207 
0208   cout<<jetscape.use_count()<<endl;
0209   cout<<jloss.use_count()<<endl;
0210   */
0211   // ------------------
0212   
0213   jetscape->Exec();
0214 
0215   //jetscape->Finish();
0216   
0217   //REMARK<<"Overload Exec for Hydro ...";
0218 
0219   // Others like finish and write (and in general data structure handling to be added/implmented accordingly)
0220   
0221   // If not handeled via task class can be called individually or put in jetscape main class ...
0222   //jloss->Init();
0223   //hydro->Init();
0224   
0225   //this_thread::sleep_for(std::chrono::milliseconds(1000000));
0226 
0227   
0228   INFO_NICE<<"Finished!";
0229   cout<<endl;
0230 
0231   /*
0232   Parameter parameter_list;
0233     parameter_list.hydro_input_filename = *(argv+1);
0234 
0235     Brick *brick_ptr = new Brick();
0236     brick_ptr->InitializeHydro(parameter_list);
0237     brick_ptr->EvolveHydro();
0238      for (int i=1;i<20;i++)
0239       {
0240     FluidCellInfo* check_fluid_info_ptr = new FluidCellInfo;
0241     brick_ptr->GetHydroInfo(i, 1.0, 1.0, 0.0, check_fluid_info_ptr);
0242     //brick_ptr->PrintFluidCellInformation(check_fluid_info_ptr);
0243     cout<<i<<" "<<check_fluid_info_ptr->energy_density<<" "<<check_fluid_info_ptr->temperature<<endl;
0244     cout<<i<<" "<<brick_ptr->GetTemperature(i, 1.0, 1.0, 0.0)<<endl;
0245     delete check_fluid_info_ptr;
0246       }
0247   */
0248   
0249   return 0;
0250 }
0251 
0252 // -------------------------------------
0253 
0254 void Show()
0255 {
0256   INFO_NICE<<"-------------------------------";
0257   INFO_NICE<<"| Test JetScape Framework ... |";
0258   INFO_NICE<<"-------------------------------";
0259 }