Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:12:25

0001 int Fun4All_Pythia6(
0002                     const int nEvents = 30,
0003                     const char * pythiaConfigFile = "./config/phpythia6_ep_DISneutral.cfg",
0004                     const char * outputFile = "DST_p250_e20_1seed_DISneutral.root"
0005                     )
0006 {
0007 
0008   bool runpythia6 = true;
0009 
0010   bool writedst = false;
0011   bool writeascii = true;
0012 
0013   //---------------
0014   // Load libraries
0015   //---------------
0016 
0017   gSystem->Load("libfun4all.so");
0018   gSystem->Load("libphhepmc.so");
0019   gSystem->Load("libeicana.so");
0020 
0021   //---------------
0022   // Fun4All server
0023   //---------------
0024 
0025   Fun4AllServer *se = Fun4AllServer::instance();
0026   se->Verbosity(0);
0027 
0028   // just if we set some flags somewhere in this macro
0029   recoConsts *rc = recoConsts::instance();
0030   // By default every random number generator uses
0031   // PHRandomSeed() which reads /dev/urandom to get its seed
0032   // if the RANDOMSEED flag is set its value is taken as seed
0033   // You ca neither set this to a random value using PHRandomSeed()
0034   // which will make all seeds identical (not sure what the point of
0035   // this would be:
0036   //  rc->set_IntFlag("RANDOMSEED",PHRandomSeed());
0037   // or set it to a fixed value so you can debug your code
0038   //  rc->set_IntFlag("RANDOMSEED", 12345);
0039 
0040   rc->set_FloatFlag("WorldSizex",1000);
0041   rc->set_FloatFlag("WorldSizey",1000);
0042   rc->set_FloatFlag("WorldSizez",1000);
0043   rc->set_CharFlag("WorldShape","G4Tubs");
0044 
0045   //-----------------
0046   // Event generation
0047   //-----------------
0048 
0049   if (runpythia6)
0050     {
0051       gSystem->Load("libPHPythia6.so");
0052 
0053       PHPythia6 *pythia6 = new PHPythia6();
0054       pythia6->set_config_file(pythiaConfigFile);
0055       
0056       PHPy6ParticleTrigger *trigger = new PHPy6ParticleTrigger();
0057       //trigger->SetParticleType(15);
0058       trigger->SetQ2Min(1000.0);
0059 
0060       pythia6->register_trigger(trigger);
0061       
0062       se->registerSubsystem(pythia6);
0063     }
0064 
0065 
0066   DISKinematics *mcana = new DISKinematics(outputFile);
0067   se->registerSubsystem( mcana );
0068 
0069 
0070   //--------------
0071   // IO management
0072   //--------------
0073 
0074   /* Write DST output */
0075   if ( writedst )
0076     {
0077       Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT",outputFile);
0078       se->registerOutputManager(out);
0079     }
0080 
0081   /* Write HepMC ASCII output */
0082   else if ( writeascii )
0083     {
0084       Fun4AllHepMCOutputManager *asciiout = new Fun4AllHepMCOutputManager("HEPMCOUT",outputFile);
0085       se->registerOutputManager(asciiout);
0086     }
0087 
0088   //-----------------
0089   // Event processing
0090   //-----------------
0091   if (nEvents < 0)
0092     {
0093       return;
0094     }
0095   // if we run the particle generator and use 0 it'll run forever
0096   if (nEvents == 0 && !readhits && !readhepmc)
0097     {
0098       cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0099       cout << "it will run forever, so I just return without running anything" << endl;
0100       return;
0101     }
0102 
0103   se->run(nEvents);
0104 
0105   //-----
0106   // Exit
0107   //-----
0108 
0109   se->End();
0110   std::cout << "All done" << std::endl;
0111   delete se;
0112   gSystem->Exit(0);
0113 }