From cbbe1ac615c1440c9fd8579adaf04861bf7d1ae8 Mon Sep 17 00:00:00 2001 From: jesgum Date: Thu, 13 Mar 2025 12:19:47 +0100 Subject: [PATCH 1/6] Add xi injector for pp and PbPb --- MC/config/ALICE3/ini/tests/xi_PbPb.C | 3 +++ MC/config/ALICE3/ini/tests/xi_pp.C | 3 +++ MC/config/ALICE3/ini/xi_PbPb.ini | 6 ++++++ MC/config/ALICE3/ini/xi_pp.ini | 6 ++++++ 4 files changed, 18 insertions(+) create mode 100644 MC/config/ALICE3/ini/tests/xi_PbPb.C create mode 100644 MC/config/ALICE3/ini/tests/xi_pp.C create mode 100755 MC/config/ALICE3/ini/xi_PbPb.ini create mode 100755 MC/config/ALICE3/ini/xi_pp.ini diff --git a/MC/config/ALICE3/ini/tests/xi_PbPb.C b/MC/config/ALICE3/ini/tests/xi_PbPb.C new file mode 100644 index 000000000..8fb911b19 --- /dev/null +++ b/MC/config/ALICE3/ini/tests/xi_PbPb.C @@ -0,0 +1,3 @@ +int External() { + return 0; +} diff --git a/MC/config/ALICE3/ini/tests/xi_pp.C b/MC/config/ALICE3/ini/tests/xi_pp.C new file mode 100644 index 000000000..8fb911b19 --- /dev/null +++ b/MC/config/ALICE3/ini/tests/xi_pp.C @@ -0,0 +1,3 @@ +int External() { + return 0; +} diff --git a/MC/config/ALICE3/ini/xi_PbPb.ini b/MC/config/ALICE3/ini/xi_PbPb.ini new file mode 100755 index 000000000..49941f2d1 --- /dev/null +++ b/MC/config/ALICE3/ini/xi_PbPb.ini @@ -0,0 +1,6 @@ +[GeneratorExternal] +fileName=${O2DPG_ROOT}/MC/config/ALICE3/pythia8/generator_pythia8_gun_PbPb.C +funcName=generateNativeXi() + +[GeneratorPythia8] +config=${O2DPG_ROOT}/MC/config/ALICE3/pythia8/generator/config_custom_xicc.cfg \ No newline at end of file diff --git a/MC/config/ALICE3/ini/xi_pp.ini b/MC/config/ALICE3/ini/xi_pp.ini new file mode 100755 index 000000000..d00852849 --- /dev/null +++ b/MC/config/ALICE3/ini/xi_pp.ini @@ -0,0 +1,6 @@ +[GeneratorExternal] +fileName=${O2DPG_ROOT}/MC/config/ALICE3/pythia8/generator_pythia8_gun_pp.C +funcName=generateNativeXi() + +[GeneratorPythia8] +config=${O2DPG_ROOT}/MC/config/ALICE3/pythia8/generator/config_custom_xicc.cfg \ No newline at end of file From 601fd107d35c87ec3a0f00bee53a3f7ecdf49366 Mon Sep 17 00:00:00 2001 From: jesgum Date: Thu, 13 Mar 2025 12:22:28 +0100 Subject: [PATCH 2/6] Change to DPG_MC_CONFIG_ROOT --- MC/config/ALICE3/ini/xi_PbPb.ini | 4 ++-- MC/config/ALICE3/ini/xi_pp.ini | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MC/config/ALICE3/ini/xi_PbPb.ini b/MC/config/ALICE3/ini/xi_PbPb.ini index 49941f2d1..efa324ead 100755 --- a/MC/config/ALICE3/ini/xi_PbPb.ini +++ b/MC/config/ALICE3/ini/xi_PbPb.ini @@ -1,6 +1,6 @@ [GeneratorExternal] -fileName=${O2DPG_ROOT}/MC/config/ALICE3/pythia8/generator_pythia8_gun_PbPb.C +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/ALICE3/pythia8/generator_pythia8_gun_PbPb.C funcName=generateNativeXi() [GeneratorPythia8] -config=${O2DPG_ROOT}/MC/config/ALICE3/pythia8/generator/config_custom_xicc.cfg \ No newline at end of file +config=${O2DPG_MC_CONFIG_ROOT}/MC/config/ALICE3/pythia8/generator/config_custom_xicc.cfg \ No newline at end of file diff --git a/MC/config/ALICE3/ini/xi_pp.ini b/MC/config/ALICE3/ini/xi_pp.ini index d00852849..90039ae12 100755 --- a/MC/config/ALICE3/ini/xi_pp.ini +++ b/MC/config/ALICE3/ini/xi_pp.ini @@ -1,6 +1,6 @@ [GeneratorExternal] -fileName=${O2DPG_ROOT}/MC/config/ALICE3/pythia8/generator_pythia8_gun_pp.C +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/ALICE3/pythia8/generator_pythia8_gun_pp.C funcName=generateNativeXi() [GeneratorPythia8] -config=${O2DPG_ROOT}/MC/config/ALICE3/pythia8/generator/config_custom_xicc.cfg \ No newline at end of file +config=${O2DPG_MC_CONFIG_ROOT}/MC/config/ALICE3/pythia8/generator/config_custom_xicc.cfg \ No newline at end of file From 856d118dd73c6f002293b6b953357184a4a713a3 Mon Sep 17 00:00:00 2001 From: jesgum Date: Fri, 14 Mar 2025 14:20:16 +0100 Subject: [PATCH 3/6] Add simple test for the external generator --- MC/config/ALICE3/ini/tests/xi_PbPb.C | 37 ++++++++++++++++++++++++++-- MC/config/ALICE3/ini/tests/xi_pp.C | 37 ++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/MC/config/ALICE3/ini/tests/xi_PbPb.C b/MC/config/ALICE3/ini/tests/xi_PbPb.C index 8fb911b19..e57a542d9 100644 --- a/MC/config/ALICE3/ini/tests/xi_PbPb.C +++ b/MC/config/ALICE3/ini/tests/xi_PbPb.C @@ -1,3 +1,36 @@ -int External() { - return 0; +int External() +{ + std::string path = "o2sim_Kine.root"; + int pdgToCheck = 3312; + + TFile file(path.c_str(), "read"); + if (file.IsZombie()) { + std::err << "Cannot open ROOT file " << path << std::endl; + return 1; + } + + int nInjectedParticles = 0; + TTree* tree = (TTree*)file.Get("o2sim"); + std::vector* tracks; + tree->SetBranchAdress("MCTrack", &tracks) + + int nEvents = tree->GetEntries(); + for (int i = 0; i < nEvents; i++) { + tree->GetEntry(i); + for (const auto& track : tracks) { + auto pdgCode = track.getPdgCode(); + if (pdgCode == pdgToCheck) { + // not injecting anti-particle + nInjectedParticles++; + } + } + } + + if (nInjectedParticles < nEvents) { + // Check that we are correctly injecting one + // particle per event + return 1; + } + + return 0; } diff --git a/MC/config/ALICE3/ini/tests/xi_pp.C b/MC/config/ALICE3/ini/tests/xi_pp.C index 8fb911b19..e28e5d6fa 100644 --- a/MC/config/ALICE3/ini/tests/xi_pp.C +++ b/MC/config/ALICE3/ini/tests/xi_pp.C @@ -1,3 +1,36 @@ -int External() { - return 0; +int External() +{ + std::string path = "o2sim_Kine.root"; + int pdgToCheck = 3312; + + TFile file(path.c_str(), "read"); + if (file.IsZombie()) { + std::err << "Cannot open ROOT file " << path << std::endl; + return 1; + } + + int nInjectedParticles = 0; + TTree* tree = (TTree*)file.Get("o2sim"); + std::vector* tracks; + tree->SetBranchAdress("MCTrack", &tracks) + + int nEvents = tree->GetEntries(); + for (int i = 0; i < nEvents; i++) { + tree->GetEntry(i); + for (const auto& track : tracks) { + auto pdgCode = track.getPdgCode(); + if (pdgCode == pdgToCheck) { + // not injecting anti-particle + nInjectedParticles++; + } + } + } + + if (nInjectedParticles < nEvents) { + // Check that we are correctly injecting 15 + // particle per event + return 1; + } + + return 0; } From eb7372cb8f84355c8e0e016cf203ef1deabffc4b Mon Sep 17 00:00:00 2001 From: jesgum Date: Fri, 14 Mar 2025 14:54:50 +0100 Subject: [PATCH 4/6] Fix typo --- MC/config/ALICE3/ini/tests/xi_PbPb.C | 6 +++--- MC/config/ALICE3/ini/tests/xi_pp.C | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MC/config/ALICE3/ini/tests/xi_PbPb.C b/MC/config/ALICE3/ini/tests/xi_PbPb.C index e57a542d9..11842efd4 100644 --- a/MC/config/ALICE3/ini/tests/xi_PbPb.C +++ b/MC/config/ALICE3/ini/tests/xi_PbPb.C @@ -11,14 +11,14 @@ int External() int nInjectedParticles = 0; TTree* tree = (TTree*)file.Get("o2sim"); - std::vector* tracks; + std::vector* tracks{}; tree->SetBranchAdress("MCTrack", &tracks) int nEvents = tree->GetEntries(); for (int i = 0; i < nEvents; i++) { tree->GetEntry(i); for (const auto& track : tracks) { - auto pdgCode = track.getPdgCode(); + auto pdgCode = track.GetPdgCode(); if (pdgCode == pdgToCheck) { // not injecting anti-particle nInjectedParticles++; @@ -33,4 +33,4 @@ int External() } return 0; -} +} \ No newline at end of file diff --git a/MC/config/ALICE3/ini/tests/xi_pp.C b/MC/config/ALICE3/ini/tests/xi_pp.C index e28e5d6fa..272eab925 100644 --- a/MC/config/ALICE3/ini/tests/xi_pp.C +++ b/MC/config/ALICE3/ini/tests/xi_pp.C @@ -18,7 +18,7 @@ int External() for (int i = 0; i < nEvents; i++) { tree->GetEntry(i); for (const auto& track : tracks) { - auto pdgCode = track.getPdgCode(); + auto pdgCode = track.GetPdgCode(); if (pdgCode == pdgToCheck) { // not injecting anti-particle nInjectedParticles++; From 4ac71704480a619611bbf564338f00b81cf2562a Mon Sep 17 00:00:00 2001 From: jesgum Date: Fri, 14 Mar 2025 15:11:02 +0100 Subject: [PATCH 5/6] fix CI error --- MC/config/ALICE3/ini/tests/xi_PbPb.C | 20 +++++++++++++++----- MC/config/ALICE3/ini/tests/xi_pp.C | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/MC/config/ALICE3/ini/tests/xi_PbPb.C b/MC/config/ALICE3/ini/tests/xi_PbPb.C index 11842efd4..56b344372 100644 --- a/MC/config/ALICE3/ini/tests/xi_PbPb.C +++ b/MC/config/ALICE3/ini/tests/xi_PbPb.C @@ -1,6 +1,6 @@ int External() { - std::string path = "o2sim_Kine.root"; + std::string path{"o2sim_Kine.root"}; int pdgToCheck = 3312; TFile file(path.c_str(), "read"); @@ -11,8 +11,14 @@ int External() int nInjectedParticles = 0; TTree* tree = (TTree*)file.Get("o2sim"); - std::vector* tracks{}; - tree->SetBranchAdress("MCTrack", &tracks) + + if (!tree) { + std::cerr << "Cannot find tree o2sim in file " << path << "\n"; + return 1; + } + + std::vector *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); int nEvents = tree->GetEntries(); for (int i = 0; i < nEvents; i++) { @@ -27,10 +33,14 @@ int External() } if (nInjectedParticles < nEvents) { - // Check that we are correctly injecting one + // Check that we are correctly injecting 15 // particle per event return 1; } return 0; -} \ No newline at end of file +} + + + + diff --git a/MC/config/ALICE3/ini/tests/xi_pp.C b/MC/config/ALICE3/ini/tests/xi_pp.C index 272eab925..905e97d3e 100644 --- a/MC/config/ALICE3/ini/tests/xi_pp.C +++ b/MC/config/ALICE3/ini/tests/xi_pp.C @@ -1,6 +1,6 @@ int External() { - std::string path = "o2sim_Kine.root"; + std::string path{"o2sim_Kine.root"}; int pdgToCheck = 3312; TFile file(path.c_str(), "read"); @@ -11,8 +11,14 @@ int External() int nInjectedParticles = 0; TTree* tree = (TTree*)file.Get("o2sim"); - std::vector* tracks; - tree->SetBranchAdress("MCTrack", &tracks) + + if (!tree) { + std::cerr << "Cannot find tree o2sim in file " << path << "\n"; + return 1; + } + + std::vector *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); int nEvents = tree->GetEntries(); for (int i = 0; i < nEvents; i++) { @@ -27,10 +33,14 @@ int External() } if (nInjectedParticles < nEvents) { - // Check that we are correctly injecting 15 + // Check that we are correctly injecting one // particle per event return 1; } return 0; } + + + + From efa4771fa590ef4c169346811bf608581a87c7ab Mon Sep 17 00:00:00 2001 From: jesgum Date: Fri, 14 Mar 2025 15:37:35 +0100 Subject: [PATCH 6/6] fix CI error --- MC/config/ALICE3/ini/tests/xi_PbPb.C | 6 +++--- MC/config/ALICE3/ini/tests/xi_pp.C | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MC/config/ALICE3/ini/tests/xi_PbPb.C b/MC/config/ALICE3/ini/tests/xi_PbPb.C index 56b344372..5d55db370 100644 --- a/MC/config/ALICE3/ini/tests/xi_PbPb.C +++ b/MC/config/ALICE3/ini/tests/xi_PbPb.C @@ -5,7 +5,7 @@ int External() TFile file(path.c_str(), "read"); if (file.IsZombie()) { - std::err << "Cannot open ROOT file " << path << std::endl; + std::cerr << "Cannot open ROOT file " << path << std::endl; return 1; } @@ -13,7 +13,7 @@ int External() TTree* tree = (TTree*)file.Get("o2sim"); if (!tree) { - std::cerr << "Cannot find tree o2sim in file " << path << "\n"; + std::cerr << "Cannot find tree o2sim in file " << path << std::endl; return 1; } @@ -23,7 +23,7 @@ int External() int nEvents = tree->GetEntries(); for (int i = 0; i < nEvents; i++) { tree->GetEntry(i); - for (const auto& track : tracks) { + for (auto& track : *tracks) { auto pdgCode = track.GetPdgCode(); if (pdgCode == pdgToCheck) { // not injecting anti-particle diff --git a/MC/config/ALICE3/ini/tests/xi_pp.C b/MC/config/ALICE3/ini/tests/xi_pp.C index 905e97d3e..9a09b788e 100644 --- a/MC/config/ALICE3/ini/tests/xi_pp.C +++ b/MC/config/ALICE3/ini/tests/xi_pp.C @@ -5,7 +5,7 @@ int External() TFile file(path.c_str(), "read"); if (file.IsZombie()) { - std::err << "Cannot open ROOT file " << path << std::endl; + std::cerr << "Cannot open ROOT file " << path << std::endl; return 1; } @@ -23,7 +23,7 @@ int External() int nEvents = tree->GetEntries(); for (int i = 0; i < nEvents; i++) { tree->GetEntry(i); - for (const auto& track : tracks) { + for (auto& track : *tracks) { auto pdgCode = track.GetPdgCode(); if (pdgCode == pdgToCheck) { // not injecting anti-particle