Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

R__ADD_INCLUDE_PATH($O2DPG_MC_CONFIG_ROOT)
#include "MC/config/common/external/generator/CoalescencePythia8.h"
#include "MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C"

using namespace Pythia8;

Expand Down Expand Up @@ -60,6 +61,16 @@ class GeneratorPythia8HFHadToNuclei : public o2::eventgen::GeneratorPythia8
{
addSubGenerator(0, "Minimum bias");
addSubGenerator(1, "HF + Coalescence");

// Bias parton-level generation towards bbbar production at midrapidity, but only
// while generating the triggered events. Without this, finding the requested b-hadron
// can stall the jobs for a very long time
mBbbarBiasHook = new UserHooks_qqbar();
mBbbarBiasHook->setPDG(5);
mBbbarBiasHook->setRapidity(mHadRapidityMin, mHadRapidityMax);
mBbbarBiasHook->setActive(false);
setUserHooks(mBbbarBiasHook);

return o2::eventgen::GeneratorPythia8::Init();
}

Expand Down Expand Up @@ -93,11 +104,13 @@ class GeneratorPythia8HFHadToNuclei : public o2::eventgen::GeneratorPythia8

// Generate event of interest
bool genOk = false;
mBbbarBiasHook->setActive(true);
while (!genOk) {
if (GeneratorPythia8::generateEvent()) {
genOk = selectEvent(mPythia.event);
}
}
mBbbarBiasHook->setActive(false);
notifySubGenerator(1);
} else {
// Generate minimum-bias event
Expand Down Expand Up @@ -178,6 +191,9 @@ class GeneratorPythia8HFHadToNuclei : public o2::eventgen::GeneratorPythia8
float mHadRapidityMax;
unsigned int mUsedSeed;

// Bias towards bbbar at midrapidity, active only while generating HF-triggered events
UserHooks_qqbar* mBbbarBiasHook{nullptr};

// Control gap-triggering
unsigned long long mGeneratedEvents;
int mInverseTriggerRatio;
Expand Down
8 changes: 8 additions & 0 deletions MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class UserHooks_qqbar : public Pythia8::UserHooks
bool canVetoPartonLevel() override { return true; };
bool doVetoPartonLevel(const Pythia8::Event& event) override
{
// Veto runtime condition
if (!mActive) {
return false;
}
// search for c-cbar mother with at least one c at midrapidity
for (int ipa = 0; ipa < event.size(); ++ipa) {
auto daughterList = event[ipa].daughterList();
Expand All @@ -40,11 +44,15 @@ class UserHooks_qqbar : public Pythia8::UserHooks
mRapidityMin = valMin;
mRapidityMax = valMax;
};
// Allows the veto to be switched on/off at run time, e.g. so that a generator
// alternating between biased and unbiased events can apply the bias selectively.
void setActive(bool val) { mActive = val; };

private:
int mPDG = 4;
double mRapidityMin = -1.5;
double mRapidityMax = 1.5;
bool mActive = true;
};

Pythia8::UserHooks*
Expand Down
Loading