Skip to content

Commit 80ed3cf

Browse files
committed
Added user hook for triggered events
1 parent fd75cee commit 80ed3cf

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

MC/config/PWGHF/external/generator/generator_pythia8_hfhadron_to_nuclei.C

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

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

1314
using namespace Pythia8;
1415

@@ -60,6 +61,16 @@ class GeneratorPythia8HFHadToNuclei : public o2::eventgen::GeneratorPythia8
6061
{
6162
addSubGenerator(0, "Minimum bias");
6263
addSubGenerator(1, "HF + Coalescence");
64+
65+
// Bias parton-level generation towards bbbar production at midrapidity, but only
66+
// while generating the triggered events. Without this, finding the requested b-hadron
67+
// can stall the jobs for a very long time
68+
mBbbarBiasHook = new UserHooks_qqbar();
69+
mBbbarBiasHook->setPDG(5);
70+
mBbbarBiasHook->setRapidity(mHadRapidityMin, mHadRapidityMax);
71+
mBbbarBiasHook->setActive(false);
72+
setUserHooks(mBbbarBiasHook);
73+
6374
return o2::eventgen::GeneratorPythia8::Init();
6475
}
6576

@@ -93,11 +104,13 @@ class GeneratorPythia8HFHadToNuclei : public o2::eventgen::GeneratorPythia8
93104

94105
// Generate event of interest
95106
bool genOk = false;
107+
mBbbarBiasHook->setActive(true);
96108
while (!genOk) {
97109
if (GeneratorPythia8::generateEvent()) {
98110
genOk = selectEvent(mPythia.event);
99111
}
100112
}
113+
mBbbarBiasHook->setActive(false);
101114
notifySubGenerator(1);
102115
} else {
103116
// Generate minimum-bias event
@@ -178,6 +191,9 @@ class GeneratorPythia8HFHadToNuclei : public o2::eventgen::GeneratorPythia8
178191
float mHadRapidityMax;
179192
unsigned int mUsedSeed;
180193

194+
// Bias towards bbbar at midrapidity, active only while generating HF-triggered events
195+
UserHooks_qqbar* mBbbarBiasHook{nullptr};
196+
181197
// Control gap-triggering
182198
unsigned long long mGeneratedEvents;
183199
int mInverseTriggerRatio;

MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class UserHooks_qqbar : public Pythia8::UserHooks
1616
bool canVetoPartonLevel() override { return true; };
1717
bool doVetoPartonLevel(const Pythia8::Event& event) override
1818
{
19+
// Veto runtime condition
20+
if (!mActive) {
21+
return false;
22+
}
1923
// search for c-cbar mother with at least one c at midrapidity
2024
for (int ipa = 0; ipa < event.size(); ++ipa) {
2125
auto daughterList = event[ipa].daughterList();
@@ -40,11 +44,15 @@ class UserHooks_qqbar : public Pythia8::UserHooks
4044
mRapidityMin = valMin;
4145
mRapidityMax = valMax;
4246
};
47+
// Allows the veto to be switched on/off at run time, e.g. so that a generator
48+
// alternating between biased and unbiased events can apply the bias selectively.
49+
void setActive(bool val) { mActive = val; };
4350

4451
private:
4552
int mPDG = 4;
4653
double mRapidityMin = -1.5;
4754
double mRapidityMax = 1.5;
55+
bool mActive = true;
4856
};
4957

5058
Pythia8::UserHooks*

0 commit comments

Comments
 (0)