Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef MACRO_G4INPUT_C
0002 #define MACRO_G4INPUT_C
0003 
0004 #include <G4_TrkrVariables.C>
0005 #include <GlobalVariables.C>
0006 
0007 #include <phpythia8/PHPythia8.h>
0008 
0009 #include <g4main/CosmicSpray.h>
0010 #include <g4main/HepMCNodeReader.h>
0011 #include <g4main/PHG4IonGun.h>
0012 #include <g4main/PHG4ParticleGenerator.h>
0013 #include <g4main/PHG4ParticleGeneratorD0.h>
0014 #include <g4main/PHG4ParticleGeneratorVectorMeson.h>
0015 #include <g4main/PHG4ParticleGun.h>
0016 #include <g4main/PHG4SimpleEventGenerator.h>
0017 // #include <g4main/ReadEICFiles.h>
0018 
0019 #include <fermimotionafterburner/FermimotionAfterburner.h>
0020 #include <hijingflipafterburner/HIJINGFlipAfterburner.h>
0021 #include <reactionplaneafterburner/ReactionPlaneAfterburner.h>
0022 
0023 #include <phhepmc/Fun4AllHepMCInputManager.h>
0024 #include <phhepmc/Fun4AllHepMCPileupInputManager.h>
0025 #include <phhepmc/HepMCFlowAfterBurner.h>
0026 #include <phhepmc/PHHepMCGenHelper.h>
0027 
0028 #include <fun4all/Fun4AllDstInputManager.h>
0029 #include <fun4all/Fun4AllDummyInputManager.h>
0030 #include <fun4all/Fun4AllInputManager.h>
0031 #include <fun4all/Fun4AllNoSyncDstInputManager.h>
0032 #include <fun4all/Fun4AllServer.h>
0033 
0034 #include <TSystem.h>  // for gSystem
0035 
0036 #include <set>
0037 
0038 R__LOAD_LIBRARY(libfun4all.so)
0039 R__LOAD_LIBRARY(libg4testbench.so)
0040 R__LOAD_LIBRARY(libPHPythia8.so)
0041 R__LOAD_LIBRARY(libFermimotionAfterburner.so)
0042 R__LOAD_LIBRARY(libHIJINGFlipAfterburner.so)
0043 R__LOAD_LIBRARY(libReactionPlaneAfterburner.so)
0044 
0045 namespace Input
0046 {
0047   // Real Event generators
0048   bool PYTHIA6 = false;
0049   int PYTHIA6_EmbedId = 0;
0050 
0051   bool PYTHIA8 = false;
0052   int PYTHIA8_EmbedId = 0;
0053 
0054   // Single/multiple particle generators
0055   bool DZERO = false;
0056   int DZERO_NUMBER = 1;
0057   int DZERO_VERBOSITY = 0;
0058   std::set<int> DZERO_EmbedIds;
0059 
0060   bool GUN = false;
0061   int GUN_NUMBER = 1;
0062   int GUN_VERBOSITY = 0;
0063   std::set<int> GUN_EmbedIds;
0064 
0065   bool IONGUN = false;
0066   int IONGUN_NUMBER = 1;
0067   int IONGUN_VERBOSITY = 0;
0068   std::set<int> IONGUN_EmbedIds;
0069 
0070   bool PGEN = false;
0071   int PGEN_NUMBER = 1;
0072   int PGEN_VERBOSITY = 0;
0073   std::set<int> PGEN_EmbedIds;
0074 
0075   bool SIMPLE = false;
0076   int SIMPLE_NUMBER = 1;
0077   int SIMPLE_VERBOSITY = 0;
0078 
0079   int UPSILON_NUMBER = 1;
0080   int UPSILON_VERBOSITY = 0;
0081   // other UPSILON settings which are also used elsewhere are in GlobalVariables.C
0082 
0083   double PILEUPRATE = 0.;
0084   bool READHITS = false;
0085   int VERBOSITY = 0;
0086   int EmbedId = 1;
0087   int VertexEmbedId = 0;
0088 
0089   bool COSMIC = false;
0090   double COSMIC_R = 650.;
0091 
0092   double beam_crossing = -1.5;  // -1.5 mRad
0093   //! apply reference sPHENIX nominal beam parameter with 1.5mrad crossing as used in 2024
0094   //! \param[in] HepMCGen any HepMC generator, e.g. Fun4AllHepMCInputManager, Fun4AllHepMCPileupInputManager, PHPythia8, PHPythia6, ReadEICFiles
0095   //! \param[in] collision_type select the beam configuration with Input::BeamConfiguration
0096   void ApplysPHENIXBeamParameter(PHHepMCGenHelper *HepMCGen, const Input::BeamConfiguration &beam_config)
0097   {
0098     if (HepMCGen == nullptr)
0099     {
0100       std::cout << "ApplysPHENIXBeamParameter(): Fatal Error - null input pointer HepMCGen" << std::endl;
0101       exit(1);
0102     }
0103     double localbcross = Input::beam_crossing / 2. * 1e-3;
0104     switch (beam_config)
0105     {
0106     case AA_COLLISION:
0107       // heavy ion mode
0108       Input::beam_crossing = 1.;  // +1 mRad for late 2024 with triggered readout for mvtx
0109       localbcross = Input::beam_crossing / 2. * 1e-3;
0110       //  Xing angle is split among both beams, means set to 0.5 mRad
0111       HepMCGen->set_beam_direction_theta_phi(localbcross, 0, M_PI - localbcross, 0);  // 1.5mrad x-ing of sPHENIX
0112       HepMCGen->set_vertex_distribution_width(
0113           100e-4,         // approximation from past STAR/Run16 AuAu data
0114           100e-4,         // approximation from past STAR/Run16 AuAu data
0115           13.5,           // measured 2024 with 1mRad beam Xing
0116           20 / 29.9792);  // 20cm collision length / speed of light in cm/ns
0117 
0118       break;
0119     case pA_COLLISION:
0120 
0121       // pA mode
0122 
0123       // 1.5mRad is split among both beams, means set to 0.75 mRad
0124       HepMCGen->set_beam_direction_theta_phi(localbcross, 0, M_PI - localbcross, 0);  // 1.5mrad x-ing of sPHENIX
0125       HepMCGen->set_vertex_distribution_width(
0126           100e-4,         // set to be similar to AA
0127           100e-4,         // set to be similar to AA
0128           8,              // sPH-TRG-2022-001. Fig B.4
0129           20 / 29.9792);  // 20cm collision length / speed of light in cm/ns
0130 
0131       break;
0132     case pp_COLLISION:
0133 
0134       // pp mode
0135       // 1.5mRad is split among both beams, means set to 0.75 mRad
0136       HepMCGen->set_beam_direction_theta_phi(localbcross, 0, M_PI - localbcross, 0);  // 1.5mrad x-ing of sPHENIX
0137       HepMCGen->set_vertex_distribution_width(
0138           120e-4,         // approximation from past PHENIX data
0139           120e-4,         // approximation from past PHENIX data
0140           16,             // measured in 2024 for 1.5mrad Xing angle
0141           20 / 29.9792);  // 20cm collision length / speed of light in cm/ns
0142 
0143       break;
0144     case pp_ZEROANGLE:
0145 
0146       // pp mode
0147 
0148       HepMCGen->set_vertex_distribution_width(
0149           120e-4,         // approximation from past PHENIX data
0150           120e-4,         // approximation from past PHENIX data
0151           65,             // measured in 2024 for 0 Xing angle
0152           20 / 29.9792);  // 20cm collision length / speed of light in cm/ns
0153 
0154       break;
0155 
0156     case ppg02:
0157       Input::beam_crossing = 1.;  // +1 mRad for late 2024 with triggered readout for mvtx
0158       localbcross = Input::beam_crossing / 2. * 1e-3;
0159       //  Xing angle is split among both beams, means set to 0.5 mRad
0160       HepMCGen->set_beam_direction_theta_phi(localbcross, 0, M_PI - localbcross, 0);  // 1.5mrad x-ing of sPHENIX
0161       HepMCGen->set_vertex_distribution_mean(-0.022,0.223, -4.03, 0.);
0162       HepMCGen->set_vertex_distribution_width(
0163           120e-4,         // approximation from past PHENIX data
0164           120e-4,         // approximation from past PHENIX data
0165           9.358,             // measured by intt
0166           20 / 29.9792);  // 20cm collision length / speed of light in cm/ns
0167       break;
0168       
0169     default:
0170       std::cout << "ApplysPHENIXBeamParameter: invalid beam_config = " << beam_config << std::endl;
0171 
0172       exit(1);
0173     }
0174 
0175     HepMCGen->set_vertex_distribution_function(
0176         PHHepMCGenHelper::Gaus,
0177         PHHepMCGenHelper::Gaus,
0178         PHHepMCGenHelper::Gaus,
0179         PHHepMCGenHelper::Gaus);
0180   }
0181 
0182   //! apply sPHENIX nominal beam parameter according to the beam collision setting of Input::IS_PP_COLLISION
0183   //! \param[in] HepMCGen any HepMC generator, e.g. Fun4AllHepMCInputManager, Fun4AllHepMCPileupInputManager, PHPythia8, PHPythia6, ReadEICFiles
0184   void ApplysPHENIXBeamParameter(PHHepMCGenHelper *HepMCGen)
0185   {
0186     ApplysPHENIXBeamParameter(HepMCGen, Input::BEAM_CONFIGURATION);
0187   }
0188 
0189   //! apply EIC beam parameter to any HepMC generator following EIC CDR,
0190   //! including in-time collision's space time shift, beam crossing angle and angular divergence
0191   //! \param[in] HepMCGen any HepMC generator, e.g. Fun4AllHepMCInputManager, Fun4AllHepMCPileupInputManager, PHPythia8, PHPythia6, ReadEICFiles
0192   void ApplyEICBeamParameter(PHHepMCGenHelper *HepMCGen)
0193   {
0194     if (HepMCGen == nullptr)
0195     {
0196       std::cout << "ApplyEICBeamParameter(): Fatal Error - null input pointer HepMCGen" << std::endl;
0197       exit(1);
0198     }
0199 
0200     // 25mrad x-ing as in EIC CDR
0201     const double EIC_hadron_crossing_angle = 25e-3;
0202 
0203     HepMCGen->set_beam_direction_theta_phi(
0204         EIC_hadron_crossing_angle,  // beamA_theta
0205         0,                          // beamA_phi
0206         M_PI,                       // beamB_theta
0207         0                           // beamB_phi
0208     );
0209     HepMCGen->set_beam_angular_divergence_hv(
0210         119e-6, 119e-6,  // proton beam divergence horizontal & vertical, as in EIC CDR Table 1.1
0211         211e-6, 152e-6   // electron beam divergence horizontal & vertical, as in EIC CDR Table 1.1
0212     );
0213 
0214     // angular kick within a bunch as result of crab cavity
0215     // using an naive assumption of transfer matrix from the cavity to IP,
0216     // which is NOT yet validated with accelerator optics simulations!
0217     const double z_hadron_cavity = 52e2;  // CDR Fig 3.3
0218     const double z_e_cavity = 38e2;       // CDR Fig 3.2
0219     HepMCGen->set_beam_angular_z_coefficient_hv(
0220         -EIC_hadron_crossing_angle / 2. / z_hadron_cavity, 0,
0221         -EIC_hadron_crossing_angle / 2. / z_e_cavity, 0);
0222 
0223     // calculate beam sigma width at IP  as in EIC CDR table 1.1
0224     const double sigma_p_h = sqrt(80 * 11.3e-7);
0225     const double sigma_p_v = sqrt(7.2 * 1.0e-7);
0226     const double sigma_p_l = 6;
0227     const double sigma_e_h = sqrt(45 * 20.0e-7);
0228     const double sigma_e_v = sqrt(5.6 * 1.3e-7);
0229     const double sigma_e_l = 2;
0230 
0231     // combine two beam gives the collision sigma in z
0232     const double collision_sigma_z = sqrt(sigma_p_l * sigma_p_l + sigma_e_l * sigma_e_l) / 2;
0233     const double collision_sigma_t = collision_sigma_z / 29.9792;  // speed of light in cm/ns
0234 
0235     HepMCGen->set_vertex_distribution_width(
0236         sigma_p_h * sigma_e_h / sqrt(sigma_p_h * sigma_p_h + sigma_e_h * sigma_e_h),  // x
0237         sigma_p_v * sigma_e_v / sqrt(sigma_p_v * sigma_p_v + sigma_e_v * sigma_e_v),  // y
0238         collision_sigma_z,                                                            // z
0239         collision_sigma_t);                                                           // t
0240     HepMCGen->set_vertex_distribution_function(
0241         PHHepMCGenHelper::Gaus,   // x
0242         PHHepMCGenHelper::Gaus,   // y
0243         PHHepMCGenHelper::Gaus,   // z
0244         PHHepMCGenHelper::Gaus);  // t
0245   }
0246 }  // namespace Input
0247 
0248 namespace INPUTHEPMC
0249 {
0250   std::string filename;
0251   std::string listfile;
0252   int EmbedId = 0;
0253   bool FLOW = false;
0254   int FLOW_VERBOSITY = 0;
0255   bool FERMIMOTION = false;
0256   bool HIJINGFLIP = false;
0257   bool REACTIONPLANERAND = false;
0258   float HEPMC_STRANGENESS_FRACTION = -1.;
0259 
0260 }  // namespace INPUTHEPMC
0261 
0262 namespace INPUTREADEIC
0263 {
0264   std::string filename;
0265 }  // namespace INPUTREADEIC
0266 
0267 namespace INPUTREADHITS
0268 {
0269   std::map<unsigned int, std::string> filename;
0270   std::map<unsigned int, std::string> listfile;
0271 }  // namespace INPUTREADHITS
0272 
0273 namespace INPUTEMBED
0274 {
0275   std::map<unsigned int, std::string> filename;
0276   std::map<unsigned int, std::string> listfile;
0277   bool REPEAT = true;
0278 }  // namespace INPUTEMBED
0279 
0280 namespace PYTHIA6
0281 {
0282   std::string config_file = std::string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6.cfg";
0283 }
0284 
0285 namespace PYTHIA8
0286 {
0287   std::string config_file = std::string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia8.cfg";
0288 }
0289 
0290 namespace PILEUP
0291 {
0292   std::string pileupfile = "/sphenix/sim/sim01/sphnxpro/MDC1/sHijing_HepMC/data/sHijing_0_20fm-0000000001-00000.dat";
0293   double TpcDriftVelocity = G4TPC::tpc_drift_velocity_sim;
0294 }  // namespace PILEUP
0295 
0296 // collection of pointers to particle generators we can grab in the Fun4All macro
0297 namespace INPUTGENERATOR
0298 {
0299   std::vector<PHG4IonGun *> IonGun;
0300   std::vector<PHG4ParticleGenerator *> ParticleGenerator;
0301   std::vector<PHG4ParticleGeneratorD0 *> DZeroMesonGenerator;
0302   std::vector<PHG4ParticleGeneratorVectorMeson *> VectorMesonGenerator;
0303   std::vector<PHG4SimpleEventGenerator *> SimpleEventGenerator;
0304   std::vector<PHG4ParticleGun *> Gun;
0305   PHPythia8 *Pythia6 = nullptr;
0306   PHPythia8 *Pythia8 = nullptr;
0307   //  ReadEICFiles *EICFileReader = nullptr;
0308   CosmicSpray *Cosmic = nullptr;
0309 }  // namespace INPUTGENERATOR
0310 
0311 namespace INPUTMANAGER
0312 {
0313   Fun4AllHepMCInputManager *HepMCInputManager = nullptr;
0314   Fun4AllHepMCPileupInputManager *HepMCPileupInputManager = nullptr;
0315 }  // namespace INPUTMANAGER
0316 
0317 void InputInit()
0318 {
0319   // for pileup sims embed id is 1, to distinguish particles
0320   // which will be embedded (when Input::EMBED = true) into pileup sims
0321   // we need to start at embedid = 2
0322   if (Input::EMBED)
0323   {
0324     Input::EmbedId = 2;
0325   }
0326   // first consistency checks - not all input generators play nice
0327   // with each other
0328   if (Input::READHITS && Input::EMBED)
0329   {
0330     std::cout << "Reading Hits and Embedding into background at the same time is not supported" << std::endl;
0331     gSystem->Exit(1);
0332   }
0333   if (Input::READHITS && (Input::PYTHIA6 || Input::PYTHIA8 || Input::SIMPLE || Input::GUN || Input::UPSILON || Input::HEPMC))
0334   {
0335     std::cout << "Reading Hits and running G4 simultanously is not supported" << std::endl;
0336     gSystem->Exit(1);
0337   }
0338   if (Input::PYTHIA6 && Input::PYTHIA8)
0339   {
0340     std::cout << "Pythia6 and Pythia8 cannot be run together - might be possible but needs R&D" << std::endl;
0341     gSystem->Exit(1);
0342   }
0343 
0344   if (INPUTHEPMC::FLOW && Input::PILEUPRATE > 0)
0345   {
0346     std::cout << "Flow Afterburner and Pileup cannot be run simultanously" << std::endl;
0347     gSystem->Exit(1);
0348   }
0349   // done with consistency checks, create generators in no specific order
0350 
0351   Fun4AllServer *se = Fun4AllServer::instance();
0352   if (Input::PYTHIA6)
0353   {
0354     std::cout << "Pythia6 not implemented" << std::endl;
0355     gSystem->Exit(1);
0356     // INPUTGENERATOR::Pythia6 = new PHPythia6();
0357     // INPUTGENERATOR::Pythia6->set_config_file(PYTHIA6::config_file);
0358 
0359     // INPUTGENERATOR::Pythia6->set_embedding_id(Input::EmbedId);
0360     // Input::PYTHIA6_EmbedId = Input::EmbedId;
0361     // Input::EmbedId++;
0362   }
0363   if (Input::PYTHIA8)
0364   {
0365     INPUTGENERATOR::Pythia8 = new PHPythia8();
0366     // see coresoftware/generators/PHPythia8 for example config
0367     INPUTGENERATOR::Pythia8->set_config_file(PYTHIA8::config_file);
0368 
0369     INPUTGENERATOR::Pythia8->set_embedding_id(Input::EmbedId);
0370     Input::PYTHIA8_EmbedId = Input::EmbedId;
0371     Input::EmbedId++;
0372     if (Input::EMBED)
0373     {
0374       INPUTGENERATOR::Pythia8->set_reuse_vertex(Input::VertexEmbedId);
0375     }
0376 
0377   }
0378   // single particle generators
0379   if (Input::DZERO)
0380   {
0381     for (int i = 0; i < Input::DZERO_NUMBER; ++i)
0382     {
0383       std::string name = "DZERO_" + std::to_string(i);
0384       PHG4ParticleGeneratorD0 *dzero = new PHG4ParticleGeneratorD0(name);
0385       dzero->Embed(Input::EmbedId);
0386       Input::DZERO_EmbedIds.insert(Input::EmbedId);
0387       Input::EmbedId++;
0388       INPUTGENERATOR::DZeroMesonGenerator.push_back(dzero);
0389     }
0390   }
0391   if (Input::GUN)
0392   {
0393     for (int i = 0; i < Input::GUN_NUMBER; ++i)
0394     {
0395       std::string name = "GUN_" + std::to_string(i);
0396       PHG4ParticleGun *gun = new PHG4ParticleGun(name);
0397       gun->Embed(Input::EmbedId);
0398       Input::GUN_EmbedIds.insert(Input::EmbedId);
0399       Input::EmbedId++;
0400       INPUTGENERATOR::Gun.push_back(gun);
0401     }
0402   }
0403   if (Input::IONGUN)
0404   {
0405     for (int i = 0; i < Input::IONGUN_NUMBER; ++i)
0406     {
0407       std::string name = "IONGUN_" + std::to_string(i);
0408       PHG4IonGun *iongun = new PHG4IonGun(name);
0409       iongun->Embed(Input::EmbedId);
0410       Input::IONGUN_EmbedIds.insert(Input::EmbedId);
0411       Input::EmbedId++;
0412       INPUTGENERATOR::IonGun.push_back(iongun);
0413     }
0414   }
0415   if (Input::PGEN)
0416   {
0417     for (int i = 0; i < Input::PGEN_NUMBER; ++i)
0418     {
0419       std::string name = "PGEN_" + std::to_string(i);
0420       PHG4ParticleGenerator *pgen = new PHG4ParticleGenerator(name);
0421       pgen->Embed(Input::EmbedId);
0422       Input::PGEN_EmbedIds.insert(Input::EmbedId);
0423       Input::EmbedId++;
0424       INPUTGENERATOR::ParticleGenerator.push_back(pgen);
0425     }
0426   }
0427   if (Input::SIMPLE)
0428   {
0429     for (int i = 0; i < Input::SIMPLE_NUMBER; ++i)
0430     {
0431       std::string name = "EVTGENERATOR_" + std::to_string(i);
0432       PHG4SimpleEventGenerator *simple = new PHG4SimpleEventGenerator(name);
0433       simple->Embed(Input::EmbedId);
0434       Input::PGEN_EmbedIds.insert(Input::EmbedId);
0435       Input::EmbedId++;
0436       INPUTGENERATOR::SimpleEventGenerator.push_back(simple);
0437     }
0438   }
0439   if (Input::UPSILON)
0440   {
0441     for (int i = 0; i < Input::UPSILON_NUMBER; ++i)
0442     {
0443       std::string name = "UPSILON_" + std::to_string(i);
0444       PHG4ParticleGeneratorVectorMeson *upsilon = new PHG4ParticleGeneratorVectorMeson(name);
0445       upsilon->Embed(Input::EmbedId);
0446       Input::UPSILON_EmbedIds.insert(Input::EmbedId);
0447       Input::EmbedId++;
0448       INPUTGENERATOR::VectorMesonGenerator.push_back(upsilon);
0449     }
0450   }
0451 
0452   // input managers for which we might need to set options
0453   if (Input::HEPMC)
0454   {
0455     INPUTMANAGER::HepMCInputManager = new Fun4AllHepMCInputManager("HEPMCin");
0456     INPUTMANAGER::HepMCInputManager->set_embedding_id(INPUTHEPMC::EmbedId);
0457   }
0458   if (Input::PILEUPRATE > 0)
0459   {
0460     INPUTMANAGER::HepMCPileupInputManager = new Fun4AllHepMCPileupInputManager("HepMCPileupInput");
0461   }
0462 }
0463 
0464 void InputRegister()
0465 {
0466   Fun4AllServer *se = Fun4AllServer::instance();
0467   // if (Input::PYTHIA6)
0468   // {
0469   //   se->registerSubsystem(INPUTGENERATOR::Pythia6);
0470   // }
0471   if (Input::PYTHIA8)
0472   {
0473     se->registerSubsystem(INPUTGENERATOR::Pythia8);
0474   }
0475   if (Input::DZERO)
0476   {
0477     int verbosity = std::max(Input::DZERO_VERBOSITY, Input::VERBOSITY);
0478     for (size_t icnt = 0; icnt < INPUTGENERATOR::DZeroMesonGenerator.size(); ++icnt)
0479     {
0480       INPUTGENERATOR::DZeroMesonGenerator[icnt]->Verbosity(verbosity);
0481       se->registerSubsystem(INPUTGENERATOR::DZeroMesonGenerator[icnt]);
0482     }
0483   }
0484   if (Input::GUN)
0485   {
0486     int verbosity = std::max(Input::GUN_VERBOSITY, Input::VERBOSITY);
0487     for (size_t icnt = 0; icnt < INPUTGENERATOR::Gun.size(); ++icnt)
0488     {
0489       INPUTGENERATOR::Gun[icnt]->Verbosity(verbosity);
0490       se->registerSubsystem(INPUTGENERATOR::Gun[icnt]);
0491     }
0492   }
0493   if (Input::IONGUN)
0494   {
0495     int verbosity = std::max(Input::IONGUN_VERBOSITY, Input::VERBOSITY);
0496     for (size_t icnt = 0; icnt < INPUTGENERATOR::IonGun.size(); ++icnt)
0497     {
0498       INPUTGENERATOR::IonGun[icnt]->Verbosity(verbosity);
0499       se->registerSubsystem(INPUTGENERATOR::IonGun[icnt]);
0500     }
0501   }
0502   if (Input::PGEN)
0503   {
0504     int verbosity = std::max(Input::PGEN_VERBOSITY, Input::VERBOSITY);
0505     for (size_t icnt = 0; icnt < INPUTGENERATOR::ParticleGenerator.size(); ++icnt)
0506     {
0507       INPUTGENERATOR::ParticleGenerator[icnt]->Verbosity(verbosity);
0508       se->registerSubsystem(INPUTGENERATOR::ParticleGenerator[icnt]);
0509     }
0510   }
0511   if (Input::SIMPLE)
0512   {
0513     int verbosity = std::max(Input::SIMPLE_VERBOSITY, Input::VERBOSITY);
0514     for (size_t icnt = 0; icnt < INPUTGENERATOR::SimpleEventGenerator.size(); ++icnt)
0515     {
0516       INPUTGENERATOR::SimpleEventGenerator[icnt]->Verbosity(verbosity);
0517       se->registerSubsystem(INPUTGENERATOR::SimpleEventGenerator[icnt]);
0518     }
0519   }
0520   if (Input::UPSILON)
0521   {
0522     for (size_t icnt = 0; icnt < INPUTGENERATOR::VectorMesonGenerator.size(); ++icnt)
0523     {
0524       int verbosity = std::max(Input::UPSILON_VERBOSITY, Input::VERBOSITY);
0525       if (Input::HEPMC || Input::SIMPLE)
0526       {
0527         INPUTGENERATOR::VectorMesonGenerator[icnt]->set_reuse_existing_vertex(true);
0528       }
0529       INPUTGENERATOR::VectorMesonGenerator[icnt]->Verbosity(verbosity);
0530       se->registerSubsystem(INPUTGENERATOR::VectorMesonGenerator[icnt]);
0531     }
0532   }
0533   if (Input::READEIC)
0534   {
0535     std::cout << "Eic File Reading disabled" << std::endl;
0536     gSystem->Exit(1);
0537     // INPUTGENERATOR::EICFileReader = new ReadEICFiles();
0538     // INPUTGENERATOR::EICFileReader->OpenInputFile(INPUTREADEIC::filename);
0539     // INPUTGENERATOR::EICFileReader->Verbosity(Input::VERBOSITY);
0540     // se->registerSubsystem(INPUTGENERATOR::EICFileReader);
0541   }
0542   if (Input::COSMIC)
0543   {
0544     INPUTGENERATOR::Cosmic = new CosmicSpray("COSMIC", Input::COSMIC_R);
0545     se->registerSubsystem(INPUTGENERATOR::Cosmic);
0546   }
0547   // here are the various utility modules which read particles and
0548   // put them onto the G4 particle stack
0549   if (Input::HEPMC || Input::PYTHIA8 || Input::PYTHIA6 || Input::READEIC)
0550   {
0551     if (Input::HEPMC)
0552     {
0553       if (INPUTHEPMC::REACTIONPLANERAND)
0554       {
0555         ReactionPlaneAfterburner *rp = new ReactionPlaneAfterburner();
0556         se->registerSubsystem(rp);
0557       }
0558 
0559       if (INPUTHEPMC::HIJINGFLIP)
0560       {
0561         HIJINGFlipAfterburner *flip = new HIJINGFlipAfterburner();
0562         se->registerSubsystem(flip);
0563       }
0564       // these need to be applied before the HepMCNodeReader since they
0565       // work on the hepmc records
0566       if (INPUTHEPMC::FLOW)
0567       {
0568         HepMCFlowAfterBurner *burn = new HepMCFlowAfterBurner();
0569         burn->Verbosity(INPUTHEPMC::FLOW_VERBOSITY);
0570         se->registerSubsystem(burn);
0571       }
0572       if (INPUTHEPMC::FERMIMOTION)
0573       {
0574         FermimotionAfterburner *fermi = new FermimotionAfterburner();
0575         se->registerSubsystem(fermi);
0576       }
0577     }
0578     // copy HepMC records into G4
0579     HepMCNodeReader *hr = new HepMCNodeReader();
0580     if (INPUTHEPMC::HEPMC_STRANGENESS_FRACTION >= 0)
0581     {
0582       hr->AddStrangeness(INPUTHEPMC::HEPMC_STRANGENESS_FRACTION);
0583     }
0584     se->registerSubsystem(hr);
0585   }
0586 }
0587 
0588 void InputManagers()
0589 {
0590   Fun4AllServer *se = Fun4AllServer::instance();
0591   if (Input::EMBED)
0592   {
0593     gSystem->Load("libg4dst.so");
0594     if (!INPUTEMBED::filename.empty() && !INPUTEMBED::listfile.empty())
0595     {
0596       std::cout << "only filenames or filelists are supported, not mixtures" << std::endl;
0597       gSystem->Exit(1);
0598     }
0599     if (INPUTEMBED::filename.empty() && INPUTEMBED::listfile.empty())
0600     {
0601       std::cout << "you need to give an input filenames or filelist" << std::endl;
0602       gSystem->Exit(1);
0603     }
0604     for (auto iter = INPUTEMBED::filename.begin(); iter != INPUTEMBED::filename.end(); ++iter)
0605     {
0606       std::string mgrname = "DSTin" + std::to_string(iter->first);
0607       Fun4AllInputManager *hitsin = new Fun4AllDstInputManager(mgrname);
0608       hitsin->fileopen(iter->second);
0609       hitsin->Verbosity(Input::VERBOSITY);
0610       if (INPUTEMBED::REPEAT)
0611       {
0612         hitsin->Repeat();
0613       }
0614       se->registerInputManager(hitsin);
0615     }
0616     for (auto iter = INPUTEMBED::listfile.begin(); iter != INPUTEMBED::listfile.end(); ++iter)
0617     {
0618       std::string mgrname = "DSTin" + std::to_string(iter->first);
0619       Fun4AllInputManager *hitsin = new Fun4AllDstInputManager(mgrname);
0620       hitsin->AddListFile(iter->second);
0621       hitsin->Verbosity(Input::VERBOSITY);
0622       if (INPUTEMBED::REPEAT)
0623       {
0624         hitsin->Repeat();
0625       }
0626       se->registerInputManager(hitsin);
0627     }
0628   }
0629   if (Input::HEPMC)
0630   {
0631     INPUTMANAGER::HepMCInputManager->Verbosity(Input::VERBOSITY);
0632     se->registerInputManager(INPUTMANAGER::HepMCInputManager);
0633     if (!INPUTHEPMC::filename.empty() && INPUTHEPMC::listfile.empty())
0634     {
0635       INPUTMANAGER::HepMCInputManager->fileopen(INPUTHEPMC::filename);
0636     }
0637     else if (!INPUTHEPMC::listfile.empty())
0638     {
0639       INPUTMANAGER::HepMCInputManager->AddListFile(INPUTHEPMC::listfile);
0640     }
0641     else
0642     {
0643       std::cout << "no filename INPUTHEPMC::filename or listfile INPUTHEPMC::listfile given" << std::endl;
0644       gSystem->Exit(1);
0645     }
0646   }
0647   else if (Input::READHITS)
0648   {
0649     gSystem->Load("libg4dst.so");
0650     if (!INPUTREADHITS::filename.empty() && !INPUTREADHITS::listfile.empty())
0651     {
0652       std::cout << "only filenames or filelists are supported, not mixtures" << std::endl;
0653       gSystem->Exit(1);
0654     }
0655     if (INPUTREADHITS::filename.empty() && INPUTREADHITS::listfile.empty())
0656     {
0657       std::cout << "you need to give an input filenames or filelist" << std::endl;
0658       gSystem->Exit(1);
0659     }
0660     for (auto iter = INPUTREADHITS::filename.begin(); iter != INPUTREADHITS::filename.end(); ++iter)
0661     {
0662       std::string mgrname = "DSTin" + std::to_string(iter->first);
0663       Fun4AllInputManager *hitsin = new Fun4AllDstInputManager(mgrname);
0664       hitsin->fileopen(iter->second);
0665       hitsin->Verbosity(Input::VERBOSITY);
0666       se->registerInputManager(hitsin);
0667     }
0668     for (auto iter = INPUTREADHITS::listfile.begin(); iter != INPUTREADHITS::listfile.end(); ++iter)
0669     {
0670       std::string mgrname = "DSTin" + std::to_string(iter->first);
0671       Fun4AllInputManager *hitsin = new Fun4AllDstInputManager(mgrname);
0672       hitsin->AddListFile(iter->second);
0673       hitsin->Verbosity(Input::VERBOSITY);
0674       se->registerInputManager(hitsin);
0675     }
0676   }
0677   else
0678   {
0679     Fun4AllInputManager *in = new Fun4AllDummyInputManager("JADE");
0680     in->Verbosity(Input::VERBOSITY);
0681     se->registerInputManager(in);
0682   }
0683   if (Input::PILEUPRATE > 0)
0684   {
0685     INPUTMANAGER::HepMCPileupInputManager->SignalInputManager(INPUTMANAGER::HepMCInputManager);
0686     INPUTMANAGER::HepMCPileupInputManager->Verbosity(Input::VERBOSITY);
0687     INPUTMANAGER::HepMCPileupInputManager->AddFile(PILEUP::pileupfile);
0688     INPUTMANAGER::HepMCPileupInputManager->set_collision_rate(Input::PILEUPRATE);
0689     double time_window = 105.5 / PILEUP::TpcDriftVelocity;
0690     double extended_readout_time = 0.0;
0691     if (TRACKING::pp_mode) extended_readout_time = TRACKING::pp_extended_readout_time;
0692     INPUTMANAGER::HepMCPileupInputManager->set_time_window(-time_window, time_window + extended_readout_time);
0693     std::cout << "Pileup window is from " << -time_window << " to " << time_window + extended_readout_time << std::endl;
0694     se->registerInputManager(INPUTMANAGER::HepMCPileupInputManager);
0695   }
0696 }
0697 #endif