diff --git a/MC/config/PWGHF/external/generator/selectNonHfe.C b/MC/config/PWGHF/external/generator/selectNonHfe.C new file mode 100644 index 000000000..7c685c585 --- /dev/null +++ b/MC/config/PWGHF/external/generator/selectNonHfe.C @@ -0,0 +1,96 @@ +/// Select π⁰ and η within a given rapidity window for enhancement +/// pdgPartForAccCut: PDG of the particle to select (111=π⁰, 221=η) +/// minNb: minimum number of such particles per event for enhancement + +//// authors: Rashi Gupta (rashi.gupta@cern.ch) +/// authors: Ravindra Singh (ravindra.singh@cern.ch) + + +#if !defined(__CLING__) || defined(__ROOTCLING__) +#include "FairGenerator.h" +#include "FairPrimaryGenerator.h" +#include "Generators/GeneratorPythia8.h" +#include "TRandom3.h" +#include "TParticlePDG.h" +#include "TDatabasePDG.h" +#include "TMath.h" +#include +#include +#endif + +#include "Pythia8/Pythia.h" +using namespace Pythia8; + +class GeneratorPythia8Box : public o2::eventgen::GeneratorPythia8 +{ +public: + + GeneratorPythia8Box(std::vector pdgList, int nInject = 3, float ptMin = 0.1, float ptMax = 50.0, float etaMin = -0.8, float etaMax = 0.8) + : mPdgList(pdgList), nParticles(nInject), genMinPt(ptMin), genMaxPt(ptMax), genMinEta(etaMin), genMaxEta(etaMax) + { + } + + ~GeneratorPythia8Box() = default; + +Bool_t generateEvent() override +{ + bool hasElectron = false; + + while (!hasElectron) { + mPythia.event.reset(); + + for (int i{0}; i < nParticles; ++i) + { + int currentPdg = mPdgList[gRandom->Integer(mPdgList.size())]; + double mass = TDatabasePDG::Instance()->GetParticle(currentPdg)->Mass(); + + const double pt = gRandom->Uniform(genMinPt, genMaxPt); + const double eta = gRandom->Uniform(genMinEta, genMaxEta); + const double phi = gRandom->Uniform(0, TMath::TwoPi()); + + const double px{pt * std::cos(phi)}; + const double py{pt * std::sin(phi)}; + const double pz{pt * std::sinh(eta)}; + const double et{std::hypot(std::hypot(pt, pz), mass)}; + + + mPythia.event.append(currentPdg, 11, 0, 0, px, py, pz, et, mass); + } + + + if (!mPythia.next()) continue; + + + for (int i = 0; i < mPythia.event.size(); ++i) { + if (std::abs(mPythia.event[i].id()) == 11) { + + + double childPt = mPythia.event[i].pT(); + double childEta = mPythia.event[i].eta(); + + if (childPt > 0.1 && std::abs(childEta) < 1.2) { + hasElectron = true; // Mil gaya! + break; + } + } + } + + } + + return true; +} + +private: + std::vector mPdgList; + double genMinPt, genMaxPt; + double genMinEta, genMaxEta; + int nParticles; +}; + + +FairGenerator *generatePythia8Box(float ptMin = 0.1, float ptMax = 50.0) +{ + + std::vector pdgList = {111, 221}; + return new GeneratorPythia8Box(pdgList, 3, ptMin, ptMax, -0.8, 0.8); +} diff --git a/MC/config/PWGHF/ini/GeneratorHF_Non_Hfe.ini b/MC/config/PWGHF/ini/GeneratorHF_Non_Hfe.ini index 7ed9bb10b..f5455e34d 100644 --- a/MC/config/PWGHF/ini/GeneratorHF_Non_Hfe.ini +++ b/MC/config/PWGHF/ini/GeneratorHF_Non_Hfe.ini @@ -1,4 +1,7 @@ -#### This configuration uses the Hybrid external generator to trigger π⁰/η production within the specified rapidity window - -[GeneratorHybrid] -configFile = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/hybrid/GeneratorHF_Non_Hfe.json +#### This configuration uses the Box generator to trigger π⁰/η production within the specified rapidity window +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/external/generator/selectNonHfe.C +funcName = generatePythia8Box(0.1, 50.0) +[GeneratorPythia8] +config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/pythia8/generator/pythia8_NonHfe.cfg +includePartonEvent=true diff --git a/MC/config/PWGHF/ini/tests/GeneratorHF_Non_Hfe.C b/MC/config/PWGHF/ini/tests/GeneratorHF_Non_Hfe.C index ba9dcb737..fb2c280d9 100644 --- a/MC/config/PWGHF/ini/tests/GeneratorHF_Non_Hfe.C +++ b/MC/config/PWGHF/ini/tests/GeneratorHF_Non_Hfe.C @@ -1,4 +1,4 @@ -int Hybrid() { +int External() { std::string path{"o2sim_Kine.root"}; const int pdgPi0 = 111; diff --git a/MC/config/PWGHF/pythia8/generator/pythia8_NonHfe.cfg b/MC/config/PWGHF/pythia8/generator/pythia8_NonHfe.cfg index b19227718..3feaa6585 100644 --- a/MC/config/PWGHF/pythia8/generator/pythia8_NonHfe.cfg +++ b/MC/config/PWGHF/pythia8/generator/pythia8_NonHfe.cfg @@ -8,11 +8,14 @@ Beams:idB 2212 # proton Beams:eCM 13600. # GeV ### processes -SoftQCD:inelastic on # all inelastic processes + +ProcessLevel:all = off ### decays ParticleDecays:limitTau0 on ParticleDecays:tau0Max 10. +### processes + ### switch off all decay channels 111:onMode = off diff --git a/MC/config/PWGHF/trigger/selectNonHfe.C b/MC/config/PWGHF/trigger/selectNonHfe.C deleted file mode 100644 index 2acfc23fe..000000000 --- a/MC/config/PWGHF/trigger/selectNonHfe.C +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include "Generators/Trigger.h" -#include -#include - -///============================================================================ - -/// Select π⁰ and η within a given rapidity window for enhancement -/// pdgPartForAccCut: PDG of the particle to select (111=π⁰, 221=η) -/// minNb: minimum number of such particles per event for enhancement - -//// authors: Rashi Gupta (rashi.gupta@cern.ch) -/// authors: Ravindra Singh (ravindra.singh@cern.ch) -/// ============================================================================ -o2::eventgen::Trigger selectPionEtaWithinAcc(TString pdgPartForAccCut = "111;221", double rapidityMin = -1.5, double rapidityMax = 1.5, int minNb = 1) -{ - return [pdgPartForAccCut, rapidityMin, rapidityMax, minNb](const std::vector& particles) -> bool { - TObjArray* obj = pdgPartForAccCut.Tokenize(";"); - int count = 0; - for (const auto& particle : particles) { - int pdg = TMath::Abs(particle.GetPdgCode()); - double y = particle.Y(); - - if (y < rapidityMin || y > rapidityMax) continue; - - for (int i = 0; i < obj->GetEntriesFast(); ++i) { - int pdgCode = std::stoi(obj->At(i)->GetName()); - - if (pdg == pdgCode) { - count++; - break; - } - } - } - // Only accept events with at least minNb π⁰/η - if (count >= minNb) - return kTRUE; - else - return kFALSE; - }; -}