From a6e70e253a319e4430613450384c2ca48c4d616d Mon Sep 17 00:00:00 2001 From: jesgum Date: Mon, 17 Mar 2025 16:31:31 +0100 Subject: [PATCH] Add XiC injector --- MC/config/ALICE3/ini/tests/xic_PbPb.C | 46 +++++++++++++++++++++++++++ MC/config/ALICE3/ini/tests/xic_pp.C | 46 +++++++++++++++++++++++++++ MC/config/ALICE3/ini/xic_PbPb.ini | 6 ++++ MC/config/ALICE3/ini/xic_pp.ini | 6 ++++ 4 files changed, 104 insertions(+) create mode 100644 MC/config/ALICE3/ini/tests/xic_PbPb.C create mode 100644 MC/config/ALICE3/ini/tests/xic_pp.C create mode 100755 MC/config/ALICE3/ini/xic_PbPb.ini create mode 100755 MC/config/ALICE3/ini/xic_pp.ini diff --git a/MC/config/ALICE3/ini/tests/xic_PbPb.C b/MC/config/ALICE3/ini/tests/xic_PbPb.C new file mode 100644 index 000000000..8286b733b --- /dev/null +++ b/MC/config/ALICE3/ini/tests/xic_PbPb.C @@ -0,0 +1,46 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int pdgToCheck = 4232; + + TFile file(path.c_str(), "read"); + if (file.IsZombie()) { + std::cerr << "Cannot open ROOT file " << path << std::endl; + return 1; + } + + int nInjectedParticles = 0; + TTree* tree = (TTree*)file.Get("o2sim"); + + if (!tree) { + std::cerr << "Cannot find tree o2sim in file " << path << std::endl; + return 1; + } + + std::vector *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + int nEvents = tree->GetEntries(); + for (int i = 0; i < nEvents; i++) { + tree->GetEntry(i); + for (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; +} + + + + diff --git a/MC/config/ALICE3/ini/tests/xic_pp.C b/MC/config/ALICE3/ini/tests/xic_pp.C new file mode 100644 index 000000000..5b531f7b8 --- /dev/null +++ b/MC/config/ALICE3/ini/tests/xic_pp.C @@ -0,0 +1,46 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int pdgToCheck = 4232; + + TFile file(path.c_str(), "read"); + if (file.IsZombie()) { + std::cerr << "Cannot open ROOT file " << path << std::endl; + return 1; + } + + int nInjectedParticles = 0; + TTree* 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); + + int nEvents = tree->GetEntries(); + for (int i = 0; i < nEvents; i++) { + tree->GetEntry(i); + for (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/xic_PbPb.ini b/MC/config/ALICE3/ini/xic_PbPb.ini new file mode 100755 index 000000000..4e8c02141 --- /dev/null +++ b/MC/config/ALICE3/ini/xic_PbPb.ini @@ -0,0 +1,6 @@ +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/ALICE3/pythia8/generator_pythia8_gun_PbPb.C +funcName=generateNativeXiC() + +[GeneratorPythia8] +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/xic_pp.ini b/MC/config/ALICE3/ini/xic_pp.ini new file mode 100755 index 000000000..df8a3d220 --- /dev/null +++ b/MC/config/ALICE3/ini/xic_pp.ini @@ -0,0 +1,6 @@ +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/ALICE3/pythia8/generator_pythia8_gun_pp.C +funcName=generateNativeXiC() + +[GeneratorPythia8] +config=${O2DPG_MC_CONFIG_ROOT}/MC/config/ALICE3/pythia8/generator/config_custom_xicc.cfg \ No newline at end of file