Skip to content

Commit

Permalink
Extend HF ccbar embedding becnhmark to bbbar as well
Browse files Browse the repository at this point in the history
  • Loading branch information
preghenella authored and gconesab committed Jun 3, 2021
1 parent dcabe31 commit bcd2f4c
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 11 deletions.
31 changes: 28 additions & 3 deletions MC/config/PWGHF/external/generator/GeneratorHF.C
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public:
int findAncestor(Pythia8::Event& event) {
for (int ipa = 0; ipa < event.size(); ++ipa) {
auto daughterList = event[ipa].daughterList();
bool hasc = false, hascbar = false, atmidy = false;
bool hasq = false, hasqbar = false, atmidy = false;
for (auto ida : daughterList) {
if (event[ida].id() == 4) hasc = true;
if (event[ida].id() == -4) hascbar = true;
if (event[ida].id() == mPDG) hasq = true;
if (event[ida].id() == -mPDG) hasqbar = true;
if (fabs(event[ida].y()) < mRapidity) atmidy = true;
}
if (hasc && hascbar && atmidy)
Expand All @@ -88,6 +88,7 @@ public:
return -1;
};

int setPDG(int val) { mPDG = val; };
void setRapidity(double val) { mRapidity = val; };
void setVerbose(bool val) { mVerbose = val; };
void setFormula(std::string val) { mFormula.Compile(val.c_str()); };
Expand All @@ -97,6 +98,7 @@ private:
TFormula mFormula;
int mEvents = 1;
Pythia8::Event mOutputEvent;
int mPDG = 4;
double mRapidity = 1.5;
bool mVerbose = false;

Expand All @@ -117,4 +119,27 @@ GeneratorHF(double rapidity = 1.5, bool verbose = false)
return gen;
}

FairGenerator*
GeneratorHF_ccbar(double rapidity = 1.5, bool verbose = false)
{
auto gen = new o2::eventgen::GeneratorHF();
gen->setPDG(4);
gen->setRapidity(rapidity);
gen->setVerbose(verbose);
gen->setFormula("max(1.,120.*(x<5.)+80.*(1.-x/20.)*(x>5.)*(x<11.)+240.*(1.-x/13.)*(x>11.))");

return gen;
}

FairGenerator*
GeneratorHF_bbbar(double rapidity = 1.5, bool verbose = false)
{
auto gen = new o2::eventgen::GeneratorHF();
gen->setPDG(5);
gen->setRapidity(rapidity);
gen->setVerbose(verbose);
gen->setFormula("max(1.,120.*(x<5.)+80.*(1.-x/20.)*(x>5.)*(x<11.)+240.*(1.-x/13.)*(x>11.))");

return gen;
}

2 changes: 1 addition & 1 deletion MC/config/PWGHF/ini/GeneratorHF.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ funcName = GeneratorHF()

[GeneratorPythia8]
config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8.cfg
hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_ccbar.C
hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C
hooksFuncName = pythia8_userhooks_ccbar(1.5)

### The setup uses the base configuration of the decayer which is loaded from the file specified by config[0].
Expand Down
34 changes: 34 additions & 0 deletions MC/config/PWGHF/ini/GeneratorHF_bbbar.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### The setup uses an external event generator
### This part sets the path of the file and the function call to retrieve it

[GeneratorExternal]
fileName = ${O2DPG_ROOT}/MC/config/PWGHF/external/generator/GeneratorHF.C
funcName = GeneratorHF_bbar()

### The external generator derives from GeneratorPythia8.
### This part configures the bits of the interface: configuration and user hooks

[GeneratorPythia8]
config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8.cfg
hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C
hooksFuncName = pythia8_userhooks_bbbar(1.5)

### The setup uses the base configuration of the decayer which is loaded from the file specified by config[0].
### On top of the base configuration, two more sets of settings are loaded sequentially from config[1] and [2].

[DecayerPythia8]
config[0] = ${O2DPG_ROOT}/MC/config/common/pythia8/decayer/base.cfg
config[1] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D.cfg
config[2] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D_use4bodies.cfg

