Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:24:01

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