starPythia8.C 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // This macro based on code: $STAR/StRoot/StarGenerator/macros/starsim.pythia8.C
  3. // Author: Nikita Ermakov (coffe92@gmail.com)
  4. //
  5. void starPythia8(const char *outFileName = "pythia8.root",
  6. unsigned int nevents = 10,
  7. unsigned int ranseed = 1234,
  8. Float_t energy = 510.0)
  9. {
  10. std::cout << "Loading libraries..." << std::endl;
  11. gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  12. loadSharedLibraries();
  13. gSystem->Load("libMinuit");
  14. gSystem->Load("StarClassLibrary");
  15. gSystem->Load("libgsl");
  16. gSystem->Load("libgslcblas");
  17. gSystem->Load("libVMC.so");
  18. gSystem->Load("libStDb_Tables.so");
  19. gSystem->Load("libgen_Tables.so");
  20. gSystem->Load("libgeometry_Tables.so");
  21. gSystem->Load("libsim_Tables.so");
  22. gSystem->Load("libStarMagField.so");
  23. gSystem->Load("libSt_db_Maker.so");
  24. gSystem->Load("libSt_g2t.so");
  25. gSystem->Load("libSt_geant_Maker.so");
  26. gSystem->Load("StarGeneratorUtil.so");
  27. gSystem->Load("StarGeneratorEvent.so");
  28. gSystem->Load("StarGeneratorBase.so");
  29. gSystem->Load("Pythia8_1_62.so");
  30. gSystem->Load("libMathMore.so");
  31. gSystem->Load("Pythia8_1_62.so");
  32. std::cout << "Libraries have been successfully loaded" << std::endl;
  33. /*
  34. gROOT->ProcessLine(".L bfc.C");
  35. TString simple = "y2012 agml ";
  36. bfc(0, simple );
  37. gSystem->Load("libVMC.so");
  38. gSystem->Load("StarGeneratorUtil.so");
  39. gSystem->Load("StarGeneratorEvent.so");
  40. gSystem->Load("StarGeneratorBase.so" );
  41. gSystem->Load("Pythia8_1_62.so");
  42. gSystem->Load("libMathMore.so");
  43. gSystem->Load("Pythia8_1_62.so" ); // TODO: why do we need to load lib second time?
  44. */
  45. // Setup RNG seed and map all ROOT TRandom here
  46. /*
  47. struct timeval t;
  48. gettimeofday(&t, 0);
  49. int ranseed = (t.tv_sec*1000) + (t.tv_usec/1000);
  50. std::cout << "using random seed = " << ranseed << std::endl;
  51. */
  52. StChain *chain = new StChain("StChain");
  53. chain->SetDebug(0);
  54. StarRandom::seed(ranseed);
  55. StarRandom::capture();
  56. //
  57. // Create the primary event generator
  58. //
  59. StarPrimaryMaker *primary = new StarPrimaryMaker();
  60. primary->SetFileName(outFileName);
  61. primary->SetVertex(0.1, -0.1, 0.0);
  62. primary->SetSigma(0.1, 0.1, 30.0);
  63. //
  64. // Setup an event generator
  65. //
  66. //
  67. // Create the pythia 8 event generator and add it to
  68. // the primary generator
  69. //
  70. StarPythia8 *pythia8 = new StarPythia8();
  71. pythia8->SetFrame("CMS", energy);
  72. pythia8->SetBlue("proton");
  73. pythia8->SetYell("proton");
  74. pythia8->Set("SoftQCD:minBias = on");
  75. primary->AddGenerator(pythia8);
  76. //
  77. // Setup cuts on which particles get passed to geant for
  78. // simulation. (To run generator in standalone mode,
  79. // set ptmin=1.0E9.)
  80. // ptmin ptmax
  81. // primary->SetPtRange(0.0, -1.0); // GeV
  82. // etamin etamax
  83. // primary->SetEtaRange(-3.0, +3.0);
  84. // phimin phimax
  85. // primary->SetPhiRange(0., TMath::TwoPi());
  86. //
  87. // Setup a realistic z-vertex distribution:
  88. // x = 0 gauss width = 1mm
  89. // y = 0 gauss width = 1mm
  90. // z = 0 gauss width = 30cm
  91. //
  92. primary->SetVertex(0., 0., 0.);
  93. primary->SetSigma(0.1, 0.1, 30.0);
  94. //
  95. // Initialize primary event generator and all sub makers
  96. //
  97. chain->Init();
  98. //
  99. // Trigger on nevents
  100. //
  101. for (int i = 0; i < nevents; i++)
  102. {
  103. chain->Clear();
  104. chain->Make();
  105. }
  106. //
  107. // Finish the chain
  108. //
  109. chain->Finish();
  110. }