diff --git a/MC/config/PWGLF/ini/GeneratorLF_Strangeness_ppLStar_gap3.ini b/MC/config/PWGLF/ini/GeneratorLF_Strangeness_ppLStar_gap3.ini new file mode 100644 index 000000000..d96b90e48 --- /dev/null +++ b/MC/config/PWGLF/ini/GeneratorLF_Strangeness_ppLStar_gap3.ini @@ -0,0 +1,7 @@ +#---> GeneratorLF_Strangeness_ppLStar +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_Lstar.C +funcName=generator_Lstar(3) + +[GeneratorPythia8] +config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_forceLStar.cfg diff --git a/MC/config/PWGLF/ini/GeneratorLF_Strangeness_ppLStar_gap4.ini b/MC/config/PWGLF/ini/GeneratorLF_Strangeness_ppLStar_gap4.ini new file mode 100644 index 000000000..3f57505d4 --- /dev/null +++ b/MC/config/PWGLF/ini/GeneratorLF_Strangeness_ppLStar_gap4.ini @@ -0,0 +1,7 @@ +#---> GeneratorLF_Strangeness_ppLStar +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_Lstar.C +funcName=generator_Lstar(4) + +[GeneratorPythia8] +config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_forceLStar.cfg diff --git a/MC/config/PWGLF/ini/tests/GeneratorLF_Strangeness_ppLStar.C b/MC/config/PWGLF/ini/tests/GeneratorLF_Strangeness_ppLStar.C index c69a84d5d..3b4982996 100644 --- a/MC/config/PWGLF/ini/tests/GeneratorLF_Strangeness_ppLStar.C +++ b/MC/config/PWGLF/ini/tests/GeneratorLF_Strangeness_ppLStar.C @@ -1,8 +1,7 @@ int External() { std::string path{"o2sim_Kine.root"}; - const int pdgMother = 3124; // Lambda(1520)0 - const int triggerRatio = 5; // must match generator_Lstar(N) in the .ini file + const int pdgMother = 3124; // Lambda(1520)0 TFile file(path.c_str(), "READ"); if (file.IsZombie()) { @@ -20,19 +19,12 @@ int External() const auto nEvents = tree->GetEntries(); int nMother = 0; int nNotDecayed = 0; - int nBadDecay = 0; // mothers not decaying exactly to Lambda + gamma - int nEventsWrongCount = 0; // events with the wrong number of injected mothers - int nGapEvents = 0; // events expected to contain the injected mother + int nBadDecay = 0; // mothers not decaying exactly to Lambda + gamma + std::vector motherPerEvent; // number of injected mothers in each event for (int i = 0; i < nEvents; i++) { tree->GetEntry(i); - // the generator injects in every triggerRatio-th event (it counts events from 1) - const bool isGapEvent = ((i + 1) % triggerRatio == 0); - if (isGapEvent) { - nGapEvents++; - } - int nInEvent = 0; for (auto &track : *tracks) { const int pdg = track.GetPdgCode(); @@ -59,30 +51,52 @@ int External() std::cerr << "Unexpected decay of " << pdg << " (" << nDau << " daughters)\n"; } } + motherPerEvent.push_back(nInEvent); + } - const int nExpected = isGapEvent ? 1 : 0; - if (nInEvent != nExpected) { - nEventsWrongCount++; - std::cerr << "Event " << i << ": found " << nInEvent - << " Lambda(1520), expected " << nExpected << "\n"; + // the trigger ratio is inferred from the first event containing a mother + // (the generator counts events from 1 and injects every triggerRatio-th event) + int triggerRatio = 0; + for (int i = 0; i < nEvents; i++) { + if (motherPerEvent[i] > 0) { + triggerRatio = i + 1; + break; + } + } + + int nEventsWrongCount = 0; + int nGapEvents = 0; + if (triggerRatio > 0) { + for (int i = 0; i < nEvents; i++) { + const bool isGapEvent = ((i + 1) % triggerRatio == 0); + if (isGapEvent) { + nGapEvents++; + } + const int nExpected = isGapEvent ? 1 : 0; + if (motherPerEvent[i] != nExpected) { + nEventsWrongCount++; + std::cerr << "Event " << i << ": found " << motherPerEvent[i] + << " Lambda(1520), expected " << nExpected << "\n"; + } } } std::cout << "--------------------------------\n"; std::cout << "# Events: " << nEvents << "\n"; - std::cout << "# Gap-trigger events: " << nGapEvents << " (ratio " << triggerRatio << ")\n"; + std::cout << "# Inferred trigger ratio: " << triggerRatio << "\n"; + std::cout << "# Gap-trigger events: " << nGapEvents << "\n"; std::cout << "# Lambda(1520) + anti: " << nMother << "\n"; std::cout << "# not decayed: " << nNotDecayed << "\n"; std::cout << "# unexpected decays: " << nBadDecay << "\n"; std::cout << "# events wrong count: " << nEventsWrongCount << "\n"; std::cout << "--------------------------------\n"; - if (nMother != nGapEvents) { - std::cerr << "Expected one injected Lambda(1520) per gap-trigger event\n"; + if (triggerRatio == 0) { + std::cerr << "No Lambda(1520) found in any event\n"; return 1; } - if (nEventsWrongCount > 0) { - std::cerr << "Lambda(1520) must appear in every gap-triggered events\n"; + if (nMother != nGapEvents || nEventsWrongCount > 0) { + std::cerr << "Lambda(1520) must appear exactly once every triggerRatio events\n"; return 1; } if (nNotDecayed > 0 || nBadDecay > 0) { diff --git a/MC/config/PWGLF/pythia8/generator_pythia8_Lstar.C b/MC/config/PWGLF/pythia8/generator_pythia8_Lstar.C index 3a732db28..aec043dfe 100644 --- a/MC/config/PWGLF/pythia8/generator_pythia8_Lstar.C +++ b/MC/config/PWGLF/pythia8/generator_pythia8_Lstar.C @@ -1,3 +1,7 @@ +#include "Framework/Logger.h" + +#if !defined(__CLING__) || defined(__ROOTCLING__) + #include "Pythia8/Pythia.h" #include "Pythia8/HeavyIons.h" #include "FairGenerator.h" @@ -5,12 +9,11 @@ #include "Generators/GeneratorPythia8.h" #include "TF1.h" #include "TRandom3.h" -//#include "TParticlePDG.h" -//#include "TDatabasePDG.h" - #include #include +#endif + class GeneratorPythia8ExtraStrangeness : public o2::eventgen::GeneratorPythia8 { public: @@ -268,4 +271,4 @@ private: { auto myGen = new GeneratorPythia8ExtraStrangeness(3124, inputTriggerRatio); return myGen; - } \ No newline at end of file + }