Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
runJetscape.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file runJetscape.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 Run Macro
17 // -------------------------------------------------------------
18 
19 #include <iostream>
20 #include <time.h>
21 
22 // JetScape Framework includes ...
23 #include "JetScape.h"
24 #include "JetScapeWriterStream.h"
25 #ifdef USE_HEPMC
26 #include "JetScapeWriterHepMC.h"
27 #endif
28 
29 #include <chrono>
30 #include <thread>
31 
32 using namespace Jetscape;
33 
34 // Forward declaration
35 void Show();
36 
37 // -------------------------------------
38 
39 int main(int argc, char** argv)
40 {
41  clock_t t; t = clock();
42  time_t start, end; time(&start);
43 
44  // Logger settings (can be also set also via XML file, although note in that case they will apply only after they are initialized)
49 
50  Show();
51 
52  // Create main Jetscape task, and assign XML configuration files from command line arguments.
53  // The user can supply 0, 1, 2 arguments, where the first (second) corresponds to the user (main) XML path.
54  auto jetscape = make_shared<JetScape>();
55  const char* mainXMLName = "../config/jetscape_main.xml";
56  const char* userXMLName = "../config/jetscape_user.xml";
57  if (argc == 2) {
58  if ( strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-h")==0 ){
59  std::cout << "Command line options:" << std::endl;
60  std::cout << " First (optional) argument: path to user XML file ./runJetscape /path/to/user.xml" << std::endl;
61  std::cout << " Second (optional) argument: path to main XML file ./runJetscape /path/to/user.xml /path/to/main.xml" << std::endl;
62  std::cout << " If no command line options are given, defaults are used: config/jetscape_user.xml config/jetscape_main.xml" << std::endl;
63  return -1;
64  }
65  else {
66  userXMLName = argv[1];
67  }
68  }
69  else if (argc == 3) {
70  userXMLName = argv[1];
71  mainXMLName = argv[2];
72  }
73  jetscape->SetXMLMainFileName(mainXMLName);
74  jetscape->SetXMLUserFileName(userXMLName);
75 
76  // Initialize all modules tasks
77  jetscape->Init();
78 
79  // Run JetScape with all task/modules as specified
80  jetscape->Exec();
81 
82  // For the future, cleanup is mostly already done in write and clear
83  jetscape->Finish();
84 
85  INFO_NICE<<"Finished!";
86  cout<<endl;
87 
88  t = clock() - t;
89  time(&end);
90  printf ("CPU time: %f seconds.\n",((float)t)/CLOCKS_PER_SEC);
91  printf ("Real time: %f seconds.\n",difftime(end,start));
92  return 0;
93 }
94 
95 // -------------------------------------
96 
97 void Show()
98 {
99  INFO_NICE<<"------------------------------";
100  INFO_NICE<<"| ... JetScape Framework ... |";
101  INFO_NICE<<"------------------------------";
102  INFO_NICE;
103 }