Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_Pythia6.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_Pythia6.C
2  const int nEvents = 30,
3  const char * pythiaConfigFile = "./config/phpythia6_ep_DISneutral.cfg",
4  const char * outputFile = "DST_p250_e20_1seed_DISneutral.root"
5  )
6 {
7 
8  bool runpythia6 = true;
9 
10  bool writedst = false;
11  bool writeascii = true;
12 
13  //---------------
14  // Load libraries
15  //---------------
16 
17  gSystem->Load("libfun4all.so");
18  gSystem->Load("libphhepmc.so");
19  gSystem->Load("libeicana.so");
20 
21  //---------------
22  // Fun4All server
23  //---------------
24 
26  se->Verbosity(0);
27 
28  // just if we set some flags somewhere in this macro
30  // By default every random number generator uses
31  // PHRandomSeed() which reads /dev/urandom to get its seed
32  // if the RANDOMSEED flag is set its value is taken as seed
33  // You ca neither set this to a random value using PHRandomSeed()
34  // which will make all seeds identical (not sure what the point of
35  // this would be:
36  // rc->set_IntFlag("RANDOMSEED",PHRandomSeed());
37  // or set it to a fixed value so you can debug your code
38  // rc->set_IntFlag("RANDOMSEED", 12345);
39 
40  rc->set_FloatFlag("WorldSizex",1000);
41  rc->set_FloatFlag("WorldSizey",1000);
42  rc->set_FloatFlag("WorldSizez",1000);
43  rc->set_CharFlag("WorldShape","G4Tubs");
44 
45  //-----------------
46  // Event generation
47  //-----------------
48 
49  if (runpythia6)
50  {
51  gSystem->Load("libPHPythia6.so");
52 
53  PHPythia6 *pythia6 = new PHPythia6();
54  pythia6->set_config_file(pythiaConfigFile);
55 
57  //trigger->SetParticleType(15);
58  trigger->SetQ2Min(1000.0);
59 
60  pythia6->register_trigger(trigger);
61 
62  se->registerSubsystem(pythia6);
63  }
64 
65 
66  DISKinematics *mcana = new DISKinematics(outputFile);
67  se->registerSubsystem( mcana );
68 
69 
70  //--------------
71  // IO management
72  //--------------
73 
74  /* Write DST output */
75  if ( writedst )
76  {
77  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT",outputFile);
78  se->registerOutputManager(out);
79  }
80 
81  /* Write HepMC ASCII output */
82  else if ( writeascii )
83  {
84  Fun4AllHepMCOutputManager *asciiout = new Fun4AllHepMCOutputManager("HEPMCOUT",outputFile);
85  se->registerOutputManager(asciiout);
86  }
87 
88  //-----------------
89  // Event processing
90  //-----------------
91  if (nEvents < 0)
92  {
93  return;
94  }
95  // if we run the particle generator and use 0 it'll run forever
96  if (nEvents == 0 && !readhits && !readhepmc)
97  {
98  cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
99  cout << "it will run forever, so I just return without running anything" << endl;
100  return;
101  }
102 
103  se->run(nEvents);
104 
105  //-----
106  // Exit
107  //-----
108 
109  se->End();
110  std::cout << "All done" << std::endl;
111  delete se;
112  gSystem->Exit(0);
113 }