Skip to content

Commit

Permalink
PWGHF: Add possibility to pass pT-hard bins from script (#1674)
Browse files Browse the repository at this point in the history
* PWGHF: Add possibility to pass pT-hard bins from script

* Add missing cast

* Add missing cast

* Fix typo

(cherry picked from commit 96c75a6)
  • Loading branch information
fgrosa authored and alcaliva committed Aug 23, 2024
1 parent 9375939 commit 734cfb7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
17 changes: 16 additions & 1 deletion MC/config/PWGHF/external/generator/generator_pythia8_embed_hf.C
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ public:
LOG(fatal) << "********** [GeneratorPythia8EmbedHF] bad configuration, fix it! **********";
break;
}

// we set pT hard bins
auto seed = dynamic_cast<GeneratorPythia8GapTriggeredHF*>(mGeneratorEvHF)->getUsedSeed();
float ptHardBins[4] = {2.76, 20., 50., 1000.};
int iPt{0};
if (seed % 10 < 7) {
iPt = 0;
} else if (seed % 10 < 9) {
iPt = 1;
} else {
iPt = 2;
}
dynamic_cast<GeneratorPythia8GapTriggeredHF*>(mGeneratorEvHF)->readString(Form("PhaseSpace:pTHatMin = %f", ptHardBins[iPt]));
dynamic_cast<GeneratorPythia8GapTriggeredHF*>(mGeneratorEvHF)->readString(Form("PhaseSpace:pTHatMax = %f", ptHardBins[iPt+1]));
mGeneratorEvHF->Init();
}

Expand Down Expand Up @@ -188,4 +202,5 @@ FairGenerator * GeneratorPythia8EmbedHFCharmAndBeauty(float yQuarkMin = -1.5, fl
myGen->setupGeneratorEvHF(hf_generators::GapTriggeredCharmAndBeauty, yQuarkMin, yQuarkMax, yHadronMin, yHadronMax, hadronPdgList);

return myGen;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ public:
mHadRapidityMin = yMin;
mHadRapidityMax = yMax;
};
void setUsedSeed(unsigned int seed)
{
mUsedSeed = seed;
};
unsigned int getUsedSeed() const
{
return mUsedSeed;
};

protected:
//__________________________________________________________________
Expand Down Expand Up @@ -200,6 +208,7 @@ private:
int mHadronPdg;
float mHadRapidityMin;
float mHadRapidityMax;
unsigned int mUsedSeed;

// Control gap-triggering
unsigned long long mGeneratedEvents;
Expand All @@ -218,6 +227,7 @@ FairGenerator *GeneratorPythia8GapTriggeredCharm(int inputTriggerRatio, float yQ
{
auto myGen = new GeneratorPythia8GapTriggeredHF(inputTriggerRatio, std::vector<int>{4}, hadronPdgList);
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
myGen->setUsedSeed(seed);
myGen->readString("Random:setSeed on");
myGen->readString("Random:seed " + std::to_string(seed));
myGen->setQuarkRapidity(yQuarkMin, yQuarkMax);
Expand All @@ -233,6 +243,7 @@ FairGenerator *GeneratorPythia8GapTriggeredBeauty(int inputTriggerRatio, float y
{
auto myGen = new GeneratorPythia8GapTriggeredHF(inputTriggerRatio, std::vector<int>{5}, hadronPdgList);
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
myGen->setUsedSeed(seed);
myGen->readString("Random:setSeed on");
myGen->readString("Random:seed " + std::to_string(seed));
myGen->setQuarkRapidity(yQuarkMin, yQuarkMax);
Expand All @@ -248,6 +259,7 @@ FairGenerator *GeneratorPythia8GapTriggeredCharmAndBeauty(int inputTriggerRatio,
{
auto myGen = new GeneratorPythia8GapTriggeredHF(inputTriggerRatio, std::vector<int>{4, 5}, hadronPdgList);
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
myGen->setUsedSeed(seed);
myGen->readString("Random:setSeed on");
myGen->readString("Random:seed " + std::to_string(seed));
myGen->setQuarkRapidity(yQuarkMin, yQuarkMax);
Expand All @@ -266,6 +278,7 @@ FairGenerator *GeneratorPythia8GapHF(int inputTriggerRatio, float yQuarkMin = -1
}
auto myGen = new GeneratorPythia8GapTriggeredHF(inputTriggerRatio, quarkPdgList, hadronPdgList);
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
myGen->setUsedSeed(seed);
myGen->readString("Random:setSeed on");
myGen->readString("Random:seed " + std::to_string(seed));
myGen->setQuarkRapidity(yQuarkMin, yQuarkMax);
Expand Down

0 comments on commit 734cfb7

Please sign in to comment.