112 LOG(warning) <<
"No primary generator instance; Cannot setup";
118 auto makeBoxGen = [](
int pdgid,
int mult,
double etamin,
double etamax,
double pmin,
double pmax,
double phimin,
double phimax) {
122#ifdef GENERATORS_WITH_PYTHIA8
123 auto makePythia8Gen = [](std::string& config) {
126 .
config = config.size() > 0 ? config : singleton.config,
127 .hooksFileName = singleton.hooksFileName,
128 .hooksFuncName = singleton.hooksFuncName,
129 .includePartonEvent = singleton.includePartonEvent,
130 .particleFilter = singleton.particleFilter,
131 .verbose = singleton.verbose,
134 if (!config.empty()) {
135 LOG(info) <<
"Setting \'Pythia8\' base configuration: " << config << std::endl;
136 gen->setConfig(config);
149 LOG(fatal) <<
"Monopoles were registered in TDatabasePDG with a mass other than G4.monopoleMass = " << monopoleMass <<
" GeV";
152#if defined(GENERATORS_WITH_PYTHIA8) && defined(GENERATORS_WITH_HEPMC3)
153 std::string hyperloopExtHybridConfigFile;
154 if (genconfig.compare(
"external") == 0 || genconfig.compare(
"extgen") == 0) {
156 LOG(info) <<
"Switching external generator to hybrid mode";
157 genconfig =
"hybrid";
162 LOG(info) <<
"IS_HYPERLOOP detected: expanding external generator into "
165 genconfig =
"hybrid";
169 LOG(info) <<
"** Generator to use: '" << genconfig <<
"'";
170 if (genconfig.compare(
"boxgen") == 0) {
173 LOG(info) <<
"Init generic box generator with following parameters";
174 LOG(info) << boxparam;
175 auto boxGen = makeBoxGen(boxparam.pdg, boxparam.number, boxparam.eta[0], boxparam.eta[1], boxparam.prange[0], boxparam.prange[1], boxparam.phirange[0], boxparam.phirange[1]);
177 }
else if (genconfig.compare(
"fwmugen") == 0) {
179 LOG(info) <<
"Init box forward muons generator";
180 auto boxGen = makeBoxGen(13, 1, -4, -2.5, 50., 50., 0., 360);
182 }
else if (genconfig.compare(
"hmpidgun") == 0) {
184 LOG(info) <<
"Init hmpid gun generator";
185 auto boxGen = makeBoxGen(-211, 100, -0.5, -0.5, 2, 5, -5, 60);
187 }
else if (genconfig.compare(
"fwpigen") == 0) {
189 LOG(info) <<
"Init box forward pions generator";
190 auto boxGen = makeBoxGen(-211, 10, -4, -2.5, 7, 7, 0, 360);
192 }
else if (genconfig.compare(
"fwrootino") == 0) {
194 LOG(info) <<
"Init box forward rootinos generator";
195 auto boxGen = makeBoxGen(0, 1, -4, -2.5, 1, 5, 0, 360);
197 }
else if (genconfig.compare(
"zdcgen") == 0) {
199 LOG(info) <<
"Init box forward/backward zdc generator";
200 auto boxGenC = makeBoxGen(2112 , 1, -8, -9999, 500, 1000, 0., 360.);
201 auto boxGenA = makeBoxGen(2112 , 1, 8, 9999, 500, 1000, 0., 360.);
204 }
else if (genconfig.compare(
"emcgenele") == 0) {
206 LOG(info) <<
"Init box generator for electrons in EMCAL";
208 auto elecgen = makeBoxGen(11, 1, -0.67, 0.67, 15, 15, 80, 187);
210 }
else if (genconfig.compare(
"emcgenphoton") == 0) {
211 LOG(info) <<
"Init box generator for photons in EMCAL";
212 auto photongen = makeBoxGen(22, 1, -0.67, 0.67, 15, 15, 80, 187);
214 }
else if (genconfig.compare(
"fddgen") == 0) {
215 LOG(info) <<
"Init box FDD generator";
216 auto boxGenFDC = makeBoxGen(13, 1000, -7, -4.8, 10, 500, 0, 360.);
217 auto boxGenFDA = makeBoxGen(13, 1000, 4.9, 6.3, 10, 500, 0., 360);
220 }
else if (genconfig.compare(
"extkin") == 0) {
227 LOG(info) <<
"using external kinematics";
228 }
else if (genconfig.compare(
"extkinO2") == 0) {
231 auto name1 = singleton.fileName;
235 .continueMode = singleton.continueMode,
236 .roundRobin = singleton.roundRobin,
237 .randomize = singleton.randomize,
238 .rngseed = singleton.rngseed,
239 .randomphi = singleton.randomphi,
240 .fileName = name1.size() > 0 ? name1.c_str() : name2.c_str()};
244 if (pars.continueMode) {
250 LOG(info) <<
"using external O2 kinematics";
251 }
else if (genconfig.compare(
"evtpool") == 0) {
257 LOG(info) <<
"using the eventpool generator";
258 }
else if (genconfig.compare(
"tparticle") == 0) {
263 LOG(info) <<
"Init 'GeneratorTParticle' with the following parameters";
267 tgen->setup(param0,
param, conf);
269#ifdef GENERATORS_WITH_HEPMC3
270 }
else if (genconfig.compare(
"hepmc") == 0) {
275 LOG(info) <<
"Init \'GeneratorHepMC\' with following parameters";
279 hepmcGen->setup(param0,
param, conf);
282#ifdef GENERATORS_WITH_PYTHIA8
283 }
else if (genconfig.compare(
"alldets") == 0) {
288 auto py8config = std::string(std::getenv(
"O2_ROOT")) +
"/share/Generators/egconfig/pythia8_inel.cfg";
289 auto py8 = makePythia8Gen(py8config);
292 auto muon = makeBoxGen(13, 100, -2.5, -4.0, 100, 100, 0., 360);
294 }
else if (genconfig.compare(
"pythia8") == 0) {
295 auto py8config = std::string();
296 auto py8 = makePythia8Gen(py8config);
298 }
else if (genconfig.compare(
"pythia8pp") == 0) {
299 auto py8config = std::string(std::getenv(
"O2_ROOT")) +
"/share/Generators/egconfig/pythia8_inel.cfg";
300 auto py8 = makePythia8Gen(py8config);
302 }
else if (genconfig.compare(
"pythia8hf") == 0) {
305 auto py8config = std::string(std::getenv(
"O2_ROOT")) +
"/share/Generators/egconfig/pythia8_hf.cfg";
306 auto py8 = makePythia8Gen(py8config);
308 }
else if (genconfig.compare(
"pythia8hi") == 0) {
312 auto py8config = std::string(std::getenv(
"O2_ROOT")) +
"/share/Generators/egconfig/pythia8_hi.cfg";
313 auto py8 = makePythia8Gen(py8config);
315 }
else if (genconfig.compare(
"pythia8powheg") == 0) {
317 auto py8config = std::string(std::getenv(
"O2_ROOT")) +
"/share/Generators/egconfig/pythia8_powheg.cfg";
318 auto py8 = makePythia8Gen(py8config);
321 }
else if (genconfig.compare(
"external") == 0 || genconfig.compare(
"extgen") == 0) {
324 LOG(info) <<
"Setting up external generator with following parameters";
326 auto extgen_filename =
params.fileName;
327 auto extgen_func =
params.funcName;
328 auto extgen = o2::conf::GetFromMacro<FairGenerator*>(extgen_filename, extgen_func,
"FairGenerator*",
"extgen");
330 LOG(fatal) <<
"Failed to retrieve \'extgen\': problem with configuration ";
333 }
else if (genconfig.compare(
"toftest") == 0) {
334 LOG(info) <<
"Init tof test generator -> 1 muon per sector and per module";
335 for (
int i = 0;
i < 18;
i++) {
336 for (
int j = 0;
j < 5;
j++) {
337 auto boxGen = makeBoxGen(13 , 1, -0.8 + 0.32 *
j + 0.15, -0.8 + 0.32 *
j + 0.17, 9, 10, 10 + 20. *
i - 1, 10 + 20. *
i + 1);
341#if defined(GENERATORS_WITH_PYTHIA8) && defined(GENERATORS_WITH_HEPMC3)
342 }
else if (genconfig.compare(
"hybrid") == 0) {
343 LOG(info) <<
"Init hybrid generator";
346 if (config.empty()) {
347 LOG(fatal) <<
"No configuration file provided for hybrid generator";
354 LOG(fatal) <<
"Invalid generator";
363 if (!(genconfig.compare(
"hybrid") == 0)) {
365 if (trgconfig.empty()) {
367 }
else if (trgconfig.compare(
"particle") == 0) {
369 }
else if (trgconfig.compare(
"external") == 0) {
372 LOG(info) <<
"Setting up external trigger with following parameters";
374 auto external_trigger_filename =
params.fileName;
375 auto external_trigger_func =
params.funcName;
376 trigger = o2::conf::GetFromMacro<o2::eventgen::Trigger>(external_trigger_filename, external_trigger_func,
"o2::eventgen::Trigger",
"trigger");
378 LOG(info) <<
"Trying to retrieve a \'o2::eventgen::DeepTrigger\' type" << std::endl;
379 deeptrigger = o2::conf::GetFromMacro<o2::eventgen::DeepTrigger>(external_trigger_filename, external_trigger_func,
"o2::eventgen::DeepTrigger",
"deeptrigger");
381 if (!trigger && !deeptrigger) {
382 LOG(fatal) <<
"Failed to retrieve \'external trigger\': problem with configuration ";
385 LOG(fatal) <<
"Invalid trigger";
390 for (
int igen = 0; igen < generators->GetEntries(); ++igen) {
393 LOG(fatal) <<
"request to add a trigger to an unsupported generator";
398 generator->addTrigger(trigger);
401 generator->addDeepTrigger(deeptrigger);