File indexing completed on 2025-08-03 08:12:25
0001
0002 int Fun4All_MCEventGen(
0003 const int nEvents = 100,
0004 const char * outputFile = "G4MCEventGen.root"
0005 )
0006 {
0007
0008
0009
0010
0011
0012 const bool readhepmc = false;
0013
0014
0015 const bool readeictree = false;
0016
0017
0018 const bool runpythia8 = false;
0019
0020
0021 const bool runpythia6 = true;
0022 const char * pythia6configfile = "config_pythia6/phpythia6_ep.cfg";
0023
0024
0025 const bool runhepgen = false;
0026
0027
0028 const bool runsartre = false;
0029
0030
0031 const bool do_dst_compress = true;
0032
0033
0034 const bool do_DSTOutput = true;
0035
0036
0037 const bool do_DSTReader = false;
0038
0039
0040 const bool do_ASCIIOutput = false;
0041
0042
0043
0044
0045
0046 gSystem->Load("libfun4all.so");
0047 gSystem->Load("libphhepmc.so");
0048 gSystem->Load("libg4detectors.so");
0049 gSystem->Load("libg4eval.so");
0050
0051
0052
0053
0054 Fun4AllServer *se = Fun4AllServer::instance();
0055 se->Verbosity(0);
0056
0057
0058
0059 recoConsts *rc = recoConsts::instance();
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 rc->set_FloatFlag("WorldSizex", 1000.);
0072 rc->set_FloatFlag("WorldSizey", 1000.);
0073 rc->set_FloatFlag("WorldSizez", 1000.);
0074 rc->set_CharFlag("WorldShape", "G4Tubs");
0075
0076
0077
0078
0079
0080
0081 if (readhepmc)
0082 {
0083 }
0084 else if (readeictree)
0085 {
0086
0087 ReadEICFiles *eicr = new ReadEICFiles();
0088 eicr->OpenInputFile("data/eictree_milou_dvcs_10x250.root");
0089
0090 se->registerSubsystem(eicr);
0091 }
0092 else if (runpythia8)
0093 {
0094 gSystem->Load("libPHPythia8.so");
0095
0096 PHPythia8* pythia8 = new PHPythia8();
0097
0098 pythia8->set_config_file("phpythia8.cfg");
0099 se->registerSubsystem(pythia8);
0100 }
0101 else if (runpythia6)
0102 {
0103 gSystem->Load("libPHPythia6.so");
0104
0105 PHPythia6 *pythia6 = new PHPythia6();
0106 pythia6->set_config_file( pythia6configfile );
0107 se->registerSubsystem(pythia6);
0108 }
0109 else if (runhepgen)
0110 {
0111 gSystem->Load("libsHEPGen.so");
0112
0113 sHEPGen *hepgen = new sHEPGen();
0114 hepgen->set_datacard_file("config/hepgen_eic_dvcs.data");
0115 hepgen->set_momentum_electron(-10);
0116 hepgen->set_momentum_hadron(250);
0117 se->registerSubsystem(hepgen);
0118 }
0119 else if (runsartre)
0120 {
0121
0122
0123
0124 gSystem->Load("libPHSartre.so");
0125
0126 PHSartre* mysartre = new PHSartre();
0127
0128 mysartre->set_config_file("config/sartre_ep.cfg");
0129
0130
0131
0132
0133
0134
0135
0136
0137 se->registerSubsystem(mysartre);
0138 }
0139
0140
0141 if ( do_DSTOutput )
0142 {
0143 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outputFile);
0144 se->registerOutputManager(out);
0145 }
0146
0147
0148 if (do_DSTReader)
0149 {
0150
0151 HepMCNodeReader *hr = new HepMCNodeReader();
0152 se->registerSubsystem(hr);
0153
0154
0155 PHG4Reco* g4Reco = new PHG4Reco();
0156 PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
0157 g4Reco->registerSubsystem(truth);
0158 se->registerSubsystem( g4Reco );
0159
0160
0161 PHG4DSTReader* ana = new PHG4DSTReader(string(outputFile) + string("_DSTReader.root"));
0162 ana->set_save_particle(true);
0163 ana->set_load_all_particle(false);
0164 ana->set_load_active_particle(true);
0165 ana->set_save_vertex(true);
0166
0167 se->registerSubsystem(ana);
0168 }
0169
0170
0171 else if ( do_ASCIIOutput )
0172 {
0173 Fun4AllHepMCOutputManager *asciiout = new Fun4AllHepMCOutputManager("HEPMCOUT",outputFile);
0174 se->registerOutputManager(asciiout);
0175 }
0176
0177
0178
0179
0180 if (nEvents <= 0 && !readhepmc)
0181 {
0182 cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0183 cout << "it will run forever, so I just return without running anything" << endl;
0184 return;
0185 }
0186 else
0187 {
0188 se->run(nEvents);
0189
0190 se->End();
0191 std::cout << "All done" << std::endl;
0192 delete se;
0193 gSystem->Exit(0);
0194 }
0195
0196 }
0197
0198
0199 void
0200 G4Cmd(const char * cmd)
0201 {
0202 Fun4AllServer *se = Fun4AllServer::instance();
0203 PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
0204 g4->ApplyCommand(cmd);
0205 }