Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:19:05

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 Run Macro
0017 // -------------------------------------------------------------
0018 
0019 #include <iostream>
0020 #include <time.h>
0021 
0022 // JetScape Framework includes ...
0023 #include "JetScape.h"
0024 #include "JetScapeWriterStream.h"
0025 #ifdef USE_HEPMC
0026 #include "JetScapeWriterHepMC.h"
0027 #endif
0028 
0029 #include <chrono>
0030 #include <thread>
0031 
0032 using namespace Jetscape;
0033 
0034 // Forward declaration
0035 void Show();
0036 
0037 // -------------------------------------
0038 
0039 int main(int argc, char** argv)
0040 {
0041   clock_t t; t = clock();
0042   time_t start, end; time(&start);
0043     
0044   // Logger settings (can be also set also via XML file, although note in that case they will apply only after they are initialized)
0045   JetScapeLogger::Instance()->SetInfo(true);
0046   JetScapeLogger::Instance()->SetDebug(false);
0047   JetScapeLogger::Instance()->SetRemark(false);
0048   JetScapeLogger::Instance()->SetVerboseLevel(0);
0049    
0050   Show();
0051 
0052   // Create main Jetscape task, and assign XML configuration files from command line arguments.
0053   // The user can supply 0, 1, 2 arguments, where the first (second) corresponds to the user (main) XML path.
0054   auto jetscape = make_shared<JetScape>();
0055   const char* mainXMLName = "../config/jetscape_main.xml";
0056   const char* userXMLName = "../config/jetscape_user.xml";
0057   if (argc == 2)  {
0058     if ( strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-h")==0 ){
0059       std::cout << "Command line options:" << std::endl;
0060       std::cout << "    First (optional) argument: path to user XML file         ./runJetscape /path/to/user.xml" << std::endl;
0061       std::cout << "    Second (optional) argument: path to main XML file      ./runJetscape /path/to/user.xml /path/to/main.xml" << std::endl;
0062       std::cout << "    If no command line options are given, defaults are used: config/jetscape_user.xml config/jetscape_main.xml" << std::endl;
0063       return -1;
0064     }
0065     else {
0066       userXMLName = argv[1];
0067     }
0068   }
0069   else if (argc == 3) {
0070     userXMLName = argv[1];
0071     mainXMLName = argv[2];
0072   }
0073   jetscape->SetXMLMainFileName(mainXMLName);
0074   jetscape->SetXMLUserFileName(userXMLName);
0075 
0076   // Initialize all modules tasks
0077   jetscape->Init();
0078 
0079   // Run JetScape with all task/modules as specified
0080   jetscape->Exec();
0081 
0082   // For the future, cleanup is mostly already done in write and clear
0083   jetscape->Finish();
0084   
0085   INFO_NICE<<"Finished!";
0086   cout<<endl;
0087 
0088   t = clock() - t;
0089   time(&end);
0090   printf ("CPU time: %f seconds.\n",((float)t)/CLOCKS_PER_SEC);
0091   printf ("Real time: %f seconds.\n",difftime(end,start));
0092   return 0;
0093 }
0094 
0095 // -------------------------------------
0096 
0097 void Show()
0098 {
0099   INFO_NICE<<"------------------------------";
0100   INFO_NICE<<"| ... JetScape Framework ... |";
0101   INFO_NICE<<"------------------------------";
0102   INFO_NICE;
0103 }