From 3a6f38a8e3de606b4703ee77c814988ea22be735 Mon Sep 17 00:00:00 2001 From: Maria Paula Martins Palhares Date: Fri, 25 Oct 2024 16:27:47 +0200 Subject: [PATCH 1/3] PWGLF: Add GeneratorLFLnnPbPb.ini and lnn_pbpb.gun files --- MC/config/PWGLF/ini/GeneratorLFLnnPbPb.ini | 6 ++++++ MC/config/PWGLF/pythia8/generator/lnn_pbpb.gun | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 MC/config/PWGLF/ini/GeneratorLFLnnPbPb.ini create mode 100644 MC/config/PWGLF/pythia8/generator/lnn_pbpb.gun diff --git a/MC/config/PWGLF/ini/GeneratorLFLnnPbPb.ini b/MC/config/PWGLF/ini/GeneratorLFLnnPbPb.ini new file mode 100644 index 000000000..56c7f6fbd --- /dev/null +++ b/MC/config/PWGLF/ini/GeneratorLFLnnPbPb.ini @@ -0,0 +1,6 @@ +[GeneratorExternal] +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/lnn_pbpb.gun", 1) + +[GeneratorPythia8] +config=${O2_ROOT}/share/Generators/egconfig/pythia8_hi.cfg \ No newline at end of file diff --git a/MC/config/PWGLF/pythia8/generator/lnn_pbpb.gun b/MC/config/PWGLF/pythia8/generator/lnn_pbpb.gun new file mode 100644 index 000000000..59ddfa554 --- /dev/null +++ b/MC/config/PWGLF/pythia8/generator/lnn_pbpb.gun @@ -0,0 +1,3 @@ +# PDG N ptMin ptMax yMin yMax +1010000030 10 0.2 10 -1 1 +-1010000030 10 0.2 10 -1 1 \ No newline at end of file From 33a84c4773b27843541b40fec992b01db8613cdc Mon Sep 17 00:00:00 2001 From: Maria Paula Martins Palhares Date: Thu, 21 Nov 2024 17:03:09 +0100 Subject: [PATCH 2/3] add GeneratorLnnPbPb.C --- .../PWGLF/ini/tests/GeneratorLFLnnPbPb.C | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 MC/config/PWGLF/ini/tests/GeneratorLFLnnPbPb.C diff --git a/MC/config/PWGLF/ini/tests/GeneratorLFLnnPbPb.C b/MC/config/PWGLF/ini/tests/GeneratorLFLnnPbPb.C new file mode 100644 index 000000000..5dde77a93 --- /dev/null +++ b/MC/config/PWGLF/ini/tests/GeneratorLFLnnPbPb.C @@ -0,0 +1,61 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int numberOfInjectedSignalsPerEvent{10}; + std::vector injectedPDGs = {1010000030, -1010000030}; + + auto nInjection = injectedPDGs.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 nSignal; + for (int i = 0; i < nInjection; i++) + { + nSignal.push_back(0); + } + + 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(injectedPDGs.begin(), injectedPDGs.end(), pdg); + int index = std::distance(injectedPDGs.begin(), it); // index of injected PDG + if (it != injectedPDGs.end()) // found + { + // count signal PDG + nSignal[index]++; + } + } + } + std::cout << "--------------------------------\n"; + std::cout << "# Events: " << nEvents << "\n"; + for (int i = 0; i < nInjection; i++) + { + std::cout << "# Injected nuclei \n"; + std::cout << injectedPDGs[i] << ": " << nSignal[i] << "\n"; + if (nSignal[i] == 0) + { + std::cerr << "No generated: " << injectedPDGs[i] << "\n"; + return 1; // At least one of the injected particles should be generated + } + } + return 0; +} \ No newline at end of file From 8553f3f0ef5a5fd59b44004be8ce7c9646091b7c Mon Sep 17 00:00:00 2001 From: Maria Paula Martins Palhares Date: Thu, 21 Nov 2024 19:06:10 +0100 Subject: [PATCH 3/3] Fix configuration --- .../PWGLF/ini/tests/GeneratorLFLnnPbPb.C | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/MC/config/PWGLF/ini/tests/GeneratorLFLnnPbPb.C b/MC/config/PWGLF/ini/tests/GeneratorLFLnnPbPb.C index 5dde77a93..d96a1d08c 100644 --- a/MC/config/PWGLF/ini/tests/GeneratorLFLnnPbPb.C +++ b/MC/config/PWGLF/ini/tests/GeneratorLFLnnPbPb.C @@ -1,10 +1,9 @@ int External() { std::string path{"o2sim_Kine.root"}; - int numberOfInjectedSignalsPerEvent{10}; - std::vector injectedPDGs = {1010000030, -1010000030}; + std::vector possiblePDGs = {1010000030, -1010000030}; - auto nInjection = injectedPDGs.size(); + int nPossiblePDGs = possiblePDGs.size(); TFile file(path.c_str(), "READ"); if (file.IsZombie()) @@ -22,11 +21,7 @@ int External() std::vector *tracks{}; tree->SetBranchAddress("MCTrack", &tracks); - std::vector nSignal; - for (int i = 0; i < nInjection; i++) - { - nSignal.push_back(0); - } + std::vector injectedPDGs; auto nEvents = tree->GetEntries(); for (int i = 0; i < nEvents; i++) @@ -36,26 +31,23 @@ int External() { auto track = tracks->at(idxMCTrack); auto pdg = track.GetPdgCode(); - auto it = std::find(injectedPDGs.begin(), injectedPDGs.end(), pdg); - int index = std::distance(injectedPDGs.begin(), it); // index of injected PDG - if (it != injectedPDGs.end()) // found + auto it = std::find(possiblePDGs.begin(), possiblePDGs.end(), pdg); + if (it != possiblePDGs.end() && track.isPrimary()) // found { - // count signal PDG - nSignal[index]++; + injectedPDGs.push_back(pdg); } } } std::cout << "--------------------------------\n"; std::cout << "# Events: " << nEvents << "\n"; - for (int i = 0; i < nInjection; i++) + 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 << injectedPDGs[i] << ": " << nSignal[i] << "\n"; - if (nSignal[i] == 0) - { - std::cerr << "No generated: " << injectedPDGs[i] << "\n"; - return 1; // At least one of the injected particles should be generated - } + std::cout << possiblePDGs[i] << ": " << std::count(injectedPDGs.begin(), injectedPDGs.end(), possiblePDGs[i]) << "\n"; } return 0; } \ No newline at end of file