### The setup forces some particles to be decayed by the external decayer instead of Geant.
### The PDG list of the particles is specified below.

[SimUserDecay]
pdglist = 411 421 431 4112 4122 4232 4132

### The setup inhibits transport of primary particles which are produce at forward rapidity.
### The settings below only transports particles in the barrel, which is currently defined as |eta| < 2

[Stack]
transportPrimary = barrel
34 changes: 34 additions & 0 deletions MC/config/PWGHF/ini/GeneratorHF_ccbar.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### The setup uses an external event generator
### This part sets the path of the file and the function call to retrieve it

[GeneratorExternal]
fileName = ${O2DPG_ROOT}/MC/config/PWGHF/external/generator/GeneratorHF.C
funcName = GeneratorHF_ccbar()

### The external generator derives from GeneratorPythia8.
### This part configures the bits of the interface: configuration and user hooks

[GeneratorPythia8]
config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8.cfg
hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C
hooksFuncName = pythia8_userhooks_ccbar(1.5)

### The setup uses the base configuration of the decayer which is loaded from the file specified by config[0].
### On top of the base configuration, two more sets of settings are loaded sequentially from config[1] and [2].

[DecayerPythia8]
config[0] = ${O2DPG_ROOT}/MC/config/common/pythia8/decayer/base.cfg
config[1] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D.cfg
config[2] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D_use4bodies.cfg

### The setup forces some particles to be decayed by the external decayer instead of Geant.
### The PDG list of the particles is specified below.

[SimUserDecay]
pdglist = 411 421 431 4112 4122 4232 4132

### The setup inhibits transport of primary particles which are produce at forward rapidity.
### The settings below only transports particles in the barrel, which is currently defined as |eta| < 2

[Stack]
transportPrimary = barrel
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/// \author R+Preghenella - July 2020

/// This Pythia8 UserHooks can veto the processing at parton level.
/// The partonic event is scanned searching for a c-cbar mother
/// The partonic event is scanned searching for a q-qbar mother
/// with at least one of the c quarks produced withing a fiducial
/// window around midrapidity that can be specified by the user.

#include "Pythia8/Pythia.h"

class UserHooks_ccbar : public Pythia8::UserHooks
class UserHooks_qqbar : public Pythia8::UserHooks
{

public:
UserHooks_ccbar() = default;
~UserHooks_ccbar() = default;
UserHooks_qqbar() = default;
~UserHooks_qqbar() = default;
bool canVetoPartonLevel() override { return true; };
bool doVetoPartonLevel(const Pythia8::Event& event) override {
// 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();
bool hasc = false, hascbar = false, atmidy = false;
for (auto ida : daughterList) {
if (event[ida].id() == 4) hasc = true;
if (event[ida].id() == -4) hascbar = true;
if (event[ida].id() == mPDG) hasc = true;
if (event[ida].id() == -mPDG) hascbar = true;
if (fabs(event[ida].y()) < mRapidity) atmidy = true;
}
if (hasc && hascbar && atmidy)
Expand All @@ -30,18 +30,31 @@ class UserHooks_ccbar : public Pythia8::UserHooks
return true; // did not find it, veto event
};

void setPDG(int val) { mPDG = val; };
void setRapidity(double val) { mRapidity = val; };

private:

int mPDG = 4;
double mRapidity = 1.5;

};

Pythia8::UserHooks*
pythia8_userhooks_ccbar(double rapidity = 1.5)
{
auto hooks = new UserHooks_ccbar();
auto hooks = new UserHooks_qqbar();
hooks->setPDG(4);
hooks->setRapidity(rapidity);
return hooks;
}

Pythia8::UserHooks*
pythia8_userhooks_bbbar(double rapidity = 1.5)
{
auto hooks = new UserHooks_qqbar();
hooks->setPDG(5);
hooks->setRapidity(rapidity);
return hooks;
}

0 comments on commit bcd2f4c

Please sign in to comment.