Back to home page

sPhenix code displayed by LXR

 
 

    


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

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 #include <iostream>
0017 #include <time.h>
0018 
0019 // JetScape Framework includes ...
0020 #include "JetScape.h"
0021 #include "JetEnergyLoss.h"
0022 #include "JetEnergyLossManager.h"
0023 #include "JetScapeWriterStream.h"
0024 #ifdef USE_HEPMC
0025 #include "JetScapeWriterHepMC.h"
0026 #endif
0027 
0028 // User modules derived from jetscape framework clasess
0029 // to be used to run Jetscape ...
0030 // #include "AdSCFT.h"
0031 #include "Matter.h"
0032 // #include "Martini.h"
0033 #include "Brick.h"
0034 #include "PythiaGun.h"
0035 #include "HadronizationManager.h"
0036 #include "Hadronization.h"
0037 #include "ColoredHadronization.h"
0038 #include "ColorlessHadronization.h"
0039 
0040 // // Add initial state module for test
0041 // #include "TrentoInitial.h"
0042 
0043 #include <chrono>
0044 #include <thread>
0045 #include <sstream>
0046 
0047 using namespace std;
0048 
0049 using namespace Jetscape;
0050 
0051 // Forward declaration
0052 void Show();
0053 
0054 // -------------------------------------
0055 
0056 int main(int argc, char** argv)
0057 {
0058   clock_t t; t = clock();
0059   time_t start, end; time(&start);
0060   
0061   string XMLname="./pwg2_init.xml";
0062   string outname="test_out.dat.gz";
0063   int Nevents = 10;  
0064   
0065   if ( argc >1 && string(argv[1]) == "-h" ) {
0066     cout << "Usage: PWG2Wrapper [xmlname] [outputname] [Nevents]" << endl;
0067     return -1;
0068   }
0069 
0070   switch ( argc ){
0071     break;
0072   case 4:
0073     Nevents=atoi( argv[3] );
0074     // Fallthrough
0075   case 3:
0076     outname = argv[2];
0077     // Fallthrough
0078   case 2:
0079     XMLname = argv[1];
0080     break;
0081   case 1:
0082     break;
0083   case 0:
0084     break;
0085   default:
0086     cout << "Usage: brickTest [xmlname] [outputname] [Nevents]" << endl;
0087     return -1;
0088   }
0089   cout<<endl;
0090     
0091   // DEBUG=true by default and REMARK=false
0092   // can be also set also via XML file (at least partially)
0093   JetScapeLogger::Instance()->SetInfo(true);
0094   JetScapeLogger::Instance()->SetDebug(false);
0095   JetScapeLogger::Instance()->SetRemark(false);
0096   //SetVerboseLevel (9 a lot of additional debug output ...)
0097   //If you want to suppress it: use SetVerboseLevle(0) or max  SetVerboseLevle(9) or 10
0098   JetScapeLogger::Instance()->SetVerboseLevel(0);
0099 
0100   
0101   Show();
0102 
0103   auto jetscape = make_shared<JetScape>(XMLname,Nevents);
0104   jetscape->SetId("primary");
0105   // jetscape->SetReuseHydro (true);
0106   // jetscape->SetNReuseHydro (10);
0107 
0108   // auto trento = make_shared<TrentoInitial>();
0109   auto init = make_shared<InitialState>();
0110   auto pythiaGun= make_shared<PythiaGun> ();
0111   auto hydro = make_shared<Brick> ();
0112   
0113   auto jlossmanager = make_shared<JetEnergyLossManager> ();
0114   auto jloss = make_shared<JetEnergyLoss> ();
0115   auto matter = make_shared<Matter> ();
0116 
0117   // hadronization
0118   auto printer = make_shared<PartonPrinter>();
0119   auto hadroMgr = make_shared<HadronizationManager> ();
0120   auto hadro = make_shared<Hadronization> ();
0121   auto hadroModule = make_shared<ColoredHadronization> ();
0122   auto colorless = make_shared<ColorlessHadronization> ();
0123   
0124   // auto writer= make_shared<JetScapeWriterAscii> (outname);
0125   auto writer= make_shared<JetScapeWriterAsciiGZ> (outname);  
0126 #ifdef USE_HEPMC
0127   // auto writer= make_shared<JetScapeWriterHepMC> (outname);
0128 #endif
0129 
0130   //Remark: For now modules have to be added
0131   //in proper "workflow" order (can be defined via xml and sorted if necessary)  
0132   // jetscape->Add(trento);
0133   jetscape->Add(init);
0134   jetscape->Add(pythiaGun);
0135   jetscape->Add(hydro);
0136 
0137   // add module(s) to the eloss wrapper, than the eloss wrapper to the manager
0138   jloss->Add(matter);
0139   //jloss->Add(martini);
0140   //jloss->Add(adscft);
0141   jlossmanager->Add(jloss);  
0142   jetscape->Add(jlossmanager);
0143 
0144   // hadronization
0145   jetscape->Add(printer);
0146   hadro->Add(colorless);
0147   hadroMgr->Add(hadro);
0148   jetscape->Add(hadroMgr);
0149 
0150   // Add the writer object
0151   jetscape->Add(writer);
0152 
0153   // Initialize all modules tasks
0154   jetscape->Init();
0155   
0156   // Run JetScape with all task/modules as specified ...
0157   jetscape->Exec();
0158 
0159   // Some information is only known after the full run,
0160   // Therefore store information at the end of the file, in a footer
0161   writer->WriteComment ( "EVENT GENERATION INFORMATION" );
0162   Pythia8::Info& info = pythiaGun->info;
0163   std::ostringstream oss;
0164   oss.str(""); oss << "nTried    = " << info.nTried();
0165   writer->WriteComment ( oss.str() );
0166   oss.str(""); oss << "nSelected = " << info.nSelected();
0167   writer->WriteComment ( oss.str() );
0168   oss.str(""); oss << "nAccepted = " << info.nAccepted();
0169   writer->WriteComment ( oss.str() );
0170   oss.str(""); oss << "sigmaGen  = " << info.sigmaGen();  
0171   writer->WriteComment ( oss.str() );
0172   oss.str(""); oss << "sigmaErr  = " << info.sigmaErr();
0173   writer->WriteComment ( oss.str() );
0174 
0175   oss.str(""); oss << "eCM  = " << info.eCM();
0176   writer->WriteComment ( oss.str() );
0177   oss.str(""); oss << "pTHatMin  = " << pythiaGun->GetpTHatMin();
0178   writer->WriteComment ( oss.str() );
0179   oss.str(""); oss << "pTHatMax  = " << pythiaGun->GetpTHatMax();
0180   writer->WriteComment ( oss.str() );
0181 
0182   oss.str(""); oss << "JETSCAPE Random Seed  = " << JetScapeTaskSupport::Instance()->GetRandomSeed();
0183   writer->WriteComment ( oss.str() );
0184 
0185   writer->WriteComment ( "/EVENT GENERATION INFORMATION" );
0186   
0187   // Finalize
0188   jetscape->Finish();
0189   
0190   INFO_NICE<<"Finished!";
0191   cout<<endl;
0192 
0193   t = clock() - t;
0194   time(&end);
0195   printf ("CPU time: %f seconds.\n",((float)t)/CLOCKS_PER_SEC);
0196   printf ("Real time: %f seconds.\n",difftime(end,start));
0197 
0198     
0199   // Print pythia statistics
0200   // pythiaGun->stat();
0201 
0202  
0203   
0204   return 0;
0205 }
0206 
0207 // -------------------------------------
0208 
0209 void Show()
0210 {
0211   INFO_NICE<<"------------------------------------";
0212   INFO_NICE<<"| Brick Test JetScape Framework ... |";
0213   INFO_NICE<<"------------------------------------";
0214   INFO_NICE;
0215 }