From 5a1079bcb78f0f3deedf65175a2c7cdb7d91c018 Mon Sep 17 00:00:00 2001 From: mbroz84 Date: Fri, 6 Dec 2024 13:51:21 +0100 Subject: [PATCH] Enable DPMJET (#1832) --- .../external/generator/GeneratorStarlight.C | 28 ++++++++++++-- MC/config/PWGUD/ini/makeStarlightConfig.py | 38 ++++++++++--------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/MC/config/PWGUD/external/generator/GeneratorStarlight.C b/MC/config/PWGUD/external/generator/GeneratorStarlight.C index 132e57444..88535ffa1 100644 --- a/MC/config/PWGUD/external/generator/GeneratorStarlight.C +++ b/MC/config/PWGUD/external/generator/GeneratorStarlight.C @@ -1,5 +1,5 @@ -//R__LOAD_LIBRARY(libDPMJET.so) -//R__LOAD_LIBRARY(libDpmJetLib.so) +R__LOAD_LIBRARY(libDPMJET.so) +R__LOAD_LIBRARY(libDpmJetLib.so) R__LOAD_LIBRARY(libStarlib.so) R__ADD_INCLUDE_PATH($STARlight_ROOT/include) @@ -104,7 +104,7 @@ class GeneratorStarlight_class : public Generator {"kIncohPsi2sToElPi", 4, 444011, 20, -1.0, -1.0, 100443, 1 }, // {"kIncohUpsilonToMu", 4, 553013, 20, -1.0, -1.0, 553, 0 }, // {"kIncohUpsilonToEl", 4, 553011, 20, -1.0, -1.0, 553, 0 }, // -// {"kDpmjetSingle", 5, 113, 20, -1.0, -1.0, -1, 0 }, // + {"kDpmjetSingle", 5, 113, 20, -1.0, -1.0, -1, 0 }, // {"kTauLowToEl3Pi", 1, 15, 990, 3.5, 20.0, -1, 1 }, // from 0.4 to 15 GeV {"kTauLowToPo3Pi", 1, 15, 990, 3.5, 20.0, -1, 1 }, // from 0.4 to 15 GeV {"kTauLowToElMu", 1, 15, 990, 3.5, 20.0, -1, 1 }, // from 0.4 to 15 GeV @@ -312,8 +312,28 @@ class GeneratorStarlight_class : public Generator FairGenerator* - GeneratorStarlight(std::string configuration = "empty",float energyCM = 5020, int beam1Z = 82, int beam1A = 208, int beam2Z = 82, int beam2A = 208, std::string extrapars = "") + GeneratorStarlight(std::string configuration = "empty",float energyCM = 5020, int beam1Z = 82, int beam1A = 208, int beam2Z = 82, int beam2A = 208, std::string extrapars = "",std::string dpmjetconf = "") { + if(dpmjetconf.size() != 0){ + //Copy necesary files to the working directory + TString pathDPMJET = gSystem->ExpandPathName("$DPMJET_ROOT/dpmdata"); + system(TString::Format("cp -r %s .",pathDPMJET.Data())); + system(TString::Format("cp %s ./my.input",dpmjetconf.c_str())); + + //Reset four seeds of the DPMJET random generator in the config + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> dist(1, 168); + + std::string command = "awk -i inplace -v nums=\""; + for (int i = 0; i < 4; ++i)command += TString::Format("%d.0 ", dist(gen)); + command +=" \" \' "; + command += "BEGIN {split(nums, newvals);}"; + command += "{if ($1 == \"RNDMINIT\") {printf \"%-16s%-9s%-9s%-9s%-9s\\n\", $1, newvals[1], newvals[2], newvals[3], newvals[4];}"; + command += " else {print $0;}}\' \"my.input\" "; + system(command.c_str()); + } + auto gen = new o2::eventgen::GeneratorStarlight_class(); gen->selectConfiguration(configuration); gen->setCollisionSystem(energyCM, beam1Z, beam1A, beam2Z, beam2A); diff --git a/MC/config/PWGUD/ini/makeStarlightConfig.py b/MC/config/PWGUD/ini/makeStarlightConfig.py index 2cc92456f..7d941e463 100755 --- a/MC/config/PWGUD/ini/makeStarlightConfig.py +++ b/MC/config/PWGUD/ini/makeStarlightConfig.py @@ -27,6 +27,9 @@ parser.add_argument('--extraPars', default='', help='Extra parameters for SL config') +parser.add_argument('--dpmjetConf', default='', + help='DPMJET config file') + args = parser.parse_args() @@ -76,25 +79,26 @@ fout.write('funcName = GeneratorStarlightToEvtGen("%s", %f, %d, %d, %d, %d, "%s") \n' % (args.process,args.eCM ,pZ,pA,tZ,tA,args.extraPars)) else: fout.write('fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGUD/external/generator/GeneratorStarlight.C \n') - fout.write('funcName = GeneratorStarlight("%s", %f, %d, %d, %d, %d, "%s") \n' % (args.process,args.eCM ,pZ,pA,tZ,tA,args.extraPars)) + fout.write('funcName = GeneratorStarlight("%s", %f, %d, %d, %d, %d, "%s", "%s") \n' % (args.process,args.eCM ,pZ,pA,tZ,tA,args.extraPars,args.dpmjetConf)) ###Trigger -fout.write('[TriggerExternal] \n') -fout.write('fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGUD/trigger/selectParticlesInAcceptance.C \n') -if 'kTwoGamma' in args.process or 'kTau' in args.process: - if args.rapidity == 'cent_eta': - fout.write('funcName = selectDirectPartInAcc(-0.9,0.9) \n') - if args.rapidity == 'muon_eta': - fout.write('funcName = selectDirectPartInAcc(-4.0,-2.5) \n') -else: - if args.rapidity == 'cent_rap': - fout.write('funcName = selectMotherPartInAcc(-0.9,0.9) \n') - if args.rapidity == 'muon_rap': - fout.write('funcName = selectMotherPartInAcc(-4.0,-2.5) \n') - if args.rapidity == 'cent_eta': - fout.write('funcName = selectDaughterPartInAcc(-0.9,0.9) \n') - if args.rapidity == 'muon_eta': - fout.write('funcName = selectDaughterPartInAcc(-4.0,-2.5) \n') +if not 'kDpmjet' in args.process: + fout.write('[TriggerExternal] \n') + fout.write('fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGUD/trigger/selectParticlesInAcceptance.C \n') + if 'kTwoGamma' in args.process or 'kTau' in args.process: + if args.rapidity == 'cent_eta': + fout.write('funcName = selectDirectPartInAcc(-0.9,0.9) \n') + if args.rapidity == 'muon_eta': + fout.write('funcName = selectDirectPartInAcc(-4.0,-2.5) \n') + else: + if args.rapidity == 'cent_rap': + fout.write('funcName = selectMotherPartInAcc(-0.9,0.9) \n') + if args.rapidity == 'muon_rap': + fout.write('funcName = selectMotherPartInAcc(-4.0,-2.5) \n') + if args.rapidity == 'cent_eta': + fout.write('funcName = selectDaughterPartInAcc(-0.9,0.9) \n') + if args.rapidity == 'muon_eta': + fout.write('funcName = selectDaughterPartInAcc(-4.0,-2.5) \n') ### close outout file fout.close()