From be8475be20a94b8593f7e32cb053ab5c3b012557 Mon Sep 17 00:00:00 2001 From: Luca Barioglio Date: Tue, 6 May 2025 18:03:08 +0200 Subject: [PATCH 1/2] Fix generator path for nuclei with flow --- MC/config/PWGLF/ini/GeneratorLFHyperNucleiPbPbGapWithFlow.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MC/config/PWGLF/ini/GeneratorLFHyperNucleiPbPbGapWithFlow.ini b/MC/config/PWGLF/ini/GeneratorLFHyperNucleiPbPbGapWithFlow.ini index 8debf1065..1eac6c39f 100644 --- a/MC/config/PWGLF/ini/GeneratorLFHyperNucleiPbPbGapWithFlow.ini +++ b/MC/config/PWGLF/ini/GeneratorLFHyperNucleiPbPbGapWithFlow.ini @@ -1,5 +1,5 @@ [GeneratorExternal] -fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_longlived_gaptriggered_flow.C +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_longlived_gaptriggered.C funcName=generateLongLivedGapTriggered("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/hypernuclei_pbpb.gun", 1, 1, 1) [GeneratorPythia8] From 0fcffe18253b909936c10d7eaf3fcb5b5585a1c8 Mon Sep 17 00:00:00 2001 From: Luca Barioglio Date: Wed, 7 May 2025 09:28:36 +0200 Subject: [PATCH 2/2] Add test for GeneratorLFHyperNucleiPbPbGapWithFlow --- .../GeneratorLFHyperNucleiPbPbGapWithFlow.C | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 MC/config/PWGLF/ini/tests/GeneratorLFHyperNucleiPbPbGapWithFlow.C diff --git a/MC/config/PWGLF/ini/tests/GeneratorLFHyperNucleiPbPbGapWithFlow.C b/MC/config/PWGLF/ini/tests/GeneratorLFHyperNucleiPbPbGapWithFlow.C new file mode 100644 index 000000000..0f51674fb --- /dev/null +++ b/MC/config/PWGLF/ini/tests/GeneratorLFHyperNucleiPbPbGapWithFlow.C @@ -0,0 +1,58 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + std::vector possiblePDGs = {1000010020, -1000010020, + 1000010030, -1000010030, + 1000020030, -1000020030, + 1000020040, -1000020040, + 1010010030, -1010010030, + 1010010040, -1010010040}; + + int nPossiblePDGs = possiblePDGs.size(); + + 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); + + std::vector injectedPDGs; + + auto nEvents = tree->GetEntries(); + for (int i = 0; i < nEvents; i++) + { + auto check = tree->GetEntry(i); + for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack) + { + auto track = tracks->at(idxMCTrack); + auto pdg = track.GetPdgCode(); + auto it = std::find(possiblePDGs.begin(), possiblePDGs.end(), pdg); + if (it != possiblePDGs.end() && track.isPrimary()) // found + { + injectedPDGs.push_back(pdg); + } + } + } + std::cout << "--------------------------------\n"; + std::cout << "# Events: " << nEvents << "\n"; + if(injectedPDGs.empty()){ + std::cerr << "No injected particles\n"; + return 1; // At least one of the injected particles should be generated + } + for (int i = 0; i < nPossiblePDGs; i++) + { + std::cout << "# Injected nuclei \n"; + std::cout << possiblePDGs[i] << ": " << std::count(injectedPDGs.begin(), injectedPDGs.end(), possiblePDGs[i]) << "\n"; + } + return 0; +}