diff --git a/MC/config/examples/epos4/generator/examplepbpb.optns b/MC/config/examples/epos4/generator/examplepbpb.optns new file mode 100644 index 000000000..217b2db77 --- /dev/null +++ b/MC/config/examples/epos4/generator/examplepbpb.optns @@ -0,0 +1,32 @@ +!-------------------------------------------------------------------- +! Lead-Lead collision with hydro and hadronic cascade +!-------------------------------------------------------------------- + +!--------------------------------------- +! Define run +!--------------------------------------- + +application hadron !hadron-hadron, hadron-nucleus, or nucleus-nucleus +set laproj 82 !projectile atomic number +set maproj 208 !projectile mass number +set latarg 82 !target atomic number +set matarg 208 !target mass number +set ecms 5360 !sqrt(s)_pp +set istmax 25 !max status considered for storage + +ftime on !string formation time non-zero +!suppressed decays: +nodecays + 110 20 2130 -2130 2230 -2230 1130 -1130 1330 -1330 2330 -2330 3331 -3331 +end + +set ninicon 1 !number of initial conditions used for hydro evolution +core full !core/corona activated +hydro hlle !hydro activated +eos x3ff !eos activated (epos standard EoS) +hacas full !hadronic cascade activated (UrQMD) +set nfreeze 1 !number of freeze out events per hydro event +set modsho 1 !printout every modsho events +set centrality 0 !0=min bias +set ihepmc 2 !HepMC output enabled on stdout +set nfull 10 \ No newline at end of file diff --git a/MC/config/examples/ini/GeneratorEPOS4PbPb.ini b/MC/config/examples/ini/GeneratorEPOS4PbPb.ini new file mode 100644 index 000000000..6732c459c --- /dev/null +++ b/MC/config/examples/ini/GeneratorEPOS4PbPb.ini @@ -0,0 +1,12 @@ +#NEV_TEST> 1 +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/generator_EPOS4.C +funcName=generateEPOS4("${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/generator/examplepbpb.optns", 2147483647) + +[GeneratorFileOrCmd] +cmd=${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/epos.sh +bMaxSwitch=none + +# Set to version 2 if EPOS4.0.0 is used +[HepMC] +version=3 diff --git a/MC/config/examples/ini/tests/GeneratorEPOS4PbPb.C b/MC/config/examples/ini/tests/GeneratorEPOS4PbPb.C new file mode 100644 index 000000000..3cc43d99c --- /dev/null +++ b/MC/config/examples/ini/tests/GeneratorEPOS4PbPb.C @@ -0,0 +1,60 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + // Check that file exists, can be opened and has the correct tree + TFile file(path.c_str(), "READ"); + if (file.IsZombie()) + { + std::cerr << "Cannot open ROOT file " << path << "\n"; + return 1; + } + auto tree = (TTree *)file.Get("o2sim"); + if (!tree) + { + std::cerr << "Cannot find tree o2sim in file " << path << "\n"; + return 1; + } + std::vector *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + // Check if all events are filled + auto nEvents = tree->GetEntries(); + for (Long64_t i = 0; i < nEvents; ++i) + { + tree->GetEntry(i); + if (tracks->empty()) + { + std::cerr << "Empty entry found at event " << i << "\n"; + return 1; + } + } + // Check if there is 1 event, as customly set in the ini file + // Lead-Lead collisions with hydro and hadronic cascade are very slow to simulate + if (nEvents != 1) + { + std::cerr << "Expected 1 event, got " << nEvents << "\n"; + return 1; + } + // check if each event has two lead ions with 557440 (208*5360) GeV of energy + for (int i = 0; i < nEvents; i++) + { + auto check = tree->GetEntry(i); + int count = 0; + for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack) + { + auto track = tracks->at(idxMCTrack); + double energy = track.GetEnergy(); + // Check if lead ion track energy is approximately equal to 557440 GeV (a tolerance of 50 MeV is considered, straight equality does not work due to floating point precision) + if (std::abs(energy - 557440) < 5e-2 && track.GetPdgCode() == 1000822080) + { + count++; + } + } + if (count < 2) + { + std::cerr << "Event " << i << " has less than 2 lead ions at 557440 GeV\n"; + return 1; + } + } + return 0; +} \ No newline at end of file diff --git a/test/run_generator_tests.sh b/test/run_generator_tests.sh index c977f49c1..1fd510158 100755 --- a/test/run_generator_tests.sh +++ b/test/run_generator_tests.sh @@ -76,6 +76,16 @@ get_test_script_path_for_ini() echo ${path_to_test_script} } +get_nevents_from_ini() +{ + # function to force the number of events to be simulated from the ini file (default = 100) + # Syntax: #NEV_TEST> 10 (space between #NEV_TEST> and the number is mandatory) + # To be used only if external generator takes too long to run causing timeouts in CI + local ini_path=${1} + local nev=$(grep "#NEV_TEST>" ${ini_path} | tail -n 1 | awk '{print $2}' | tr -d ' ') + [[ "${nev}" == "" ]] && nev=100 + echo ${nev} +} exec_test() { @@ -89,12 +99,14 @@ exec_test() local RET=0 # this is how our test script is expected to be called local test_script=$(get_test_script_path_for_ini ${ini_path}) + # get the number of events to be simulated from the ini file + local nev=$(get_nevents_from_ini ${ini_path}) # prepare the header of the log files echo "### Testing ${ini_path} with generator ${generator} ###" > ${LOG_FILE_KINE} echo "### Testing ${ini_path} with generator ${generator} ###" > ${LOG_FILE_GENERIC_KINE} echo "### Testing ${ini_path} with generator ${generator} ###" > ${LOG_FILE_SIM} # run the simulation, fail if not successful - o2-sim -g ${generator_lower} ${trigger} --noGeant -n 100 -j 4 --configFile ${ini_path} --configKeyValues "GeneratorPythia8.includePartonEvent=true" >> ${LOG_FILE_SIM} 2>&1 + o2-sim -g ${generator_lower} ${trigger} --noGeant -n ${nev} -j 4 --configFile ${ini_path} --configKeyValues "GeneratorPythia8.includePartonEvent=true" >> ${LOG_FILE_SIM} 2>&1 RET=${?} [[ "${RET}" != "0" ]] && { remove_artifacts ; return ${RET} ; }