Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PWG2Wrapper.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PWG2Wrapper.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 #include <iostream>
17 #include <time.h>
18 
19 // JetScape Framework includes ...
20 #include "JetScape.h"
21 #include "JetEnergyLoss.h"
22 #include "JetEnergyLossManager.h"
23 #include "JetScapeWriterStream.h"
24 #ifdef USE_HEPMC
25 #include "JetScapeWriterHepMC.h"
26 #endif
27 
28 // User modules derived from jetscape framework clasess
29 // to be used to run Jetscape ...
30 // #include "AdSCFT.h"
31 #include "Matter.h"
32 // #include "Martini.h"
33 #include "Brick.h"
34 #include "PythiaGun.h"
35 #include "HadronizationManager.h"
36 #include "Hadronization.h"
37 #include "ColoredHadronization.h"
38 #include "ColorlessHadronization.h"
39 
40 // // Add initial state module for test
41 // #include "TrentoInitial.h"
42 
43 #include <chrono>
44 #include <thread>
45 #include <sstream>
46 
47 using namespace std;
48 
49 using namespace Jetscape;
50 
51 // Forward declaration
52 void Show();
53 
54 // -------------------------------------
55 
56 int main(int argc, char** argv)
57 {
58  clock_t t; t = clock();
59  time_t start, end; time(&start);
60 
61  string XMLname="./pwg2_init.xml";
62  string outname="test_out.dat.gz";
63  int Nevents = 10;
64 
65  if ( argc >1 && string(argv[1]) == "-h" ) {
66  cout << "Usage: PWG2Wrapper [xmlname] [outputname] [Nevents]" << endl;
67  return -1;
68  }
69 
70  switch ( argc ){
71  break;
72  case 4:
73  Nevents=atoi( argv[3] );
74  // Fallthrough
75  case 3:
76  outname = argv[2];
77  // Fallthrough
78  case 2:
79  XMLname = argv[1];
80  break;
81  case 1:
82  break;
83  case 0:
84  break;
85  default:
86  cout << "Usage: brickTest [xmlname] [outputname] [Nevents]" << endl;
87  return -1;
88  }
89  cout<<endl;
90 
91  // DEBUG=true by default and REMARK=false
92  // can be also set also via XML file (at least partially)
93  JetScapeLogger::Instance()->SetInfo(true);
94  JetScapeLogger::Instance()->SetDebug(false);
95  JetScapeLogger::Instance()->SetRemark(false);
96  //SetVerboseLevel (9 a lot of additional debug output ...)
97  //If you want to suppress it: use SetVerboseLevle(0) or max SetVerboseLevle(9) or 10
98  JetScapeLogger::Instance()->SetVerboseLevel(0);
99 
100 
101  Show();
102 
103  auto jetscape = make_shared<JetScape>(XMLname,Nevents);
104  jetscape->SetId("primary");
105  // jetscape->SetReuseHydro (true);
106  // jetscape->SetNReuseHydro (10);
107 
108  // auto trento = make_shared<TrentoInitial>();
109  auto init = make_shared<InitialState>();
110  auto pythiaGun= make_shared<PythiaGun> ();
111  auto hydro = make_shared<Brick> ();
112 
113  auto jlossmanager = make_shared<JetEnergyLossManager> ();
114  auto jloss = make_shared<JetEnergyLoss> ();
115  auto matter = make_shared<Matter> ();
116 
117  // hadronization
118  auto printer = make_shared<PartonPrinter>();
119  auto hadroMgr = make_shared<HadronizationManager> ();
120  auto hadro = make_shared<Hadronization> ();
121  auto hadroModule = make_shared<ColoredHadronization> ();
122  auto colorless = make_shared<ColorlessHadronization> ();
123 
124  // auto writer= make_shared<JetScapeWriterAscii> (outname);
125  auto writer= make_shared<JetScapeWriterAsciiGZ> (outname);
126 #ifdef USE_HEPMC
127  // auto writer= make_shared<JetScapeWriterHepMC> (outname);
128 #endif
129 
130  //Remark: For now modules have to be added
131  //in proper "workflow" order (can be defined via xml and sorted if necessary)
132  // jetscape->Add(trento);
133  jetscape->Add(init);
134  jetscape->Add(pythiaGun);
135  jetscape->Add(hydro);
136 
137  // add module(s) to the eloss wrapper, than the eloss wrapper to the manager
138  jloss->Add(matter);
139  //jloss->Add(martini);
140  //jloss->Add(adscft);
141  jlossmanager->Add(jloss);
142  jetscape->Add(jlossmanager);
143 
144  // hadronization
145  jetscape->Add(printer);
146  hadro->Add(colorless);
147  hadroMgr->Add(hadro);
148  jetscape->Add(hadroMgr);
149 
150  // Add the writer object
151  jetscape->Add(writer);
152 
153  // Initialize all modules tasks
154  jetscape->Init();
155 
156  // Run JetScape with all task/modules as specified ...
157  jetscape->Exec();
158 
159  // Some information is only known after the full run,
160  // Therefore store information at the end of the file, in a footer
161  writer->WriteComment ( "EVENT GENERATION INFORMATION" );
162  Pythia8::Info& info = pythiaGun->info;
163  std::ostringstream oss;
164  oss.str(""); oss << "nTried = " << info.nTried();
165  writer->WriteComment ( oss.str() );
166  oss.str(""); oss << "nSelected = " << info.nSelected();
167  writer->WriteComment ( oss.str() );
168  oss.str(""); oss << "nAccepted = " << info.nAccepted();
169  writer->WriteComment ( oss.str() );
170  oss.str(""); oss << "sigmaGen = " << info.sigmaGen();
171  writer->WriteComment ( oss.str() );
172  oss.str(""); oss << "sigmaErr = " << info.sigmaErr();
173  writer->WriteComment ( oss.str() );
174 
175  oss.str(""); oss << "eCM = " << info.eCM();
176  writer->WriteComment ( oss.str() );
177  oss.str(""); oss << "pTHatMin = " << pythiaGun->GetpTHatMin();
178  writer->WriteComment ( oss.str() );
179  oss.str(""); oss << "pTHatMax = " << pythiaGun->GetpTHatMax();
180  writer->WriteComment ( oss.str() );
181 
182  oss.str(""); oss << "JETSCAPE Random Seed = " << JetScapeTaskSupport::Instance()->GetRandomSeed();
183  writer->WriteComment ( oss.str() );
184 
185  writer->WriteComment ( "/EVENT GENERATION INFORMATION" );
186 
187  // Finalize
188  jetscape->Finish();
189 
190  INFO_NICE<<"Finished!";
191  cout<<endl;
192 
193  t = clock() - t;
194  time(&end);
195  printf ("CPU time: %f seconds.\n",((float)t)/CLOCKS_PER_SEC);
196  printf ("Real time: %f seconds.\n",difftime(end,start));
197 
198 
199  // Print pythia statistics
200  // pythiaGun->stat();
201 
202 
203 
204  return 0;
205 }
206 
207 // -------------------------------------
208 
209 void Show()
210 {
211  INFO_NICE<<"------------------------------------";
212  INFO_NICE<<"| Brick Test JetScape Framework ... |";
213  INFO_NICE<<"------------------------------------";
214  INFO_NICE;
215 }