@@ -18,6 +18,7 @@ namespace hf_generators
1818 GapTriggeredBeauty , // --> GeneratorPythia8GapTriggeredBeauty: beauty enriched
1919 GapTriggeredCharmAndBeauty , // --> GeneratorPythia8GapTriggeredCharmAndBeauty: charm and beauty enriched (with same ratio)
2020 GapHF , // --> GeneratorPythia8GapHF
21+ GapHFRatio , // --> GeneratorPythia8GapHF, quark list built from b/c ratio
2122 NGenType
2223 };
2324}
@@ -83,6 +84,12 @@ public:
8384 LOG (info ) << "********** Default number of HF signal events to be merged (updated by notifyEmbedding): " << mNumSigEvs ;
8485 mGeneratorEvHF = dynamic_cast < GeneratorPythia8GapTriggeredHF * > (GeneratorPythia8GapTriggeredBeauty (/*no gap trigger*/ 1 , yQuarkMin , yQuarkMax , yHadronMin , yHadronMax , hadronPdgList , partPdgToReplaceList , freqReplaceList ));
8586 break ;
87+
88+ case hf_generators ::GapHFRatio :
89+ LOG (info ) << "********** [GeneratorPythia8EmbedHF] configuring GapHFRatio (custom b/c ratio) **********" ;
90+ LOG (info ) << "********** Default number of HF signal events to be merged (updated by notifyEmbedding): " << mNumSigEvs ;
91+ mGeneratorEvHF = dynamic_cast < GeneratorPythia8GapTriggeredHF * > (GeneratorPythia8GapHF (/*no gap trigger*/ 1 , yQuarkMin , yQuarkMax , yHadronMin , yHadronMax , quarkPdgList , hadronPdgList , partPdgToReplaceList , freqReplaceList ));
92+ break ;
8693 default :
8794 LOG (fatal ) << "********** [GeneratorPythia8EmbedHF] bad configuration, fix it! **********" ;
8895 break ;
@@ -387,6 +394,44 @@ private:
387394
388395};
389396
397+ // Helper: build quarkPdgList from bOverCRatio (= N(beauty)/N(charm), default 1 = 1:1)
398+ // Integer b/c: taken directly; fractional b/c: reduced to nearest nB:nC with nC+nB <= 20
399+ static std ::vector < int > BuildQuarkListFromBOverC (float bOverCRatio )
400+ {
401+ if (bOverCRatio <= 0.f ) {
402+ LOG (fatal ) << "bOverCRatio (b/c) must be > 0" ;
403+ }
404+ if (bOverCRatio > 19.f ) {
405+ bOverCRatio = 19.f ;
406+ LOG (warn ) << "bOverCRatio (b/c) too large, using 19:1" ;
407+ }else if (bOverCRatio < 1.f /19.f ) {
408+ bOverCRatio = 1.f /19.f ;
409+ LOG (warn ) << "bOverCRatio (b/c) too small, using 1:19" ;
410+ }
411+
412+ int nC = 1 , nB = 1 ;
413+ float bestErr = 1e9f ;
414+ for (int c = 1 ; c <= 19 ; ++ c ) {
415+ int b = (int )std ::lround (bOverCRatio * c );
416+ if (b < 1 || c + b > 20 ) {
417+ continue ;
418+ }
419+ float err = std ::fabs ((float )b / c - bOverCRatio );
420+ if (err < bestErr ) {
421+ bestErr = err ;
422+ nC = c ;
423+ nB = b ;
424+ }
425+ }
426+
427+ std ::vector < int > list ;
428+ // Bresenham interleaving
429+ int len = nC + nB ;
430+ for (int k = 0 ; k < len ; ++ k )
431+ list .push_back ((((k + 1 ) * nC ) / len > (k * nC ) / len ) ? 4 : 5 );
432+ return list ;
433+ }
434+
390435// Charm enriched
391436FairGenerator * GeneratorPythia8EmbedHFCharm (bool usePtHardBins = false, float yQuarkMin = -1.5 , float yQuarkMax = 1.5 , float yHadronMin = -1.5 , float yHadronMax = 1.5 , std ::vector < int > quarkPdgList = {}, std ::vector < int > hadronPdgList = {}, std ::vector < std ::array < int ,2 >> partPdgToReplaceList = {}, std ::vector < float > freqReplaceList = {})
392437{
@@ -420,3 +465,18 @@ FairGenerator * GeneratorPythia8EmbedHFCharmAndBeauty(bool usePtHardBins = false
420465 return myGen ;
421466}
422467
468+ // Charm and beauty enriched with tunable b/c ratio
469+ FairGenerator * GeneratorPythia8EmbedHFRatio (float bOverCRatio = 1.f , bool usePtHardBins = false, float yQuarkMin = -1.5 , float yQuarkMax = 1.5 , float yHadronMin = -1.5 , float yHadronMax = 1.5 , std ::vector < int > hadronPdgList = {}, std ::vector < std ::array < int ,2 >> partPdgToReplaceList = {}, std ::vector < float > freqReplaceList = {})
470+ {
471+ auto myGen = new GeneratorPythia8EmbedHF ();
472+
473+ /// build the quark list from the b/c ratio
474+ auto quarkPdgList = BuildQuarkListFromBOverC (bOverCRatio );
475+
476+ /// setup the internal generator for HF events
477+ myGen -> setupGeneratorEvHF (hf_generators ::GapHFRatio ,
478+ usePtHardBins , yQuarkMin , yQuarkMax , yHadronMin , yHadronMax ,
479+ quarkPdgList , hadronPdgList , partPdgToReplaceList , freqReplaceList );
480+
481+ return myGen ;
482+ }
0 commit comments