Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
writerTest.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file writerTest.cc
1 // -----------------------------------------
2 // JetScape (modular/task) based framework
3 // Intial Design: Joern Putschke (2017)
4 // (Wayne State University)
5 // -----------------------------------------
6 // License and Doxygen-like Documentation to be added ...
7 
8 // ------------------------------------------------------------
9 // JetScape Framework Writer Test Program
10 // Test by Kurt Jung (UIC)
11 // Validate parton and vertex linkage through new initial-state module
12 // -------------------------------------------------------------
13 
14 #include <iostream>
15 #include <time.h>
16 
17 // JetScape Framework includes ...
18 #include "JetScape.h"
19 #include "JetEnergyLoss.h"
20 #include "JetEnergyLossManager.h"
21 #include "JetScapeWriterAscii.h"
22 #include "JetScapeWriterAsciiGZ.h"
23 #ifdef USE_HEPMC
24 #include "JetScapeWriterHepMC.h"
25 #endif
26 
27 // User modules derived from jetscape framework clasess
28 // to be used to run Jetscape ...
29 #include "InitialState.h"
30 #include "Matter.h"
31 #include "Martini.h"
32 #include "Brick.h"
33 #include "GubserHydro.h"
34 #include "PGun.h"
35 
36 #include <chrono>
37 #include <thread>
38 
39 using namespace std;
40 
41 using namespace Jetscape;
42 
43 // Forward declaration
44 void Show();
45 
46 // -------------------------------------
47 
48 int main(int argc, char** argv)
49 {
50  clock_t t; t = clock();
51  time_t start, end; time(&start);
52 
53  cout<<endl;
54 
55  // DEBUG=true by default and REMARK=false
56  // can be also set also via XML file (at least partially)
57  JetScapeLogger::Instance()->SetDebug(false);
58  JetScapeLogger::Instance()->SetRemark(false);
59  //SetVerboseLevel (9 a lot of additional debug output ...)
60  //If you want to suppress it: use SetVerboseLevle(0) or max SetVerboseLevle(9) or 10
61  JetScapeLogger::Instance()->SetVerboseLevel(8);
62 
63  Show();
64 
65  auto jetscape = make_shared<JetScape>("./jetscape_init.xml",10);
66  jetscape->SetId("primary");
67  auto initState = make_shared<InitialState> ();
68  auto jlossmanager = make_shared<JetEnergyLossManager> ();
69  auto jloss = make_shared<JetEnergyLoss> ();
70  auto hydro = make_shared<Brick> ();
71  //auto hydro = make_shared<GubserHydro> ();
72 
73  auto matter = make_shared<Matter> ();
74  auto martini = make_shared<Martini> ();
75 
76  auto pGun= make_shared<PGun> ();
77 
78  // only pure Ascii writer implemented and working with graph output ...
79  //auto writer= make_shared<JetScapeWriterAscii> ("test_out.dat");
80  auto writer= make_shared<JetScapeWriterAsciiGZ> ("test_out.dat.gz");
81 #ifdef HepMC
82  auto writer= make_shared<JetScapeWriterHepMC> ("test_out.hepmc");
83 #endif
84 
85  jetscape->Add(initState);
86 
87  //Remark: For now modules have to be added
88  //in proper "workflow" order (can be defined via xml and sorted if necessary)
89 
90  jetscape->Add(pGun);
91 
92  //Some modifications will be needed for reusing hydro events, so far
93  //simple test hydros always executed "on the fly" ...
94  jetscape->Add(hydro);
95 
96  jloss->Add(matter);
97  jloss->Add(martini);
98 
99  jlossmanager->Add(jloss);
100 
101  jetscape->Add(jlossmanager);
102 
103  jetscape->Add(writer);
104 
105  // Initialize all modules tasks
106  jetscape->Init();
107 
108  // Run JetScape with all task/modules as specified ...
109  jetscape->Exec();
110 
111  jetscape->Finish();
112 
113  INFO_NICE<<"Finished!";
114  cout<<endl;
115 
116  // wait for 5s
117  //std::this_thread::sleep_for(std::chrono::milliseconds(500000));
118 
119  t = clock() - t;
120  time(&end);
121  printf ("CPU time: %f seconds.\n",((float)t)/CLOCKS_PER_SEC);
122  printf ("Real time: %f seconds.\n",difftime(end,start));
123  //printf ("Real time: %f seconds.\n",(start-end));
124  return 0;
125 }
126 
127 // -------------------------------------
128 
129 void Show()
130 {
131  INFO_NICE<<"------------------------------------";
132  INFO_NICE<<"| Writer Test JetScape Framework ... |";
133  INFO_NICE<<"------------------------------------";
134  INFO_NICE;
135 }